Description
There are lots of use cases for getting the line number and/or symbol name from a code address, and there are several existing ways it can be done:
- Given a wasm (or object) file with a DWARF .debug_line section, llvm-symbolizer can get symbol and file/line information
- Given a wasm file and a source map, we can get file/line information from the source map (I don't think we currently have a sourcemap parser that goes in this direction, we'd want to add one)
- Given a wasm file with a name section, we can get symbol information for code addresses (but not line information, and not for data addresses)
- Given a wasm file and an emscripten symbol map, we can get symbol information for code addresses (but not file/line information, and not for data addreses)
- (IIRC) Given an object file (or a wasm file with a symbol table) llvm-nm can get symbol information (but not file/line information)
Given that 3 is wasm-specific, and 2 and 4 are emscripten-specific, it might be warranted to have an emscripten-specific wrapper that can just figure out which, if any, of these sources of information are available, and print the information.
Some of these (at least the LLVM-based ones) currently require section offsets rather than the file offsets printed by the engines in stack traces and the like. That's an orthogonal problem to this one (e.g. we might want to fix the llvm tools and/or internal interfaces to use file offsets instead). But either way this script can do any necessary conversions, and we can adjust it if we make changes to LLVM, and it will have utility even aside from that.