Module: Debugger
- Defined in:
- lib/ruby-debug-ide.rb,
lib/ruby-debug-ide/helper.rb,
lib/ruby-debug-ide/command.rb,
lib/ruby-debug-ide/version.rb,
lib/ruby-debug-ide/interface.rb,
lib/ruby-debug-ide/xml_printer.rb,
lib/ruby-debug-ide/commands/eval.rb,
lib/ruby-debug-ide/commands/jump.rb,
lib/ruby-debug-ide/commands/load.rb,
lib/ruby-debug-ide/ide_processor.rb,
lib/ruby-debug-ide/commands/frame.rb,
lib/ruby-debug-ide/commands/pause.rb,
lib/ruby-debug-ide/commands/enable.rb,
lib/ruby-debug-ide/event_processor.rb,
lib/ruby-debug-ide/commands/control.rb,
lib/ruby-debug-ide/commands/inspect.rb,
lib/ruby-debug-ide/commands/threads.rb,
lib/ruby-debug-ide/commands/set_type.rb,
lib/ruby-debug-ide/commands/stepping.rb,
lib/ruby-debug-ide/commands/condition.rb,
lib/ruby-debug-ide/commands/variables.rb,
lib/ruby-debug-ide/commands/catchpoint.rb,
lib/ruby-debug-ide/multiprocess/monkey.rb,
lib/ruby-debug-ide/commands/breakpoints.rb,
lib/ruby-debug-ide/multiprocess/pre_child.rb
Defined Under Namespace
Modules: EnableDisableFunctions, FrameFunctions, MultiProcess, ParseFunctions Classes: AddBreakpoint, BreakpointsCommand, CatchCommand, Command, ConditionCommand, ContinueCommand, ControlState, DeleteBreakpointCommand, DisableCommand, DownCommand, EnableCommand, EvalCommand, EventProcessor, Exception, FinishCommand, FrameCommand, IdeCommandProcessor, IdeControlCommandProcessor, InspectCommand, Interface, InterruptCommand, JumpCommand, LoadCommand, LocalInterface, NextCommand, PPCommand, PauseCommand, QuitCommand, RemoteInterface, RestartCommand, SetTypeCommand, StartCommand, State, StepCommand, ThreadCurrentCommand, ThreadInspectCommand, ThreadListCommand, ThreadResumeCommand, ThreadStopCommand, ThreadSwitchCommand, UpCommand, VarConstantCommand, VarGlobalCommand, VarInstanceCommand, VarLocalCommand, WhereCommand, XmlPrinter
Constant Summary collapse
- IDE_VERSION =
'0.4.22'
Class Attribute Summary collapse
-
.cli_debug ⇒ Object
Returns the value of attribute cli_debug.
-
.control_thread ⇒ Object
Returns the value of attribute control_thread.
-
.interface ⇒ Object
readonly
Returns the value of attribute interface.
-
.xml_debug ⇒ Object
Returns the value of attribute xml_debug.
Class Method Summary collapse
- .cleanup_backtrace(backtrace) ⇒ Object
- .debug_program(options) ⇒ Object
-
.interrupt_last ⇒ Object
Interrupts the last debugged thread.
- .prepare_debugger(options) ⇒ Object
-
.print_debug(*args) ⇒ Object
Prints to the stderr using printf(*args) if debug logging flag (-d) is on.
- .run_prog_script ⇒ Object
- .start_control(host, port) ⇒ Object
- .start_server(host = nil, port = 1234) ⇒ Object
Class Attribute Details
.cli_debug ⇒ Object
Returns the value of attribute cli_debug.
44 45 46 |
# File 'lib/ruby-debug-ide.rb', line 44 def cli_debug @cli_debug end |
.control_thread ⇒ Object
Returns the value of attribute control_thread.
45 46 47 |
# File 'lib/ruby-debug-ide.rb', line 45 def control_thread @control_thread end |
.interface ⇒ Object (readonly)
Returns the value of attribute interface.
46 47 48 |
# File 'lib/ruby-debug-ide.rb', line 46 def interface @interface end |
.xml_debug ⇒ Object
Returns the value of attribute xml_debug.
44 45 46 |
# File 'lib/ruby-debug-ide.rb', line 44 def xml_debug @xml_debug end |
Class Method Details
.cleanup_backtrace(backtrace) ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/ruby-debug-ide.rb', line 29 def cleanup_backtrace(backtrace) cleared = [] return cleared unless backtrace backtrace.each do |line| if line.index(File.(File.dirname(__FILE__) + "/..")) == 0 next end if line.index("-e:1") == 0 break end cleared << line end cleared end |
.debug_program(options) ⇒ Object
82 83 84 85 86 87 88 89 90 91 |
# File 'lib/ruby-debug-ide.rb', line 82 def debug_program() prepare_debugger() abs_prog_script = File.(Debugger::PROG_SCRIPT) bt = debug_load(abs_prog_script, .stop, .load_mode) if bt && !bt.is_a?(SystemExit) $stderr.print "Uncaught exception: #{bt}\n" $stderr.print Debugger.cleanup_backtrace(bt.backtrace).map{|l| "\t#{l}"}.join("\n"), "\n" end end |
.interrupt_last ⇒ Object
Interrupts the last debugged thread
52 53 54 55 56 57 58 59 60 |
# File 'lib/ruby-debug-ide.rb', line 52 def interrupt_last skip do if context = last_context return nil unless context.thread.alive? context.interrupt end context end end |
.prepare_debugger(options) ⇒ Object
68 69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/ruby-debug-ide.rb', line 68 def prepare_debugger() start_server(.host, .port) raise "Control thread did not start (#{@control_thread}}" unless @control_thread && @control_thread.alive? @mutex = Mutex.new @proceed = ConditionVariable.new # wait for 'start' command @mutex.synchronize do @proceed.wait(@mutex) end end |
.print_debug(*args) ⇒ Object
Prints to the stderr using printf(*args) if debug logging flag (-d) is on.
20 21 22 23 24 25 26 27 |
# File 'lib/ruby-debug-ide.rb', line 20 def print_debug(*args) if Debugger.cli_debug $stderr.printf("#{Process.pid}: ") $stderr.printf(*args) $stderr.printf("\n") $stderr.flush end end |
.run_prog_script ⇒ Object
93 94 95 96 97 98 |
# File 'lib/ruby-debug-ide.rb', line 93 def run_prog_script return unless @mutex @mutex.synchronize do @proceed.signal end end |
.start_control(host, port) ⇒ Object
100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 |
# File 'lib/ruby-debug-ide.rb', line 100 def start_control(host, port) raise "Debugger is not started" unless started? return if @control_thread @control_thread = DebugThread.new do begin # 127.0.0.1 seemingly works with all systems and with IPv6 as well. # "localhost" and nil have problems on some systems. host ||= '127.0.0.1' gem_name = (defined?(JRUBY_VERSION) || RUBY_VERSION < '1.9.0') ? 'ruby-debug-base' : RUBY_VERSION < '2.0.0' ? 'ruby-debug-base19x' : 'debase' server = TCPServer.new(host, port) $stderr.printf "Fast Debugger (ruby-debug-ide #{IDE_VERSION}, #{gem_name} #{VERSION}) listens on #{host}:#{port}\n" while (session = server.accept) $stderr.puts "Connected from #{session.peeraddr[2]}" if Debugger.cli_debug dispatcher = ENV['IDE_PROCESS_DISPATCHER'] if dispatcher ENV['IDE_PROCESS_DISPATCHER'] = "#{session.peeraddr[2]}:#{dispatcher}" unless dispatcher.include?(":") ENV['DEBUGGER_HOST'] = host end begin @interface = RemoteInterface.new(session) self.handler = EventProcessor.new(interface) IdeControlCommandProcessor.new(interface).process_commands rescue StandardError, ScriptError => ex bt = ex.backtrace $stderr.printf "#{Process.pid}: Exception in DebugThread loop: #{ex.}\nBacktrace:\n#{bt ? bt.join("\n from: ") : "<none>"}\n" exit 1 end end rescue bt = $!.backtrace $stderr.printf "Fatal exception in DebugThread loop: #{$!.}\nBacktrace:\n#{bt ? bt.join("\n from: ") : "<none>"}\n" exit 2 end end end |
.start_server(host = nil, port = 1234) ⇒ Object
62 63 64 65 66 |
# File 'lib/ruby-debug-ide.rb', line 62 def start_server(host = nil, port = 1234) return if started? start start_control(host, port) end |