Commit 34cf4d1
committed
Support names field in source maps
This adds support for `names` field in source maps, which contains
function names. Source map mappings are correspondingly updated and
emsymbolizer now can provide function name information only with source
maps.
While source maps don't provide the full inlined hierarchies, this
provides the name of the original (= pre-inlining) function, which may
not exist in the final binary because they were inlined. This is because
source maps are primarily intended for user debugging.
This also demangles C++ function names using `llvm-cxxfilt`, so the
printed names can be human-readable.
I tested with `wasm-opt.wasm` from Binaryen by `if (EMSCRIPTEN)` setup
here:
https://github.com/WebAssembly/binaryen/blob/95b2cf0a4ab2386f099568c5c61a02163770af32/CMakeLists.txt#L311-L372
with `-g -gsource-map`. With this PR and
WebAssembly/binaryen#8068, the source map file
size increases by 3.5x (8632423 -> 30070042) primarily due to the
function name strings.
From `llvm-dwarfdump` output, this also requires additional parsing of
`DW_TAG_subprogram` and `DW_TAG_inlined_subroutine` tags which can be at
any depths (because functions can be within nested namespaces or
classes), so we cannot use `--recurse-depth=0` (#9580) anymore. In case
of `wasm-opt.wasm` built with DWARF info, without `--recurse-depth=0` in
the command line, the size of its text output increased by 27.5x, but
with the `--filter-child-tag` / `-t` option
(llvm/llvm-project#165720), the text output
increased only (?) by 3.2x, which I think is tolerable. This disables
`names` field generation when `-t` option is not available in
`llvm-dwarfdump` because it was added recently. To avoid this text size
problem, we can consider using DWARF-parsing Python libraries like
https://github.com/eliben/pyelftools, but this will make another third
party dependency, so I'm not sure if it's worth it at this point.
This also increased running time of `wasm-sourcemap.py`, in case of the
`wasm-opt.wasm`, by 2.3x (6.6s -> 15.4s), but compared to the linking
time this was not very noticeable.
Fixes #20715 and closes #25116.1 parent 9f751bb commit 34cf4d1
File tree
4 files changed
+321
-35
lines changed- test
- core
- tools
4 files changed
+321
-35
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9639 | 9639 | | |
9640 | 9640 | | |
9641 | 9641 | | |
9642 | | - | |
| 9642 | + | |
9643 | 9643 | | |
9644 | 9644 | | |
9645 | 9645 | | |
| 9646 | + | |
9646 | 9647 | | |
9647 | 9648 | | |
| 9649 | + | |
| 9650 | + | |
| 9651 | + | |
| 9652 | + | |
| 9653 | + | |
| 9654 | + | |
| 9655 | + | |
| 9656 | + | |
| 9657 | + | |
| 9658 | + | |
| 9659 | + | |
| 9660 | + | |
| 9661 | + | |
| 9662 | + | |
| 9663 | + | |
| 9664 | + | |
| 9665 | + | |
| 9666 | + | |
| 9667 | + | |
| 9668 | + | |
| 9669 | + | |
| 9670 | + | |
| 9671 | + | |
| 9672 | + | |
| 9673 | + | |
| 9674 | + | |
| 9675 | + | |
| 9676 | + | |
| 9677 | + | |
| 9678 | + | |
| 9679 | + | |
| 9680 | + | |
| 9681 | + | |
| 9682 | + | |
| 9683 | + | |
| 9684 | + | |
| 9685 | + | |
9648 | 9686 | | |
9649 | 9687 | | |
9650 | 9688 | | |
| |||
9667 | 9705 | | |
9668 | 9706 | | |
9669 | 9707 | | |
9670 | | - | |
9671 | | - | |
9672 | | - | |
9673 | | - | |
9674 | | - | |
9675 | | - | |
9676 | | - | |
9677 | | - | |
9678 | | - | |
9679 | | - | |
9680 | | - | |
9681 | | - | |
9682 | | - | |
9683 | | - | |
9684 | | - | |
9685 | | - | |
9686 | | - | |
9687 | | - | |
| 9708 | + | |
9688 | 9709 | | |
9689 | | - | |
9690 | | - | |
9691 | | - | |
9692 | | - | |
9693 | | - | |
9694 | | - | |
| 9710 | + | |
| 9711 | + | |
| 9712 | + | |
| 9713 | + | |
| 9714 | + | |
| 9715 | + | |
| 9716 | + | |
| 9717 | + | |
| 9718 | + | |
| 9719 | + | |
| 9720 | + | |
| 9721 | + | |
| 9722 | + | |
| 9723 | + | |
| 9724 | + | |
| 9725 | + | |
| 9726 | + | |
| 9727 | + | |
| 9728 | + | |
| 9729 | + | |
| 9730 | + | |
| 9731 | + | |
| 9732 | + | |
| 9733 | + | |
9695 | 9734 | | |
9696 | 9735 | | |
9697 | 9736 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
118 | 118 | | |
119 | 119 | | |
120 | 120 | | |
| 121 | + | |
121 | 122 | | |
122 | 123 | | |
123 | 124 | | |
| |||
129 | 130 | | |
130 | 131 | | |
131 | 132 | | |
| 133 | + | |
132 | 134 | | |
133 | 135 | | |
134 | 136 | | |
| |||
156 | 158 | | |
157 | 159 | | |
158 | 160 | | |
| 161 | + | |
159 | 162 | | |
160 | 163 | | |
161 | 164 | | |
| |||
170 | 173 | | |
171 | 174 | | |
172 | 175 | | |
173 | | - | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
174 | 179 | | |
175 | 180 | | |
176 | 181 | | |
| |||
208 | 213 | | |
209 | 214 | | |
210 | 215 | | |
| 216 | + | |
211 | 217 | | |
212 | 218 | | |
213 | 219 | | |
| |||
0 commit comments