| 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
| |||||||||||||||||||||||||||||
| 13 | 2 | $self->{mem} = $mem; | |||||||||||||||||||||||||||
| 14 | 2 | $self->{len} = length($mem); | |||||||||||||||||||||||||||
| 15 | 2 | ▶ | $self->{start} = $args{start} || 0; | ||||||||||||||||||||||||||
|
Condition50%1/2
$args{'start'} || 0
MC/DC0%0/1
$args{'start'} || 0
$args{'start'}
Truth table50%1/2
A
A= $args{'start'}
| |||||||||||||||||||||||||||||
| 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'}
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'}
| |||||||||||||||||||||||||||||
| 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
Condition66%2/3
$pos < 0 or $pos >= $self->{"len"}
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"}
| |||||||||||||||||||||||||||||
| 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
Condition33%1/3
$pos < 0 or $pos + 2 > $self->{"len"}
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"}
| |||||||||||||||||||||||||||||
| 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
Condition33%1/3
$pos < 0 or $pos + 4 > $self->{"len"}
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"}
| |||||||||||||||||||||||||||||
| 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
Condition0%0/3
$pos < 0 or $pos > $self->{"len"}
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"}
| |||||||||||||||||||||||||||||
| 54 | 0 | ▶ | $len ||= "*"; | ||||||||||||||||||||||||||
|
Condition0%0/2
$len ||= "*"
MC/DC0%0/1
$len ||= "*"
$len
Truth table0%0/2
A
A= $len
| |||||||||||||||||||||||||||||
| 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
Condition0%0/3
$pos < 0 or $pos >= $mem_len
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
| |||||||||||||||||||||||||||||
| 63 | 0 | my $str_len = ord substr($self->{mem}, $pos, 1); | |||||||||||||||||||||||||||
| 64 | 0 | ▶ | return undef if $pos+$str_len >= $mem_len; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 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
Condition0%0/3
$pos < 0 or $pos + 2 > $mem_len
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
| |||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||
| 75 | 0 | return substr($self->{mem}, $pos+2, $str_len); | |||||||||||||||||||||||||||
| 76 | } # get_string_lenword | ||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||
| 78 | 1 | 1 # end MemRegion.pm | |||||||||||||||||||||||||||
| 79 | __END__ | ||||||||||||||||||||||||||||