readapt 1.4.4 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (70) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/rspec.yml +38 -0
  3. data/.gitignore +16 -16
  4. data/.rspec +2 -2
  5. data/.travis.yml +19 -19
  6. data/CHANGELOG.md +103 -100
  7. data/Gemfile +4 -4
  8. data/LICENSE.txt +21 -21
  9. data/README.md +37 -37
  10. data/Rakefile +14 -14
  11. data/bin/console +14 -14
  12. data/bin/setup +8 -8
  13. data/exe/readapt +5 -5
  14. data/ext/readapt/breakpoints.c +83 -83
  15. data/ext/readapt/breakpoints.h +11 -11
  16. data/ext/readapt/extconf.rb +0 -0
  17. data/ext/readapt/frame.c +137 -137
  18. data/ext/readapt/frame.h +17 -17
  19. data/ext/readapt/inspector.c +51 -51
  20. data/ext/readapt/inspector.h +8 -8
  21. data/ext/readapt/lookup_table.c +211 -211
  22. data/ext/readapt/lookup_table.h +30 -30
  23. data/ext/readapt/monitor.c +0 -0
  24. data/ext/readapt/monitor.h +0 -0
  25. data/ext/readapt/normalize.c +62 -62
  26. data/ext/readapt/normalize.h +7 -7
  27. data/ext/readapt/readapt.c +18 -18
  28. data/ext/readapt/stack.c +86 -86
  29. data/ext/readapt/stack.h +20 -20
  30. data/ext/readapt/threads.c +1 -1
  31. data/ext/readapt/threads.h +0 -0
  32. data/lib/readapt/adapter.rb +98 -98
  33. data/lib/readapt/breakpoint.rb +21 -21
  34. data/lib/readapt/data_reader.rb +62 -62
  35. data/lib/readapt/debugger.rb +227 -227
  36. data/lib/readapt/error.rb +63 -63
  37. data/lib/readapt/finder.rb +34 -34
  38. data/lib/readapt/frame.rb +40 -40
  39. data/lib/readapt/input.rb +7 -7
  40. data/lib/readapt/message/attach.rb +11 -11
  41. data/lib/readapt/message/base.rb +32 -32
  42. data/lib/readapt/message/configuration_done.rb +11 -11
  43. data/lib/readapt/message/continue.rb +15 -15
  44. data/lib/readapt/message/disconnect.rb +13 -13
  45. data/lib/readapt/message/evaluate.rb +19 -19
  46. data/lib/readapt/message/initialize.rb +21 -21
  47. data/lib/readapt/message/launch.rb +11 -11
  48. data/lib/readapt/message/next.rb +12 -12
  49. data/lib/readapt/message/pause.rb +11 -11
  50. data/lib/readapt/message/scopes.rb +26 -26
  51. data/lib/readapt/message/set_breakpoints.rb +25 -25
  52. data/lib/readapt/message/set_exception_breakpoints.rb +11 -11
  53. data/lib/readapt/message/stack_trace.rb +38 -38
  54. data/lib/readapt/message/step_in.rb +11 -11
  55. data/lib/readapt/message/step_out.rb +11 -11
  56. data/lib/readapt/message/threads.rb +18 -18
  57. data/lib/readapt/message/variables.rb +53 -53
  58. data/lib/readapt/message.rb +62 -62
  59. data/lib/readapt/monitor.rb +0 -0
  60. data/lib/readapt/output.rb +25 -25
  61. data/lib/readapt/references.rb +27 -27
  62. data/lib/readapt/server.rb +22 -22
  63. data/lib/readapt/shell.rb +104 -104
  64. data/lib/readapt/snapshot.rb +0 -0
  65. data/lib/readapt/thread.rb +20 -20
  66. data/lib/readapt/variable.rb +0 -0
  67. data/lib/readapt/version.rb +3 -3
  68. data/lib/readapt.rb +21 -21
  69. data/readapt.gemspec +39 -39
  70. metadata +8 -7
