Class: Byebug::CommandProcessor
- Defined in:
- lib/byebug/processor.rb
Defined Under Namespace
Classes: State
Constant Summary collapse
- @@Show_breakpoints_postcmd =
[ Byebug::BreakCommand.new(nil).regexp, Byebug::ConditionCommand.new(nil).regexp, Byebug::DeleteCommand.new(nil).regexp, Byebug::DisableCommand.new(nil).regexp, Byebug::EnableCommand.new(nil).regexp ]
- @@Show_annotations_run =
[ Byebug::ContinueCommand.new(nil).regexp, Byebug::FinishCommand.new(nil).regexp, Byebug::NextCommand.new(nil).regexp, Byebug::StepCommand.new(nil).regexp ]
- @@Show_annotations_postcmd =
[ Byebug::DownCommand.new(nil).regexp, Byebug::FrameCommand.new(nil).regexp, Byebug::UpCommand.new(nil).regexp ]
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.
- .print_location_and_text(file, line) ⇒ Object
- .protect(mname) ⇒ Object
Instance Method Summary collapse
- #at_breakpoint(context, breakpoint) ⇒ Object
- #at_catchpoint(context, excpt) ⇒ Object
- #at_line(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 inherited from Processor
Constructor Details
#initialize(interface = LocalInterface.new) ⇒ CommandProcessor
Returns a new instance of CommandProcessor.
44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/byebug/processor.rb', line 44 def initialize(interface = LocalInterface.new) @interface = interface @display = [] @mutex = Mutex.new @last_cmd = nil @last_file = nil # Filename the last time we stopped @last_line = nil # line number the last time we stopped @byebug_breakpoints_were_empty = false # Show breakpoints 1st time @byebug_displays_were_empty = true # No display 1st time @byebug_context_was_dead = true # Assume we haven't started. end |
Instance Attribute Details
#display ⇒ Object (readonly)
Returns the value of attribute display.
26 27 28 |
# File 'lib/byebug/processor.rb', line 26 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.
72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/byebug/processor.rb', line 72 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 |
.print_location_and_text(file, line) ⇒ Object
84 85 86 87 88 89 90 91 92 93 94 95 96 97 |
# File 'lib/byebug/processor.rb', line 84 def self.print_location_and_text(file, line) if file == '(irb)' file_line = "#{canonic_file(file)} @ #{line}\n" else file_line = "#{canonic_file(file)} @ #{line}\n" \ "#{Byebug.line_at(file, line)}\n" end # FIXME: use annotations routines if Byebug.annotate.to_i > 2 file_line = "\032\032source #{file_line}" end print file_line end |
.protect(mname) ⇒ Object
99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 |
# File 'lib/byebug/processor.rb', line 99 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
118 119 120 121 122 123 124 125 126 127 |
# File 'lib/byebug/processor.rb', line 118 def at_breakpoint(context, breakpoint) aprint 'stopped' if Byebug.annotate.to_i > 2 n = Byebug.breakpoints.index(breakpoint) + 1 file = CommandProcessor.canonic_file(breakpoint.source) line = breakpoint.pos if Byebug.annotate.to_i > 2 print afmt("source #{file}:#{line}") end print "Stopped by breakpoint #{n} at #{file}:#{line}\n" end |
#at_catchpoint(context, excpt) ⇒ Object
130 131 132 133 134 135 136 137 138 139 140 141 142 |
# File 'lib/byebug/processor.rb', line 130 def at_catchpoint(context, excpt) aprint 'stopped' if Byebug.annotate.to_i > 2 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
157 158 159 |
# File 'lib/byebug/processor.rb', line 157 def at_line(context, file, line) process_commands(context, file, line) end |
#at_tracing(context, file, line) ⇒ Object
145 146 147 148 149 150 151 152 153 154 |
# File 'lib/byebug/processor.rb', line 145 def at_tracing(context, file, line) if file != @last_file || line != @last_line || Command.settings[:tracing_plus] == false @last_file = file @last_line = 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
57 58 59 60 61 62 |
# File 'lib/byebug/processor.rb', line 57 def interface=(interface) @mutex.synchronize do @interface.close if @interface @interface = interface end end |