forked from rocky/rb-trepanning
/
continue.rb
57 lines (49 loc) · 1.72 KB
/
continue.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# Copyright (C) 2010, 2011 Rocky Bernstein <rockyb@rubyforge.net>
require_relative 'base/cmd'
require_relative '../running'
require_relative '../../app/breakpoint' # FIXME: possibly temporary
class Trepan::Command::ContinueCommand < Trepan::Command
unless defined?(HELP)
NAME = File.basename(__FILE__, '.rb')
HELP = <<-HELP
#{NAME} [LOCATION]
Leave the debugger loop and continue execution. Subsequent entry to
the debugger however may occur via breakpoints or explicit calls, or
exceptions.
If a parameter is given, a temporary breakpoint is set at that position
before continuing. Offset are numbers prefixed with an "O" otherwise
the parameter is taken as a line number.
Examples:
#{NAME}
#{NAME} 10 # continue to line 10
#{NAME} o20 # continue to VM Instruction Sequence offset 20
#{NAME} gcd # continue to first instruction of method gcd
#{NAME} IRB.start o7 # continue to IRB.start offset 7
See also 'step', 'next', 'finish', 'nexti' commands and "help location".
HELP
ALIASES = %w(c cont)
CATEGORY = 'running'
MAX_ARGS = 2 # Need at most this many
NEED_RUNNING = true
SHORT_HELP = 'Continue execution of the debugged program'
end
# This is the method that runs the command
def run(args)
if args.size == 1
# Form is: "continue"
@proc.continue
else
iseq, line_number, vm_offset, condition, negate =
@proc.breakpoint_position(@proc.cmd_argstr, false)
return false unless iseq && vm_offset
bp = @proc.breakpoint_offset(vm_offset, iseq, condition, negate)
return unless bp
@proc.continue
end
end
end
if __FILE__ == $0
require_relative '../mock'
dbgr, cmd = MockDebugger::setup
p cmd.run([cmd.name])
end