data/lib/readapt/frame.rb CHANGED
@@ -1,40 +1,40 @@
1
- # frozen_string_literal: true
2
-
3
- module Readapt
4
- # @!method file
5
- # @return [String]
6
- # @!method line
7
- # @return [Integer]
8
- # @!method binding_id
9
- # @return [Integer]
10
- # @!method initialize(file, line, binding_id)
11
- class Frame
12
- def evaluate code
13
- frame_binding.eval(code).inspect
14
- rescue StandardError => e
15
- "[#{e.class}] #{e.message}"
16
- end
17
-
18
- def local_id
19
- frame_binding.object_id
20
- end
21
-
22
- def locals
23
- return [] if frame_binding.nil?
24
- result = []
25
- frame_binding.local_variables.sort.each do |sym|
26
- var = frame_binding.local_variable_get(sym)
27
- result.push Variable.new(sym, var)
28
- end
29
- result.push Variable.new(:self, frame_binding.receiver)
30
- result
31
- end
32
-
33
- def local sym
34
- return frame_binding.receiver if sym == :self
35
- frame_binding.local_variable_get sym
36
- end
37
-
38
- NULL_FRAME = Frame.new("", 0, nil)
39
- end
40
- end
1
+ # frozen_string_literal: true
2
+
3
+ module Readapt
4
+ # @!method file
5
+ # @return [String]
6
+ # @!method line
7
+ # @return [Integer]
8
+ # @!method binding_id
9
+ # @return [Integer]
10
+ # @!method initialize(file, line, binding_id)
11
+ class Frame
12
+ def evaluate code
13
+ frame_binding.eval(code).inspect
14
+ rescue StandardError => e
15
+ "[#{e.class}] #{e.message}"
16
+ end
17
+
18
+ def local_id
19
+ frame_binding.object_id
20
+ end
21
+
22
+ def locals
23
+ return [] if frame_binding.nil?
24
+ result = []
25
+ frame_binding.local_variables.sort.each do |sym|
26
+ var = frame_binding.local_variable_get(sym)
27
+ result.push Variable.new(sym, var)
28
+ end
29
+ result.push Variable.new(:self, frame_binding.receiver)
30
+ result
31
+ end
32
+
33
+ def local sym
34
+ return frame_binding.receiver if sym == :self
35
+ frame_binding.local_variable_get sym
36
+ end
37
+
38
+ NULL_FRAME = Frame.new("", 0, nil)
39
+ end
40
+ end
data/lib/readapt/input.rb CHANGED
@@ -1,7 +1,7 @@
1
- module Readapt
2
- module Input
3
- def receiving data
4
- print data
5
- end
6
- end
7
- end
1
+ module Readapt
2
+ module Input
3
+ def receiving data
4
+ print data
5
+ end
6
+ end
7
+ end
@@ -1,11 +1,11 @@
1
- # frozen_string_literal: true
2
-
3
- module Readapt
4
- module Message
5
- class Attach < Base
6
- def run
7
- debugger.config arguments, :attach
8
- end
9
- end
10
- end
11
- end
1
+ # frozen_string_literal: true
2
+
3
+ module Readapt
4
+ module Message
5
+ class Attach < Base
6
+ def run
7
+ debugger.config arguments, :attach
8
+ end
9
+ end
10
+ end
11
+ end
@@ -1,32 +1,32 @@
1
- # frozen_string_literal: true
2
-
3
- module Readapt
4
- module Message
5
- class Base
6
- # @return [Hash]
7
- attr_reader :arguments
8
-
9
- # @return [Debugger]
10
- attr_reader :debugger
11
-
12
- def initialize arguments, debugger
13
- @arguments = arguments
14
- @debugger = debugger
15
- end
16
-
17
- def run; end
18
-
19
- def body
20
- @body ||= {}
21
- end
22
-
23
- def set_body hash
24
- @body = hash
25
- end
26
-
27
- def self.run arguments, debugger
28
- new(arguments, debugger).run
29
- end
30
- end
31
- end
32
- end
1
+ # frozen_string_literal: true
2
+
3
+ module Readapt
4
+ module Message
5
+ class Base
6
+ # @return [Hash]
7
+ attr_reader :arguments
8
+
9
+ # @return [Debugger]
10
+ attr_reader :debugger
11
+
12
+ def initialize arguments, debugger
13
+ @arguments = arguments
14
+ @debugger = debugger
15
+ end
16
+
17
+ def run; end
18
+
19
+ def body
20
+ @body ||= {}
21
+ end
22
+
23
+ def set_body hash
24
+ @body = hash
25
+ end
26
+
27
+ def self.run arguments, debugger
28
+ new(arguments, debugger).run
29
+ end
30
+ end
31
+ end
32
+ end
@@ -1,11 +1,11 @@
1
- # frozen_string_literal: true
2
-
3
- module Readapt
4
- module Message
5
- class ConfigurationDone < Base
6
- def run
7
- debugger.start
8
- end
9
- end
10
- end
11
- end
1
+ # frozen_string_literal: true
2
+
3
+ module Readapt
4
+ module Message
5
+ class ConfigurationDone < Base
6
+ def run
7
+ debugger.start
8
+ end
9
+ end
10
+ end
11
+ end
@@ -1,15 +1,15 @@
1
- # frozen_string_literal: true
2
-
3
- module Readapt
4
- module Message
5
- class Continue < Base
6
- def run
7
- thread = debugger.thread(arguments['threadId'])
8
- thread.control = :continue
9
- set_body({
10
- allThreadsContinued: false
11
- })
12
- end
13
- end
14
- end
15
- end
1
+ # frozen_string_literal: true
2
+
3
+ module Readapt
4
+ module Message
5
+ class Continue < Base
6
+ def run
7
+ thread = debugger.thread(arguments['threadId'])
8
+ thread.control = :continue
9
+ set_body({
10
+ allThreadsContinued: false
11
+ })
12
+ end
13
+ end
14
+ end
15
+ end
@@ -1,13 +1,13 @@
1
- # frozen_string_literal: true
2
-
3
- module Readapt
4
- module Message
5
- class Disconnect < Base
6
- def run
7
- # The message only sets an empty body to acknowledge that the request
8
- # was received. The adapter handles the actual disconnection process.
9
- set_body({})
10
- end
11
- end
12
- end
13
- end
1
+ # frozen_string_literal: true
2
+
3
+ module Readapt
4
+ module Message
5
+ class Disconnect < Base
6
+ def run
7
+ # The message only sets an empty body to acknowledge that the request
8
+ # was received. The adapter handles the actual disconnection process.
9
+ set_body({})
10
+ end
11
+ end
12
+ end
13
+ end
@@ -1,19 +1,19 @@
1
- # frozen_string_literal: true
2
-
3
- require 'json'
4
-
5
- module Readapt
6
- module Message
7
- class Evaluate < Base
8
- def run
9
- ref = arguments['frameId']
10
- frame = debugger.frame(ref)
11
- expression = arguments['expression']
12
- result = ref ? frame.evaluate(expression) : eval(expression)
13
- set_body(
14
- result: result
15
- )
16
- end
17
- end
18
- end
19
- end
1
+ # frozen_string_literal: true
2
+
3
+ require 'json'
4
+
5
+ module Readapt
6
+ module Message
7
+ class Evaluate < Base
8
+ def run
9
+ ref = arguments['frameId']
10
+ frame = debugger.frame(ref)
11
+ expression = arguments['expression']
12
+ result = ref ? frame.evaluate(expression) : eval(expression)
13
+ set_body(
14
+ result: result
15
+ )
16
+ end
17
+ end
18
+ end
19
+ end
@@ -1,21 +1,21 @@
1
- # frozen_string_literal: true
2
-
3
- module Readapt
4
- module Message
5
- class Initialize < Base
6
- def run
7
- set_body({
8
- supportsConfigurationDoneRequest: true,
9
- exceptionBreakpointFilters: [
10
- {
11
- filter: 'raise',
12
- label: 'Break on raised exceptions',
13
- description: 'The debugger will break when an exception is raised, regardless of whether it is subsequently rescued.',
14
- default: false
15
- }
16
- ]
17
- })
18
- end
19
- end
20
- end
21
- end
1
+ # frozen_string_literal: true
2
+
3
+ module Readapt
4
+ module Message
5
+ class Initialize < Base
6
+ def run
7
+ set_body({
8
+ supportsConfigurationDoneRequest: true,
9
+ exceptionBreakpointFilters: [
10
+ {
11
+ filter: 'raise',
12
+ label: 'Break on raised exceptions',
13
+ description: 'The debugger will break when an exception is raised, regardless of whether it is subsequently rescued.',
14
+ default: false
15
+ }
16
+ ]
17
+ })
18
+ end
19
+ end
20
+ end
21
+ end
@@ -1,11 +1,11 @@
1
- # frozen_string_literal: true
2
-
3
- module Readapt
4
- module Message
5
- class Launch < Base
6
- def run
7
- debugger.config arguments, :launch
8
- end
9
- end
10
- end
11
- end
1
+ # frozen_string_literal: true
2
+
3
+ module Readapt
4
+ module Message
5
+ class Launch < Base
6
+ def run
7
+ debugger.config arguments, :launch
8
+ end
9
+ end
10
+ end
11
+ end
@@ -1,12 +1,12 @@
1
- # frozen_string_literal: true
2
-
3
- module Readapt
4
- module Message
5
- class Next < Base
6
- def run
7
- thread = debugger.thread(arguments['threadId'])
8
- thread.control = :next
9
- end
10
- end
11
- end
12
- end
1
+ # frozen_string_literal: true
2
+
3
+ module Readapt
4
+ module Message
5
+ class Next < Base
6
+ def run
7
+ thread = debugger.thread(arguments['threadId'])
8
+ thread.control = :next
9
+ end
10
+ end
11
+ end
12
+ end
@@ -1,11 +1,11 @@
1
- # frozen_string_literal: true
2
-
3
- module Readapt
4
- module Message
5
- class Pause < Base
6
- def run
7
- Monitor.pause arguments['threadId']
8
- end
9
- end
10
- end
11
- end
1
+ # frozen_string_literal: true
2
+
3
+ module Readapt
4
+ module Message
5
+ class Pause < Base
6
+ def run
7
+ Monitor.pause arguments['threadId']
8
+ end
9
+ end
10
+ end
11
+ end
@@ -1,26 +1,26 @@
1
- # frozen_string_literal: true
2
-
3
- module Readapt
4
- module Message
5
- class Scopes < Base
6
- def run
7
- frame = debugger.frame(arguments['frameId'])
8
- set_body({
9
- scopes: [
10
- {
11
- name: 'Local',
12
- variablesReference: frame.local_id,
13
- expensive: false
14
- },
15
- {
16
- name: 'Global',
17
- # @todo 1 is a magic number representing the toplevel binding
18
- variablesReference: 1,
19
- expensive: true
20
- }
21
- ]
22
- })
23
- end
24
- end
25
- end
26
- end
1
+ # frozen_string_literal: true
2
+
3
+ module Readapt
4
+ module Message
5
+ class Scopes < Base
6
+ def run
7
+ frame = debugger.frame(arguments['frameId'])
8
+ set_body({
9
+ scopes: [
10
+ {
11
+ name: 'Local',
12
+ variablesReference: frame.local_id,
13
+ expensive: false
14
+ },
15
+ {
16
+ name: 'Global',
17
+ # @todo 1 is a magic number representing the toplevel binding
18
+ variablesReference: 1,
19
+ expensive: true
20
+ }
21
+ ]
22
+ })
23
+ end
24
+ end
25
+ end
26
+ end
@@ -1,25 +1,25 @@
1
- # frozen_string_literal: true
2
-
3
- module Readapt
4
- module Message
5
- class SetBreakpoints < Base
6
- def run
7
- path = Readapt.normalize_path(arguments['source']['path'])
8
- debugger.clear_breakpoints path
9
- lines = []
10
- set_body(
11
- breakpoints: arguments['breakpoints'].map do |val|
12
- debugger.set_breakpoint path, val['line'], val['condition'], val['hitCondition']
13
- lines.push val['line']
14
- {
15
- verified: true, # @todo Verify
16
- source: arguments['source'],
17
- line: val['line']
18
- }
19
- end
20
- )
21
- Breakpoints.set(path, lines)
22
- end
23
- end
24
- end
25
- end
1
+ # frozen_string_literal: true
2
+
3
+ module Readapt
4
+ module Message
5
+ class SetBreakpoints < Base
6
+ def run
7
+ path = Readapt.normalize_path(arguments['source']['path'])
8
+ debugger.clear_breakpoints path
9
+ lines = []
10
+ set_body(
11
+ breakpoints: arguments['breakpoints'].map do |val|
12
+ debugger.set_breakpoint path, val['line'], val['condition'], val['hitCondition']
13
+ lines.push val['line']
14
+ {
15
+ verified: true, # @todo Verify
16
+ source: arguments['source'],
17
+ line: val['line']
18
+ }
19
+ end
20
+ )
21
+ Breakpoints.set(path, lines)
22
+ end
23
+ end
24
+ end
25
+ end
@@ -1,11 +1,11 @@
1
- # frozen_string_literal: true
2
-
3
- module Readapt
4
- module Message
5
- class SetExceptionBreakpoints < Base
6
- def run
7
- debugger.pause_on_raise = arguments['filters'] && arguments['filters'].include?('raise')
8
- end
9
- end
10
- end
11
- end
1
+ # frozen_string_literal: true
2
+
3
+ module Readapt
4
+ module Message
5
+ class SetExceptionBreakpoints < Base
6
+ def run
7
+ debugger.pause_on_raise = arguments['filters'] && arguments['filters'].include?('raise')
8
+ end
9
+ end
10
+ end
11
+ end
@@ -1,38 +1,38 @@
1
- # frozen_string_literal: true
2
-
3
- module Readapt
4
- module Message
5
- class StackTrace < Base
6
- @@file_hash = {}
7
-
8
- def run
9
- frames = debugger.thread(arguments['threadId']).frames
10
- set_body({
11
- stackFrames: frames.map do |frm|
12
- {
13
- name: frame_code(frm.file, frm.line),
14
- source: {
15
- name: frm.file ? File.basename(frm.file) : nil,
16
- path: frm.file
17
- },
18
- id: frm.local_id,
19
- line: frm.line,
20
- column: 0
21
- }
22
- end,
23
- totalFrames: frames.length
24
- })
25
- end
26
-
27
- private
28
-
29
- def read_file file
30
- @@file_hash[file] ||= File.read(file)
31
- end
32
-
33
- def frame_code file, line
34
- read_file(file).lines[line - 1].strip
35
- end
36
- end
37
- end
38
- end
1
+ # frozen_string_literal: true
2
+
3
+ module Readapt
4
+ module Message
5
+ class StackTrace < Base
6
+ @@file_hash = {}
7
+
8
+ def run
9
+ frames = debugger.thread(arguments['threadId']).frames
10
+ set_body({
11
+ stackFrames: frames.map do |frm|
12
+ {
13
+ name: frame_code(frm.file, frm.line),
14
+ source: {
15
+ name: frm.file ? File.basename(frm.file) : nil,
16
+ path: frm.file
17
+ },
18
+ id: frm.local_id,
19
+ line: frm.line,
20
+ column: 0
21
+ }
22
+ end,
23
+ totalFrames: frames.length
24
+ })
25
+ end
26
+
27
+ private
28
+
29
+ def read_file file
30
+ @@file_hash[file] ||= File.read(file)
31
+ end
32
+
33
+ def frame_code file, line
34
+ read_file(file).lines[line - 1].strip
35
+ end
36
+ end
37
+ end
38
+ end
@@ -1,11 +1,11 @@
1
- # frozen_string_literal: true
2
-
3
- module Readapt
4
- module Message
5
- class StepIn < Base
6
- def run
7
- debugger.thread(arguments['threadId']).control = :step_in
8
- end
9
- end
10
- end
11
- end
1
+ # frozen_string_literal: true
2
+
3
+ module Readapt
4
+ module Message
5
+ class StepIn < Base
6
+ def run
7
+ debugger.thread(arguments['threadId']).control = :step_in
8
+ end
9
+ end
10
+ end
11
+ end
@@ -1,11 +1,11 @@
1
- # frozen_string_literal: true
2
-
3
- module Readapt
4
- module Message
5
- class StepOut < Base
6
- def run
7
- debugger.thread(arguments['threadId']).control = :step_out
8
- end
9
- end
10
- end
11
- end
1
+ # frozen_string_literal: true
2
+
3
+ module Readapt
4
+ module Message
5
+ class StepOut < Base
6
+ def run
7
+ debugger.thread(arguments['threadId']).control = :step_out
8
+ end
9
+ end
10
+ end
11
+ end