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,
lib/ruby-debug-ide/commands/file_filtering.rb,
lib/ruby-debug-ide/commands/expression_info.rb
Defined Under Namespace
Modules: EnableDisableFunctions, FrameFunctions, MultiProcess, ParseFunctions Classes: AddBreakpoint, BreakpointsCommand, CatchCommand, Command, ConditionCommand, ContinueCommand, ControlState, DeleteBreakpointCommand, DisableCommand, DownCommand, EnableCommand, EvalCommand, EventProcessor, Exception, ExcludeFile, ExpressionInfoCommand, FileFilterCommand, FinishCommand, FrameCommand, IdeCommandProcessor, IdeControlCommandProcessor, IncludeFile, 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.6.0'
Class Attribute Summary collapse
-
.catchpoint_deleted_event ⇒ Object
protocol extensions.
-
.cli_debug ⇒ Object
Returns the value of attribute cli_debug.
-
.control_thread ⇒ Object
Returns the value of attribute control_thread.
-
.evaluation_timeout ⇒ Object
Returns the value of attribute evaluation_timeout.
-
.interface ⇒ Object
readonly
Returns the value of attribute interface.
-
.value_as_nested_element ⇒ Object
protocol extensions.
-
.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.
- .print_greeting_msg(host, port) ⇒ Object
- .run_prog_script ⇒ Object
- .start_control(host, port, notify_dispatcher) ⇒ Object
- .start_server(host = nil, port = 1234, notify_dispatcher = false) ⇒ Object
Class Attribute Details
.catchpoint_deleted_event ⇒ Object
protocol extensions
48 49 50 |
# File 'lib/ruby-debug-ide.rb', line 48 def catchpoint_deleted_event @catchpoint_deleted_event end |
.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 |
.evaluation_timeout ⇒ Object
Returns the value of attribute evaluation_timeout.
44 45 46 |
# File 'lib/ruby-debug-ide.rb', line 44 def evaluation_timeout @evaluation_timeout 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 |
.value_as_nested_element ⇒ Object
protocol extensions
48 49 50 |
# File 'lib/ruby-debug-ide.rb', line 48 def value_as_nested_element @value_as_nested_element 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
84 85 86 87 88 89 90 91 92 93 |
# File 'lib/ruby-debug-ide.rb', line 84 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
54 55 56 57 58 59 60 61 62 |
# File 'lib/ruby-debug-ide.rb', line 54 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
70 71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/ruby-debug-ide.rb', line 70 def prepare_debugger() @mutex = Mutex.new @proceed = ConditionVariable.new start_server(.host, .port, .notify_dispatcher) raise "Control thread did not start (#{@control_thread}}" unless @control_thread && @control_thread.alive? # 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 |
.print_greeting_msg(host, port) ⇒ Object
139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 |
# File 'lib/ruby-debug-ide.rb', line 139 def print_greeting_msg(host, port) base_gem_name = if defined?(JRUBY_VERSION) || RUBY_VERSION < '1.9.0' 'ruby-debug-base' elsif RUBY_VERSION < '2.0.0' 'ruby-debug-base19x' else 'debase' end file_filtering_support = if Command.file_filter_supported? 'supported' else 'not supported' end $stderr.printf "Fast Debugger (ruby-debug-ide #{IDE_VERSION}, #{base_gem_name} #{VERSION}, file filtering is #{file_filtering_support}) listens on #{host}:#{port}\n" end |
.run_prog_script ⇒ Object
95 96 97 98 99 100 |
# File 'lib/ruby-debug-ide.rb', line 95 def run_prog_script return unless @mutex @mutex.synchronize do @proceed.signal end end |
.start_control(host, port, notify_dispatcher) ⇒ Object
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 136 137 |
# File 'lib/ruby-debug-ide.rb', line 102 def start_control(host, port, notify_dispatcher) 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' server = TCPServer.new(host, port) print_greeting_msg(host, port) notify_dispatcher(port) if notify_dispatcher 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.}(#{ex.class})\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, notify_dispatcher = false) ⇒ Object
64 65 66 67 68 |
# File 'lib/ruby-debug-ide.rb', line 64 def start_server(host = nil, port = 1234, notify_dispatcher = false) return if started? start start_control(host, port, notify_dispatcher) end |