line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package AnyEvent::ITM; |
2
|
|
|
|
|
|
|
our $AUTHORITY = 'cpan:GETTY'; |
3
|
|
|
|
|
|
|
# ABSTRACT: Debug ITM/SWD stream deserializer for AnyEvent |
4
|
|
|
|
|
|
|
$AnyEvent::ITM::VERSION = '0.002'; |
5
|
2
|
|
|
2
|
|
7085
|
use strict; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
81
|
|
6
|
2
|
|
|
2
|
|
13
|
use warnings; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
180
|
|
7
|
2
|
|
|
2
|
|
1145
|
use bytes; |
|
2
|
|
|
|
|
26
|
|
|
2
|
|
|
|
|
7
|
|
8
|
|
|
|
|
|
|
|
9
|
2
|
|
|
2
|
|
1347
|
use AnyEvent::Handle; |
|
2
|
|
|
|
|
39968
|
|
|
2
|
|
|
|
|
77
|
|
10
|
2
|
|
|
2
|
|
19
|
use Carp qw( croak ); |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
115
|
|
11
|
2
|
|
|
2
|
|
1162
|
use ITM; |
|
2
|
|
|
|
|
91490
|
|
|
2
|
|
|
|
|
474
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
AnyEvent::Handle::register_read_type(itm => sub { |
14
|
|
|
|
|
|
|
my ( $self, $cb ) = @_; |
15
|
|
|
|
|
|
|
sub { |
16
|
|
|
|
|
|
|
if (defined $_[0]{rbuf}) { |
17
|
|
|
|
|
|
|
my $first = substr($_[0]{rbuf},0,1); |
18
|
|
|
|
|
|
|
my $len = length($_[0]{rbuf}); |
19
|
|
|
|
|
|
|
my $f = ord($first); |
20
|
|
|
|
|
|
|
my $header = itm_header($first); |
21
|
|
|
|
|
|
|
if ($header) { |
22
|
|
|
|
|
|
|
my $size = $header->{size} ? $header->{size} : 0; |
23
|
|
|
|
|
|
|
my $payload = substr($_[0]{rbuf},1,$size); |
24
|
|
|
|
|
|
|
if (defined $payload && length($payload) == $size) { |
25
|
|
|
|
|
|
|
my $itm = itm_parse($header,$size ? ($payload) : ()); |
26
|
|
|
|
|
|
|
$_[0]{rbuf} = substr($_[0]{rbuf},$size + 1); |
27
|
|
|
|
|
|
|
$cb->( $_[0], $itm ); |
28
|
|
|
|
|
|
|
return 1; |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
return 0; |
31
|
|
|
|
|
|
|
} else { |
32
|
|
|
|
|
|
|
croak sprintf("unknown packet type"); |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
return 0; |
36
|
|
|
|
|
|
|
}; |
37
|
|
|
|
|
|
|
}); |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
1; |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
__END__ |