tracy: workaround zig bug (#1066)

This commit is contained in:
Lee Cannon 2023-03-15 15:59:56 +00:00 committed by GitHub
parent 0475d868c4
commit 985e7069a2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -88,12 +88,15 @@ pub const Ctx = if (enable) ___tracy_c_zone_context else struct {
pub inline fn trace(comptime src: std.builtin.SourceLocation) Ctx { pub inline fn trace(comptime src: std.builtin.SourceLocation) Ctx {
if (!enable) return .{}; if (!enable) return .{};
// TODO: the below `.line = 1,` should be `.line = src.line`, this is blocked by
// https://github.com/ziglang/zig/issues/13315
if (enable_callstack) { if (enable_callstack) {
return ___tracy_emit_zone_begin_callstack(&.{ return ___tracy_emit_zone_begin_callstack(&.{
.name = null, .name = null,
.function = src.fn_name.ptr, .function = src.fn_name.ptr,
.file = src.file.ptr, .file = src.file.ptr,
.line = src.line, .line = 1,
.color = 0, .color = 0,
}, callstack_depth, 1); }, callstack_depth, 1);
} else { } else {
@ -101,7 +104,7 @@ pub inline fn trace(comptime src: std.builtin.SourceLocation) Ctx {
.name = null, .name = null,
.function = src.fn_name.ptr, .function = src.fn_name.ptr,
.file = src.file.ptr, .file = src.file.ptr,
.line = src.line, .line = 1,
.color = 0, .color = 0,
}, 1); }, 1);
} }
@ -110,12 +113,15 @@ pub inline fn trace(comptime src: std.builtin.SourceLocation) Ctx {
pub inline fn traceNamed(comptime src: std.builtin.SourceLocation, comptime name: [:0]const u8) Ctx { pub inline fn traceNamed(comptime src: std.builtin.SourceLocation, comptime name: [:0]const u8) Ctx {
if (!enable) return .{}; if (!enable) return .{};
// TODO: the below `.line = 1,` should be `.line = src.line`, this is blocked by
// https://github.com/ziglang/zig/issues/13315
if (enable_callstack) { if (enable_callstack) {
return ___tracy_emit_zone_begin_callstack(&.{ return ___tracy_emit_zone_begin_callstack(&.{
.name = name.ptr, .name = name.ptr,
.function = src.fn_name.ptr, .function = src.fn_name.ptr,
.file = src.file.ptr, .file = src.file.ptr,
.line = src.line, .line = 1,
.color = 0, .color = 0,
}, callstack_depth, 1); }, callstack_depth, 1);
} else { } else {
@ -123,7 +129,7 @@ pub inline fn traceNamed(comptime src: std.builtin.SourceLocation, comptime name
.name = name.ptr, .name = name.ptr,
.function = src.fn_name.ptr, .function = src.fn_name.ptr,
.file = src.file.ptr, .file = src.file.ptr,
.line = src.line, .line = 1,
.color = 0, .color = 0,
}, 1); }, 1);
} }