| author | |
| committer | |
| log | 4fb61d4447b4e90d385c961a45c54aed8352381e |
| tree | c958b3ae4b9632d87518adcae2a00e9fa3c81f74 |
| parent | f87511611a32cbb063bd77e6cc9130965333a30d |
3 files changed, 6 insertions(+), 14 deletions(-)
build.zig+1-2| ... | @@ -14,13 +14,12 @@ pub fn build(b: *std.Build) void { | ... | @@ -14,13 +14,12 @@ pub fn build(b: *std.Build) void { |
| 14 | addTest(b, target, mode, disable_llvm, mod, 3); | 14 | addTest(b, target, mode, disable_llvm, mod, 3); |
| 15 | 15 | ||
| 16 | const test_step = b.step("test", "Run all library tests"); | 16 | const test_step = b.step("test", "Run all library tests"); |
| 17 | test_step.dependOn(b.default_step); | 17 | test_step.dependOn(b.getInstallStep()); |
| 18 | } | 18 | } |
| 19 | 19 | ||
| 20 | fn addTest(b: *std.Build, target: std.Build.ResolvedTarget, mode: std.builtin.Mode, disable_llvm: bool, mod: *std.Build.Module, comptime backend: u8) void { | 20 | fn addTest(b: *std.Build, target: std.Build.ResolvedTarget, mode: std.builtin.Mode, disable_llvm: bool, mod: *std.Build.Module, comptime backend: u8) void { |
| 21 | _ = mod; | 21 | _ = mod; |
| 22 | const options = b.addOptions(); | 22 | const options = b.addOptions(); |
| 23 | options.addOption(usize, "src_file_trimlen", std.fs.path.dirname(std.fs.path.dirname(@src().file).?).?.len); | ||
| 24 | options.addOption(u8, "backend", backend); | 23 | options.addOption(u8, "backend", backend); |
| 25 | 24 | ||
| 26 | const exe = b.addExecutable(.{ | 25 | const exe = b.addExecutable(.{ |
src/chrome.zig+4-5| ... | @@ -3,7 +3,6 @@ const tracer = @import("./mod.zig"); | ... | @@ -3,7 +3,6 @@ const tracer = @import("./mod.zig"); |
| 3 | const alloc = std.heap.c_allocator; | 3 | const alloc = std.heap.c_allocator; |
| 4 | const log = std.log.scoped(.tracer); | 4 | const log = std.log.scoped(.tracer); |
| 5 | const root = @import("root"); | 5 | const root = @import("root"); |
| 6 | const trim_count = root.build_options.src_file_trimlen; | ||
| 7 | 6 | ||
| 8 | var pid: std.os.linux.pid_t = undefined; | 7 | var pid: std.os.linux.pid_t = undefined; |
| 9 | threadlocal var tid: std.os.linux.pid_t = undefined; | 8 | threadlocal var tid: std.os.linux.pid_t = undefined; |
| ... | @@ -40,12 +39,12 @@ pub fn deinit_thread() void { | ... | @@ -40,12 +39,12 @@ pub fn deinit_thread() void { |
| 40 | pub inline fn trace_begin(ctx: tracer.Ctx, comptime ifmt: []const u8, iargs: anytype) void { | 39 | pub inline fn trace_begin(ctx: tracer.Ctx, comptime ifmt: []const u8, iargs: anytype) void { |
| 41 | buffered_writer.writer().print( | 40 | buffered_writer.writer().print( |
| 42 | \\{{"cat":"function", "name":"{s}:{d}:{d} ({s}) | 41 | \\{{"cat":"function", "name":"{s}:{d}:{d} ({s}) |
| 43 | ++ ifmt ++ | 42 | ++ ifmt ++ |
| 44 | \\", "ph": "B", "pid": {d}, "tid": {d}, "ts": {d}}}, | 43 | \\", "ph": "B", "pid": {d}, "tid": {d}, "ts": {d}}}, |
| 45 | \\ | 44 | \\ |
| 46 | , | 45 | , |
| 47 | .{ | 46 | .{ |
| 48 | if (ctx.src.file[0] == '/') ctx.src.file[trim_count..] else ctx.src.file, | 47 | ctx.src.file, |
| 49 | ctx.src.line, | 48 | ctx.src.line, |
| 50 | ctx.src.column, | 49 | ctx.src.column, |
| 51 | ctx.src.fn_name, | 50 | ctx.src.fn_name, |
src/spall.zig+1-7| ... | @@ -3,7 +3,6 @@ const tracer = @import("./mod.zig"); | ... | @@ -3,7 +3,6 @@ const tracer = @import("./mod.zig"); |
| 3 | const alloc = std.heap.c_allocator; | 3 | const alloc = std.heap.c_allocator; |
| 4 | const log = std.log.scoped(.tracer); | 4 | const log = std.log.scoped(.tracer); |
| 5 | const root = @import("root"); | 5 | const root = @import("root"); |
| 6 | const trim_count = root.build_options.src_file_trimlen; | ||
| 7 | 6 | ||
| 8 | var pid: std.os.linux.pid_t = undefined; | 7 | var pid: std.os.linux.pid_t = undefined; |
| 9 | threadlocal var tid: std.os.linux.pid_t = undefined; | 8 | threadlocal var tid: std.os.linux.pid_t = undefined; |
| ... | @@ -38,12 +37,7 @@ pub fn deinit_thread() void { | ... | @@ -38,12 +37,7 @@ pub fn deinit_thread() void { |
| 38 | 37 | ||
| 39 | pub inline fn trace_begin(ctx: tracer.Ctx, comptime ifmt: []const u8, iargs: anytype) void { | 38 | pub inline fn trace_begin(ctx: tracer.Ctx, comptime ifmt: []const u8, iargs: anytype) void { |
| 40 | const fmt = "{s}:{d}:{d} ({s})" ++ ifmt; | 39 | const fmt = "{s}:{d}:{d} ({s})" ++ ifmt; |
| 41 | const args = .{ | 40 | const args = .{ ctx.src.file, ctx.src.line, ctx.src.column, ctx.src.fn_name }; |
| 42 | if (ctx.src.file[0] == '/') ctx.src.file[trim_count..] else ctx.src.file, | ||
| 43 | ctx.src.line, | ||
| 44 | ctx.src.column, | ||
| 45 | ctx.src.fn_name, | ||
| 46 | }; | ||
| 47 | buffered_writer.writer().writeStruct(BeginEvent{ | 41 | buffered_writer.writer().writeStruct(BeginEvent{ |
| 48 | .pid = @intCast(pid), | 42 | .pid = @intCast(pid), |
| 49 | .tid = @intCast(tid), | 43 | .tid = @intCast(tid), |