lib/byebug/processor.rb in byebug-2.3.1 vs lib/byebug/processor.rb in byebug-2.4.0

- old
+ new

@@ -56,11 +56,11 @@ end end def self.protect(mname) alias_method "__#{mname}", mname - module_eval %{ + module_eval <<-END, __FILE__, __LINE__+1 def #{mname}(*args) @mutex.synchronize do return unless @interface __#{mname}(*args) end @@ -70,11 +70,11 @@ raise rescue Exception print "INTERNAL ERROR!!! #\{$!\}\n" rescue nil print $!.backtrace.map{|l| "\t#\{l\}"}.join("\n") rescue nil end - } + END end def at_breakpoint(context, breakpoint) n = Byebug.breakpoints.index(breakpoint) + 1 file = CommandProcessor.canonic_file(breakpoint.source) @@ -85,11 +85,10 @@ def at_catchpoint(context, excpt) file = CommandProcessor.canonic_file(context.frame_file(0)) line = context.frame_line(0) print "Catchpoint at %s:%d: `%s' (%s)\n", file, line, excpt, excpt.class - print_backtrace end protect :at_catchpoint def at_tracing(context, file, line) if file != @last_file || line != @last_line || Command.settings[:linetrace_plus] @@ -127,28 +126,26 @@ # "autolist" or "autoirb". # # @return List of commands acceptable to run bound to the current state # def always_run(context, file, line, run_level) - event_cmds = Command.commands.select{|cmd| cmd.event } + cmds = Command.commands # Remove some commands in post-mortem - event_cmds = event_cmds.find_all do |cmd| - cmd.allow_in_post_mortem - end if context.dead? + cmds = cmds.find_all { |cmd| cmd.allow_in_post_mortem } if context.dead? - state = State.new(event_cmds, context, @display, file, @interface, line) + state = State.new(cmds, context, @display, file, @interface, line) # Change default when in irb or code included in command line Command.settings[:autolist] = 0 if ['(irb)', '-e'].include?(file) # Bind commands to the current state. - commands = event_cmds.map{|cmd| cmd.new(state)} + commands = cmds.map { |cmd| cmd.new(state) } - commands.select do |cmd| - cmd.class.always_run >= run_level - end.each {|cmd| cmd.execute} + commands.select { |cmd| cmd.class.always_run >= run_level } + .each { |cmd| cmd.execute } + return state, commands end # # Splits a command line of the form "cmd1 ; cmd2 ; ... ; cmdN" into an @@ -173,10 +170,15 @@ # # Handle byebug commands. # def process_commands(context, file, line) state, commands = always_run(context, file, line, 1) - $state = Command.settings[:testing] ? state : nil + + if Command.settings[:testing] + Thread.current.thread_variable_set('state', state) + else + Thread.current.thread_variable_set('state', nil) + end preloop(commands, context) print state.location if Command.settings[:autolist] == 0 while !state.proceed?