How do I enable error return traces in release mode?
Add .error_tracing = true
to the exe part of the build script
const cli = b.addExecutable(.{
.name = exe_name,
.root_source_file = b.path("src/cli/main.zig"),
.target = target,
.optimize = optimize,
.error_tracing = true,
});
jeff@jeff-debian:~/repos/gatorcat$ sudo ./zig-out/release/gatorcat-0.3.8-x86_64-linux-musl --log-level warn run --ifname docker0
warning: Scheduler: NORMAL
error: Ping failed. No frame returned before the recv timeout. Is anything connected to the specified interface (docker0)?
error: NonRecoverable
/home/jeff/repos/gatorcat/src/module/Port.zig:297:9: 0x15561f0 in sendRecvDatagram (gatorcat-0.3.8-x86_64-linux-musl)
return error.RecvTimeout;
^
/home/jeff/repos/gatorcat/src/module/Port.zig:309:9: 0x154e68e in run (gatorcat-0.3.8-x86_64-linux-musl)
_ = try sendRecvDatagram(
^
/home/jeff/repos/gatorcat/src/module/Port.zig:269:5: 0x154e696 in run (gatorcat-0.3.8-x86_64-linux-musl)
try self.nop(1, timeout_us);
^
/home/jeff/repos/gatorcat/src/cli/run.zig:85:45: 0x1549d34 in run (gatorcat-0.3.8-x86_64-linux-musl)
var raw_socket = gcat.nic.RawSocket.init(args.ifname) catch return error.NonRecoverable;
^
/home/jeff/repos/gatorcat/src/cli/main.zig:61:31: 0x154850b in main (gatorcat-0.3.8-x86_64-linux-musl)
defer std.process.argsFree(args_allocator.allocator(), args);
1 Like
that was actually the deprecated way of doing it. You should instead declare a root module and then an exe on top of it:
const cli_module = b.createModule(.{
.optimize = optimize,
.target = target,
.error_tracing = true,
.root_source_file = b.path("src/cli/main.zig"),
});
const cli = b.addExecutable(.{
.name = exe_name,
.root_module = cli_module,
});
3 Likes