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

filter: Statementstmt 86.0% 80 / 93 Branchbran 75.0% 3 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 92.0% 23 / 25 Podpod 0.0% 0 / 2 totaltotal 85.4% 106 / 124 CC 1 SCAR 0.1
CC
1
Cov
86%
run
1.1
run
1.1
run
1.1
CRAP 1.0
« example/next2.pl ↑ Summary blib/lib/Devel/Trepan/IO/InOutBase.pm »
1 # -*- coding: utf-8 -*-
2 # Copyright (C) 2011, 2012, 2014 Rocky Bernstein <rockb@cpan.org>
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  
5 12 ▶use rlib '../../../..';
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 package Devel::Trepan::CmdProcessor::Command::Debug;
8 12 ▶use if !@ISA, Devel::Trepan::CmdProcessor::Command ;
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 1 ▶unless (@ISA) {
Branch: 1 branch
BranchTrueFalseTotal
unless (@ISA) 11 1 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 CATEGORY => 'data';
13 use constant SHORT_HELP => 'debug into a Perl expression or statement';
14 use constant MIN_ARGS => 1; # Need at least this many
15 use constant MAX_ARGS => undef; # Need at most this many -
16 # undef -> unlimited.
17 use constant NEED_STACK => 0;
18 EOE
19 }
20  
21 12 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
22 12 ▶use Devel::Trepan::Util;
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
23  
24 12 ▶use vars qw(@ISA); @ISA = @CMD_ISA;
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
25 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
26  
27 1 our $NAME = set_name();
28 1 our $HELP = <<'HELP';
29 =pod
30  
31 B<debug> I<Perl-code>
32  
33 Recursively debug I<Perl-code>.
34  
35 The level of recursive debugging is shown in the prompt. For example
36 C<((trepan.pl))> indicates one nested level of debugging.
37  
38 =head2 Examples:
39  
40 debug finonacci(5) # Debug fibonacci function
41 debug $x=1; $y=2; # Kind of pointless, but doable.
42 =cut
43 HELP
44  
45 # sub complete($$)
46 # {
47 # my ($self, $prefix) = @_;
48 # }
49  
50 sub run($$)
51 0 ▶{
Subroutine run: not called CC=1 SCAR=1.2
Subroutine run: not called CC=1 SCAR=1.2
Pod undocumented
Pod undocumented
52 0 my ($self, $args) = @_;
53 0 my $proc = $self->{proc};
54 0 my $expr = $proc->{cmd_argstr};
55 # Trim leading and trailing spaces.
56 0 $expr =~ s/^\s+//; $expr =~ s/\s+$//;
57 0 my $cmd_name = $args->[0];
58 12 ▶ no warnings 'once';
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
59 0 my $opts = {
60 return_type => parse_eval_suffix($cmd_name),
61 nest => $DB::level,
62 # Don't fix up __FILE__ and __LINE__ in this eval.
63 # We want to see our debug (eval) with its string.
64 fix_file_and_line => 0
65 };
66  
67 # FIXME: may mess up trace print. And cause skips we didn't want.
68 ## Skip over stopping in the eval that is setup below.
69 ## $proc->{skip_count} = 1;
70  
71 # Have to use $^D rather than $DEBUGGER below since we are in the
72 # user's code and they might not have English set.
73 0 my $full_expr =
74 "\$DB::event=undef;\n" .
75 "\$DB::single = 1;\n" .
76 "\$^D |= DB::db_stop;\n" .
77 "\$DB::in_debugger=0;\n" .
78 $expr;
79  
80 0 $proc->eval($full_expr, $opts);
81  
82 }
83  
84 1 ▶unless (caller) {
Branch: 1 branch
BranchTrueFalseTotal
unless (caller) 0 12 12
85 # require_relative '../mock'
86 # dbgr, cmd = MockDebugger::setup
87 # arg_str = '1 + 2'
88 # $proc->{cmd_argstr} = $arg_str;
89 # print "eval ${arg_str} is: ${cmd.run([cmd.name, arg_str])}\n";
90 # $arg_str = 'return "foo"';
91 # # sub cmd.proc.current_source_text
92 # # {
93 # # 'return "foo"';
94 # # }
95 # # $proc->{cmd_argstr} = $arg_str;
96 # # print "eval? ${arg_str} is: ${cmd.run([cmd.name + '?'])}\n";
97 }
« example/next2.pl ↑ Summary blib/lib/Devel/Trepan/IO/InOutBase.pm »