« lib/Devel/Trepan/CmdProcessor/Command/Up.pm
↑ Summary
blib/lib/Devel/Trepan/CmdProcessor/Command/Info_Subcmd/Signals.pm »
| 1 | # -*- coding: utf-8 -*- | ||||||||||||||
| 2 | # Copyright (C) 2011-2012, 2014, 2016 Rocky Bernstein <rocky@cpan.org> | ||||||||||||||
| 3 | 12 | ▶ | use warnings; use utf8; | ||||||||||||
|
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::Watch; | ||||||||||||||
| 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::WatchMgr ; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 10 | 12 | ▶ | use if !@ISA, Devel::Trepan::Condition ; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 11 | 12 | ▶ | use if !@ISA, Devel::Trepan::CmdProcessor::Command ; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 12 | |||||||||||||||
| 13 | 1 | ▶ | unless (@ISA) { | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 14 | 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
| |||||||||||||||
| 15 | # eval "use constant ALIASES => qw(w);"; | ||||||||||||||
| 16 | use constant CATEGORY => 'breakpoints'; | ||||||||||||||
| 17 | use constant NEED_STACK => 0; | ||||||||||||||
| 18 | use constant SHORT_HELP => | ||||||||||||||
| 19 | 'Set to enter debugger when a watched expression changes'; | ||||||||||||||
| 20 | use constant MIN_ARGS => 1; # Need at least this many | ||||||||||||||
| 21 | use constant MAX_ARGS => undef; # Need at most this many - undef -> unlimited. | ||||||||||||||
| 22 | EOE | ||||||||||||||
| 23 | } | ||||||||||||||
| 24 | |||||||||||||||
| 25 | 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
| |||||||||||||||
| 26 | 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
| |||||||||||||||
| 27 | |||||||||||||||
| 28 | 1 | our $NAME = set_name(); | |||||||||||||
| 29 | =pod | ||||||||||||||
| 30 | |||||||||||||||
| 31 | =head2 Synopsis: | ||||||||||||||
| 32 | |||||||||||||||
| 33 | =cut | ||||||||||||||
| 34 | 1 | our $HELP = <<'HELP'; | |||||||||||||
| 35 | =pod | ||||||||||||||
| 36 | |||||||||||||||
| 37 | B<watch> I<Perl-expression> | ||||||||||||||
| 38 | |||||||||||||||
| 39 | Stop every time I<Perl-expression> changes from its prior value. | ||||||||||||||
| 40 | |||||||||||||||
| 41 | =head2 Examples: | ||||||||||||||
| 42 | |||||||||||||||
| 43 | watch $a # enter debugger when the value of $a changes | ||||||||||||||
| 44 | watch scalar(@ARGV)) # enter debugger if size of @ARGV changes. | ||||||||||||||
| 45 | |||||||||||||||
| 46 | =head2 See also | ||||||||||||||
| 47 | |||||||||||||||
| 48 | L<C<delete>|Devel::Trepan::CmdProcessor::Command::Delete>, | ||||||||||||||
| 49 | L<C<enable>|Devel::Trepan::CmdProcessor::Command::Enable>, | ||||||||||||||
| 50 | L<C<disable>|Devel::Trepan::CmdProcessor::Command::Disable>, and | ||||||||||||||
| 51 | L<C<info watch>|Devel::Trepan::CmdProcessor::Command::Watch>. | ||||||||||||||
| 52 | |||||||||||||||
| 53 | =cut | ||||||||||||||
| 54 | HELP | ||||||||||||||
| 55 | |||||||||||||||
| 56 | 12 | ▶ | no warnings 'redefine'; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 57 | |||||||||||||||
| 58 | # This method runs the command | ||||||||||||||
| 59 | 0 | ▶ | sub run($$) { | ||||||||||||
|
Subroutine
run: not called CC=3 SCAR=18.1
Subroutine
run: not called CC=3 SCAR=18.1
Pod
undocumented
Pod
undocumented
| |||||||||||||||
| 60 | 0 | my ($self, $args) = @_; | |||||||||||||
| 61 | 0 | my $proc = $self->{proc}; | |||||||||||||
| 62 | 0 | my $expr; | |||||||||||||
| 63 | 0 | my @args = @{$args}; | |||||||||||||
| 64 | 0 | shift @args; | |||||||||||||
| 65 | |||||||||||||||
| 66 | 0 | $expr = join(' ', @args); | |||||||||||||
| 67 | 0 | ▶ | unless (is_valid_condition($expr)) { | ||||||||||||
|
Branch: 2 branches
| |||||||||||||||
| 68 | 0 | $proc->errmsg("Invalid watch expression: $expr"); | |||||||||||||
| 69 | return | ||||||||||||||
| 70 | 0 | } | |||||||||||||
| 71 | 0 | my $wp = $proc->{dbgr}->{watch}->add($expr); | |||||||||||||
| 72 | 0 | ▶ | if ($wp) { | ||||||||||||
|
Branch: 2 branches
| |||||||||||||||
| 73 | # FIXME: handle someday... | ||||||||||||||
| 74 | # my $cmd_name = $args->[0]; | ||||||||||||||
| 75 | # my $opts->{return_type} = parse_eval_suffix($cmd_name); | ||||||||||||||
| 76 | 0 | my $opts = {return_type => '$'}; | |||||||||||||
| 77 | 0 | my $mess = sprintf("Watch expression %d: %s set", $wp->id, $expr); | |||||||||||||
| 78 | 0 | $proc->msg($mess); | |||||||||||||
| 79 | 0 | $proc->eval($expr, $opts); | |||||||||||||
| 80 | 0 | $proc->{set_wp} = $wp; | |||||||||||||
| 81 | |||||||||||||||
| 82 | # Without setting $DB::trace = 1, it is possible | ||||||||||||||
| 83 | # that a continue won't trigger calls to $DB::DB | ||||||||||||||
| 84 | # and therefore we won't check watch expressions. | ||||||||||||||
| 85 | 12 | ▶ | no warnings 'once'; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 86 | 0 | $DB::trace = 1; | |||||||||||||
| 87 | } | ||||||||||||||
| 88 | } | ||||||||||||||
| 89 | |||||||||||||||
| 90 | 1 | ▶ | unless (caller) { | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 91 | 0 | require Devel::Trepan::CmdProcessor::Mock; | |||||||||||||
| 92 | 0 | my $proc = Devel::Trepan::CmdProcessor::Mock::setup(); | |||||||||||||
| 93 | # my $cmd = __PACKAGE__->new($proc); | ||||||||||||||
| 94 | # $cmd->run([$NAME]); | ||||||||||||||
| 95 | } | ||||||||||||||
| 96 | |||||||||||||||
| 97 | 1 | 1; | |||||||||||||