| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
# -*- coding: utf-8 -*- |
|
2
|
|
|
|
|
|
|
# Copyright (C) 2011-2012, 2014 Rocky Bernstein <rocky@cpan.org> |
|
3
|
|
|
|
|
|
|
|
|
4
|
12
|
|
|
12
|
|
131
|
use warnings; no warnings 'redefine'; |
|
|
12
|
|
|
12
|
|
28
|
|
|
|
12
|
|
|
1
|
|
441
|
|
|
|
12
|
|
|
1
|
|
73
|
|
|
|
12
|
|
|
|
|
27
|
|
|
|
12
|
|
|
|
|
722
|
|
|
|
1
|
|
|
|
|
7
|
|
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
23
|
|
|
|
1
|
|
|
|
|
5
|
|
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
49
|
|
|
5
|
12
|
|
|
12
|
|
85
|
use rlib '../../../..'; |
|
|
12
|
|
|
1
|
|
24
|
|
|
|
12
|
|
|
|
|
76
|
|
|
|
1
|
|
|
|
|
6
|
|
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
5
|
|
|
6
|
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
package Devel::Trepan::CmdProcessor::Command::Alias; |
|
8
|
12
|
|
|
12
|
|
5664
|
use if !@ISA, Devel::Trepan::CmdProcessor::Command ; |
|
|
12
|
|
|
1
|
|
27
|
|
|
|
12
|
|
|
|
|
67
|
|
|
|
1
|
|
|
|
|
346
|
|
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
4
|
|
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
unless (@ISA) { |
|
11
|
12
|
|
|
12
|
|
75
|
eval <<"EOE"; |
|
|
12
|
|
|
12
|
|
28
|
|
|
|
12
|
|
|
12
|
|
848
|
|
|
|
12
|
|
|
12
|
|
94
|
|
|
|
12
|
|
|
|
|
31
|
|
|
|
12
|
|
|
|
|
833
|
|
|
|
12
|
|
|
|
|
75
|
|
|
|
12
|
|
|
|
|
45
|
|
|
|
12
|
|
|
|
|
758
|
|
|
|
12
|
|
|
|
|
73
|
|
|
|
12
|
|
|
|
|
31
|
|
|
|
12
|
|
|
|
|
474
|
|
|
12
|
|
|
|
|
|
|
use constant CATEGORY => 'support'; |
|
13
|
|
|
|
|
|
|
use constant SHORT_HELP => 'Add an alias for a debugger command'; |
|
14
|
|
|
|
|
|
|
use constant MIN_ARGS => 0; # Need at least this many |
|
15
|
|
|
|
|
|
|
use constant MAX_ARGS => undef; # Need at most this many - undef -> unlimited. |
|
16
|
|
|
|
|
|
|
EOE |
|
17
|
|
|
|
|
|
|
} |
|
18
|
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
|
|
20
|
12
|
|
|
12
|
|
2055
|
use strict; use vars qw(@ISA); @ISA = @CMD_ISA; |
|
|
12
|
|
|
12
|
|
25
|
|
|
|
12
|
|
|
1
|
|
349
|
|
|
|
12
|
|
|
1
|
|
64
|
|
|
|
12
|
|
|
|
|
20
|
|
|
|
12
|
|
|
|
|
754
|
|
|
|
1
|
|
|
|
|
64
|
|
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
28
|
|
|
|
1
|
|
|
|
|
6
|
|
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
58
|
|
|
21
|
12
|
|
|
12
|
|
72
|
use vars @CMD_VARS; # Value inherited from parent |
|
|
12
|
|
|
1
|
|
23
|
|
|
|
12
|
|
|
|
|
6243
|
|
|
|
1
|
|
|
|
|
6
|
|
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
444
|
|
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
our $NAME = set_name(); |
|
24
|
|
|
|
|
|
|
=pod |
|
25
|
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
=head2 Synopsis: |
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
=cut |
|
29
|
|
|
|
|
|
|
our $HELP = <<'HELP'; |
|
30
|
|
|
|
|
|
|
=pod |
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
B<alias> I<alias> I<command> |
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
Add alias I<alias> for a debugger command I<command>. |
|
35
|
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
Add an alias when you want to use a command abbreviation for a command |
|
37
|
|
|
|
|
|
|
that would otherwise be ambigous. For example, by default we make C<s> |
|
38
|
|
|
|
|
|
|
be an alias of C<step> to force it to be used. Without the alias, C<s> |
|
39
|
|
|
|
|
|
|
might be C<step>, C<show>, or C<set>, among others. |
|
40
|
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
=head2 Examples: |
|
42
|
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
alias cat list # "cat file.pl" is the same as "list file.pl" |
|
44
|
|
|
|
|
|
|
alias s step # "s" is now an alias for "step". |
|
45
|
|
|
|
|
|
|
# The above "s" alias is initially set up, by |
|
46
|
|
|
|
|
|
|
# default. But you can change or remove it. |
|
47
|
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
=head2 See also: |
|
49
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
L<C<macro>|Devel::Trepan::CmdProcessor::Command::Macro> E<mdash> more complex definitions, |
|
51
|
|
|
|
|
|
|
L<C<unalias>|Devel::Trepan::CmdProcessor::Command::Unalias>, and |
|
52
|
|
|
|
|
|
|
L<C<show aliases>|Devel::Trepan::CmdProcessor::Command::Show::Aliases> |
|
53
|
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
=cut |
|
55
|
|
|
|
|
|
|
HELP |
|
56
|
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
# Run command. |
|
58
|
|
|
|
|
|
|
sub run($$) { |
|
59
|
0
|
|
|
0
|
0
|
|
my ($self, $args) = @_; |
|
|
0
|
|
|
0
|
0
|
|
|
|
60
|
0
|
|
|
|
|
|
my $proc = $self->{proc}; |
|
|
0
|
|
|
|
|
|
|
|
61
|
0
|
0
|
|
|
|
|
if (scalar @$args == 1) { |
|
|
0
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
62
|
0
|
|
|
|
|
|
$proc->{commands}->{show}->run(['show', ${NAME}]); |
|
|
0
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
} elsif (scalar @$args == 2) { |
|
64
|
0
|
|
|
|
|
|
$proc->{commands}->{show}->run(['show', ${NAME}, $args->[1]]); |
|
|
0
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
} else { |
|
66
|
0
|
|
|
|
|
|
my ($junk, $al, $command, @rest) = @$args; |
|
|
0
|
|
|
|
|
|
|
|
67
|
0
|
|
|
|
|
|
my $old_command = $proc->{aliases}{$al}; |
|
|
0
|
|
|
|
|
|
|
|
68
|
0
|
0
|
|
|
|
|
if (exists $proc->{commands}{$command}) { |
|
|
0
|
0
|
|
|
|
|
|
|
69
|
0
|
|
|
|
|
|
my $cmd_str = join(' ', ($command, @rest)); |
|
|
0
|
|
|
|
|
|
|
|
70
|
0
|
|
|
|
|
|
$proc->add_alias($command, $al, $cmd_str); |
|
|
0
|
|
|
|
|
|
|
|
71
|
0
|
0
|
|
|
|
|
if ($old_command) { |
|
|
0
|
0
|
|
|
|
|
|
|
72
|
0
|
|
|
|
|
|
$proc->remove_alias($old_command); |
|
|
0
|
|
|
|
|
|
|
|
73
|
0
|
|
|
|
|
|
$self->msg("Alias '${al}' for command string '${cmd_str}' replaced old " . |
|
|
0
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
"alias for '${old_command}'."); |
|
75
|
|
|
|
|
|
|
} else { |
|
76
|
0
|
|
|
|
|
|
$self->msg("New alias '${al}' for command string '${cmd_str}' created."); |
|
|
0
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
} |
|
78
|
|
|
|
|
|
|
} else { |
|
79
|
0
|
|
|
|
|
|
$self->errmsg("You must alias to a command name, and '${command}' isn't one."); |
|
|
0
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
} |
|
81
|
|
|
|
|
|
|
} |
|
82
|
|
|
|
|
|
|
} |
|
83
|
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
unless (caller) { |
|
85
|
|
|
|
|
|
|
# Demo it. |
|
86
|
|
|
|
|
|
|
require Devel::Trepan::CmdProcessor::Mock; |
|
87
|
|
|
|
|
|
|
my $proc = Devel::Trepan::CmdProcessor::Mock::setup(); |
|
88
|
|
|
|
|
|
|
my $cmd = __PACKAGE__->new($proc); |
|
89
|
|
|
|
|
|
|
$cmd->run([$NAME, 'yy', 'foo']); |
|
90
|
|
|
|
|
|
|
$cmd->run([$NAME, 'yy', 'step']); |
|
91
|
|
|
|
|
|
|
$cmd->run([$NAME]); |
|
92
|
|
|
|
|
|
|
$cmd->run([$NAME, 'yy', 'next']); |
|
93
|
|
|
|
|
|
|
$cmd->run([$NAME, 'evd', 'show', 'evaldisplay']); |
|
94
|
|
|
|
|
|
|
} |
|
95
|
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
1; |