debug 1.6.3 → 1.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 61c14c6e761a2ed0f10294682cb7b152c4329d3cd0eccbffff68e3ae122d00a0
4
- data.tar.gz: 714add08d21df0ceb674a8a9c8b8599f0dcc45cb38b68611c766fab1b6ddcd41
3
+ metadata.gz: 14d08935b209386adbc7a1172ae0d43feb7bf31c9483aa177946fa0669db69e8
4
+ data.tar.gz: '01917758f048b2927a6e42b8965985477fed13011b3cd7626220ea8d1aad42fd'
5
5
  SHA512:
6
- metadata.gz: 2c43d785c88ce38a676941b87ab320d126d9083f8b4dcc487ef22b8f7f0c4a144ed2fe9dfc800f8d7b2bf9287694c3d5abcd3b7c5075248b5ca08bd6bd0b3bcf
7
- data.tar.gz: 8f2e9922aac4e297c437f3fc63ec11df2af430c2f3b3406df8723d4703fc254705246300fee99fee6f38f1da62348184b3ff0dcb6a4ddf302c3345f8ae5d4634
6
+ metadata.gz: 6381058fe16c43d79afdc04db1dcfcff6bd3c65216ce9bc9a03b02c26dbe098011879128c2e4f3ed31b1f7cf279b590fd641b4030f6cb6308434d65d17e51110
7
+ data.tar.gz: c2896cca900dea7f5f4456b30f8dc4ecbed6886da74c46033e82bcda37da561759f2bd3b9a702eef7603785c17989f437b4f186817ad458edd16371c7b879688
data/CONTRIBUTING.md CHANGED
@@ -166,7 +166,7 @@ module DEBUGGER__
166
166
  9| end
167
167
  RUBY
168
168
  end
169
-
169
+
170
170
  def test_1629720194
171
171
  debug_code(program) do
172
172
  type 's'
@@ -272,7 +272,7 @@ To run the test generator, you can enter `$ bin/gentest target.rb --open=vscode`
272
272
  Also, if you enter `$ bin/gentest target.rb --open=chrome` there, Chrome will be executed.
273
273
  If you need to modify existing tests, it is basically a good idea to regenerate them by the test generator instead of rewriting them directly.
