Skip to content

session_name config #1036

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Nov 14, 2023
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
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -504,6 +504,7 @@ config set no_color true
* `RUBY_DEBUG_LOCAL_FS_MAP` (`local_fs_map`): Specify local fs map
* `RUBY_DEBUG_SKIP_BP` (`skip_bp`): Skip breakpoints if no clients are attached (default: false)
* `RUBY_DEBUG_COOKIE` (`cookie`): Cookie for negotiation
* `RUBY_DEBUG_SESSION_NAME` (`session_name`): Session name for differentiating multiple sessions
* `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))

* OBSOLETE
Expand Down Expand Up @@ -883,6 +884,7 @@ Debug console mode:
--port=PORT Listening TCP/IP port
--host=HOST Listening TCP/IP host
--cookie=COOKIE Set a cookie for connection
--session-name=NAME Session name

Debug console mode runs Ruby program with the debug console.

Expand Down
16 changes: 11 additions & 5 deletions lib/debug/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ module DEBUGGER__
local_fs_map: ['RUBY_DEBUG_LOCAL_FS_MAP', "REMOTE: Specify local fs map", :path_map],
skip_bp: ['RUBY_DEBUG_SKIP_BP', "REMOTE: Skip breakpoints if no clients are attached", :bool, 'false'],
cookie: ['RUBY_DEBUG_COOKIE', "REMOTE: Cookie for negotiation"],
session_name: ['RUBY_DEBUG_SESSION_NAME', "REMOTE: Session name for differentiating multiple sessions"],
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))"],

# obsolete
Expand Down Expand Up @@ -340,6 +341,9 @@ def self.parse_argv argv
o.on('--cookie=COOKIE', 'Set a cookie for connection') do |c|
config[:cookie] = c
end
o.on('--session-name=NAME', 'Session name') do |name|
config[:session_name] = name
end

rdbg = 'rdbg'

Expand Down Expand Up @@ -458,7 +462,7 @@ def self.unix_domain_socket_tmpdir
require 'tmpdir'

if tmpdir = Dir.tmpdir
path = File.join(tmpdir, "ruby-debug-sock-#{Process.uid}")
path = File.join(tmpdir, "rdbg-#{Process.uid}")

unless File.exist?(path)
d = Dir.mktmpdir
Expand All @@ -471,7 +475,7 @@ def self.unix_domain_socket_tmpdir

def self.unix_domain_socket_homedir
if home = ENV['HOME']
path = File.join(home, '.ruby-debug-sock')
path = File.join(home, '.rdbg-sock')

unless File.exist?(path)
Dir.mkdir(path, 0700)
Expand All @@ -495,12 +499,14 @@ def self.unix_domain_socket_dir
end

def self.create_unix_domain_socket_name_prefix(base_dir = unix_domain_socket_dir)
user = ENV['USER'] || 'UnknownUser'
File.join(base_dir, "ruby-debug-#{user}")
File.join(base_dir, "rdbg")
end

def self.create_unix_domain_socket_name(base_dir = unix_domain_socket_dir)
create_unix_domain_socket_name_prefix(base_dir) + "-#{Process.pid}"
suffix = "-#{Process.pid}"
name = CONFIG[:session_name]
suffix << "-#{name}" if name
create_unix_domain_socket_name_prefix(base_dir) + suffix
end

## Help
Expand Down
4 changes: 2 additions & 2 deletions test/console/client_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ def test_gen_sockpath
Client.util("gen-sockpath")
end

assert_match(/ruby-debug-/, output)
assert_match(/rdbg-/, output)
end

def test_list_socks
Expand All @@ -19,7 +19,7 @@ def test_list_socks
end

unless output.empty?
assert_match(/ruby-debug-/, output)
assert_match(/rdbg-/, output)
end
end

Expand Down