mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-23 20:26:09 +03:00
crash: tag the thread type
This commit is contained in:
@ -23,8 +23,13 @@ var init_thread: ?std.Thread = null;
|
||||
/// This means that if we want to set thread-specific data we have to do it
|
||||
/// on our own in the on crash callback.
|
||||
pub const ThreadState = struct {
|
||||
/// Thread type, used to tag the crash
|
||||
type: Type,
|
||||
|
||||
/// The surface that this thread is attached to.
|
||||
surface: *Surface,
|
||||
|
||||
pub const Type = enum { main, renderer, io };
|
||||
};
|
||||
|
||||
/// See ThreadState. This should only ever be set by the owner of the
|
||||
@ -156,6 +161,14 @@ fn beforeSend(
|
||||
event.set("contexts", obj);
|
||||
break :contexts obj;
|
||||
};
|
||||
const tags = event.get("tags") orelse tags: {
|
||||
const obj = sentry.Value.initObject();
|
||||
event.set("tags", obj);
|
||||
break :tags obj;
|
||||
};
|
||||
|
||||
// Store our thread type
|
||||
tags.set("thread-type", sentry.Value.initString(@tagName(thr_state.type)));
|
||||
|
||||
// Read the surface data. This is likely unsafe because on a crash
|
||||
// other threads can continue running. We don't have race-safe way to
|
||||
@ -189,7 +202,7 @@ fn beforeSend(
|
||||
sentry.Value.initInt32(std.math.cast(i32, surface.cell_size.height) orelse -1),
|
||||
);
|
||||
|
||||
contexts.set("dimensions", obj);
|
||||
contexts.set("Dimensions", obj);
|
||||
}
|
||||
|
||||
return event_val;
|
||||
|
@ -194,6 +194,7 @@ fn threadMain_(self: *Thread) !void {
|
||||
|
||||
// Setup our crash metadata
|
||||
crash.sentry.thread_state = .{
|
||||
.type = .renderer,
|
||||
.surface = self.renderer.surface_mailbox.surface,
|
||||
};
|
||||
defer crash.sentry.thread_state = null;
|
||||
|
@ -203,6 +203,7 @@ fn threadMain_(self: *Thread, io: *termio.Termio) !void {
|
||||
|
||||
// Setup our crash metadata
|
||||
crash.sentry.thread_state = .{
|
||||
.type = .io,
|
||||
.surface = io.surface_mailbox.surface,
|
||||
};
|
||||
defer crash.sentry.thread_state = null;
|
||||
|
Reference in New Issue
Block a user