compiler: test traps report correct line numbers (#1528)
Signed-off-by: Nuno Cruces <ncruces@users.noreply.github.com>
This commit is contained in:
2
Makefile
2
Makefile
@@ -62,7 +62,7 @@ build.examples.tinygo: $(tinygo_sources)
|
|||||||
|
|
||||||
# We use zig to build C as it is easy to install and embeds a copy of zig-cc.
|
# We use zig to build C as it is easy to install and embeds a copy of zig-cc.
|
||||||
# Note: Don't use "-Oz" as that breaks our wasi sock example.
|
# Note: Don't use "-Oz" as that breaks our wasi sock example.
|
||||||
c_sources := imports/wasi_snapshot_preview1/example/testdata/zig-cc/cat.c imports/wasi_snapshot_preview1/testdata/zig-cc/wasi.c
|
c_sources := imports/wasi_snapshot_preview1/example/testdata/zig-cc/cat.c imports/wasi_snapshot_preview1/testdata/zig-cc/wasi.c internal/testing/dwarftestdata/testdata/zig-cc/main.c
|
||||||
.PHONY: build.examples.zig-cc
|
.PHONY: build.examples.zig-cc
|
||||||
build.examples.zig-cc: $(c_sources)
|
build.examples.zig-cc: $(c_sources)
|
||||||
@for f in $^; do \
|
@for f in $^; do \
|
||||||
|
|||||||
@@ -88,6 +88,18 @@ wasm stack trace:
|
|||||||
._start()
|
._start()
|
||||||
0x6a: /start.zig:609:37 (inlined)
|
0x6a: /start.zig:609:37 (inlined)
|
||||||
/start.zig:224:5`,
|
/start.zig:224:5`,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "cc",
|
||||||
|
bin: dwarftestdata.ZigCCWasm,
|
||||||
|
exp: `module[] function[_start] failed: wasm error: unreachable
|
||||||
|
wasm stack trace:
|
||||||
|
.a()
|
||||||
|
0x312: /main.c:7:18
|
||||||
|
.__original_main() i32
|
||||||
|
0x47c: /main.c:11:3
|
||||||
|
._start()
|
||||||
|
._start.command_export()`,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "rust",
|
name: "rust",
|
||||||
|
|||||||
@@ -19,6 +19,9 @@ var TinyGoWasm []byte
|
|||||||
//go:embed testdata/zig/main.wasm
|
//go:embed testdata/zig/main.wasm
|
||||||
var ZigWasm []byte
|
var ZigWasm []byte
|
||||||
|
|
||||||
|
//go:embed testdata/zig-cc/main.wasm
|
||||||
|
var ZigCCWasm []byte
|
||||||
|
|
||||||
// RustWasm comes with huge DWARF sections, so we do not check it in directly,
|
// RustWasm comes with huge DWARF sections, so we do not check it in directly,
|
||||||
// but instead xz-compressed one is.
|
// but instead xz-compressed one is.
|
||||||
var RustWasm []byte
|
var RustWasm []byte
|
||||||
|
|||||||
13
internal/testing/dwarftestdata/testdata/zig-cc/main.c
vendored
Normal file
13
internal/testing/dwarftestdata/testdata/zig-cc/main.c
vendored
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
volatile int base = 65536;
|
||||||
|
|
||||||
|
void a() {
|
||||||
|
char str[16];
|
||||||
|
str[4] = 'a';
|
||||||
|
str[8] = 'b';
|
||||||
|
str[12 + base] = 'c'; // This traps.
|
||||||
|
}
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
a();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
BIN
internal/testing/dwarftestdata/testdata/zig-cc/main.wasm
vendored
Executable file
BIN
internal/testing/dwarftestdata/testdata/zig-cc/main.wasm
vendored
Executable file
Binary file not shown.
Reference in New Issue
Block a user