-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Closed
Labels
enhancementSolving this issue will likely involve adding new logic or components to the codebase.Solving this issue will likely involve adding new logic or components to the codebase.frontendTokenization, parsing, AstGen, Sema, and Liveness.Tokenization, parsing, AstGen, Sema, and Liveness.
Milestone
Description
Zig version: 0.10.0-dev.1311+5ea94e771
const std = @import("std");
pub fn main() void {
var x: i32 = 1234;
x += foo() +
bar();
}
fn foo() i32 {
return 1;
}
fn bar() i32 {
@panic("crash");
}Here you can see in a debugging session, the traceback points back to the wrong function call:
$ ./stage2/bin/zig build-exe test3.zig -fLLVM
$ gdb ./test3 -ex run
Program received signal SIGTRAP, Trace/breakpoint trap.
0x00000000002019e7 in builtin.default_panic (msg=..., error_return_trace=<optimized out>) at /home/andy/dev/zig/lib/std/builtin.zig:758
758 @breakpoint();
(gdb) up
#1 0x0000000000202127 in test3.bar () at test3.zig:14
14 @panic("crash");
(gdb)
#2 0x0000000000201b42 in test3.main () at test3.zig:5
5 x += foo() +
(gdb)
This is because in the ZIR we only emit dbg_stmt for the var decl, not each function call:
%11 = dbg_stmt(3, 5)
%12 = load(%7) node_offset:5:7
%13 = typeof(%12) node_offset:5:7
%14 = decl_val("foo") token_offset:5:10
%15 = call(.auto, %14, []) node_offset:5:13
%16 = decl_val("bar") token_offset:6:9
%17 = call(.auto, %16, []) node_offset:6:12
%18 = add(%15, %17) node_offset:5:16
%19 = add(%12, %18) node_offset:5:7
%20 = store(%7, %19)
%21 = ret_tok(@Ref.void_value) token_offset:7:1
The two call instructions do have a source node, but only the index is communicated; not line/column info for use by debug info.
We need to augment the call ZIR instruction with the same information as provided by dbg_stmt and then treat each function call as an implicit dbg_stmt instruction.
Metadata
Metadata
Assignees
Labels
enhancementSolving this issue will likely involve adding new logic or components to the codebase.Solving this issue will likely involve adding new logic or components to the codebase.frontendTokenization, parsing, AstGen, Sema, and Liveness.Tokenization, parsing, AstGen, Sema, and Liveness.