package B::Xref;
+our $VERSION = '1.01';
+
=head1 NAME
B::Xref - Generates cross reference reports for Perl programs
File filename1
Subroutine subname1
Package package1
- object1 C<line numbers>
- object2 C<line numbers>
+ object1 line numbers
+ object2 line numbers
...
Package package2
...
Raw output. Instead of producing a human-readable report, outputs a line
in machine-readable form for each definition/use of a variable/sub/format.
+=item C<-d>
+
+Don't output the "(definitions)" sections.
+
=item C<-D[tO]>
(Internal) debug options, probably only useful if C<-r> included.
use strict;
use Config;
use B qw(peekop class comppadlist main_start svref_2object walksymtable
- OPpLVAL_INTRO SVf_POK
+ OPpLVAL_INTRO SVf_POK OPpOUR_INTRO cstring
);
sub UNKNOWN { ["?", "?", "?"] }
my $namesv = $namelist[$ix];
next if class($namesv) eq "SPECIAL";
my ($type, $name) = $namesv->PV =~ /^(.)([^\0]*)(\0.*)?$/;
- $pad[$ix] = ["(lexical)", $type, $name];
+ $pad[$ix] = ["(lexical)", $type || '?', $name || '?'];
}
if ($Config{useithreads}) {
my (@vallist);
sub pp_padhv { pp_padsv(@_) }
sub deref {
- my ($var, $as) = @_;
+ my ($op, $var, $as) = @_;
$var->[1] = $as . $var->[1];
- process($var, "used");
+ process($var, $op->private & OPpOUR_INTRO ? "intro" : "used");
}
-sub pp_rv2cv { deref($top, "&"); }
-sub pp_rv2hv { deref($top, "%"); }
-sub pp_rv2sv { deref($top, "\$"); }
-sub pp_rv2av { deref($top, "\@"); }
-sub pp_rv2gv { deref($top, "*"); }
+sub pp_rv2cv { deref(shift, $top, "&"); }
+sub pp_rv2hv { deref(shift, $top, "%"); }
+sub pp_rv2sv { deref(shift, $top, "\$"); }
+sub pp_rv2av { deref(shift, $top, "\@"); }
+sub pp_rv2gv { deref(shift, $top, "*"); }
sub pp_gvsv {
my $op = shift;
}
else {
$gv = $op->gv;
- $top = [$gv->STASH->NAME, '$', $gv->NAME];
+ $top = [$gv->STASH->NAME, '$', $gv->SAFENAME];
}
- process($top, $op->private & OPpLVAL_INTRO ? "intro" : "used");
+ process($top, $op->private & OPpLVAL_INTRO ||
+ $op->private & OPpOUR_INTRO ? "intro" : "used");
}
sub pp_gv {
}
else {
$gv = $op->gv;
- $top = [$gv->STASH->NAME, "*", $gv->NAME];
+ $top = [$gv->STASH->NAME, "*", $gv->SAFENAME];
}
process($top, $op->private & OPpLVAL_INTRO ? "intro" : "used");
}
# constant could be in the pad (under useithreads)
if ($$sv) {
$top = ["?", "",
- (class($sv) ne "SPECIAL" && $sv->FLAGS & SVf_POK) ? $sv->PV : "?"];
+ (class($sv) ne "SPECIAL" && $sv->FLAGS & SVf_POK)
+ ? cstring($sv->PV) : "?"];
}
else {
$top = $pad[$op->targ];
+ $top = UNKNOWN unless $top;
}
}
return if $nodefs;
$subname = "(definitions)";
foreach $pack (qw(B O AutoLoader DynaLoader XSLoader Config DB VMS
- strict vars FileHandle Exporter Carp)) {
+ strict vars FileHandle Exporter Carp PerlIO::Layer
+ attributes utf8 warnings)) {
$exclude{$pack."::"} = 1;
}
no strict qw(vars refs);