Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion lib/debug/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,10 @@ def initialize argv
@width = IO.console_size[1]
@width = 80 if @width == 0

send "version: #{VERSION} width: #{@width} cookie: #{CONFIG[:cookie]}"
send "version: #{VERSION} " +
"width: #{@width} " +
"cookie: #{CONFIG[:cookie] || '-'} " +
"nonstop: #{CONFIG[:nonstop] ? 'true' : 'false'}"
end

def deactivate
Expand Down
31 changes: 26 additions & 5 deletions lib/debug/server.rb
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,24 @@ def check_cookie c
end
end

def parse_option params
case params.strip
when /width:\s+(\d+)/
@width = $1.to_i
parse_option $~.post_match
when /cookie:\s+(\S+)/
check_cookie $1 if $1 != '-'
parse_option $~.post_match
when /nonstop: (true|false)/
@need_pause_at_first = false if $1 == 'true'
parse_option $~.post_match
when /(.+):(.+)/
raise GreetingError, "Unkown option: #{params}"
else
# OK
end
end

def greeting
case g = @sock.gets
when /^info cookie:\s+(.*)$/
Expand All @@ -117,16 +135,18 @@ def greeting
@sock.close
raise GreetingError, "HEAD request"

when /^version:\s+(.+)\s+width: (\d+) cookie:\s+(.*)$/
v, w, c = $1, $2, $3
when /^version:\s+(\S+)\s+(.+)$/
v, params = $1, $2

# TODO: protocol version
if v != VERSION
raise GreetingError, "Incompatible version (server:#{VERSION} and client:#{$1})"
end
parse_option(params)

check_cookie c

@width = w.to_i
puts "DEBUGGER (client): Connected. PID:#{Process.pid}, $0:#{$0}"
puts "DEBUGGER (client): Type `Ctrl-C` to enter the debug console." unless @need_pause_at_first
puts

when /^Content-Length: (\d+)/
require_relative 'server_dap'
Expand All @@ -136,6 +156,7 @@ def greeting
@repl = false
@need_pause_at_first = false
dap_setup @sock.read($1.to_i)

when /^GET \/.* HTTP\/1.1/
require_relative 'server_cdp'

Expand Down
2 changes: 1 addition & 1 deletion lib/debug/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# frozen_string_literal: true

module DEBUGGER__
VERSION = "1.5.0"
VERSION = "1.6.0dev1"
end