Skip to content

Commit

Permalink
Try a fix for #127
Browse files Browse the repository at this point in the history
  • Loading branch information
David Rodríguez committed Mar 25, 2015
1 parent 5f86a3d commit 806fd4a
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 7 deletions.
10 changes: 6 additions & 4 deletions lib/byebug/attacher.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,15 @@ module Byebug
# Enters byebug right before (or right after if _before_ is false) return
# events occur. Before entering byebug the init script is read.
#
def self.attach(steps_out, before)
def self.attach
return errmsg('Byebug already started. Ignoring `byebug` call.') if started?

setup_cmd_line_args

start
run_init_script

current_context.step_out(steps_out, before)
current_context.step_out(2, true)
end
end

Expand All @@ -22,8 +24,8 @@ def self.attach(steps_out, before)
# Dropping a `byebug` call anywhere in your code, you get a debug prompt.
#
module Kernel
def byebug(steps_out = 1, before = true)
Byebug.attach(steps_out + 1, before)
def byebug
Byebug.attach
end

alias_method :debugger, :byebug
Expand Down
3 changes: 2 additions & 1 deletion lib/byebug/commands/tracevar.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ def execute

def on_change(name, value, stop)
puts pr('trace.messages.on_change', name: name, value: value)
byebug(1, false) if stop

@state.context.step_out(1, false) if stop
end

class << self
Expand Down
6 changes: 4 additions & 2 deletions test/commands/eval_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,10 @@ module Byebug
# Toy class to test evaluation in Byebug's prompt
#
class #{example_class}
attr_accessor :thread
def initialize
Thread.new do
@thread = Thread.new do
loop do
sleep 0.01
next if numbers.empty?
Expand Down Expand Up @@ -144,7 +146,7 @@ def calc(number)
byebug
'Processed: ' + worker.squares.join(' ')
worker.thread.kill
end
EOC
end
Expand Down
1 change: 1 addition & 0 deletions test/support/test_case.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ def setup
def teardown
cleanup_namespace
clear_example_file
Byebug.stop
end

#
Expand Down

0 comments on commit 806fd4a

Please sign in to comment.