Class: Byebug::DAP::Server
- Inherits:
-
Object
- Object
- Byebug::DAP::Server
- Defined in:
- lib/byebug/dap/server.rb
Overview
Byebug DAP Server
Instance Method Summary collapse
-
#initialize(capture: true, forward: true) ⇒ Server
constructor
Create a new server.
-
#start(host, port = 0) ⇒ Server
Starts the server.
-
#start_stdio ⇒ Server
Starts the server using STDIN and STDOUT to communicate.
-
#start_tcp(host, port) ⇒ Server
Starts the server, listening on a TCP socket.
-
#start_unix(socket) ⇒ Server
Starts the server, listening on a Unix socket.
-
#wait_for_client ⇒ Object
Blocks until a client connects and begins debugging.
Constructor Details
#initialize(capture: true, forward: true) ⇒ Server
Create a new server.
8 9 10 11 12 13 14 15 |
# File 'lib/byebug/dap/server.rb', line 8 def initialize(capture: true, forward: true) @started = false @mu = Mutex.new @cond = ConditionVariable.new @configured = false @capture = capture @forward = forward end |
Instance Method Details
#start(host, port = 0) ⇒ Server
Starts the server. Calls #start_stdio if ‘host == :stdio`. Calls #start_unix with `port` if `host == :unix`. Calls #start_tcp with `host` and `port` otherwise.
23 24 25 26 27 28 29 30 31 32 |
# File 'lib/byebug/dap/server.rb', line 23 def start(host, port = 0) case host when :stdio start_stdio when :unix start_unix port else start_tcp host, port end end |
#start_stdio ⇒ Server
Starts the server using STDIN and STDOUT to communicate.
59 60 61 62 63 64 65 66 67 |
# File 'lib/byebug/dap/server.rb', line 59 def start_stdio return if @started @started = true stream = STDIO.new STDIN.close @ios = CapturedIO.new(false, @forward) if @capture launch stream end |
#start_tcp(host, port) ⇒ Server
Starts the server, listening on a TCP socket.
38 39 40 41 42 43 44 |
# File 'lib/byebug/dap/server.rb', line 38 def start_tcp(host, port) return if @started @started = true @ios = CapturedIO.new(@forward, @forward) if @capture launch_accept TCPServer.new(host, port) end |
#start_unix(socket) ⇒ Server
Starts the server, listening on a Unix socket.
49 50 51 52 53 54 55 |
# File 'lib/byebug/dap/server.rb', line 49 def start_unix(socket) return if @started @started = true @ios = CapturedIO.new(@forward, @forward) if @capture launch_accept UNIXServer.new(socket) end |
#wait_for_client ⇒ Object
Blocks until a client connects and begins debugging.
70 71 72 73 74 75 76 77 78 |
# File 'lib/byebug/dap/server.rb', line 70 def wait_for_client @mu.synchronize do loop do return if @configured @cond.wait(@mu) end end end |