File Coverage

lib/Devel/Trepan/CmdProcessor/Command/Handle.pm
Criterion Covered Total %
statement 57 69 82.6
branch 0 4 0.0
condition 0 6 0.0
subroutine 19 21 90.4
pod 0 2 0.0
total 76 102 74.5


line stmt bran cond sub pod time code
1             # -*- coding: utf-8 -*-
2             # Copyright (C) 2011-2012, 2014 Rocky Bernstein
3             #
4             # This program is free software: you can redistribute it and/or modify
5             # it under the terms of the GNU General Public License as published by
6             # the Free Software Foundation, either version 3 of the License, or
7             # (at your option) any later version.
8             #
9             # This program is distributed in the hope that it will be useful,
10             # but WITHOUT ANY WARRANTY; without even the implied warranty of
11             # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12             # GNU General Public License for more details.
13             #
14             # You should have received a copy of the GNU General Public License
15             # along with this program. If not, see <http://www.gnu.org/licenses/>.
16 12     12   91 use warnings; no warnings 'redefine';
  12     12   26  
  12     1   373  
  12     1   72  
  12         26  
  12         552  
  1         7  
  1         1  
  1         23  
  1         4  
  1         3  
  1         35  
17              
18             package Devel::Trepan::CmdProcessor::Command::Handle;
19 12     12   60 use English qw( -no_match_vars );
  12     1   23  
  12         98  
  1         5  
  1         2  
  1         6  
20 12     12   4724 use if !@ISA, Devel::Trepan::CmdProcessor::Command ;
  12     1   24  
  12         104  
  1         265  
  1         2  
  1         6  
21              
22             unless (@ISA) {
23 12     12   65 eval <<"EOE";
  12     12   25  
  12     12   659  
  12     12   72  
  12     12   26  
  12         827  
  12         68  
  12         27  
  12         483  
  12         625  
  12         35  
  12         527  
  12         72  
  12         29  
  12         427  
24             use constant CATEGORY => 'running';
25             use constant NEED_STACK => 0;
26             use constant SHORT_HELP =>
27             'Specify a how to handle a signal';
28             use constant MIN_ARGS => 1; # Need at least this many
29             use constant MAX_ARGS => undef; # Need at most this many - undef -> unlimited.
30             EOE
31             }
32              
33 12     12   1854 use strict; use vars qw(@ISA); @ISA = @CMD_ISA;
  12     12   26  
  12     1   329  
  12     1   58  
  12         21  
  12         712  
  1         51  
  1         9  
  1         24  
  1         4  
  1         2  
  1         50  
34 12     12   76 use vars @CMD_VARS; # Value inherited from parent
  12     1   24  
  12         3873  
  1         5  
  1         3  
  1         282  
35              
36             our $NAME = set_name();
37             =pod
38              
39             =head2 Synopsis:
40              
41             =cut
42             our $HELP = <<'HELP';
43             =pod
44              
45             B<handle> [I<sig> [I<action1> I<action2> ...]]
46              
47             Specify how to handle a signal SIG. SIG can be a signal name like
48             SIGINT or a signal number like 2. The absolute value is used for
49             numbers so -9 is the same as 9 (SIGKILL). When signal names are used,
50             you can drop off the leading "SIG" if you want. Also letter case is
51             not important either.
52              
53             Arguments are signals and actions to apply to those signals.
54             recognized actions include "stop", "nostop", "print", "noprint",
55             "pass", "nopass", "ignore", or "noignore".
56              
57             =over
58              
59             =item *
60              
61             C<stop> means reenter debugger if this signal happens (implies
62             C<print> and C<nopass>).
63              
64             =item *
65             C<Print> means print a message if this signal happens.
66              
67             =item *
68             C<Pass> means let program see this signal; otherwise the program see
69             it.
70              
71             =item *
72             C<Ignore> is a synonym for C<nopass>; C<noignore> is a synonym for
73             C<pass>.
74              
75             =back
76              
77             Without any action names the current settings are shown.
78              
79             =head2 Examples:
80              
81             handle INT # Show current settings of SIGINT
82             handle SIGINT # same as above
83             handle int # same as above
84             handle 2 # Probably the same as above
85             handle -2 # the same as above
86             handle INT nostop # Don't stop in the debugger on SIGINT
87              
88             =head2 See also:
89              
90             L<C<info signals>|Devel::Trepan::CmdProcessor::Command::Info::Signals>
91             =cut
92             HELP
93              
94             sub run($$) {
95 0     0 0   my ($self, $args) = @_;
  0     0 0    
96 0           my $proc = $self->{proc};
  0            
97              
98 0           my $sigmgr = $self->{dbgr}{sigmgr};
  0            
99 0 0 0       if ($sigmgr->action($proc->{cmd_argstr}) &&
  0 0 0        
100 0           scalar(@{$args}) > 2) {
  0            
101             # Show results of recent change
102 0           $sigmgr->info_signal([$args->[1]]);
  0            
103             }
104             }
105              
106             unless(caller) {
107             require Devel::Trepan::DB;
108             require Devel::Trepan::Core;
109             my $db = Devel::Trepan::Core->new;
110             my $intf = Devel::Trepan::Interface::User->new(undef, undef, {readline => 0});
111             my $proc = Devel::Trepan::CmdProcessor->new([$intf], $db);
112             my $cmd = __PACKAGE__->new($proc);
113             $cmd->run([$NAME]);
114             }