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;
26 printf <<'EOT', $op->seq;
30 printf <<'EOT', $op->flags, $op->private;
39 printf "\top_first\t0x%x\n", ${$op->first};
44 $op->B::UNOP::debug();
45 printf "\top_last\t\t0x%x\n", ${$op->last};
50 $op->B::BINOP::debug();
51 printf <<'EOT', ${$op->redoop}, ${$op->nextop}, ${$op->lastop};
60 $op->B::UNOP::debug();
61 printf "\top_other\t0x%x\n", ${$op->other};
64 sub B::LISTOP::debug {
66 $op->B::BINOP::debug();
67 printf "\top_children\t%d\n", $op->children;
72 $op->B::LISTOP::debug();
73 printf "\top_pmreplroot\t0x%x\n", ${$op->pmreplroot};
74 printf "\top_pmreplstart\t0x%x\n", ${$op->pmreplstart};
75 printf "\top_pmnext\t0x%x\n", ${$op->pmnext};
76 printf "\top_pmregexp->precomp\t%s\n", cstring($op->precomp);
77 printf "\top_pmflags\t0x%x\n", $op->pmflags;
78 $op->pmreplroot->debug;
84 my $cop_io = class($op->io) eq 'SPECIAL' ? '' : $op->io->as_string;
85 printf <<'EOT', $op->label, $op->stashpv, $op->file, $op->cop_seq, $op->arybase, $op->line, ${$op->warnings}, cstring($cop_io);
100 printf "\top_sv\t\t0x%x\n", ${$op->sv};
107 printf "\top_pv\t\t%s\n", cstring($op->pv);
110 sub B::PADOP::debug {
113 printf "\top_padix\t\t%ld\n", $op->padix;
118 if ($$sv == ${sv_undef()}) {
121 printf "NULL (0x%x)\n", $$sv;
128 print class($sv), " = NULL\n";
131 printf <<'EOT', class($sv), $$sv, $sv->REFCNT, $sv->FLAGS;
141 printf <<'EOT', ${$rv->RV};
151 printf <<'EOT', cstring($pv), length($pv);
160 printf "\txiv_iv\t\t%d\n", $sv->IV;
166 printf "\txnv_nv\t\t%s\n", $sv->NV;
172 printf "\txiv_iv\t\t%d\n", $sv->IV;
177 $sv->B::PVIV::debug();
178 printf "\txnv_nv\t\t%s\n", $sv->NV;
183 $sv->B::PVNV::debug();
184 printf "\txlv_targoff\t%d\n", $sv->TARGOFF;
185 printf "\txlv_targlen\t%u\n", $sv->TARGLEN;
186 printf "\txlv_type\t%s\n", cstring(chr($sv->TYPE));
191 $sv->B::PVNV::debug();
192 printf "\txbm_useful\t%d\n", $sv->USEFUL;
193 printf "\txbm_previous\t%u\n", $sv->PREVIOUS;
194 printf "\txbm_rare\t%s\n", cstring(chr($sv->RARE));
199 $sv->B::PVNV::debug();
200 my ($stash) = $sv->STASH;
201 my ($start) = $sv->START;
202 my ($root) = $sv->ROOT;
203 my ($padlist) = $sv->PADLIST;
204 my ($file) = $sv->FILE;
206 printf <<'EOT', $$stash, $$start, $$root, $$gv, $file, $sv->DEPTH, $padlist, ${$sv->OUTSIDE}, $sv->OUTSIDE_SEQ;
217 $start->debug if $start;
218 $root->debug if $root;
220 $padlist->debug if $padlist;
226 my(@array) = $av->ARRAY;
227 print "\tARRAY\t\t(", join(", ", map("0x" . $$_, @array)), ")\n";
228 printf <<'EOT', scalar(@array), $av->MAX, $av->OFF;
233 printf <<'EOT', $av->AvFLAGS if $] < 5.009;
240 if ($done_gv{$$gv}++) {
241 printf "GV %s::%s\n", $gv->STASH->NAME, $gv->SAFENAME;
248 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;
268 sub B::SPECIAL::debug {
270 print $specialsv_name[$$sv], "\n";
276 if ($order && $order eq "exec") {
277 return sub { walkoptree_exec(main_start, "debug") }
279 return sub { walkoptree(main_root, "debug") }
289 B::Debug - Walk Perl syntax tree, printing debug info about ops
293 perl -MO=Debug[,OPTIONS] foo.pl
301 Malcolm Beattie, C<mbeattie@sable.ox.ac.uk>