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->opt, $op->static, $op->flags, $op->private;
31 printf "\top_first\t0x%x\n", ${$op->first};
36 $op->B::UNOP::debug();
37 printf "\top_last\t\t0x%x\n", ${$op->last};
42 $op->B::BINOP::debug();
43 printf <<'EOT', ${$op->redoop}, ${$op->nextop}, ${$op->lastop};
52 $op->B::UNOP::debug();
53 printf "\top_other\t0x%x\n", ${$op->other};
56 sub B::LISTOP::debug {
58 $op->B::BINOP::debug();
59 printf "\top_children\t%d\n", $op->children;
64 $op->B::LISTOP::debug();
65 printf "\top_pmreplroot\t0x%x\n", ${$op->pmreplroot};
66 printf "\top_pmreplstart\t0x%x\n", ${$op->pmreplstart};
67 printf "\top_pmnext\t0x%x\n", ${$op->pmnext};
68 printf "\top_pmregexp->precomp\t%s\n", cstring($op->precomp);
69 printf "\top_pmflags\t0x%x\n", $op->pmflags;
70 $op->pmreplroot->debug;
76 my $cop_io = class($op->io) eq 'SPECIAL' ? '' : $op->io->as_string;
77 printf <<'EOT', $op->label, $op->stashpv, $op->file, $op->cop_seq, $op->arybase, $op->line, ${$op->warnings}, cstring($cop_io);
92 printf "\top_sv\t\t0x%x\n", ${$op->sv};
99 printf "\top_pv\t\t%s\n", cstring($op->pv);
102 sub B::PADOP::debug {
105 printf "\top_padix\t\t%ld\n", $op->padix;
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;
133 printf <<'EOT', ${$rv->RV};
143 printf <<'EOT', cstring($pv), length($pv);
152 printf "\txiv_iv\t\t%d\n", $sv->IV;
158 printf "\txnv_nv\t\t%s\n", $sv->NV;
164 printf "\txiv_iv\t\t%d\n", $sv->IV;
169 $sv->B::PVIV::debug();
170 printf "\txnv_nv\t\t%s\n", $sv->NV;
175 $sv->B::PVNV::debug();
176 printf "\txlv_targoff\t%d\n", $sv->TARGOFF;
177 printf "\txlv_targlen\t%u\n", $sv->TARGLEN;
178 printf "\txlv_type\t%s\n", cstring(chr($sv->TYPE));
183 $sv->B::PVNV::debug();
184 printf "\txbm_useful\t%d\n", $sv->USEFUL;
185 printf "\txbm_previous\t%u\n", $sv->PREVIOUS;
186 printf "\txbm_rare\t%s\n", cstring(chr($sv->RARE));
191 $sv->B::PVNV::debug();
192 my ($stash) = $sv->STASH;
193 my ($start) = $sv->START;
194 my ($root) = $sv->ROOT;
195 my ($padlist) = $sv->PADLIST;
196 my ($file) = $sv->FILE;
198 printf <<'EOT', $$stash, $$start, $$root, $$gv, $file, $sv->DEPTH, $padlist, ${$sv->OUTSIDE}, $sv->OUTSIDE_SEQ;
209 $start->debug if $start;
210 $root->debug if $root;
212 $padlist->debug if $padlist;
218 my(@array) = $av->ARRAY;
219 print "\tARRAY\t\t(", join(", ", map("0x" . $$_, @array)), ")\n";
220 printf <<'EOT', scalar(@array), $av->MAX, $av->OFF, $av->AvFLAGS;
230 if ($done_gv{$$gv}++) {
231 printf "GV %s::%s\n", $gv->STASH->NAME, $gv->SAFENAME;
238 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;
258 sub B::SPECIAL::debug {
260 print $specialsv_name[$$sv], "\n";
266 if ($order && $order eq "exec") {
267 return sub { walkoptree_exec(main_start, "debug") }
269 return sub { walkoptree(main_root, "debug") }
279 B::Debug - Walk Perl syntax tree, printing debug info about ops
283 perl -MO=Debug[,OPTIONS] foo.pl
291 Malcolm Beattie, C<mbeattie@sable.ox.ac.uk>