Skip to content

Commit 95df2c5

Browse files
committed
show more information for UNIX domain sockets
If there are some debuggee processes open debug ports with UNIX domain socket, `rdbg -A` client lists possible ports. This patch add more information (pid, $0) for this list.
1 parent 31cb9ee commit 95df2c5

File tree

2 files changed

+25
-7
lines changed

2 files changed

+25
-7
lines changed

lib/debug/client.rb

+23-6
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ def util name
2525
when 'list-socks'
2626
cleanup_unix_domain_sockets
2727
puts list_connections
28+
when 'list-socks-verbose'
29+
cleanup_unix_domain_sockets
30+
puts list_connections verbose: true
2831
when 'setup-autoload'
2932
setup_autoload
3033
else
@@ -91,10 +94,24 @@ def cleanup_unix_domain_sockets
9194
end
9295
end
9396

94-
def list_connections
95-
Dir.glob(DEBUGGER__.create_unix_domain_socket_name_prefix + '*').find_all do |path|
97+
def list_connections verbose: false
98+
socks = Dir.glob(DEBUGGER__.create_unix_domain_socket_name_prefix + '*').find_all do |path|
9699
File.socket?(path)
97100
end
101+
102+
if verbose
103+
socks = socks.map{|sock_path|
104+
Socket.unix(sock_path){|sock|
105+
sock.puts "info cookie: #{CONFIG[:cookie] || '-'}"
106+
pid = sock.gets.chomp
107+
_dbg = sock.gets.chomp
108+
_unm = sock.gets.chomp
109+
[sock_path, pid]
110+
}
111+
}
112+
end
113+
114+
socks
98115
end
99116
end
100117

@@ -148,18 +165,18 @@ def connect_unix name = nil
148165
end
149166
else
150167
Client.cleanup_unix_domain_sockets
151-
files = Client.list_connections
168+
files = Client.list_connections verbose: true
152169

153170
case files.size
154171
when 0
155172
$stderr.puts "No debug session is available."
156173
exit
157174
when 1
158-
@s = Socket.unix(files.first)
175+
@s = Socket.unix(files.first.first)
159176
else
160177
$stderr.puts "Please select a debug session:"
161-
files.each{|f|
162-
$stderr.puts " #{File.basename(f)}"
178+
files.each{|(f, desc)|
179+
$stderr.puts " #{File.basename(f)} (#{desc})"
163180
}
164181
exit
165182
end

lib/debug/server.rb

+2-1
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,8 @@ def greeting
144144

145145
# TODO: protocol version
146146
if v != VERSION
147-
raise GreetingError, "Incompatible version (server:#{VERSION} and client:#{$1})"
147+
@sock.puts msg = "out DEBUGGER: Incompatible version (server:#{VERSION} and client:#{$1})"
148+
raise GreetingError, msg
148149
end
149150
parse_option(params)
150151

0 commit comments

Comments
 (0)