diff options
Diffstat (limited to 'gui/src/app.zig')
| -rw-r--r-- | gui/src/app.zig | 34 |
1 files changed, 30 insertions, 4 deletions
diff --git a/gui/src/app.zig b/gui/src/app.zig index f5ebf3d..8f4f4b5 100644 --- a/gui/src/app.zig +++ b/gui/src/app.zig @@ -7,6 +7,7 @@ const Client = @import("Client.zig"); const Navigation = @import("Navigation.zig"); const Geometry = @import("Geometry.zig"); const Sources = @import("Sources.zig"); +const tracy = @import("tracy"); var sources: Sources = .{}; pub const name = "ztrace debugger"; pub const width = 2240; @@ -71,6 +72,7 @@ pub const Session = struct { action: sk.Handled = .{}, graph: bool = false, scroll: [3]f64 = @splat(0), + scroll_motion: [3]Navigation.Scroll = @splat(.{}), base: [3]u64 = @splat(0), mini: [3]ui.Collected = @splat(.{}), mini_key: [3]u64 = @splat(0), @@ -542,6 +544,8 @@ fn pointer(s: *State, mouse_button: u16, x: f32, y: f32) void { } pub fn update(s: *State, in: *const sk.Input) void { + const zone = tracy.zone(@src(), "update"); + defer zone.end(); if (in.console) return; s.page_scroll = std.math.clamp(s.page_scroll, 0, @max(0, geometry.content - geometry.h)); for (in.events) |event| { @@ -832,6 +836,8 @@ fn paneButtons(u: ui.Ui, s: *const State, pane: Pane) void { } pub fn draw(s: *const State, ss: *Session, f: *sk.Frame) void { + const zone = tracy.zone(@src(), "draw"); + defer zone.end(); if (ss.launches != s.launches) ss.* = .{ .launches = s.launches }; if (ss.action.take(s.action)) |action| switch (action.kind) { .restart => f.run("restart"), @@ -847,6 +853,8 @@ pub fn draw(s: *const State, ss: *Session, f: *sk.Frame) void { if (client) |c| if (c.poll()) |update_| if (update_.generation != latest.generation) { latest = update_; if (latest.status != .running and latest.moments > loaded) { + const refresh_zone = tracy.zone(@src(), "trace refresh"); + defer refresh_zone.end(); if (zt.Trace.open(gpa, io, c.path)) |next| { if (trace) |*t| t.close(); trace = next; @@ -924,6 +932,7 @@ pub fn draw(s: *const State, ss: *Session, f: *sk.Frame) void { if (ss.graph != s.graph) { ss.graph = s.graph; ss.scroll[0] = 0; + ss.scroll_motion[0] = .{}; } const seconds = @as(f32, @floatFromInt(f.in.now -| ss.changed_at)) / 1e9; const heat = changedHeat(seconds); @@ -940,14 +949,14 @@ pub fn draw(s: *const State, ss: *Session, f: *sk.Frame) void { bases[p] = if (p == 0) address else ranges[p].addr; if (ss.base[p] != bases[p]) { ss.scroll[p] = 0; + ss.scroll_motion[p] = .{}; ss.base[p] = bases[p]; } if (p > 0) extents[p] = @max(0, @as(f64, @floatFromInt(ranges[p].len / (if (p == 1) @as(u64, 8) else 16))) - Geometry.visible(panes[p])); const target = if (nav.manual) nav.row else if (p == 0) @as(f64, 0) else @as(f64, @floatFromInt((address -| bases[p]) / (if (p == 1) @as(u64, 8) else 16))); - const dt = @as(f32, @floatFromInt(f.in.dt)) / 1e9; // Avoid animating across millions of uncaptured rows after an address jump. if (p == 0 and nav.follow and !nav.manual) continue; - if (@abs(ss.scroll[p] - target) > Geometry.visible(panes[p]) * 2) ss.scroll[p] = target else ss.scroll[p] = std.math.lerp(ss.scroll[p], target, 1 - @exp(-dt * 18)); + ss.scroll[p] = ss.scroll_motion[p].sample(ss.scroll[p], target, f.in.now, Geometry.visible(panes[p]) * 2); shown_scroll[p] = ss.scroll[p]; } listing(ss, m, bases[0]); @@ -989,6 +998,8 @@ pub fn draw(s: *const State, ss: *Session, f: *sk.Frame) void { ties(u, s, ss); } fn listing(ss: *Session, m: zt.store.Moment, base: u64) void { + const zone = tracy.zone(@src(), "listing"); + defer zone.end(); if (ss.listing_at == m.index and ss.listing_base == base) return; ss.listing_at = m.index; ss.listing_base = base; @@ -1091,6 +1102,8 @@ fn codeRows(u: ui.Ui, s: *const State, ss: *Session, m: zt.store.Moment, regs: z }; } fn drawCode(u: ui.Ui, s: *const State, ss: *Session, m: zt.store.Moment, regs: zt.Regs, heat: ui.Heat, fire: f32, travel: f32) void { + const zone = tracy.zone(@src(), "drawCode"); + defer zone.end(); code_top = 32; const actual_height = @min(panes[0].h, geometry.h - 40 - panes[0].y); origin_height = if (actual_height < 250) 48 else 72; @@ -1128,8 +1141,7 @@ fn drawCode(u: ui.Ui, s: *const State, ss: *Session, m: zt.store.Moment, regs: z } const visible = codeVisible(); const target = @max(0, @max(start - 2, ss.marker_to - visible + @min(3, visible))); - const dt = @as(f32, @floatFromInt(u.f.in.dt)) / 1e9; - ss.scroll[0] = std.math.lerp(ss.scroll[0], target, 1 - @exp(-dt * 18)); + ss.scroll[0] = ss.scroll_motion[0].sample(ss.scroll[0], target, u.f.in.now, std.math.inf(f64)); shown_scroll[0] = ss.scroll[0]; } const marker_time = @as(f32, @floatFromInt(u.f.in.now -| ss.marker_at)) / 1e9; @@ -1202,6 +1214,8 @@ fn drawCode(u: ui.Ui, s: *const State, ss: *Session, m: zt.store.Moment, regs: z } } fn drawRegisters(u: ui.Ui, s: *const State, ss: *Session, m: zt.store.Moment, regs: zt.Regs, heat: ui.Heat, seconds: f32, fire: f32) void { + const zone = tracy.zone(@src(), "drawRegisters"); + defer zone.end(); _ = u.panel(geometry.registers.w, geometry.registers.h, "registers / call stack", .{ .note = u.print("{d} changed", .{@popCount(ss.changed_regs)}) }); u.clip(.{ .x = 2, .y = 30, .w = geometry.registers.w - 4, .h = geometry.registers.h - 34 }); const v = u.moved(0, -s.register_scroll * 24); @@ -1247,6 +1261,8 @@ fn stackRows(u: ui.Ui, s: *const State, ss: *Session, m: zt.store.Moment, regs: } } fn drawStack(u: ui.Ui, s: *const State, ss: *Session, m: zt.store.Moment, regs: zt.Regs, heat: ui.Heat, seconds: f32) void { + const zone = tracy.zone(@src(), "drawStack"); + defer zone.end(); _ = u.panel(panes[1].w, panes[1].h, if (panes[1].w < 600) "stack" else "stack / telescope", .{ .focus = s.focus == .stack }); if (panes[1].w > 800) u.text(.sans, 17, 235, 19, u.print("{d} pointer hops", .{s.depth}), ui.theme.color.text.dim); paneButtons(u, s, .stack); @@ -1309,6 +1325,8 @@ fn memoryRows(u: ui.Ui, s: *const State, ss: *Session, m: zt.store.Moment, first } } fn drawMemory(u: ui.Ui, s: *const State, ss: *Session, m: zt.store.Moment, heat: ui.Heat) void { + const zone = tracy.zone(@src(), "drawMemory"); + defer zone.end(); _ = u.panel(panes[2].w, panes[2].h, "memory", .{ .focus = s.focus == .memory }); paneButtons(u, s, .memory); button(u, 112, -3, .{ .kind = .unit, .address = s.unit }, "Group size: 8 / 16 / 32 / 64 bits", true, false); @@ -1323,6 +1341,8 @@ fn drawMemory(u: ui.Ui, s: *const State, ss: *Session, m: zt.store.Moment, heat: } } fn memoryMini(u: ui.Ui, ss: *Session, m: zt.store.Moment, p: usize) void { + const zone = tracy.zone(@src(), "memoryMini"); + defer zone.end(); const stride: u64 = if (p == 1) 8 else 16; const current = bases[p] + @as(u64, @intFromFloat(ss.scroll[p])) * stride; const first = @max(bases[p], current -| 32 * stride); @@ -1384,6 +1404,8 @@ fn visibleHit(hit: Hit) bool { return true; } fn ties(u: ui.Ui, s: *const State, ss: *Session) void { + const zone = tracy.zone(@src(), "ties"); + defer zone.end(); if (s.help or s.segments or s.command_open) return; const hovered = addressAt(u.f.in.mouse_x / display_scale, u.f.in.mouse_y / display_scale); const address = if (hovered) |hit| hit.address else if (s.selected_address != 0) s.selected_address else if (ss.touch) |touch| touch.addr else return; @@ -1414,6 +1436,8 @@ fn ties(u: ui.Ui, s: *const State, ss: *Session) void { }; } fn overlays(u: ui.Ui, s: *const State, ss: *Session, moment: ?zt.store.Moment) void { + const zone = tracy.zone(@src(), "overlays"); + defer zone.end(); const ink = ui.theme.color.text; if (!s.lens) ss.lens_previous = 0; if (s.lens and moment != null) { @@ -1573,6 +1597,8 @@ fn rowOf(m: zt.store.Moment, start: u64, address: u64) ?usize { } fn selected(ss: *Session, t: *zt.Trace, m: zt.store.Moment, regs: zt.Regs, tid: u32, low: u64, now: u64) void { + const zone = tracy.zone(@src(), "selected"); + defer zone.end(); if (rowOf(m, ss.code_start, regs.rip) == null) { ss.code_start = regs.rip; for (0..6) |_| { |
