Class: Connection::Breakpoint

Inherits:
Base
  • Object
show all
Defined in:
lib/rudebug/connection/breakpoint.rb

Defined Under Namespace

Classes: Session

Constant Summary

Constants inherited from Base

Connection::Base::Code

Instance Attribute Summary

Attributes inherited from Base

#on_disconnect, #on_session

Instance Method Summary collapse

Methods inherited from Base

load_rudebug_code

Instance Method Details

#breakpoint_handler(workspace, message) ⇒ Object



97
98
99
100
101
102
# File 'lib/rudebug/connection/breakpoint.rb', line 97

def breakpoint_handler(workspace, message)
  title = title_filter(message)
  session = Session.new(workspace, title)
  @on_session.call(session)
  sleep 0.1 until session.done?
end

#connect(server) ⇒ Object



51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# File 'lib/rudebug/connection/breakpoint.rb', line 51

def connect(server)
  require 'breakpoint'
  require 'breakpoint/drb'
  require 'drb'

  DRb.start_service()

  @service = DRbObject.new(nil, server)
  @service.eval_handler = method(:eval_handler)
  @service.handler = method(:breakpoint_handler)

  @check_thread = Thread.new(
    @service, @on_disconnect
  ) do |service, on_disconnect|
    loop do
      begin
        service.ping
      rescue DRb::DRbConnError => error
        on_disconnect.call()
        disconnect()
        break
      end

      sleep(0.5)
    end
  end
end

#disconnectObject



79
80
81
82
83
84
85
86
87
88
89
90
91
# File 'lib/rudebug/connection/breakpoint.rb', line 79

def disconnect()
  begin
    @service.handler = nil
    @service.eval_handler = nil
  rescue Exception
  end

  @check_thread.kill if @check_thread
  @check_thread = nil

  DRb.stop_service()
  @service = nil
end

#eval_handler(code) ⇒ Object



104
105
106
107
108
# File 'lib/rudebug/connection/breakpoint.rb', line 104

def eval_handler(code)
  result = eval(code, TOPLEVEL_BINDING)
  Breakpoint.undumpify(result)
  return result
end

#stepping_support?Boolean

Returns:

  • (Boolean)


4
5
6
# File 'lib/rudebug/connection/breakpoint.rb', line 4

def stepping_support?()
  false
end

#title_filter(message) ⇒ Object



93
94
95
# File 'lib/rudebug/connection/breakpoint.rb', line 93

def title_filter(message)
  message[/"([^"]+)"/, 1] || message #"
end