| 1 | # You may distribute under the terms of either the GNU General Public License | ||||||||||||||||||||||||||||||||||||||||||
| 2 | # or the Artistic License (the same terms as Perl itself) | ||||||||||||||||||||||||||||||||||||||||||
| 3 | # | ||||||||||||||||||||||||||||||||||||||||||
| 4 | # (C) Paul Evans, 2017-2026 -- leonerd@leonerd.org.uk | ||||||||||||||||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||||||||||||||||
| 6 | package Devel::MAT::Tool::Find 0.56; | ||||||||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||||||||
| 8 | 5 | ▶ | use v5.20; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 9 | 5 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 10 | 5 | ▶ | use base qw( Devel::MAT::Tool ); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||||||||||||
| 12 | 5 | ▶ | use feature qw( postderef signatures ); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 13 | 5 | ▶ | no warnings qw( experimental::postderef experimental::signatures ); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||||||||||||
| 15 | 5 | ▶ | use Scalar::Util qw( blessed ); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||||||||||||||||
| 17 | 5 | ▶ | use constant CMD => "find"; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 18 | 5 | ▶ | use constant CMD_DESC => "List SVs matching given criteria"; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||||||||||||
| 20 | 5 | ▶ | use constant CMD_OPTS => ( | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 21 | count => { help => "Just print a count of the matching SVs", | ||||||||||||||||||||||||||||||||||||||||||
| 22 | alias => "C" }, | ||||||||||||||||||||||||||||||||||||||||||
| 23 | 5 | ); | |||||||||||||||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||||||||||||||||
| 25 | use Module::Pluggable | ||||||||||||||||||||||||||||||||||||||||||
| 26 | 5 | ▶ | sub_name => "FILTERS", | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 27 | search_path => [ "Devel::MAT::Tool::Find::filter" ], | ||||||||||||||||||||||||||||||||||||||||||
| 28 | 5 | require => 1; | |||||||||||||||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||||||||||||||||
| 30 | =head1 NAME | ||||||||||||||||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||||||||||||||||
| 32 | C<Devel::MAT::Tool::Find> - list SVs matching given criteria | ||||||||||||||||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||||||||||||||||
| 34 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||||||||||||||||
| 36 | This C<Devel::MAT> tool provides a command to search for SVs matching given | ||||||||||||||||||||||||||||||||||||||||||
| 37 | criteria. | ||||||||||||||||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||||||||||||||||
| 39 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||||||||||||||||
| 41 | =head1 COMMANDS | ||||||||||||||||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||||||||||||||||
| 43 | =for highlighter | ||||||||||||||||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||||||||||||||||
| 45 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||||||||||||||||
| 47 | =head2 find | ||||||||||||||||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||||||||||||||||
| 49 | pmat> find io | ||||||||||||||||||||||||||||||||||||||||||
| 50 | IO()=IO::File at 0x55a7e4d88760: ifileno=1 ofileno=1 | ||||||||||||||||||||||||||||||||||||||||||
| 51 | ... | ||||||||||||||||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||||||||||||||||
| 53 | Prints a list of all the SVs that match the given filter criteria. | ||||||||||||||||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||||||||||||||||
| 55 | Takes the following named options: | ||||||||||||||||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||||||||||||||||
| 57 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||||||||||||||||
| 59 | =item --count, -C | ||||||||||||||||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||||||||||||||||
| 61 | Just count the matching SVs and print the total | ||||||||||||||||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||||||||||||||||
| 63 | =back | ||||||||||||||||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||||||||||||||||
| 65 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||||||||||||||||
| 67 | # TODO(leonerd): This is ugly; taking over ->run_cmd directly. See if we can | ||||||||||||||||||||||||||||||||||||||||||
| 68 | # integrate it better | ||||||||||||||||||||||||||||||||||||||||||
| 69 | 0 | ▶ | sub run_cmd ( $self, $inv ) | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
run_cmd: not called CC=10 SCAR=47.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 70 | { | ||||||||||||||||||||||||||||||||||||||||||
| 71 | 0 | my %opts = $self->get_opts_from_inv( $inv, { $self->CMD_OPTS }, | |||||||||||||||||||||||||||||||||||||||||
| 72 | permute => 0, | ||||||||||||||||||||||||||||||||||||||||||
| 73 | )->%*; | ||||||||||||||||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||||||||||||||||
| 75 | 0 | my @filters; | |||||||||||||||||||||||||||||||||||||||||
| 76 | 0 | ▶ | while( length $inv->peek_remaining ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 77 | 0 | push @filters, $self->build_filter( $inv ); | |||||||||||||||||||||||||||||||||||||||||
| 78 | } | ||||||||||||||||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||||||||||||||||
| 80 | 0 | ▶ | if( $opts{count} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 81 | 0 | my $count = 0; | |||||||||||||||||||||||||||||||||||||||||
| 82 | 0 | SV: foreach my $sv ( $self->df->heap ) { | |||||||||||||||||||||||||||||||||||||||||
| 83 | 0 | foreach my $filter ( @filters ) { | |||||||||||||||||||||||||||||||||||||||||
| 84 | 0 | ▶ | my $ret = $filter->( $sv ) or next SV; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 85 | 0 | ▶ | if( !blessed $ret and ref $ret eq "HASH" ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
not builtin::blessed($ret) and ref $ret eq "HASH"
MC/DC0%0/2
not builtin::blessed($ret) and ref $ret eq "HASH"
not builtin::blessed($ret)
ref $ret eq "HASH"
Truth table0%0/3
not(A) and B
A= not builtin::blessed($ret)B= ref $ret eq "HASH"
| |||||||||||||||||||||||||||||||||||||||||||
| 86 | 0 | ▶ | $sv = $ret->{sv} if $ret->{sv}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 87 | } | ||||||||||||||||||||||||||||||||||||||||||
| 88 | } | ||||||||||||||||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||||||||||||||||
| 90 | 0 | $count++; | |||||||||||||||||||||||||||||||||||||||||
| 91 | } | ||||||||||||||||||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||||||||||||||||
| 93 | 0 | ▶ | Devel::MAT::Cmd->printf( "Total: %s SVs\n", $count ) if $opts{count}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 94 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 95 | } | ||||||||||||||||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||||||||||||||||
| 97 | 0 | my @svs = $self->df->heap; | |||||||||||||||||||||||||||||||||||||||||
| 98 | 0 | my ( $sv, @output ); | |||||||||||||||||||||||||||||||||||||||||
| 99 | 0 | ▶ | Devel::MAT::Tool::more->paginate( sub ( $count ) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=10 SCAR=47.0
| |||||||||||||||||||||||||||||||||||||||||||
| 100 | 0 | ▶ | SV: while( $sv = shift @svs ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 101 | 0 | @output = (); | |||||||||||||||||||||||||||||||||||||||||
| 102 | |||||||||||||||||||||||||||||||||||||||||||
| 103 | 0 | foreach my $filter ( @filters ) { | |||||||||||||||||||||||||||||||||||||||||
| 104 | 0 | ▶ | my $ret = $filter->( $sv ) or next SV; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 105 | # Allow filters to alter the search as we go | ||||||||||||||||||||||||||||||||||||||||||
| 106 | 0 | ▶ | if( !blessed $ret and ref $ret eq "HASH" ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
not builtin::blessed($ret) and ref $ret eq "HASH"
MC/DC0%0/2
not builtin::blessed($ret) and ref $ret eq "HASH"
not builtin::blessed($ret)
ref $ret eq "HASH"
Truth table0%0/3
not(A) and B
A= not builtin::blessed($ret)B= ref $ret eq "HASH"
| |||||||||||||||||||||||||||||||||||||||||||
| 107 | 0 | ▶ | $sv = $ret->{sv} if $ret->{sv}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 108 | 0 | ▶ | push @output, $ret->{output} if $ret->{output}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 109 | } | ||||||||||||||||||||||||||||||||||||||||||
| 110 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 111 | 0 | push @output, $ret; | |||||||||||||||||||||||||||||||||||||||||
| 112 | } | ||||||||||||||||||||||||||||||||||||||||||
| 113 | } | ||||||||||||||||||||||||||||||||||||||||||
| 114 | |||||||||||||||||||||||||||||||||||||||||||
| 115 | 0 | my $fmt = "%s"; | |||||||||||||||||||||||||||||||||||||||||
| 116 | 0 | ▶ | $fmt .= ": " . join( " ", ( "%s" ) x @output ) if @output; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 117 | |||||||||||||||||||||||||||||||||||||||||||
| 118 | 0 | Devel::MAT::Cmd->printf( "$fmt\n", | |||||||||||||||||||||||||||||||||||||||||
| 119 | Devel::MAT::Cmd->format_sv( $sv ), | ||||||||||||||||||||||||||||||||||||||||||
| 120 | @output | ||||||||||||||||||||||||||||||||||||||||||
| 121 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 122 | |||||||||||||||||||||||||||||||||||||||||||
| 123 | 0 | ▶ | last SV unless $count--; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 124 | } | ||||||||||||||||||||||||||||||||||||||||||
| 125 | |||||||||||||||||||||||||||||||||||||||||||
| 126 | 0 | return !!@svs; | |||||||||||||||||||||||||||||||||||||||||
| 127 | 0 | } ); | |||||||||||||||||||||||||||||||||||||||||
| 128 | } | ||||||||||||||||||||||||||||||||||||||||||
| 129 | |||||||||||||||||||||||||||||||||||||||||||
| 130 | 0 | ▶ | sub help_cmd ( $self ) | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
help_cmd: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 131 | { | ||||||||||||||||||||||||||||||||||||||||||
| 132 | 0 | Devel::MAT::Cmd->printf( "\nSYNOPSIS:\n" ); | |||||||||||||||||||||||||||||||||||||||||
| 133 | 0 | Devel::MAT::Cmd->printf( " find [FILTER...]\n" ); | |||||||||||||||||||||||||||||||||||||||||
| 134 | |||||||||||||||||||||||||||||||||||||||||||
| 135 | 0 | Devel::MAT::Cmd->printf( "\nFILTERS:\n" ); | |||||||||||||||||||||||||||||||||||||||||
| 136 | |||||||||||||||||||||||||||||||||||||||||||
| 137 | 0 | foreach my $pkg ( FILTERS ) { | |||||||||||||||||||||||||||||||||||||||||
| 138 | 0 | my $name = $pkg =~ s/^Devel::MAT::Tool::Find::filter:://r; | |||||||||||||||||||||||||||||||||||||||||
| 139 | |||||||||||||||||||||||||||||||||||||||||||
| 140 | 0 | Devel::MAT::Cmd->printf( " %s %s - %s\n", | |||||||||||||||||||||||||||||||||||||||||
| 141 | Devel::MAT::Cmd->format_note( "find" ), | ||||||||||||||||||||||||||||||||||||||||||
| 142 | Devel::MAT::Cmd->format_note( $name ), | ||||||||||||||||||||||||||||||||||||||||||
| 143 | $pkg->FILTER_DESC, | ||||||||||||||||||||||||||||||||||||||||||
| 144 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 145 | } | ||||||||||||||||||||||||||||||||||||||||||
| 146 | } | ||||||||||||||||||||||||||||||||||||||||||
| 147 | |||||||||||||||||||||||||||||||||||||||||||
| 148 | # to make help work | ||||||||||||||||||||||||||||||||||||||||||
| 149 | 0 | ▶ | sub find_subcommand ( $self, $name ) { return "Devel::MAT::Tool::Find::filter::$name" } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
find_subcommand: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 150 | |||||||||||||||||||||||||||||||||||||||||||
| 151 | 0 | ▶ | sub build_filter ( $self, $inv ) | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
build_filter: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 152 | { | ||||||||||||||||||||||||||||||||||||||||||
| 153 | 0 | my $name = $inv->pull_token; | |||||||||||||||||||||||||||||||||||||||||
| 154 | 0 | my $filterpkg = "Devel::MAT::Tool::Find::filter::$name"; | |||||||||||||||||||||||||||||||||||||||||
| 155 | 0 | ▶ | $filterpkg->can( "build" ) or | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 156 | die "Unknown filter type '$name'"; | ||||||||||||||||||||||||||||||||||||||||||
| 157 | |||||||||||||||||||||||||||||||||||||||||||
| 158 | 0 | my @args; | |||||||||||||||||||||||||||||||||||||||||
| 159 | |||||||||||||||||||||||||||||||||||||||||||
| 160 | 0 | ▶ | if( my %optspec = $filterpkg->FILTER_OPTS ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 161 | 0 | push @args, $self->get_opts_from_inv( $inv, \%optspec ); | |||||||||||||||||||||||||||||||||||||||||
| 162 | } | ||||||||||||||||||||||||||||||||||||||||||
| 163 | |||||||||||||||||||||||||||||||||||||||||||
| 164 | 0 | ▶ | if( my @argspec = $filterpkg->FILTER_ARGS ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 165 | 0 | push @args, $self->get_args_from_inv( $inv, @argspec ); | |||||||||||||||||||||||||||||||||||||||||
| 166 | } | ||||||||||||||||||||||||||||||||||||||||||
| 167 | |||||||||||||||||||||||||||||||||||||||||||
| 168 | 0 | return $filterpkg->build( $inv, @args ); | |||||||||||||||||||||||||||||||||||||||||
| 169 | } | ||||||||||||||||||||||||||||||||||||||||||
| 170 | |||||||||||||||||||||||||||||||||||||||||||
| 171 | =head1 FILTERS | ||||||||||||||||||||||||||||||||||||||||||
| 172 | |||||||||||||||||||||||||||||||||||||||||||
| 173 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 174 | |||||||||||||||||||||||||||||||||||||||||||
| 175 | package # hide | ||||||||||||||||||||||||||||||||||||||||||
| 176 | Devel::MAT::Tool::Find::filter; | ||||||||||||||||||||||||||||||||||||||||||
| 177 | |||||||||||||||||||||||||||||||||||||||||||
| 178 | 0 | ▶ | sub CMD_DESC ( $self ) { return "find " . $self->FILTER_DESC } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
CMD_DESC: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 179 | |||||||||||||||||||||||||||||||||||||||||||
| 180 | 5 | ▶ | use constant FILTER_OPTS => (); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 181 | 0 | ▶ | sub CMD_OPTS ( $self ) { $self->FILTER_OPTS } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
CMD_OPTS: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 182 | |||||||||||||||||||||||||||||||||||||||||||
| 183 | 5 | ▶ | use constant CMD_ARGS_SV => 0; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 184 | |||||||||||||||||||||||||||||||||||||||||||
| 185 | 5 | ▶ | use constant FILTER_ARGS => (); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 186 | 0 | ▶ | sub CMD_ARGS ( $self ) { $self->FILTER_ARGS } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
CMD_ARGS: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 187 | |||||||||||||||||||||||||||||||||||||||||||
| 188 | package # hide | ||||||||||||||||||||||||||||||||||||||||||
| 189 | Devel::MAT::Tool::Find::filter::num; | ||||||||||||||||||||||||||||||||||||||||||
| 190 | 5 | ▶ | use base qw( Devel::MAT::Tool::Find::filter ); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 191 | |||||||||||||||||||||||||||||||||||||||||||
| 192 | 5 | ▶ | use constant FILTER_DESC => "Numerical (IV, UV or NV) SVs"; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 193 | |||||||||||||||||||||||||||||||||||||||||||
| 194 | 5 | ▶ | use constant FILTER_OPTS => ( | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 195 | iv => { help => "Include IVs" }, | ||||||||||||||||||||||||||||||||||||||||||
| 196 | uv => { help => "Include UVs" }, | ||||||||||||||||||||||||||||||||||||||||||
| 197 | nv => { help => "Include NVs" }, | ||||||||||||||||||||||||||||||||||||||||||
| 198 | 5 | ); | |||||||||||||||||||||||||||||||||||||||||
| 199 | |||||||||||||||||||||||||||||||||||||||||||
| 200 | 5 | ▶ | use constant FILTER_ARGS => ( | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 201 | { name => "value", help => "match value" }, | ||||||||||||||||||||||||||||||||||||||||||
| 202 | 5 | ); | |||||||||||||||||||||||||||||||||||||||||
| 203 | |||||||||||||||||||||||||||||||||||||||||||
| 204 | =head2 num | ||||||||||||||||||||||||||||||||||||||||||
| 205 | |||||||||||||||||||||||||||||||||||||||||||
| 206 | pmat> find num | ||||||||||||||||||||||||||||||||||||||||||
| 207 | SCALAR(UV) at 0x555555a1e9c0: 5 | ||||||||||||||||||||||||||||||||||||||||||
| 208 | SCALAR(UV) at 0x555555c4f1b0: 2 | ||||||||||||||||||||||||||||||||||||||||||
| 209 | SCALAR(UV) at 0x555555aa0dc0: 18446744073709551615 | ||||||||||||||||||||||||||||||||||||||||||
| 210 | |||||||||||||||||||||||||||||||||||||||||||
| 211 | Prints a list of all the scalar SVs that have a numerical value, optionally | ||||||||||||||||||||||||||||||||||||||||||
| 212 | filtering for only an exact value. | ||||||||||||||||||||||||||||||||||||||||||
| 213 | |||||||||||||||||||||||||||||||||||||||||||
| 214 | Takes the following named options: | ||||||||||||||||||||||||||||||||||||||||||
| 215 | |||||||||||||||||||||||||||||||||||||||||||
| 216 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||
| 217 | |||||||||||||||||||||||||||||||||||||||||||
| 218 | =item --nv, --iv, --uv | ||||||||||||||||||||||||||||||||||||||||||
| 219 | |||||||||||||||||||||||||||||||||||||||||||
| 220 | Find only numerical SVs of the given types. If no options present, any | ||||||||||||||||||||||||||||||||||||||||||
| 221 | numerical SV will be found. | ||||||||||||||||||||||||||||||||||||||||||
| 222 | |||||||||||||||||||||||||||||||||||||||||||
| 223 | =back | ||||||||||||||||||||||||||||||||||||||||||
| 224 | |||||||||||||||||||||||||||||||||||||||||||
| 225 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 226 | |||||||||||||||||||||||||||||||||||||||||||
| 227 | 0 | ▶ | sub build ( $self, $inv, $optsref, $value = undef ) | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
build: not called CC=5 SCAR=34.0
| |||||||||||||||||||||||||||||||||||||||||||
| 228 | 0 | { | |||||||||||||||||||||||||||||||||||||||||
| 229 | 0 | my %opts = $optsref->%*; | |||||||||||||||||||||||||||||||||||||||||
| 230 | |||||||||||||||||||||||||||||||||||||||||||
| 231 | $opts{iv} or $opts{uv} or $opts{nv} or | ||||||||||||||||||||||||||||||||||||||||||
| 232 | 0 | ▶ | $opts{iv} = $opts{uv} = $opts{nv} = 1; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
$opts{"iv"} or $opts{"uv"} or $opts{"nv"}
$opts{"iv"} or $opts{"uv"}
MC/DC0%0/3
$opts{"iv"} or $opts{"uv"} or $opts{"nv"}
$opts{"iv"}
$opts{"uv"}
$opts{"nv"}
Truth table0%0/4
A or B or C
A= $opts{"iv"}B= $opts{"uv"}C= $opts{"nv"}
| |||||||||||||||||||||||||||||||||||||||||||
| 233 | |||||||||||||||||||||||||||||||||||||||||||
| 234 | 0 | ▶ | return sub ( $sv ) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=14 SCAR=53.5
| |||||||||||||||||||||||||||||||||||||||||||
| 235 | 0 | ▶ | return unless $sv->type eq "SCALAR"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 236 | |||||||||||||||||||||||||||||||||||||||||||
| 237 | 0 | ▶ | if( $opts{nv} and defined( my $nv = $sv->nv ) ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$opts{"nv"} and defined(my $nv = $sv->nv)
MC/DC0%0/2
$opts{"nv"} and defined(my $nv = $sv->nv)
$opts{"nv"}
defined(my $nv = $sv->nv)
Truth table0%0/3
A and B
A= $opts{"nv"}B= defined(my $nv = $sv->nv)
| |||||||||||||||||||||||||||||||||||||||||||
| 238 | 0 | ▶ | defined $value and $nv != $value and return; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $value and $nv != $value
MC/DC0%0/2
defined $value and $nv != $value
defined $value
$nv != $value
Truth table0%0/3
A and B
A= defined $valueB= $nv != $value
| |||||||||||||||||||||||||||||||||||||||||||
| 239 | 0 | return Devel::MAT::Cmd->format_value( $nv, nv => 1 ); | |||||||||||||||||||||||||||||||||||||||||
| 240 | } | ||||||||||||||||||||||||||||||||||||||||||
| 241 | |||||||||||||||||||||||||||||||||||||||||||
| 242 | 0 | ▶ | if( $opts{iv} and defined( my $iv = $sv->iv ) ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$opts{"iv"} and defined(my $iv = $sv->iv)
MC/DC0%0/2
$opts{"iv"} and defined(my $iv = $sv->iv)
$opts{"iv"}
defined(my $iv = $sv->iv)
Truth table0%0/3
A and B
A= $opts{"iv"}B= defined(my $iv = $sv->iv)
| |||||||||||||||||||||||||||||||||||||||||||
| 243 | 0 | ▶ | defined $value and $iv != $value and return; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $value and $iv != $value
MC/DC0%0/2
defined $value and $iv != $value
defined $value
$iv != $value
Truth table0%0/3
A and B
A= defined $valueB= $iv != $value
| |||||||||||||||||||||||||||||||||||||||||||
| 244 | 0 | return Devel::MAT::Cmd->format_value( $iv, iv => 1 ); | |||||||||||||||||||||||||||||||||||||||||
| 245 | } | ||||||||||||||||||||||||||||||||||||||||||
| 246 | |||||||||||||||||||||||||||||||||||||||||||
| 247 | 0 | ▶ | if( $opts{uv} and defined( my $uv = $sv->uv ) ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$opts{"uv"} and defined(my $uv = $sv->uv)
MC/DC0%0/2
$opts{"uv"} and defined(my $uv = $sv->uv)
$opts{"uv"}
defined(my $uv = $sv->uv)
Truth table0%0/3
A and B
A= $opts{"uv"}B= defined(my $uv = $sv->uv)
| |||||||||||||||||||||||||||||||||||||||||||
| 248 | 0 | ▶ | defined $value and $uv != $value and return; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $value and $uv != $value
MC/DC0%0/2
defined $value and $uv != $value
defined $value
$uv != $value
Truth table0%0/3
A and B
A= defined $valueB= $uv != $value
| |||||||||||||||||||||||||||||||||||||||||||
| 249 | 0 | return Devel::MAT::Cmd->format_value( $uv, uv => 1 ); | |||||||||||||||||||||||||||||||||||||||||
| 250 | } | ||||||||||||||||||||||||||||||||||||||||||
| 251 | 0 | }; | |||||||||||||||||||||||||||||||||||||||||
| 252 | } | ||||||||||||||||||||||||||||||||||||||||||
| 253 | |||||||||||||||||||||||||||||||||||||||||||
| 254 | package # hide | ||||||||||||||||||||||||||||||||||||||||||
| 255 | Devel::MAT::Tool::Find::filter::pv; | ||||||||||||||||||||||||||||||||||||||||||
| 256 | 5 | ▶ | use base qw( Devel::MAT::Tool::Find::filter ); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 257 | |||||||||||||||||||||||||||||||||||||||||||
| 258 | 5 | ▶ | use constant FILTER_DESC => "PV (string) SVs"; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 259 | |||||||||||||||||||||||||||||||||||||||||||
| 260 | 5 | ▶ | use constant FILTER_OPTS => ( | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 261 | eq => { help => "Pattern is an exact equality match" }, | ||||||||||||||||||||||||||||||||||||||||||
| 262 | regexp => { help => "Pattern is a regular expression", | ||||||||||||||||||||||||||||||||||||||||||
| 263 | alias => "r" }, | ||||||||||||||||||||||||||||||||||||||||||
| 264 | ignorecase => { help => "Match case-insensitively", | ||||||||||||||||||||||||||||||||||||||||||
| 265 | alias => "i" }, | ||||||||||||||||||||||||||||||||||||||||||
| 266 | 5 | ); | |||||||||||||||||||||||||||||||||||||||||
| 267 | |||||||||||||||||||||||||||||||||||||||||||
| 268 | 5 | ▶ | use constant FILTER_ARGS => ( | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 269 | { name => "pattern", help => "string pattern", required => 1 }, | ||||||||||||||||||||||||||||||||||||||||||
| 270 | 5 | ); | |||||||||||||||||||||||||||||||||||||||||
| 271 | |||||||||||||||||||||||||||||||||||||||||||
| 272 | =head2 pv | ||||||||||||||||||||||||||||||||||||||||||
| 273 | |||||||||||||||||||||||||||||||||||||||||||
| 274 | pmat> find pv "boot" | ||||||||||||||||||||||||||||||||||||||||||
| 275 | SCALAR(PV) at 0x556e4737d968: "boot_Devel::MAT::Dumper" | ||||||||||||||||||||||||||||||||||||||||||
| 276 | SCALAR(PV) at 0x556e4733a160: "boot_Cwd" | ||||||||||||||||||||||||||||||||||||||||||
| 277 | ... | ||||||||||||||||||||||||||||||||||||||||||
| 278 | |||||||||||||||||||||||||||||||||||||||||||
| 279 | Prints a list of all the scalar SVs that have a PV (string value) matching the | ||||||||||||||||||||||||||||||||||||||||||
| 280 | supplied pattern. Normally, the pattern is interpreted as a substring match, | ||||||||||||||||||||||||||||||||||||||||||
| 281 | but the C<--eq> and C<--regexp> options can alter this. | ||||||||||||||||||||||||||||||||||||||||||
| 282 | |||||||||||||||||||||||||||||||||||||||||||
| 283 | Takes the following named options: | ||||||||||||||||||||||||||||||||||||||||||
| 284 | |||||||||||||||||||||||||||||||||||||||||||
| 285 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||
| 286 | |||||||||||||||||||||||||||||||||||||||||||
| 287 | =item --eq | ||||||||||||||||||||||||||||||||||||||||||
| 288 | |||||||||||||||||||||||||||||||||||||||||||
| 289 | Interpret the pattern as a full string equality match, instead of substring. | ||||||||||||||||||||||||||||||||||||||||||
| 290 | |||||||||||||||||||||||||||||||||||||||||||
| 291 | =item --regexp, -r | ||||||||||||||||||||||||||||||||||||||||||
| 292 | |||||||||||||||||||||||||||||||||||||||||||
| 293 | Interpret the pattern as a regular expression, instead of a literal substring. | ||||||||||||||||||||||||||||||||||||||||||
| 294 | |||||||||||||||||||||||||||||||||||||||||||
| 295 | =item --ignorecase, -i | ||||||||||||||||||||||||||||||||||||||||||
| 296 | |||||||||||||||||||||||||||||||||||||||||||
| 297 | Match case-insensitively, for any of substring, equality or regexp match. | ||||||||||||||||||||||||||||||||||||||||||
| 298 | |||||||||||||||||||||||||||||||||||||||||||
| 299 | =back | ||||||||||||||||||||||||||||||||||||||||||
| 300 | |||||||||||||||||||||||||||||||||||||||||||
| 301 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 302 | |||||||||||||||||||||||||||||||||||||||||||
| 303 | 0 | ▶ | sub build ( $self, $inv, $optsref, $pattern ) | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
build: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||||||||||||||||
| 304 | { | ||||||||||||||||||||||||||||||||||||||||||
| 305 | 0 | my %opts = $optsref->%*; | |||||||||||||||||||||||||||||||||||||||||
| 306 | |||||||||||||||||||||||||||||||||||||||||||
| 307 | 0 | ▶ | my $flags = $opts{ignorecase} ? "i" : ""; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 308 | |||||||||||||||||||||||||||||||||||||||||||
| 309 | 0 | ▶ | if( $opts{eq} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 310 | 0 | $pattern = qr/(?$flags)^\Q$pattern\E$/; | |||||||||||||||||||||||||||||||||||||||||
| 311 | } | ||||||||||||||||||||||||||||||||||||||||||
| 312 | elsif( $opts{regexp} ) { | ||||||||||||||||||||||||||||||||||||||||||
| 313 | 0 | $pattern = qr/(?$flags)$pattern/; | |||||||||||||||||||||||||||||||||||||||||
| 314 | } | ||||||||||||||||||||||||||||||||||||||||||
| 315 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 316 | # substring | ||||||||||||||||||||||||||||||||||||||||||
| 317 | 0 | $pattern = qr/(?$flags)\Q$pattern\E/; | |||||||||||||||||||||||||||||||||||||||||
| 318 | } | ||||||||||||||||||||||||||||||||||||||||||
| 319 | |||||||||||||||||||||||||||||||||||||||||||
| 320 | 0 | ▶ | return sub ( $sv ) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||||||||||||||||
| 321 | 0 | ▶ | return unless $sv->type eq "SCALAR"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 322 | 0 | ▶ | return unless defined( my $pv = $sv->pv ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 323 | 0 | ▶ | return unless $pv =~ $pattern; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 324 | |||||||||||||||||||||||||||||||||||||||||||
| 325 | 0 | return Devel::MAT::Cmd->format_value( $pv, pv => 1 ); | |||||||||||||||||||||||||||||||||||||||||
| 326 | 0 | }; | |||||||||||||||||||||||||||||||||||||||||
| 327 | } | ||||||||||||||||||||||||||||||||||||||||||
| 328 | |||||||||||||||||||||||||||||||||||||||||||
| 329 | package # hide | ||||||||||||||||||||||||||||||||||||||||||
| 330 | Devel::MAT::Tool::Find::filter::cv; | ||||||||||||||||||||||||||||||||||||||||||
| 331 | 5 | ▶ | use base qw( Devel::MAT::Tool::Find::filter ); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 332 | |||||||||||||||||||||||||||||||||||||||||||
| 333 | 5 | ▶ | use constant FILTER_DESC => "Code CVs"; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 334 | |||||||||||||||||||||||||||||||||||||||||||
| 335 | 5 | ▶ | use constant FILTER_OPTS => ( | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 336 | xsub => { help => "Is an XSUB" }, | ||||||||||||||||||||||||||||||||||||||||||
| 337 | package => { help => "In the given package", | ||||||||||||||||||||||||||||||||||||||||||
| 338 | type => "s", | ||||||||||||||||||||||||||||||||||||||||||
| 339 | alias => "p" }, | ||||||||||||||||||||||||||||||||||||||||||
| 340 | file => { help => "Location is the given file", | ||||||||||||||||||||||||||||||||||||||||||
| 341 | type => "s", | ||||||||||||||||||||||||||||||||||||||||||
| 342 | alias => "f" }, | ||||||||||||||||||||||||||||||||||||||||||
| 343 | 5 | ); | |||||||||||||||||||||||||||||||||||||||||
| 344 | |||||||||||||||||||||||||||||||||||||||||||
| 345 | 0 | ▶ | sub build ( $self, $inv, $optsref ) | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
build: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 346 | { | ||||||||||||||||||||||||||||||||||||||||||
| 347 | 0 | my %opts = $optsref->%*; | |||||||||||||||||||||||||||||||||||||||||
| 348 | |||||||||||||||||||||||||||||||||||||||||||
| 349 | 0 | ▶ | return sub ( $sv ) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=10 SCAR=47.0
| |||||||||||||||||||||||||||||||||||||||||||
| 350 | 0 | ▶ | return unless $sv->type eq "CODE"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 351 | 0 | ▶ | if( $opts{xsub} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 352 | 0 | ▶ | return if !$sv->is_xsub; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 353 | } | ||||||||||||||||||||||||||||||||||||||||||
| 354 | 0 | ▶ | if( $opts{package} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 355 | 0 | ▶ | my $stash = $sv->glob ? $sv->glob->stash : return; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 356 | 0 | ▶ | return if $stash->stashname ne $opts{package}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 357 | } | ||||||||||||||||||||||||||||||||||||||||||
| 358 | 0 | ▶ | if( $opts{file} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 359 | 0 | ▶ | return if $sv->file ne $opts{file}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 360 | } | ||||||||||||||||||||||||||||||||||||||||||
| 361 | |||||||||||||||||||||||||||||||||||||||||||
| 362 | # Selected | ||||||||||||||||||||||||||||||||||||||||||
| 363 | 0 | ▶ | if( my $symname = $sv->symname ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 364 | 0 | return Devel::MAT::Cmd->format_symbol( $symname ); | |||||||||||||||||||||||||||||||||||||||||
| 365 | } | ||||||||||||||||||||||||||||||||||||||||||
| 366 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 367 | 0 | return "__ANON__"; | |||||||||||||||||||||||||||||||||||||||||
| 368 | } | ||||||||||||||||||||||||||||||||||||||||||
| 369 | 0 | }; | |||||||||||||||||||||||||||||||||||||||||
| 370 | } | ||||||||||||||||||||||||||||||||||||||||||
| 371 | |||||||||||||||||||||||||||||||||||||||||||
| 372 | package # hide | ||||||||||||||||||||||||||||||||||||||||||
| 373 | Devel::MAT::Tool::Find::filter::io; | ||||||||||||||||||||||||||||||||||||||||||
| 374 | 5 | ▶ | use base qw( Devel::MAT::Tool::Find::filter ); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 375 | |||||||||||||||||||||||||||||||||||||||||||
| 376 | 5 | ▶ | use constant FILTER_DESC => "IO SVs"; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 377 | |||||||||||||||||||||||||||||||||||||||||||
| 378 | 5 | ▶ | use constant FILTER_OPTS => ( | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 379 | fileno => { help => "Match only this filenumber", | ||||||||||||||||||||||||||||||||||||||||||
| 380 | type => "i", | ||||||||||||||||||||||||||||||||||||||||||
| 381 | alias => "f" }, | ||||||||||||||||||||||||||||||||||||||||||
| 382 | 5 | ); | |||||||||||||||||||||||||||||||||||||||||
| 383 | |||||||||||||||||||||||||||||||||||||||||||
| 384 | =head2 io | ||||||||||||||||||||||||||||||||||||||||||
| 385 | |||||||||||||||||||||||||||||||||||||||||||
| 386 | pmat> find io | ||||||||||||||||||||||||||||||||||||||||||
| 387 | IO()=IO::File at 0x55a7e4d88760: ifileno=1 ofileno=1 | ||||||||||||||||||||||||||||||||||||||||||
| 388 | ... | ||||||||||||||||||||||||||||||||||||||||||
| 389 | |||||||||||||||||||||||||||||||||||||||||||
| 390 | pmat> find io -f 2 | ||||||||||||||||||||||||||||||||||||||||||
| 391 | IO()=IO::File at 0x55582b87f430: ifileno=2 ofileno=2 | ||||||||||||||||||||||||||||||||||||||||||
| 392 | |||||||||||||||||||||||||||||||||||||||||||
| 393 | Searches for IO handles | ||||||||||||||||||||||||||||||||||||||||||
| 394 | |||||||||||||||||||||||||||||||||||||||||||
| 395 | Takes the following named options: | ||||||||||||||||||||||||||||||||||||||||||
| 396 | |||||||||||||||||||||||||||||||||||||||||||
| 397 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||
| 398 | |||||||||||||||||||||||||||||||||||||||||||
| 399 | =item --fileno, -f INT | ||||||||||||||||||||||||||||||||||||||||||
| 400 | |||||||||||||||||||||||||||||||||||||||||||
| 401 | Match only IO handles associated with the given filenumber. | ||||||||||||||||||||||||||||||||||||||||||
| 402 | |||||||||||||||||||||||||||||||||||||||||||
| 403 | =back | ||||||||||||||||||||||||||||||||||||||||||
| 404 | |||||||||||||||||||||||||||||||||||||||||||
| 405 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 406 | |||||||||||||||||||||||||||||||||||||||||||
| 407 | 0 | ▶ | sub build ( $self, $inv, $optsref ) | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
build: not called CC=5 SCAR=34.0
| |||||||||||||||||||||||||||||||||||||||||||
| 408 | { | ||||||||||||||||||||||||||||||||||||||||||
| 409 | 0 | my %opts = $optsref->%*; | |||||||||||||||||||||||||||||||||||||||||
| 410 | |||||||||||||||||||||||||||||||||||||||||||
| 411 | # Back-compat | ||||||||||||||||||||||||||||||||||||||||||
| 412 | 0 | ▶ | if( !defined $opts{fileno} and ( $inv->peek_token // "" ) =~ m/^\d+$/ ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/5
not defined $opts{"fileno"} and ($inv->peek_token // "") =~ /^\d+$/u
$inv->peek_token // ""
MC/DC0%0/2
not defined $opts{"fileno"} and ($inv->peek_token // "") =~ /^\d+$/u
not defined $opts{"fileno"}
$inv->peek_token
Truth table0%0/3
not(A) and B
A= not defined $opts{"fileno"}B= $inv->peek_token
| |||||||||||||||||||||||||||||||||||||||||||
| 413 | 0 | $opts{fileno} = $inv->pull_token; | |||||||||||||||||||||||||||||||||||||||||
| 414 | } | ||||||||||||||||||||||||||||||||||||||||||
| 415 | |||||||||||||||||||||||||||||||||||||||||||
| 416 | 0 | ▶ | if( defined( my $fileno = $opts{fileno} ) ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 417 | 0 | ▶ | return sub ( $sv ) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=6 SCAR=37.4
| |||||||||||||||||||||||||||||||||||||||||||
| 418 | 0 | ▶ | return unless $sv->type eq "IO"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 419 | |||||||||||||||||||||||||||||||||||||||||||
| 420 | 0 | my $imatch = $sv->ifileno == $fileno; | |||||||||||||||||||||||||||||||||||||||||
| 421 | 0 | my $omatch = $sv->ofileno == $fileno; | |||||||||||||||||||||||||||||||||||||||||
| 422 | 0 | ▶ | return unless $imatch or $omatch; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$imatch or $omatch
MC/DC0%0/2
$imatch or $omatch
$imatch
$omatch
Truth table0%0/3
A or B
A= $imatchB= $omatch
| |||||||||||||||||||||||||||||||||||||||||||
| 423 | |||||||||||||||||||||||||||||||||||||||||||
| 424 | 0 | ▶ | return String::Tagged->from_sprintf( "ifileno=%s ofileno=%s", | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 425 | $imatch ? Devel::MAT::Cmd->format_note( $sv->ifileno ) : $sv->ifileno, | ||||||||||||||||||||||||||||||||||||||||||
| 426 | $omatch ? Devel::MAT::Cmd->format_note( $sv->ofileno ) : $sv->ofileno, | ||||||||||||||||||||||||||||||||||||||||||
| 427 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 428 | } | ||||||||||||||||||||||||||||||||||||||||||
| 429 | 0 | } | |||||||||||||||||||||||||||||||||||||||||
| 430 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 431 | 0 | ▶ | return sub ( $sv ) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||
| 432 | 0 | ▶ | return unless $sv->type eq "IO"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 433 | 0 | return String::Tagged->from_sprintf( "ifileno=%s ofileno=%s", | |||||||||||||||||||||||||||||||||||||||||
| 434 | $sv->ifileno, | ||||||||||||||||||||||||||||||||||||||||||
| 435 | $sv->ofileno, | ||||||||||||||||||||||||||||||||||||||||||
| 436 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 437 | } | ||||||||||||||||||||||||||||||||||||||||||
| 438 | 0 | } | |||||||||||||||||||||||||||||||||||||||||
| 439 | } | ||||||||||||||||||||||||||||||||||||||||||
| 440 | |||||||||||||||||||||||||||||||||||||||||||
| 441 | package # hide | ||||||||||||||||||||||||||||||||||||||||||
| 442 | Devel::MAT::Tool::Find::filter::blessed; | ||||||||||||||||||||||||||||||||||||||||||
| 443 | 5 | ▶ | use base qw( Devel::MAT::Tool::Find::filter ); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 444 | |||||||||||||||||||||||||||||||||||||||||||
| 445 | =head2 blessed | ||||||||||||||||||||||||||||||||||||||||||
| 446 | |||||||||||||||||||||||||||||||||||||||||||
| 447 | pmat> find blessed Config | ||||||||||||||||||||||||||||||||||||||||||
| 448 | HASH(26)=Config at 0x55bd56c28930 | ||||||||||||||||||||||||||||||||||||||||||
| 449 | |||||||||||||||||||||||||||||||||||||||||||
| 450 | Searches for SVs blessed into the given package name. | ||||||||||||||||||||||||||||||||||||||||||
| 451 | |||||||||||||||||||||||||||||||||||||||||||
| 452 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 453 | |||||||||||||||||||||||||||||||||||||||||||
| 454 | 5 | ▶ | use constant FILTER_DESC => "blessed SVs"; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 455 | |||||||||||||||||||||||||||||||||||||||||||
| 456 | 5 | ▶ | use constant FILTER_ARGS => ( | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 457 | { name => "package", help => "the blessed package", required => 1 }, | ||||||||||||||||||||||||||||||||||||||||||
| 458 | 5 | ); | |||||||||||||||||||||||||||||||||||||||||
| 459 | |||||||||||||||||||||||||||||||||||||||||||
| 460 | 0 | ▶ | sub build ( $self, $inv, $package = undef ) | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
build: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||
| 461 | 0 | { | |||||||||||||||||||||||||||||||||||||||||
| 462 | 0 | ▶ | defined $package or | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 463 | die "Expected package name for 'blessed' filter"; | ||||||||||||||||||||||||||||||||||||||||||
| 464 | |||||||||||||||||||||||||||||||||||||||||||
| 465 | 0 | ▶ | return sub ( $sv ) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||
| 466 | 0 | ▶ | return unless my $stash = $sv->blessed; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 467 | 0 | ▶ | return unless $stash->stashname eq $package; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 468 | 0 | return Devel::MAT::Cmd->format_value( $stash->stashname ); | |||||||||||||||||||||||||||||||||||||||||
| 469 | 0 | }; | |||||||||||||||||||||||||||||||||||||||||
| 470 | } | ||||||||||||||||||||||||||||||||||||||||||
| 471 | |||||||||||||||||||||||||||||||||||||||||||
| 472 | package # hide | ||||||||||||||||||||||||||||||||||||||||||
| 473 | Devel::MAT::Tool::Find::filter::lexical; | ||||||||||||||||||||||||||||||||||||||||||
| 474 | 5 | ▶ | use base qw( Devel::MAT::Tool::Find::filter ); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 475 | |||||||||||||||||||||||||||||||||||||||||||
| 476 | =head2 lexical | ||||||||||||||||||||||||||||||||||||||||||
| 477 | |||||||||||||||||||||||||||||||||||||||||||
| 478 | pmat> find lexical $x | ||||||||||||||||||||||||||||||||||||||||||
| 479 | UNDEF() at 0x56426e97c8b0: $x at depth 1 of CODE(PP) at 0x56426e97c5e0 | ||||||||||||||||||||||||||||||||||||||||||
| 480 | ... | ||||||||||||||||||||||||||||||||||||||||||
| 481 | |||||||||||||||||||||||||||||||||||||||||||
| 482 | Searches for SVs that are lexical variables of the given name. | ||||||||||||||||||||||||||||||||||||||||||
| 483 | |||||||||||||||||||||||||||||||||||||||||||
| 484 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 485 | |||||||||||||||||||||||||||||||||||||||||||
| 486 | 5 | ▶ | use constant FILTER_DESC => "lexical variables"; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 487 | |||||||||||||||||||||||||||||||||||||||||||
| 488 | 5 | ▶ | use constant FILTER_ARGS => ( | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 489 | { name => "name", help => "the variable name", required => 1 }, | ||||||||||||||||||||||||||||||||||||||||||
| 490 | 5 | ); | |||||||||||||||||||||||||||||||||||||||||
| 491 | |||||||||||||||||||||||||||||||||||||||||||
| 492 | 5 | ▶ | use constant FILTER_OPTS => ( | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 493 | inactive => { help => "Include variables in non-live pads", | ||||||||||||||||||||||||||||||||||||||||||
| 494 | alias => "I" }, | ||||||||||||||||||||||||||||||||||||||||||
| 495 | 5 | ); | |||||||||||||||||||||||||||||||||||||||||
| 496 | |||||||||||||||||||||||||||||||||||||||||||
| 497 | 0 | ▶ | sub build ( $self, $inv, $optsref, $name = undef ) | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
build: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||
| 498 | 0 | { | |||||||||||||||||||||||||||||||||||||||||
| 499 | 0 | my %opts = $optsref->%*; | |||||||||||||||||||||||||||||||||||||||||
| 500 | |||||||||||||||||||||||||||||||||||||||||||
| 501 | 0 | ▶ | defined $name or | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 502 | die "Expected variable name for 'lexical' filter"; | ||||||||||||||||||||||||||||||||||||||||||
| 503 | |||||||||||||||||||||||||||||||||||||||||||
| 504 | # We'll actually match pad which contains such a lexical. then redirect the | ||||||||||||||||||||||||||||||||||||||||||
| 505 | # search onto the SV itself | ||||||||||||||||||||||||||||||||||||||||||
| 506 | 0 | ▶ | return sub ( $pad ) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=9 SCAR=45.0
| |||||||||||||||||||||||||||||||||||||||||||
| 507 | 0 | ▶ | return unless $pad->type eq "PAD"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 508 | 0 | ▶ | return unless my $sv = $pad->maybe_lexvar( $name ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 509 | |||||||||||||||||||||||||||||||||||||||||||
| 510 | 0 | my $cv = $pad->padcv; | |||||||||||||||||||||||||||||||||||||||||
| 511 | |||||||||||||||||||||||||||||||||||||||||||
| 512 | 0 | my $depth; | |||||||||||||||||||||||||||||||||||||||||
| 513 | 0 | my @pads = $cv->pads; | |||||||||||||||||||||||||||||||||||||||||
| 514 | $pad == $pads[$_] and $depth = $_+1 and last | ||||||||||||||||||||||||||||||||||||||||||
| 515 | 0 | ▶ | for 0 .. $#pads; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$pad == $pads[$_] and $depth = $_ + 1
MC/DC0%0/2
$pad == $pads[$_] and $depth = $_ + 1
$pad == $pads[$_]
$depth = $_ + 1
Truth table0%0/3
A and B
A= $pad == $pads[$_]B= $depth = $_ + 1
| |||||||||||||||||||||||||||||||||||||||||||
| 516 | |||||||||||||||||||||||||||||||||||||||||||
| 517 | # This isn't a real hit unless the pad is live | ||||||||||||||||||||||||||||||||||||||||||
| 518 | 0 | my $is_live = $depth <= $cv->depth; | |||||||||||||||||||||||||||||||||||||||||
| 519 | 0 | ▶ | return unless $is_live || $opts{inactive}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$is_live or $opts{"inactive"}
MC/DC0%0/2
$is_live or $opts{"inactive"}
$is_live
$opts{"inactive"}
Truth table0%0/3
A or B
A= $is_liveB= $opts{"inactive"}
| |||||||||||||||||||||||||||||||||||||||||||
| 520 | |||||||||||||||||||||||||||||||||||||||||||
| 521 | return { | ||||||||||||||||||||||||||||||||||||||||||
| 522 | 0 | ▶ | sv => $sv, | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 523 | output => String::Tagged->from_sprintf( "%s at depth %d%s of %s", | ||||||||||||||||||||||||||||||||||||||||||
| 524 | Devel::MAT::Cmd->format_note( $name, 1 ), | ||||||||||||||||||||||||||||||||||||||||||
| 525 | $depth, $is_live ? "" : Devel::MAT::Cmd->format_note( " [inactive]", 2 ), | ||||||||||||||||||||||||||||||||||||||||||
| 526 | Devel::MAT::Cmd->format_sv( $cv ) | ||||||||||||||||||||||||||||||||||||||||||
| 527 | ), | ||||||||||||||||||||||||||||||||||||||||||
| 528 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 529 | 0 | }; | |||||||||||||||||||||||||||||||||||||||||
| 530 | } | ||||||||||||||||||||||||||||||||||||||||||
| 531 | |||||||||||||||||||||||||||||||||||||||||||
| 532 | package # hide | ||||||||||||||||||||||||||||||||||||||||||
| 533 | Devel::MAT::Tool::Find::filter::struct; | ||||||||||||||||||||||||||||||||||||||||||
| 534 | 5 | ▶ | use base qw( Devel::MAT::Tool::Find::filter ); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 535 | |||||||||||||||||||||||||||||||||||||||||||
| 536 | =head2 struct | ||||||||||||||||||||||||||||||||||||||||||
| 537 | |||||||||||||||||||||||||||||||||||||||||||
| 538 | pmat> find struct Module::Name/Type | ||||||||||||||||||||||||||||||||||||||||||
| 539 | C_STRUCT(Module::Name/Type) at 0x55e0c3017bf0: Module::Name/Type | ||||||||||||||||||||||||||||||||||||||||||
| 540 | ... | ||||||||||||||||||||||||||||||||||||||||||
| 541 | |||||||||||||||||||||||||||||||||||||||||||
| 542 | Searches for SVs that are C structures of the given type name. | ||||||||||||||||||||||||||||||||||||||||||
| 543 | |||||||||||||||||||||||||||||||||||||||||||
| 544 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 545 | |||||||||||||||||||||||||||||||||||||||||||
| 546 | 5 | ▶ | use constant FILTER_DESC => "structs"; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 547 | |||||||||||||||||||||||||||||||||||||||||||
| 548 | 5 | ▶ | use constant FILTER_ARGS => ( | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 549 | { name => "name", help => "the structure type name", required => 1 }, | ||||||||||||||||||||||||||||||||||||||||||
| 550 | 5 | ); | |||||||||||||||||||||||||||||||||||||||||
| 551 | |||||||||||||||||||||||||||||||||||||||||||
| 552 | 0 | ▶ | sub build ( $self, $inv, $name = undef ) | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
build: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||
| 553 | 0 | { | |||||||||||||||||||||||||||||||||||||||||
| 554 | 0 | ▶ | defined $name or | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 555 | die "Expected structure type name for 'struct' filter"; | ||||||||||||||||||||||||||||||||||||||||||
| 556 | |||||||||||||||||||||||||||||||||||||||||||
| 557 | 0 | ▶ | return sub ( $struct ) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||
| 558 | 0 | ▶ | return unless $struct->type eq "C_STRUCT"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 559 | 0 | my $type = $struct->structtype; | |||||||||||||||||||||||||||||||||||||||||
| 560 | 0 | ▶ | return unless $type->name eq $name; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 561 | |||||||||||||||||||||||||||||||||||||||||||
| 562 | 0 | return Devel::MAT::Cmd->format_value( $type->name ); | |||||||||||||||||||||||||||||||||||||||||
| 563 | 0 | }; | |||||||||||||||||||||||||||||||||||||||||
| 564 | } | ||||||||||||||||||||||||||||||||||||||||||
| 565 | |||||||||||||||||||||||||||||||||||||||||||
| 566 | package # hide | ||||||||||||||||||||||||||||||||||||||||||
| 567 | Devel::MAT::Tool::Find::filter::magic; | ||||||||||||||||||||||||||||||||||||||||||
| 568 | 5 | ▶ | use base qw( Devel::MAT::Tool::Find::filter ); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 569 | |||||||||||||||||||||||||||||||||||||||||||
| 570 | =head2 magic | ||||||||||||||||||||||||||||||||||||||||||
| 571 | |||||||||||||||||||||||||||||||||||||||||||
| 572 | pmat> find magic --vtbl 0x7fa73f5421c0 | ||||||||||||||||||||||||||||||||||||||||||
| 573 | SCALAR(UV) at 0x5632acbddc50: magic type '^', with object ARRAY(1) at 0x5632acbd2f88 | ||||||||||||||||||||||||||||||||||||||||||
| 574 | ... | ||||||||||||||||||||||||||||||||||||||||||
| 575 | |||||||||||||||||||||||||||||||||||||||||||
| 576 | Searches for SVs that have magic that uses the given MGVTBL address. | ||||||||||||||||||||||||||||||||||||||||||
| 577 | |||||||||||||||||||||||||||||||||||||||||||
| 578 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||
| 579 | |||||||||||||||||||||||||||||||||||||||||||
| 580 | =item --vtbl, -v ADDR | ||||||||||||||||||||||||||||||||||||||||||
| 581 | |||||||||||||||||||||||||||||||||||||||||||
| 582 | Address of the required MGVTBL | ||||||||||||||||||||||||||||||||||||||||||
| 583 | |||||||||||||||||||||||||||||||||||||||||||
| 584 | =back | ||||||||||||||||||||||||||||||||||||||||||
| 585 | |||||||||||||||||||||||||||||||||||||||||||
| 586 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 587 | |||||||||||||||||||||||||||||||||||||||||||
| 588 | 5 | ▶ | use constant FILTER_DESC => "SVs with magic"; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 589 | |||||||||||||||||||||||||||||||||||||||||||
| 590 | 5 | ▶ | use constant FILTER_OPTS => ( | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 591 | vtbl => { help => "the VTBL pointer", | ||||||||||||||||||||||||||||||||||||||||||
| 592 | type => "x", | ||||||||||||||||||||||||||||||||||||||||||
| 593 | alias => "v" }, | ||||||||||||||||||||||||||||||||||||||||||
| 594 | 5 | ); | |||||||||||||||||||||||||||||||||||||||||
| 595 | |||||||||||||||||||||||||||||||||||||||||||
| 596 | 0 | ▶ | sub build ( $self, $inv, $optsref ) | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
build: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||
| 597 | { | ||||||||||||||||||||||||||||||||||||||||||
| 598 | 0 | my %opts = $optsref->%*; | |||||||||||||||||||||||||||||||||||||||||
| 599 | |||||||||||||||||||||||||||||||||||||||||||
| 600 | 0 | ▶ | if( my $vtbl = $opts{vtbl} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 601 | 0 | ▶ | return sub ( $sv ) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=8 SCAR=42.8
| |||||||||||||||||||||||||||||||||||||||||||
| 602 | 0 | ▶ | my @magics = $sv->magic or return; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 603 | 0 | foreach my $magic ( @magics ) { | |||||||||||||||||||||||||||||||||||||||||
| 604 | 0 | ▶ | next unless $magic->ver == 1 and | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
$magic->ver == 1 and defined $magic->vtbl and $magic->vtbl == $vtbl
$magic->ver == 1 and defined $magic->vtbl
MC/DC0%0/3
$magic->ver == 1 and defined $magic->vtbl and $magic->vtbl == $vtbl
$magic->ver == 1
defined $magic->vtbl
$magic->vtbl == $vtbl
Truth table0%0/4
A and B and C
A= $magic->ver == 1B= defined $magic->vtblC= $magic->vtbl == $vtbl
| |||||||||||||||||||||||||||||||||||||||||||
| 605 | defined $magic->vtbl and | ||||||||||||||||||||||||||||||||||||||||||
| 606 | $magic->vtbl == $vtbl; | ||||||||||||||||||||||||||||||||||||||||||
| 607 | |||||||||||||||||||||||||||||||||||||||||||
| 608 | 0 | my $ret = String::Tagged->from_sprintf( "magic type '%s'", | |||||||||||||||||||||||||||||||||||||||||
| 609 | $magic->type, | ||||||||||||||||||||||||||||||||||||||||||
| 610 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 611 | |||||||||||||||||||||||||||||||||||||||||||
| 612 | 0 | ▶ | $ret .= ", with object " . Devel::MAT::Cmd->format_sv( $magic->obj ) if $magic->obj; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 613 | |||||||||||||||||||||||||||||||||||||||||||
| 614 | 0 | ▶ | $ret .= ", with pointer " . Devel::MAT::Cmd->format_sv( $magic->ptr ) if $magic->ptr; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 615 | |||||||||||||||||||||||||||||||||||||||||||
| 616 | 0 | return $ret; | |||||||||||||||||||||||||||||||||||||||||
| 617 | } | ||||||||||||||||||||||||||||||||||||||||||
| 618 | 0 | }; | |||||||||||||||||||||||||||||||||||||||||
| 619 | } | ||||||||||||||||||||||||||||||||||||||||||
| 620 | |||||||||||||||||||||||||||||||||||||||||||
| 621 | 0 | die "Expected --vtbl\n"; | |||||||||||||||||||||||||||||||||||||||||
| 622 | } | ||||||||||||||||||||||||||||||||||||||||||
| 623 | |||||||||||||||||||||||||||||||||||||||||||
| 624 | package # hide | ||||||||||||||||||||||||||||||||||||||||||
| 625 | Devel::MAT::Tool::Find::filter::magicv2; | ||||||||||||||||||||||||||||||||||||||||||
| 626 | 5 | ▶ | use base qw( Devel::MAT::Tool::Find::filter ); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 627 | |||||||||||||||||||||||||||||||||||||||||||
| 628 | =head2 magicv2 | ||||||||||||||||||||||||||||||||||||||||||
| 629 | |||||||||||||||||||||||||||||||||||||||||||
| 630 | pmat> find magicv2 --funcs 0x562c1d39bc20 | ||||||||||||||||||||||||||||||||||||||||||
| 631 | SCALAR(PV) at 0x562c1fce1070: MagicV2 funcs 0x562c1d39bc20 | ||||||||||||||||||||||||||||||||||||||||||
| 632 | ... | ||||||||||||||||||||||||||||||||||||||||||
| 633 | |||||||||||||||||||||||||||||||||||||||||||
| 634 | Searches for SVs that have Magic v2 attachments, optionally limited to those | ||||||||||||||||||||||||||||||||||||||||||
| 635 | which use the given MagicFunctions structure or have the given C<MgAUXSV>. | ||||||||||||||||||||||||||||||||||||||||||
| 636 | |||||||||||||||||||||||||||||||||||||||||||
| 637 | Takes the following named options: | ||||||||||||||||||||||||||||||||||||||||||
| 638 | |||||||||||||||||||||||||||||||||||||||||||
| 639 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||
| 640 | |||||||||||||||||||||||||||||||||||||||||||
| 641 | =item --funcs, -f ADDR | ||||||||||||||||||||||||||||||||||||||||||
| 642 | |||||||||||||||||||||||||||||||||||||||||||
| 643 | Returns only attachments that use the given C<struct MagicFunctions> structure | ||||||||||||||||||||||||||||||||||||||||||
| 644 | address. | ||||||||||||||||||||||||||||||||||||||||||
| 645 | |||||||||||||||||||||||||||||||||||||||||||
| 646 | =item --auxsv, -A ADDR | ||||||||||||||||||||||||||||||||||||||||||
| 647 | |||||||||||||||||||||||||||||||||||||||||||
| 648 | Returns only attachments that have the given SV as the C<MgAUXSV>. | ||||||||||||||||||||||||||||||||||||||||||
| 649 | |||||||||||||||||||||||||||||||||||||||||||
| 650 | =back | ||||||||||||||||||||||||||||||||||||||||||
| 651 | |||||||||||||||||||||||||||||||||||||||||||
| 652 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 653 | |||||||||||||||||||||||||||||||||||||||||||
| 654 | 5 | ▶ | use constant FILTER_DESC => "SVs with MagicV2"; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 655 | |||||||||||||||||||||||||||||||||||||||||||
| 656 | 5 | ▶ | use constant FILTER_OPTS => ( | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 657 | funcs => { help => "the MgFUNCS pointer", | ||||||||||||||||||||||||||||||||||||||||||
| 658 | type => "x", | ||||||||||||||||||||||||||||||||||||||||||
| 659 | alias => "f" }, | ||||||||||||||||||||||||||||||||||||||||||
| 660 | auxsv => { help => "the MgAUXSV pointer", | ||||||||||||||||||||||||||||||||||||||||||
| 661 | type => "x", | ||||||||||||||||||||||||||||||||||||||||||
| 662 | alias => "A" }, | ||||||||||||||||||||||||||||||||||||||||||
| 663 | 5 | ); | |||||||||||||||||||||||||||||||||||||||||
| 664 | |||||||||||||||||||||||||||||||||||||||||||
| 665 | 0 | ▶ | sub build ( $self, $inv, $optsref ) | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
build: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 666 | { | ||||||||||||||||||||||||||||||||||||||||||
| 667 | 0 | my %opts = $optsref->%*; | |||||||||||||||||||||||||||||||||||||||||
| 668 | |||||||||||||||||||||||||||||||||||||||||||
| 669 | 0 | my $want_funcs = $optsref->{funcs}; | |||||||||||||||||||||||||||||||||||||||||
| 670 | 0 | my $want_auxsv = $optsref->{auxsv}; | |||||||||||||||||||||||||||||||||||||||||
| 671 | |||||||||||||||||||||||||||||||||||||||||||
| 672 | 0 | ▶ | return sub ( $sv ) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=10 SCAR=47.0
| |||||||||||||||||||||||||||||||||||||||||||
| 673 | 0 | ▶ | my @magics = $sv->magic or return; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 674 | 0 | foreach my $magic ( @magics ) { | |||||||||||||||||||||||||||||||||||||||||
| 675 | 0 | ▶ | next unless $magic->ver == 2; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 676 | |||||||||||||||||||||||||||||||||||||||||||
| 677 | 0 | ▶ | next if defined $want_funcs and | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $want_funcs and $magic->funcs != $want_funcs
MC/DC0%0/2
defined $want_funcs and $magic->funcs != $want_funcs
defined $want_funcs
$magic->funcs != $want_funcs
Truth table0%0/3
A and B
A= defined $want_funcsB= $magic->funcs != $want_funcs
| |||||||||||||||||||||||||||||||||||||||||||
| 678 | $magic->funcs != $want_funcs; | ||||||||||||||||||||||||||||||||||||||||||
| 679 | 0 | ▶ | next if defined $want_auxsv and | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
defined $want_auxsv and !defined($magic->auxsv) || $magic->auxsv != $want_auxsv
not defined $magic->auxsv or $magic->auxsv != $want_auxsv
MC/DC0%0/3
defined $want_auxsv and !defined($magic->auxsv) || $magic->auxsv != $want_auxsv
defined $want_auxsv
not defined $magic->auxsv
$magic->auxsv != $want_auxsv
Truth table0%0/4
A and not(B) or C
A= defined $want_auxsvB= not defined $magic->auxsvC= $magic->auxsv != $want_auxsv
| |||||||||||||||||||||||||||||||||||||||||||
| 680 | ( !defined $magic->auxsv or $magic->auxsv != $want_auxsv ); | ||||||||||||||||||||||||||||||||||||||||||
| 681 | |||||||||||||||||||||||||||||||||||||||||||
| 682 | 0 | my $ret = String::Tagged->from_sprintf( "MagicV2 funcs %s", | |||||||||||||||||||||||||||||||||||||||||
| 683 | Devel::MAT::Cmd->format_value( $magic->funcs, addr => 1 ), | ||||||||||||||||||||||||||||||||||||||||||
| 684 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 685 | |||||||||||||||||||||||||||||||||||||||||||
| 686 | 0 | ▶ | $ret .= ", with auxsv " . Devel::MAT::Cmd->format_sv( $magic->auxsv ) if $magic->auxsv; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 687 | |||||||||||||||||||||||||||||||||||||||||||
| 688 | 0 | return $ret; | |||||||||||||||||||||||||||||||||||||||||
| 689 | } | ||||||||||||||||||||||||||||||||||||||||||
| 690 | 0 | }; | |||||||||||||||||||||||||||||||||||||||||
| 691 | } | ||||||||||||||||||||||||||||||||||||||||||
| 692 | |||||||||||||||||||||||||||||||||||||||||||
| 693 | =head1 AUTHOR | ||||||||||||||||||||||||||||||||||||||||||
| 694 | |||||||||||||||||||||||||||||||||||||||||||
| 695 | Paul Evans <leonerd@leonerd.org.uk> | ||||||||||||||||||||||||||||||||||||||||||
| 696 | |||||||||||||||||||||||||||||||||||||||||||
| 697 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 698 | |||||||||||||||||||||||||||||||||||||||||||
| 699 | 5 | 0x55AA; | |||||||||||||||||||||||||||||||||||||||||