X86/MemRegion.pm

filter: Statementstmt 59.6% 34 / 57 Branchbran 27.7% 5 / 18 Conditioncond 20.0% 5 / 25 MC/DCmcdc 6.2% 1 / 16 Subroutinesub 60.0% 9 / 15 Podpod 100% 11 / 11 totaltotal 45.7% 65 / 142 CC 19 SCAR 22.0
CC
19
Cov
44%
get_string
20.0
get_string_lenbyte
20.0
get_string_lenword
20.0
CRAP 9.1
« X86/FormatText.pm ↑ Summary X86/FormatTree.pm »
1 package Disassemble::X86::MemRegion;
2  
3 1 ▶use 5.006;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 ▶use integer;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 2 ▶sub new {
Subroutine new: called CC=3 SCAR=11.1
Pod documented
9 2 my ($class, %args) = @_;
10 2 my $self = bless { } => $class;
11 2 my $mem = $args{mem};
12 2 ▶ defined $mem or $mem = "";
Branch: 1 branch
BranchTrueFalseTotal
defined $mem or $mem = "" 2 0 2
13 2 $self->{mem} = $mem;
14 2 $self->{len} = length($mem);
15 2 ▶ $self->{start} = $args{start} || 0;
Condition50%1/2
$args{'start'} || 0
l!l
02
MC/DC0%0/1
$args{'start'} || 0
$args{'start'}
Truth table50%1/2
A
A= $args{'start'}
Aresult
11
00
16 2 $self->{end} = $self->{start} + $self->{len};
17 2 return $self;
18 } # new
19  
20 0 ▶sub mem { $_[0]->{mem} }
Subroutine mem: not called CC=1 SCAR=6.9
Pod documented
21 2 ▶sub start { $_[0]->{start} }
Subroutine start: called CC=1 SCAR=0.0
Pod documented
22 0 ▶sub end { $_[0]->{end} }
Subroutine end: not called CC=1 SCAR=6.9
Pod documented
23  
24 0 ▶sub contains {
Subroutine contains: not called CC=2 SCAR=17.9
Pod documented
25 0 my ($self, $addr) = @_;
26 0 ▶ return $addr >= $self->{start} && $addr < $self->{end};
Condition0%0/3
$addr >= $self->{'start'} && $addr < $self->{'end'}
!ll&&!rl&&r
000
MC/DC0%0/2
$addr >= $self->{'start'} && $addr < $self->{'end'}
$addr >= $self->{'start'} $addr < $self->{'end'}
Truth table0%0/3
A && B
A= $addr >= $self->{'start'}B= $addr < $self->{'end'}
ABresult
0X0
100
111
27 } # contains
28  
29 1333 ▶sub get_byte {
Subroutine get_byte: called CC=3 SCAR=11.0
Pod documented
30 1333 my ($self, $pos) = @_;
31 1333 $pos -= $self->{start};
32 1333 ▶ return undef if $pos < 0 || $pos >= $self->{len};
Branch: 1 branch
BranchTrueFalseTotal
if $pos < 0 or $pos >= $self->{"len"} 4 1329 1333
Condition66%2/3
$pos < 0 or $pos >= $self->{"len"}
l!l&&r!l&&!r
041329
MC/DC50%1/2
$pos < 0 or $pos >= $self->{"len"}
$pos < 0 $pos >= $self->{"len"}
Truth table66%2/3
A or B
A= $pos < 0B= $pos >= $self->{"len"}
ABresult
1X1
011
000
33 1329 return ord substr($self->{mem}, $pos, 1);
34 } # get_byte
35  
36 64 ▶sub get_word {
Subroutine get_word: called CC=3 SCAR=12.0
Pod documented
37 64 my ($self, $pos) = @_;
38 64 $pos -= $self->{start};
39 64 ▶ return undef if $pos < 0 || $pos+2 > $self->{len};
Branch: 1 branch
BranchTrueFalseTotal
if $pos < 0 or $pos + 2 > $self->{"len"} 0 64 64
Condition33%1/3
$pos < 0 or $pos + 2 > $self->{"len"}
l!l&&r!l&&!r
0064
MC/DC0%0/2
$pos < 0 or $pos + 2 > $self->{"len"}
$pos < 0 $pos + 2 > $self->{"len"}
Truth table33%1/3
A or B
A= $pos < 0B= $pos + 2 > $self->{"len"}
ABresult
1X1
011
000
40 64 return unpack "v", substr($self->{mem}, $pos, 2);
41 } # get_word
42  
43 56 ▶sub get_long {
Subroutine get_long: called CC=3 SCAR=12.0
Pod documented
44 56 my ($self, $pos) = @_;
45 56 $pos -= $self->{start};
46 56 ▶ return undef if $pos < 0 || $pos+4 > $self->{len};
Branch: 1 branch
BranchTrueFalseTotal
if $pos < 0 or $pos + 4 > $self->{"len"} 0 56 56
Condition33%1/3
$pos < 0 or $pos + 4 > $self->{"len"}
l!l&&r!l&&!r
0056
MC/DC0%0/2
$pos < 0 or $pos + 4 > $self->{"len"}
$pos < 0 $pos + 4 > $self->{"len"}
Truth table33%1/3
A or B
A= $pos < 0B= $pos + 4 > $self->{"len"}
ABresult
1X1
011
000
47 56 return unpack "V", substr($self->{mem}, $pos, 4);
48 } # get_long
49  
50 0 ▶sub get_string {
Subroutine get_string: not called CC=4 SCAR=30.0
Pod documented
51 0 my ($self, $pos, $len) = @_;
52 0 $pos -= $self->{start};
53 0 ▶ return undef if $pos < 0 || $pos > $self->{len};
Branch: 1 branch
BranchTrueFalseTotal
if $pos < 0 or $pos > $self->{"len"} 0 0 0
Condition0%0/3
$pos < 0 or $pos > $self->{"len"}
l!l&&r!l&&!r
000
MC/DC0%0/2
$pos < 0 or $pos > $self->{"len"}
$pos < 0 $pos > $self->{"len"}
Truth table0%0/3
A or B
A= $pos < 0B= $pos > $self->{"len"}
ABresult
1X1
011
000
54 0 ▶ $len ||= "*";
Condition0%0/2
$len ||= "*"
l!l
00
MC/DC0%0/1
$len ||= "*"
$len
Truth table0%0/2
A
A= $len
Aresult
11
00
55 0 return unpack "x${pos}Z$len", $self->{mem};
56 } # get_string
57  
58 0 ▶sub get_string_lenbyte {
Subroutine get_string_lenbyte: not called CC=4 SCAR=30.0
Pod documented
59 0 my ($self, $pos) = @_;
60 0 $pos -= $self->{start};
61 0 my $mem_len = $self->{len};
62 0 ▶ return undef if $pos < 0 || $pos >= $mem_len;
Branch: 1 branch
BranchTrueFalseTotal
if $pos < 0 or $pos >= $mem_len 0 0 0
Condition0%0/3
$pos < 0 or $pos >= $mem_len
l!l&&r!l&&!r
000
MC/DC0%0/2
$pos < 0 or $pos >= $mem_len
$pos < 0 $pos >= $mem_len
Truth table0%0/3
A or B
A= $pos < 0B= $pos >= $mem_len
ABresult
1X1
011
000
63 0 my $str_len = ord substr($self->{mem}, $pos, 1);
64 0 ▶ return undef if $pos+$str_len >= $mem_len;
Branch: 1 branch
BranchTrueFalseTotal
if $pos + $str_len >= $mem_len 0 0 0
65 0 return substr($self->{mem}, $pos+1, $str_len);
66 } # get_string_lenbyte
67  
68 0 ▶sub get_string_lenword {
Subroutine get_string_lenword: not called CC=4 SCAR=30.0
Pod documented
69 0 my ($self, $pos) = @_;
70 0 $pos -= $self->{start};
71 0 my $mem_len = $self->{len};
72 0 ▶ return undef if $pos < 0 || $pos+2 > $mem_len;
Branch: 1 branch
BranchTrueFalseTotal
if $pos < 0 or $pos + 2 > $mem_len 0 0 0
Condition0%0/3
$pos < 0 or $pos + 2 > $mem_len
l!l&&r!l&&!r
000
MC/DC0%0/2
$pos < 0 or $pos + 2 > $mem_len
$pos < 0 $pos + 2 > $mem_len
Truth table0%0/3
A or B
A= $pos < 0B= $pos + 2 > $mem_len
ABresult
1X1
011
000
73 0 my $str_len = unpack "v", substr($self->{mem}, $pos, 2);
74 0 ▶ return undef if $pos+$str_len+2 > $mem_len;
Branch: 1 branch
BranchTrueFalseTotal
if $pos + $str_len + 2 > $mem_len 0 0 0
75 0 return substr($self->{mem}, $pos+2, $str_len);
76 } # get_string_lenword
77  
78 1 1 # end MemRegion.pm
79 __END__
« X86/FormatText.pm ↑ Summary X86/FormatTree.pm »