diff --git a/lib/debugger.rb b/lib/debugger.rb index d36c003616..73a6e8b14a 100644 --- a/lib/debugger.rb +++ b/lib/debugger.rb @@ -130,28 +130,35 @@ def start(offset=0) # stoping at a breakpoint. # def listen(step_into=false) - if @channel - if step_into - @channel << :step - else - @channel << true + while true + if @channel + if step_into + @channel << :step + else + @channel << true + end end - end - # Wait for someone to stop - bp, thr, chan, locs = @local_channel.receive + # Wait for someone to stop + bp, thr, chan, locs = @local_channel.receive - # Uncache all frames since we stopped at a new place - @frames = [] + # Uncache all frames since we stopped at a new place + @frames = [] - @locations = locs - @breakpoint = bp - @debuggee_thread = thr - @channel = chan + @locations = locs + @breakpoint = bp + @debuggee_thread = thr + @channel = chan - @current_frame = frame(0) + @current_frame = frame(0) - bp.hit! if bp + if bp + # Only break out if the hit was valid + break if bp.hit!(locs.first) + else + break + end + end puts info "Breakpoint: #{@current_frame.describe}" diff --git a/lib/debugger/breakpoint.rb b/lib/debugger/breakpoint.rb index 513c7adbb5..e1d1e292d9 100644 --- a/lib/debugger/breakpoint.rb +++ b/lib/debugger/breakpoint.rb @@ -29,9 +29,9 @@ def describe "#{descriptor} - #{location}" end - def for_step! + def for_step!(scope) @temp = true - @for_step = true + @for_step = scope end def set_temp! @@ -58,12 +58,18 @@ def remove! @method.clear_breakpoint(@ip) end - def hit! - return unless @temp + def hit!(loc) + return true unless @temp + + if @for_step + return false unless loc.variables == @for_step + end remove! @paired_bp.remove! if @paired_bp + + return true end def delete! diff --git a/lib/debugger/commands.rb b/lib/debugger/commands.rb index 07a03106e6..565079773d 100644 --- a/lib/debugger/commands.rb +++ b/lib/debugger/commands.rb @@ -255,7 +255,7 @@ def step_to_parent ip = f.ip bp = BreakPoint.for_ip(exec, ip) - bp.for_step! + bp.for_step!(current_frame.variables) bp.activate return bp @@ -273,8 +273,8 @@ def set_breakpoints_between(exec, start_ip, fin_ip) bp1.paired_with(bp2) bp2.paired_with(bp1) - bp1.for_step! - bp2.for_step! + bp1.for_step!(current_frame.variables) + bp2.for_step!(current_frame.variables) bp1.activate bp2.activate @@ -288,7 +288,7 @@ def set_breakpoints_between(exec, start_ip, fin_ip) end bp = BreakPoint.for_ip(exec, ip) - bp.for_step! + bp.for_step!(current_frame.variables) bp.activate return bp @@ -379,7 +379,7 @@ def run(args) line = exec.line_from_ip(next_ip) bp = BreakPoint.for_ip(exec, next_ip) - bp.for_step! + bp.for_step!(current_frame.variables) bp.activate end diff --git a/lib/debugger/frame.rb b/lib/debugger/frame.rb index 92eba683dd..2e8002e74c 100644 --- a/lib/debugger/frame.rb +++ b/lib/debugger/frame.rb @@ -31,6 +31,10 @@ def ip @location.ip end + def variables + @location.variables + end + def local_variables method.local_names end