6 use B qw(peekop class walkoptree walkoptree_exec
7 main_start main_root cstring sv_undef);
8 use B::Asmdata qw(@specialsv_name);
14 printf <<'EOT', class($op), $$op, ${$op->next}, ${$op->sibling}, $op->ppaddr, $op->targ, $op->type;
23 printf <<'EOT', $op->opt, $op->static;
28 printf <<'EOT', $op->seq;
32 printf <<'EOT', $op->flags, $op->private;
41 printf "\top_first\t0x%x\n", ${$op->first};
46 $op->B::UNOP::debug();
47 printf "\top_last\t\t0x%x\n", ${$op->last};
52 $op->B::BINOP::debug();
53 printf <<'EOT', ${$op->redoop}, ${$op->nextop}, ${$op->lastop};
62 $op->B::UNOP::debug();
63 printf "\top_other\t0x%x\n", ${$op->other};
66 sub B::LISTOP::debug {
68 $op->B::BINOP::debug();
69 printf "\top_children\t%d\n", $op->children;
74 $op->B::LISTOP::debug();
75 printf "\top_pmreplroot\t0x%x\n", ${$op->pmreplroot};
76 printf "\top_pmreplstart\t0x%x\n", ${$op->pmreplstart};
77 printf "\top_pmnext\t0x%x\n", ${$op->pmnext};
78 printf "\top_pmregexp->precomp\t%s\n", cstring($op->precomp);
79 printf "\top_pmflags\t0x%x\n", $op->pmflags;
80 $op->pmreplroot->debug;
86 my $cop_io = class($op->io) eq 'SPECIAL' ? '' : $op->io->as_string;
87 printf <<'EOT', $op->label, $op->stashpv, $op->file, $op->cop_seq, $op->arybase, $op->line, ${$op->warnings}, cstring($cop_io);
102 printf "\top_sv\t\t0x%x\n", ${$op->sv};
109 printf "\top_pv\t\t%s\n", cstring($op->pv);
112 sub B::PADOP::debug {
115 printf "\top_padix\t\t%ld\n", $op->padix;
120 if ($$sv == ${sv_undef()}) {
123 printf "NULL (0x%x)\n", $$sv;
130 print class($sv), " = NULL\n";
133 printf <<'EOT', class($sv), $$sv, $sv->REFCNT, $sv->FLAGS;
143 printf <<'EOT', ${$rv->RV};
153 printf <<'EOT', cstring($pv), length($pv);
162 printf "\txiv_iv\t\t%d\n", $sv->IV;
168 printf "\txnv_nv\t\t%s\n", $sv->NV;
174 printf "\txiv_iv\t\t%d\n", $sv->IV;
179 $sv->B::PVIV::debug();
180 printf "\txnv_nv\t\t%s\n", $sv->NV;
185 $sv->B::PVNV::debug();
186 printf "\txlv_targoff\t%d\n", $sv->TARGOFF;
187 printf "\txlv_targlen\t%u\n", $sv->TARGLEN;
188 printf "\txlv_type\t%s\n", cstring(chr($sv->TYPE));
193 $sv->B::PVNV::debug();
194 printf "\txbm_useful\t%d\n", $sv->USEFUL;
195 printf "\txbm_previous\t%u\n", $sv->PREVIOUS;
196 printf "\txbm_rare\t%s\n", cstring(chr($sv->RARE));
201 $sv->B::PVNV::debug();
202 my ($stash) = $sv->STASH;
203 my ($start) = $sv->START;
204 my ($root) = $sv->ROOT;
205 my ($padlist) = $sv->PADLIST;
206 my ($file) = $sv->FILE;
208 printf <<'EOT', $$stash, $$start, $$root, $$gv, $file, $sv->DEPTH, $padlist, ${$sv->OUTSIDE}, $sv->OUTSIDE_SEQ;
219 $start->debug if $start;
220 $root->debug if $root;
222 $padlist->debug if $padlist;
228 my(@array) = $av->ARRAY;
229 print "\tARRAY\t\t(", join(", ", map("0x" . $$_, @array)), ")\n";
230 printf <<'EOT', scalar(@array), $av->MAX, $av->OFF;
235 printf <<'EOT', $av->AvFLAGS if $] < 5.009;
242 if ($done_gv{$$gv}++) {
243 printf "GV %s::%s\n", $gv->STASH->NAME, $gv->SAFENAME;
250 printf <<'EOT', $gv->SAFENAME, $gv->STASH->NAME, $gv->STASH, $$sv, $gv->GvREFCNT, $gv->FORM, $$av, ${$gv->HV}, ${$gv->EGV}, $$cv, $gv->CVGEN, $gv->LINE, $gv->FILE, $gv->GvFLAGS;
270 sub B::SPECIAL::debug {
272 print $specialsv_name[$$sv], "\n";
278 if ($order && $order eq "exec") {
279 return sub { walkoptree_exec(main_start, "debug") }
281 return sub { walkoptree(main_root, "debug") }
291 B::Debug - Walk Perl syntax tree, printing debug info about ops
295 perl -MO=Debug[,OPTIONS] foo.pl
303 Malcolm Beattie, C<mbeattie@sable.ox.ac.uk>