line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# -*- coding: utf-8 -*- |
2
|
|
|
|
|
|
|
# Copyright (C) 2011-2014 Rocky Bernstein <rocky@cpan.org> |
3
|
12
|
|
|
12
|
|
84
|
use warnings; no warnings 'redefine'; no warnings 'once'; |
|
12
|
|
|
12
|
|
31
|
|
|
12
|
|
|
12
|
|
382
|
|
|
12
|
|
|
12
|
|
64
|
|
|
12
|
|
|
12
|
|
31
|
|
|
12
|
|
|
12
|
|
337
|
|
|
12
|
|
|
|
|
62
|
|
|
12
|
|
|
|
|
29
|
|
|
12
|
|
|
|
|
265
|
|
|
12
|
|
|
|
|
96
|
|
|
12
|
|
|
|
|
28
|
|
|
12
|
|
|
|
|
448
|
|
|
12
|
|
|
|
|
70
|
|
|
12
|
|
|
|
|
34
|
|
|
12
|
|
|
|
|
354
|
|
|
12
|
|
|
|
|
64
|
|
|
12
|
|
|
|
|
31
|
|
|
12
|
|
|
|
|
315
|
|
4
|
12
|
|
|
12
|
|
65
|
use rlib '../../../../../..'; |
|
12
|
|
|
12
|
|
31
|
|
|
12
|
|
|
|
|
77
|
|
|
12
|
|
|
|
|
68
|
|
|
12
|
|
|
|
|
35
|
|
|
12
|
|
|
|
|
74
|
|
5
|
12
|
|
|
12
|
|
5242
|
use Data::Dumper; |
|
12
|
|
|
12
|
|
30
|
|
|
12
|
|
|
|
|
908
|
|
|
12
|
|
|
|
|
5245
|
|
|
12
|
|
|
|
|
34
|
|
|
12
|
|
|
|
|
931
|
|
6
|
|
|
|
|
|
|
$Data::Dumper::Sortkeys = 1; |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
package Devel::Trepan::CmdProcessor::Command::Info::Variables::My; |
9
|
12
|
|
|
12
|
|
72
|
use vars qw(@ISA @SUBCMD_VARS); |
|
12
|
|
|
12
|
|
33
|
|
|
12
|
|
|
|
|
753
|
|
|
12
|
|
|
|
|
83
|
|
|
12
|
|
|
|
|
33
|
|
|
12
|
|
|
|
|
777
|
|
10
|
|
|
|
|
|
|
unless (@ISA) { |
11
|
12
|
|
|
12
|
|
83
|
eval <<'EOE'; |
|
12
|
|
|
12
|
|
34
|
|
|
12
|
|
|
|
|
720
|
|
|
12
|
|
|
|
|
76
|
|
|
12
|
|
|
|
|
440
|
|
|
12
|
|
|
|
|
411
|
|
12
|
|
|
|
|
|
|
use constant MAX_ARGS => undef; |
13
|
|
|
|
|
|
|
use constant NEED_STACK => 1; |
14
|
|
|
|
|
|
|
EOE |
15
|
|
|
|
|
|
|
} |
16
|
12
|
|
|
12
|
|
75
|
use strict; |
|
12
|
|
|
12
|
|
29
|
|
|
12
|
|
|
|
|
264
|
|
|
12
|
|
|
|
|
78
|
|
|
12
|
|
|
|
|
31
|
|
|
12
|
|
|
|
|
274
|
|
17
|
|
|
|
|
|
|
|
18
|
12
|
|
|
12
|
|
68
|
use Devel::Trepan::CmdProcessor::Command::Subcmd::Subsubcmd; |
|
12
|
|
|
12
|
|
30
|
|
|
12
|
|
|
|
|
287
|
|
|
12
|
|
|
|
|
74
|
|
|
12
|
|
|
|
|
40
|
|
|
12
|
|
|
|
|
311
|
|
19
|
12
|
|
|
12
|
|
67
|
use PadWalker qw(peek_my); |
|
12
|
|
|
12
|
|
38
|
|
|
12
|
|
|
|
|
430
|
|
|
12
|
|
|
|
|
68
|
|
|
12
|
|
|
|
|
36
|
|
|
12
|
|
|
|
|
509
|
|
20
|
12
|
|
|
12
|
|
83
|
use Devel::Trepan::CmdProcessor::Command::Subcmd::Core; |
|
12
|
|
|
12
|
|
42
|
|
|
12
|
|
|
|
|
13799
|
|
|
12
|
|
|
|
|
79
|
|
|
12
|
|
|
|
|
36
|
|
|
12
|
|
|
|
|
13432
|
|
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
our $CMD = "info variables my"; |
23
|
|
|
|
|
|
|
my @CMD = split(/ /, $CMD); |
24
|
|
|
|
|
|
|
=pod |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
=head2 Synopsis: |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
=cut |
29
|
|
|
|
|
|
|
our $MIN_ABBREV = length('m'); |
30
|
|
|
|
|
|
|
our $HELP = <<'HELP'; |
31
|
|
|
|
|
|
|
=pod |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
B<info variables my> |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
B<info variables my -v> |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
B<info variables my> I<var1> [I<var2>...] |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
Lists C<my> variables at the current frame. Use the frame changing |
40
|
|
|
|
|
|
|
commands like C<up>, C<down> or C<frame> set the current frame. |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
In the first form, give a list of C<my> variable names only. In the |
43
|
|
|
|
|
|
|
second form, list variable names and values In the third form, list |
44
|
|
|
|
|
|
|
variable names and values of I<var1>, etc. |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
=head2 See also: |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
L<C<info variables |
49
|
|
|
|
|
|
|
lexicals>|Devel::Trepan::CmdProcessor::Command::Info::Variables::Lexicals>, |
50
|
|
|
|
|
|
|
L<C<info variables |
51
|
|
|
|
|
|
|
our>|Devel::Trepan::CmdProcessor::Command::Info::Variables::Our>, and |
52
|
|
|
|
|
|
|
frame-changing commands |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
=cut |
55
|
|
|
|
|
|
|
HELP |
56
|
|
|
|
|
|
|
our $SHORT_HELP = "Information about 'my' variables."; |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
@ISA = qw(Devel::Trepan::CmdProcessor::Command::Subsubcmd); |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
sub get_var_hash($;$) |
61
|
|
|
|
|
|
|
{ |
62
|
0
|
|
|
0
|
|
|
my ($self, $fixup_num) = @_; |
63
|
|
|
|
|
|
|
# FIXME: combine with My.pm |
64
|
0
|
|
|
|
|
|
my $i = 0; |
65
|
0
|
|
|
|
|
|
while (my ($pkg, $file, $line, $fn) = caller($i++)) { ; }; |
66
|
0
|
|
|
|
|
|
my $diff = $i - $DB::stack_depth; |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
# FIXME: 5 is a magic fixup constant, also found in DB::finish. |
69
|
|
|
|
|
|
|
# Remove it. |
70
|
0
|
0
|
|
|
|
|
$fixup_num = 5 unless defined($fixup_num); |
71
|
0
|
|
|
|
|
|
my $ref = peek_my($diff + $self->{proc}{frame_index} + $fixup_num); |
72
|
0
|
|
|
|
|
|
return $ref; |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
sub complete($$;$) |
76
|
|
|
|
|
|
|
{ |
77
|
0
|
|
|
0
|
|
|
my ($self, $prefix, $fixup_num) = @_; |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
# This is really hacky |
80
|
0
|
0
|
|
|
|
|
unless ($fixup_num) { |
81
|
0
|
|
|
|
|
|
my $i = 0; |
82
|
0
|
|
|
|
|
|
while (my ($pkg, $file, $line, $fn) = caller($i++)) { |
83
|
0
|
0
|
0
|
|
|
|
last if $pkg eq 'Devel::Trepan::CmdProcessor' && $fn eq '(eval)'; |
84
|
0
|
0
|
0
|
|
|
|
last if $pkg eq 'Devel::Trepan::Core' && |
85
|
|
|
|
|
|
|
$fn eq 'Devel::Trepan::CmdProcessor::process_commands'; |
86
|
|
|
|
|
|
|
}; |
87
|
|
|
|
|
|
|
|
88
|
0
|
|
|
|
|
|
$fixup_num = $i; |
89
|
|
|
|
|
|
|
} |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
# print "FIXUP_NUM is $fixup_num\n"; |
92
|
|
|
|
|
|
|
|
93
|
0
|
|
|
|
|
|
my $var_hash = $self->get_var_hash($fixup_num); |
94
|
0
|
|
|
|
|
|
my @vars = sort keys %$var_hash; |
95
|
0
|
|
|
|
|
|
my @results = Devel::Trepan::Complete::complete_token(\@vars, $prefix); |
96
|
0
|
|
|
|
|
|
return @results; |
97
|
|
|
|
|
|
|
} |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
sub show_var($$$) |
101
|
|
|
|
|
|
|
{ |
102
|
0
|
|
|
0
|
|
|
my ($proc, $var_name, $ref) = @_; |
103
|
0
|
|
|
|
|
|
my $dumper; |
104
|
0
|
|
|
|
|
|
my $type = substr($var_name, 0, 1); |
105
|
0
|
0
|
|
|
|
|
if ('$' eq $type) { |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
106
|
0
|
|
|
|
|
|
$dumper = Data::Dumper->new([${$ref}]); |
|
0
|
|
|
|
|
|
|
107
|
0
|
|
|
|
|
|
$dumper->Useqq(0); |
108
|
0
|
|
|
|
|
|
$dumper->Terse(1); |
109
|
0
|
|
|
|
|
|
$dumper->Indent(0); |
110
|
0
|
|
|
|
|
|
$proc->msg("$var_name = ". $dumper->Dump); |
111
|
|
|
|
|
|
|
} elsif ('@' eq $type) { |
112
|
0
|
|
|
|
|
|
$dumper = Data::Dumper->new([$ref]); |
113
|
0
|
|
|
|
|
|
$dumper->Useqq(0); |
114
|
0
|
|
|
|
|
|
$dumper->Terse(1); |
115
|
0
|
|
|
|
|
|
$dumper->Indent(0); |
116
|
0
|
|
|
|
|
|
$proc->msg("$var_name = ". $dumper->Dump); |
117
|
|
|
|
|
|
|
} elsif ('%' eq $type) { |
118
|
0
|
|
|
|
|
|
$dumper = Data::Dumper->new([$ref], [$var_name]); |
119
|
0
|
|
|
|
|
|
$dumper->Useqq(0); |
120
|
0
|
|
|
|
|
|
$dumper->Terse(0); |
121
|
0
|
|
|
|
|
|
$dumper->Indent(0); |
122
|
0
|
|
|
|
|
|
$proc->msg($dumper->Dump); |
123
|
|
|
|
|
|
|
} else { |
124
|
0
|
|
|
|
|
|
$dumper = Data::Dumper->new([$ref], [$var_name]); |
125
|
0
|
|
|
|
|
|
$dumper->Useqq(0); |
126
|
0
|
|
|
|
|
|
$dumper->Terse(1); |
127
|
0
|
|
|
|
|
|
$dumper->Indent(0); |
128
|
0
|
|
|
|
|
|
$proc->msg($dumper->Dump); |
129
|
|
|
|
|
|
|
}; |
130
|
|
|
|
|
|
|
} |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
sub process_args($$$) { |
134
|
0
|
|
|
0
|
|
|
my ($self, $args, $hash_ref) = @_; |
135
|
0
|
|
|
|
|
|
my $lex_type = $self->{prefix}[-1]; |
136
|
0
|
|
|
|
|
|
my $proc = $self->{proc}; |
137
|
0
|
|
|
|
|
|
my @ARGS = @{$args}; |
|
0
|
|
|
|
|
|
|
138
|
0
|
|
|
|
|
|
my @names = sort keys %{$hash_ref}; |
|
0
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
|
140
|
0
|
0
|
|
|
|
|
if (0 == scalar @ARGS) { |
141
|
0
|
0
|
|
|
|
|
if (scalar @names) { |
142
|
0
|
|
|
|
|
|
$proc->section("$lex_type variables"); |
143
|
0
|
|
|
|
|
|
$proc->msg($self->{parent}{parent}->columnize_commands(\@names)); |
144
|
|
|
|
|
|
|
} else { |
145
|
0
|
|
|
|
|
|
$proc->msg("No '$lex_type' variables at this level"); |
146
|
|
|
|
|
|
|
} |
147
|
|
|
|
|
|
|
} else { |
148
|
0
|
0
|
|
|
|
|
if ($ARGS[0] eq '-v') { |
149
|
0
|
0
|
|
|
|
|
if (scalar @names) { |
150
|
0
|
|
|
|
|
|
$proc->section("$lex_type variables"); |
151
|
0
|
|
|
|
|
|
for my $name (@names) { |
152
|
0
|
|
|
|
|
|
show_var($proc, $name, $hash_ref->{$name}); |
153
|
|
|
|
|
|
|
} |
154
|
|
|
|
|
|
|
} else { |
155
|
0
|
|
|
|
|
|
$proc->msg("No '$lex_type' variables at this level"); |
156
|
|
|
|
|
|
|
} |
157
|
|
|
|
|
|
|
} else { |
158
|
0
|
|
|
|
|
|
for my $name (@ARGS) { |
159
|
0
|
0
|
|
|
|
|
if (exists($hash_ref->{$name})) { |
160
|
0
|
|
|
|
|
|
show_var($proc, $name, $hash_ref->{$name}); |
161
|
|
|
|
|
|
|
} else { |
162
|
0
|
|
|
|
|
|
$proc->errmsg("No '$lex_type' variable $name found at this level"); |
163
|
|
|
|
|
|
|
} |
164
|
|
|
|
|
|
|
} |
165
|
|
|
|
|
|
|
} |
166
|
|
|
|
|
|
|
} |
167
|
|
|
|
|
|
|
} |
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
sub run($$;$) |
170
|
|
|
|
|
|
|
{ |
171
|
0
|
|
|
0
|
|
|
my ($self, $args, $fixup_num) = @_; |
172
|
0
|
|
|
|
|
|
my $var_hash = $self->get_var_hash($fixup_num); |
173
|
0
|
|
|
|
|
|
my @ARGS = splice(@{$args}, scalar(@CMD)); |
|
0
|
|
|
|
|
|
|
174
|
0
|
|
|
|
|
|
$self->process_args(\@ARGS, $var_hash); |
175
|
|
|
|
|
|
|
} |
176
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
unless (caller) { |
178
|
|
|
|
|
|
|
# Demo it. |
179
|
|
|
|
|
|
|
require Devel::Trepan; |
180
|
|
|
|
|
|
|
my $proc = Devel::Trepan::CmdProcessor->new; |
181
|
|
|
|
|
|
|
my $grandparent = |
182
|
|
|
|
|
|
|
Devel::Trepan::CmdProcessor::Command::Info->new($proc, 'info'); |
183
|
|
|
|
|
|
|
my $parent = |
184
|
|
|
|
|
|
|
Devel::Trepan::CmdProcessor::Command::Info::Variables->new($grandparent, |
185
|
|
|
|
|
|
|
'variables'); |
186
|
|
|
|
|
|
|
my $cmd = __PACKAGE__->new($parent, 'my'); |
187
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
eval { |
189
|
|
|
|
|
|
|
sub create_frame() { |
190
|
0
|
|
|
0
|
|
|
my ($pkg, $file, $line, $fn) = caller(0); |
191
|
0
|
|
|
|
|
|
$DB::package = $pkg; |
192
|
|
|
|
|
|
|
return [ |
193
|
|
|
|
|
|
|
{ |
194
|
0
|
|
|
|
|
|
file => $file, |
195
|
|
|
|
|
|
|
fn => $fn, |
196
|
|
|
|
|
|
|
line => $line, |
197
|
|
|
|
|
|
|
pkg => $pkg, |
198
|
|
|
|
|
|
|
}]; |
199
|
|
|
|
|
|
|
} |
200
|
|
|
|
|
|
|
}; |
201
|
|
|
|
|
|
|
my $frame_ary = create_frame(); |
202
|
|
|
|
|
|
|
$proc->frame_setup($frame_ary); |
203
|
|
|
|
|
|
|
|
204
|
|
|
|
|
|
|
$cmd->run($cmd->{prefix}, -2); |
205
|
|
|
|
|
|
|
my @args = @{$cmd->{prefix}}; |
206
|
|
|
|
|
|
|
push @args, '$args'; |
207
|
|
|
|
|
|
|
print '-' x 40, "\n"; |
208
|
|
|
|
|
|
|
$cmd->run(\@args, -2); |
209
|
|
|
|
|
|
|
print '-' x 40, "\n"; |
210
|
|
|
|
|
|
|
$cmd->run($cmd->{prefix}, -1); |
211
|
|
|
|
|
|
|
print '-' x 40, "\n"; |
212
|
|
|
|
|
|
|
my @complete = $cmd->complete('', -2); |
213
|
|
|
|
|
|
|
print join(', ', @complete), "\n"; |
214
|
|
|
|
|
|
|
print '-' x 40, "\n"; |
215
|
|
|
|
|
|
|
@complete = $cmd->complete('$p', -2); |
216
|
|
|
|
|
|
|
print join(', ', @complete), "\n"; |
217
|
|
|
|
|
|
|
|
218
|
|
|
|
|
|
|
} |
219
|
|
|
|
|
|
|
|
220
|
|
|
|
|
|
|
1; |