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::UNOP::debug();
39 printf "\top_other\t0x%x\n", ${$op->other};
42 sub B::CONDOP::debug {
44 $op->B::UNOP::debug();
45 printf "\top_true\t0x%x\n", ${$op->true};
46 printf "\top_false\t0x%x\n", ${$op->false};
49 sub B::LISTOP::debug {
51 $op->B::BINOP::debug();
52 printf "\top_children\t%d\n", $op->children;
57 $op->B::LISTOP::debug();
58 printf "\top_pmreplroot\t0x%x\n", ${$op->pmreplroot};
59 printf "\top_pmreplstart\t0x%x\n", ${$op->pmreplstart};
60 printf "\top_pmnext\t0x%x\n", ${$op->pmnext};
61 printf "\top_pmregexp->precomp\t%s\n", cstring($op->precomp);
62 printf "\top_pmflags\t0x%x\n", $op->pmflags;
64 $op->pmreplroot->debug;
70 my ($filegv) = $op->filegv;
71 printf <<'EOT', $op->label, ${$op->stash}, $$filegv, $op->seq, $op->arybase, $op->line;
85 printf "\top_sv\t\t0x%x\n", ${$op->sv};
92 printf "\top_pv\t\t0x%x\n", $op->pv;
98 printf "\top_gv\t\t0x%x\n", ${$op->gv};
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;
188 my ($filegv) = $sv->FILEGV;
189 printf <<'EOT', $$stash, $$start, $$root, $$gv, $$filegv, $sv->DEPTH, $padlist, ${$sv->OUTSIDE};
199 $start->debug if $start;
200 $root->debug if $root;
202 $filegv->debug if $filegv;
203 $padlist->debug if $padlist;
209 my(@array) = $av->ARRAY;
210 print "\tARRAY\t\t(", join(", ", map("0x" . $$_, @array)), ")\n";
211 printf <<'EOT', scalar(@array), $av->MAX, $av->OFF, $av->AvFLAGS;
221 if ($done_gv{$$gv}++) {
222 printf "GV %s::%s\n", $gv->STASH->NAME, $gv->NAME;
229 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->FILEGV, $gv->GvFLAGS;
249 sub B::SPECIAL::debug {
251 print $specialsv_name[$$sv], "\n";
256 if ($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>