| 1 | # -*- coding: utf-8 -*- | ||||||||||||||
| 2 | # Copyright (C) 2011-2014 Rocky Bernstein <rocky@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 | 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::Action; | ||||||||||||||
| 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::Condition ; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 10 | 12 | ▶ | use if !@ISA, Devel::Trepan::CmdProcessor::Command ; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 11 | |||||||||||||||
| 12 | 1 | ▶ | unless (@ISA) { | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 13 | 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
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 14 | use constant ALIASES => qw(a); | ||||||||||||||
| 15 | use constant CATEGORY => 'breakpoints'; | ||||||||||||||
| 16 | use constant NEED_STACK => 0; | ||||||||||||||
| 17 | use constant MIN_ARGS => 2; # Need at least this many | ||||||||||||||
| 18 | use constant MAX_ARGS => undef; # Need at most this many - undef -> unlimited. | ||||||||||||||
| 19 | use constant SHORT_HELP => | ||||||||||||||
| 20 | 'Set an action to be done before the line is executed.'; | ||||||||||||||
| 21 | EOE | ||||||||||||||
| 22 | } | ||||||||||||||
| 23 | |||||||||||||||
| 24 | 12 | ▶ | use strict; use vars qw(@ISA); @ISA = @CMD_ISA; | ||||||||||||
|
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
| |||||||||||||||
| 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 | =pod | ||||||||||||||
| 29 | |||||||||||||||
| 30 | =head2 Synopsis: | ||||||||||||||
| 31 | |||||||||||||||
| 32 | =cut | ||||||||||||||
| 33 | 1 | our $HELP = <<'HELP'; | |||||||||||||
| 34 | =pod | ||||||||||||||
| 35 | |||||||||||||||
| 36 | B<action> I<position> I<Perl-statement> | ||||||||||||||
| 37 | |||||||||||||||
| 38 | Set an action to be done before the line is executed. If line is | ||||||||||||||
| 39 | C<.>, set an action on the line about to be executed. The sequence | ||||||||||||||
| 40 | of steps taken by the debugger is: | ||||||||||||||
| 41 | |||||||||||||||
| 42 | =over | ||||||||||||||
| 43 | |||||||||||||||
| 44 | =item 1. | ||||||||||||||
| 45 | check for a breakpoint at this line | ||||||||||||||
| 46 | |||||||||||||||
| 47 | =item 2. | ||||||||||||||
| 48 | print the line if necessary (tracing) | ||||||||||||||
| 49 | |||||||||||||||
| 50 | =item 3. | ||||||||||||||
| 51 | do any actions associated with that line | ||||||||||||||
| 52 | |||||||||||||||
| 53 | =item 4. | ||||||||||||||
| 54 | prompt user if at a breakpoint or in single-step | ||||||||||||||
| 55 | |||||||||||||||
| 56 | =item 5. | ||||||||||||||
| 57 | evaluate line | ||||||||||||||
| 58 | |||||||||||||||
| 59 | =back | ||||||||||||||
| 60 | |||||||||||||||
| 61 | For example, this will print out the value of C<$foo> every time line | ||||||||||||||
| 62 | 53 is passed: | ||||||||||||||
| 63 | |||||||||||||||
| 64 | =head2 Examples: | ||||||||||||||
| 65 | |||||||||||||||
| 66 | action 53 print "DB FOUND $foo\n" | ||||||||||||||
| 67 | |||||||||||||||
| 68 | =head2 See also: | ||||||||||||||
| 69 | |||||||||||||||
| 70 | C<help breakpoints> | ||||||||||||||
| 71 | |||||||||||||||
| 72 | =cut | ||||||||||||||
| 73 | HELP | ||||||||||||||
| 74 | |||||||||||||||
| 75 | # This method runs the command | ||||||||||||||
| 76 | 0 | ▶ | sub run($$) { | ||||||||||||
|
Subroutine
run: not called CC=5 SCAR=29.7
Subroutine
run: not called CC=5 SCAR=29.7
Pod
undocumented
Pod
undocumented
| |||||||||||||||
| 77 | 0 | my ($self, $args) = @_; | |||||||||||||
| 78 | 0 | my $proc = $self->{proc}; | |||||||||||||
| 79 | 0 | my $frame = $proc->{frame}; | |||||||||||||
| 80 | 0 | my @args = @$args; | |||||||||||||
| 81 | 0 | shift @args; | |||||||||||||
| 82 | |||||||||||||||
| 83 | 0 | my ($filename, $lineno, $fn, $gobble_count, $rest) = | |||||||||||||
| 84 | $proc->parse_position(\@args, 0); # should be: , 1); | ||||||||||||||
| 85 | 0 | ▶ | shift @args if $gobble_count-- > 0; | ||||||||||||
|
Branch: 2 branches
| |||||||||||||||
| 86 | 0 | ▶ | shift @args if $gobble_count-- > 0; | ||||||||||||
|
Branch: 2 branches
| |||||||||||||||
| 87 | # error should have been shown previously | ||||||||||||||
| 88 | |||||||||||||||
| 89 | 0 | my $action_expression = join(' ', @args); | |||||||||||||
| 90 | 0 | ▶ | unless (is_valid_condition($action_expression)) { | ||||||||||||
|
Branch: 2 branches
| |||||||||||||||
| 91 | 0 | $proc->errmsg("Invalid action: $action_expression"); | |||||||||||||
| 92 | return | ||||||||||||||
| 93 | 0 | } | |||||||||||||
| 94 | 0 | my $action = $self->{dbgr}->set_action($lineno, $filename, | |||||||||||||
| 95 | $action_expression); | ||||||||||||||
| 96 | 0 | ▶ | if ($action) { | ||||||||||||
|
Branch: 2 branches
| |||||||||||||||
| 97 | 0 | my $id = $action->id; | |||||||||||||
| 98 | 0 | my $filename = $proc->canonic_file($action->filename); | |||||||||||||
| 99 | 0 | my $line_num = $action->line_num; | |||||||||||||
| 100 | 0 | $proc->{actions}->add($action); | |||||||||||||
| 101 | 0 | $proc->msg("Action $id set in $filename at line $line_num"); | |||||||||||||
| 102 | |||||||||||||||
| 103 | } | ||||||||||||||
| 104 | } | ||||||||||||||
| 105 | |||||||||||||||
| 106 | 1 | ▶ | unless (caller) { | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 107 | 0 | require Devel::Trepan::CmdProcessor::Mock; | |||||||||||||
| 108 | 0 | my $proc = Devel::Trepan::CmdProcessor::Mock::setup(); | |||||||||||||
| 109 | # my $cmd = __PACKAGE__->new($proc); | ||||||||||||||
| 110 | # $cmd->run([$NAME]); | ||||||||||||||
| 111 | } | ||||||||||||||
| 112 | |||||||||||||||
| 113 | 1 | 1; | |||||||||||||