Skip to content

Commit 1fac270

Browse files
committed
Add testing
1 parent 1087383 commit 1fac270

File tree

4 files changed

+141
-3
lines changed

4 files changed

+141
-3
lines changed
Binary file not shown.
Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
foo.wasm: file format WASM
2+
3+
.debug_info contents:
4+
0x00000000: Compile Unit: length = 0x00000045, format = DWARF32, version = 0x0004, abbr_offset = 0x0000, addr_size = 0x04 (next unit at 0x00000049)
5+
6+
0x0000000b: DW_TAG_compile_unit
7+
DW_AT_producer ("clang version 18.0.0 (https://github.com/llvm/llvm-project 269685545e439ad050b67740533c59f965cae955)")
8+
DW_AT_language (DW_LANG_C11)
9+
DW_AT_name ("no_main.c")
10+
DW_AT_stmt_list (0x00000000)
11+
DW_AT_comp_dir ("/emscripten/test/other/wasm_sourcemap_resolve_dummy_comp_dir")
12+
DW_AT_low_pc (0x00000002)
13+
DW_AT_high_pc (0x0000000d)
14+
0x00000049: Compile Unit: length = 0x00000120, format = DWARF32, version = 0x0004, abbr_offset = 0x0034, addr_size = 0x04 (next unit at 0x0000016d)
15+
16+
0x00000054: DW_TAG_compile_unit
17+
DW_AT_stmt_list (0x00000042)
18+
DW_AT_ranges (0x00000000
19+
[0x0000000e, 0x00000016)
20+
[0x00000017, 0x00000021)
21+
[0x00000022, 0x0000003c))
22+
DW_AT_name ("system/lib/compiler-rt/stack_ops.S")
23+
DW_AT_comp_dir ("/emsdk/emscripten")
24+
DW_AT_producer ("clang version 18.0.0 (https://github.com/llvm/llvm-project 269685545e439ad050b67740533c59f965cae955)")
25+
DW_AT_language (DW_LANG_Mips_Assembler)
26+
27+
.debug_line contents:
28+
debug_line[0x00000000]
29+
Line table prologue:
30+
total_length: 0x0000003e
31+
format: DWARF32
32+
version: 4
33+
prologue_length: 0x00000021
34+
min_inst_length: 1
35+
max_ops_per_inst: 1
36+
default_is_stmt: 1
37+
line_base: -5
38+
line_range: 14
39+
opcode_base: 13
40+
standard_opcode_lengths[DW_LNS_copy] = 0
41+
standard_opcode_lengths[DW_LNS_advance_pc] = 1
42+
standard_opcode_lengths[DW_LNS_advance_line] = 1
43+
standard_opcode_lengths[DW_LNS_set_file] = 1
44+
standard_opcode_lengths[DW_LNS_set_column] = 1
45+
standard_opcode_lengths[DW_LNS_negate_stmt] = 0
46+
standard_opcode_lengths[DW_LNS_set_basic_block] = 0
47+
standard_opcode_lengths[DW_LNS_const_add_pc] = 0
48+
standard_opcode_lengths[DW_LNS_fixed_advance_pc] = 1
49+
standard_opcode_lengths[DW_LNS_set_prologue_end] = 0
50+
standard_opcode_lengths[DW_LNS_set_epilogue_begin] = 0
51+
standard_opcode_lengths[DW_LNS_set_isa] = 1
52+
file_names[ 1]:
53+
name: "no_main.c"
54+
dir_index: 0
55+
mod_time: 0x00000000
56+
length: 0x00000000
57+
58+
Address Line Column File ISA Discriminator OpIndex Flags
59+
------------------ ------ ------ ------ --- ------------- ------- -------------
60+
0x0000000000000005 12 3 1 0 0 0 is_stmt prologue_end
61+
0x000000000000000d 12 3 1 0 0 0 is_stmt end_sequence
62+
63+
debug_line[0x00000042]
64+
Line table prologue:
65+
total_length: 0x000000ea
66+
format: DWARF32
67+
version: 4
68+
prologue_length: 0x0000003a
69+
min_inst_length: 1
70+
max_ops_per_inst: 1
71+
default_is_stmt: 1
72+
line_base: -5
73+
line_range: 14
74+
opcode_base: 13
75+
standard_opcode_lengths[DW_LNS_copy] = 0
76+
standard_opcode_lengths[DW_LNS_advance_pc] = 1
77+
standard_opcode_lengths[DW_LNS_advance_line] = 1
78+
standard_opcode_lengths[DW_LNS_set_file] = 1
79+
standard_opcode_lengths[DW_LNS_set_column] = 1
80+
standard_opcode_lengths[DW_LNS_negate_stmt] = 0
81+
standard_opcode_lengths[DW_LNS_set_basic_block] = 0
82+
standard_opcode_lengths[DW_LNS_const_add_pc] = 0
83+
standard_opcode_lengths[DW_LNS_fixed_advance_pc] = 1
84+
standard_opcode_lengths[DW_LNS_set_prologue_end] = 0
85+
standard_opcode_lengths[DW_LNS_set_epilogue_begin] = 0
86+
standard_opcode_lengths[DW_LNS_set_isa] = 1
87+
include_directories[ 1] = "system/lib/compiler-rt"
88+
file_names[ 1]:
89+
name: "stack_ops.S"
90+
dir_index: 1
91+
mod_time: 0x00000000
92+
length: 0x00000000
93+
94+
Address Line Column File ISA Discriminator OpIndex Flags
95+
------------------ ------ ------ ------ --- ------------- ------- -------------
96+
0x000000000000000e 18 0 1 0 0 0 is_stmt
97+
0x0000000000000011 19 0 1 0 0 0 is_stmt
98+
0x0000000000000012 19 0 1 0 0 0 is_stmt end_sequence
99+
0x0000000000000013 23 0 1 0 0 0 is_stmt
100+
0x0000000000000016 24 0 1 0 0 0 is_stmt
101+
0x0000000000000018 25 0 1 0 0 0 is_stmt
102+
0x0000000000000019 25 0 1 0 0 0 is_stmt end_sequence
103+
0x000000000000001f 30 0 1 0 0 0 is_stmt
104+
0x0000000000000021 32 0 1 0 0 0 is_stmt
105+
0x0000000000000023 34 0 1 0 0 0 is_stmt
106+
0x0000000000000024 36 0 1 0 0 0 is_stmt
107+
0x0000000000000026 37 0 1 0 0 0 is_stmt
108+
0x0000000000000027 38 0 1 0 0 0 is_stmt
109+
0x0000000000000029 39 0 1 0 0 0 is_stmt
110+
0x000000000000002b 40 0 1 0 0 0 is_stmt
111+
0x000000000000002d 41 0 1 0 0 0 is_stmt
112+
0x000000000000002e 41 0 1 0 0 0 is_stmt end_sequence
113+
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
/*
2+
* Copyright 2023 The Emscripten Authors. All rights reserved.
3+
* Emscripten is available under two separate licenses, the MIT license and the
4+
* University of Illinois/NCSA Open Source License. Both these licenses can be
5+
* found in the LICENSE file.
6+
*/
7+
8+
// embuilder build libcompiler_rt --force
9+
// emcc -nostartfiles -sASSERTIONS=0 -sSUPPORT_ERRNO=0 \
10+
// -sEXPORTED_FUNCTIONS=_foo -Wl,--no-entry -g -o foo.wasm no_main.c
11+
// llvm-dwarfdump -debug-info -debug-line --recurse-depth=0 foo.wasm \
12+
// >foo.wasm.dump
13+
int foo() { return 42; }

