debugger-xml 0.3.3 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (74) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +1 -1
  3. data/bin/rdebug-ide +12 -9
  4. data/bin/rdebug-vim +30 -13
  5. data/debugger-xml.gemspec +7 -3
  6. data/lib/byebug/commands/frame.rb +16 -0
  7. data/lib/byebug/commands/help.rb +13 -0
  8. data/lib/byebug/commands/info.rb +13 -0
  9. data/lib/byebug/commands/inspect.rb +30 -0
  10. data/lib/byebug/commands/kill.rb +13 -0
  11. data/lib/byebug/commands/start.rb +25 -0
  12. data/lib/byebug/commands/threads.rb +10 -0
  13. data/lib/byebug/commands/trace.rb +13 -0
  14. data/lib/byebug/commands/variables.rb +54 -0
  15. data/lib/byebug/context_xml.rb +29 -0
  16. data/lib/byebug/printers/texts/xml.yml +122 -0
  17. data/lib/byebug/printers/xml.rb +197 -0
  18. data/lib/debugger/{xml/extensions/processor.rb → command_processor.rb} +0 -0
  19. data/lib/debugger/{xml/extensions/commands → commands}/edit.rb +0 -0
  20. data/lib/debugger/{xml/extensions/commands → commands}/frame.rb +0 -1
  21. data/lib/debugger/{xml/extensions/commands → commands}/help.rb +0 -0
  22. data/lib/debugger/{xml/extensions/commands → commands}/info.rb +0 -0
  23. data/lib/debugger/{xml/extensions/commands → commands}/inspect.rb +0 -0
  24. data/lib/debugger/{xml/extensions/commands → commands}/irb.rb +0 -0
  25. data/lib/debugger/{xml/extensions/commands → commands}/kill.rb +0 -0
  26. data/lib/debugger/commands/start.rb +25 -0
  27. data/lib/debugger/{xml/extensions/commands → commands}/threads.rb +0 -0
  28. data/lib/debugger/{xml/extensions/commands → commands}/tmate.rb +0 -0
  29. data/lib/debugger/{xml/extensions/commands → commands}/trace.rb +0 -0
  30. data/lib/debugger/{xml/extensions/commands → commands}/variables.rb +14 -0
  31. data/lib/debugger_xml.rb +91 -0
  32. data/lib/debugger_xml/byebug_proxy.rb +108 -0
  33. data/lib/debugger_xml/debugger_proxy.rb +115 -0
  34. data/lib/debugger_xml/fake_logger.rb +9 -0
  35. data/lib/debugger_xml/ide/control_command_processor.rb +69 -0
  36. data/lib/debugger_xml/ide/interface.rb +74 -0
  37. data/lib/debugger_xml/ide/logger.rb +9 -0
  38. data/lib/debugger_xml/ide/processor.rb +118 -0
  39. data/lib/debugger_xml/multiprocess/monkey.rb +47 -0
  40. data/lib/debugger_xml/multiprocess/pre_child.rb +79 -0
  41. data/lib/{debugger/xml → debugger_xml}/multiprocess/starter.rb +2 -2
  42. data/lib/debugger_xml/version.rb +3 -0
  43. data/lib/debugger_xml/vim/control_command_processor.rb +23 -0
  44. data/lib/debugger_xml/vim/interface.rb +46 -0
  45. data/lib/debugger_xml/vim/logger.rb +16 -0
  46. data/lib/debugger_xml/vim/notification.rb +35 -0
  47. data/lib/debugger_xml/vim/processor.rb +20 -0
  48. data/test/breakpoints_test.rb +0 -1
  49. data/test/ide/control_command_processor_test.rb +18 -13
  50. data/test/ide/processor_test.rb +11 -25
  51. data/test/printers/xml_test.rb +1 -0
  52. data/test/test_helper.rb +12 -3
  53. data/test/variables_test.rb +0 -1
  54. data/test/vim/control_command_processor_test.rb +4 -5
  55. data/test/vim/interface_test.rb +6 -6
  56. data/test/vim/notification_test.rb +3 -3
  57. data/test/vim/processor_test.rb +8 -8
  58. metadata +61 -48
  59. data/lib/debugger/xml.rb +0 -11
  60. data/lib/debugger/xml/extensions/ide_server.rb +0 -33
  61. data/lib/debugger/xml/extensions/vim_server.rb +0 -56
  62. data/lib/debugger/xml/fake_logger.rb +0 -11
  63. data/lib/debugger/xml/ide/control_command_processor.rb +0 -81
  64. data/lib/debugger/xml/ide/interface.rb +0 -72
  65. data/lib/debugger/xml/ide/logger.rb +0 -11
  66. data/lib/debugger/xml/ide/processor.rb +0 -94
  67. data/lib/debugger/xml/multiprocess/monkey.rb +0 -49
  68. data/lib/debugger/xml/multiprocess/pre_child.rb +0 -81
  69. data/lib/debugger/xml/version.rb +0 -5
  70. data/lib/debugger/xml/vim/control_command_processor.rb +0 -19
  71. data/lib/debugger/xml/vim/interface.rb +0 -42
  72. data/lib/debugger/xml/vim/logger.rb +0 -18
  73. data/lib/debugger/xml/vim/notification.rb +0 -37
  74. data/lib/debugger/xml/vim/processor.rb +0 -22
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5fe797dc2d6d07beba865c6d7dfe1a2cd71e6927
4
- data.tar.gz: 5cee2ad6bca4e73ba710bca6e8667f05f49e806a
3
+ metadata.gz: 19c5d53c2123f938edfb1309c441c1f9c936531d
4
+ data.tar.gz: 6b287e9a8e24e25bae59e50c451d60fee31796cd
5
5
  SHA512:
