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::LISTOP::debug {
44 $op->B::BINOP::debug();
45 printf "\top_last\t\t0x%x\n", ${$op->last};
50 $op->B::LISTOP::debug();
51 printf "\top_pmreplroot\t0x%x\n", ${$op->pmreplroot};
52 printf "\top_pmreplstart\t0x%x\n", ${$op->pmreplstart};
53 printf "\top_pmnext\t0x%x\n", ${$op->pmnext};
54 printf "\top_pmregexp->precomp\t%s\n", cstring($op->precomp);
55 printf "\top_pmflags\t0x%x\n", $op->pmflags;
56 $op->pmreplroot->debug;
62 printf <<'EOT', $op->label, $op->stashpv, $op->file, $op->seq, $op->arybase, $op->line, ${$op->warnings};
76 printf "\top_sv\t\t0x%x\n", ${$op->sv};
83 printf "\top_pv\t\t0x%x\n", $op->pv;
89 printf "\top_padix\t\t%ld\n", $op->padix;
95 printf "\top_cv\t\t0x%x\n", ${$op->cv};
100 if ($$sv == ${sv_undef()}) {
103 printf "NULL (0x%x)\n", $$sv;
110 print class($sv), " = NULL\n";
113 printf <<'EOT', class($sv), $$sv, $sv->REFCNT, $sv->FLAGS;
124 printf <<'EOT', cstring($pv), length($pv);
133 printf "\txiv_iv\t\t%d\n", $sv->IV;
139 printf "\txnv_nv\t\t%s\n", $sv->NV;
145 printf "\txiv_iv\t\t%d\n", $sv->IV;
150 $sv->B::PVIV::debug();
151 printf "\txnv_nv\t\t%s\n", $sv->NV;
156 $sv->B::PVNV::debug();
157 printf "\txlv_targoff\t%d\n", $sv->TARGOFF;
158 printf "\txlv_targlen\t%u\n", $sv->TARGLEN;
159 printf "\txlv_type\t%s\n", cstring(chr($sv->TYPE));
164 $sv->B::PVNV::debug();
165 printf "\txbm_useful\t%d\n", $sv->USEFUL;
166 printf "\txbm_previous\t%u\n", $sv->PREVIOUS;
167 printf "\txbm_rare\t%s\n", cstring(chr($sv->RARE));
172 $sv->B::PVNV::debug();
173 my ($stash) = $sv->STASH;
174 my ($start) = $sv->START;
175 my ($root) = $sv->ROOT;
176 my ($padlist) = $sv->PADLIST;
177 my ($file) = $sv->FILE;
179 printf <<'EOT', $$stash, $$start, $$root, $$gv, $file, $sv->DEPTH, $padlist, ${$sv->OUTSIDE};
189 $start->debug if $start;
190 $root->debug if $root;
192 $padlist->debug if $padlist;
198 my(@array) = $av->ARRAY;
199 print "\tARRAY\t\t(", join(", ", map("0x" . $$_, @array)), ")\n";
200 printf <<'EOT', scalar(@array), $av->MAX, $av->OFF, $av->AvFLAGS;
210 if ($done_gv{$$gv}++) {
211 printf "GV %s::%s\n", $gv->STASH->NAME, $gv->NAME;
218 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;
238 sub B::SPECIAL::debug {
240 print $specialsv_name[$$sv], "\n";
246 if ($order && $order eq "exec") {
247 return sub { walkoptree_exec(main_start, "debug") }
249 return sub { walkoptree(main_root, "debug") }
259 B::Debug - Walk Perl syntax tree, printing debug info about ops
263 perl -MO=Debug[,OPTIONS] foo.pl
271 Malcolm Beattie, C<mbeattie@sable.ox.ac.uk>