@@ -9629,49 +9629,12 @@ def check_dwarf_loc_info(address, funcs, locs):
96299629 for loc in locs:
96309630 self.assertIn(loc, out)
96319631
9632- def check_source_map_loc_info(address, func, loc):
9632+ def check_source_map_loc_info(address, loc):
96339633 out = self.run_process(
96349634 [emsymbolizer, '-s', 'sourcemap', 'test_dwarf.wasm', address],
96359635 stdout=PIPE).stdout
9636- self.assertIn(func, out)
96379636 self.assertIn(loc, out)
96389637
9639- def do_tests(src):
9640- # 1. Test DWARF + source map together
9641- # For DWARF, we check for the full inlined info for both function names and
9642- # source locations. Source maps does not provide inlined info. So we only
9643- # check for the info of the outermost function.
9644- self.run_process([EMCC, test_file(src), '-g', '-gsource-map', '-O1', '-o',
9645- 'test_dwarf.js'])
9646- check_dwarf_loc_info(out_to_js_call_addr, out_to_js_call_func,
9647- out_to_js_call_loc)
9648- check_source_map_loc_info(out_to_js_call_addr, out_to_js_call_func[0],
9649- out_to_js_call_loc[0])
9650- check_dwarf_loc_info(unreachable_addr, unreachable_func, unreachable_loc)
9651- # Source map shows the original (inlined) source location with the original
9652- # function name
9653- check_source_map_loc_info(unreachable_addr, unreachable_func[0],
9654- unreachable_loc[0])
9655-
9656- # 2. Test source map only
9657- # The addresses, function names, and source locations are the same across
9658- # the builds because they are relative offsets from the code section, so we
9659- # don't need to recompute them
9660- self.run_process([EMCC, test_file(src), '-gsource-map', '-O1', '-o',
9661- 'test_dwarf.js'])
9662- check_source_map_loc_info(out_to_js_call_addr, out_to_js_call_func[0],
9663- out_to_js_call_loc[0])
9664- check_source_map_loc_info(unreachable_addr, unreachable_func[0],
9665- unreachable_loc[0])
9666-
9667- # 3. Test DWARF only
9668- self.run_process([EMCC, test_file(src), '-g', '-O1', '-o',
9669- 'test_dwarf.js'])
9670- check_dwarf_loc_info(out_to_js_call_addr, out_to_js_call_func,
9671- out_to_js_call_loc)
9672- check_dwarf_loc_info(unreachable_addr, unreachable_func, unreachable_loc)
9673-
9674- # -- C program test --
96759638 # We test two locations within test_dwarf.c:
96769639 # out_to_js(0); // line 6
96779640 # __builtin_trap(); // line 13
@@ -9694,32 +9657,31 @@ def do_tests(src):
96949657 # The first one corresponds to the innermost inlined location.
96959658 unreachable_loc = ['test_dwarf.c:13:3', 'test_dwarf.c:18:3']
96969659
9697- do_tests('core/test_dwarf.c')
9698-
9699- # -- C++ program test --
9700- # We test two locations within test_dwarf.cpp:
9701- # out_to_js(0); // line 12
9702- # __builtin_trap(); // line 19
9703- self.run_process([EMCC, test_file('core/test_dwarf.cpp'),
9704- '-g', '-gsource-map', '-O1', '-o', 'test_dwarf.js'])
9705- # Address of out_to_js(0) within MyClass::foo(), uninlined
9706- out_to_js_call_addr = self.get_instr_addr('call\t0', 'test_dwarf.wasm')
9707- # Address of __builtin_trap() within MyClass::bar(), inlined into main()
9708- unreachable_addr = self.get_instr_addr('unreachable', 'test_dwarf.wasm')
9709-
9710- # Function name of out_to_js(0) within MyClass::foo(), uninlined
9711- out_to_js_call_func = ['MyClass::foo()']
9712- # Function names of __builtin_trap() within MyClass::bar(), inlined into
9713- # main(). The first one corresponds to the innermost inlined function.
9714- unreachable_func = ['MyClass::bar()', 'main']
9715-
9716- # Source location of out_to_js(0) within MyClass::foo(), uninlined
9717- out_to_js_call_loc = ['test_dwarf.cpp:12:3']
9718- # Source locations of __builtin_trap() within MyClass::bar(), inlined into
9719- # main(). The first one corresponds to the innermost inlined location.
9720- unreachable_loc = ['test_dwarf.cpp:19:3', 'test_dwarf.cpp:25:6']
9660+ # 1. Test DWARF + source map together
9661+ # For DWARF, we check for the full inlined info for both function names and
9662+ # source locations. Source maps provide neither function names nor inlined
9663+ # info. So we only check for the source location of the outermost function.
9664+ check_dwarf_loc_info(out_to_js_call_addr, out_to_js_call_func,
9665+ out_to_js_call_loc)
9666+ check_source_map_loc_info(out_to_js_call_addr, out_to_js_call_loc[0])
9667+ check_dwarf_loc_info(unreachable_addr, unreachable_func, unreachable_loc)
9668+ check_source_map_loc_info(unreachable_addr, unreachable_loc[0])
9669+
9670+ # 2. Test source map only
9671+ # The addresses, function names, and source locations are the same across
9672+ # the builds because they are relative offsets from the code section, so we
9673+ # don't need to recompute them
9674+ self.run_process([EMCC, test_file('core/test_dwarf.c'),
9675+ '-gsource-map', '-O1', '-o', 'test_dwarf.js'])
9676+ check_source_map_loc_info(out_to_js_call_addr, out_to_js_call_loc[0])
9677+ check_source_map_loc_info(unreachable_addr, unreachable_loc[0])
97219678
9722- do_tests('core/test_dwarf.cpp')
9679+ # 3. Test DWARF only
9680+ self.run_process([EMCC, test_file('core/test_dwarf.c'),
9681+ '-g', '-O1', '-o', 'test_dwarf.js'])
9682+ check_dwarf_loc_info(out_to_js_call_addr, out_to_js_call_func,
9683+ out_to_js_call_loc)
9684+ check_dwarf_loc_info(unreachable_addr, unreachable_func, unreachable_loc)
97239685
97249686 def test_emsymbolizer_functions(self):
97259687 'Test emsymbolizer use cases that only provide function-granularity info'
0 commit comments