petdance/scratch — Issue #577: pbc_dump: Mark branch targets in -d mode
Author: petdance
Created: 2011-11-01 05:35:18+00:00
State: open
Labels: Pri-normal, Sev-medium, todo, tools

pbc_dump -d shows opcodes but does not indicate branch targets:
{{{
012b: 0000001b 00000001 00000046 unless_p_ic
012e: 00000348 00000002 00000001 shift_p_p
0131: 00000023 00000004 set_args_pc
0134: 00000024 00000004 get_results_pc
0137: 000002c4 00000002 00000044 callmethodcc_p_sc
013a: 00000367 00000009 00000007 iter_p_p
013d: 0000001b 00000009 ffffffee unless_p_ic
0140: 00000347 00000001 00000009 shift_s_p
0143: 000003d1 00000003 00000007 00000049 set_p_p_kc
0147: 000002d5 00000000 00000003 00000043 isa_i_p_sc
014b: 00000014 00000000 fffffff2 if_i_ic
}}}

While backwards branching means that marking branch targets in the output stream as labels would be a two pass operation, it should be possible to do the match and indicate the target offset as part of the opcode:

{{{
012b: 0000001b 00000001 00000046 unless_p_ic 0171
...
013d: 0000001b 00000009 ffffffee unless_p_ic 012b
...
014b: 00000014 00000000 fffffff2 if_i_ic 013d
}}}

Note: I make no guarantee those offsets are right.
Trac ID #1439