Skip to content
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

Centralize configuration defaults #642

Merged
merged 7 commits into from
Jul 1, 2022

Conversation

st0012
Copy link
Member

@st0012 st0012 commented May 22, 2022

Currently, we use CONFIG[:key] || default to apply default values at the places we use the config. This has 2 problems:

  1. The config descriptions' default and the actual default needs to be synced manually. And as the time goes by, some of them are likely to be out-of-sync gradually.
  2. Config defaults are scattered around the codebase and you need to know where a config is used to see its default. With code searching this isn't a big issue but it's still nicer to see all of them in one place.

So in this PR, I moved all configs' default to the config.rb, just right after the config type info. And now the default is synced between README <-> config command <-> actual logic.

Changes on the config command output

Before

(rdbg) config    # command
log_level = (default)          # UI: Log level same as Logger (default: WARN)
show_src_lines = (default)     # UI: Show n lines source code on breakpoint (default: 10 lines)
show_frames = (default)        # UI: Show n frames on breakpoint (default: 2 frames)
use_short_path = (default)     # UI: Show shorten PATH (like $(Gem)/foo.rb)
no_color = (default)           # UI: Do not use colorize (default: false)
no_sigint_hook = (default)     # UI: Do not suspend on SIGINT (default: false)
no_reline = (default)          # UI: Do not use Reline library (default: false)
skip_path = (default)          # CONTROL: Skip showing/entering frames for given paths (default: [])
skip_nosrc = (default)         # CONTROL: Skip on no source code lines (default: false)
keep_alloc_site = (default)    # CONTROL: Keep allocation site and p, pp shows it (default: false)
postmortem = (default)         # CONTROL: Enable postmortem debug (default: false)
fork_mode = (default)          # CONTROL: Control which process activates a debugger after fork (both/parent/child) (default: both)
sigdump_sig = (default)        # CONTROL: Sigdump signal (default: disabled)
nonstop = (default)            # BOOT: Nonstop mode
stop_at_load = (default)       # BOOT: Stop at just loading location
init_script = (default)        # BOOT: debug command script path loaded at first stop
commands = (default)           # BOOT: debug commands invoked at first stop. commands should be separated by ';;'
no_rc = (default)              # BOOT: ignore loading ~/.rdbgrc(.rb)
history_file = (default)       # BOOT: history file (default: ~/.rdbg_history)
save_history = (default)       # BOOT: maximum save history lines (default: 10,000)
port = (default)               # REMOTE: TCP/IP remote debugging: port
host = (default)               # REMOTE: TCP/IP remote debugging: host (localhost if not given)
sock_path = (default)          # REMOTE: UNIX Domain Socket remote debugging: socket path
sock_dir = (default)           # REMOTE: UNIX Domain Socket remote debugging: socket directory
cookie = (default)             # REMOTE: Cookie for negotiation
open_frontend = (default)      # REMOTE: frontend used by open command (vscode, chrome, default: rdbg).
chrome_path = (default)        # REMOTE: Platform dependent path of Chrome (For more information, See [here](https://github.com/ruby/debug/pull/334/files#diff-5fc3d0a901379a95bc111b86cf0090b03f857edfd0b99a0c1537e26735698453R55-R64))
parent_on_fork = (default)     # OBSOLETE: Keep debugging parent process on fork (default: false)

After

(rdbg) config    # command
log_level = :WARN                  # UI: Log level same as Logger (default: WARN)
show_src_lines = 10                # UI: Show n lines source code on breakpoint (default: 10)
show_frames = 2                    # UI: Show n frames on breakpoint (default: 2)
use_short_path = false             # UI: Show shorten PATH (like $(Gem)/foo.rb) (default: false)
no_color = false                   # UI: Do not use colorize (default: false)
no_sigint_hook = false             # UI: Do not suspend on SIGINT (default: false)
no_reline = false                  # UI: Do not use Reline library (default: false)
skip_path = nil                    # CONTROL: Skip showing/entering frames for given paths
skip_nosrc = false                 # CONTROL: Skip on no source code lines (default: false)
keep_alloc_site = false            # CONTROL: Keep allocation site and p, pp shows it (default: false)
postmortem = false                 # CONTROL: Enable postmortem debug (default: false)
fork_mode = :both                  # CONTROL: Control which process activates a debugger after fork (both/parent/child) (default: both)
sigdump_sig = false                # CONTROL: Sigdump signal (default: false)
nonstop = false                    # BOOT: Nonstop mode (default: false)
stop_at_load = false               # BOOT: Stop at just loading location (default: false)
init_script = nil                  # BOOT: debug command script path loaded at first stop
commands = nil                     # BOOT: debug commands invoked at first stop. commands should be separated by ';;'
no_rc = false                      # BOOT: ignore loading ~/.rdbgrc(.rb) (default: false)
history_file = "~/.rdbg_history"   # BOOT: history file (default: ~/.rdbg_history)
save_history = 10000               # BOOT: maximum save history lines (default: 10000)
port = nil                         # REMOTE: TCP/IP remote debugging: port
host = "127.0.0.1"                 # REMOTE: TCP/IP remote debugging: host (default: 127.0.0.1)
sock_path = nil                    # REMOTE: UNIX Domain Socket remote debugging: socket path
sock_dir = nil                     # REMOTE: UNIX Domain Socket remote debugging: socket directory
cookie = nil                       # REMOTE: Cookie for negotiation
open_frontend = nil                # REMOTE: frontend used by open command (vscode, chrome, default: rdbg).
# REMOTE: Platform dependent path of Chrome (For more information, See [here](https://github.com/ruby/debug/pull/334/files#diff-5fc3d0a901379a95bc111b86cf0090b03f857edfd0b99a0c1537e267356984
53R55-R64))
chrome_path = nil
parent_on_fork = false             # OBSOLETE: Keep debugging parent process on fork (default: false)
(rdbg)

@st0012 st0012 force-pushed the improve-config-default branch 3 times, most recently from 5929e10 to 3f72e9e Compare May 23, 2022 15:47
@st0012
Copy link
Member Author

st0012 commented Jul 1, 2022

cc @peterzhu2118

lib/debug/session.rb Outdated Show resolved Hide resolved
Copy link
Member

@peterzhu2118 peterzhu2118 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, thanks!

@peterzhu2118 peterzhu2118 merged commit 5076303 into ruby:master Jul 1, 2022
@st0012 st0012 deleted the improve-config-default branch July 1, 2022 19:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants