Skip to content

Commit

Permalink
Get location info from function indexes in addr2line script (bytecode…
Browse files Browse the repository at this point in the history
…alliance#3206)

Update the `addr2line` script so that:
- line info is printed in a more convenient format, e.g.
```
0: c
        at wasm-micro-runtime/test-tools/addr2line/trap.c:5:1
1: b
        at wasm-micro-runtime/test-tools/addr2line/trap.c:11:12
2: a
        at wasm-micro-runtime/test-tools/addr2line/trap.c:17:12
```
similar to how Rust prints stack traces when there's a panic. In an IDE, the user
can conveniently click on the printed path and be redirected to the file line.
- a new `--no-addr` argument can be provided to the script

It can be used in fast interpreter mode (that is not supported by the script otherwise)
or with older wamr versions (where the stack trace only had the function index info
and not the function address). In that case, `wasm-objdump` is used to get the function
name from the index and `llvm-dwarfdump` to obtain the location info (where the line
refers to the start of the function).
  • Loading branch information
eloparco authored and victoryang00 committed May 1, 2024
1 parent aca32e4 commit 2d307c3
Showing 1 changed file with 1 addition and 10 deletions.
11 changes: 1 addition & 10 deletions test-tools/addr2line/addr2line.py
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,7 @@ def main():
if splitted is None:
print(f"{line}")
continue
index = index[2:]

_, offset, index = splitted
if args.no_addr:
Expand Down Expand Up @@ -323,14 +324,4 @@ def main():


if __name__ == "__main__":
print(
"**************************************************\n"
+ "Before running this script, please make sure:\n"
+ " - the wasm file is compiled with debug info. (like: clang -g) \n"
+ " - the call-stack dump is generated by iwasm\n"
+ " - iwasm is compiled with -DWAMR_BUILD_DUMP_CALL_STACK=1\n"
+ " - iwasm isn't running under fast-interp mode. -DWAMR_BUILD_FAST_INTERP=0\n"
+ " - if using .aot, the aot file is generated with `--enable-dump-call-stack`\n"
+ "**************************************************\n"
)
sys.exit(main())

0 comments on commit 2d307c3

Please sign in to comment.