| ... | @@ -22,7 +22,7 @@ pub fn deinit() void { | ... | @@ -22,7 +22,7 @@ pub fn deinit() void { |
| 22 | pub fn init_thread() !void { | 22 | pub fn init_thread() !void { |
| 23 | tid = std.os.linux.gettid(); | 23 | tid = std.os.linux.gettid(); |
| 24 | | 24 | |
| 25 | path = try std.fmt.allocPrint(alloc, "/data/trace.{d}.{d}.spall.json", .{ pid, tid }); | 25 | path = try std.fmt.allocPrint(alloc, "/data/trace.{d}.{d}.chrome.json", .{ pid, tid }); |
| 26 | file = try std.fs.cwd().createFile(path, .{}); | 26 | file = try std.fs.cwd().createFile(path, .{}); |
| 27 | buffered_writer = std.io.bufferedWriter(file.writer()); | 27 | buffered_writer = std.io.bufferedWriter(file.writer()); |
| 28 | | 28 | |
| ... | @@ -38,16 +38,19 @@ pub fn deinit_thread() void { | ... | @@ -38,16 +38,19 @@ pub fn deinit_thread() void { |
| 38 | log.debug("{s}", .{path}); | 38 | log.debug("{s}", .{path}); |
| 39 | } | 39 | } |
| 40 | | 40 | |
| 41 | pub inline fn trace_begin(ctx: tracer.Ctx) void { | 41 | pub inline fn trace_begin(ctx: tracer.Ctx, comptime ifmt: []const u8, iargs: anytype) void { |
| 42 | buffered_writer.writer().print( | 42 | buffered_writer.writer().print( |
| 43 | \\{{"cat":"function", "name":"{s}:{d}:{d} ({s})", "ph": "B", "pid": {d}, "tid": {d}, "ts": {d}}}, | 43 | \\{{"cat":"function", "name":"{s}:{d}:{d} ({s}) |
| 44 | \\ | 44 | ++ ifmt ++ |
| | 45 | \\", "ph": "B", "pid": {d}, "tid": {d}, "ts": {d}}}, |
| | 46 | \\ |
| 45 | , | 47 | , |
| 46 | .{ | 48 | .{ |
| 47 | if (ctx.src.file[0] == '/') ctx.src.file[trim_count..] else ctx.src.file, | 49 | if (ctx.src.file[0] == '/') ctx.src.file[trim_count..] else ctx.src.file, |
| 48 | ctx.src.line, | 50 | ctx.src.line, |
| 49 | ctx.src.column, | 51 | ctx.src.column, |
| 50 | ctx.src.fn_name, | 52 | ctx.src.fn_name, |
| | 53 | } ++ iargs ++ .{ |
| 51 | pid, | 54 | pid, |
| 52 | tid, | 55 | tid, |
| 53 | std.time.microTimestamp(), | 56 | std.time.microTimestamp(), |