Skip to content

Commit 2b2419a

Browse files
committed
Adjust objdump printing of InstPos on frame progpoints; and adjust progpoint collapsing.
1 parent 27042a3 commit 2b2419a

File tree

3 files changed

+47
-36
lines changed

3 files changed

+47
-36
lines changed

crates/environ/src/compile/frame_table.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -260,11 +260,15 @@ impl FrameTableBuilder {
260260
frames: &[(u32, FrameTableDescriptorIndex, FrameStackShape)],
261261
) {
262262
let pc_and_pos = FrameInstPos::encode(native_pc, pos);
263-
// If we already have a program point record at this PC, don't add another.
264-
if let Some(last) = self.progpoint_pcs.last()
263+
// If we already have a program point record at this PC,
264+
// overwrite it.
265+
while let Some(last) = self.progpoint_pcs.last()
265266
&& last.get(LittleEndian) == pc_and_pos
266267
{
267-
return;
268+
self.progpoint_pcs.pop();
269+
self.progpoint_descriptor_offsets.pop();
270+
self.progpoint_descriptor_data
271+
.truncate(self.progpoint_descriptor_data.len() - 3);
268272
}
269273

270274
let start = u32::try_from(self.progpoint_descriptor_data.len()).unwrap();

src/commands/objdump.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -696,6 +696,10 @@ impl Decorator<'_> {
696696
FrameInstPos::Post => &mut *pre_list,
697697
FrameInstPos::Pre => &mut *post_list,
698698
};
699+
let pos = match pos {
700+
FrameInstPos::Post => "after previous inst",
701+
FrameInstPos::Pre => "before next inst",
702+
};
699703
for (wasm_pc, frame_descriptor, stack_shape) in frames {
700704
let (frame_descriptor_data, offset) =
701705
frame_tables.frame_descriptor(frame_descriptor).unwrap();
@@ -704,7 +708,7 @@ impl Decorator<'_> {
704708
let local_shape = Self::describe_local_shape(&frame_descriptor);
705709
let stack_shape = Self::describe_stack_shape(&frame_descriptor, stack_shape);
706710
let func_key = frame_descriptor.func_key();
707-
list.push(format!("debug frame state: func key {func_key:?}, wasm PC {wasm_pc}, slot at FP-0x{offset:x}, locals {local_shape}, stack {stack_shape}"));
711+
list.push(format!("debug frame state ({pos}): func key {func_key:?}, wasm PC {wasm_pc}, slot at FP-0x{offset:x}, locals {local_shape}, stack {stack_shape}"));
708712
}
709713
}
710714
}

tests/disas/debug-exceptions.wat

