Class: Byebug::CommandProcessor
- Defined in:
- lib/byebug/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.
22 23 24 25 26 27 28 29 30 31 |
# File 'lib/byebug/processor.rb', line 22 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.
20 21 22 |
# File 'lib/byebug/processor.rb', line 20 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.
48 49 50 51 52 53 54 55 56 57 |
# File 'lib/byebug/processor.rb', line 48 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
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/byebug/processor.rb', line 59 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, Errno::EPIPE self.interface = nil rescue SignalException raise rescue Exception 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
78 79 80 81 82 83 |
# File 'lib/byebug/processor.rb', line 78 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
86 87 88 89 90 |
# File 'lib/byebug/processor.rb', line 86 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
103 104 105 106 |
# File 'lib/byebug/processor.rb', line 103 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
109 110 111 |
# File 'lib/byebug/processor.rb', line 109 def at_return(context, file, line) process_commands(context, file, line) end |
#at_tracing(context, file, line) ⇒ Object
93 94 95 96 97 98 99 100 |
# File 'lib/byebug/processor.rb', line 93 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
33 34 35 36 37 38 |
# File 'lib/byebug/processor.rb', line 33 def interface=(interface) @mutex.synchronize do @interface.close if @interface @interface = interface end end |