6
- metadata.gz: 79b07ae2c79d223ff04ffbe0368677470ba35ac482cb660726ee669abe36422e9b7e50316363c56970031592be256b4632df14e57c07385cd92be0f23d0c3323
7
- data.tar.gz: 0a187a786b414758660275a9916a63d2c21ee57c597b002f2dfcab41674d96d73c772094d726f2462f299af4c91a90106e6b9a5b42382b2feffbd71ec08b019b
6
+ metadata.gz: 1df8f6145823191d66d20a0526c4ba9c8bade1f74b2dbb28ea5ccf76c4e1772449b88cfde48b1e089db253b177e50f111e4f03b2ba973b57335f2c5c401ea1bf
7
+ data.tar.gz: e57ff1a5591d10e6e18ea2732fbc6c85b896df40f2fff73094c094fac8a145b5abbc39a736e0d6dc5276f1c9faee20c39e4eab39b6095fd682687b9b9146294b
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  ## Description
2
2
 
3
- This is a gem, which adds the XML printer to the 'debugger' gem, using the same API as
3
+ This is a gem, which adds the XML printer to the 'debugger' or 'byebug' gems, using the same API as
4
4
  the ruby-debug-ide gem, which allows it to be used with Ruby IDEs (for example, in my
5
5
  vim-ruby-debugger :))
6
6
 
@@ -12,14 +12,17 @@ class RdebugIde
12
12
 
13
13
  def initialize
14
14
  check_argv!
15
- Debugger.const_set("ARGV", ARGV.clone)
16
- Debugger.const_set("RDEBUG_SCRIPT", rdebug_path)
17
- install_interruption_handler if options.int_handler
18
- Debugger.tracing = options.tracing
19
- Debugger.wait_for_start = options.wait_for_start
20
- Debugger.wait_connection = true
21
- Debugger.printer = Printers::Xml.new
22
- Debugger.const_set("PROG_SCRIPT", ARGV.shift)
15
+ @proxy = DebuggerXml::DebuggerProxy.new
16
+ @proxy.set_argv(ARGV.clone)
17
+ @proxy.set_rdebug_script(rdebug_path)
18
+ @proxy.set_prog_script(ARGV.shift)
19
+ if options.int_handler
20
+ install_interruption_handler
21
+ end
22
+ @proxy.tracing = options.tracing
23
+ @proxy.printer = Printers::Xml.new
24
+ @proxy.wait_connection = true
25
+ DebuggerXml.wait_for_start = options.wait_for_start
23
26
  Debugger::Xml.logger = if options.debug_mode
24
27
  Debugger::Xml::Ide::Logger.new
25
28
  else
@@ -59,7 +62,7 @@ class RdebugIde
59
62
  end
60
63
 
61
64
  def install_interruption_handler
62
- trap('INT') { Debugger.interrupt_last }
65
+ trap('INT') { @proxy.interrupt_last }
63
66
  end
64
67
 
65
68
  def rdebug_path
@@ -3,29 +3,46 @@
3
3
  $LOAD_PATH.unshift(File.expand_path('../../lib', __FILE__))
4
4
  require 'optparse'
5
5
  require 'ostruct'
6
- require 'debugger'
7
- require 'debugger/xml'
6
+
7
+ DEBUGGER_TYPE = if RUBY_VERSION < "2.0"
8
+ require 'debugger'
9
+ :debugger
10
+ else
11
+ require 'byebug'
12
+ :byebug
13
+ end
14
+
15
+ require 'debugger_xml'
16
+
17
+ if DEBUGGER_TYPE == :debugger
18
+ PROXY_CLASS = DebuggerXml::DebuggerProxy
19
+ PRINTER_CLASS = Printers::Xml
20
+ else
21
+ PROXY_CLASS = DebuggerXml::ByebugProxy
22
+ PRINTER_CLASS = Byebug::Printers::Xml
23
+ end
8
24
 
9
25
  class RdebugVim
10
26
 
11
27
  def initialize
12
28
  check_argv!
13
- Debugger.const_set("RDEBUG_SCRIPT", File.expand_path($0))
29
+ DebuggerXml.wait_for_start = true
30
+ @proxy = PROXY_CLASS.new
31
+ @proxy.tracing = false
32
+ @proxy.printer = PRINTER_CLASS.new
33
+ @proxy.set_rdebug_script(File.expand_path($0))
34
+ @proxy.set_prog_script(options.script)
14
35
  install_interruption_hander
15
- Debugger.tracing = false
16
- Debugger.wait_for_start = true
17
- Debugger.printer = Printers::Xml.new
18
- Debugger.const_set("PROG_SCRIPT", options.script)
19
- Debugger::Xml.logger = if options.debug_mode
20
- Debugger::Xml::Vim::Logger.new(options.logger_file)
36
+ DebuggerXml.logger = if options.debug_mode
37
+ DebuggerXml::Vim::Logger.new(options.logger_file)
21
38
  else
22
- Debugger::Xml::FakeLogger.new
39
+ DebuggerXml::FakeLogger.new
23
40
  end
24
41
  end
25
42
 
26
43
  def run
27
- Debugger.start_for_vim(options)
28
- bt = Debugger.debug_load(Debugger::PROG_SCRIPT, false, false)
44
+ DebuggerXml.start_for_vim(@proxy, options)
45
+ bt = @proxy.debug_load
29
46
  if bt
30
47
  print bt.backtrace.map{|l| "\t#{l}"}.join("\n"), "\n"
31
48
  print "Uncaught exception: #{bt}\n"
@@ -44,7 +61,7 @@ class RdebugVim
44
61
  end
45
62
 
46
63
  def install_interruption_hander
47
- trap('INT') { Debugger.interrupt_last }
64
+ trap('INT') { @proxy.interrupt_last }
48
65
  end
49
66
 
50
67
  def options
@@ -1,11 +1,11 @@
1
1
  # -*- encoding: utf-8 -*-
2
2
  lib = File.expand_path('../lib', __FILE__)
3
3
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require 'debugger/xml/version'
4
+ require 'debugger_xml/version'
5
5
 
6
6
  Gem::Specification.new do |gem|
7
7
  gem.name = "debugger-xml"
8
- gem.version = Debugger::Xml::VERSION
8
+ gem.version = DebuggerXml::VERSION
9
9
  gem.authors = ["Anton Astashov"]
10
10
  gem.email = ["anton.astashov@gmail.com"]
11
11
  gem.description = %q{XML interface for debugger}
@@ -18,7 +18,11 @@ Gem::Specification.new do |gem|
18
18
  gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
19
19
  gem.require_paths = ["lib"]
20
20
 
21
- gem.add_dependency "debugger", '>= 1.6.2'
21
+ if RUBY_VERSION < "2.0"
22
+ gem.add_dependency 'debugger'
23
+ else
24
+ gem.add_dependency 'byebug'
25
+ end
22
26
  gem.add_dependency 'builder', '>= 2.0.0'
23
27
  gem.add_development_dependency 'rake', '~> 0.9.2.2'
24
28
  gem.add_development_dependency 'minitest', '~> 2.12.1'
@@ -0,0 +1,16 @@
1
+ module Byebug
2
+ module FrameFunctions
3
+
4
+ # Mark should be 'true' or 'false', as a String
5
+ def get_pr_arguments_with_xml(pos, mark = nil)
6
+ mark = (pos == @state.frame_pos).to_s
7
+ res = get_pr_arguments_without_xml(pos, mark)
8
+ res[:file] = File.expand_path(res[:file])
9
+ res
10
+ end
11
+
12
+ alias_method :get_pr_arguments_without_xml, :get_pr_arguments
13
+ alias_method :get_pr_arguments, :get_pr_arguments_with_xml
14
+
15
+ end
16
+ end
@@ -0,0 +1,13 @@
1
+ module Byebug
2
+ class HelpCommand < Command
3
+
4
+ def execute_with_xml(*args)
5
+ errmsg(pr("general.errors.unsupported", cmd: 'help')) && return if Byebug.printer.type == "xml"
6
+ execute_without_xml(*args)
7
+ end
8
+
9
+ alias_method :execute_without_xml, :execute
10
+ alias_method :execute, :execute_with_xml
11
+
12
+ end
13
+ end
@@ -0,0 +1,13 @@
1
+ module Byebug
2
+ class InfoCommand < Command
3
+
4
+ def execute_with_xml(*args)
5
+ errmsg(pr("general.errors.unsupported", cmd: 'info')) && return if Byebug.printer.type == "xml"
6
+ execute_without_xml(*args)
7
+ end
8
+
9
+ alias_method :execute_without_xml, :execute
10
+ alias_method :execute, :execute_with_xml
11
+
12
+ end
13
+ end
@@ -0,0 +1,30 @@
1
+ module Byebug
2
+ class InspectCommand < Command
3
+ # reference inspection results in order to save them from the GC
4
+ @@references = []
5
+ def self.reference_result(result)
6
+ @@references << result
7
+ end
8
+ def self.clear_references
9
+ @@references = []
10
+ end
11
+
12
+ def regexp
13
+ /^\s*v(?:ar)?\s+inspect\s+/
14
+ end
15
+
16
+ def execute
17
+ run_with_binding do |binding|
18
+ obj = debug_eval(@match.post_match, binding)
19
+ InspectCommand.reference_result(obj)
20
+ print prv({eval_result: obj}, "local")
21
+ end
22
+ end
23
+
24
+ def help
25
+ %{
26
+ v[ar] instpect <object>\tinpect a given object (supposed to be used only from ide)
27
+ }
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,13 @@
1
+ module Byebug
2
+ class KillCommand < Command
3
+
4
+ def execute_with_xml(*args)
5
+ errmsg(pr("general.errors.unsupported", cmd: 'kill')) && return if Byebug.printer.type == "xml"
6
+ execute_without_xml(*args)
7
+ end
8
+
9
+ alias_method :execute_without_xml, :execute
10
+ alias_method :execute, :execute_with_xml
11
+
12
+ end
13
+ end
@@ -0,0 +1,25 @@
1
+ module Byebug
2
+ class StartCommand < Command # :nodoc:
3
+ self.allow_in_control = true
4
+
5
+ def regexp
6
+ /^\s*(start)\s*$/ix
7
+ end
8
+
9
+ def execute
10
+ DebuggerXml.proceed
11
+ end
12
+
13
+ class << self
14
+ def help_command
15
+ 'start'
16
+ end
17
+
18
+ def help(cmd)
19
+ %{
20
+ run prog script
21
+ }
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,10 @@
1
+ module Byebug
2
+ module ThreadFunctions # :nodoc:
3
+ def thread_arguments_with_pid(context, should_show_top_frame = true)
4
+ thread_arguments_without_pid(context, should_show_top_frame).merge(pid: Process.pid)
5
+ end
6
+
7
+ alias_method :thread_arguments_without_pid, :thread_arguments
8
+ alias_method :thread_arguments, :thread_arguments_with_pid
9
+ end
10
+ end
@@ -0,0 +1,13 @@
1
+ module Byebug
2
+ class TracevarCommand < Command
3
+
4
+ def execute_with_xml(*args)
5
+ errmsg(pr("general.errors.unsupported", cmd: 'trace')) && return if Byebug.printer.type == "xml"
6
+ execute_without_xml(*args)
7
+ end
8
+
9
+ alias_method :execute_without_xml, :execute
10
+ alias_method :execute, :execute_with_xml
11
+
12
+ end
13
+ end
@@ -0,0 +1,54 @@
1
+ module Byebug
2
+ module VarFunctions # :nodoc:
3
+
4
+ def var_global
5
+ var_list(global_variables.reject { |v| [:$=, :$KCODE, :$-K, :$FILENAME].include?(v) })
6
+ end
7
+
8
+ end
9
+ class VarInstanceCommand < Command
10
+
11
+ def execute_with_xml(*args)
12
+ if Byebug.printer.type == "xml"
13
+ DebuggerXml.logger.puts("match: #{@match}")
14
+ DebuggerXml.logger.puts("THE OBJ: #{get_obj(@match).inspect}")
15
+ print Byebug.printer.print_instance_variables(get_obj(@match))
16
+ else
17
+ execute_without_xml(*args)
18
+ end
19
+ end
20
+
21
+ alias_method :execute_without_xml, :execute
22
+ alias_method :execute, :execute_with_xml
23
+
24
+ private
25
+
26
+ def get_obj(match)
27
+ if match[1]
28
+ begin
29
+ DebuggerXml.logger.puts("Getting object space")
30
+ ObjectSpace._id2ref(match[1].hex)
31
+ rescue RangeError
32
+ errmsg "Unknown object id : %s" % match[1]
33
+ nil
34
+ end
35
+ else
36
+ bb_warning_eval(match.post_match.empty? ? 'self' : match.post_match)
37
+ end
38
+ end
39
+ end
40
+
41
+ class VarIdeCommand < Command
42
+ def regexp
43
+ /^\s*v(?:ar)?\s+ide\s*$/
44
+ end
45
+
46
+ def execute
47
+ locals = []
48
+ _self = @state.context.frame_self(@state.frame_pos)
49
+ locals << ['self', _self] unless _self.to_s == "main"
50
+ locals += @state.context.frame_locals(@state.frame_pos).sort.map { |key, value| [key, value] }
51
+ print prv(locals, 'instance')
52
+ end
53
+ end
54
+ end
@@ -0,0 +1,29 @@
1
+ module Byebug
2
+ class Context
3
+ class << self
4
+ IGNORED_XML_FILES = Dir.glob(File.expand_path('../../../**/*', __FILE__))
5
+
6
+ def stack_size(byebug_frames = false)
7
+ backtrace = Thread.current.backtrace_locations(0)
8
+ return 0 unless backtrace
9
+
10
+ unless byebug_frames
11
+ backtrace = backtrace.select { |l| !ignored(l.path) }
12
+ end
13
+ backtrace.size
14
+ end
15
+
16
+ def ignored_with_xml(path)
17
+ result = ignored_without_xml(path) ||
18
+ IGNORED_XML_FILES.include?(path) ||
19
+ !!path.match(/^\(eval\)/) ||
20
+ !!path.match(/rdebug-vim$/) ||
21
+ !!path.match(/rdebug-ide$/)
22
+ result
23
+ end
24
+
25
+ alias_method :ignored_without_xml, :ignored
26
+ alias_method :ignored, :ignored_with_xml
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,122 @@
1
+ general:
2
+ errors:
3
+ unsupported: "Unsupported command '{cmd}'"
4
+
5
+ breakpoints:
6
+ set_breakpoint_to_line:
7
+ tag: breakpointAdded
8
+ attributes:
9
+ "no": "{id}"
10
+ location: "{file}:{line}"
11
+ set_breakpoint_to_method:
12
+ tag: breakpointAdded
13
+ attributes:
14
+ "no": "{id}"
15
+ method: "{class}::{method}"
16
+ stop_at_breakpoint:
17
+ tag: breakpoint
18
+ attributes:
19
+ file: "{file}"
20
+ line: "{line}"
21
+ threadId: "{thread_id}"
22
+ delete:
23
+ tag: breakpointDeleted
24
+ attributes:
25
+ "no": "{id}"
26
+
27
+ conditions:
28
+ set_condition:
29
+ tag: conditionSet
30
+ attributes:
31
+ bp_id: "{id}"
32
+ unset_condition:
33
+ tag: conditionSet # Would ideally be conditionUnset, but we keep compatibility with old ruby-debug-ide
34
+ attributes:
35
+ bp_id: "{id}"
36
+
37
+ display:
38
+ result:
39
+ tag: display
40
+ attributes:
41
+ key: "{exp}"
42
+ value: "{result}"
43
+
44
+ eval:
45
+ exception:
46
+ tag: processingException
47
+ attributes:
48
+ type: "{class}"
49
+ message: "{value}"
50
+ result:
51
+ tag: eval
52
+ attributes:
53
+ expression: "{expr}"
54
+ value: "{result}"
55
+
56
+ frame:
57
+ line:
58
+ tag: frame
59
+ attributes:
60
+ "no": "{pos}"
61
+ file: "{file}"
62
+ line: "{line}"
63
+ current: "{mark}"
64
+
65
+ method:
66
+ methods:
67
+ tag: method
68
+ attributes:
69
+ name: "{name}"
70
+
71
+ stop:
72
+ suspend:
73
+ tag: suspended
74
+ attributes:
75
+ file: "{file}"
76
+ line: "{line_number}"
77
+ threadId: "{thnum}"
78
+ frames: "{frames}"
79
+
80
+ toggle:
81
+ breakpoint_enabled:
82
+ tag: breakpointEnabled
83
+ attributes:
84
+ bp_id: "{id}"
85
+ breakpoint_disabled:
86
+ tag: breakpointDisabled
87
+ attributes:
88
+ bp_id: "{id}"
89
+
90
+ restart:
91
+ success:
92
+ tag: restart
93
+ attributes:
94
+ command: "{cmd}"
95
+
96
+ set:
97
+ errors:
98
+ no_subcommand: "'set' must be followed by the name of a subcommand"
99
+
100
+ show:
101
+ errors:
102
+ no_subcommand: "'show' must be followed by the name of a subcommand"
103
+
104
+ thread:
105
+ context:
106
+ tag: thread
107
+ attributes:
108
+ id: "{id}"
109
+ status: "{status}"
110
+ current: "{current}"
111
+ pid: "{pid}"
112
+
113
+ variable:
114
+ variable:
115
+ tag: variable
116
+ attributes:
117
+ name: "{name}"
118
+ kind: "{kind}"
119
+ value: "{value}"
120
+ type: "{type}"
121
+ hasChildren: "{has_children}"
122
+ objectId: "{id}"