Lines changed: 35 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
(func (export "main")
99
(block $b (result i32)
1010
(try_table (catch $t $b)
11+
(drop (i32.const 42))
1112
(throw $t (i32.const 42)))
1213
i32.const 0)
1314
(call 0)
@@ -19,7 +20,7 @@
1920
;; ldur x16, [x16, #0x10]
2021
;; add x16, x16, #0xc0
2122
;; cmp sp, x16
22-
;; b.lo #0x10c
23+
;; b.lo #0x110
2324
;; 1c: stp x27, x28, [sp, #-0x10]!
2425
;; stp x25, x26, [sp, #-0x10]!
2526
;; stp x23, x24, [sp, #-0x10]!
@@ -33,49 +34,51 @@
3334
;; stur x2, [sp]
3435
;; stur x2, [sp, #0x10]
3536
;; mov w27, #0x2a
36-
;; ╰─╼ debug frame state: func key DefinedWasmFunction(StaticModuleIndex(0), DefinedFuncIndex(0)), wasm PC 53, slot at FP-0xb0, locals , stack
37+
;; ╰─╼ debug frame state (before next inst): func key DefinedWasmFunction(StaticModuleIndex(0), DefinedFuncIndex(0)), wasm PC 61, slot at FP-0xb0, locals , stack
3738
;; stur w27, [sp, #8]
39+
;; stur w27, [sp, #8]
40+
;; ╰─╼ debug frame state (before next inst): func key DefinedWasmFunction(StaticModuleIndex(0), DefinedFuncIndex(0)), wasm PC 64, slot at FP-0xb0, locals , stack
3841
;; ldur x2, [sp, #0x10]
39-
;; ╰─╼ debug frame state: func key DefinedWasmFunction(StaticModuleIndex(0), DefinedFuncIndex(0)), wasm PC 63, slot at FP-0xb0, locals , stack I32 @ slot+0x8
40-
;; bl #0x318
41-
;; 5c: mov x21, x2
42+
;; ╰─╼ debug frame state (before next inst): func key DefinedWasmFunction(StaticModuleIndex(0), DefinedFuncIndex(0)), wasm PC 66, slot at FP-0xb0, locals , stack I32 @ slot+0x8
43+
;; bl #0x31c
44+
;; 60: mov x21, x2
4245
;; mov w3, #0x4000000
4346
;; mov w4, #2
4447
;; mov w5, #0x28
4548
;; mov w6, #8
4649
;; ldur x2, [sp, #0x10]
47-
;; bl #0x2a4
48-
;; 78: ldur x8, [sp, #0x10]
49-
;; ldr x13, [x8, #8]
50-
;; ldr x3, [x13, #0x18]
51-
;; add x13, x3, #0x20
52-
;; str w27, [x13, w2, uxtw]
53-
;; add x14, x3, #0x18
54-
;; mov x0, x21
55-
;; str w0, [x14, w2, uxtw]
56-
;; mov w15, #0
57-
;; add x0, x3, #0x1c
58-
;; stur x3, [sp, #0x18]
59-
;; str w15, [x0, w2, uxtw]
50+
;; bl #0x2a8
51+
;; 7c: ldur x11, [sp, #0x10]
52+
;; ldr x0, [x11, #8]
53+
;; ldr x5, [x0, #0x18]
54+
;; add x0, x5, #0x20
55+
;; str w27, [x0, w2, uxtw]
56+
;; add x3, x5, #0x18
57+
;; mov x4, x21
58+
;; str w4, [x3, w2, uxtw]
59+
;; mov w3, #0
60+
;; add x4, x5, #0x1c
61+
;; stur x5, [sp, #0x18]
62+
;; str w3, [x4, w2, uxtw]
6063
;; mov x3, x2
6164
;; ldur x2, [sp, #0x10]
62-
;; bl #0x350
65+
;; bl #0x354
6366
;; ├─╼ exception frame offset: SP = FP - 0xb0
64-
;; ╰─╼ exception handler: tag=0, context at [SP+0x10], handler=0xb8
65-
;; b4: .byte 0x1f, 0xc1, 0x00, 0x00
66-
;; ldur x3, [sp, #0x18]
67-
;; add x1, x3, #0x20
68-
;; ldr w3, [x1, w0, uxtw]
69-
;; stur w3, [sp, #8]
67+
;; ╰─╼ exception handler: tag=0, context at [SP+0x10], handler=0xbc
68+
;; b8: .byte 0x1f, 0xc1, 0x00, 0x00
69+
;; ldur x5, [sp, #0x18]
70+
;; add x4, x5, #0x20
71+
;; ldr w6, [x4, w0, uxtw]
72+
;; stur w6, [sp, #8]
7073
;; ldur x2, [sp, #0x10]
71-
;; ╰─╼ debug frame state: func key DefinedWasmFunction(StaticModuleIndex(0), DefinedFuncIndex(0)), wasm PC 69, slot at FP-0xb0, locals , stack I32 @ slot+0x8
72-
;; ldr x5, [x2, #0x30]
74+
;; ╰─╼ debug frame state (before next inst): func key DefinedWasmFunction(StaticModuleIndex(0), DefinedFuncIndex(0)), wasm PC 72, slot at FP-0xb0, locals , stack I32 @ slot+0x8
75+
;; ldr x8, [x2, #0x30]
7376
;; ldr x2, [x2, #0x40]
7477
;; ldur x3, [sp, #0x10]
75-
;; blr x5
76-
;; ╰─╼ debug frame state: func key DefinedWasmFunction(StaticModuleIndex(0), DefinedFuncIndex(0)), wasm PC 69, slot at FP-0xb0, locals , stack I32 @ slot+0x8
77-
;; dc: add sp, sp, #0x20
78-
;; ╰─╼ debug frame state: func key DefinedWasmFunction(StaticModuleIndex(0), DefinedFuncIndex(0)), wasm PC 71, slot at FP-0xb0, locals , stack I32 @ slot+0x8
78+
;; blr x8
79+
;; ╰─╼ debug frame state (after previous inst): func key DefinedWasmFunction(StaticModuleIndex(0), DefinedFuncIndex(0)), wasm PC 72, slot at FP-0xb0, locals , stack I32 @ slot+0x8
80+
;; e0: add sp, sp, #0x20
81+
;; ╰─╼ debug frame state (before next inst): func key DefinedWasmFunction(StaticModuleIndex(0), DefinedFuncIndex(0)), wasm PC 75, slot at FP-0xb0, locals , stack
7982
;; ldp d8, d9, [sp], #0x10
8083
;; ldp d10, d11, [sp], #0x10
8184
;; ldp d12, d13, [sp], #0x10
@@ -87,4 +90,4 @@
8790
;; ldp x27, x28, [sp], #0x10
8891
;; ldp x29, x30, [sp], #0x10
8992
;; ret
90-
;; 10c: .byte 0x1f, 0xc1, 0x00, 0x00
93+
;; 110: .byte 0x1f, 0xc1, 0x00, 0x00

0 commit comments

Comments
 (0)