diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2022-04-19 14:12:13 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-04-19 14:12:13 -0400 |
| commit | 9c2cbe39c2caa9137e1123fcdf2f326282cad1b5 (patch) | |
| tree | da31a6f7307bcf03a87be3c7497600667b3a7c25 /lib/std/debug.zig | |
| parent | 78f26b970e1c5c288e45d0edd2ab2f229e6fe924 (diff) | |
| parent | be08d2bdbd2f64ccb9ef0f985a57a4bf89b9aebb (diff) | |
| download | zig-9c2cbe39c2caa9137e1123fcdf2f326282cad1b5.tar.gz zig-9c2cbe39c2caa9137e1123fcdf2f326282cad1b5.zip | |
Merge pull request #11461 from Luukdegram/wasm-debug-info
Wasm: add support for debug information
Diffstat (limited to 'lib/std/debug.zig')
| -rw-r--r-- | lib/std/debug.zig | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/lib/std/debug.zig b/lib/std/debug.zig index e00c0a21a2..b600f7245a 100644 --- a/lib/std/debug.zig +++ b/lib/std/debug.zig @@ -113,6 +113,13 @@ pub fn detectTTYConfig() TTY.Config { /// TODO multithreaded awareness pub fn dumpCurrentStackTrace(start_addr: ?usize) void { nosuspend { + if (comptime builtin.target.isWasm()) { + if (native_os == .wasi) { + const stderr = io.getStdErr().writer(); + stderr.print("Unable to dump stack trace: not implemented for Wasm\n", .{}) catch return; + } + return; + } const stderr = io.getStdErr().writer(); if (builtin.strip_debug_info) { stderr.print("Unable to dump stack trace: debug info stripped\n", .{}) catch return; @@ -134,6 +141,13 @@ pub fn dumpCurrentStackTrace(start_addr: ?usize) void { /// TODO multithreaded awareness pub fn dumpStackTraceFromBase(bp: usize, ip: usize) void { nosuspend { + if (comptime builtin.target.isWasm()) { + if (native_os == .wasi) { + const stderr = io.getStdErr().writer(); + stderr.print("Unable to dump stack trace: not implemented for Wasm\n", .{}) catch return; + } + return; + } const stderr = io.getStdErr().writer(); if (builtin.strip_debug_info) { stderr.print("Unable to dump stack trace: debug info stripped\n", .{}) catch return; @@ -204,6 +218,13 @@ pub fn captureStackTrace(first_address: ?usize, stack_trace: *std.builtin.StackT /// TODO multithreaded awareness pub fn dumpStackTrace(stack_trace: std.builtin.StackTrace) void { nosuspend { + if (comptime builtin.target.isWasm()) { + if (native_os == .wasi) { + const stderr = io.getStdErr().writer(); + stderr.print("Unable to dump stack trace: not implemented for Wasm\n", .{}) catch return; + } + return; + } const stderr = io.getStdErr().writer(); if (builtin.strip_debug_info) { stderr.print("Unable to dump stack trace: debug info stripped\n", .{}) catch return; @@ -1134,6 +1155,8 @@ pub const DebugInfo = struct { return self.lookupModuleWin32(address); } else if (native_os == .haiku) { return self.lookupModuleHaiku(address); + } else if (comptime builtin.target.isWasm()) { + return self.lookupModuleWasm(address); } else { return self.lookupModuleDl(address); } @@ -1349,6 +1372,12 @@ pub const DebugInfo = struct { _ = address; @panic("TODO implement lookup module for Haiku"); } + + fn lookupModuleWasm(self: *DebugInfo, address: usize) !*ModuleDebugInfo { + _ = self; + _ = address; + @panic("TODO implement lookup module for Wasm"); + } }; pub const ModuleDebugInfo = switch (native_os) { @@ -1628,6 +1657,13 @@ pub const ModuleDebugInfo = switch (native_os) { return getSymbolFromDwarf(relocated_address, &self.dwarf); } }, + .wasi => struct { + pub fn getSymbolAtAddress(self: *@This(), address: usize) !SymbolInfo { + _ = self; + _ = address; + return SymbolInfo{}; + } + }, else => DW.DwarfInfo, }; |