274
274
  Please refer to [the Microsoft "Debug Adapter Protocol" article](https://microsoft.github.io/debug-adapter-protocol/specification) to learn more about DAP formats.
275
- Please refer to [Procol viewer for "Chrome DevTools Protocol"](https://chromedevtools.github.io/devtools-protocol/) to learn more about CDP formats.
275
+ Please refer to [the "Chrome DevTools Protocol" official documentation](https://chromedevtools.github.io/devtools-protocol/) to learn more about CDP formats.
276
276
 
277
277
  2. High-level tests
278
278
 
@@ -320,6 +320,22 @@ Execute debugging `program` with `&scenario`. If you want to test it only for DA
320
320
 
321
321
  `run_protocol_scenario program, cdp: false ...`
322
322
 
323
+ - attach_to_dap_server(terminate_debuggee:)
324
+
325
+ Attach to the running DAP server through UNIX Domain Socket.
326
+
327
+ - attach_to_cdp_server
328
+
329
+ Attach to the running CDP server through TCP/IP.
330
+
331
+ - req_dap_disconnect
332
+
333
+ Disconnect from the currently connected DAP server.
334
+
335
+ - req_cdp_disconnect
336
+
337
+ Disconnect from the currently connected CDP server.
338
+
323
339
  - req_add_breakpoint(lineno, path: temp_file_path, cond: nil)
324
340
 
325
341
  Sends request to rdbg to add a breakpoint.
@@ -336,7 +352,7 @@ Sends request to rdbg to set exception breakpoints. e.g.
336
352
  req_set_exception_breakpoints([{ name: "RuntimeError", condition: "a == 1" }])
337
353
  ```
338
354
 
339
- Please note that `setExceptionBreakpoints` resets all exception breakpoints in every request.
355
+ Please note that `setExceptionBreakpoints` resets all exception breakpoints in every request.
340
356
 
341
357
  So the following code will only set breakpoint for `Exception`.
342
358
 
@@ -377,10 +393,6 @@ Sends request to rdbg to step back from current method.
377
393
 
378
394
  Sends request to rdbg to terminate the debuggee.
379
395
 
380
- - assert_reattach
381
-
382
- Passes if reattaching to rdbg is successful.
383
-
384
396
  - assert_hover_result(expected, expression)
385
397
 
386
398
  Passes if result of `expression` matches `expected`.
data/Gemfile CHANGED
File without changes
data/LICENSE.txt CHANGED
File without changes
data/README.md CHANGED
@@ -469,6 +469,7 @@ config set no_color true
469
469
  * UI
470
470
  * `RUBY_DEBUG_LOG_LEVEL` (`log_level`): Log level same as Logger (default: WARN)
471
471
  * `RUBY_DEBUG_SHOW_SRC_LINES` (`show_src_lines`): Show n lines source code on breakpoint (default: 10)
472
+ * `RUBY_DEBUG_SHOW_EVALEDSRC` (`show_evaledsrc`): Show actually evaluated source (default: false)
472
473
  * `RUBY_DEBUG_SHOW_FRAMES` (`show_frames`): Show n frames on breakpoint (default: 2)
473
474
  * `RUBY_DEBUG_USE_SHORT_PATH` (`use_short_path`): Show shorten PATH (like $(Gem)/foo.rb) (default: false)
474
475
  * `RUBY_DEBUG_NO_COLOR` (`no_color`): Do not use colorize (default: false)
@@ -488,12 +489,13 @@ config set no_color true
488
489
  * `RUBY_DEBUG_NONSTOP` (`nonstop`): Nonstop mode (default: false)
489
490
  * `RUBY_DEBUG_STOP_AT_LOAD` (`stop_at_load`): Stop at just loading location (default: false)
490
491
  * `RUBY_DEBUG_INIT_SCRIPT` (`init_script`): debug command script path loaded at first stop
491
- * `RUBY_DEBUG_COMMANDS` (`commands`): debug commands invoked at first stop. commands should be separated by ';;'
492
+ * `RUBY_DEBUG_COMMANDS` (`commands`): debug commands invoked at first stop. Commands should be separated by `;;`
492
493
  * `RUBY_DEBUG_NO_RC` (`no_rc`): ignore loading ~/.rdbgrc(.rb) (default: false)
493
494
  * `RUBY_DEBUG_HISTORY_FILE` (`history_file`): history file (default: ~/.rdbg_history)
494
495
  * `RUBY_DEBUG_SAVE_HISTORY` (`save_history`): maximum save history lines (default: 10000)
495
496
 
496
497
  * REMOTE
498
+ * `RUBY_DEBUG_OPEN` (`open`): Open remote port (same as `rdbg --open` option)
497
499
  * `RUBY_DEBUG_PORT` (`port`): TCP/IP remote debugging: port
498
500
  * `RUBY_DEBUG_HOST` (`host`): TCP/IP remote debugging: host (default: 127.0.0.1)
499
501
  * `RUBY_DEBUG_SOCK_PATH` (`sock_path`): UNIX Domain Socket remote debugging: socket path
@@ -501,7 +503,6 @@ config set no_color true
501
503
  * `RUBY_DEBUG_LOCAL_FS_MAP` (`local_fs_map`): Specify local fs map
502
504
  * `RUBY_DEBUG_SKIP_BP` (`skip_bp`): Skip breakpoints if no clients are attached (default: false)
503
505
  * `RUBY_DEBUG_COOKIE` (`cookie`): Cookie for negotiation
504
- * `RUBY_DEBUG_OPEN_FRONTEND` (`open_frontend`): frontend used by open command (vscode, chrome, default: rdbg).
505
506
  * `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))
506
507
 
507
508
  * OBSOLETE
@@ -536,7 +537,8 @@ There are additional features:
536
537
  * `<expr>` without debug command is almost same as `pp <expr>`.
537
538
  * If the input line `<expr>` does *NOT* start with any debug command, the line `<expr>` will be evaluated as a Ruby expression and the result will be printed with `pp` method. So that the input `foo.bar` is same as `pp foo.bar`.
538
539
  * If `<expr>` is recognized as a debug command, of course it is not evaluated as a Ruby expression, but is executed as debug command. For example, you can not evaluate such single letter local variables `i`, `b`, `n`, `c` because they are single letter debug commands. Use `p i` instead.
539
- * `Enter` without any input repeats the last command (useful when repeating `step`s).
540
+ * So the author (Koichi Sasada) recommends to use `p`, `pp` or `eval` command to evaluate the Ruby expression everytime.
541
+ * `Enter` without any input repeats the last command (useful when repeating `step`s) for some commands.
540
542
  * `Ctrl-D` is equal to `quit` command.
541
543
  * [debug command compare sheet - Google Sheets](https://docs.google.com/spreadsheets/d/1TlmmUDsvwK4sSIyoMv-io52BUUz__R5wpu-ComXlsw0/edit?usp=sharing)
542
544
 
@@ -558,7 +560,14 @@ The `<...>` notation means the argument.
558
560
  * Finish this frame. Resume the program until the current frame is finished.
559
561
  * `fin[ish] <n>`
560
562
  * Finish `<n>`th frames.
561
- * `c[ontinue]`
563
+ * `u[ntil]`
564
+ * Similar to `next` command, but only stop later lines or the end of the current frame.
565
+ * Similar to gdb's `advance` command.
566
+ * `u[ntil] <[file:]line>
567
+ * Run til the program reaches given location or the end of the current frame.
568
+ * `u[ntil] <name>
569
+ * Run til the program invokes a method `<name>`. `<name>` can be a regexp with `/name/`.
570
+ * `c` or `cont` or `continue`
562
571
  * Resume the program.
563
572
  * `q[uit]` or `Ctrl-D`
564
573
  * Finish debugger (with the debuggee process on non-remote debugging).
@@ -638,26 +647,35 @@ The `<...>` notation means the argument.
638
647
  * Show predecessor lines as opposed to the `list` command.
639
648
  * `l[ist] <start>` or `l[ist] <start>-<end>`
640
649
  * Show current frame's source code from the line <start> to <end> if given.
650
+ * `whereami`
651
+ * Show the current frame with source code.
641
652
  * `edit`
642
653
  * Open the current file on the editor (use `EDITOR` environment variable).
643
654
  * Note that edited file will not be reloaded.
644
655
  * `edit <file>`
645
656
  * Open <file> on the editor.
646
657
  * `i[nfo]`
647
- * Show information about current frame (local/instance variables and defined constants).
648
- * `i[nfo] l[ocal[s]]`
658
+ * Show information about current frame (local/instance variables and defined constants).
659
+ * `i[nfo]` <subcommand>
660
+ * `info` has the following sub-commands.
661
+ * Sub-commands can be specified with few letters which is unambiguous, like `l` for 'locals'.
662
+ * `i[nfo] l or locals or local_variables`
649
663
  * Show information about the current frame (local variables)
650
- * It includes `self` as `%self` and a return value as `%return`.
651
- * `i[nfo] i[var[s]]` or `i[nfo] instance`
664
+ * It includes `self` as `%self` and a return value as `_return`.
665
+ * `i[nfo] i or ivars or instance_variables`
652
666
  * Show information about instance variables about `self`.
653
- * `i[nfo] c[onst[s]]` or `i[nfo] constant[s]`
667
+ * `info ivars <expr>` shows the instance variables of the result of `<expr>`.
668
+ * `i[nfo] c or consts or constants`
654
669
  * Show information about accessible constants except toplevel constants.
655
- * `i[nfo] g[lobal[s]]`
670
+ * `info consts <expr>` shows the constants of a class/module of the result of `<expr>`
671
+ * `i[nfo] g or globals or global_variables`
656
672
  * Show information about global variables
673
+ * `i[nfo] th or threads`
674
+ * Show all threads (same as `th[read]`).
675
+ * `i[nfo] b or breakpoints or w or watchpoints`
676
+ * Show all breakpoints and watchpoints.
657
677
  * `i[nfo] ... /regexp/`
658
678
  * Filter the output with `/regexp/`.
659
- * `i[nfo] th[read[s]]`
660
- * Show all threads (same as `th[read]`).
661
679
  * `o[utline]` or `ls`
662
680
  * Show you available methods, constants, local variables, and instance variables in the current scope.
663
681
  * `o[utline] <expr>` or `ls <expr>`
@@ -822,11 +840,11 @@ It is useful if you only want to call a debug command and don't want to stop the
822
840
  ```
823
841
  def initialize
824
842
  @a = 1
825
- binding.b do: 'watch @a'
843
+ binding.b do: 'info \n watch @a'
826
844
  end
827
845
  ```
828
846
 
829
- On this case, register a watch breakpoint for `@a` and continue to run.
847
+ On this case, execute the `info` command then register a watch breakpoint for `@a` and continue to run. You can also use `;;` instead of `\n` to separate your commands.
830
848
 
831
849
  If `pre: 'command'` is specified, the debugger suspends the program and run the `command` as a debug command, and keep suspend.
832
850
  It is useful if you have operations before suspend.
@@ -900,6 +918,11 @@ NOTE
900
918
 
901
919
  ```
902
920
 
921
+ # Additional Resources
922
+
923
+ - [From byebug to ruby/debug](https://st0012.dev/from-byebug-to-ruby-debug) by Stan Lo - A migration guide for `byebug` users.
924
+ - [ruby/debug cheatsheet](https://st0012.dev/ruby-debug-cheatsheet) by Stan Lo
925
+
903
926
  # Contributing
904
927
 
905
928
  Bug reports and pull requests are welcome on GitHub at https://github.com/ruby/debug.
data/Rakefile CHANGED
File without changes
data/TODO.md CHANGED
File without changes
data/debug.gemspec CHANGED
@@ -27,6 +27,6 @@ Gem::Specification.new do |spec|
27
27
  spec.require_paths = ["lib"]
28
28
  spec.extensions = ['ext/debug/extconf.rb']
29
29
 
30
- spec.add_dependency "irb", ">= 1.3.6" # for its color_printer class, which was added after 1.3
30
+ spec.add_dependency "irb", ">= 1.5.0" # for binding.irb(show_code: false)
31
31
  spec.add_dependency "reline", ">= 0.3.1"
32
32
  end
data/exe/rdbg CHANGED
@@ -10,7 +10,7 @@ when :start
10
10
  require 'rbconfig'
11
11
 
12
12
  libpath = File.join(File.expand_path(File.dirname(__dir__)), 'lib/debug')
13
- start_mode = config[:remote] ? "open" : 'start'
13
+ start_mode = config[:open] ? "open" : 'start'
14
14
  cmd = config[:command] ? ARGV.shift : (ENV['RUBY'] || RbConfig.ruby)
15
15
 
16
16
  if defined?($:.resolve_feature_path)
data/ext/debug/debug.c CHANGED
@@ -76,7 +76,12 @@ di_body(const rb_debug_inspector_t *dc, void *ptr)
76
76
  rb_debug_inspector_frame_binding_get(dc, i),
77
77
  iseq,
78
78
  rb_debug_inspector_frame_class_get(dc, i),
79
- INT2FIX(len - i));
79
+ #ifdef RB_DEBUG_INSPECTOR_FRAME_DEPTH
80
+ rb_debug_inspector_frame_depth(dc, i)
81
+ #else
82
+ INT2FIX(len - i)
83
+ #endif
84
+ );
80
85
  rb_ary_push(ary, e);
81
86
  }
82
87
 
@@ -89,6 +94,13 @@ capture_frames(VALUE self, VALUE skip_path_prefix)
89
94
  return rb_debug_inspector_open(di_body, (void *)skip_path_prefix);
90
95
  }
91
96
 
97
+ #ifdef RB_DEBUG_INSPECTOR_FRAME_DEPTH
98
+ static VALUE
99
+ frame_depth(VALUE self)
100
+ {
101
+ return rb_debug_inspector_current_depth();
102
+ }
103
+ #else
92
104
  static VALUE
93
105
  frame_depth(VALUE self)
94
106
  {
@@ -96,6 +108,8 @@ frame_depth(VALUE self)
96
108
  VALUE bt = rb_make_backtrace();
97
109
  return INT2FIX(RARRAY_LEN(bt));
98
110
  }
111
+ #endif
112
+
99
113
 
100
114
  // iseq
101
115
 
data/ext/debug/extconf.rb CHANGED
File without changes
File without changes
@@ -0,0 +1,77 @@
1
+
2
+ module DEBUGGER__
3
+ class AbbrevCommand
4
+ class TrieNode
5
+ def initialize
6
+ @children = {}
7
+ @types = {} # set
8
+ end
9
+
10
+ def append c, type
11
+ trie = (@children[c] ||= TrieNode.new)
12
+ trie.add_type type
13
+ end
14
+
15
+ def [](c)
16
+ @children[c]
17
+ end
18
+
19
+ def add_type type
20
+ @types[type] = true
21
+ self
22
+ end
23
+
24
+ def types
25
+ @types.keys
26
+ end
27
+
28
+ def type
29
+ if @types.size == 1
30
+ @types.keys.first
31
+ else
32
+ nil
33
+ end
34
+ end
35
+
36
+ def candidates
37
+ @children.map{|c, n|
38
+ ss = n.candidates
39
+ ss.empty? ? c :
40
+ ss.map{|s|
41
+ c+s
42
+ }
43
+ }.flatten
44
+ end
45
+ end
46
+
47
+ # config: { type: [commands...], ... }
48
+ def initialize config
49
+ @trie = TrieNode.new
50
+ build config
51
+ end
52
+
53
+ private def build config
54
+ config.each do |type, commands|
55
+ commands.each do |command|
56
+ trie = @trie
57
+ command.each_char do |c|
58
+ trie = trie.append(c, type)
59
+ end
60
+ end
61
+ end
62
+ end
63
+
64
+ def search str, if_none = nil
65
+ trie = @trie
66
+ str.each_char do |c|
67
+ if trie = trie[c]
68
+ return trie.type if trie.type
69
+ else
70
+ return if_none
71
+ end
72
+ end
73
+ yield trie.candidates.map{|s| str + s} if block_given?
74
+ if_none
75
+ end
76
+ end
77
+ end
@@ -6,7 +6,7 @@ module DEBUGGER__
6
6
  class Breakpoint
7
7
  include SkipPathHelper
8
8
 
9
- attr_reader :key
9
+ attr_reader :key, :skip_src
10
10
 
11
11
  def initialize cond, command, path, do_enable: true
12
12
  @deleted = false
@@ -101,6 +101,10 @@ module DEBUGGER__
101
101
  def generate_label(name)
102
102
  colorize(" BP - #{name} ", [:YELLOW, :BOLD, :REVERSE])
103
103
  end
104
+
105
+ def pending_until_load?
106
+ false
107
+ end
104
108
  end
105
109
 
106
110
  if RUBY_VERSION.to_f <= 2.7
@@ -141,10 +145,11 @@ module DEBUGGER__
141
145
  nbp
142
146
  end
143
147
 
144
- def initialize path, line, cond: nil, oneshot: false, hook_call: true, command: nil, skip_activate: false
148
+ def initialize path, line, cond: nil, oneshot: false, hook_call: true, command: nil, skip_activate: false, skip_src: false
145
149
  @line = line
146
150
  @oneshot = oneshot
147
151
  @hook_call = hook_call
152
+ @skip_src = skip_src
148
153
  @pending = false
149
154
 
150
155
  @iseq = nil
@@ -158,6 +163,10 @@ module DEBUGGER__
158
163
  @pending = !@iseq
159
164
  end
160
165
 
166
+ def pending_until_load?
167
+ @pending
168
+ end
169
+
161
170
  def setup
162
171
  return unless @type
163
172
 
@@ -196,7 +205,7 @@ module DEBUGGER__
196
205
  enable
197
206
 
198
207
  if @pending && !@oneshot
199
- DEBUGGER__.warn "#{self} is activated."
208
+ DEBUGGER__.info "#{self} is activated."
200
209
  end
201
210
  end
202
211
 
@@ -264,13 +273,10 @@ module DEBUGGER__
264
273
 
265
274
  if !nearest || ((line - nline).abs < (line - nearest.line).abs)
266
275
  nearest = NearestISeq.new(iseq, nline, events)
267
- else
268
- if @hook_call && nearest.iseq.first_lineno <= iseq.first_lineno
269
- if (nearest.line > line && !nearest.events.include?(:RUBY_EVENT_CALL)) ||
270
- (events.include?(:RUBY_EVENT_CALL))
271
- nearest = NearestISeq.new(iseq, nline, events)
272
- end
273
- end
276
+ elsif @hook_call &&
277
+ nearest.line == iseq.first_line &&
278
+ events.include?(:RUBY_EVENT_CALL)
279
+ nearest = NearestISeq.new(iseq, nline, events)
274
280
  end
275
281
  end
276
282
  end
@@ -500,7 +506,7 @@ module DEBUGGER__
500
506
  retried = false
501
507
 
502
508
  @tp.enable(target: @method)
503
- DEBUGGER__.warn "#{self} is activated." if added
509
+ DEBUGGER__.info "#{self} is activated." if added
504
510
 
505
511
  if @sig_op == '#'
506
512
  @cond_class = @klass if @method.owner != @klass
data/lib/debug/client.rb CHANGED
@@ -25,6 +25,9 @@ module DEBUGGER__
25
25
  when 'list-socks'
26
26
  cleanup_unix_domain_sockets
27
27
  puts list_connections
28
+ when 'list-socks-verbose'
29
+ cleanup_unix_domain_sockets
30
+ puts list_connections verbose: true
28
31
  when 'setup-autoload'
29
32
  setup_autoload
30
33
  else
@@ -91,10 +94,24 @@ module DEBUGGER__
91
94
  end
92
95
  end
93
96
 
94
- def list_connections
95
- Dir.glob(DEBUGGER__.create_unix_domain_socket_name_prefix + '*').find_all do |path|
97
+ def list_connections verbose: false
98
+ socks = Dir.glob(DEBUGGER__.create_unix_domain_socket_name_prefix + '*').find_all do |path|
96
99
  File.socket?(path)
97
100
  end
101
+
102
+ if verbose
103
+ socks = socks.map{|sock_path|
104
+ Socket.unix(sock_path){|sock|
105
+ sock.puts "info cookie: #{CONFIG[:cookie] || '-'}"
106
+ pid = sock.gets.chomp
107
+ _dbg = sock.gets.chomp
108
+ _unm = sock.gets.chomp
109
+ [sock_path, pid]
110
+ }
111
+ }
112
+ end
113
+
114
+ socks
98
115
  end
99
116
  end
100
117
 
@@ -148,18 +165,18 @@ module DEBUGGER__
148
165
  end
149
166
  else
150
167
  Client.cleanup_unix_domain_sockets
151
- files = Client.list_connections
168
+ files = Client.list_connections verbose: true
152
169
 
153
170
  case files.size
154
171
  when 0
155
172
  $stderr.puts "No debug session is available."
156
173
  exit
157
174
  when 1
158
- @s = Socket.unix(files.first)
175
+ @s = Socket.unix(files.first.first)
159
176
  else
160
177
  $stderr.puts "Please select a debug session:"
161
- files.each{|f|
162
- $stderr.puts " #{File.basename(f)}"
178
+ files.each{|(f, desc)|
179
+ $stderr.puts " #{File.basename(f)} (#{desc})"
163
180
  }
164
181
  exit
165
182
  end
@@ -222,7 +239,7 @@ module DEBUGGER__
222
239
  when /^ask (\d+) (.*)/
223
240
  pid = $1
224
241
  print $2
225
- send "answer #{pid} #{gets || ''}"
242
+ send "answer #{pid} #{$stdin.gets || ''}"
226
243
 
227
244
  when /^quit/
228
245
  raise 'quit'
@@ -231,8 +248,8 @@ module DEBUGGER__
231
248
  puts "(unknown) #{line.inspect}"
232
249
  end
233
250
  end
234
- rescue
235
- STDERR.puts "disconnected (#{$!})"
251
+ rescue => e
252
+ STDERR.puts "disconnected (#{e})"
236
253
  exit
237
254
  ensure
238
255
  deactivate
data/lib/debug/color.rb CHANGED
File without changes
data/lib/debug/config.rb CHANGED
@@ -14,6 +14,7 @@ module DEBUGGER__
14
14
  # UI setting
15
15
  log_level: ['RUBY_DEBUG_LOG_LEVEL', "UI: Log level same as Logger", :loglevel, "WARN"],
16
16
  show_src_lines: ['RUBY_DEBUG_SHOW_SRC_LINES', "UI: Show n lines source code on breakpoint", :int, "10"],
17
+ show_evaledsrc: ['RUBY_DEBUG_SHOW_EVALEDSRC', "UI: Show actually evaluated source", :bool, "false"],
17
18
  show_frames: ['RUBY_DEBUG_SHOW_FRAMES', "UI: Show n frames on breakpoint", :int, "2"],
18
19
  use_short_path: ['RUBY_DEBUG_USE_SHORT_PATH', "UI: Show shorten PATH (like $(Gem)/foo.rb)", :bool, "false"],
19
20
  no_color: ['RUBY_DEBUG_NO_COLOR', "UI: Do not use colorize", :bool, "false"],
@@ -33,12 +34,13 @@ module DEBUGGER__
33
34
  nonstop: ['RUBY_DEBUG_NONSTOP', "BOOT: Nonstop mode", :bool, "false"],
34
35
  stop_at_load: ['RUBY_DEBUG_STOP_AT_LOAD',"BOOT: Stop at just loading location", :bool, "false"],
35
36
  init_script: ['RUBY_DEBUG_INIT_SCRIPT', "BOOT: debug command script path loaded at first stop"],
36
- commands: ['RUBY_DEBUG_COMMANDS', "BOOT: debug commands invoked at first stop. commands should be separated by ';;'"],
37
+ commands: ['RUBY_DEBUG_COMMANDS', "BOOT: debug commands invoked at first stop. Commands should be separated by `;;`"],
37
38
  no_rc: ['RUBY_DEBUG_NO_RC', "BOOT: ignore loading ~/.rdbgrc(.rb)", :bool, "false"],
38
39
  history_file: ['RUBY_DEBUG_HISTORY_FILE',"BOOT: history file", :string, "~/.rdbg_history"],
39
40
  save_history: ['RUBY_DEBUG_SAVE_HISTORY',"BOOT: maximum save history lines", :int, "10000"],
40
41
 
41
42
  # remote setting
43
+ open: ['RUBY_DEBUG_OPEN', "REMOTE: Open remote port (same as `rdbg --open` option)"],
42
44
  port: ['RUBY_DEBUG_PORT', "REMOTE: TCP/IP remote debugging: port"],
43
45
  host: ['RUBY_DEBUG_HOST', "REMOTE: TCP/IP remote debugging: host", :string, "127.0.0.1"],
44
46
  sock_path: ['RUBY_DEBUG_SOCK_PATH', "REMOTE: UNIX Domain Socket remote debugging: socket path"],
@@ -46,7 +48,6 @@ module DEBUGGER__
46
48
  local_fs_map: ['RUBY_DEBUG_LOCAL_FS_MAP', "REMOTE: Specify local fs map", :path_map],
47
49
  skip_bp: ['RUBY_DEBUG_SKIP_BP', "REMOTE: Skip breakpoints if no clients are attached", :bool, 'false'],
48
50
  cookie: ['RUBY_DEBUG_COOKIE', "REMOTE: Cookie for negotiation"],
49
- open_frontend: ['RUBY_DEBUG_OPEN_FRONTEND',"REMOTE: frontend used by open command (vscode, chrome, default: rdbg)."],
50
51
  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))"],
51
52
 
52
53
  # obsolete
@@ -63,8 +64,6 @@ module DEBUGGER__
63
64
  end
64
65
 
65
66
  def initialize argv
66
- @skip_all = false
67
-
68
67
  if self.class.config
69
68
  raise 'Can not make multiple configurations in one process'
70
69
  end
@@ -94,14 +93,6 @@ module DEBUGGER__
94
93
  set_config(key => val)
95
94
  end
96
95
 
97
- def skip_all
98
- @skip_all = true
99
- end
100
-
101
- def skip?
102
- @skip_all
103
- end
104
-
105
96
  def set_config(**kw)
106
97
  conf = config.dup
107
98
  kw.each{|k, v|
@@ -158,6 +149,12 @@ module DEBUGGER__
158
149
  if_updated old_conf, conf, :sigdump_sig do |old_sig, new_sig|
159
150
  setup_sigdump old_sig, new_sig
160
151
  end
152
+
153
+ if_updated old_conf, conf, :no_sigint_hook do |old, new|
154
+ if defined?(SESSION)
155
+ SESSION.set_no_sigint_hook old, new
156
+ end
157
+ end
161
158
  end
162
159
 
163
160
  private def if_updated old_conf, new_conf, key
@@ -308,8 +305,25 @@ module DEBUGGER__
308
305
  'If TCP/IP options are not given, a UNIX domain socket will be used.',
309
306
  'If FRONTEND is given, prepare for the FRONTEND.',
310
307
  'Now rdbg, vscode and chrome is supported.') do |f|
311
- config[:remote] = true
312
- config[:open_frontend] = f.downcase if f
308
+
309
+ case f # some format patterns are not documented yet
310
+ when nil
311
+ config[:open] = true
312
+ when /\A\d\z/
313
+ config[:open] = true
314
+ config[:port] = f.to_i
315
+ when /\A(\S+):(\d+)\z/
316
+ config[:open] = true
317
+ config[:host] = $1
318
+ config[:port] = $2.to_i
319
+ when 'tcp'
320
+ config[:open] = true
321
+ config[:port] ||= 0
322
+ when 'vscode', 'chrome', 'cdp'
323
+ config[:open] = f&.downcase
324
+ else
325
+ raise "Unknown option for --open: #{f}"
326
+ end
313
327
  end
314
328
  o.on('--sock-path=SOCK_PATH', 'UNIX Domain socket path') do |path|
315
329
  config[:sock_path] = path
@@ -479,10 +493,14 @@ module DEBUGGER__
479
493
  when /\A\s*### (.+)/
480
494
  cat = $1
481
495
  break if $1 == 'END'
482
- when /\A when (.+)/
496
+ when /\A register_command (.+)/
483
497
  next unless cat
484
498
  next unless desc
485
- ws = $1.split(/,\s*/).map{|e| e.gsub('\'', '')}
499
+
500
+ ws = []
501
+ $1.gsub(/'([a-z]+)'/){|w|
502
+ ws << $1
503
+ }
486
504
  helps[cat] << [ws, desc]
487
505
  desc = nil
488
506
  max_w = ws.max_by{|w| w.length}
data/lib/debug/console.rb CHANGED
File without changes
File without changes
data/lib/debug/local.rb CHANGED
@@ -13,23 +13,28 @@ module DEBUGGER__
13
13
  false
14
14
  end
15
15
 
16
- def activate session, on_fork: false
17
- unless CONFIG[:no_sigint_hook]
18
- prev_handler = trap(:SIGINT){
19
- if session.active?
20
- ThreadClient.current.on_trap :SIGINT
21
- end
22
- }
23
- session.intercept_trap_sigint_start prev_handler
24
- end
16
+ def activate_sigint
17
+ prev_handler = trap(:SIGINT){
18
+ if SESSION.active?
19
+ ThreadClient.current.on_trap :SIGINT
20
+ end
21
+ }
22
+ SESSION.intercept_trap_sigint_start prev_handler
25
23
  end
26
24
 
27
- def deactivate
25
+ def deactivate_sigint
28
26
  if SESSION.intercept_trap_sigint?
29
27
  prev = SESSION.intercept_trap_sigint_end
30
28
  trap(:SIGINT, prev)
31
29
  end
30
+ end
31
+
32
+ def activate session, on_fork: false
33
+ activate_sigint unless CONFIG[:no_sigint_hook]
34
+ end
32
35
 
36
+ def deactivate
37
+ deactivate_sigint
33
38
  @console.deactivate
34
39
  end
35
40
 
@@ -42,6 +47,7 @@ module DEBUGGER__
42
47
  end
43
48
 
44
49
  def quit n
50
+ yield
45
51
  exit n
46
52
  end
47
53
 
data/lib/debug/open.rb CHANGED
File without changes
File without changes