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 my $cop_io = class($op->io) eq 'SPECIAL' ? '' : $op->io->as_string;
76 printf <<'EOT', $op->label, $op->stashpv, $op->file, $op->seq, $op->arybase, $op->line, ${$op->warnings}, cstring($cop_io);
91 printf "\top_sv\t\t0x%x\n", ${$op->sv};
98 printf "\top_pv\t\t%s\n", cstring($op->pv);
101 sub B::PADOP::debug {
104 printf "\top_padix\t\t%ld\n", $op->padix;
110 printf "\top_cv\t\t0x%x\n", ${$op->cv};
115 if ($$sv == ${sv_undef()}) {
118 printf "NULL (0x%x)\n", $$sv;
125 print class($sv), " = NULL\n";
128 printf <<'EOT', class($sv), $$sv, $sv->REFCNT, $sv->FLAGS;
138 printf <<'EOT', ${$rv->RV};
148 printf <<'EOT', cstring($pv), length($pv);
157 printf "\txiv_iv\t\t%d\n", $sv->IV;
163 printf "\txnv_nv\t\t%s\n", $sv->NV;
169 printf "\txiv_iv\t\t%d\n", $sv->IV;
174 $sv->B::PVIV::debug();
175 printf "\txnv_nv\t\t%s\n", $sv->NV;
180 $sv->B::PVNV::debug();
181 printf "\txlv_targoff\t%d\n", $sv->TARGOFF;
182 printf "\txlv_targlen\t%u\n", $sv->TARGLEN;
183 printf "\txlv_type\t%s\n", cstring(chr($sv->TYPE));
188 $sv->B::PVNV::debug();
189 printf "\txbm_useful\t%d\n", $sv->USEFUL;
190 printf "\txbm_previous\t%u\n", $sv->PREVIOUS;
191 printf "\txbm_rare\t%s\n", cstring(chr($sv->RARE));
196 $sv->B::PVNV::debug();
197 my ($stash) = $sv->STASH;
198 my ($start) = $sv->START;
199 my ($root) = $sv->ROOT;
200 my ($padlist) = $sv->PADLIST;
201 my ($file) = $sv->FILE;
203 printf <<'EOT', $$stash, $$start, $$root, $$gv, $file, $sv->DEPTH, $padlist, ${$sv->OUTSIDE}, $sv->OUTSIDE_SEQ;
214 $start->debug if $start;
215 $root->debug if $root;
217 $padlist->debug if $padlist;
223 my(@array) = $av->ARRAY;
224 print "\tARRAY\t\t(", join(", ", map("0x" . $$_, @array)), ")\n";
225 printf <<'EOT', scalar(@array), $av->MAX, $av->OFF, $av->AvFLAGS;
235 if ($done_gv{$$gv}++) {
236 printf "GV %s::%s\n", $gv->STASH->NAME, $gv->SAFENAME;
243 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;
263 sub B::SPECIAL::debug {
265 print $specialsv_name[$$sv], "\n";
271 if ($order && $order eq "exec") {
272 return sub { walkoptree_exec(main_start, "debug") }
274 return sub { walkoptree(main_root, "debug") }
284 B::Debug - Walk Perl syntax tree, printing debug info about ops
288 perl -MO=Debug[,OPTIONS] foo.pl
296 Malcolm Beattie, C<mbeattie@sable.ox.ac.uk>