debug 1.7.0 → 1.7.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/TODO.md +8 -8
- data/lib/debug/prelude.rb +1 -1
- data/lib/debug/server_cdp.rb +22 -17
- data/lib/debug/server_dap.rb +28 -15
- data/lib/debug/thread_client.rb +10 -3
- data/lib/debug/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a84e87e9582c98cf24ca8aa9f1f30032c10736bf4dbc1c44da016db564a7a574
|
4
|
+
data.tar.gz: da093ef6ebfd8fc5e4a10fcc39c59826e45829ec09da0d9dc164b9cd71085286
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d663b6db0dba8921aaaa535f834e768367e07fef03613e6a277a27724fb75ecf830c7557465521998d42cbb41744e6335495958f626285468d6e38ae6ec52515
|
7
|
+
data.tar.gz: cb24e62c5875c069812ff1b056dda3b912a20069d09123b72dbd0da69e61aed66968bc4dc5f80e9b599df743fb7755a2399f1461f344fc43ed9ea6bbf20f251c
|
data/TODO.md
CHANGED
@@ -2,22 +2,22 @@
|
|
2
2
|
|
3
3
|
## Basic functionality
|
4
4
|
|
5
|
-
* Support Ractors
|
6
|
-
* Signal (SIGINT) trap handling
|
5
|
+
* Support Fibers and Ractors
|
7
6
|
|
8
7
|
## UI
|
9
8
|
|
9
|
+
* Multi-line support
|
10
10
|
* Completion for Ruby's code
|
11
11
|
* Interactive breakpoint setting
|
12
12
|
* Interactive record & play debugging
|
13
13
|
* irb integration
|
14
|
-
* Web browser integrated UI
|
15
|
-
* History file
|
16
14
|
|
17
15
|
## Debug command
|
18
16
|
|
19
|
-
* Breakpoints
|
20
|
-
* Lightweight pending method break points with Ruby 3.1 feature (TP:method_added)
|
21
17
|
* Watch points
|
22
|
-
* Lightweight watchpoints for instance variables with Ruby 3.
|
23
|
-
*
|
18
|
+
* Lightweight watchpoints for instance variables with Ruby 3.3 features (TP:ivar_set)
|
19
|
+
* Alias
|
20
|
+
|
21
|
+
## Debug port
|
22
|
+
|
23
|
+
* Debug port for monitoring
|
data/lib/debug/prelude.rb
CHANGED
data/lib/debug/server_cdp.rb
CHANGED
@@ -34,25 +34,26 @@ module DEBUGGER__
|
|
34
34
|
|
35
35
|
loop do
|
36
36
|
res = ws_client.extract_data
|
37
|
-
case
|
38
|
-
when
|
37
|
+
case res['id']
|
38
|
+
when 1
|
39
|
+
target_info = res.dig('result', 'targetInfos')
|
39
40
|
page = target_info.find{|t| t['type'] == 'page'}
|
40
41
|
ws_client.send id: 2, method: 'Target.attachToTarget',
|
41
42
|
params: {
|
42
43
|
targetId: page['targetId'],
|
43
44
|
flatten: true
|
44
45
|
}
|
45
|
-
when
|
46
|
+
when 2
|
46
47
|
s_id = res.dig('result', 'sessionId')
|
47
48
|
# TODO: change id
|
48
49
|
ws_client.send sessionId: s_id, id: 100, method: 'Network.enable'
|
49
50
|
ws_client.send sessionId: s_id, id: 3,
|
50
51
|
method: 'Page.enable'
|
51
|
-
when
|
52
|
+
when 3
|
52
53
|
s_id = res['sessionId']
|
53
54
|
ws_client.send sessionId: s_id, id: 4,
|
54
55
|
method: 'Page.getFrameTree'
|
55
|
-
when
|
56
|
+
when 4
|
56
57
|
s_id = res['sessionId']
|
57
58
|
f_id = res.dig('result', 'frameTree', 'frame', 'id')
|
58
59
|
ws_client.send sessionId: s_id, id: 5,
|
@@ -61,17 +62,19 @@ module DEBUGGER__
|
|
61
62
|
url: "devtools://devtools/bundled/inspector.html?v8only=true&panel=sources&ws=#{addr}/#{uuid}",
|
62
63
|
frameId: f_id
|
63
64
|
}
|
64
|
-
when
|
65
|
-
s_id = res['sessionId']
|
66
|
-
# Display the console by entering ESC key
|
67
|
-
ws_client.send sessionId: s_id, id: 101, # TODO: change id
|
68
|
-
method:"Input.dispatchKeyEvent",
|
69
|
-
params: {
|
70
|
-
type:"keyDown",
|
71
|
-
windowsVirtualKeyCode:27 # ESC key
|
72
|
-
}
|
73
|
-
when res['id'] == 101
|
65
|
+
when 101
|
74
66
|
break
|
67
|
+
else
|
68
|
+
if res['method'] == 'Network.webSocketWillSendHandshakeRequest'
|
69
|
+
s_id = res['sessionId']
|
70
|
+
# Display the console by entering ESC key
|
71
|
+
ws_client.send sessionId: s_id, id: 101, # TODO: change id
|
72
|
+
method:"Input.dispatchKeyEvent",
|
73
|
+
params: {
|
74
|
+
type:"keyDown",
|
75
|
+
windowsVirtualKeyCode:27 # ESC key
|
76
|
+
}
|
77
|
+
end
|
75
78
|
end
|
76
79
|
end
|
77
80
|
pid
|
@@ -696,6 +699,8 @@ module DEBUGGER__
|
|
696
699
|
end
|
697
700
|
|
698
701
|
class Session
|
702
|
+
include GlobalVariablesHelper
|
703
|
+
|
699
704
|
# FIXME: unify this method with ThreadClient#propertyDescriptor.
|
700
705
|
def get_type obj
|
701
706
|
case obj
|
@@ -750,7 +755,7 @@ module DEBUGGER__
|
|
750
755
|
fid = @frame_map[frame_id]
|
751
756
|
request_tc [:cdp, :scope, req, fid]
|
752
757
|
when 'global'
|
753
|
-
vars =
|
758
|
+
vars = safe_global_variables.sort.map do |name|
|
754
759
|
gv = eval(name.to_s)
|
755
760
|
prop = {
|
756
761
|
name: name,
|
@@ -1040,7 +1045,7 @@ module DEBUGGER__
|
|
1040
1045
|
case expr
|
1041
1046
|
# Chrome doesn't read instance variables
|
1042
1047
|
when /\A\$\S/
|
1043
|
-
|
1048
|
+
safe_global_variables.each{|gvar|
|
1044
1049
|
if gvar.to_s == expr
|
1045
1050
|
result = eval(gvar.to_s)
|
1046
1051
|
break false
|
data/lib/debug/server_dap.rb
CHANGED
@@ -452,7 +452,11 @@ module DEBUGGER__
|
|
452
452
|
@q_msg << req
|
453
453
|
|
454
454
|
else
|
455
|
-
|
455
|
+
if respond_to? mid = "request_#{req['command']}"
|
456
|
+
send mid, req
|
457
|
+
else
|
458
|
+
raise "Unknown request: #{req.inspect}"
|
459
|
+
end
|
456
460
|
end
|
457
461
|
end
|
458
462
|
ensure
|
@@ -516,6 +520,8 @@ module DEBUGGER__
|
|
516
520
|
end
|
517
521
|
|
518
522
|
class Session
|
523
|
+
include GlobalVariablesHelper
|
524
|
+
|
519
525
|
def find_waiting_tc id
|
520
526
|
@th_clients.each{|th, tc|
|
521
527
|
return tc if tc.id == id && tc.waiting?
|
@@ -562,8 +568,12 @@ module DEBUGGER__
|
|
562
568
|
if ref = @var_map[varid]
|
563
569
|
case ref[0]
|
564
570
|
when :globals
|
565
|
-
vars =
|
566
|
-
|
571
|
+
vars = safe_global_variables.sort.map do |name|
|
572
|
+
begin
|
573
|
+
gv = eval(name.to_s)
|
574
|
+
rescue Exception => e
|
575
|
+
gv = e.inspect
|
576
|
+
end
|
567
577
|
{
|
568
578
|
name: name,
|
569
579
|
value: gv.inspect,
|
@@ -721,9 +731,8 @@ module DEBUGGER__
|
|
721
731
|
end
|
722
732
|
|
723
733
|
class ThreadClient
|
724
|
-
|
725
734
|
MAX_LENGTH = 180
|
726
|
-
|
735
|
+
|
727
736
|
def value_inspect obj, short: true
|
728
737
|
# TODO: max length should be configuarable?
|
729
738
|
str = DEBUGGER__.safe_inspect obj, short: short, max_length: MAX_LENGTH
|
@@ -735,6 +744,14 @@ module DEBUGGER__
|
|
735
744
|
end
|
736
745
|
end
|
737
746
|
|
747
|
+
def dap_eval b, expr, _context, prompt: '(repl_eval)'
|
748
|
+
begin
|
749
|
+
b.eval(expr.to_s, prompt)
|
750
|
+
rescue Exception => e
|
751
|
+
e
|
752
|
+
end
|
753
|
+
end
|
754
|
+
|
738
755
|
def process_dap args
|
739
756
|
# pp tc: self, args: args
|
740
757
|
type = args.shift
|
@@ -800,7 +817,7 @@ module DEBUGGER__
|
|
800
817
|
name: 'Global variables',
|
801
818
|
presentationHint: 'globals',
|
802
819
|
variablesReference: 1, # GLOBAL
|
803
|
-
namedVariables:
|
820
|
+
namedVariables: safe_global_variables.size,
|
804
821
|
indexedVariables: 0,
|
805
822
|
expensive: false,
|
806
823
|
}]
|
@@ -837,10 +854,11 @@ module DEBUGGER__
|
|
837
854
|
}
|
838
855
|
when String
|
839
856
|
vars = [
|
840
|
-
variable('#
|
857
|
+
variable('#lengthddsfsd', obj.length),
|
841
858
|
variable('#encoding', obj.encoding),
|
842
859
|
]
|
843
|
-
|
860
|
+
printed_str = value_inspect(obj)
|
861
|
+
vars << variable('#dump', NaiveString.new(obj)) if printed_str.end_with?('...')
|
844
862
|
when Class, Module
|
845
863
|
vars << variable('%ancestors', obj.ancestors[1..])
|
846
864
|
when Range
|
@@ -872,12 +890,7 @@ module DEBUGGER__
|
|
872
890
|
|
873
891
|
case context
|
874
892
|
when 'repl', 'watch'
|
875
|
-
|
876
|
-
result = b.eval(expr.to_s, '(DEBUG CONSOLE)')
|
877
|
-
rescue Exception => e
|
878
|
-
result = e
|
879
|
-
end
|
880
|
-
|
893
|
+
result = dap_eval b, expr, context, prompt: '(DEBUG CONSOLE)'
|
881
894
|
when 'hover'
|
882
895
|
case expr
|
883
896
|
when /\A\@\S/
|
@@ -887,7 +900,7 @@ module DEBUGGER__
|
|
887
900
|
message = "Error: Not defined instance variable: #{expr.inspect}"
|
888
901
|
end
|
889
902
|
when /\A\$\S/
|
890
|
-
|
903
|
+
safe_global_variables.each{|gvar|
|
891
904
|
if gvar.to_s == expr
|
892
905
|
result = eval(gvar.to_s)
|
893
906
|
break false
|
data/lib/debug/thread_client.rb
CHANGED
@@ -29,7 +29,7 @@ module DEBUGGER__
|
|
29
29
|
end
|
30
30
|
|
31
31
|
def skip_internal_path?(path)
|
32
|
-
path.start_with?(__dir__) || path.start_with?('<internal:')
|
32
|
+
path.start_with?(__dir__) || path.delete_prefix('!eval:').start_with?('<internal:')
|
33
33
|
end
|
34
34
|
|
35
35
|
def skip_location?(loc)
|
@@ -38,6 +38,13 @@ module DEBUGGER__
|
|
38
38
|
end
|
39
39
|
end
|
40
40
|
|
41
|
+
module GlobalVariablesHelper
|
42
|
+
SKIP_GLOBAL_LIST = %i[$= $KCODE $-K $SAFE].freeze
|
43
|
+
def safe_global_variables
|
44
|
+
global_variables.reject{|name| SKIP_GLOBAL_LIST.include? name }
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
41
48
|
class ThreadClient
|
42
49
|
def self.current
|
43
50
|
if thc = Thread.current[:DEBUGGER__ThreadClient]
|
@@ -50,6 +57,7 @@ module DEBUGGER__
|
|
50
57
|
|
51
58
|
include Color
|
52
59
|
include SkipPathHelper
|
60
|
+
include GlobalVariablesHelper
|
53
61
|
|
54
62
|
attr_reader :thread, :id, :recorder, :check_bp_fulfillment_map
|
55
63
|
|
@@ -636,9 +644,8 @@ module DEBUGGER__
|
|
636
644
|
end
|
637
645
|
end
|
638
646
|
|
639
|
-
SKIP_GLOBAL_LIST = %i[$= $KCODE $-K $SAFE].freeze
|
640
647
|
def show_globals pat
|
641
|
-
|
648
|
+
safe_global_variables.sort.each{|name|
|
642
649
|
next if SKIP_GLOBAL_LIST.include? name
|
643
650
|
|
644
651
|
value = eval(name.to_s)
|
data/lib/debug/version.rb
CHANGED
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.7.
|
4
|
+
version: 1.7.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Koichi Sasada
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-12-
|
11
|
+
date: 2022-12-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: irb
|