File Coverage

lib/Devel/Trepan/CmdProcessor/Command/Run.pm
Criterion Covered Total %
statement 63 81 77.7
branch 0 4 0.0
condition n/a
subroutine 21 23 91.3
pod 0 2 0.0
total 84 110 76.3


line stmt bran cond sub pod time code
1             # Copyright (C) 2011-2012, 2014-2015 Rocky Bernstein <rocky@cpan.org>
2             # -*- coding: utf-8 -*-
3 12     12   99 use warnings; no warnings 'redefine';
  12     12   31  
  12     1   386  
  12     1   70  
  12         27  
  12         379  
  1         7  
  1         3  
  1         26  
  1         5  
  1         2  
  1         27  
4 12     12   74 use rlib '../../../..';
  12     1   34  
  12         78  
  1         5  
  1         3  
  1         5  
5              
6             package Devel::Trepan::CmdProcessor::Command::Run;
7 12     12   4641 use English qw( -no_match_vars );
  12     1   29  
  12         208  
  1         327  
  1         3  
  1         8  
8              
9 12     12   4686 use if !@ISA, Devel::Trepan::CmdProcessor::Command ;
  12     1   31  
  12         82  
  1         276  
  1         3  
  1         5  
10             unless (@ISA) {
11 12     12   87 eval <<'EOE';
  12     12   34  
  12     12   910  
  12     12   82  
  12     12   50  
  12         604  
  12         74  
  12         33  
  12         538  
  12         74  
  12         33  
  12         592  
  12         78  
  12         30  
  12         403  
12             use constant ALIASES => ('R', 'restart');
13             use constant CATEGORY => 'running';;
14             use constant SHORT_HELP => '(Hard) restart of program via exec()';
15             use constant MIN_ARGS => 0; # Need at least this many
16             use constant MAX_ARGS => undef; # Need at most this many - undef -> unlimited.
17             EOE
18             }
19              
20 12     12   2043 use strict;
  12     1   31  
  12         319  
  1         59  
  1         3  
  1         25  
21 12     12   66 use vars qw(@ISA);
  12     1   31  
  12         653  
  1         5  
  1         2  
  1         44  
22             @ISA = @CMD_ISA;
23 12     12   76 use vars @CMD_VARS; # Value inherited from parent
  12     1   31  
  12         3759  
  1         5  
  1         3  
  1         263  
24              
25             our $NAME = set_name();
26              
27             =pod
28              
29             =head2 Synopsis:
30              
31             =cut
32             our $HELP = <<'HELP';
33             =pod
34              
35             B<run>
36              
37             Restart debugger and program via an I<exec()> call.
38              
39             Hash reference variable I<$Devel::Trepan::Core::invoke_opts> contains a
40             hash of options that were used to start the debugger. These are
41             consulted in figuring out how to restart.
42              
43             =head2 See also:
44              
45             L<C<show args>|Devel::Trepan::CmdProcessor::Command:Show::Args> for
46             the exact invocation that will be used.
47              
48             =cut
49             HELP
50              
51             # This method runs the command
52             sub run($$) {
53 0     0 0   my ($self, $args) = @_;
  0     0 0    
54 0           my $proc = $self->{proc};
  0            
55 0           my $dbgr = $proc->{dbgr};
  0            
56              
57             # I may not be able to resurrect you, but here goes ...
58 0           $self->msg("Warning: some settings and command-line options may be lost!");
  0            
59              
60 0           my @script = $proc->restart_args();
  0            
61              
62 0           my $intf = $proc->{interfaces}[-1];
  0            
63 0           $intf->save_history($proc->{last_command});
  0            
64              
65 0           $self->msg( "Running: " . join(' ', @script));
  0            
66              
67             # And run Perl again. We use exec() to keep the
68             # PID stable (and that way $ini_pids is still valid).
69              
70 0 0         exec(@script) || $self->errmsg("exec failed: $!");
  0 0          
71              
72             }
73              
74             unless (caller()) {
75             require Devel::Trepan::CmdProcessor::Mock;
76             my $proc = Devel::Trepan::CmdProcessor::Mock::setup();
77             my $cmd = Devel::Trepan::CmdProcessor::Command::Run->new($proc);
78             }
79              
80             1;