-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Add name section and object symbol table support to emsymbolizer #21367
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 3 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
7fd1614
Add name section and object symbol table support to emsymbolizer
dschuff 95c8b8f
review comment
dschuff 53571cb
remove objfile test
dschuff 3158e60
Use docstring
dschuff 420f5a4
suggestions
dschuff 3293dc5
flake8
dschuff 2d3a457
Merge branch 'main' into symbolizer_names
dschuff 1912780
another attempt at flake8
dschuff 3469517
Merge branch 'main' into symbolizer_names
dschuff File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -9736,7 +9736,31 @@ def test(dump_file): | |||||
| test('foo.wasm.dump') | ||||||
| test('bar.wasm.dump') | ||||||
|
|
||||||
| def test_emsymbolizer(self): | ||||||
| # Runs llvm-objdump to get the address of the first occurrence of the | ||||||
| # specified line within the given function. llvm-objdump's output format | ||||||
| # example is as follows: | ||||||
| # ... | ||||||
| # 00000004 <foo>: | ||||||
| # ... | ||||||
| # 6: 41 00 i32.const 0 | ||||||
| # ... | ||||||
| # The addresses here are the offsets to the start of the file. Returns | ||||||
| # the address string in hexadecimal. | ||||||
dschuff marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||
| def get_instr_addr(self, text, filename): | ||||||
| out = self.run_process([common.LLVM_OBJDUMP, '-d', filename], | ||||||
| stdout=PIPE).stdout.strip() | ||||||
| out_lines = out.splitlines() | ||||||
| found = False | ||||||
| for line in out_lines: | ||||||
| if text in line: | ||||||
| offset = line.strip().split(':')[0] | ||||||
| found = True | ||||||
| break | ||||||
| assert found | ||||||
| return '0x' + offset | ||||||
|
|
||||||
| def test_emsymbolizer_srcloc(self): | ||||||
| # Test emsymbolizer use cases that provide src location granularity info | ||||||
| def check_dwarf_loc_info(address, funcs, locs): | ||||||
| out = self.run_process( | ||||||
| [emsymbolizer, '-s', 'dwarf', 'test_dwarf.wasm', address], | ||||||
|
|
@@ -9748,45 +9772,19 @@ def check_dwarf_loc_info(address, funcs, locs): | |||||
|
|
||||||
| def check_source_map_loc_info(address, loc): | ||||||
| out = self.run_process( | ||||||
| [emsymbolizer, '-s', 'sourcemap', 'test_dwarf.wasm', | ||||||
| address], | ||||||
| [emsymbolizer, '-s', 'sourcemap', 'test_dwarf.wasm', address], | ||||||
| stdout=PIPE).stdout | ||||||
| self.assertIn(loc, out) | ||||||
|
|
||||||
| # Runs llvm-objdump to get the address of the first occurrence of the | ||||||
| # specified line within the given function. llvm-objdump's output format | ||||||
| # example is as follows: | ||||||
| # ... | ||||||
| # 00000004 <foo>: | ||||||
| # ... | ||||||
| # 6: 41 00 i32.const 0 | ||||||
| # ... | ||||||
| # The addresses here are the offsets to the start of the file. Returns | ||||||
| # the address string in hexadecimal. | ||||||
| def get_addr(text): | ||||||
| out = self.run_process([common.LLVM_OBJDUMP, '-d', 'test_dwarf.wasm'], | ||||||
| stdout=PIPE).stdout.strip() | ||||||
| out_lines = out.splitlines() | ||||||
| found = False | ||||||
| for line in out_lines: | ||||||
| if text in line: | ||||||
| offset = line.strip().split(':')[0] | ||||||
| found = True | ||||||
| break | ||||||
| assert found | ||||||
| return '0x' + offset | ||||||
|
|
||||||
| # We test two locations within test_dwarf.c: | ||||||
| # out_to_js(0); // line 6 | ||||||
| # __builtin_trap(); // line 13 | ||||||
|
|
||||||
| # 1. Test DWARF + source map together | ||||||
| self.run_process([EMCC, test_file('core/test_dwarf.c'), | ||||||
| '-g', '-gsource-map', '-O1', '-o', 'test_dwarf.js']) | ||||||
| # Address of out_to_js(0) within foo(), uninlined | ||||||
| out_to_js_call_addr = get_addr('call\t0') | ||||||
| out_to_js_call_addr = self.get_instr_addr('call\t0', 'test_dwarf.wasm') | ||||||
| # Address of __builtin_trap() within bar(), inlined into main() | ||||||
| unreachable_addr = get_addr('unreachable') | ||||||
| unreachable_addr = self.get_instr_addr('unreachable', 'test_dwarf.wasm') | ||||||
|
|
||||||
| # Function name of out_to_js(0) within foo(), uninlined | ||||||
| out_to_js_call_func = ['foo'] | ||||||
|
|
@@ -9800,6 +9798,7 @@ def get_addr(text): | |||||
| # The first one corresponds to the innermost inlined location. | ||||||
| unreachable_loc = ['test_dwarf.c:13:3', 'test_dwarf.c:18:3'] | ||||||
|
|
||||||
| # 1. Test DWARF + source map together | ||||||
| # For DWARF, we check for the full inlined info for both function names and | ||||||
| # source locations. Source maps provide neither function names nor inlined | ||||||
| # info. So we only check for the source location of the outermost function. | ||||||
|
|
@@ -9825,6 +9824,27 @@ def get_addr(text): | |||||
| out_to_js_call_loc) | ||||||
| check_dwarf_loc_info(unreachable_addr, unreachable_func, unreachable_loc) | ||||||
|
|
||||||
| def test_emsymbolizer_functions(self): | ||||||
| # Test emsymbolizer use cases that only provide function-granularity info | ||||||
| def check_func_info(filename, address, func): | ||||||
| out = self.run_process( | ||||||
| [emsymbolizer, filename, address], stdout=PIPE).stdout | ||||||
| self.assertIn(func, out) | ||||||
|
|
||||||
| # 1. Test name section only | ||||||
| self.run_process([EMCC, test_file('core/test_dwarf.c'), | ||||||
| '--profiling-funcs', '-O1', '-o', 'test_dwarf.js']) | ||||||
| with webassembly.Module('test_dwarf.wasm') as wasm: | ||||||
| self.assertTrue(wasm.has_name_section()) | ||||||
| self.assertIsNone(wasm.get_custom_section('.debug_info')) | ||||||
| # Address of out_to_js(0) within foo(), uninlined | ||||||
| out_to_js_call_addr = self.get_instr_addr('call\t0', 'test_dwarf.wasm') | ||||||
| # Address of __builtin_trap() within bar(), inlined into main() | ||||||
| unreachable_addr = self.get_instr_addr('unreachable', 'test_dwarf.wasm') | ||||||
| check_func_info('test_dwarf.wasm', out_to_js_call_addr, 'foo') | ||||||
| # The name section will not reflect bar being inlined into main | ||||||
|
||||||
| # The name section will not reflect bar being inlined into main | |
| # The name section will reflect bar being inlined into main |
?
Member
Author
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess this was intended to mean that DWARF has the inlining info, and shows bar, but name section doesn't I made it more claer.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.