How to select version of function with a particular comptime parameter in gdb

Viewed 34

For example how to add a breakpoint to function foo(true) in line 100, which is if (a) cat(), of src.zig in gdb?

fn foo(comptime a: bool) void {
    if (a) cat()
    else mouse();
}
1 Answers

Unfortunately, zig does not seem to name comptime functions based on parameters

export fn demo() void {
    foo(true);
    foo(false);
}

→

// zig self-hosted (0.10.0):
call example.foo__anon_213
call example.foo__anon_214

// zig stage1 (0.9.0):
call foo
call foo.2

(godbolt link)

One way you could get around this is by putting a call to the function with the parameters you want somewhere you can find in order to determine what the symbol name is.

Related