Skip to content

Commit

Permalink
continue.rb: chase API change. validate.rb: remove crud.
Browse files Browse the repository at this point in the history
  • Loading branch information
rocky committed Mar 10, 2011
1 parent f6a8f6d commit ecbc07a
Show file tree
Hide file tree
Showing 4 changed files with 90 additions and 23 deletions.
2 changes: 1 addition & 1 deletion processor/command/continue.rb
Expand Up @@ -43,7 +43,7 @@ def run(args)
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, condition, negate, iseq)
bp = @proc.breakpoint_offset(vm_offset, iseq, condition, negate)
return unless bp
@proc.continue
end
Expand Down
22 changes: 1 addition & 21 deletions processor/validate.rb
Expand Up @@ -145,26 +145,6 @@ def object_iseq(object_string)
nil
end

def parse_num_or_offset(position_str)
err_str = "argument '%s' does not seem to be an integer" %
position_str.dup
use_offset =
if position_str.size > 0 && position_str[0] == '@'
err_str << 'or an offset.'
position_str[0] = ''
true
else
err_str << '.'
false
end
opts = {
:msg_on_error => err_str,
:min_value => 0
}
position = get_an_int(position_str, opts)
[position, use_offset]
end

def position_to_line_and_offset(iseq, filename, position, offset_type)
case offset_type
when :line
Expand Down Expand Up @@ -208,7 +188,7 @@ def position_to_line_and_offset(iseq, filename, position, offset_type)
# - the line number - a Fixnum
# - vm_offset - a Fixnum
# - the condition (by default 'true') to use for this breakpoint
# - true if 'if' given for condition, false if 'unless'
# - true condition should be negated. Used in *condition* if/unless
def breakpoint_position(position_str, allow_condition)
break_cmd_parse = if allow_condition
parse_breakpoint(position_str)
Expand Down
87 changes: 87 additions & 0 deletions test/functional/test-break-long.rb
@@ -0,0 +1,87 @@
#!/usr/bin/env ruby
require 'test/unit'
require 'trace'
require_relative 'fn_helper'
require_relative '../../app/breakpoint'

class TestBreakLong < Test::Unit::TestCase

include FnTestHelper

def setup
Trepan::Breakpoint::reset
end

def test_break_same_level

# See that we can stop at a breakpoint
cmds = ['set basename on',
'break ' + (__LINE__ + 7).to_s,
'continue']
d = strarray_setup(cmds)
d.start
########### b1 ###############
x = 5
y = 6
z = 7
##############################
d.stop
out = ['-- ',
'x = 5',
'basename is on.',
"Breakpoint 1 set at VM offset 55 of instruction sequence \"test_break_same_level\",
\tline 55 in file foo.rb",
'xx ',
'z = 7']
compare_output(out, d, cmds)

# Try a disabling the breakpoint
cmds = ['set basename on',
'break ' + (__LINE__ + 8).to_s,
'break ' + (__LINE__ + 8).to_s,
'disable 1',
'continue']
d = strarray_setup(cmds)
d.start
########### b2 ###############
x = 7
y = 8
z = 8+1
##############################
d.stop
out = ['-- ',
'x = 7',
"basename is on.",
"Breakpoint 1 set at VM offset 55 of instruction sequence \"test_break_same_level\",
\tline 55 in file foo.rb",
"Breakpoint 2 set at VM offset 55 of instruction sequence \"test_break_same_level\",
\tline 55 in file foo.rb",
"Breakpoint 1 disabled.",
'xx ',
'z = 8+1']
compare_output(out, d, cmds)

# Stepping after a breakpoint should not stay at same location.
cmds = ['set basename on',
'continue ' + (__LINE__ + 8).to_s,
'continue']
dbg = strarray_setup(cmds)
dbg.start
########### b3 ###############
a = 1
b = 2
c = 3
d = 4
e = 5
##############################
dbg.stop
out = ['-- ',
'a = 1',
'basename is on.',
'xx ',
'd = 4' ]
compare_output(out, dbg, cmds)
end

end

2 changes: 1 addition & 1 deletion test/functional/test-break.rb
Expand Up @@ -2,7 +2,7 @@
require 'test/unit'
require_relative 'fn_helper'

class TestBreak2 < Test::Unit::TestCase
class TestBreak < Test::Unit::TestCase

include FnTestHelper

Expand Down

0 comments on commit ecbc07a

Please sign in to comment.