Class: Byebug::CommandProcessor
- Defined in:
- lib/byebug/processors/command_processor.rb
Defined Under Namespace
Classes: State
Instance Attribute Summary collapse
-
#display ⇒ Object
readonly
Returns the value of attribute display.
Attributes inherited from Processor
Class Method Summary collapse
-
.canonic_file(filename) ⇒ Object
Regularize file name.
- .protect(mname) ⇒ Object
Instance Method Summary collapse
- #at_breakpoint(context, breakpoint) ⇒ Object
- #at_catchpoint(context, excpt) ⇒ Object
- #at_line(context, file, line) ⇒ Object
- #at_return(context, file, line) ⇒ Object
- #at_tracing(context, file, line) ⇒ Object
-
#initialize(interface = LocalInterface.new) ⇒ CommandProcessor
constructor
A new instance of CommandProcessor.
- #interface=(interface) ⇒ Object
Constructor Details
#initialize(interface = LocalInterface.new) ⇒ CommandProcessor
Returns a new instance of CommandProcessor.
6 7 8 9 10 11 12 13 14 15 |
# File 'lib/byebug/processors/command_processor.rb', line 6 def initialize(interface = LocalInterface.new) super(interface) @display = [] @mutex = Mutex.new @last_cmd = nil # To allow empty (just <RET>) commands @last_file = nil # Filename the last time we stopped @last_line = nil # Line number the last time we stopped @context_was_dead = false # Assume we haven't started. end |
Instance Attribute Details
#display ⇒ Object (readonly)
Returns the value of attribute display.
4 5 6 |
# File 'lib/byebug/processors/command_processor.rb', line 4 def display @display end |
Class Method Details
.canonic_file(filename) ⇒ Object
Regularize file name.
This is also used as a common funnel place if basename is desired or if we are working remotely and want to change the basename. Or we are eliding filenames.
32 33 34 35 36 37 38 39 40 41 |
# File 'lib/byebug/processors/command_processor.rb', line 32 def self.canonic_file(filename) return filename if ['(irb)', '-e'].include?(filename) # For now we want resolved filenames if Command.settings[:basename] File.basename(filename) else Pathname.new(filename).cleanpath.to_s end end |
.protect(mname) ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/byebug/processors/command_processor.rb', line 43 def self.protect(mname) alias_method "__#{mname}", mname module_eval <<-END, __FILE__, __LINE__+1 def #{mname}(*args) @mutex.synchronize do return unless @interface __#{mname}(*args) end rescue IOError, SystemCallError @interface.close rescue SignalException raise rescue print "INTERNAL ERROR!!! #\{$!\}\n" rescue nil print $!.backtrace.map{|l| "\t#\{l\}"}.join("\n") rescue nil end END end |
Instance Method Details
#at_breakpoint(context, breakpoint) ⇒ Object
62 63 64 65 66 67 |
# File 'lib/byebug/processors/command_processor.rb', line 62 def at_breakpoint(context, breakpoint) n = Byebug.breakpoints.index(breakpoint) + 1 file = CommandProcessor.canonic_file(breakpoint.source) line = breakpoint.pos print "Stopped by breakpoint #{n} at #{file}:#{line}\n" end |
#at_catchpoint(context, excpt) ⇒ Object
70 71 72 73 74 |
# File 'lib/byebug/processors/command_processor.rb', line 70 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 end |
#at_line(context, file, line) ⇒ Object
87 88 89 90 |
# File 'lib/byebug/processors/command_processor.rb', line 87 def at_line(context, file, line) Byebug.source_reload if Command.settings[:autoreload] process_commands(context, file, line) end |
#at_return(context, file, line) ⇒ Object
93 94 95 |
# File 'lib/byebug/processors/command_processor.rb', line 93 def at_return(context, file, line) process_commands(context, file, line) end |
#at_tracing(context, file, line) ⇒ Object
77 78 79 80 81 82 83 84 |
# File 'lib/byebug/processors/command_processor.rb', line 77 def at_tracing(context, file, line) if file != @last_file || line != @last_line || Command.settings[:linetrace_plus] @last_file, @last_line = file, line print "Tracing: #{CommandProcessor.canonic_file(file)}:#{line} " \ "#{Byebug.line_at(file,line)}\n" end always_run(context, file, line, 2) end |
#interface=(interface) ⇒ Object
17 18 19 20 21 22 |
# File 'lib/byebug/processors/command_processor.rb', line 17 def interface=(interface) @mutex.synchronize do @interface.close if @interface @interface = interface end end |