test/test_other.py

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9561,6 +9561,18 @@ def test_wasm_sourcemap_dead(self):
95619561
# has only two entries
95629562
self.assertRegexpMatches(output, r'"mappings":\s*"[A-Za-z0-9+/]+,[A-Za-z0-9+/]+"')
95639563

9564+
def test_wasm_sourcemap_resolve_dummy_comp_dir(self):
9565+
wasm_map_cmd = [PYTHON, path_from_root('tools/wasm-sourcemap.py'),
9566+
'--dwarfdump-output',
9567+
test_file('other/wasm_sourcemap_resolve_dummy_comp_dir/foo.wasm.dump'),
9568+
'-o', 'a.out.wasm.map',
9569+
test_file('other/wasm_sourcemap_resolve_dummy_comp_dir/foo.wasm'),
9570+
'--basepath=' + path_from_root()]
9571+
self.run_process(wasm_map_cmd, stdout=PIPE, stderr=PIPE)
9572+
output = read_file('a.out.wasm.map')
9573+
# has an actual path to the source file of system library, not a dummy path (/emsdk/emscripten/**)
9574+
self.assertIn('"system/lib/compiler-rt/stack_ops.S"', output)
9575+
95649576
def test_wasm_sourcemap_relative_paths(self):
95659577
ensure_dir('build')
95669578

@@ -9803,11 +9815,11 @@ def test_dwarf_system_lib(self):
98039815
if config.FROZEN_CACHE:
98049816
self.skipTest("test doesn't work with frozen cache")
98059817
self.run_process([EMBUILDER, 'build', 'libemmalloc', '--force'])
9806-
libc = os.path.join(config.CACHE, 'sysroot', 'lib', 'wasm32-emscripten', 'libemmalloc.a')
9807-
self.assertExists(libc)
9818+
system_lib = os.path.join(config.CACHE, 'sysroot', 'lib', 'wasm32-emscripten', 'libemmalloc.a')
9819+
self.assertExists(system_lib)
98089820

98099821
dwdump = self.run_process(
9810-
[LLVM_DWARFDUMP, libc, '-debug-info', '-debug-line', '--recurse-depth=0'],
9822+
[LLVM_DWARFDUMP, system_lib, '-debug-info', '-debug-line', '--recurse-depth=0'],
98119823
stdout=PIPE).stdout
98129824
# Check that the embedded location of the source file is correct.
98139825
self.assertIn('DW_AT_name\t("system/lib/emmalloc.c")', dwdump)

0 commit comments

Comments
 (0)