Lenny, please try an attached patch (
https://github.com/keenetic/libunwind/commit/d746635d2b8d44b3dddbc333cfcd32f9fe8b213d
).

>From d746635d2b8d44b3dddbc333cfcd32f9fe8b213d Mon Sep 17 00:00:00 2001
From: Sergey Korolev <s.koro...@ndmsystems.com>
Date: Tue, 22 Jan 2019 23:56:38 +0300
Subject: [PATCH] mips: fix regression after "Handle Gstep according
the N64/N32 ABI"

unw_step should return zero for _MIPS_SIM != _ABI64 when dwarf_step failed
(restore unw_step behaviour before
5eec9a2ecb9a93996d566bbfbcdbe006f64b7e16).
---
 src/mips/Gstep.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/src/mips/Gstep.c b/src/mips/Gstep.c
index f5a742e1..b967dd89 100644
--- a/src/mips/Gstep.c
+++ b/src/mips/Gstep.c
@@ -208,11 +208,14 @@ unw_step (unw_cursor_t *cursor)
   if (unlikely (ret == -UNW_ESTOPUNWIND))
     return ret;

-#if _MIPS_SIM == _ABI64
   if (unlikely (ret < 0))
     {
+#if _MIPS_SIM == _ABI64
       return _step_n64(c);
-    }
+#else
+      return ret;
 #endif
+    }
+
   return (c->dwarf.ip == 0) ? 0 : 1;
 }
-- 
2.25.1

On Tue, Jun 8, 2021 at 11:39 PM Story, Lenny <lst...@irobot.com> wrote:

> Greetings,
>
> I have a test of libunwind running on my mips target.  It seems the the
> unw_step api always returns > 0. This results in my backtrace loop never
> terminating.
>
> Any thoughts on why this would happen ?
>
> Thanks !
> -Lenny
>
> I am using 1.5.0.
>
>  [BACKTRACE] (1) main:140
>  [BACKTRACE] (1) _init:736
>  [BACKTRACE] (1) _init:736
>  [BACKTRACE] (1) _init:736
>  [BACKTRACE] (1) _init:736
>  [BACKTRACE] (1) _init:736
>  [BACKTRACE] (1) _init:736
>  [BACKTRACE] (1) _init:736
>  [BACKTRACE] (1) _init:736
>  [BACKTRACE] (1) _init:736
>  [BACKTRACE] (1) _init:736
>  [BACKTRACE] (1) _init:736
>
>
> void show_backtrace(void)
> {
>     char symbol[256];
>     unw_cursor_t  cursor;
>     unw_context_t context;
>
>     unw_getcontext(&context);
>     unw_init_local(&cursor, &context);
>
>     int Cursor_Result = 0;
>
>     int n = 0;
>
>     while((Cursor_Result = unw_step(&cursor)) > 0)
>     {
>         unw_word_t ip;
>         unw_word_t sp;
>         unw_word_t off;
>
>         unw_get_reg(&cursor, UNW_REG_IP, &ip);
>         unw_get_reg(&cursor, UNW_REG_SP, &sp);
>
>         memset(&symbol, 0, sizeof(symbol));
>
>         if (unw_get_proc_name(&cursor, &symbol[0], sizeof(symbol), &off)
> == 0)
>         {
>             fprintf(stdout, "[BACKTRACE] (%d) %s:%d \n", Cursor_Result,
> &symbol[0], off);
>         }
>
>         if(n++ > 10)
>             break;
>     }
> }
>
>
> *This e-mail message and any files attached may contain information that
> iRobot Corporation considers confidential and/or proprietary or may later
> designate as confidential and proprietary. If you are not the intended
> recipient, please contact the sender and delete the email immediately.
> Unauthorized use or distribution is strictly prohibited.*
>
From d746635d2b8d44b3dddbc333cfcd32f9fe8b213d Mon Sep 17 00:00:00 2001
From: Sergey Korolev <s.koro...@ndmsystems.com>
Date: Tue, 22 Jan 2019 23:56:38 +0300
Subject: [PATCH] mips: fix regression after "Handle Gstep according the
 N64/N32 ABI"

unw_step should return zero for _MIPS_SIM != _ABI64 when dwarf_step failed
(restore unw_step behaviour before 5eec9a2ecb9a93996d566bbfbcdbe006f64b7e16).
---
 src/mips/Gstep.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/src/mips/Gstep.c b/src/mips/Gstep.c
index f5a742e1..b967dd89 100644
--- a/src/mips/Gstep.c
+++ b/src/mips/Gstep.c
@@ -208,11 +208,14 @@ unw_step (unw_cursor_t *cursor)
   if (unlikely (ret == -UNW_ESTOPUNWIND))
     return ret;
 
-#if _MIPS_SIM == _ABI64
   if (unlikely (ret < 0))
     {
+#if _MIPS_SIM == _ABI64
       return _step_n64(c);
-    }
+#else
+      return ret;
 #endif
+    }
+
   return (c->dwarf.ip == 0) ? 0 : 1;
 }
-- 
2.25.1

Reply via email to