lib/Devel/Trepan/CmdProcessor/Command/Run.pm

filter: Statementstmt 82.4% 75 / 91 Branchbran 37.5% 3 / 8 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 91.3% 21 / 23 Podpod 0.0% 0 / 2 totaltotal 79.8% 99 / 124 CC 4 SCAR 4.1
CC
4
Cov
79%
run
3.3
run
3.3
run
3.3
CRAP 1.5
« lib/Devel/Trepan/CmdProcessor/Alias.pm ↑ Summary example/callbug.pl »
1 # Copyright (C) 2011-2012, 2014-2015 Rocky Bernstein <rocky@cpan.org>
2 # -*- coding: utf-8 -*-
3 12 ▶use warnings; no warnings 'redefine';
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
4 12 ▶use rlib '../../../..';
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 package Devel::Trepan::CmdProcessor::Command::Run;
7 12 ▶use English qw( -no_match_vars );
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 12 ▶use if !@ISA, Devel::Trepan::CmdProcessor::Command ;
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
10 12 ▶unless (@ISA) {
Branch: 1 branch
BranchTrueFalseTotal
unless (@ISA) 0 12 12
11 0 ▶ eval <<'EOE';
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
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 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
21 12 ▶use vars qw(@ISA);
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
22 1 @ISA = @CMD_ISA;
23 12 ▶use vars @CMD_VARS; # Value inherited from parent
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
24  
25 1 our $NAME = set_name();
26  
27 =pod
28  
29 =head2 Synopsis:
30  
31 =cut
32 1 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 0 ▶sub run($$) {
Subroutine run: not called CC=2 SCAR=11.8
Subroutine run: not called CC=2 SCAR=11.8
Pod undocumented
Pod undocumented
53 0 my ($self, $args) = @_;
54 0 my $proc = $self->{proc};
55 0 my $dbgr = $proc->{dbgr};
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!");
59  
60 0 my @script = $proc->restart_args();
61  
62 0 my $intf = $proc->{interfaces}[-1];
63 0 $intf->save_history($proc->{last_command});
64  
65 0 $self->msg( "Running: " . join(' ', @script));
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 ▶ exec(@script) || $self->errmsg("exec failed: $!");
Branch: 2 branches
BranchTrueFalseTotal
exec @script or $self->errmsg("exec failed: $!") 0 0 0
exec @script or $self->errmsg("exec failed: $!") 11 0 11
71  
72 }
73  
74 1 ▶unless (caller()) {
Branch: 1 branch
BranchTrueFalseTotal
unless (caller()) 0 1 1
75 0 require Devel::Trepan::CmdProcessor::Mock;
76 0 my $proc = Devel::Trepan::CmdProcessor::Mock::setup();
77 0 my $cmd = Devel::Trepan::CmdProcessor::Command::Run->new($proc);
78 }
79  
80 1 1;
« lib/Devel/Trepan/CmdProcessor/Alias.pm ↑ Summary example/callbug.pl »