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, $op->seq, $op->flags, $op->private;
30 printf "\top_first\t0x%x\n", ${$op->first};
35 $op->B::UNOP::debug();
36 printf "\top_last\t\t0x%x\n", ${$op->last};
41 $op->B::BINOP::debug();
42 printf <<'EOT', ${$op->redoop}, ${$op->nextop}, ${$op->lastop};
51 $op->B::UNOP::debug();
52 printf "\top_other\t0x%x\n", ${$op->other};
55 sub B::LISTOP::debug {
57 $op->B::BINOP::debug();
58 printf "\top_children\t%d\n", $op->children;
63 $op->B::LISTOP::debug();
64 printf "\top_pmreplroot\t0x%x\n", ${$op->pmreplroot};
65 printf "\top_pmreplstart\t0x%x\n", ${$op->pmreplstart};
66 printf "\top_pmnext\t0x%x\n", ${$op->pmnext};
67 printf "\top_pmregexp->precomp\t%s\n", cstring($op->precomp);
68 printf "\top_pmflags\t0x%x\n", $op->pmflags;
69 $op->pmreplroot->debug;
75 printf <<'EOT', $op->label, $op->stashpv, $op->file, $op->seq, $op->arybase, $op->line, ${$op->warnings};
89 printf "\top_sv\t\t0x%x\n", ${$op->sv};
96 printf "\top_pv\t\t%s\n", cstring($op->pv);
102 printf "\top_padix\t\t%ld\n", $op->padix;
108 printf "\top_cv\t\t0x%x\n", ${$op->cv};
113 if ($$sv == ${sv_undef()}) {
116 printf "NULL (0x%x)\n", $$sv;
123 print class($sv), " = NULL\n";
126 printf <<'EOT', class($sv), $$sv, $sv->REFCNT, $sv->FLAGS;
136 printf <<'EOT', ${$rv->RV};
146 printf <<'EOT', cstring($pv), length($pv);
155 printf "\txiv_iv\t\t%d\n", $sv->IV;
161 printf "\txnv_nv\t\t%s\n", $sv->NV;
167 printf "\txiv_iv\t\t%d\n", $sv->IV;
172 $sv->B::PVIV::debug();
173 printf "\txnv_nv\t\t%s\n", $sv->NV;
178 $sv->B::PVNV::debug();
179 printf "\txlv_targoff\t%d\n", $sv->TARGOFF;
180 printf "\txlv_targlen\t%u\n", $sv->TARGLEN;
181 printf "\txlv_type\t%s\n", cstring(chr($sv->TYPE));
186 $sv->B::PVNV::debug();
187 printf "\txbm_useful\t%d\n", $sv->USEFUL;
188 printf "\txbm_previous\t%u\n", $sv->PREVIOUS;
189 printf "\txbm_rare\t%s\n", cstring(chr($sv->RARE));
194 $sv->B::PVNV::debug();
195 my ($stash) = $sv->STASH;
196 my ($start) = $sv->START;
197 my ($root) = $sv->ROOT;
198 my ($padlist) = $sv->PADLIST;
199 my ($file) = $sv->FILE;
201 printf <<'EOT', $$stash, $$start, $$root, $$gv, $file, $sv->DEPTH, $padlist, ${$sv->OUTSIDE};
211 $start->debug if $start;
212 $root->debug if $root;
214 $padlist->debug if $padlist;
220 my(@array) = $av->ARRAY;
221 print "\tARRAY\t\t(", join(", ", map("0x" . $$_, @array)), ")\n";
222 printf <<'EOT', scalar(@array), $av->MAX, $av->OFF, $av->AvFLAGS;
232 if ($done_gv{$$gv}++) {
233 printf "GV %s::%s\n", $gv->STASH->NAME, $gv->SAFENAME;
240 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;
260 sub B::SPECIAL::debug {
262 print $specialsv_name[$$sv], "\n";
268 if ($order && $order eq "exec") {
269 return sub { walkoptree_exec(main_start, "debug") }
271 return sub { walkoptree(main_root, "debug") }
281 B::Debug - Walk Perl syntax tree, printing debug info about ops
285 perl -MO=Debug[,OPTIONS] foo.pl
293 Malcolm Beattie, C<mbeattie@sable.ox.ac.uk>