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 58 |
# File 'lib/byebug/processor.rb', line 48 def self.canonic_file(filename) return '(nil)' if not filename # For now we want resolved filenames if Command.settings[:basename] File.basename(filename) else # Cache this? Pathname.new(filename).cleanpath.to_s end end |
.protect(mname) ⇒ Object
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/byebug/processor.rb', line 60 def self.protect(mname) alias_method "__#{mname}", mname module_eval %{ 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 |
Instance Method Details
#at_breakpoint(context, breakpoint) ⇒ Object
79 80 81 82 83 84 |
# File 'lib/byebug/processor.rb', line 79 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
87 88 89 90 91 92 93 94 95 96 97 98 |
# File 'lib/byebug/processor.rb', line 87 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 fs = context.stack_size tb = caller(0)[-fs..-1] if tb for i in tb print "\tfrom %s\n", i end end end |
#at_line(context, file, line) ⇒ Object
111 112 113 |
# File 'lib/byebug/processor.rb', line 111 def at_line(context, file, line) process_commands(context, file, line) end |
#at_return(context, file, line) ⇒ Object
116 117 118 |
# File 'lib/byebug/processor.rb', line 116 def at_return(context, file, line) process_commands(context, file, line) end |
#at_tracing(context, file, line) ⇒ Object
101 102 103 104 105 106 107 108 |
# File 'lib/byebug/processor.rb', line 101 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 |