Stream: general

Topic: How to symbolicate stack traces


view this post on Zulip Enrico Loparco (Dec 12 2023 at 09:41):

Given a wasm file that has been stripped of debug symbols with wasm-opt, the original wasm file (with debug symbols) and a stack trace from WAMR:

#00 $f117
#01 $f109
#02 $f108
#03 $f97
#04 $f96
#05 $f103
#06 $f176
#07 $f14
#08 $f15
#09 $f16
#10 $f17
#11 $f12
#12 $f21
#13 $f20
#14 $f64
#15 $f19
#16 __main_void
#17 _start

or Wasmtime:

0: 0x4590 - <unknown>!<wasm function 117>
           1: 0x4433 - <unknown>!<wasm function 109>
           2: 0x43d4 - <unknown>!<wasm function 108>
           3: 0x3791 - <unknown>!<wasm function 97>
           4: 0x370a - <unknown>!<wasm function 96>
           5: 0x3e08 - <unknown>!<wasm function 103>
           6: 0x8a1a - <unknown>!<wasm function 176>
           7:  0x5dc - <unknown>!<wasm function 14>
           8:  0x5e3 - <unknown>!<wasm function 15>
           9:  0x5e9 - <unknown>!<wasm function 16>
          10:  0x5ef - <unknown>!<wasm function 17>
          11:  0x559 - <unknown>!<wasm function 12>
          12:  0x721 - <unknown>!<wasm function 21>
          13:  0x6c1 - <unknown>!<wasm function 20>
          14: 0x1c43 - <unknown>!<wasm function 64>
          15:  0x66e - <unknown>!<wasm function 19>
          16:  0x60b - <unknown>!<wasm function 18>
          17:  0x390 - <unknown>!<wasm function 7>

What's the best tool/library to symbolicate the stack trace and get the function names? Even better, getting file names and line numbers.

I could use something like https://github.com/getsentry/symbolic, but I was wondering if there are other tools/libraries.
@Andrew Brown @Alex Crichton

Stack trace symbolication library written in Rust. Contribute to getsentry/symbolic development by creating an account on GitHub.

view this post on Zulip Alex Crichton (Dec 12 2023 at 15:14):

I wrote up wasm-tools addr2line as a subcommand which takes a WebAssembly offset and maps it to a filename/line number which might help here. The short answer though is the only real way to do this today is DWARF information, so that DWARF would need to be preserved through wasm-opt.

view this post on Zulip Alex Crichton (Dec 12 2023 at 15:15):

I don't know much about that symbolic crate myself, but I would naively assume that it probably doesn't have wasm support and it probably wouldn't be too too hard to port it given that all the primitives are roughly the same

view this post on Zulip Enrico Loparco (Dec 13 2023 at 02:28):

Thanks, I tried wasm-tools addr2line. Is there anything similar, but starting from the function index instead of the address? In the example above, I would pass 14 instead of 0x5dc.

Because, after running wasm-opt --strip-debug --strip-dwarf --strip-producers --strip-target-features, the addresses of the stripped wasm file are different from the ones of the original wasm file. The function indexes are the same though.
I guess I would have to do it myself, through some parsing to get the addresses starting from the indexes.


Last updated: Nov 22 2024 at 16:03 UTC