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.3'
FRONT_END =
"debase"

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.attachedObject

Returns the value of attribute attached.



53
54
55
# File 'lib/ruby-debug-ide.rb', line 53

def attached
  @attached
end

.catchpoint_deleted_eventObject

protocol extensions



60
61
62
# File 'lib/ruby-debug-ide.rb', line 60

def catchpoint_deleted_event
  @catchpoint_deleted_event
end

.cli_debugObject

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_threadObject

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_limitObject

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_timeoutObject

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_limitObject

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

.interfaceObject (readonly)

Returns the value of attribute interface.



58
59
60
# File 'lib/ruby-debug-ide.rb', line 58

def interface
  @interface
end

.key_value_modeObject

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_sObject

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_elementObject

protocol extensions



60
61
62
# File 'lib/ruby-debug-ide.rb', line 60

def value_as_nested_element
  @value_as_nested_element
end

.xml_debugObject

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.expand_path(File.dirname(__FILE__) + "/..")) == 0
      next
    end
    if line.index("-e:1") == 0
      break
    end
    cleared << line
  end
  cleared
end

.debug_program(options) ⇒ Object



102
103
104
105
106
107
108
109
110
111
# File 'lib/ruby-debug-ide.rb', line 102

def debug_program(options)
  prepare_debugger(options)

  abs_prog_script = File.expand_path(Debugger::PROG_SCRIPT)
  bt = debug_load(abs_prog_script, options.stop, options.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_lastObject

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



84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
# File 'lib/ruby-debug-ide.rb', line 84

def prepare_debugger(options)
  @mutex = Mutex.new
  @proceed = ConditionVariable.new

  if options.socket_path.nil?
    start_server(options.host, options.port, options.notify_dispatcher)
  else
    start_server_unix(options.socket_path, options.notify_dispatcher)
  end

  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 unless options.skip_wait_for_start
end

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


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
38
39
# File 'lib/ruby-debug-ide/greeter.rb', line 13

def print_greeting_msg(stream, host, port, debugger_name = "Fast", socket_path = nil)
  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"
  elsif socket_path
    listens_on = " listens on #{socket_path}\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_scriptObject



113
114
115
116
117
118
# File 'lib/ruby-debug-ide.rb', line 113

def run_prog_script
  return unless @mutex
  @mutex.synchronize do
    @proceed.signal
  end
end

.start_control(host, port, notify_dispatcher) ⇒ Object



120
121
122
# File 'lib/ruby-debug-ide.rb', line 120

def start_control(host, port, notify_dispatcher)
  _start_control_common(host, port, nil, notify_dispatcher)
end

.start_control_unix(socket_path, notify_dispatcher) ⇒ Object



124
125
126
# File 'lib/ruby-debug-ide.rb', line 124

def start_control_unix(socket_path, notify_dispatcher)
  _start_control_common(nil, 0, socket_path, notify_dispatcher)
end

.start_server(host = nil, port = 1234, notify_dispatcher = false) ⇒ Object



76
77
78
# File 'lib/ruby-debug-ide.rb', line 76

def start_server(host = nil, port = 1234, notify_dispatcher = false)
  _start_server_common(host, port, nil, notify_dispatcher)
end

.start_server_unix(socket_path, notify_dispatcher = false) ⇒ Object



80
81
82
# File 'lib/ruby-debug-ide.rb', line 80

def start_server_unix(socket_path, notify_dispatcher = false)
  _start_server_common(nil, 0, socket_path, notify_dispatcher)
end