Skip to content

Commit 5c33af4

Browse files
ko1andyjeffries
andcommitted
session_name config
to allow multiple debug sessions. Now session name is used to name UNIX domain socket file name. ``` $ exe/rdbg -O target.rb --session-name=hoge DEBUGGER: Debugger can attach via UNIX domain socket (/run/user/1000/rdbg-230122-hoge) ``` ``` $ RUBY_DEBUG_SESSION_NAME=fuga exe/rdbg -O target.rb DEBUGGER: Debugger can attach via UNIX domain socket (/run/user/1000/rdbg-230150-fuga) ``` Co-authored-by: Andy Jeffries <andy@andyjeffries.co.uk>
1 parent b719b3e commit 5c33af4

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

README.md

+2
Original file line numberDiff line numberDiff line change
@@ -504,6 +504,7 @@ config set no_color true
504504
* `RUBY_DEBUG_LOCAL_FS_MAP` (`local_fs_map`): Specify local fs map
505505
* `RUBY_DEBUG_SKIP_BP` (`skip_bp`): Skip breakpoints if no clients are attached (default: false)
506506
* `RUBY_DEBUG_COOKIE` (`cookie`): Cookie for negotiation
507+
* `RUBY_DEBUG_SESSION_NAME` (`session_name`): Session name for differentiating multiple sessions
507508
* `RUBY_DEBUG_CHROME_PATH` (`chrome_path`): Platform dependent path of Chrome (For more information, See [here](https://github.com/ruby/debug/pull/334/files#diff-5fc3d0a901379a95bc111b86cf0090b03f857edfd0b99a0c1537e26735698453R55-R64))
508509

509510
* OBSOLETE
@@ -883,6 +884,7 @@ Debug console mode:
883884
--port=PORT Listening TCP/IP port
884885
--host=HOST Listening TCP/IP host
885886
--cookie=COOKIE Set a cookie for connection
887+
--session-name=NAME Session name
886888
887889
Debug console mode runs Ruby program with the debug console.
888890

lib/debug/config.rb

+8-1
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ module DEBUGGER__
4949
local_fs_map: ['RUBY_DEBUG_LOCAL_FS_MAP', "REMOTE: Specify local fs map", :path_map],
5050
skip_bp: ['RUBY_DEBUG_SKIP_BP', "REMOTE: Skip breakpoints if no clients are attached", :bool, 'false'],
5151
cookie: ['RUBY_DEBUG_COOKIE', "REMOTE: Cookie for negotiation"],
52+
session_name: ['RUBY_DEBUG_SESSION_NAME', "REMOTE: Session name for differentiating multiple sessions"],
5253
chrome_path: ['RUBY_DEBUG_CHROME_PATH', "REMOTE: Platform dependent path of Chrome (For more information, See [here](https://github.com/ruby/debug/pull/334/files#diff-5fc3d0a901379a95bc111b86cf0090b03f857edfd0b99a0c1537e26735698453R55-R64))"],
5354

5455
# obsolete
@@ -340,6 +341,9 @@ def self.parse_argv argv
340341
o.on('--cookie=COOKIE', 'Set a cookie for connection') do |c|
341342
config[:cookie] = c
342343
end
344+
o.on('--session-name=NAME', 'Session name') do |name|
345+
config[:session_name] = name
346+
end
343347

344348
rdbg = 'rdbg'
345349

@@ -499,7 +503,10 @@ def self.create_unix_domain_socket_name_prefix(base_dir = unix_domain_socket_dir
499503
end
500504

501505
def self.create_unix_domain_socket_name(base_dir = unix_domain_socket_dir)
502-
create_unix_domain_socket_name_prefix(base_dir) + "-#{Process.pid}"
506+
suffix = "-#{Process.pid}"
507+
name = CONFIG[:session_name]
508+
suffix << "-#{name}" if name
509+
create_unix_domain_socket_name_prefix(base_dir) + suffix
503510
end
504511

505512
## Help

0 commit comments

Comments
 (0)