Class: Byebug::CommandProcessor
- Includes:
- ParseFunctions
- Defined in:
- lib/byebug/processors/command_processor.rb
Overview
Processes commands in regular mode
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
Methods included from ParseFunctions
#get_int, #get_line, #get_lines, #lines, #parse_steps, #syntax_valid?
Methods inherited from Processor
Constructor Details
#initialize(interface = LocalInterface.new) ⇒ CommandProcessor
Returns a new instance of CommandProcessor.
8 9 10 11 12 13 14 15 16 17 |
# File 'lib/byebug/processors/command_processor.rb', line 8 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.
6 7 8 |
# File 'lib/byebug/processors/command_processor.rb', line 6 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.
34 35 36 37 38 39 40 41 42 43 |
# File 'lib/byebug/processors/command_processor.rb', line 34 def self.canonic_file(filename) return filename if ['(irb)', '-e'].include?(filename) # For now we want resolved filenames if Setting[:basename] File.basename(filename) else Pathname.new(filename).cleanpath.to_s end end |
.protect(mname) ⇒ Object
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/byebug/processors/command_processor.rb', line 45 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 without_exceptions do puts "INTERNAL ERROR!!! #\{$!\}" puts $!.backtrace.map{|l| "\t#\{l\}"}.join("\n") end end END end |
Instance Method Details
#at_breakpoint(_context, breakpoint) ⇒ Object
66 67 68 69 70 71 |
# File 'lib/byebug/processors/command_processor.rb', line 66 def at_breakpoint(_context, breakpoint) n = Byebug.breakpoints.index(breakpoint) + 1 file = self.class.canonic_file(breakpoint.source) line = breakpoint.pos puts "Stopped by breakpoint #{n} at #{file}:#{line}" end |
#at_catchpoint(context, excpt) ⇒ Object
74 75 76 77 78 |
# File 'lib/byebug/processors/command_processor.rb', line 74 def at_catchpoint(context, excpt) file = self.class.canonic_file(context.frame_file(0)) line = context.frame_line(0) puts "Catchpoint at #{file}:#{line}: `#{excpt}' (#{excpt.class})" end |
#at_line(context, file, line) ⇒ Object
93 94 95 96 |
# File 'lib/byebug/processors/command_processor.rb', line 93 def at_line(context, file, line) Byebug.source_reload if Setting[:autoreload] process_commands(context, file, line) end |
#at_return(context, file, line) ⇒ Object
99 100 101 |
# File 'lib/byebug/processors/command_processor.rb', line 99 def at_return(context, file, line) process_commands(context, file, line) end |
#at_tracing(context, file, line) ⇒ Object
83 84 85 86 87 88 89 90 |
# File 'lib/byebug/processors/command_processor.rb', line 83 def at_tracing(context, file, line) if file != @last_file || line != @last_line || Setting[:tracing_plus] path = self.class.canonic_file(file) @last_file, @last_line = file, line puts "Tracing: #{path}:#{line} #{get_line(file, line)}" end always_run(context, file, line, 2) end |
#interface=(interface) ⇒ Object
19 20 21 22 23 24 |
# File 'lib/byebug/processors/command_processor.rb', line 19 def interface=(interface) @mutex.synchronize do @interface.close if @interface @interface = interface end end |