Skip to content

Commit

Permalink
Add socket filename prefix as well as suffix
Browse files Browse the repository at this point in the history
  • Loading branch information
andyjeffries committed Sep 25, 2023
1 parent 2ab4d9f commit 76fb156
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 14 deletions.
27 changes: 13 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ New debug.rb has several advantages:
# Installation

```
$ gem install debug
gem install debug
```

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

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

- `binding.b`
- `debugger`
* `binding.b`
* `debugger`

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

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

Examples:

* `rdbg -c -- rails server`
* `rdbg -c -- bundle exec ruby foo.rb`
* `rdbg -c -- bundle exec rake test`
Expand Down Expand Up @@ -335,7 +336,7 @@ If you want to use TCP/IP for the remote debugging, you need to specify the port
To connect to the debuggee, you need to specify the port.

```shell
$ rdbg --attach 12345
rdbg --attach 12345
```

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

```shell
$ RUBY_DEBUG_PORT=12345 ruby target.rb
RUBY_DEBUG_PORT=12345 ruby target.rb
```

### Integration with external debugger frontend

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

```
$ rdbg --open=[frontend] target.rb
rdbg --open=[frontend] target.rb
```

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



* UI
* `RUBY_DEBUG_LOG_LEVEL` (`log_level`): Log level same as Logger (default: WARN)
* `RUBY_DEBUG_SHOW_SRC_LINES` (`show_src_lines`): Show n lines source code on breakpoint (default: 10)
Expand Down Expand Up @@ -501,6 +500,7 @@ config set no_color true
* `RUBY_DEBUG_HOST` (`host`): TCP/IP remote debugging: host (default: 127.0.0.1)
* `RUBY_DEBUG_SOCK_PATH` (`sock_path`): UNIX Domain Socket remote debugging: socket path
* `RUBY_DEBUG_SOCK_DIR` (`sock_dir`): UNIX Domain Socket remote debugging: socket directory
* `RUBY_DEBUG_SOCK_PREFIX` (`sock_prefix`): UNIX Domain Socket remote debugging: socket prefix
* `RUBY_DEBUG_SOCK_SUFFIX` (`sock_suffix`): UNIX Domain Socket remote debugging: socket suffix
* `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)
Expand Down Expand Up @@ -592,9 +592,9 @@ The `<...>` notation means the argument.
* `b[reak] <file>:<line>` or `<file> <line>`
* Set breakpoint on `<file>:<line>`.
* `b[reak] <class>#<name>`
* Set breakpoint on the method `<class>#<name>`.
* Set breakpoint on the method `<class>#<name>`.
* `b[reak] <expr>.<name>`
* Set breakpoint on the method `<expr>.<name>`.
* Set breakpoint on the method `<expr>.<name>`.
* `b[reak] ... if: <expr>`
* break if `<expr>` is true at specified location.
* `b[reak] ... pre: <command>`
Expand Down Expand Up @@ -782,7 +782,6 @@ The `<...>` notation means the argument.
* `h[elp] <command>`
* Show help for the given command.


## Debugger API

### Start debugging
Expand Down Expand Up @@ -924,12 +923,12 @@ NOTE
# Additional Resources
- [From byebug to ruby/debug](https://st0012.dev/from-byebug-to-ruby-debug) by Stan Lo - A migration guide for `byebug` users.
- [ruby/debug cheatsheet](https://st0012.dev/ruby-debug-cheatsheet) by Stan Lo
* [From byebug to ruby/debug](https://st0012.dev/from-byebug-to-ruby-debug) by Stan Lo - A migration guide for `byebug` users.
* [ruby/debug cheatsheet](https://st0012.dev/ruby-debug-cheatsheet) by Stan Lo
# Contributing
Bug reports and pull requests are welcome on GitHub at https://github.com/ruby/debug.
Bug reports and pull requests are welcome on GitHub at <https://github.com/ruby/debug>.
This debugger is not mature so your feedback will help us.
Please also check the [contributing guideline](/CONTRIBUTING.md).
Expand Down
4 changes: 4 additions & 0 deletions lib/debug/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ module DEBUGGER__
sock_path: ['RUBY_DEBUG_SOCK_PATH', "REMOTE: UNIX Domain Socket remote debugging: socket path"],
sock_dir: ['RUBY_DEBUG_SOCK_DIR', "REMOTE: UNIX Domain Socket remote debugging: socket directory"],
sock_suffix: ['RUBY_DEBUG_SOCK_SUFFIX', "REMOTE: UNIX Domain Socket remote debugging: socket suffix"],
sock_prefix: ['RUBY_DEBUG_SOCK_PREFIX', "REMOTE: UNIX Domain Socket remote debugging: socket prefix"],
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"],
Expand Down Expand Up @@ -498,6 +499,9 @@ def self.unix_domain_socket_dir
def self.create_unix_domain_socket_name_prefix(base_dir = unix_domain_socket_dir)
user = ENV['USER'] || 'UnknownUser'
filename = "ruby-debug-#{user}"
if !CONFIG[:sock_prefix].nil?
filename = "#{CONFIG[:sock_prefix]}-#{filename}"
end
if !CONFIG[:sock_suffix].nil?
filename += "-#{CONFIG[:sock_suffix]}"
end
Expand Down

0 comments on commit 76fb156

Please sign in to comment.