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->cop_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;
109 if ($$sv == ${sv_undef()}) {
112 printf "NULL (0x%x)\n", $$sv;
119 print class($sv), " = NULL\n";
122 printf <<'EOT', class($sv), $$sv, $sv->REFCNT, $sv->FLAGS;
132 printf <<'EOT', ${$rv->RV};
142 printf <<'EOT', cstring($pv), length($pv);
151 printf "\txiv_iv\t\t%d\n", $sv->IV;
157 printf "\txnv_nv\t\t%s\n", $sv->NV;
163 printf "\txiv_iv\t\t%d\n", $sv->IV;
168 $sv->B::PVIV::debug();
169 printf "\txnv_nv\t\t%s\n", $sv->NV;
174 $sv->B::PVNV::debug();
175 printf "\txlv_targoff\t%d\n", $sv->TARGOFF;
176 printf "\txlv_targlen\t%u\n", $sv->TARGLEN;
177 printf "\txlv_type\t%s\n", cstring(chr($sv->TYPE));
182 $sv->B::PVNV::debug();
183 printf "\txbm_useful\t%d\n", $sv->USEFUL;
184 printf "\txbm_previous\t%u\n", $sv->PREVIOUS;
185 printf "\txbm_rare\t%s\n", cstring(chr($sv->RARE));
190 $sv->B::PVNV::debug();
191 my ($stash) = $sv->STASH;
192 my ($start) = $sv->START;
193 my ($root) = $sv->ROOT;
194 my ($padlist) = $sv->PADLIST;
195 my ($file) = $sv->FILE;
197 printf <<'EOT', $$stash, $$start, $$root, $$gv, $file, $sv->DEPTH, $padlist, ${$sv->OUTSIDE}, $sv->OUTSIDE_SEQ;
208 $start->debug if $start;
209 $root->debug if $root;
211 $padlist->debug if $padlist;
217 my(@array) = $av->ARRAY;
218 print "\tARRAY\t\t(", join(", ", map("0x" . $$_, @array)), ")\n";
219 printf <<'EOT', scalar(@array), $av->MAX, $av->OFF, $av->AvFLAGS;
229 if ($done_gv{$$gv}++) {
230 printf "GV %s::%s\n", $gv->STASH->NAME, $gv->SAFENAME;
237 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;
257 sub B::SPECIAL::debug {
259 print $specialsv_name[$$sv], "\n";
265 if ($order && $order eq "exec") {
266 return sub { walkoptree_exec(main_start, "debug") }
268 return sub { walkoptree(main_root, "debug") }
278 B::Debug - Walk Perl syntax tree, printing debug info about ops
282 perl -MO=Debug[,OPTIONS] foo.pl
290 Malcolm Beattie, C<mbeattie@sable.ox.ac.uk>