Should this be a mixin?
# File lib/debugger/test/processor.rb, line 3 def print(message) Debugger.handler.interface.print_queue << message end
# File lib/ruby-debug/processor.rb, line 12 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
Format msg with gdb-style annotation header
# File lib/ruby-debug/processor.rb, line 32 def afmt(msg, newline="\n") "\0032\0032#{msg}#{newline}" end
# File lib/ruby-debug/processor.rb, line 36 def aprint(msg) print afmt(msg) if Debugger.annotate.to_i > 2 end
FIXME: use delegate?
# File lib/ruby-debug/processor.rb, line 41 def errmsg(*args) @interface.errmsg(*args) end
Callers of this routine should make sure to use comma to separate format argments rather than %. Otherwise it seems that if the string you want to print has format specifier, which could happen if you are trying to show say a source-code line with “puts” or “print” in it, this print routine will give an error saying it is looking for more arguments.
# File lib/ruby-debug/processor.rb, line 51 def print(*args) @interface.print(*args) end
Split commands like this: split_commands(“abc;def\;ghi;jkl”) => [“abc”, “def;ghi”, “jkl”]
# File lib/ruby-debug/processor.rb, line 57 def split_commands(input) input.split(/(?<!\\);/).map { |e| e.gsub("\\;", ";") } end
Generated with the Darkfish Rdoc Generator 2.