diff options
| author | Gabriel Schneider <[email protected]> | 2026-11-13 12:30:37 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-11-13 12:31:12 -0300 |
| commit | 5adffa613619eea42405d0cfdb402705e0f4751f (patch) | |
| tree | 5835048cf6a29a449182fba71c67a2583ed6335d | |
| parent | 4f31aaef1338b53195f8c475db5a72d75cc1fc82 (diff) | |
| download | computeranim-5adffa613619eea42405d0cfdb402705e0f4751f.tar.gz computeranim-5adffa613619eea42405d0cfdb402705e0f4751f.zip | |
debugger: make hexdump pointer bytes clickable in every integer grouping
Publish full pointer spans from the shared byte renderer and grouped numeric rows. Both mouse buttons now use the existing lens/navigation handlers even in 8-bit view, including zero padding. Reject pointer hits when any constituent byte is uncaptured.
Verified native/headless left and right clicks, recursive lenses, stack destinations, and GUI/shared-renderer suites.
| -rw-r--r-- | anim/src/rows.zig | 10 | ||||
| -rw-r--r-- | gui/README.md | 4 | ||||
| -rw-r--r-- | gui/bench/RESULTS.md | 9 | ||||
| -rw-r--r-- | gui/targets/segments.c | 3 | ||||
| -rw-r--r-- | gui/test/lenses.py | 42 |
5 files changed, 64 insertions, 4 deletions
diff --git a/anim/src/rows.zig b/anim/src/rows.zig index 0e4f58c..3d0c75c 100644 --- a/anim/src/rows.zig +++ b/anim/src/rows.zig @@ -68,6 +68,7 @@ pub fn wordsAt(u: ui.Ui, y: f32, addr: u64, values: *const [16]u8, known: *const std.debug.assert(unit == 1 or unit == 2 or unit == 4 or unit == 8); _ = u.address(theme.metric.bytes.address, baseline(y), addr, .{ .ink = ui.rgb(ink(regionOf(moment, addr))) }); var x = theme.metric.bytes.first + addressRoom(addr); + var pointer_x = x; var at_byte: usize = 0; while (at_byte < 16) : (at_byte += unit) { const octets = values[at_byte..][0..unit]; @@ -81,10 +82,12 @@ pub fn wordsAt(u: ui.Ui, y: f32, addr: u64, values: *const [16]u8, known: *const .float => if (unit == 8) 25 else 16, }; const width = @as(f32, @floatFromInt(digits)) * adv; - const value = if (unit == 8) std.mem.readInt(u64, octets[0..8], .little) else 0; - const pointer = captured and unit == 8 and format != .float and regionOf(moment, value) != .none; + const pointer_at = at_byte / 8 * 8; + if (at_byte == pointer_at) pointer_x = x; + const value = std.mem.readInt(u64, values[pointer_at..][0..8], .little); + const pointer = format != .float and std.mem.indexOfScalar(bool, known[pointer_at..][0..8], false) == null and regionOf(moment, value) != .none; u.text(.mono, size, x, baseline(y), text, if (pointer) ink(regionOf(moment, value)) else t.primary); - if (pointer) u.hitAddress(value, .{ .x = x, .y = y, .w = width, .h = row_h }); + if (pointer and at_byte + unit == pointer_at + 8) u.hitAddress(value, .{ .x = pointer_x, .y = y, .w = x + width - pointer_x, .h = row_h }); x += width + adv * 2; } return x; @@ -618,6 +621,7 @@ pub fn bytesAt(at: ui.Ui, y: f32, addr: u64, values: *const [16]u8, known: *cons top = j; }; const word: u64 = if (run.len == 8) std.mem.readInt(u64, values[run.first..][0..8], .little) else 0; + if (run.kind == .pointer and run.len == 8 and std.mem.indexOfScalar(bool, known[run.first..][0..8], false) == null) u.hitAddress(word, r); const run_ink: ui.Color = switch (run.kind) { .number => ui.rgb(t.primary), .pointer => ui.rgb(if (run.len == 8) ink(regionOf(moment, word)) else t.primary), diff --git a/gui/README.md b/gui/README.md index b355665..288261e 100644 --- a/gui/README.md +++ b/gui/README.md @@ -96,7 +96,9 @@ Memory's two header controls choose 8/16/32/64-bit groups and hexadecimal, unsigned, signed or floating-point values (little endian). `memory-format SIZE FORMAT` sets byte sizes 1/2/4/8 and `hex`, `unsigned`, `signed` or `float` directly; floats require 4 or 8 bytes. Unknown bytes stay unknown; these controls only -change rendering. Wide values remain reachable with Shift-h/l. +change rendering. Recognized pointer fields are clickable across all their bytes, +including 8-bit view: left-click opens a lens; right-click opens stack or memory. +Wide values remain reachable with Shift-h/l. Lenses keep an opaque reading surface, with a native GPU backdrop shader for edge refraction, subtle color separation and a cyan rim. A canvas-sized texture and one reusable lens snapshot diff --git a/gui/bench/RESULTS.md b/gui/bench/RESULTS.md index e0c5626..54ecf4e 100644 --- a/gui/bench/RESULTS.md +++ b/gui/bench/RESULTS.md @@ -187,3 +187,12 @@ recording `/tmp/ztrace-gui-17379-8471380224093.ztrace`. Generated wrong-map exit `0x7f4c80c01fba`, the printed wrong-map return for the naturally optimized `jitWork`. Origin context and the executable lens use guard `0x7f4c80c01bd4`. The target remains stopped; lens inspection only captures bytes and instructions. + +Hexdump pointer follow-up: shared byte/grouped-integer rows now expose the full +pointer span to both mouse buttons, including 8-bit display and zero padding. +Native/headless checks cover 8/16/32/64-bit groups, recursive byte-view lenses, +and a stack pointer stored in data. GUI and shared-renderer suites pass. +The updated native session (GUI20122, d8 20207) remains at `Deoptimizer::New+4` +`0x7f24dbbe3f74`, with wrong-map origin `0x7f247ac00ffa` and JS guard +`0x7f247ac00c14`; recording `/tmp/ztrace-gui-20122-9224949592653.ztrace`. +A native 8-bit hexdump click opened the saved-stack-pointer lens successfully. diff --git a/gui/targets/segments.c b/gui/targets/segments.c index 0fdc25f..c52ad3b 100644 --- a/gui/targets/segments.c +++ b/gui/targets/segments.c @@ -7,9 +7,12 @@ struct node { struct node *next; uint64_t value; }; struct node head, middle, tail; volatile uint64_t counter; +uint64_t *stack_pointer; __attribute__((noinline)) void checkpoint(void) { __asm__ volatile("" ::: "memory"); } int main(void) { + uint64_t stack_value = 42; + stack_pointer = &stack_value; const size_t size = (size_t)1 << 32; int fd = memfd_create("ztrace-test-segment", 0); assert(fd >= 0 && ftruncate(fd, size) == 0); diff --git a/gui/test/lenses.py b/gui/test/lenses.py index c78e250..9d287fa 100644 --- a/gui/test/lenses.py +++ b/gui/test/lenses.py @@ -84,6 +84,46 @@ expect number_format float click 1278 822 expect number_format hex ''' + # Pointer hits cover the full eight-byte field, independently of grouping. + for unit in (1, 2, 4, 8): + commands += f'''console memory-format {unit} hex +console goto memory {head} +frames 40 +click 1270 863 +expect lens_count 1 +expect lenses[0].address {symbols['middle']} +key escape +console mouse-button 3 1270 863 +expect focus memory +expect nav[2].place.address {symbols['middle']} +''' + commands += f'''console memory-format 1 hex +console goto memory {head} +frames 40 +# The last (zero) byte of a little-endian pointer follows the full pointer too. +click 1480 863 +expect lenses[0].address {symbols['middle']} +frames 30 +# The pointer's bytes in a recursive lens use the same shared hit geometry. +click 1250 231 +expect lens_count 2 +expect lenses[1].address {symbols['tail']} +key escape +# A stack pointer stored in ordinary data routes by its target mapping. +console goto memory {symbols['stack_pointer']} +frames 40 +click {1270 + (symbols['stack_pointer'] % 16) * 30 + (12 if symbols['stack_pointer'] % 16 >= 8 else 0)} 863 +expect lens_count 1 +print lenses[0].address +key escape +console mouse-button 3 {1270 + (symbols['stack_pointer'] % 16) * 30 + (12 if symbols['stack_pointer'] % 16 >= 8 else 0)} 863 +expect focus stack +print nav[1].place.address +expect nav[1].place.follow false +expect execution 1 +console goto memory {head} +frames 40 +''' for unit in (1, 2, 4, 8): for fmt in ('hex', 'unsigned', 'signed') + (('float',) if unit >= 4 else ()): commands += f'console memory-format {unit} {fmt}\nexpect unit {unit}\nexpect number_format {fmt}\nframes 2\n' @@ -114,6 +154,8 @@ expect-no-log backdrop shader assert run.returncode == 0, stderr first = int(re.search(r'lenses\[0\].first = (\d+)', stderr)[1]) assert first > code, (first, code) + stack_addresses = re.findall(r'(?:lenses\[0\].address|nav\[1\].place.address) = (\d+)', stderr) + assert len(stack_addresses) == 2 and stack_addresses[0] == stack_addresses[1], stack_addresses stops = re.findall(r'stops = (\d+)', stderr) assert len(stops) == 2 and stops[0] == stops[1], stops for recording in Path('/tmp').glob(f'ztrace-gui-{run.pid}-*.ztrace'): |
