Class: Byebug::CommandProcessor
- Defined in:
- lib/byebug/processor.rb
Defined Under Namespace
Classes: State
Constant Summary collapse
- @@Show_breakpoints_postcmd =
FIXME: get from Command regexp method.
[ /^\s*b(?:reak)?/, /^\s* cond(?:ition)? (?:\s+(\d+)\s*(.*))?$/ix, /^\s*del(?:ete)?(?:\s+(.*))?$/ix, /^\s* dis(?:able)? (?:\s+(.*))?$/ix, /^\s* en(?:able)? (?:\s+(.*))?$/ix # "tbreak", "clear", ]
- @@Show_annotations_run =
“tbreak”, “clear”,
[ /^\s*c(?:ont(?:inue)?)?(?:\s+(.*))?$/, /^\s*fin(?:ish)?$/, /^\s*n(?:ext)?([+-])?(?:\s+(.*))?$/, /^\s*s(?:tep)?([+-])?(?:\s+(.*))?$/ ]
- @@Show_annotations_postcmd =
[ /^\s* down (?:\s+(.*))? .*$/x, /^\s* f(?:rame)? (?:\s+ (.*))? \s*$/x, /^\s* u(?:p)? (?:\s+(.*))?$/x ]
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.
50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/byebug/processor.rb', line 50 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.
78 79 80 81 82 83 84 85 86 |
# File 'lib/byebug/processor.rb', line 78 def self.canonic_file(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
88 89 90 91 92 93 94 95 96 97 |
# File 'lib/byebug/processor.rb', line 88 def self.print_location_and_text(file, line) file_line = "#{canonic_file(file)}:#{line}\n" \ "#{Byebug.line_at(file, line)}\n" # 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 %d at %s:%s\n", n, file, line 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
160 161 162 |
# File 'lib/byebug/processor.rb', line 160 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 155 156 157 |
# File 'lib/byebug/processor.rb', line 145 def at_tracing(context, file, line) # Don't trace ourselves return if defined?(Byebug::BYEBUG_SCRIPT) && Byebug::BYEBUG_SCRIPT == file file = CommandProcessor.canonic_file(file) tracing_plus = Command.settings[:tracing_plus] if file != @last_file || line != @last_line || tracing_plus == false @last_file = file @last_line = line print "Tracing: #{file}:#{line} #{Byebug.line_at(file, line)}\n" end always_run(context, file, line, 2) end |
#interface=(interface) ⇒ Object
63 64 65 66 67 68 |
# File 'lib/byebug/processor.rb', line 63 def interface=(interface) @mutex.synchronize do @interface.close if @interface @interface = interface end end |