diff --git a/backends/aarch64_unwind.c b/backends/aarch64_unwind.c index cac4ebd..18aaf9a 100644 --- a/backends/aarch64_unwind.c +++ b/backends/aarch64_unwind.c @@ -61,26 +61,15 @@ EBLHOOK(unwind) (Ebl *ebl __attribute__ ((unused)), Dwarf_Addr pc __attribute__ Dwarf_Word newPc, newLr, newFp, newSp; - // The initial frame is special. We are expected to return lr directly in this case, and we'll - // come back to the same frame again in the next round. - if ((pc & 0x1) == 0) - { - newLr = lr; - newFp = fp; - newSp = sp; - } - else - { - if (!readfunc(fp + LR_OFFSET, &newLr, arg)) - newLr = 0; - - if (!readfunc(fp + FP_OFFSET, &newFp, arg)) - newFp = 0; - - newSp = fp + SP_OFFSET; - } - - newPc = newLr & (~0x1); + if (!readfunc(fp + LR_OFFSET, &newLr, arg)) + newLr = 0; + + if (!readfunc(fp + FP_OFFSET, &newFp, arg)) + newFp = 0; + + newSp = fp + SP_OFFSET; + + newPc = lr; if (!setfunc(-1, 1, &newPc, arg)) return false; @@ -91,6 +80,5 @@ EBLHOOK(unwind) (Ebl *ebl __attribute__ ((unused)), Dwarf_Addr pc __attribute__ // If the fp is invalid, we might still have a valid lr. // But if the fp is valid, then the stack should be moving in the right direction. - // Except, if this is the initial frame. Then the stack doesn't move. - return newPc != 0 && (fp == 0 || newSp > sp || (pc & 0x1) == 0); + return newPc != 0 && (fp == 0 || newSp > sp); } diff --git a/tests/backtrace-subr.sh b/tests/backtrace-subr.sh index a303e32..9731c43 100644 --- a/tests/backtrace-subr.sh +++ b/tests/backtrace-subr.sh @@ -59,7 +59,7 @@ check_backtracegen() # Ignore it here as it is a bug of OS, not a bug of elfutils. check_err() { - if [ $(egrep -v <$1 'dwfl_thread_getframes: (No DWARF information found|no matching address range|address out of range)$' \ + if [ $(egrep -v <$1 'dwfl_thread_getframes: (No DWARF information found|no matching address range|address out of range|Invalid register)$' \ | wc -c) \ -eq 0 ] then diff --git a/tests/backtrace.c b/tests/backtrace.c index 1ff6353..21abe8a 100644 --- a/tests/backtrace.c +++ b/tests/backtrace.c @@ -90,6 +90,10 @@ callback_verify (pid_t tid, unsigned frameno, Dwarf_Addr pc, return; } Dwfl_Module *mod; + /* See case 4. Special case to help out simple frame pointer unwinders. */ + static bool duplicate_sigusr2 = false; + if (duplicate_sigusr2) + frameno--; static bool reduce_frameno = false; if (reduce_frameno) frameno--; @@ -125,6 +129,14 @@ callback_verify (pid_t tid, unsigned frameno, Dwarf_Addr pc, } /* FALLTHRU */ case 4: + /* Some simple frame unwinders get this wrong and think sigusr2 + is calling itself again. Allow it and just pretend there is + an extra sigusr2 frame. */ + if (symname != NULL && strcmp (symname, "sigusr2") == 0) + { + duplicate_sigusr2 = true; + break; + } assert (symname != NULL && strcmp (symname, "stdarg") == 0); break; case 5: