line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# Copyright (C) 2011-2012, 2014-2015 Rocky Bernstein <rocky@cpan.org> |
2
|
12
|
|
|
12
|
|
112
|
use warnings; no warnings 'redefine'; |
|
12
|
|
|
12
|
|
37
|
|
|
12
|
|
|
1
|
|
464
|
|
|
12
|
|
|
1
|
|
75
|
|
|
12
|
|
|
|
|
29
|
|
|
12
|
|
|
|
|
443
|
|
|
1
|
|
|
|
|
6
|
|
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
22
|
|
|
1
|
|
|
|
|
5
|
|
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
28
|
|
3
|
|
|
|
|
|
|
|
4
|
12
|
|
|
12
|
|
80
|
use rlib '../../../..'; |
|
12
|
|
|
1
|
|
32
|
|
|
12
|
|
|
|
|
84
|
|
|
1
|
|
|
|
|
6
|
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
4
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
package Devel::Trepan::CmdProcessor::Command::Backtrace; |
7
|
12
|
|
|
12
|
|
4368
|
use if !@ISA, Devel::Trepan::CmdProcessor::Command ; |
|
12
|
|
|
1
|
|
30
|
|
|
12
|
|
|
|
|
84
|
|
|
1
|
|
|
|
|
306
|
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
5
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
unless (@ISA) { |
10
|
12
|
|
|
12
|
|
80
|
eval <<"EOE"; |
|
12
|
|
|
12
|
|
34
|
|
|
12
|
|
|
12
|
|
877
|
|
|
12
|
|
|
12
|
|
80
|
|
|
12
|
|
|
12
|
|
27
|
|
|
12
|
|
|
12
|
|
577
|
|
|
12
|
|
|
|
|
72
|
|
|
12
|
|
|
|
|
33
|
|
|
12
|
|
|
|
|
545
|
|
|
12
|
|
|
|
|
76
|
|
|
12
|
|
|
|
|
31
|
|
|
12
|
|
|
|
|
658
|
|
|
12
|
|
|
|
|
88
|
|
|
12
|
|
|
|
|
40
|
|
|
12
|
|
|
|
|
604
|
|
|
12
|
|
|
|
|
79
|
|
|
12
|
|
|
|
|
31
|
|
|
12
|
|
|
|
|
512
|
|
11
|
|
|
|
|
|
|
use constant ALIASES => qw(bt where T); |
12
|
|
|
|
|
|
|
use constant CATEGORY => 'stack'; |
13
|
|
|
|
|
|
|
use constant SHORT_HELP => 'Print backtrace of stack frames'; |
14
|
|
|
|
|
|
|
use constant MIN_ARGS => 0; # Need at least this many |
15
|
|
|
|
|
|
|
use constant MAX_ARGS => 1; # Need at most this many - undef -> unlimited. |
16
|
|
|
|
|
|
|
use constant NEED_STACK => 1; |
17
|
|
|
|
|
|
|
EOE |
18
|
|
|
|
|
|
|
} |
19
|
|
|
|
|
|
|
|
20
|
12
|
|
|
12
|
|
2226
|
use strict; use vars qw(@ISA); @ISA = @CMD_ISA; |
|
12
|
|
|
12
|
|
37
|
|
|
12
|
|
|
1
|
|
322
|
|
|
12
|
|
|
1
|
|
63
|
|
|
12
|
|
|
|
|
35
|
|
|
12
|
|
|
|
|
623
|
|
|
1
|
|
|
|
|
54
|
|
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
19
|
|
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
39
|
|
21
|
12
|
|
|
12
|
|
77
|
use vars @CMD_VARS; # Value inherited from parent |
|
12
|
|
|
1
|
|
43
|
|
|
12
|
|
|
|
|
5279
|
|
|
1
|
|
|
|
|
5
|
|
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
329
|
|
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
our $NAME = set_name(); |
24
|
|
|
|
|
|
|
=pod |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
=head2 Synopsis: |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
=cut |
29
|
|
|
|
|
|
|
our $HELP = <<'HELP'; |
30
|
|
|
|
|
|
|
=pod |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
B<backtrace> [I<count>] |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
Print a stack trace, with the most recent frame at the top. With a |
35
|
|
|
|
|
|
|
positive number, print at most many entries. |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
In the listing produced, an arrow, C<--E<gt>>, indicates the 'current |
38
|
|
|
|
|
|
|
frame'. The current frame determines the context used for many |
39
|
|
|
|
|
|
|
debugger commands such as source-line listing |
40
|
|
|
|
|
|
|
(L<C<list>|Devel::Trepan::CmdProcessor::Command::List>) or the |
41
|
|
|
|
|
|
|
L<C<edit>|Devel::Trepan::CmdProcessor::Command::Edit> command. |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
=head2 Examples: |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
backtrace # Print a full stack trace |
46
|
|
|
|
|
|
|
backtrace 2 # Print only the top two entries |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
=head2 See also: |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
L<C<up>|Devel::Trepan::CmdProcessor::Command::Up>, |
51
|
|
|
|
|
|
|
L<C<down>|Devel::Trepan::CmdProcessor::Command::Down>, and |
52
|
|
|
|
|
|
|
L<C<frame>|Devel::Trepan::CmdProcessor::Command::Frame>, |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
=cut |
55
|
|
|
|
|
|
|
HELP |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
sub complete($$) |
58
|
|
|
|
|
|
|
{ |
59
|
0
|
|
|
0
|
0
|
|
my ($self, $prefix) = @_; |
|
0
|
|
|
0
|
0
|
|
|
60
|
0
|
|
|
|
|
|
$self->{proc}->frame_complete($prefix); |
|
0
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
# This method runs the command |
64
|
|
|
|
|
|
|
sub run($$) |
65
|
|
|
|
|
|
|
{ |
66
|
0
|
|
|
0
|
0
|
|
my ($self, $args) = @_; |
|
0
|
|
|
0
|
0
|
|
|
67
|
0
|
|
|
|
|
|
my $proc = $self->{proc}; |
|
0
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
my $opts = { |
69
|
|
|
|
|
|
|
basename => $proc->{settings}{basename}, |
70
|
|
|
|
|
|
|
current_pos => $proc->{frame_index}, |
71
|
|
|
|
|
|
|
maxstack => $proc->{settings}{maxstack}, |
72
|
|
|
|
|
|
|
maxwidth => $proc->{settings}{maxwidth}, |
73
|
|
|
|
|
|
|
displayop => $proc->{settings}{displayop}, |
74
|
0
|
|
|
|
|
|
}; |
|
0
|
|
|
|
|
|
|
75
|
0
|
|
|
|
|
|
my $stack_size = $proc->{stack_size}; |
|
0
|
|
|
|
|
|
|
76
|
0
|
|
|
|
|
|
my $count = $stack_size; |
|
0
|
|
|
|
|
|
|
77
|
0
|
0
|
|
|
|
|
if (scalar @$args > 1) { |
|
0
|
0
|
|
|
|
|
|
78
|
0
|
|
|
|
|
|
$count = |
|
0
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
$proc->get_an_int($args->[1], |
80
|
|
|
|
|
|
|
{cmdname => $self->name, |
81
|
|
|
|
|
|
|
min_value => 1}); |
82
|
0
|
0
|
|
|
|
|
return unless defined $count; |
|
0
|
0
|
|
|
|
|
|
83
|
|
|
|
|
|
|
} |
84
|
0
|
|
|
|
|
|
$opts->{count} = $count; |
|
0
|
|
|
|
|
|
|
85
|
0
|
|
|
|
|
|
my @frames = $self->{dbgr}->tbacktrace($count-1); |
|
0
|
|
|
|
|
|
|
86
|
0
|
|
|
|
|
|
$self->{proc}->print_stack_trace(\@frames, $opts); |
|
0
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
} |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
unless(caller) { |
90
|
|
|
|
|
|
|
# FIXME: DRY this code by putting in common location. |
91
|
|
|
|
|
|
|
require Devel::Trepan::DB; |
92
|
|
|
|
|
|
|
require Devel::Trepan::Core; |
93
|
|
|
|
|
|
|
my $db = Devel::Trepan::Core->new; |
94
|
|
|
|
|
|
|
my $intf = Devel::Trepan::Interface::User->new(undef, undef, {readline => 0}); |
95
|
|
|
|
|
|
|
my $proc = Devel::Trepan::CmdProcessor->new([$intf], $db); |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
$proc->{stack_size} = 0; |
98
|
|
|
|
|
|
|
my $cmd = __PACKAGE__->new($proc); |
99
|
|
|
|
|
|
|
$cmd->run([$NAME]); |
100
|
|
|
|
|
|
|
} |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
1; |