3 use B qw(peekop class walkoptree walkoptree_exec
4 main_start main_root cstring sv_undef);
5 use B::Asmdata qw(@specialsv_name);
11 printf <<'EOT', class($op), $$op, ${$op->next}, ${$op->sibling}, $op->ppaddr, $op->targ, $op->type, $op->seq, $op->flags, $op->private;
27 printf "\top_first\t0x%x\n", ${$op->first};
32 $op->B::UNOP::debug();
33 printf "\top_last\t\t0x%x\n", ${$op->last};
38 $op->B::BINOP::debug();
39 printf <<'EOT', ${$op->redoop}, ${$op->nextop}, ${$op->lastop};
48 $op->B::UNOP::debug();
49 printf "\top_other\t0x%x\n", ${$op->other};
52 sub B::LISTOP::debug {
54 $op->B::BINOP::debug();
55 printf "\top_children\t%d\n", $op->children;
60 $op->B::LISTOP::debug();
61 printf "\top_pmreplroot\t0x%x\n", ${$op->pmreplroot};
62 printf "\top_pmreplstart\t0x%x\n", ${$op->pmreplstart};
63 printf "\top_pmnext\t0x%x\n", ${$op->pmnext};
64 printf "\top_pmregexp->precomp\t%s\n", cstring($op->precomp);
65 printf "\top_pmflags\t0x%x\n", $op->pmflags;
66 $op->pmreplroot->debug;
72 printf <<'EOT', $op->label, $op->stashpv, $op->file, $op->seq, $op->arybase, $op->line, ${$op->warnings};
86 printf "\top_sv\t\t0x%x\n", ${$op->sv};
93 printf "\top_pv\t\t0x%x\n", $op->pv;
99 printf "\top_padix\t\t%ld\n", $op->padix;
105 printf "\top_cv\t\t0x%x\n", ${$op->cv};
110 if ($$sv == ${sv_undef()}) {
113 printf "NULL (0x%x)\n", $$sv;
120 print class($sv), " = NULL\n";
123 printf <<'EOT', class($sv), $$sv, $sv->REFCNT, $sv->FLAGS;
134 printf <<'EOT', cstring($pv), length($pv);
143 printf "\txiv_iv\t\t%d\n", $sv->IV;
149 printf "\txnv_nv\t\t%s\n", $sv->NV;
155 printf "\txiv_iv\t\t%d\n", $sv->IV;
160 $sv->B::PVIV::debug();
161 printf "\txnv_nv\t\t%s\n", $sv->NV;
166 $sv->B::PVNV::debug();
167 printf "\txlv_targoff\t%d\n", $sv->TARGOFF;
168 printf "\txlv_targlen\t%u\n", $sv->TARGLEN;
169 printf "\txlv_type\t%s\n", cstring(chr($sv->TYPE));
174 $sv->B::PVNV::debug();
175 printf "\txbm_useful\t%d\n", $sv->USEFUL;
176 printf "\txbm_previous\t%u\n", $sv->PREVIOUS;
177 printf "\txbm_rare\t%s\n", cstring(chr($sv->RARE));
182 $sv->B::PVNV::debug();
183 my ($stash) = $sv->STASH;
184 my ($start) = $sv->START;
185 my ($root) = $sv->ROOT;
186 my ($padlist) = $sv->PADLIST;
187 my ($file) = $sv->FILE;
189 printf <<'EOT', $$stash, $$start, $$root, $$gv, $file, $sv->DEPTH, $padlist, ${$sv->OUTSIDE};
199 $start->debug if $start;
200 $root->debug if $root;
202 $padlist->debug if $padlist;
208 my(@array) = $av->ARRAY;
209 print "\tARRAY\t\t(", join(", ", map("0x" . $$_, @array)), ")\n";
210 printf <<'EOT', scalar(@array), $av->MAX, $av->OFF, $av->AvFLAGS;
220 if ($done_gv{$$gv}++) {
221 printf "GV %s::%s\n", $gv->STASH->NAME, $gv->NAME;
228 printf <<'EOT', $gv->NAME, $gv->STASH->NAME, $gv->STASH, $$sv, $gv->GvREFCNT, $gv->FORM, $$av, ${$gv->HV}, ${$gv->EGV}, $$cv, $gv->CVGEN, $gv->LINE, $gv->FILE, $gv->GvFLAGS;
248 sub B::SPECIAL::debug {
250 print $specialsv_name[$$sv], "\n";
256 if ($order && $order eq "exec") {
257 return sub { walkoptree_exec(main_start, "debug") }
259 return sub { walkoptree(main_root, "debug") }
269 B::Debug - Walk Perl syntax tree, printing debug info about ops
273 perl -MO=Debug[,OPTIONS] foo.pl
281 Malcolm Beattie, C<mbeattie@sable.ox.ac.uk>