this repo has no description

add: support for GC frames

altagos.dev 812a65d7 e0d67a20

verified
+13 -16
+13 -16
src/austin.zig
··· 21 21 pub const FrameWrapper = union(enum) { 22 22 call_stack: Frame, 23 23 invalid: void, 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 - .invalid => {}, 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 - usize => { 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 - }, 104 - ?usize => { 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 - error.InvalidFrame => { 342 - try frames.append(FrameWrapper{ .invalid = {} }); 343 - break; 344 - }, 345 339 ParseError.NoModule, 346 340 ParseError.InvalidLineNumber, 347 341 ParseError.NoFunction, ··· 362 356 else => return err, 363 357 } 364 358 }; 365 - try frames.append(FrameWrapper{ .call_stack = frame }); 359 + try frames.append(frame); 366 360 } 367 361 368 362 sample.frames = try frames.toOwnedSlice(); 369 363 } 370 364 371 - fn parseFrame(self: *Parser, frame_raw: []const u8) !Frame { 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 - return Frame{ 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 - }; 375 + } }; 382 376 } 377 + 378 + if (mem.eql(u8, module, "GC")) 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 - return f; 398 - } else { 399 - return error.InvalidFrame; 394 + return FrameWrapper{ .call_stack = f }; 400 395 } 396 + 397 + return FrameWrapper{ .invalid = {} }; 401 398 } 402 399 };