diff options
author | Jerome Forissier <jerome@forissier.org> | 2020-07-31 11:30:54 +0200 |
---|---|---|
committer | Jérôme Forissier <jerome@forissier.org> | 2020-08-03 13:10:36 +0200 |
commit | 5500d70387c7d8097417cf391ea66f82fce605c0 (patch) | |
tree | 6102fd04c6ccb01f082bba434abeb0071350502b | |
parent | 0c33be7a1240bcb4b2418f6ef16e193496fc38ea (diff) |
symbolize.py: infer PC from (E)LR
When translating a call stack address to source file and line number,
subtract 2 to try and reflect the PC at the time the call was made or
the exception occurred. This makes the calls easier to follow and
corresponds to what the GDB backtrace command (bt) does. For data or
prefetch aborts it is even more important because now we report exactly
the line that caused the abort instead of showing the next one, which
could be misleading.
As a result of this fix, the extra "nop" instruction in __ta_entry() is
not needed anymore so remove it.
Signed-off-by: Jerome Forissier <jerome@forissier.org>
Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org>
-rwxr-xr-x | scripts/symbolize.py | 10 | ||||
-rw-r--r-- | ta/arch/arm/ta_entry_a32.S | 5 |
2 files changed, 9 insertions, 6 deletions
diff --git a/scripts/symbolize.py b/scripts/symbolize.py index a00962ec..91d06815 100755 --- a/scripts/symbolize.py +++ b/scripts/symbolize.py @@ -385,7 +385,15 @@ class Symbolizer(object): post = match.end('addr') self._out.write(line[:pre]) self._out.write(addr) - res = self.resolve(addr) + # The call stack contains return addresses (LR/ELR values). + # Heuristic: subtract 2 to obtain the call site of the function + # or the location of the exception. This value works for A64, + # A32 as well as Thumb. + pc = 0 + lr = int(addr, 16) + if lr: + pc = lr - 2 + res = self.resolve('0x{:x}'.format(pc)) res = self.pretty_print_path(res) self._out.write(' ' + res) self._out.write(line[post:]) diff --git a/ta/arch/arm/ta_entry_a32.S b/ta/arch/arm/ta_entry_a32.S index f9325455..e3ef0e33 100644 --- a/ta/arch/arm/ta_entry_a32.S +++ b/ta/arch/arm/ta_entry_a32.S @@ -25,10 +25,5 @@ FUNC __ta_entry, : UNWIND( .fnstart) UNWIND( .cantunwind) bl __ta_entry_c - /* - * The nop makes the stack unwinding more clear (without it, - * symbolize.py may show a file/line outside the function). - */ - nop UNWIND( .fnend) END_FUNC __ta_entry |