Class: Connection::RubyDebug::Session

Inherits:
Object
  • Object
show all
Defined in:
lib/rudebug/connection/ruby-debug.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(connection, location) ⇒ Session

Returns a new instance of Session.



11
12
13
14
15
16
17
18
# File 'lib/rudebug/connection/ruby-debug.rb', line 11

def initialize(connection, location)
  @connection = connection
  @location = location
  @title = location.join(":")
  @done = false

  Connection::Base.load_rudebug_code(self)
end

Instance Attribute Details

#titleObject (readonly)

Returns the value of attribute title.



9
10
11
# File 'lib/rudebug/connection/ruby-debug.rb', line 9

def title
  @title
end

Instance Method Details

#continueObject



66
67
68
# File 'lib/rudebug/connection/ruby-debug.rb', line 66

def continue()
  generic_step("cont")
end

#current_fileObject



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

def current_file()
  @location[0]
end

#current_lineObject



46
47
48
# File 'lib/rudebug/connection/ruby-debug.rb', line 46

def current_line()
  @location[1].to_i
end

#eval(code) ⇒ Object



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/rudebug/connection/ruby-debug.rb', line 25

def eval(code)
  cmd = %(
    p begin;
      [eval(%p, nil, *([
         caller[0].split(":")[0],
         caller[0].split(":")[1].to_i
       ] rescue [])).inspect, nil];
    rescue Exception;
      [nil, $!.inspect];
    end
  ).strip.gsub(/\n\s*/, "")
  result, error = *Kernel.eval(execute(cmd % [code, @location]))

  raise(Connection::RemoteException, error) if error
  return result
end

#execute(cmd) ⇒ Object



20
21
22
23
# File 'lib/rudebug/connection/ruby-debug.rb', line 20

def execute(cmd)
  result = @connection.execute(cmd)
  result ? result.chomp : result
end

#generic_step(cmd) ⇒ Object



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

def generic_step(cmd)
  result = execute(cmd)

  if result then
    @connection.location?(result)
  else
    @connection.on_disconnect.call()
    @connection.disconnect()
    return nil
  end
end

#source_code(file) ⇒ Object



50
51
52
# File 'lib/rudebug/connection/ruby-debug.rb', line 50

def source_code(file)
  Kernel.eval(eval("File.read(%p)" % file)).chomp
end

#step_intoObject



70
71
72
# File 'lib/rudebug/connection/ruby-debug.rb', line 70

def step_into()
  generic_step("step")
end

#step_overObject



74
75
76
# File 'lib/rudebug/connection/ruby-debug.rb', line 74

def step_over()
  generic_step("next")
end