Module: Debugger
- Defined in:
- lib/ruby-debug-ide/helper.rb,
lib/ruby-debug-ide/command.rb,
lib/ruby-debug-ide/greeter.rb,
lib/ruby-debug-ide/version.rb,
lib/ruby-debug-ide/interface.rb,
lib/ruby-debug-ide/xml_printer.rb,
lib/ruby-debug-ide/multiprocess.rb,
lib/ruby-debug-ide/thread_alias.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/unmonkey.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,
lib/ruby-debug-ide.rb
Defined Under Namespace
Modules: EnableDisableFunctions, FrameFunctions, MultiProcess, OverflowMessageType, ParseFunctions, TimeoutHandler Classes: AddBreakpoint, BreakpointsCommand, CatchCommand, Command, ConditionCommand, ContinueCommand, ControlState, DeleteBreakpointCommand, DetachCommand, DisableCommand, DownCommand, EnableCommand, EvalCommand, EventProcessor, Exception, ExcludeFile, ExecError, ExpressionInfoCommand, FileFilterCommand, FinishCommand, FrameCommand, IdeCommandProcessor, IdeControlCommandProcessor, IncludeFile, InspectCommand, Interface, InterruptCommand, JumpCommand, LoadCommand, LocalInterface, MemoryLimitError, NextCommand, PPCommand, PauseCommand, QuitCommand, RemoteInterface, RestartCommand, SetTypeCommand, SimpleTimeLimitError, StartCommand, State, StepCommand, ThreadCurrentCommand, ThreadInspectCommand, ThreadListCommand, ThreadResumeCommand, ThreadStopCommand, ThreadSwitchCommand, TimeLimitError, UpCommand, VarConstantCommand, VarGlobalCommand, VarInstanceCommand, VarLocalCommand, WhereCommand, XmlPrinter
Constant Summary collapse
- IDE_VERSION =
'0.7.0'
- FRONT_END =
"debase"
Class Attribute Summary collapse
-
.attached ⇒ Object
Returns the value of attribute attached.
-
.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.
-
.debugger_memory_limit ⇒ Object
Returns the value of attribute debugger_memory_limit.
-
.evaluation_timeout ⇒ Object
Returns the value of attribute evaluation_timeout.
-
.inspect_time_limit ⇒ Object
Returns the value of attribute inspect_time_limit.
-
.interface ⇒ Object
readonly
Returns the value of attribute interface.
-
.key_value_mode ⇒ Object
Returns the value of attribute key_value_mode.
-
.trace_to_s ⇒ Object
Returns the value of attribute trace_to_s.
-
.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
- .find_free_port(host) ⇒ 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(stream, host, port, debugger_name = "Fast") ⇒ 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
.attached ⇒ Object
Returns the value of attribute attached.
53 54 55 |
# File 'lib/ruby-debug-ide.rb', line 53 def attached @attached end |
.catchpoint_deleted_event ⇒ Object
protocol extensions
60 61 62 |
# File 'lib/ruby-debug-ide.rb', line 60 def catchpoint_deleted_event @catchpoint_deleted_event end |
.cli_debug ⇒ Object
Returns the value of attribute cli_debug.
55 56 57 |
# File 'lib/ruby-debug-ide.rb', line 55 def cli_debug @cli_debug end |
.control_thread ⇒ Object
Returns the value of attribute control_thread.
57 58 59 |
# File 'lib/ruby-debug-ide.rb', line 57 def control_thread @control_thread end |
.debugger_memory_limit ⇒ Object
Returns the value of attribute debugger_memory_limit.
56 57 58 |
# File 'lib/ruby-debug-ide.rb', line 56 def debugger_memory_limit @debugger_memory_limit end |
.evaluation_timeout ⇒ Object
Returns the value of attribute evaluation_timeout.
55 56 57 |
# File 'lib/ruby-debug-ide.rb', line 55 def evaluation_timeout @evaluation_timeout end |
.inspect_time_limit ⇒ Object
Returns the value of attribute inspect_time_limit.
56 57 58 |
# File 'lib/ruby-debug-ide.rb', line 56 def inspect_time_limit @inspect_time_limit end |
.interface ⇒ Object (readonly)
Returns the value of attribute interface.
58 59 60 |
# File 'lib/ruby-debug-ide.rb', line 58 def interface @interface end |
.key_value_mode ⇒ Object
Returns the value of attribute key_value_mode.
54 55 56 |
# File 'lib/ruby-debug-ide.rb', line 54 def key_value_mode @key_value_mode end |
.trace_to_s ⇒ Object
Returns the value of attribute trace_to_s.
56 57 58 |
# File 'lib/ruby-debug-ide.rb', line 56 def trace_to_s @trace_to_s end |
.value_as_nested_element ⇒ Object
protocol extensions
60 61 62 |
# File 'lib/ruby-debug-ide.rb', line 60 def value_as_nested_element @value_as_nested_element end |
.xml_debug ⇒ Object
Returns the value of attribute xml_debug.
55 56 57 |
# File 'lib/ruby-debug-ide.rb', line 55 def xml_debug @xml_debug end |
Class Method Details
.cleanup_backtrace(backtrace) ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/ruby-debug-ide.rb', line 38 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
96 97 98 99 100 101 102 103 104 105 |
# File 'lib/ruby-debug-ide.rb', line 96 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 |
.find_free_port(host) ⇒ Object
21 22 23 24 25 26 |
# File 'lib/ruby-debug-ide.rb', line 21 def find_free_port(host) server = TCPServer.open(host, 0) port = server.addr[1] server.close port end |
.interrupt_last ⇒ Object
Interrupts the last debugged thread
66 67 68 69 70 71 72 73 74 |
# File 'lib/ruby-debug-ide.rb', line 66 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
82 83 84 85 86 87 88 89 90 91 92 93 94 |
# File 'lib/ruby-debug-ide.rb', line 82 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.
29 30 31 32 33 34 35 36 |
# File 'lib/ruby-debug-ide.rb', line 29 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(stream, host, port, debugger_name = "Fast") ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/ruby-debug-ide/greeter.rb', line 13 def print_greeting_msg(stream, host, port, debugger_name = "Fast") 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 if host && port listens_on = " listens on #{host}:#{port}\n" else listens_on = "\n" end msg = "#{debugger_name} Debugger (ruby-debug-ide #{IDE_VERSION}, #{base_gem_name} #{VERSION}, file filtering is #{file_filtering_support})" + listens_on stream.printf msg end |
.run_prog_script ⇒ Object
107 108 109 110 111 112 |
# File 'lib/ruby-debug-ide.rb', line 107 def run_prog_script return unless @mutex @mutex.synchronize do @proceed.signal end end |
.start_control(host, port, notify_dispatcher) ⇒ Object
114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 |
# File 'lib/ruby-debug-ide.rb', line 114 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 = notify_dispatcher_if_needed(host, port, notify_dispatcher) do |real_port, port_changed| s = TCPServer.new(host, real_port) print_greeting_msg $stderr, host, real_port, port_changed ? "Subprocess" : "Fast" if defined? IDE_VERSION s end return unless server 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
76 77 78 79 80 |
# File 'lib/ruby-debug-ide.rb', line 76 def start_server(host = nil, port = 1234, notify_dispatcher = false) return if started? start start_control(host, port, notify_dispatcher) end |