tangled
alpha
login
or
join now
altagos.dev
/
austin-converter
0
fork
atom
this repo has no description
0
fork
atom
overview
issues
pulls
pipelines
add: support for GC frames
altagos.dev
8 months ago
812a65d7
e0d67a20
verified
This commit was signed with the committer's
known signature
.
altagos.dev
SSH Key Fingerprint:
SHA256:UbTjEcCZlc6GzQWLCuDK3D//HESWD2xFPkzue9XMras=
+13
-16
1 changed file
expand all
collapse all
unified
split
src
austin.zig
+13
-16
src/austin.zig
···
21
21
pub const FrameWrapper = union(enum) {
22
22
call_stack: Frame,
23
23
invalid: void,
24
24
+
gc: void,
24
25
};
25
26
26
27
pub const Metric = struct {
···
53
54
inline else => |*sample| {
54
55
for (sample.frames) |frame| {
55
56
switch (frame) {
56
56
-
.invalid => {},
57
57
+
.invalid, .gc => {},
57
58
.call_stack => |stack| {
58
59
allocator.free(stack.module);
59
60
allocator.free(stack.function);
···
92
93
std.SemanticVersion => {
93
94
field_ptr.* = try std.SemanticVersion.parse(value);
94
95
},
95
95
-
usize => {
96
96
+
usize, ?usize => {
96
97
field_ptr.* = try std.fmt.parseUnsigned(usize, value, 0);
97
98
},
98
99
bool => {
···
100
101
},
101
102
@TypeOf(self.mode) => {
102
103
field_ptr.* = std.meta.stringToEnum(@TypeOf(self.mode), value) orelse return error.UnknownMetadataFieldValue;
103
103
-
},
104
104
-
?usize => {
105
105
-
field_ptr.* = try std.fmt.parseUnsigned(usize, value, 0);
106
104
},
107
105
else => @compileError("Unsupported metadata field type: " ++ @typeName(field.type)),
108
106
}
···
338
336
while (data.next()) |frame_raw| {
339
337
const frame = self.parseFrame(frame_raw) catch |err| {
340
338
switch (err) {
341
341
-
error.InvalidFrame => {
342
342
-
try frames.append(FrameWrapper{ .invalid = {} });
343
343
-
break;
344
344
-
},
345
339
ParseError.NoModule,
346
340
ParseError.InvalidLineNumber,
347
341
ParseError.NoFunction,
···
362
356
else => return err,
363
357
}
364
358
};
365
365
-
try frames.append(FrameWrapper{ .call_stack = frame });
359
359
+
try frames.append(frame);
366
360
}
367
361
368
362
sample.frames = try frames.toOwnedSlice();
369
363
}
370
364
371
371
-
fn parseFrame(self: *Parser, frame_raw: []const u8) !Frame {
365
365
+
fn parseFrame(self: *Parser, frame_raw: []const u8) !FrameWrapper {
372
366
var frame = std.mem.tokenizeScalar(u8, frame_raw, ':');
373
367
const module = frame.next() orelse return ParseError.NoModule;
374
368
375
369
if (mem.startsWith(u8, frame_raw, "::")) {
376
376
-
return Frame{
370
370
+
return FrameWrapper{ .call_stack = Frame{
377
371
.module = "",
378
372
.function = "",
379
373
.line_number = std.fmt.parseInt(isize, module, 0) catch
380
374
return ParseError.InvalidLineNumber,
381
381
-
};
375
375
+
} };
382
376
}
377
377
+
378
378
+
if (mem.eql(u8, module, "GC"))
379
379
+
return FrameWrapper{ .gc = {} };
383
380
384
381
if (!mem.eql(u8, module, "INVALID")) {
385
382
const function = frame.next() orelse return ParseError.NoFunction;
···
394
391
f.module = try self.arena.dupe(u8, module);
395
392
f.function = try self.arena.dupe(u8, function);
396
393
397
397
-
return f;
398
398
-
} else {
399
399
-
return error.InvalidFrame;
394
394
+
return FrameWrapper{ .call_stack = f };
400
395
}
396
396
+
397
397
+
return FrameWrapper{ .invalid = {} };
401
398
}
402
399
};