B-Debugger
view release on metacpan or search on metacpan
lib/B/Debugger.pm view on Meta::CPAN
our $XS_VERSION = $VERSION;
$VERSION = eval $VERSION;
=pod
=head1 NAME
B::Debugger - optree debugger
=head1 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...
=head1 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.
=head1 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
=head1 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
=head1 SEE ALSO
Use L<Od> to step through the compiler with the perl debugger.
It delays the C<CHECK> block for the B::backend.
=head1 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.
=head1 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
=head1 AUTHOR
Reini Urban C<rurban@cpan.org>
=cut
use Devel::Hook;
use B qw(main_start main_root class main_cv);
use B::Utils; # qw(carp croak);
( run in 2.019 seconds using v1.01-cache-2.11-cpan-d7f47b0818f )