Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ See docs/process.md for more on how version tagging works.

4.0.24 (in development)
-----------------------
- Source map's 'names' field support is removed, because the way we used it was
inconsistent with JS and was not supported in browser devtools. We plan to
provide this information using Scopes encoding later. (#26149)
- compiler-rt, libcxx, libcxxabi, and libunwind were updated to LLVM 21.1.8.
- (#26036, #26045, and #26058)
- Calling pthread_create in a single-threaded build will now return ENOTSUP
Expand Down
26 changes: 11 additions & 15 deletions test/test_other.py
Original file line number Diff line number Diff line change
Expand Up @@ -9651,36 +9651,32 @@ def check_source_map_loc_info(address, func, loc):
out = self.run_process(
[emsymbolizer, '-s', 'sourcemap', 'test_dwarf.wasm', address],
stdout=PIPE).stdout
self.assertIn(func, out)
if func:
self.assertIn(func, out)
self.assertIn(loc, out)

def do_tests(src):
# 1. Test DWARF + source map together
# For DWARF, we check for the full inlined info for both function names and
# source locations. Source maps does not provide inlined info. So we only
# check for the info of the outermost function.
# For DWARF, we check for the full inlined info for both function names
# and source locations. Source maps does not provide inlining information
# and function name, so we only check for the info of the outermost
# location.
self.run_process([EMCC, test_file(src), '-g', '-gsource-map', '-O1', '-o',
'test_dwarf.js'])
check_dwarf_loc_info(out_to_js_call_addr, out_to_js_call_func,
out_to_js_call_loc)
check_source_map_loc_info(out_to_js_call_addr, out_to_js_call_func[0],
check_source_map_loc_info(out_to_js_call_addr, None,
out_to_js_call_loc[0])
check_dwarf_loc_info(unreachable_addr, unreachable_func, unreachable_loc)
# Source map shows the original (inlined) source location with the original
# function name
check_source_map_loc_info(unreachable_addr, unreachable_func[0],
unreachable_loc[0])
# Source map shows the original (inlined) source location
check_source_map_loc_info(unreachable_addr, None, unreachable_loc[0])

# 2. Test source map only
# The addresses, function names, and source locations are the same across
# the builds because they are relative offsets from the code section, so we
# don't need to recompute them
Comment on lines -9675 to -9677
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unrelated, but this comment seems unnecessary anyway

self.run_process([EMCC, test_file(src), '-gsource-map', '-O1', '-o',
'test_dwarf.js'])
check_source_map_loc_info(out_to_js_call_addr, out_to_js_call_func[0],
check_source_map_loc_info(out_to_js_call_addr, None,
out_to_js_call_loc[0])
check_source_map_loc_info(unreachable_addr, unreachable_func[0],
unreachable_loc[0])
check_source_map_loc_info(unreachable_addr, None, unreachable_loc[0])

# 3. Test DWARF only
self.run_process([EMCC, test_file(src), '-g', '-O1', '-o',
Expand Down
25 changes: 18 additions & 7 deletions tools/wasm-sourcemap.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@

logger = logging.getLogger('wasm-sourcemap')

# FIXME: Generate Scopes info
generate_scopes = False


def parse_args(args):
parser = argparse.ArgumentParser(prog='wasm-sourcemap.py', description=__doc__)
Expand Down Expand Up @@ -399,12 +402,17 @@ def read_dwarf_info(wasm, options):
logger.debug('Reading DWARF information from %s' % wasm)
if not os.path.exists(options.dwarfdump):
utils.exit_with_error('llvm-dwarfdump not found: ' + options.dwarfdump)
# We need only three tags in the debug info: DW_TAG_compile_unit for
# source location, and DW_TAG_subprogram and DW_TAG_inlined_subroutine
# for the function ranges.
dwarfdump_cmd = [options.dwarfdump, '-debug-info', '-debug-line', wasm,
'-t', 'DW_TAG_compile_unit', '-t', 'DW_TAG_subprogram',
'-t', 'DW_TAG_inlined_subroutine']
dwarfdump_cmd = [options.dwarfdump, '-debug-info', '-debug-line', wasm]
if generate_scopes:
# We need only three tags in the debug info: DW_TAG_compile_unit for
# source location, and DW_TAG_subprogram and DW_TAG_inlined_subroutine
# for the function ranges.
dwarfdump_cmd += ['-t', 'DW_TAG_compile_unit', '-t', 'DW_TAG_subprogram',
'-t', 'DW_TAG_inlined_subroutine']
else:
# We only need the top-level DW_TAG_compile_unit tags when not generating
# the names field
dwarfdump_cmd += ['--recurse-depth=0']
proc = shared.check_call(dwarfdump_cmd, stdout=shared.PIPE)
output = proc.stdout
else:
Expand Down Expand Up @@ -481,7 +489,10 @@ def read_dwarf_info(wasm, options):
# return entries sorted by the address field
entries = sorted(entries, key=lambda entry: entry['address'])

func_ranges = extract_func_ranges(debug_info)
if generate_scopes:
func_ranges = extract_func_ranges(debug_info)
else:
func_ranges = []
return entries, func_ranges


Expand Down