Initial commit of OpenSPARC T2 design and verification files.
[OpenSPARC-T2-DV] / tools / perl-5.8.0 / lib / 5.8.0 / sun4-solaris / B / Debug.pm
CommitLineData
86530b38
AT
1package B::Debug;
2
3our $VERSION = '1.00';
4
5use strict;
6use B qw(peekop class walkoptree walkoptree_exec
7 main_start main_root cstring sv_undef);
8use B::Asmdata qw(@specialsv_name);
9
10my %done_gv;
11
12sub B::OP::debug {
13 my ($op) = @_;
14 printf <<'EOT', class($op), $$op, ${$op->next}, ${$op->sibling}, $op->ppaddr, $op->targ, $op->type, $op->seq, $op->flags, $op->private;
15%s (0x%lx)
16 op_next 0x%x
17 op_sibling 0x%x
18 op_ppaddr %s
19 op_targ %d
20 op_type %d
21 op_seq %d
22 op_flags %d
23 op_private %d
24EOT
25}
26
27sub B::UNOP::debug {
28 my ($op) = @_;
29 $op->B::OP::debug();
30 printf "\top_first\t0x%x\n", ${$op->first};
31}
32
33sub B::BINOP::debug {
34 my ($op) = @_;
35 $op->B::UNOP::debug();
36 printf "\top_last\t\t0x%x\n", ${$op->last};
37}
38
39sub B::LOOP::debug {
40 my ($op) = @_;
41 $op->B::BINOP::debug();
42 printf <<'EOT', ${$op->redoop}, ${$op->nextop}, ${$op->lastop};
43 op_redoop 0x%x
44 op_nextop 0x%x
45 op_lastop 0x%x
46EOT
47}
48
49sub B::LOGOP::debug {
50 my ($op) = @_;
51 $op->B::UNOP::debug();
52 printf "\top_other\t0x%x\n", ${$op->other};
53}
54
55sub B::LISTOP::debug {
56 my ($op) = @_;
57 $op->B::BINOP::debug();
58 printf "\top_children\t%d\n", $op->children;
59}
60
61sub B::PMOP::debug {
62 my ($op) = @_;
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;
70}
71
72sub B::COP::debug {
73 my ($op) = @_;
74 $op->B::OP::debug();
75 printf <<'EOT', $op->label, $op->stashpv, $op->file, $op->seq, $op->arybase, $op->line, ${$op->warnings};
76 cop_label %s
77 cop_stashpv %s
78 cop_file %s
79 cop_seq %d
80 cop_arybase %d
81 cop_line %d
82 cop_warnings 0x%x
83EOT
84}
85
86sub B::SVOP::debug {
87 my ($op) = @_;
88 $op->B::OP::debug();
89 printf "\top_sv\t\t0x%x\n", ${$op->sv};
90 $op->sv->debug;
91}
92
93sub B::PVOP::debug {
94 my ($op) = @_;
95 $op->B::OP::debug();
96 printf "\top_pv\t\t%s\n", cstring($op->pv);
97}
98
99sub B::PADOP::debug {
100 my ($op) = @_;
101 $op->B::OP::debug();
102 printf "\top_padix\t\t%ld\n", $op->padix;
103}
104
105sub B::CVOP::debug {
106 my ($op) = @_;
107 $op->B::OP::debug();
108 printf "\top_cv\t\t0x%x\n", ${$op->cv};
109}
110
111sub B::NULL::debug {
112 my ($sv) = @_;
113 if ($$sv == ${sv_undef()}) {
114 print "&sv_undef\n";
115 } else {
116 printf "NULL (0x%x)\n", $$sv;
117 }
118}
119
120sub B::SV::debug {
121 my ($sv) = @_;
122 if (!$$sv) {
123 print class($sv), " = NULL\n";
124 return;
125 }
126 printf <<'EOT', class($sv), $$sv, $sv->REFCNT, $sv->FLAGS;
127%s (0x%x)
128 REFCNT %d
129 FLAGS 0x%x
130EOT
131}
132
133sub B::RV::debug {
134 my ($rv) = @_;
135 B::SV::debug($rv);
136 printf <<'EOT', ${$rv->RV};
137 RV 0x%x
138EOT
139 $rv->RV->debug;
140}
141
142sub B::PV::debug {
143 my ($sv) = @_;
144 $sv->B::SV::debug();
145 my $pv = $sv->PV();
146 printf <<'EOT', cstring($pv), length($pv);
147 xpv_pv %s
148 xpv_cur %d
149EOT
150}
151
152sub B::IV::debug {
153 my ($sv) = @_;
154 $sv->B::SV::debug();
155 printf "\txiv_iv\t\t%d\n", $sv->IV;
156}
157
158sub B::NV::debug {
159 my ($sv) = @_;
160 $sv->B::IV::debug();
161 printf "\txnv_nv\t\t%s\n", $sv->NV;
162}
163
164sub B::PVIV::debug {
165 my ($sv) = @_;
166 $sv->B::PV::debug();
167 printf "\txiv_iv\t\t%d\n", $sv->IV;
168}
169
170sub B::PVNV::debug {
171 my ($sv) = @_;
172 $sv->B::PVIV::debug();
173 printf "\txnv_nv\t\t%s\n", $sv->NV;
174}
175
176sub B::PVLV::debug {
177 my ($sv) = @_;
178 $sv->B::PVNV::debug();
179 printf "\txlv_targoff\t%d\n", $sv->TARGOFF;
180 printf "\txlv_targlen\t%u\n", $sv->TARGLEN;
181 printf "\txlv_type\t%s\n", cstring(chr($sv->TYPE));
182}
183
184sub B::BM::debug {
185 my ($sv) = @_;
186 $sv->B::PVNV::debug();
187 printf "\txbm_useful\t%d\n", $sv->USEFUL;
188 printf "\txbm_previous\t%u\n", $sv->PREVIOUS;
189 printf "\txbm_rare\t%s\n", cstring(chr($sv->RARE));
190}
191
192sub B::CV::debug {
193 my ($sv) = @_;
194 $sv->B::PVNV::debug();
195 my ($stash) = $sv->STASH;
196 my ($start) = $sv->START;
197 my ($root) = $sv->ROOT;
198 my ($padlist) = $sv->PADLIST;
199 my ($file) = $sv->FILE;
200 my ($gv) = $sv->GV;
201 printf <<'EOT', $$stash, $$start, $$root, $$gv, $file, $sv->DEPTH, $padlist, ${$sv->OUTSIDE};
202 STASH 0x%x
203 START 0x%x
204 ROOT 0x%x
205 GV 0x%x
206 FILE %s
207 DEPTH %d
208 PADLIST 0x%x
209 OUTSIDE 0x%x
210EOT
211 $start->debug if $start;
212 $root->debug if $root;
213 $gv->debug if $gv;
214 $padlist->debug if $padlist;
215}
216
217sub B::AV::debug {
218 my ($av) = @_;
219 $av->B::SV::debug;
220 my(@array) = $av->ARRAY;
221 print "\tARRAY\t\t(", join(", ", map("0x" . $$_, @array)), ")\n";
222 printf <<'EOT', scalar(@array), $av->MAX, $av->OFF, $av->AvFLAGS;
223 FILL %d
224 MAX %d
225 OFF %d
226 AvFLAGS %d
227EOT
228}
229
230sub B::GV::debug {
231 my ($gv) = @_;
232 if ($done_gv{$$gv}++) {
233 printf "GV %s::%s\n", $gv->STASH->NAME, $gv->SAFENAME;
234 return;
235 }
236 my ($sv) = $gv->SV;
237 my ($av) = $gv->AV;
238 my ($cv) = $gv->CV;
239 $gv->B::SV::debug;
240 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;
241 NAME %s
242 STASH %s (0x%x)
243 SV 0x%x
244 GvREFCNT %d
245 FORM 0x%x
246 AV 0x%x
247 HV 0x%x
248 EGV 0x%x
249 CV 0x%x
250 CVGEN %d
251 LINE %d
252 FILE %s
253 GvFLAGS 0x%x
254EOT
255 $sv->debug if $sv;
256 $av->debug if $av;
257 $cv->debug if $cv;
258}
259
260sub B::SPECIAL::debug {
261 my $sv = shift;
262 print $specialsv_name[$$sv], "\n";
263}
264
265sub compile {
266 my $order = shift;
267 B::clearsym();
268 if ($order && $order eq "exec") {
269 return sub { walkoptree_exec(main_start, "debug") }
270 } else {
271 return sub { walkoptree(main_root, "debug") }
272 }
273}
274
2751;
276
277__END__
278
279=head1 NAME
280
281B::Debug - Walk Perl syntax tree, printing debug info about ops
282
283=head1 SYNOPSIS
284
285 perl -MO=Debug[,OPTIONS] foo.pl
286
287=head1 DESCRIPTION
288
289See F<ext/B/README>.
290
291=head1 AUTHOR
292
293Malcolm Beattie, C<mbeattie@sable.ox.ac.uk>
294
295=cut