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/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 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.6.1'
- 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.
-
.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
-
.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) ⇒ 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.
46 47 48 |
# File 'lib/ruby-debug-ide.rb', line 46 def attached @attached end |
.catchpoint_deleted_event ⇒ Object
protocol extensions
52 53 54 |
# File 'lib/ruby-debug-ide.rb', line 52 def catchpoint_deleted_event @catchpoint_deleted_event end |
.cli_debug ⇒ Object
Returns the value of attribute cli_debug.
47 48 49 |
# File 'lib/ruby-debug-ide.rb', line 47 def cli_debug @cli_debug end |
.control_thread ⇒ Object
Returns the value of attribute control_thread.
49 50 51 |
# File 'lib/ruby-debug-ide.rb', line 49 def control_thread @control_thread end |
.debugger_memory_limit ⇒ Object
Returns the value of attribute debugger_memory_limit.
48 49 50 |
# File 'lib/ruby-debug-ide.rb', line 48 def debugger_memory_limit @debugger_memory_limit end |
.evaluation_timeout ⇒ Object
Returns the value of attribute evaluation_timeout.
47 48 49 |
# File 'lib/ruby-debug-ide.rb', line 47 def evaluation_timeout @evaluation_timeout end |
.inspect_time_limit ⇒ Object
Returns the value of attribute inspect_time_limit.
48 49 50 |
# File 'lib/ruby-debug-ide.rb', line 48 def inspect_time_limit @inspect_time_limit end |
.interface ⇒ Object (readonly)
Returns the value of attribute interface.
50 51 52 |
# File 'lib/ruby-debug-ide.rb', line 50 def interface @interface end |
.trace_to_s ⇒ Object
Returns the value of attribute trace_to_s.
48 49 50 |
# File 'lib/ruby-debug-ide.rb', line 48 def trace_to_s @trace_to_s end |
.value_as_nested_element ⇒ Object
protocol extensions
52 53 54 |
# File 'lib/ruby-debug-ide.rb', line 52 def value_as_nested_element @value_as_nested_element end |
.xml_debug ⇒ Object
Returns the value of attribute xml_debug.
47 48 49 |
# File 'lib/ruby-debug-ide.rb', line 47 def xml_debug @xml_debug end |
Class Method Details
.cleanup_backtrace(backtrace) ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/ruby-debug-ide.rb', line 31 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
88 89 90 91 92 93 94 95 96 97 |
# File 'lib/ruby-debug-ide.rb', line 88 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
58 59 60 61 62 63 64 65 66 |
# File 'lib/ruby-debug-ide.rb', line 58 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
74 75 76 77 78 79 80 81 82 83 84 85 86 |
# File 'lib/ruby-debug-ide.rb', line 74 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.
22 23 24 25 26 27 28 29 |
# File 'lib/ruby-debug-ide.rb', line 22 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) ⇒ 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) 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 = "Fast 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
99 100 101 102 103 104 |
# File 'lib/ruby-debug-ide.rb', line 99 def run_prog_script return unless @mutex @mutex.synchronize do @proceed.signal end end |
.start_control(host, port, notify_dispatcher) ⇒ Object
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 138 139 140 |
# File 'lib/ruby-debug-ide.rb', line 106 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($stderr, host, port) if defined? IDE_VERSION 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
68 69 70 71 72 |
# File 'lib/ruby-debug-ide.rb', line 68 def start_server(host = nil, port = 1234, notify_dispatcher = false) return if started? start start_control(host, port, notify_dispatcher) end |