| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
# Copyright (C) 2011-2012 Rocky Bernstein <rocky@cpan.org> |
|
2
|
|
|
|
|
|
|
# classes to support communication to and from the debugger. This |
|
3
|
|
|
|
|
|
|
# communcation might be to/from another process or another computer. |
|
4
|
|
|
|
|
|
|
# And reading may be from a debugger command script. |
|
5
|
|
|
|
|
|
|
# |
|
6
|
|
|
|
|
|
|
# For example, we'd like to support Sockets, and serial lines and file |
|
7
|
|
|
|
|
|
|
# reading, as well a readline-type input. Encryption and Authentication |
|
8
|
|
|
|
|
|
|
# methods might decorate some of the communication channels. |
|
9
|
|
|
|
|
|
|
# |
|
10
|
|
|
|
|
|
|
# Some ideas originiated as part of Matt Fleming's 2006 Google Summer of |
|
11
|
|
|
|
|
|
|
# Code project. |
|
12
|
|
|
|
|
|
|
|
|
13
|
15
|
|
|
15
|
|
17771
|
use strict; |
|
|
15
|
|
|
|
|
40
|
|
|
|
15
|
|
|
|
|
389
|
|
|
14
|
15
|
|
|
15
|
|
76
|
use Exporter; |
|
|
15
|
|
|
|
|
45
|
|
|
|
15
|
|
|
|
|
446
|
|
|
15
|
15
|
|
|
15
|
|
81
|
use warnings; |
|
|
15
|
|
|
|
|
33
|
|
|
|
15
|
|
|
|
|
363
|
|
|
16
|
|
|
|
|
|
|
|
|
17
|
15
|
|
|
15
|
|
82
|
use rlib '../../..'; |
|
|
15
|
|
|
|
|
34
|
|
|
|
15
|
|
|
|
|
80
|
|
|
18
|
15
|
|
|
15
|
|
4905
|
use IO::Handle; |
|
|
15
|
|
|
|
|
4629
|
|
|
|
15
|
|
|
|
|
739
|
|
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
# This is an abstract class that specifies debugger output. |
|
21
|
|
|
|
|
|
|
package Devel::Trepan::IO::Output; |
|
22
|
|
|
|
|
|
|
# use Devel::Trepan::Util qw(hash_merge); |
|
23
|
|
|
|
|
|
|
|
|
24
|
15
|
|
|
15
|
|
89
|
use vars qw(@EXPORT @EXPORT_OK); |
|
|
15
|
|
|
|
|
34
|
|
|
|
15
|
|
|
|
|
5964
|
|
|
25
|
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub new($;$$) { |
|
27
|
14
|
|
|
14
|
0
|
182
|
my($class, $output, $opts) = @_; |
|
28
|
14
|
|
50
|
|
|
2007
|
$opts ||= {}; |
|
29
|
14
|
50
|
|
|
|
55
|
unless ($output) { |
|
30
|
14
|
|
|
|
|
217
|
open STDOUT_DUP, ">&", STDOUT; |
|
31
|
14
|
|
|
|
|
78
|
$output = *STDOUT_DUP; |
|
32
|
|
|
|
|
|
|
}; |
|
33
|
14
|
|
|
|
|
79
|
my $self = { |
|
34
|
|
|
|
|
|
|
flush_after_write => 0, |
|
35
|
|
|
|
|
|
|
output => $output, |
|
36
|
|
|
|
|
|
|
eof => 0 |
|
37
|
|
|
|
|
|
|
}; |
|
38
|
14
|
|
|
|
|
44
|
bless $self, $class; |
|
39
|
14
|
|
|
|
|
159
|
return $self; |
|
40
|
|
|
|
|
|
|
} |
|
41
|
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
sub is_closed($) { |
|
43
|
1
|
|
|
1
|
0
|
2
|
my($self) = @_; |
|
44
|
1
|
50
|
|
|
|
8
|
! $self->{output} || $self->is_eof; |
|
45
|
|
|
|
|
|
|
} |
|
46
|
|
|
|
|
|
|
sub close($) { |
|
47
|
0
|
|
|
0
|
0
|
0
|
my($self) = @_; |
|
48
|
0
|
0
|
|
|
|
0
|
close $self->{output} unless $self->is_closed; |
|
49
|
0
|
|
|
|
|
0
|
$self->{eof} = 1; |
|
50
|
|
|
|
|
|
|
} |
|
51
|
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
sub is_eof($) { |
|
53
|
1
|
|
|
1
|
0
|
3
|
my($self) = @_; |
|
54
|
1
|
|
|
|
|
6
|
return $self->{eof}; |
|
55
|
|
|
|
|
|
|
} |
|
56
|
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
sub flush($) { |
|
58
|
0
|
|
|
0
|
0
|
0
|
my($self) = @_; |
|
59
|
0
|
|
|
|
|
0
|
$self->{output}->autoflush(1); |
|
60
|
|
|
|
|
|
|
} |
|
61
|
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
# Use this to set where to write to. output can be a |
|
63
|
|
|
|
|
|
|
# file object or a string. This code raises IOError on error. |
|
64
|
|
|
|
|
|
|
sub write($$) { |
|
65
|
0
|
|
|
0
|
0
|
0
|
my ($self, $msg) = @_; |
|
66
|
0
|
|
|
|
|
0
|
print {$self->{output}} $msg; |
|
|
0
|
|
|
|
|
0
|
|
|
67
|
|
|
|
|
|
|
} |
|
68
|
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
# used to write to a debugger that is connected to this |
|
70
|
|
|
|
|
|
|
# `str' written will have a newline added to it |
|
71
|
|
|
|
|
|
|
# |
|
72
|
|
|
|
|
|
|
sub writeline($$) { |
|
73
|
1
|
|
|
1
|
0
|
13
|
my ($self, $msg) = @_; |
|
74
|
1
|
50
|
|
|
|
3
|
print {$self->{output}} $msg . "\n" unless $self->is_closed(); |
|
|
1
|
|
|
|
|
20
|
|
|
75
|
|
|
|
|
|
|
} |
|
76
|
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
if (__FILE__ eq $0) { |
|
78
|
|
|
|
|
|
|
my $out = Devel::Trepan::IO::Output->new(); |
|
79
|
|
|
|
|
|
|
CORE::close(STDOUT); |
|
80
|
|
|
|
|
|
|
$out->writeline("Now is the time!"); |
|
81
|
|
|
|
|
|
|
} |
|
82
|
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
1; |