| 1 | package Devel::ebug::Plugin::Run; | ||||||||||||
| 2 | |||||||||||||
| 3 | 31 | ▶ | use strict; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 4 | 31 | ▶ | use warnings; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 5 | 31 | ▶ | use base qw(Exporter); | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 6 | 31 | our @EXPORT = qw(undo run run_nowait wait_for_stop interrupt return step next); | |||||||||||
| 7 | |||||||||||||
| 8 | 31 | ▶ | use Carp qw(croak); | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 9 | 31 | ▶ | use Devel::ebug::Plugin::Basic (); | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 10 | |||||||||||||
| 11 | 31 | our $VERSION = '0.69'; # VERSION | |||||||||||
| 12 | |||||||||||||
| 13 | # undo | ||||||||||||
| 14 | 4 | ▶ | sub undo { | ||||||||||
|
Subroutine
undo: called CC=4 SCAR=13.9
Pod
undocumented
| |||||||||||||
| 15 | 4 | my($self, $levels) = @_; | |||||||||||
| 16 | 4 | ▶ | $levels ||= 1; | ||||||||||
|
Condition50%1/2
$levels ||= 1
MC/DC0%0/1
$levels ||= 1
$levels
Truth table50%1/2
A
A= $levels
| |||||||||||||
| 17 | 4 | my $response = $self->talk({ command => "commands" }); | |||||||||||
| 18 | 4 | my @commands = @{$response->{commands}}; | |||||||||||
| 19 | 4 | pop @commands foreach 1..$levels; | |||||||||||
| 20 | # use YAML; warn Dump \@commands; | ||||||||||||
| 21 | 4 | my $proc = $self->proc; | |||||||||||
| 22 | 4 | $proc->die; | |||||||||||
| 23 | 4 | $self->load; | |||||||||||
| 24 | 4 | $self->talk($_) foreach @commands; | |||||||||||
| 25 | 4 | $self->basic; | |||||||||||
| 26 | } | ||||||||||||
| 27 | |||||||||||||
| 28 | |||||||||||||
| 29 | |||||||||||||
| 30 | # run until a breakpoint | ||||||||||||
| 31 | 45 | ▶ | sub run { | ||||||||||
|
Subroutine
run: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||
| 32 | 45 | my($self) = @_; | |||||||||||
| 33 | 45 | $self->run_nowait; | |||||||||||
| 34 | 45 | $self->wait_for_stop; | |||||||||||
| 35 | } | ||||||||||||
| 36 | |||||||||||||
| 37 | # start running, without waiting for the program to stop | ||||||||||||
| 38 | 51 | ▶ | sub run_nowait { | ||||||||||
|
Subroutine
run_nowait: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||
| 39 | 51 | my($self) = @_; | |||||||||||
| 40 | 51 | $self->talk({ command => "run" }); | |||||||||||
| 41 | # The backend reads this once it stops again, so the socket becomes | ||||||||||||
| 42 | # readable exactly when the program has stopped. | ||||||||||||
| 43 | 51 | $self->_send({ command => "basic" }); | |||||||||||
| 44 | 51 | $self->running(1); | |||||||||||
| 45 | 51 | return $self; | |||||||||||
| 46 | } | ||||||||||||
| 47 | |||||||||||||
| 48 | # wait for a program started with run_nowait to stop | ||||||||||||
| 49 | 51 | ▶ | sub wait_for_stop { | ||||||||||
|
Subroutine
wait_for_stop: called CC=2 SCAR=7.0
Pod
undocumented
| |||||||||||||
| 50 | 51 | my($self) = @_; | |||||||||||
| 51 | 51 | ▶ | return $self unless $self->running; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 52 | 51 | my $response = $self->_receive; | |||||||||||
| 53 | 44 | $self->running(0); | |||||||||||
| 54 | 44 | Devel::ebug::Plugin::Basic::_basic_response($self, $response); | |||||||||||
| 55 | 44 | return $self; | |||||||||||
| 56 | } | ||||||||||||
| 57 | |||||||||||||
| 58 | # ask a running program to stop at the next statement | ||||||||||||
| 59 | 7 | ▶ | sub interrupt { | ||||||||||
|
Subroutine
interrupt: called CC=6 SCAR=18.3
Pod
undocumented
| |||||||||||||
| 60 | 7 | my($self) = @_; | |||||||||||
| 61 | 7 | ▶ | return 0 unless $self->running; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 62 | 5 | ▶ | croak "interrupt is not supported on $^O" if $^O eq 'MSWin32'; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 63 | 5 | ▶ | croak "interrupt is only supported for programs started with load()" | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 64 | unless $self->proc; | ||||||||||||
| 65 | 4 | ▶ | croak "the debugger did not report the program's process id" | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 66 | unless $self->pid; | ||||||||||||
| 67 | 4 | ▶ | return kill(INT => $self->pid) ? 1 : 0; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 68 | } | ||||||||||||
| 69 | |||||||||||||
| 70 | |||||||||||||
| 71 | # return from a subroutine | ||||||||||||
| 72 | 2 | ▶ | sub return { | ||||||||||
|
Subroutine
return: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||
| 73 | 2 | my($self, @values) = @_; | |||||||||||
| 74 | 2 | my $values; | |||||||||||
| 75 | 2 | ▶ | $values = \@values if @values; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 76 | 2 | my $response = $self->talk({ | |||||||||||
| 77 | command => "return", | ||||||||||||
| 78 | values => $values, | ||||||||||||
| 79 | }); | ||||||||||||
| 80 | 2 | $self->basic; # get basic information for the new line | |||||||||||
| 81 | } | ||||||||||||
| 82 | |||||||||||||
| 83 | |||||||||||||
| 84 | |||||||||||||
| 85 | # step onto the next line (going into subroutines) | ||||||||||||
| 86 | 52 | ▶ | sub step { | ||||||||||
|
Subroutine
step: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||
| 87 | 52 | my($self) = @_; | |||||||||||
| 88 | 52 | my $response = $self->talk({ command => "step" }); | |||||||||||
| 89 | 51 | $self->basic; # get basic information for the new line | |||||||||||
| 90 | } | ||||||||||||
| 91 | |||||||||||||
| 92 | # step onto the next line (going over subroutines) | ||||||||||||
| 93 | 28 | ▶ | sub next { | ||||||||||
|
Subroutine
next: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||
| 94 | 28 | my($self) = @_; | |||||||||||
| 95 | 28 | my $response = $self->talk({ command => "next" }); | |||||||||||
| 96 | 28 | $self->basic; # get basic information for the new line | |||||||||||
| 97 | } | ||||||||||||
| 98 | |||||||||||||
| 99 | 31 | 1; | |||||||||||
| 100 | |||||||||||||
| 101 | __END__ | ||||||||||||