Skip to content

Commit 76fb156

Browse files
committed
Add socket filename prefix as well as suffix
1 parent 2ab4d9f commit 76fb156

File tree

2 files changed

+17
-14
lines changed

2 files changed

+17
-14
lines changed

README.md

+13-14
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ New debug.rb has several advantages:
3131
# Installation
3232

3333
```
34-
$ gem install debug
34+
gem install debug
3535
```
3636

3737
or specify `-Ipath/to/debug/lib` in `RUBYOPT` or each ruby command-line option, especially for debug this gem development.
@@ -71,8 +71,8 @@ If you can modify the source code, you can use the debugger by adding `require '
7171

7272
You can also use its 2 aliases in the same way:
7373

74-
- `binding.b`
75-
- `debugger`
74+
* `binding.b`
75+
* `debugger`
7676

7777
After that, run the program as usual and you will enter the debug console at breakpoints you inserted.
7878

@@ -248,6 +248,7 @@ If you want to run a command written in Ruby like like `rake`, `rails`, `bundle`
248248
* With `-c` option, `rdbg -c <name>` means that `<name>` is command in `PATH` and simply invoke it with the debugger.
249249

250250
Examples:
251+
251252
* `rdbg -c -- rails server`
252253
* `rdbg -c -- bundle exec ruby foo.rb`
253254
* `rdbg -c -- bundle exec rake test`
@@ -335,7 +336,7 @@ If you want to use TCP/IP for the remote debugging, you need to specify the port
335336
To connect to the debuggee, you need to specify the port.
336337

337338
```shell
338-
$ rdbg --attach 12345
339+
rdbg --attach 12345
339340
```
340341

341342
If you want to choose the host to bind, you can use `--host` option.
@@ -353,15 +354,15 @@ Please use it carefully.
353354
By default, UNIX domain socket is used for the debugging port. To use TCP/IP, you can set the `RUBY_DEBUG_PORT` environment variable.
354355

355356
```shell
356-
$ RUBY_DEBUG_PORT=12345 ruby target.rb
357+
RUBY_DEBUG_PORT=12345 ruby target.rb
357358
```
358359

359360
### Integration with external debugger frontend
360361

361362
You can attach with external debugger frontend with VSCode and Chrome.
362363

363364
```
364-
$ rdbg --open=[frontend] target.rb
365+
rdbg --open=[frontend] target.rb
365366
```
366367

367368
will open a debug port and `[frontend]` can attach to the port.
@@ -464,8 +465,6 @@ config set log_level INFO
464465
config set no_color true
465466
```
466467

467-
468-
469468
* UI
470469
* `RUBY_DEBUG_LOG_LEVEL` (`log_level`): Log level same as Logger (default: WARN)
471470
* `RUBY_DEBUG_SHOW_SRC_LINES` (`show_src_lines`): Show n lines source code on breakpoint (default: 10)
@@ -501,6 +500,7 @@ config set no_color true
501500
* `RUBY_DEBUG_HOST` (`host`): TCP/IP remote debugging: host (default: 127.0.0.1)
502501
* `RUBY_DEBUG_SOCK_PATH` (`sock_path`): UNIX Domain Socket remote debugging: socket path
503502
* `RUBY_DEBUG_SOCK_DIR` (`sock_dir`): UNIX Domain Socket remote debugging: socket directory
503+
* `RUBY_DEBUG_SOCK_PREFIX` (`sock_prefix`): UNIX Domain Socket remote debugging: socket prefix
504504
* `RUBY_DEBUG_SOCK_SUFFIX` (`sock_suffix`): UNIX Domain Socket remote debugging: socket suffix
505505
* `RUBY_DEBUG_LOCAL_FS_MAP` (`local_fs_map`): Specify local fs map
506506
* `RUBY_DEBUG_SKIP_BP` (`skip_bp`): Skip breakpoints if no clients are attached (default: false)
@@ -592,9 +592,9 @@ The `<...>` notation means the argument.
592592
* `b[reak] <file>:<line>` or `<file> <line>`
593593
* Set breakpoint on `<file>:<line>`.
594594
* `b[reak] <class>#<name>`
595-
* Set breakpoint on the method `<class>#<name>`.
595+
* Set breakpoint on the method `<class>#<name>`.
596596
* `b[reak] <expr>.<name>`
597-
* Set breakpoint on the method `<expr>.<name>`.
597+
* Set breakpoint on the method `<expr>.<name>`.
598598
* `b[reak] ... if: <expr>`
599599
* break if `<expr>` is true at specified location.
600600
* `b[reak] ... pre: <command>`
@@ -782,7 +782,6 @@ The `<...>` notation means the argument.
782782
* `h[elp] <command>`
783783
* Show help for the given command.
784784

785-
786785
## Debugger API
787786

788787
### Start debugging
@@ -924,12 +923,12 @@ NOTE
924923
925924
# Additional Resources
926925
927-
- [From byebug to ruby/debug](https://st0012.dev/from-byebug-to-ruby-debug) by Stan Lo - A migration guide for `byebug` users.
928-
- [ruby/debug cheatsheet](https://st0012.dev/ruby-debug-cheatsheet) by Stan Lo
926+
* [From byebug to ruby/debug](https://st0012.dev/from-byebug-to-ruby-debug) by Stan Lo - A migration guide for `byebug` users.
927+
* [ruby/debug cheatsheet](https://st0012.dev/ruby-debug-cheatsheet) by Stan Lo
929928
930929
# Contributing
931930
932-
Bug reports and pull requests are welcome on GitHub at https://github.com/ruby/debug.
931+
Bug reports and pull requests are welcome on GitHub at <https://github.com/ruby/debug>.
933932
This debugger is not mature so your feedback will help us.
934933
935934
Please also check the [contributing guideline](/CONTRIBUTING.md).

lib/debug/config.rb

+4
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ module DEBUGGER__
4747
sock_path: ['RUBY_DEBUG_SOCK_PATH', "REMOTE: UNIX Domain Socket remote debugging: socket path"],
4848
sock_dir: ['RUBY_DEBUG_SOCK_DIR', "REMOTE: UNIX Domain Socket remote debugging: socket directory"],
4949
sock_suffix: ['RUBY_DEBUG_SOCK_SUFFIX', "REMOTE: UNIX Domain Socket remote debugging: socket suffix"],
50+
sock_prefix: ['RUBY_DEBUG_SOCK_PREFIX', "REMOTE: UNIX Domain Socket remote debugging: socket prefix"],
5051
local_fs_map: ['RUBY_DEBUG_LOCAL_FS_MAP', "REMOTE: Specify local fs map", :path_map],
5152
skip_bp: ['RUBY_DEBUG_SKIP_BP', "REMOTE: Skip breakpoints if no clients are attached", :bool, 'false'],
5253
cookie: ['RUBY_DEBUG_COOKIE', "REMOTE: Cookie for negotiation"],
@@ -498,6 +499,9 @@ def self.unix_domain_socket_dir
498499
def self.create_unix_domain_socket_name_prefix(base_dir = unix_domain_socket_dir)
499500
user = ENV['USER'] || 'UnknownUser'
500501
filename = "ruby-debug-#{user}"
502+
if !CONFIG[:sock_prefix].nil?
503+
filename = "#{CONFIG[:sock_prefix]}-#{filename}"
504+
end
501505
if !CONFIG[:sock_suffix].nil?
502506
filename += "-#{CONFIG[:sock_suffix]}"
503507
end

0 commit comments

Comments
 (0)