« lib/Devel/Trepan/CmdProcessor/Command/Alias.pm
↑ Summary
blib/lib/Devel/Trepan/CmdProcessor/Command.pm »
| 1 | # -*- coding: utf-8 -*- | ||||||||||||||
| 2 | # Copyright (C) 2011-2012 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::Condition; | ||||||||||||||
| 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(cond); | ||||||||||||||
| 15 | use constant CATEGORY => 'breakpoints'; | ||||||||||||||
| 16 | use constant NEED_STACK => 0; | ||||||||||||||
| 17 | use constant SHORT_HELP => | ||||||||||||||
| 18 | 'Specify a condition on a breakpoint'; | ||||||||||||||
| 19 | use constant MIN_ARGS => 2; # Need at least this many | ||||||||||||||
| 20 | use constant MAX_ARGS => undef; # Need at most this many - undef -> unlimited. | ||||||||||||||
| 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<condition> I<bp-number> I<Perl-expression> | ||||||||||||||
| 37 | |||||||||||||||
| 38 | I<bp-number> is a breakpoint number. I<Perl-expresion> is a Perl | ||||||||||||||
| 39 | expression which must evaluate to true before the breakpoint is | ||||||||||||||
| 40 | honored. If I<perl-expression> is absent, any existing condition is removed; | ||||||||||||||
| 41 | i.e., the breakpoint is made unconditional. | ||||||||||||||
| 42 | |||||||||||||||
| 43 | =head2 Examples: | ||||||||||||||
| 44 | |||||||||||||||
| 45 | condition 5 x > 10 # Breakpoint 5 now has condition x > 10 | ||||||||||||||
| 46 | condition 5 # Remove above condition | ||||||||||||||
| 47 | |||||||||||||||
| 48 | =head2 See also: | ||||||||||||||
| 49 | |||||||||||||||
| 50 | L<C<break>|Devel::Trepan::CmdProcessor::Command::Break>, | ||||||||||||||
| 51 | L<C<enable>|Devel::Trepan::CmdProcessor::Command::Enable> and | ||||||||||||||
| 52 | L<C<disable>|Devel::Trepan::CmdProcessor::Command::Disable>. | ||||||||||||||
| 53 | |||||||||||||||
| 54 | =cut | ||||||||||||||
| 55 | HELP | ||||||||||||||
| 56 | |||||||||||||||
| 57 | # This method runs the command | ||||||||||||||
| 58 | 0 | ▶ | sub run($$) { | ||||||||||||
|
Subroutine
run: not called CC=5 SCAR=30.5
Subroutine
run: not called CC=5 SCAR=30.5
Pod
undocumented
Pod
undocumented
| |||||||||||||||
| 59 | 0 | my ($self, $args) = @_; | |||||||||||||
| 60 | 0 | my $proc = $self->{proc}; | |||||||||||||
| 61 | 0 | my $bpnum = $proc->get_an_int($args->[1]); | |||||||||||||
| 62 | 0 | ▶ | return unless defined($bpnum); | ||||||||||||
|
Branch: 2 branches
| |||||||||||||||
| 63 | 0 | my $bp = $proc->{brkpts}->find($bpnum); | |||||||||||||
| 64 | 0 | ▶ | unless ($bp) { | ||||||||||||
|
Branch: 2 branches
| |||||||||||||||
| 65 | 0 | $proc->errmsg("No breakpoint number $bpnum"); | |||||||||||||
| 66 | 0 | return; | |||||||||||||
| 67 | } | ||||||||||||||
| 68 | |||||||||||||||
| 69 | 0 | my $condition; | |||||||||||||
| 70 | 0 | ▶ | if (scalar @{$args} > 2) { | ||||||||||||
|
Branch: 2 branches
| |||||||||||||||
| 71 | 0 | my @args = @{$args}; | |||||||||||||
| 72 | 0 | shift @args; shift @args; | |||||||||||||
| 73 | 0 | $condition = join(' ', @args); | |||||||||||||
| 74 | 0 | my $msg = &DB::eval_not_ok($condition); | |||||||||||||
| 75 | 0 | ▶ | if ($msg) { | ||||||||||||
|
Branch: 2 branches
| |||||||||||||||
| 76 | 0 | $proc->errmsg("Invalid condition: $condition"); | |||||||||||||
| 77 | 0 | chomp $msg; | |||||||||||||
| 78 | 0 | $proc->errmsg($msg); | |||||||||||||
| 79 | return | ||||||||||||||
| 80 | 0 | } | |||||||||||||
| 81 | } else { | ||||||||||||||
| 82 | 0 | $condition = '1'; | |||||||||||||
| 83 | 0 | $proc->msg('Breakpoint $bp->id is now unconditional.'); | |||||||||||||
| 84 | } | ||||||||||||||
| 85 | 0 | $bp->condition($condition); | |||||||||||||
| 86 | } | ||||||||||||||
| 87 | |||||||||||||||
| 88 | 1 | ▶ | unless (caller) { | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 89 | 0 | require Devel::Trepan::CmdProcessor::Mock; | |||||||||||||
| 90 | 0 | my $proc = Devel::Trepan::CmdProcessor::Mock::setup(); | |||||||||||||
| 91 | # my $cmd = __PACKAGE__->new($proc); | ||||||||||||||
| 92 | # $cmd->run([$NAME]); | ||||||||||||||
| 93 | } | ||||||||||||||
| 94 | |||||||||||||||
| 95 | 1 | 1; | |||||||||||||