6 use B qw(peekop class walkoptree walkoptree_exec
7 main_start main_root cstring sv_undef @specialsv_name);
13 printf <<'EOT', class($op), $$op, ${$op->next}, ${$op->sibling}, $op->ppaddr, $op->targ, $op->type;
22 printf <<'EOT', $op->opt, $op->static;
27 printf <<'EOT', $op->seq;
31 printf <<'EOT', $op->flags, $op->private;
40 printf "\top_first\t0x%x\n", ${$op->first};
45 $op->B::UNOP::debug();
46 printf "\top_last\t\t0x%x\n", ${$op->last};
51 $op->B::BINOP::debug();
52 printf <<'EOT', ${$op->redoop}, ${$op->nextop}, ${$op->lastop};
61 $op->B::UNOP::debug();
62 printf "\top_other\t0x%x\n", ${$op->other};
65 sub B::LISTOP::debug {
67 $op->B::BINOP::debug();
68 printf "\top_children\t%d\n", $op->children;
73 $op->B::LISTOP::debug();
74 printf "\top_pmreplroot\t0x%x\n", ${$op->pmreplroot};
75 printf "\top_pmreplstart\t0x%x\n", ${$op->pmreplstart};
76 printf "\top_pmnext\t0x%x\n", ${$op->pmnext};
77 printf "\top_pmregexp->precomp\t%s\n", cstring($op->precomp);
78 printf "\top_pmflags\t0x%x\n", $op->pmflags;
79 $op->pmreplroot->debug;
85 my $cop_io = class($op->io) eq 'SPECIAL' ? '' : $op->io->as_string;
86 printf <<'EOT', $op->label, $op->stashpv, $op->file, $op->cop_seq, $op->arybase, $op->line, ${$op->warnings}, cstring($cop_io);
101 printf "\top_sv\t\t0x%x\n", ${$op->sv};
108 printf "\top_pv\t\t%s\n", cstring($op->pv);
111 sub B::PADOP::debug {
114 printf "\top_padix\t\t%ld\n", $op->padix;
119 if ($$sv == ${sv_undef()}) {
122 printf "NULL (0x%x)\n", $$sv;
129 print class($sv), " = NULL\n";
132 printf <<'EOT', class($sv), $$sv, $sv->REFCNT, $sv->FLAGS;
142 printf <<'EOT', ${$rv->RV};
152 printf <<'EOT', cstring($pv), length($pv);
161 printf "\txiv_iv\t\t%d\n", $sv->IV;
167 printf "\txnv_nv\t\t%s\n", $sv->NV;
173 printf "\txiv_iv\t\t%d\n", $sv->IV;
178 $sv->B::PVIV::debug();
179 printf "\txnv_nv\t\t%s\n", $sv->NV;
184 $sv->B::PVNV::debug();
185 printf "\txlv_targoff\t%d\n", $sv->TARGOFF;
186 printf "\txlv_targlen\t%u\n", $sv->TARGLEN;
187 printf "\txlv_type\t%s\n", cstring(chr($sv->TYPE));
192 $sv->B::PVNV::debug();
193 printf "\txbm_useful\t%d\n", $sv->USEFUL;
194 printf "\txbm_previous\t%u\n", $sv->PREVIOUS;
195 printf "\txbm_rare\t%s\n", cstring(chr($sv->RARE));
200 $sv->B::PVNV::debug();
201 my ($stash) = $sv->STASH;
202 my ($start) = $sv->START;
203 my ($root) = $sv->ROOT;
204 my ($padlist) = $sv->PADLIST;
205 my ($file) = $sv->FILE;
207 printf <<'EOT', $$stash, $$start, $$root, $$gv, $file, $sv->DEPTH, $padlist, ${$sv->OUTSIDE}, $sv->OUTSIDE_SEQ;
218 $start->debug if $start;
219 $root->debug if $root;
221 $padlist->debug if $padlist;
227 my(@array) = $av->ARRAY;
228 print "\tARRAY\t\t(", join(", ", map("0x" . $$_, @array)), ")\n";
229 printf <<'EOT', scalar(@array), $av->MAX, $av->OFF;
234 printf <<'EOT', $av->AvFLAGS if $] < 5.009;
241 if ($done_gv{$$gv}++) {
242 printf "GV %s::%s\n", $gv->STASH->NAME, $gv->SAFENAME;
249 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;
269 sub B::SPECIAL::debug {
271 print $specialsv_name[$$sv], "\n";
277 if ($order && $order eq "exec") {
278 return sub { walkoptree_exec(main_start, "debug") }
280 return sub { walkoptree(main_root, "debug") }
290 B::Debug - Walk Perl syntax tree, printing debug info about ops
294 perl -MO=Debug[,OPTIONS] foo.pl
302 Malcolm Beattie, C<mbeattie@sable.ox.ac.uk>