Skip to documentation
SLOP

tiny.trace.Event

Reference tiny.trace Event

Defined in event.

API (28)

Actions

Public operations.

Fields and members

Public fields and members.

No direct callersNo direct callseventEvent
Static calls · unresolved targets: unknown · external targets: unknown.

Source

Source: lib/trace/src/event.zig:85

zig
pub const Event = struct {    kind: EventKind,    timepoint: Timepoint,    function_id: u64 = 0,    site_id: u64 = 0,    stack_map_id: u64 = 0,    object_id: u64 = 0,    size: u64 = 0,    alignment: u32 = 0,    status: i64 = 0,    operation: ?[]const u8 = null,    label: ?[]const u8 = null,    data: ?[]const u8 = null,    pub fn sessionStart(timepoint: Timepoint, label: []const u8) Event {        return .{ .kind = .session_start, .timepoint = timepoint, .label = label };    }    pub fn sessionEnd(timepoint: Timepoint, status: i64) Event {        return .{ .kind = .session_end, .timepoint = timepoint, .status = status };    }    pub fn functionEnter(timepoint: Timepoint, safepoint: Safepoint) Event {        return functionEvent(.function_enter, timepoint, safepoint);    }    pub fn functionExit(timepoint: Timepoint, safepoint: Safepoint) Event {        return functionEvent(.function_exit, timepoint, safepoint);    }    pub fn safepointReached(timepoint: Timepoint, safepoint: Safepoint) Event {        return functionEvent(.safepoint, timepoint, safepoint);    }    pub fn boundaryBytes(timepoint: Timepoint, operation: []const u8, bytes: []const u8) Event {        return .{            .kind = .boundary,            .timepoint = timepoint,            .operation = operation,            .data = bytes,        };    }    pub fn allocation(        timepoint: Timepoint,        object_id: u64,        size: u64,        alignment: u32,        label: ?[]const u8,    ) Event {        return .{            .kind = .allocation,            .timepoint = timepoint,            .object_id = object_id,            .size = size,            .alignment = alignment,            .label = label,        };    }    pub fn free(timepoint: Timepoint, object_id: u64) Event {        return .{ .kind = .free, .timepoint = timepoint, .object_id = object_id };    }    pub fn checkpoint(timepoint: Timepoint, label: []const u8, bytes: []const u8) Event {        return .{            .kind = .checkpoint,            .timepoint = timepoint,            .label = label,            .data = bytes,        };    }    pub fn checkpointRestore(timepoint: Timepoint, label: []const u8) Event {        return .{ .kind = .checkpoint_restore, .timepoint = timepoint, .label = label };    }    pub fn user(timepoint: Timepoint, label: []const u8, bytes: []const u8) Event {        return .{            .kind = .user,            .timepoint = timepoint,            .label = label,            .data = bytes,        };    }    pub fn cloneAlloc(self: Event, allocator: Allocator) !Event {        var cloned = self;        cloned.operation = if (self.operation) |operation|            try allocator.dupe(u8, operation)        else            null;        errdefer if (cloned.operation) |operation| allocator.free(operation);        cloned.label = if (self.label) |label|            try allocator.dupe(u8, label)        else            null;        errdefer if (cloned.label) |label| allocator.free(label);        cloned.data = if (self.data) |data|            try allocator.dupe(u8, data)        else            null;        errdefer if (cloned.data) |data| allocator.free(data);        return cloned;    }    pub fn deinit(self: *Event, allocator: Allocator) void {        if (self.operation) |operation| allocator.free(operation);        if (self.label) |label| allocator.free(label);        if (self.data) |data| allocator.free(data);        self.* = undefined;    }    pub fn eqlForReplay(left: Event, right: Event) bool {        return left.kind == right.kind and            Timepoint.eql(left.timepoint, right.timepoint) and            left.function_id == right.function_id and            left.site_id == right.site_id and            left.stack_map_id == right.stack_map_id and            left.object_id == right.object_id and            left.size == right.size and            left.alignment == right.alignment and            left.status == right.status and            optionalBytesEql(left.operation, right.operation) and            optionalBytesEql(left.label, right.label) and            optionalBytesEql(left.data, right.data);    }    pub fn writeJsonLine(self: Event, writer: *std.Io.Writer) !void {        var stream = pretty_json.Writer.init(writer, .minified);        const object = try stream.object();        try object.field("v", trace_format_version);        const timepoint = try object.object("timepoint");        try timepoint.field("epoch", self.timepoint.epoch);        try timepoint.field("thread", self.timepoint.thread_id);        try timepoint.field("seq", self.timepoint.seq);        try timepoint.end();        try object.field("kind", self.kind.tag());        try object.field("function_id", self.function_id);        try object.field("site_id", self.site_id);        try object.field("stack_map_id", self.stack_map_id);        try object.field("object_id", self.object_id);        try object.field("size", self.size);        try object.field("alignment", self.alignment);        try object.field("status", self.status);        if (self.operation) |operation| try object.field("operation", operation);        if (self.label) |label| try object.field("label", label);        if (self.data) |data| try object.hexString("data_hex", data);        try object.endLine();    }    pub fn fromJsonLine(allocator: Allocator, line: []const u8) !Event {        const parsed = std.json.parseFromSlice(std.json.Value, allocator, line, .{}) catch            return error.InvalidEventJson;        defer parsed.deinit();        const object = switch (parsed.value) {            .object => |object| object,            else => return error.InvalidEventJson,        };        const version = try jsonU64(object.get("v") orelse return error.InvalidEventJson);        if (version != trace_format_version) return error.UnsupportedTraceVersion;        const timepoint_object = switch (object.get("timepoint") orelse return error.InvalidEventJson) {            .object => |value| value,            else => return error.InvalidEventJson,        };        const kind_text = try jsonString(object.get("kind") orelse return error.InvalidEventJson);        const kind = EventKind.fromTag(kind_text) orelse return error.InvalidEventJson;        var event = Event{            .kind = kind,            .timepoint = .{                .epoch = try jsonU64(timepoint_object.get("epoch") orelse return error.InvalidEventJson),                .thread_id = @intCast(try jsonU64(timepoint_object.get("thread") orelse return error.InvalidEventJson)),                .seq = try jsonU64(timepoint_object.get("seq") orelse return error.InvalidEventJson),            },            .function_id = try jsonU64(object.get("function_id") orelse return error.InvalidEventJson),            .site_id = try jsonU64(object.get("site_id") orelse return error.InvalidEventJson),            .stack_map_id = try jsonU64(object.get("stack_map_id") orelse return error.InvalidEventJson),            .object_id = try jsonU64(object.get("object_id") orelse return error.InvalidEventJson),            .size = try jsonU64(object.get("size") orelse return error.InvalidEventJson),            .alignment = @intCast(try jsonU64(object.get("alignment") orelse return error.InvalidEventJson)),            .status = try jsonI64(object.get("status") orelse return error.InvalidEventJson),        };        errdefer event.deinit(allocator);        if (object.get("operation")) |operation| {            event.operation = try allocator.dupe(u8, try jsonString(operation));        }        if (object.get("label")) |label| {            event.label = try allocator.dupe(u8, try jsonString(label));        }        if (object.get("data_hex")) |data_hex| {            event.data = try decodeHexAlloc(allocator, try jsonString(data_hex));        }        return event;    }};

