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
|
|
106
|
use warnings; no warnings 'redefine'; |
|
12
|
|
|
12
|
|
36
|
|
|
12
|
|
|
1
|
|
441
|
|
|
12
|
|
|
1
|
|
68
|
|
|
12
|
|
|
|
|
30
|
|
|
12
|
|
|
|
|
512
|
|
|
1
|
|
|
|
|
8
|
|
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
30
|
|
|
1
|
|
|
|
|
5
|
|
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
31
|
|
5
|
12
|
|
|
12
|
|
70
|
use rlib '../../../..'; |
|
12
|
|
|
1
|
|
30
|
|
|
12
|
|
|
|
|
100
|
|
|
1
|
|
|
|
|
6
|
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
641
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
package Devel::Trepan::CmdProcessor::Command::Alias; |
8
|
12
|
|
|
12
|
|
4894
|
use if !@ISA, Devel::Trepan::CmdProcessor::Command ; |
|
12
|
|
|
1
|
|
35
|
|
|
12
|
|
|
|
|
97
|
|
|
1
|
|
|
|
|
350
|
|
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
5
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
unless (@ISA) { |
11
|
12
|
|
|
12
|
|
88
|
eval <<"EOE"; |
|
12
|
|
|
12
|
|
34
|
|
|
12
|
|
|
12
|
|
707
|
|
|
12
|
|
|
12
|
|
84
|
|
|
12
|
|
|
|
|
33
|
|
|
12
|
|
|
|
|
588
|
|
|
12
|
|
|
|
|
71
|
|
|
12
|
|
|
|
|
35
|
|
|
12
|
|
|
|
|
599
|
|
|
12
|
|
|
|
|
77
|
|
|
12
|
|
|
|
|
41
|
|
|
12
|
|
|
|
|
456
|
|
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
|
|
2418
|
use strict; use vars qw(@ISA); @ISA = @CMD_ISA; |
|
12
|
|
|
12
|
|
34
|
|
|
12
|
|
|
1
|
|
309
|
|
|
12
|
|
|
1
|
|
62
|
|
|
12
|
|
|
|
|
33
|
|
|
12
|
|
|
|
|
579
|
|
|
1
|
|
|
|
|
57
|
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
19
|
|
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
40
|
|
21
|
12
|
|
|
12
|
|
82
|
use vars @CMD_VARS; # Value inherited from parent |
|
12
|
|
|
1
|
|
34
|
|
|
12
|
|
|
|
|
5189
|
|
|
1
|
|
|
|
|
6
|
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
362
|
|
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; |