Module: Debugger

Defined in:
lib/ruby-debug.rb,
lib/ruby-debug/command.rb,
lib/ruby-debug/interface.rb,
lib/ruby-debug/processor.rb,
lib/ruby-debug/xml_printer.rb,
lib/ruby-debug/commands/eval.rb,
lib/ruby-debug/commands/load.rb,
lib/ruby-debug/commands/frame.rb,
lib/ruby-debug/event_processor.rb,
lib/ruby-debug/commands/control.rb,
lib/ruby-debug/commands/inspect.rb,
lib/ruby-debug/commands/threads.rb,
lib/ruby-debug/commands/stepping.rb,
lib/ruby-debug/commands/variables.rb,
lib/ruby-debug/commands/catchpoint.rb,
lib/ruby-debug/commands/breakpoints.rb

Defined Under Namespace

Modules: FrameFunctions, Kernel Classes: AddBreakpoint, BreakpointsCommand, CatchCommand, Command, Context, ContinueCommand, ControlCommandProcessor, ControlState, DeleteBreakpointCommand, DownCommand, EvalCommand, EventProcessor, Exception, FinishCommand, FrameCommand, InspectCommand, InterruptCommand, LoadCommand, LocalInterface, NextCommand, PPCommand, QuitCommand, RemoteInterface, RestartCommand, ScriptInterface, StartCommand, State, StepCommand, ThreadCurrentCommand, ThreadListCommand, ThreadResumeCommand, ThreadStopCommand, ThreadSwitchCommand, UpCommand, VarConstantCommand, VarGlobalCommand, VarInstanceCommand, VarLocalCommand, WhereCommand, XmlPrinter

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.control_threadObject (readonly)

Returns the value of attribute control_thread.



42
43
44
# File 'lib/ruby-debug.rb', line 42

def control_thread
  @control_thread
end

.is_debugObject

Returns the value of attribute is_debug.



41
42
43
# File 'lib/ruby-debug.rb', line 41

def is_debug
  @is_debug
end

.processorObject

Returns the value of attribute processor.



41
42
43
# File 'lib/ruby-debug.rb', line 41

def processor
  @processor
end

Class Method Details

.interruptObject

Interrupts the current thread



47
48
49
# File 'lib/ruby-debug.rb', line 47

def interrupt
  current_context.interrupt
end

.interrupt_lastObject

Interrupts the last debugged thread



54
55
56
57
58
59
60
61
62
# File 'lib/ruby-debug.rb', line 54

def interrupt_last
  skip do
    if context = last_context
      return nil unless context.thread.alive?
      context.interrupt
    end
    context
  end
end

.main(host, port) ⇒ Object



64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
# File 'lib/ruby-debug.rb', line 64

def main(host, port)
  return if started?
  
  start
  
  start_control(host, port)
  
  @mutex = Mutex.new
  @proceed = ConditionVariable.new
  
  # wait for start command
  @mutex.synchronize do
    @proceed.wait(@mutex)
  end 
  
  debug_load Debugger::PROG_SCRIPT
end

.run_prog_scriptObject



82
83
84
85
86
# File 'lib/ruby-debug.rb', line 82

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

.start_control(host, port) ⇒ Object



88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
# File 'lib/ruby-debug.rb', line 88

def start_control(host, port)
  raise "Debugger is not started" unless started?
  return if @control_thread
  @control_thread = DebugThread.new do
    server = TCPServer.new(host, port)
    while (session = server.accept)
      begin
        interface = RemoteInterface.new(session)
        @processor = EventProcessor.new(interface)
        processor = ControlCommandProcessor.new(interface)
        processor.process_commands
      rescue StandardError, ScriptError => ex
        puts ex
      end
    end
  end
end