From 30ff7f82ab842c3e229204c9b66c70abe94fadd4 Mon Sep 17 00:00:00 2001 From: st0012 Date: Sun, 22 May 2022 11:43:26 +0100 Subject: [PATCH 1/7] Proactively apply default config values --- lib/debug/config.rb | 50 ++++++++++++++++++++++++++------------------ lib/debug/session.rb | 2 +- 2 files changed, 31 insertions(+), 21 deletions(-) diff --git a/lib/debug/config.rb b/lib/debug/config.rb index 26f6cca72..404a7edba 100644 --- a/lib/debug/config.rb +++ b/lib/debug/config.rb @@ -12,34 +12,34 @@ module DEBUGGER__ CONFIG_SET = { # UI setting - log_level: ['RUBY_DEBUG_LOG_LEVEL', "UI: Log level same as Logger (default: WARN)", :loglevel], - show_src_lines: ['RUBY_DEBUG_SHOW_SRC_LINES', "UI: Show n lines source code on breakpoint (default: 10 lines)", :int], - show_frames: ['RUBY_DEBUG_SHOW_FRAMES', "UI: Show n frames on breakpoint (default: 2 frames)", :int], - use_short_path: ['RUBY_DEBUG_USE_SHORT_PATH', "UI: Show shorten PATH (like $(Gem)/foo.rb)", :bool], - no_color: ['RUBY_DEBUG_NO_COLOR', "UI: Do not use colorize (default: false)", :bool], - no_sigint_hook: ['RUBY_DEBUG_NO_SIGINT_HOOK', "UI: Do not suspend on SIGINT (default: false)", :bool], - no_reline: ['RUBY_DEBUG_NO_RELINE', "UI: Do not use Reline library (default: false)", :bool], + log_level: ['RUBY_DEBUG_LOG_LEVEL', "UI: Log level same as Logger (default: WARN)", :loglevel, "WARN"], + show_src_lines: ['RUBY_DEBUG_SHOW_SRC_LINES', "UI: Show n lines source code on breakpoint (default: 10 lines)", :int, "10"], + show_frames: ['RUBY_DEBUG_SHOW_FRAMES', "UI: Show n frames on breakpoint (default: 2 frames)", :int, "2"], + use_short_path: ['RUBY_DEBUG_USE_SHORT_PATH', "UI: Show shorten PATH (like $(Gem)/foo.rb)", :bool, "false"], + no_color: ['RUBY_DEBUG_NO_COLOR', "UI: Do not use colorize (default: false)", :bool, "false"], + no_sigint_hook: ['RUBY_DEBUG_NO_SIGINT_HOOK', "UI: Do not suspend on SIGINT (default: false)", :bool, "false"], + no_reline: ['RUBY_DEBUG_NO_RELINE', "UI: Do not use Reline library (default: false)", :bool, "false"], # control setting skip_path: ['RUBY_DEBUG_SKIP_PATH', "CONTROL: Skip showing/entering frames for given paths (default: [])", :path], - skip_nosrc: ['RUBY_DEBUG_SKIP_NOSRC', "CONTROL: Skip on no source code lines (default: false)", :bool], - keep_alloc_site:['RUBY_DEBUG_KEEP_ALLOC_SITE',"CONTROL: Keep allocation site and p, pp shows it (default: false)", :bool], - postmortem: ['RUBY_DEBUG_POSTMORTEM', "CONTROL: Enable postmortem debug (default: false)", :bool], - fork_mode: ['RUBY_DEBUG_FORK_MODE', "CONTROL: Control which process activates a debugger after fork (both/parent/child) (default: both)", :forkmode], + skip_nosrc: ['RUBY_DEBUG_SKIP_NOSRC', "CONTROL: Skip on no source code lines (default: false)", :bool, "false"], + keep_alloc_site:['RUBY_DEBUG_KEEP_ALLOC_SITE',"CONTROL: Keep allocation site and p, pp shows it (default: false)", :bool, "false"], + postmortem: ['RUBY_DEBUG_POSTMORTEM', "CONTROL: Enable postmortem debug (default: false)", :bool, "false"], + fork_mode: ['RUBY_DEBUG_FORK_MODE', "CONTROL: Control which process activates a debugger after fork (both/parent/child) (default: both)", :forkmode, "both"], sigdump_sig: ['RUBY_DEBUG_SIGDUMP_SIG', "CONTROL: Sigdump signal (default: disabled)"], # boot setting - nonstop: ['RUBY_DEBUG_NONSTOP', "BOOT: Nonstop mode", :bool], - stop_at_load: ['RUBY_DEBUG_STOP_AT_LOAD',"BOOT: Stop at just loading location", :bool], + nonstop: ['RUBY_DEBUG_NONSTOP', "BOOT: Nonstop mode", :bool, "false"], + stop_at_load: ['RUBY_DEBUG_STOP_AT_LOAD',"BOOT: Stop at just loading location", :bool, "false"], init_script: ['RUBY_DEBUG_INIT_SCRIPT', "BOOT: debug command script path loaded at first stop"], commands: ['RUBY_DEBUG_COMMANDS', "BOOT: debug commands invoked at first stop. commands should be separated by ';;'"], - no_rc: ['RUBY_DEBUG_NO_RC', "BOOT: ignore loading ~/.rdbgrc(.rb)", :bool], - history_file: ['RUBY_DEBUG_HISTORY_FILE',"BOOT: history file (default: ~/.rdbg_history)"], - save_history: ['RUBY_DEBUG_SAVE_HISTORY',"BOOT: maximum save history lines (default: 10,000)"], + no_rc: ['RUBY_DEBUG_NO_RC', "BOOT: ignore loading ~/.rdbgrc(.rb)", :bool, "false"], + history_file: ['RUBY_DEBUG_HISTORY_FILE',"BOOT: history file (default: ~/.rdbg_history)", :string, File.expand_path("~/.rdbg_history")], + save_history: ['RUBY_DEBUG_SAVE_HISTORY',"BOOT: maximum save history lines (default: 10,000)", :int, "1000"], # remote setting port: ['RUBY_DEBUG_PORT', "REMOTE: TCP/IP remote debugging: port"], - host: ['RUBY_DEBUG_HOST', "REMOTE: TCP/IP remote debugging: host (localhost if not given)"], + host: ['RUBY_DEBUG_HOST', "REMOTE: TCP/IP remote debugging: host", :string, "127.0.0.1"], 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"], cookie: ['RUBY_DEBUG_COOKIE', "REMOTE: Cookie for negotiation"], @@ -47,7 +47,7 @@ module DEBUGGER__ 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 - parent_on_fork: ['RUBY_DEBUG_PARENT_ON_FORK', "OBSOLETE: Keep debugging parent process on fork (default: false)", :bool], + parent_on_fork: ['RUBY_DEBUG_PARENT_ON_FORK', "OBSOLETE: Keep debugging parent process on fork (default: false)", :bool, "false"], }.freeze CONFIG_MAP = CONFIG_SET.map{|k, (ev, _)| [k, ev]}.to_h.freeze @@ -66,7 +66,17 @@ def initialize argv raise 'Can not make multiple configurations in one process' end - update self.class.parse_argv(argv) + config = self.class.parse_argv(argv) + + # apply defaults + CONFIG_SET.each do |k, config_detail| + unless config.key?(k) + default_value = config_detail[3] + config[k] = parse_config_value(k, default_value) + end + end + + update config end def inspect @@ -126,8 +136,8 @@ def update conf # Post process if_updated old_conf, conf, :keep_alloc_site do |_, new| + require 'objspace' if new - require 'objspace' ObjectSpace.trace_object_allocations_start else ObjectSpace.trace_object_allocations_stop diff --git a/lib/debug/session.rb b/lib/debug/session.rb index 013a9b932..0348bb914 100644 --- a/lib/debug/session.rb +++ b/lib/debug/session.rb @@ -1059,7 +1059,7 @@ def config_show key key = key.to_sym if CONFIG_SET[key] v = CONFIG[key] - kv = "#{key} = #{v.nil? ? '(default)' : v.inspect}" + kv = "#{key} = #{v.inspect}" desc = CONFIG_SET[key][1] line = "%-30s \# %s" % [kv, desc] if line.size > SESSION.width From 4cd65df8067ed43b75827dc9ca0f2f71426fd093 Mon Sep 17 00:00:00 2001 From: st0012 Date: Sun, 22 May 2022 12:00:35 +0100 Subject: [PATCH 2/7] Generate default config message dynamically --- lib/debug/config.rb | 32 ++++++++++++++++---------------- lib/debug/console.rb | 8 +++++++- lib/debug/session.rb | 11 ++++++++--- test/console/config_test.rb | 7 ++++--- 4 files changed, 35 insertions(+), 23 deletions(-) diff --git a/lib/debug/config.rb b/lib/debug/config.rb index 404a7edba..1b8ef1eaf 100644 --- a/lib/debug/config.rb +++ b/lib/debug/config.rb @@ -12,21 +12,21 @@ module DEBUGGER__ CONFIG_SET = { # UI setting - log_level: ['RUBY_DEBUG_LOG_LEVEL', "UI: Log level same as Logger (default: WARN)", :loglevel, "WARN"], - show_src_lines: ['RUBY_DEBUG_SHOW_SRC_LINES', "UI: Show n lines source code on breakpoint (default: 10 lines)", :int, "10"], - show_frames: ['RUBY_DEBUG_SHOW_FRAMES', "UI: Show n frames on breakpoint (default: 2 frames)", :int, "2"], - use_short_path: ['RUBY_DEBUG_USE_SHORT_PATH', "UI: Show shorten PATH (like $(Gem)/foo.rb)", :bool, "false"], - no_color: ['RUBY_DEBUG_NO_COLOR', "UI: Do not use colorize (default: false)", :bool, "false"], - no_sigint_hook: ['RUBY_DEBUG_NO_SIGINT_HOOK', "UI: Do not suspend on SIGINT (default: false)", :bool, "false"], - no_reline: ['RUBY_DEBUG_NO_RELINE', "UI: Do not use Reline library (default: false)", :bool, "false"], + log_level: ['RUBY_DEBUG_LOG_LEVEL', "UI: Log level same as Logger", :loglevel, "WARN"], + show_src_lines: ['RUBY_DEBUG_SHOW_SRC_LINES', "UI: Show n lines source code on breakpoint", :int, "10"], + show_frames: ['RUBY_DEBUG_SHOW_FRAMES', "UI: Show n frames on breakpoint", :int, "2"], + use_short_path: ['RUBY_DEBUG_USE_SHORT_PATH', "UI: Show shorten PATH (like $(Gem)/foo.rb)", :bool, "false"], + no_color: ['RUBY_DEBUG_NO_COLOR', "UI: Do not use colorize", :bool, "false"], + no_sigint_hook: ['RUBY_DEBUG_NO_SIGINT_HOOK', "UI: Do not suspend on SIGINT", :bool, "false"], + no_reline: ['RUBY_DEBUG_NO_RELINE', "UI: Do not use Reline library", :bool, "false"], # control setting - skip_path: ['RUBY_DEBUG_SKIP_PATH', "CONTROL: Skip showing/entering frames for given paths (default: [])", :path], - skip_nosrc: ['RUBY_DEBUG_SKIP_NOSRC', "CONTROL: Skip on no source code lines (default: false)", :bool, "false"], - keep_alloc_site:['RUBY_DEBUG_KEEP_ALLOC_SITE',"CONTROL: Keep allocation site and p, pp shows it (default: false)", :bool, "false"], - postmortem: ['RUBY_DEBUG_POSTMORTEM', "CONTROL: Enable postmortem debug (default: false)", :bool, "false"], - fork_mode: ['RUBY_DEBUG_FORK_MODE', "CONTROL: Control which process activates a debugger after fork (both/parent/child) (default: both)", :forkmode, "both"], - sigdump_sig: ['RUBY_DEBUG_SIGDUMP_SIG', "CONTROL: Sigdump signal (default: disabled)"], + skip_path: ['RUBY_DEBUG_SKIP_PATH', "CONTROL: Skip showing/entering frames for given paths", :path], + skip_nosrc: ['RUBY_DEBUG_SKIP_NOSRC', "CONTROL: Skip on no source code lines", :bool, "false"], + keep_alloc_site:['RUBY_DEBUG_KEEP_ALLOC_SITE',"CONTROL: Keep allocation site and p, pp shows it", :bool, "false"], + postmortem: ['RUBY_DEBUG_POSTMORTEM', "CONTROL: Enable postmortem debug", :bool, "false"], + fork_mode: ['RUBY_DEBUG_FORK_MODE', "CONTROL: Control which process activates a debugger after fork (both/parent/child)", :forkmode, "both"], + sigdump_sig: ['RUBY_DEBUG_SIGDUMP_SIG', "CONTROL: Sigdump signal", :bool, "false"], # boot setting nonstop: ['RUBY_DEBUG_NONSTOP', "BOOT: Nonstop mode", :bool, "false"], @@ -34,8 +34,8 @@ module DEBUGGER__ init_script: ['RUBY_DEBUG_INIT_SCRIPT', "BOOT: debug command script path loaded at first stop"], commands: ['RUBY_DEBUG_COMMANDS', "BOOT: debug commands invoked at first stop. commands should be separated by ';;'"], no_rc: ['RUBY_DEBUG_NO_RC', "BOOT: ignore loading ~/.rdbgrc(.rb)", :bool, "false"], - history_file: ['RUBY_DEBUG_HISTORY_FILE',"BOOT: history file (default: ~/.rdbg_history)", :string, File.expand_path("~/.rdbg_history")], - save_history: ['RUBY_DEBUG_SAVE_HISTORY',"BOOT: maximum save history lines (default: 10,000)", :int, "1000"], + history_file: ['RUBY_DEBUG_HISTORY_FILE',"BOOT: history file", :string, "~/.rdbg_history"], + save_history: ['RUBY_DEBUG_SAVE_HISTORY',"BOOT: maximum save history lines", :int, "10000"], # remote setting port: ['RUBY_DEBUG_PORT', "REMOTE: TCP/IP remote debugging: port"], @@ -47,7 +47,7 @@ module DEBUGGER__ 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 - parent_on_fork: ['RUBY_DEBUG_PARENT_ON_FORK', "OBSOLETE: Keep debugging parent process on fork (default: false)", :bool, "false"], + parent_on_fork: ['RUBY_DEBUG_PARENT_ON_FORK', "OBSOLETE: Keep debugging parent process on fork", :bool, "false"], }.freeze CONFIG_MAP = CONFIG_SET.map{|k, (ev, _)| [k, ev]}.to_h.freeze diff --git a/lib/debug/console.rb b/lib/debug/console.rb index 962dc8101..07e54cb14 100644 --- a/lib/debug/console.rb +++ b/lib/debug/console.rb @@ -174,7 +174,13 @@ def history end def history_file - CONFIG[:history_file] || File.expand_path("~/.rdbg_history") + history_file = CONFIG[:history_file] + + if !history_file.empty? + File.expand_path(history_file) + else + history_file + end end FH = "# Today's OMIKUJI: " diff --git a/lib/debug/session.rb b/lib/debug/session.rb index 0348bb914..e99b92c63 100644 --- a/lib/debug/session.rb +++ b/lib/debug/session.rb @@ -1057,11 +1057,16 @@ def step_command type, arg def config_show key key = key.to_sym - if CONFIG_SET[key] + if config_detail = CONFIG_SET[key] v = CONFIG[key] kv = "#{key} = #{v.inspect}" - desc = CONFIG_SET[key][1] - line = "%-30s \# %s" % [kv, desc] + desc = config_detail[1] + + if config_default = config_detail[3] + desc += " (default: #{config_default})" + end + + line = "%-34s \# %s" % [kv, desc] if line.size > SESSION.width @ui.puts "\# #{desc}\n#{kv}" else diff --git a/test/console/config_test.rb b/test/console/config_test.rb index eff72b434..ea08f2cd6 100644 --- a/test/console/config_test.rb +++ b/test/console/config_test.rb @@ -21,13 +21,14 @@ def test_config_show type 'config' # show all configurations with descriptions assert_line_text([ - /show_src_lines = \(default\)/, - /show_frames = \(default\)/ + /show_src_lines = \d+/, + /show_frames = \d+/ ]) # only show this configuration type 'config show_frames' + assert_no_line_text(/show_src_lines/) assert_line_text([ - /show_frames = \(default\)/ + /show_frames = \d+/ ]) type 'q!' end From fd6e12f725510c7eb39588913e924ca2e22a1f7e Mon Sep 17 00:00:00 2001 From: st0012 Date: Sun, 22 May 2022 21:59:38 +0100 Subject: [PATCH 3/7] Adjust forking logic for default config change --- lib/debug/session.rb | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/lib/debug/session.rb b/lib/debug/session.rb index e99b92c63..a4b7d0673 100644 --- a/lib/debug/session.rb +++ b/lib/debug/session.rb @@ -2216,12 +2216,10 @@ def fork(&given_block) end private def __fork_setup_for_debugger - unless fork_mode = CONFIG[:fork_mode] - if CONFIG[:parent_on_fork] - fork_mode = :parent - else - fork_mode = :both - end + fork_mode = CONFIG[:fork_mode] + + if fork_mode == :both && CONFIG[:parent_on_fork] + fork_mode = :parent end parent_pid = Process.pid From f53247b17ec4879272f7bffe2880892c37295172 Mon Sep 17 00:00:00 2001 From: st0012 Date: Sun, 22 May 2022 12:16:23 +0100 Subject: [PATCH 4/7] Apply generated configuration defaults on README --- README.md | 20 ++++++++++---------- misc/README.md.erb | 4 ++-- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 52b30e862..5abf69336 100644 --- a/README.md +++ b/README.md @@ -456,33 +456,33 @@ 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 lines) - * `RUBY_DEBUG_SHOW_FRAMES` (`show_frames`): Show n frames on breakpoint (default: 2 frames) - * `RUBY_DEBUG_USE_SHORT_PATH` (`use_short_path`): Show shorten PATH (like $(Gem)/foo.rb) + * `RUBY_DEBUG_SHOW_SRC_LINES` (`show_src_lines`): Show n lines source code on breakpoint (default: 10) + * `RUBY_DEBUG_SHOW_FRAMES` (`show_frames`): Show n frames on breakpoint (default: 2) + * `RUBY_DEBUG_USE_SHORT_PATH` (`use_short_path`): Show shorten PATH (like $(Gem)/foo.rb) (default: false) * `RUBY_DEBUG_NO_COLOR` (`no_color`): Do not use colorize (default: false) * `RUBY_DEBUG_NO_SIGINT_HOOK` (`no_sigint_hook`): Do not suspend on SIGINT (default: false) * `RUBY_DEBUG_NO_RELINE` (`no_reline`): Do not use Reline library (default: false) * CONTROL - * `RUBY_DEBUG_SKIP_PATH` (`skip_path`): Skip showing/entering frames for given paths (default: []) + * `RUBY_DEBUG_SKIP_PATH` (`skip_path`): Skip showing/entering frames for given paths * `RUBY_DEBUG_SKIP_NOSRC` (`skip_nosrc`): Skip on no source code lines (default: false) * `RUBY_DEBUG_KEEP_ALLOC_SITE` (`keep_alloc_site`): Keep allocation site and p, pp shows it (default: false) * `RUBY_DEBUG_POSTMORTEM` (`postmortem`): Enable postmortem debug (default: false) * `RUBY_DEBUG_FORK_MODE` (`fork_mode`): Control which process activates a debugger after fork (both/parent/child) (default: both) - * `RUBY_DEBUG_SIGDUMP_SIG` (`sigdump_sig`): Sigdump signal (default: disabled) + * `RUBY_DEBUG_SIGDUMP_SIG` (`sigdump_sig`): Sigdump signal (default: false) * BOOT - * `RUBY_DEBUG_NONSTOP` (`nonstop`): Nonstop mode - * `RUBY_DEBUG_STOP_AT_LOAD` (`stop_at_load`): Stop at just loading location + * `RUBY_DEBUG_NONSTOP` (`nonstop`): Nonstop mode (default: false) + * `RUBY_DEBUG_STOP_AT_LOAD` (`stop_at_load`): Stop at just loading location (default: false) * `RUBY_DEBUG_INIT_SCRIPT` (`init_script`): debug command script path loaded at first stop * `RUBY_DEBUG_COMMANDS` (`commands`): debug commands invoked at first stop. commands should be separated by ';;' - * `RUBY_DEBUG_NO_RC` (`no_rc`): ignore loading ~/.rdbgrc(.rb) + * `RUBY_DEBUG_NO_RC` (`no_rc`): ignore loading ~/.rdbgrc(.rb) (default: false) * `RUBY_DEBUG_HISTORY_FILE` (`history_file`): history file (default: ~/.rdbg_history) - * `RUBY_DEBUG_SAVE_HISTORY` (`save_history`): maximum save history lines (default: 10,000) + * `RUBY_DEBUG_SAVE_HISTORY` (`save_history`): maximum save history lines (default: 10000) * REMOTE * `RUBY_DEBUG_PORT` (`port`): TCP/IP remote debugging: port - * `RUBY_DEBUG_HOST` (`host`): TCP/IP remote debugging: host (localhost if not given) + * `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_COOKIE` (`cookie`): Cookie for negotiation diff --git a/misc/README.md.erb b/misc/README.md.erb index 101666d94..4e96b2997 100644 --- a/misc/README.md.erb +++ b/misc/README.md.erb @@ -452,10 +452,10 @@ config set log_level INFO config set no_color true ``` -<% cat = nil; DEBUGGER__::CONFIG_SET.each do |key, (env, desc)| %> +<% cat = nil; DEBUGGER__::CONFIG_SET.each do |key, (env, desc, _, default)| %> <% /\A(\w+): (.+)/ =~ desc; if cat != $1; cat = 1 %> * <%= $1 %> -<% cat = $1; end %> * `<%= env %>` (`<%= key %>`): <%= $2 %><% end %> +<% cat = $1; end %> * `<%= env %>` (`<%= key %>`): <%= default ? "#{$2} (default: #{default})" : $2 %><% end %> ### Initial scripts From 53c0fb92ef59b91f3542d9cdd4d9f43610780a67 Mon Sep 17 00:00:00 2001 From: st0012 Date: Sun, 22 May 2022 22:41:14 +0100 Subject: [PATCH 5/7] Remove obsolete fallback values --- lib/debug/console.rb | 2 +- lib/debug/server.rb | 4 ++-- lib/debug/session.rb | 2 +- lib/debug/thread_client.rb | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/debug/console.rb b/lib/debug/console.rb index 07e54cb14..e3d5b5afa 100644 --- a/lib/debug/console.rb +++ b/lib/debug/console.rb @@ -208,7 +208,7 @@ def deactivate if history && @init_history_lines added_records = history.to_a[@init_history_lines .. -1] path = history_file - max = CONFIG[:save_history] || 10_000 + max = CONFIG[:save_history] if !added_records.empty? && !path.empty? orig_records = read_history_file diff --git a/lib/debug/server.rb b/lib/debug/server.rb index 582a62598..9abb1879d 100644 --- a/lib/debug/server.rb +++ b/lib/debug/server.rb @@ -355,7 +355,7 @@ def vscode_setup debug_port class UI_TcpServer < UI_ServerBase def initialize host: nil, port: nil @local_addr = nil - @host = host || CONFIG[:host] || '127.0.0.1' + @host = host || CONFIG[:host] @port_save_file = nil @port = begin port_str = (port && port.to_s) || CONFIG[:port] || raise("Specify listening port by RUBY_DEBUG_PORT environment variable.") @@ -381,7 +381,7 @@ def chrome_setup With Chrome browser, type the following URL in the address-bar: devtools://devtools/bundled/inspector.html?v8only=true&panel=sources&ws=#{@local_addr.inspect_sockaddr}/#{SecureRandom.uuid} - + EOS end end diff --git a/lib/debug/session.rb b/lib/debug/session.rb index a4b7d0673..f89e4a07f 100644 --- a/lib/debug/session.rb +++ b/lib/debug/session.rb @@ -2120,7 +2120,7 @@ def self.info msg def self.check_loglevel level lv = LOG_LEVELS[level] - config_lv = LOG_LEVELS[CONFIG[:log_level] || :WARN] + config_lv = LOG_LEVELS[CONFIG[:log_level]] lv <= config_lv end diff --git a/lib/debug/thread_client.rb b/lib/debug/thread_client.rb index 4a8ea0a76..e9475c460 100644 --- a/lib/debug/thread_client.rb +++ b/lib/debug/thread_client.rb @@ -286,7 +286,7 @@ def suspend event, tp = nil, bp: nil, sig: nil, postmortem_frames: nil, replay_f if event != :pause show_src - show_frames CONFIG[:show_frames] || 2 + show_frames CONFIG[:show_frames] set_mode :waiting @@ -476,7 +476,7 @@ def get_src(frame, exit! end - def show_src(frame_index: @current_frame_index, update_line: false, max_lines: CONFIG[:show_src_lines] || 10, **options) + def show_src(frame_index: @current_frame_index, update_line: false, max_lines: CONFIG[:show_src_lines], **options) if frame = get_frame(frame_index) start_line, end_line, lines = *get_src(frame, max_lines: max_lines, **options) From 64027c243daff126472cf4163001a75e37a32de1 Mon Sep 17 00:00:00 2001 From: st0012 Date: Sun, 22 May 2022 23:24:08 +0100 Subject: [PATCH 6/7] Only call ObjectSpace.trace_object_allocations_stop when it's previouly started --- lib/debug/config.rb | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/debug/config.rb b/lib/debug/config.rb index 1b8ef1eaf..8b176ae09 100644 --- a/lib/debug/config.rb +++ b/lib/debug/config.rb @@ -135,11 +135,13 @@ def update conf self.class.instance_variable_set(:@config, conf.freeze) # Post process - if_updated old_conf, conf, :keep_alloc_site do |_, new| - require 'objspace' + if_updated old_conf, conf, :keep_alloc_site do |old, new| if new + require 'objspace' ObjectSpace.trace_object_allocations_start - else + end + + if old && !new ObjectSpace.trace_object_allocations_stop end end From 20a7f306c1ffd36df7727c935cd78464ec322fe6 Mon Sep 17 00:00:00 2001 From: st0012 Date: Fri, 1 Jul 2022 18:15:11 +0100 Subject: [PATCH 7/7] Style fix --- lib/debug/session.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/debug/session.rb b/lib/debug/session.rb index f89e4a07f..db29bd1e6 100644 --- a/lib/debug/session.rb +++ b/lib/debug/session.rb @@ -1057,7 +1057,9 @@ def step_command type, arg def config_show key key = key.to_sym - if config_detail = CONFIG_SET[key] + config_detail = CONFIG_SET[key] + + if config_detail v = CONFIG[key] kv = "#{key} = #{v.inspect}" desc = config_detail[1]