debug 1.0.0.beta5 → 1.0.0.beta6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CONTRIBUTING.md +193 -2
- data/README.md +20 -12
- data/bin/gentest +22 -0
- data/exe/rdbg +9 -13
- data/lib/debug.rb +3 -0
- data/lib/debug/breakpoint.rb +11 -0
- data/lib/debug/client.rb +5 -7
- data/lib/debug/color.rb +5 -3
- data/lib/debug/config.rb +25 -13
- data/lib/debug/console.rb +13 -0
- data/lib/debug/frame_info.rb +2 -1
- data/lib/debug/open.rb +1 -0
- data/lib/debug/run.rb +3 -2
- data/lib/debug/server.rb +25 -16
- data/lib/debug/server_dap.rb +4 -2
- data/lib/debug/session.rb +140 -64
- data/lib/debug/source_repository.rb +2 -0
- data/lib/debug/thread_client.rb +43 -31
- data/lib/debug/version.rb +3 -1
- data/misc/README.md.erb +13 -9
- metadata +3 -3
- data/lib/debug/test_console.rb +0 -0
data/lib/debug/thread_client.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'objspace'
|
2
4
|
require 'pp'
|
3
5
|
|
@@ -136,6 +138,11 @@ module DEBUGGER__
|
|
136
138
|
wait_next_action
|
137
139
|
end
|
138
140
|
|
141
|
+
def on_init name
|
142
|
+
event! :init, name
|
143
|
+
wait_next_action
|
144
|
+
end
|
145
|
+
|
139
146
|
def on_breakpoint tp, bp
|
140
147
|
on_suspend tp.event, tp, bp: bp
|
141
148
|
end
|
@@ -394,7 +401,7 @@ module DEBUGGER__
|
|
394
401
|
end
|
395
402
|
end
|
396
403
|
|
397
|
-
def
|
404
|
+
def make_breakpoint args
|
398
405
|
case args.first
|
399
406
|
when :method
|
400
407
|
klass_name, op, method_name, cond = args[1..]
|
@@ -405,7 +412,11 @@ module DEBUGGER__
|
|
405
412
|
puts e.message
|
406
413
|
::DEBUGGER__::METHOD_ADDED_TRACKER.enable
|
407
414
|
end
|
408
|
-
|
415
|
+
|
416
|
+
bp
|
417
|
+
when :watch
|
418
|
+
ivar, object, result = args[1..]
|
419
|
+
WatchIVarBreakpoint.new(ivar, object, result)
|
409
420
|
else
|
410
421
|
raise "unknown breakpoint: #{args}"
|
411
422
|
end
|
@@ -437,11 +448,15 @@ module DEBUGGER__
|
|
437
448
|
frame = @target_frames.first
|
438
449
|
path = frame.location.absolute_path || "!eval:#{frame.path}"
|
439
450
|
line = frame.location.lineno
|
440
|
-
|
441
|
-
|
442
|
-
|
443
|
-
next_line =
|
451
|
+
|
452
|
+
if frame.iseq
|
453
|
+
frame.iseq.traceable_lines_norec(lines = {})
|
454
|
+
next_line = lines.keys.bsearch{|e| e > line}
|
455
|
+
if !next_line && (last_line = frame.iseq.last_line) > line
|
456
|
+
next_line = last_line
|
457
|
+
end
|
444
458
|
end
|
459
|
+
|
445
460
|
depth = @target_frames.first.frame_depth
|
446
461
|
|
447
462
|
step_tp{
|
@@ -469,17 +484,14 @@ module DEBUGGER__
|
|
469
484
|
when :eval
|
470
485
|
eval_type, eval_src = *args
|
471
486
|
|
472
|
-
case eval_type
|
473
|
-
when :display, :try_display
|
474
|
-
else
|
475
|
-
result = frame_eval(eval_src)
|
476
|
-
end
|
477
487
|
result_type = nil
|
478
488
|
|
479
489
|
case eval_type
|
480
490
|
when :p
|
491
|
+
result = frame_eval(eval_src)
|
481
492
|
puts "=> " + result.inspect
|
482
493
|
when :pp
|
494
|
+
result = frame_eval(eval_src)
|
483
495
|
puts "=> "
|
484
496
|
PP.pp(result, out = ''.dup, SESSION.width)
|
485
497
|
puts out
|
@@ -497,23 +509,6 @@ module DEBUGGER__
|
|
497
509
|
|
498
510
|
result_type = eval_type
|
499
511
|
result = failed_results
|
500
|
-
when :watch
|
501
|
-
if @success_last_eval
|
502
|
-
if eval_src.match?(/@\w+/)
|
503
|
-
object =
|
504
|
-
if b = current_frame.binding
|
505
|
-
b.receiver
|
506
|
-
else
|
507
|
-
current_frame.self
|
508
|
-
end
|
509
|
-
puts "#{object} #{eval_src} = #{result}"
|
510
|
-
result = WatchIVarBreakpoint.new(eval_src, object, result)
|
511
|
-
end
|
512
|
-
|
513
|
-
result_type = :watch
|
514
|
-
else
|
515
|
-
result = nil
|
516
|
-
end
|
517
512
|
else
|
518
513
|
raise "unknown error option: #{args.inspect}"
|
519
514
|
end
|
@@ -576,13 +571,30 @@ module DEBUGGER__
|
|
576
571
|
end
|
577
572
|
|
578
573
|
event! :result, nil
|
579
|
-
|
580
574
|
when :breakpoint
|
581
|
-
|
575
|
+
case args[0]
|
576
|
+
when :method
|
577
|
+
bp = make_breakpoint args
|
578
|
+
event! :result, :method_breakpoint, bp
|
579
|
+
when :watch
|
580
|
+
ivar = args[1]
|
581
|
+
result = frame_eval(ivar)
|
582
582
|
|
583
|
+
if @success_last_eval
|
584
|
+
object =
|
585
|
+
if b = current_frame.binding
|
586
|
+
b.receiver
|
587
|
+
else
|
588
|
+
current_frame.self
|
589
|
+
end
|
590
|
+
bp = make_breakpoint [:watch, ivar, object, result]
|
591
|
+
event! :result, :watch_breakpoint, bp
|
592
|
+
else
|
593
|
+
event! :result, nil
|
594
|
+
end
|
595
|
+
end
|
583
596
|
when :dap
|
584
597
|
process_dap args
|
585
|
-
|
586
598
|
else
|
587
599
|
raise [cmd, *args].inspect
|
588
600
|
end
|
data/lib/debug/version.rb
CHANGED
data/misc/README.md.erb
CHANGED
@@ -11,7 +11,7 @@ New debug.rb has several advantages:
|
|
11
11
|
* Remote debugging: Support remote debugging natively.
|
12
12
|
* UNIX domain socket
|
13
13
|
* TCP/IP
|
14
|
-
* VSCode/DAP integration (
|
14
|
+
* VSCode/DAP integration ([VSCode rdbg Ruby Debugger - Visual Studio Marketplace](https://marketplace.visualstudio.com/items?itemName=KoichiSasada.vscode-rdbg))
|
15
15
|
* Extensible: application can introduce debugging support with several methods
|
16
16
|
* By `rdbg` command
|
17
17
|
* By loading libraries with `-r` command line option
|
@@ -29,6 +29,16 @@ $ gem install debug --pre
|
|
29
29
|
|
30
30
|
or specify `-Ipath/to/debug/lib` in `RUBYOPT` or each ruby command-line option, especially for debug this gem development.
|
31
31
|
|
32
|
+
If you use Bundler, write the following line to your Gemfile. And use rdbg command with -c option.
|
33
|
+
|
34
|
+
```
|
35
|
+
gem "debug", ">= 1.0.0.beta"
|
36
|
+
```
|
37
|
+
|
38
|
+
```
|
39
|
+
$ rdbg -c bundle exec ruby target.rb
|
40
|
+
```
|
41
|
+
|
32
42
|
# How to use
|
33
43
|
|
34
44
|
## Invoke with debugger
|
@@ -70,10 +80,6 @@ $ ruby -r debug/run target.rb
|
|
70
80
|
# target.rb
|
71
81
|
require 'debug/run' # start the debug console
|
72
82
|
|
73
|
-
# or
|
74
|
-
|
75
|
-
require 'debug/session' # introduce the functionality
|
76
|
-
DEBUGGER__.console # and start the debug console
|
77
83
|
# ... rest of program ...
|
78
84
|
```
|
79
85
|
|
@@ -300,11 +306,9 @@ $ rdbg --attach hostname 12345
|
|
300
306
|
|
301
307
|
### Initial scripts
|
302
308
|
|
303
|
-
If there are
|
304
|
-
|
305
|
-
Initial scripts are evaluated at the first suspend timing (generally, it is the beginning of the target script). For example, you can set break points with `break file:123`.
|
309
|
+
If there are `~/.rdbgrc`, the file is loaded as initial scripts which contains debugger commands at the beginning of debug session. `RUBY_DEBUG_INIT_SCRIPT` environment variable can specify the initial script file. You can write configurations in a file. For example, you can set break points with `break file:123` in `~/.rdbgrc`.
|
306
310
|
|
307
|
-
If there are
|
311
|
+
If there are `~/.rdbgrc.rb` is available, it is loaded as a ruby script at same timing.
|
308
312
|
|
309
313
|
### Environment variables
|
310
314
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: debug
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.0.
|
4
|
+
version: 1.0.0.beta6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Koichi Sasada
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-07-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: irb
|
@@ -43,6 +43,7 @@ files:
|
|
43
43
|
- Rakefile
|
44
44
|
- TODO.md
|
45
45
|
- bin/console
|
46
|
+
- bin/gentest
|
46
47
|
- bin/setup
|
47
48
|
- debug.gemspec
|
48
49
|
- exe/rdbg
|
@@ -63,7 +64,6 @@ files:
|
|
63
64
|
- lib/debug/server_dap.rb
|
64
65
|
- lib/debug/session.rb
|
65
66
|
- lib/debug/source_repository.rb
|
66
|
-
- lib/debug/test_console.rb
|
67
67
|
- lib/debug/thread_client.rb
|
68
68
|
- lib/debug/version.rb
|
69
69
|
- misc/README.md.erb
|
data/lib/debug/test_console.rb
DELETED
File without changes
|