Source: lib/trace/src/root.zig:43

zig
pub const Event = event.Event;
Called byCallsNo direct callsprivate sourcelib.trace.src.properties.session.Actionexpectedprivate sourcelib.trace.src.properties.storedrawEventtest sourcelib.trace.src.replaytest: object query writes allocation ...test sourcelib.trace.src.replaytest: summary query writes trace-leve...SessionallocationEventallocation
Static calls · unresolved targets: 0 · external targets: 0.
Called byCallsNo direct callstest sourcelib.trace.src.eventtest: event json roundtrip preserves ...private sourcelib.trace.src.properties.storedrawEventtest sourcelib.trace.src.replaytest: summary query writes trace-leve...test sourcelib.trace.src.replaytest: thread query writes per-thread ...SessionboundaryBytesAlloc+3 moreEventboundaryBytes
Static calls · unresolved targets: 0 · external targets: 0.
Called byCallsNo direct callsprivate sourcelib.trace.src.properties.storedrawEventtest sourcelib.trace.src.replaytest: checkpoint lookup returns neare...SessioncheckpointCapturetest sourcelib.trace.src.sessiontest: session failure atomicity prese...test sourcelib.trace.src.sessiontest: session failure atomicity valid...Eventcheckpoint
Static calls · unresolved targets: 0 · external targets: 0.
Called byCallsNo direct callsprivate sourcelib.trace.src.properties.storedrawEventSessioncheckpointRestoretest sourcelib.trace.src.sessiontest: session failure atomicity valid...EventcheckpointRestore
Static calls · unresolved targets: 0 · external targets: 0.
Called byCallsNo direct callersTimepointeqlprivate sourcelib.trace.src.eventoptionalBytesEqlEventeqlForReplay
Static calls · unresolved targets: 0 · external targets: 0.
Called byCallsNo direct callsprivate sourcelib.trace.src.properties.session.Actionexpectedprivate sourcelib.trace.src.properties.storedrawEventtest sourcelib.trace.src.replaytest: object query writes allocation ...test sourcelib.trace.src.replaytest: summary query writes trace-leve...SessionfreeEventfree
Static calls · unresolved targets: 0 · external targets: 0.
Called byCallstest sourcelib.trace.src.eventtest: event json roundtrip preserves ...private sourcelib.trace.src.properties.storeexpectJsonRoundtripEventKindfromTagprivate sourcelib.trace.src.eventdecodeHexAllocprivate sourcelib.trace.src.eventjsonI64private sourcelib.trace.src.eventjsonStringprivate sourcelib.trace.src.eventjsonU64EventfromJsonLine
Static calls · unresolved targets: 2 · external targets: 3.
Called byCallsprivate sourcelib.trace.src.properties.session.Actionexpectedprivate sourcelib.trace.src.properties.storedrawEventtest sourcelib.trace.src.replaytest: frame query drops exited frames...test sourcelib.trace.src.replaytest: frame query ignores other threa...test sourcelib.trace.src.replaytest: frame query returns active stac...+2 moreprivate sourcelib.trace.src.eventfunctionEventEventfunctionEnter
Static calls · unresolved targets: 0 · external targets: 0.
Called byCallsprivate sourcelib.trace.src.properties.session.Actionexpectedprivate sourcelib.trace.src.properties.storedrawEventtest sourcelib.trace.src.replaytest: frame query drops exited frames...test sourcelib.trace.src.replaytest: frame query returns active stac...SessionfunctionExitprivate sourcelib.trace.src.eventfunctionEventEventfunctionExit
Static calls · unresolved targets: 0 · external targets: 0.
Called byCallsprivate sourcelib.trace.src.properties.session.Actionexpectedprivate sourcelib.trace.src.properties.storedrawEventtest sourcelib.trace.src.replaytest: frame query represents safepoin...test sourcelib.trace.src.replaytest: frame query returns active stac...test sourcelib.trace.src.replaytest: object query writes allocation ...+5 moreprivate sourcelib.trace.src.eventfunctionEventEventsafepointReached
Static calls · unresolved targets: 0 · external targets: 0.
Called byCallsNo direct callsprivate sourcelib.trace.src.properties.session.Actionexpectedprivate sourcelib.trace.src.properties.storedrawEventtest sourcelib.trace.src.replaytest: summary query writes trace-leve...test sourcelib.trace.src.replaytest: thread query writes per-thread ...SessionsessionEndEventsessionEnd
Static calls · unresolved targets: 0 · external targets: 0.
Called byCallsNo direct callsprivate sourcelib.trace.src.properties.session.Actionexpectedprivate sourcelib.trace.src.properties.storedrawEventtest sourcelib.trace.src.replaytest: summary query writes trace-leve...test sourcelib.trace.src.replaytest: thread query writes per-thread ...test sourcelib.trace.src.replaytest: timepoint query writes compact ...+5 moreEventsessionStart
Static calls · unresolved targets: 0 · external targets: 0.
Called byCallsNo direct callsprivate sourcelib.choir.src.backends.gpu.metal.mslwriteMemberprivate sourcelib.trace.src.properties.session.Actionexpectedprivate sourcelib.trace.src.properties.storedrawEventtest sourcelib.trace.src.replaytest: checkpoint lookup returns neare...test sourcelib.trace.src.replaytest: timepoint query writes compact ...+15 moreEventuser
Static calls · unresolved targets: 0 · external targets: 0.
Called byCallsNo direct callersEventKindtagEventwriteJsonLine
Static calls · unresolved targets: 0 · external targets: 8.

Complete caller list for Event.boundaryBytes

8 direct callers.

Complete caller list for Event.functionEnter

7 direct callers.

Complete caller list for Event.safepointReached

10 direct callers.

Complete caller list for Event.sessionStart

10 direct callers.

Complete caller list for Event.user

20 direct callers.

Audit

Definitions17
Public names34
Members12
Version26.7.0
Revisiondaab053ee433