File Coverage

lib/Devel/ebug/Wx/View/StackTrace.pm
Criterion Covered Total %
statement 6 6 100.0
branch n/a
condition n/a
subroutine 2 2 100.0
pod n/a
total 8 8 100.0


line stmt bran cond sub pod time code
1             package Devel::ebug::Wx::View::StackTrace;
2              
3 1     1   1043 use strict;
  1         2  
  1         35  
4 1     1   8 use base qw(Wx::ListBox Devel::ebug::Wx::View::Base);
  1         2  
  1         733  
5             use Devel::ebug::Wx::Plugin qw(:plugin);
6              
7             use File::Basename;
8              
9             use Wx qw(:sizer);
10             use Wx::Event qw(EVT_LISTBOX);
11              
12             sub tag { 'stack' }
13             sub description { 'Stack' }
14              
15             sub new : View {
16             my( $class, $parent, $wxebug, $layout_state ) = @_;
17             my $self = $class->SUPER::new( $parent, -1 );
18              
19             $self->wxebug( $wxebug );
20             $self->set_stacktrace if $self->ebug->line;
21              
22             $self->subscribe_ebug( 'state_changed', sub { $self->_read_stack( @_ ) } );
23             $self->set_layout_state( $layout_state ) if $layout_state;
24             $self->register_view;
25              
26             EVT_LISTBOX( $self, $self, \&_lbox_click );
27              
28             $self->SetSize( $self->default_size );
29              
30             return $self;
31             }
32              
33             # should try and be smart and not do a full refresh...
34             sub _read_stack {
35             my( $self, $ebug, $event, %params ) = @_;
36              
37             $self->set_stacktrace;
38             }
39              
40             sub _lbox_click {
41             my( $self, $e ) = @_;
42             return unless $e->IsSelection; # skip deselections
43             my $to = $e->GetClientData;
44              
45             $self->wxebug->code_display_service
46             ->highlight_line( $to->[0], $to->[1] );
47             }
48              
49             # FIXME incremental read of stacktrace
50             sub set_stacktrace {
51             my( $self ) = @_;
52             my @frames = $self->ebug->folded_stack_trace;
53             $self->Clear;
54             foreach my $frame ( @frames ) {
55             my $string = sprintf '%s: %d %s(%s)',
56             basename( $frame->current_filename ),
57             $frame->current_line,
58             $frame->current_subroutine,
59             join ', ', $frame->args;
60             $self->Append( $string, [ $frame->current_filename,
61             $frame->current_line,
62             ] );
63             }
64             }
65              
66             1;