From Code to Community: Sponsoring The Perl and Raku Conference 2025 Learn more

NAME

B::Debugger - optree debugger

SYNOPSIS

perl -MB::Debugger programm.pl
B::Debugger 0.01 - optree debugger. h for help
op 0 enter
> n
op 1 nextstate
> h
Usage:
n [n] next op l [n|x-y] list ops
c [n] continue (until) d|Debug op
b <n> break at op o|Concise op
s step into kids f|Flags op
sib step to next sibling x|eval expr
u [n] up [sahpicg]v<n> n-th global var: sv1,
g <n> goto pad <n> n-th pad variable (my)
h help
q quit debugger, execute exit quit with no execution
op 0 enter
> b 5
breakpoint 5 added
> b const
breakpoint const added
> n
op 2 pushmark
> l
- <0> enter ->-
- <;> nextstate(main 111 test.pl:5) v:{ ->-
- <0> pushmark sM ->- > c
> q
quit
executing...

DESCRIPTION

Start an optree inspector before the runtime execution begins, similar
to the perl debugger, but only at the internal optree level, not the
source level. Kind of interactive B::Concise.
The ops are numbered and in basic (=parsed) order, starting from 0.
Breakpoints can be defined as number or by opname.

OPTIONS

None yet.

Planned:

-exec switch to exec order
-root start at main_root, not main_start
-check hook into CHECK block (Default, at B)
-unit hook into UNITCHECK block (after B)
-init hook into INIT block (before B)
-begin hook into BEGIN block (before compilation)
-d debug, be verbose in the internal recursion steps

COMMANDS

n [n] goto the next op, or step the next n ops
s step into kid if not next
sib step to next sibling
u [n] go one or n steps back or up
g <n> goto op 0-opmax
c [n] continue. Optionally until op n
l [n|x-y] list n ops or from x to y.
x <x> eval perl expression
f list B::Flags op
o/C list B::Concise op
d/D list B::Debug op
[sahpicg]v<n> inspect n-th global variable. eg. sv1
h help
q quit debugger, start execution
exit quit perl, no execution

SEE ALSO

Use Od to step through the compiler with the perl debugger. It delays the CHECK block for the B::backend.

TODO

How to manage direct opidx access?

Such as: Concise 10, list 5-10, up, sib
Do a first sweep in desired basic or exec order recording the ops?

set curcv in Concise

Commandline options

exit

de-recursify and simplify the loop, cont is broken.

BUGS

Plenty. This is alpha and for interested compiler developers only.

l => coderef CODE(0x1553f40) has no START (set curcv in Concise)

cont, goto broken

AUTHOR

Reini Urban rurban@cpan.org