Skip to content

detect inline calls in std.debug.Dwarf and print their frames in stack traces #19407

@Inve1951

Description

@Inve1951

Zig Version

0.12.0-dev.3381+7057bffc1

Steps to Reproduce and Observed Behavior

Scenario 1:

inline fn repro() void {
    @panic("");
}

pub fn main() void {
    repro();
}

Output:

$ zig run repro.zig 
thread 147441 panic: 
.../repro.zig:2:5: 0x1033fef in main (repro)
    @panic("");
    ^
.../lib/zig/std/start.zig:501:22: 0x1033899 in posixCallMainAndExit (repro)
            root.main();
                     ^
.../lib/zig/std/start.zig:253:5: 0x1033401 in _start (repro)
    asm volatile (switch (native_arch) {
    ^

Scenario 2:

inline fn repro() !void {
    try other();
}

fn other() !void {
    return error.Fail;
}

pub fn main() !void {
    try repro();
}

Output:

$ zig run repro.zig 
error: Fail
.../repro.zig:6:5: 0x1033c98 in other (repro)
    return error.Fail;
    ^
.../repro.zig:10:5: 0x1033dc7 in main (repro)
    try repro();
    ^

Expected Behavior

Expected output is as if the function wasn't inline.

Expected 1:

$ zig run repro.zig 
thread 147991 panic: 
.../repro.zig:2:5: 0x1035fdf in repro (repro)
    @panic("");
    ^
.../repro.zig:6:10: 0x1034008 in main (repro)
    repro();
         ^
.../lib/zig/std/start.zig:501:22: 0x10338c9 in posixCallMainAndExit (repro)
            root.main();
                     ^
.../zig/std/start.zig:253:5: 0x1033431 in _start (repro)
    asm volatile (switch (native_arch) {
    ^

Expected 2:

$ zig run repro.zig 
error: Fail
.../repro.zig:6:5: 0x1033cc8 in other (repro)
    return error.Fail;
    ^
.../repro.zig:2:5: 0x1033dd3 in repro (repro)
    try other();
    ^
.../repro.zig:10:5: 0x1033e13 in main (repro)
    try repro();
    ^

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementSolving this issue will likely involve adding new logic or components to the codebase.standard libraryThis issue involves writing Zig code for the standard library.

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions