debugger 1.0.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (83) hide show
  1. data/CHANGELOG.md +3 -0
  2. data/README.md +2 -1
  3. data/Rakefile +4 -5
  4. data/bin/rdebug +29 -30
  5. data/lib/debugger.rb +0 -2
  6. data/lib/debugger/version.rb +1 -1
  7. data/lib/ruby-debug-base.rb +26 -27
  8. data/{cli → lib}/ruby-debug.rb +0 -0
  9. data/{cli → lib}/ruby-debug/command.rb +19 -20
  10. data/{cli → lib}/ruby-debug/commands/breakpoints.rb +0 -0
  11. data/{cli → lib}/ruby-debug/commands/catchpoint.rb +0 -0
  12. data/{cli → lib}/ruby-debug/commands/condition.rb +0 -0
  13. data/{cli → lib}/ruby-debug/commands/continue.rb +0 -0
  14. data/{cli → lib}/ruby-debug/commands/control.rb +0 -0
  15. data/{cli → lib}/ruby-debug/commands/display.rb +0 -0
  16. data/{cli → lib}/ruby-debug/commands/edit.rb +0 -0
  17. data/{cli → lib}/ruby-debug/commands/enable.rb +0 -0
  18. data/{cli → lib}/ruby-debug/commands/eval.rb +0 -0
  19. data/{cli → lib}/ruby-debug/commands/finish.rb +0 -0
  20. data/{cli → lib}/ruby-debug/commands/frame.rb +0 -0
  21. data/{cli → lib}/ruby-debug/commands/help.rb +0 -0
  22. data/{cli → lib}/ruby-debug/commands/info.rb +0 -0
  23. data/{cli → lib}/ruby-debug/commands/irb.rb +0 -0
  24. data/{cli → lib}/ruby-debug/commands/jump.rb +0 -0
  25. data/{cli → lib}/ruby-debug/commands/kill.rb +0 -0
  26. data/{cli → lib}/ruby-debug/commands/list.rb +0 -0
  27. data/{cli → lib}/ruby-debug/commands/method.rb +0 -0
  28. data/{cli → lib}/ruby-debug/commands/quit.rb +0 -0
  29. data/{cli → lib}/ruby-debug/commands/reload.rb +0 -0
  30. data/{cli → lib}/ruby-debug/commands/save.rb +0 -0
  31. data/{cli → lib}/ruby-debug/commands/set.rb +0 -0
  32. data/{cli → lib}/ruby-debug/commands/show.rb +0 -0
  33. data/{cli → lib}/ruby-debug/commands/skip.rb +0 -0
  34. data/{cli → lib}/ruby-debug/commands/source.rb +0 -0
  35. data/{cli → lib}/ruby-debug/commands/stepping.rb +0 -0
  36. data/{cli → lib}/ruby-debug/commands/threads.rb +0 -0
  37. data/{cli → lib}/ruby-debug/commands/tmate.rb +0 -0
  38. data/{cli → lib}/ruby-debug/commands/trace.rb +0 -0
  39. data/{cli → lib}/ruby-debug/commands/variables.rb +0 -0
  40. data/{cli → lib}/ruby-debug/debugger.rb +0 -0
  41. data/{cli → lib}/ruby-debug/helper.rb +0 -0
  42. data/{cli → lib}/ruby-debug/interface.rb +0 -0
  43. data/{cli → lib}/ruby-debug/processor.rb +0 -0
  44. data/test/helper.rb +14 -16
  45. data/test/{cli → lib}/commands/catchpoint_test.rb +4 -12
  46. data/test/{cli → lib}/commands/unit/regexp.rb +3 -7
  47. data/test/tdebug.rb +17 -18
  48. data/test/test-annotate.rb +2 -3
  49. data/test/test-break-bad.rb +4 -5
  50. data/test/test-breakpoints.rb +2 -3
  51. data/test/test-catch.rb +1 -2
  52. data/test/test-catch2.rb +1 -2
  53. data/test/test-catch3.rb +1 -2
  54. data/test/test-condition.rb +2 -3
  55. data/test/test-ctrl.rb +1 -2
  56. data/test/test-display.rb +3 -4
  57. data/test/test-dollar-0.rb +7 -8
  58. data/test/test-edit.rb +2 -3
  59. data/test/test-emacs-basic.rb +4 -5
  60. data/test/test-enable.rb +2 -3
  61. data/test/test-finish.rb +3 -4
  62. data/test/test-frame.rb +2 -3
  63. data/test/test-help.rb +6 -7
  64. data/test/test-hist.rb +4 -7
  65. data/test/test-info-thread.rb +2 -3
  66. data/test/test-info-var.rb +3 -4
  67. data/test/test-info.rb +2 -3
  68. data/test/test-init.rb +1 -2
  69. data/test/test-jump.rb +4 -5
  70. data/test/test-list.rb +3 -4
  71. data/test/test-method.rb +4 -5
  72. data/test/test-next.rb +2 -3
  73. data/test/test-output.rb +2 -3
  74. data/test/test-quit.rb +2 -3
  75. data/test/test-raise.rb +1 -2
  76. data/test/test-save.rb +2 -3
  77. data/test/test-scope-var.rb +2 -3
  78. data/test/test-setshow.rb +2 -3
  79. data/test/test-source.rb +2 -3
  80. data/test/test-stepping.rb +2 -3
  81. data/test/test-trace.rb +4 -5
  82. data/test/thread1.rb +1 -2
  83. metadata +76 -51
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
data/test/helper.rb CHANGED
@@ -5,7 +5,6 @@ require 'yaml'
5
5
  # require 'diff/lcs'
6
6
  # require 'diff/lcs/hunk'
7
7
 
8
- # begin require 'rubygems' rescue LoadError end
9
8
  # require 'ruby-debug'; Debugger.start
10
9
 
11
10
  module TestHelper
@@ -14,13 +13,13 @@ module TestHelper
14
13
  def run_debugger(testname, args='', outfile=nil, filter=nil, old_code=false,
15
14
  debug_pgm='tdebug.rb')
16
15
  rightfile = File.join('data', "#{testname}.right")
17
-
16
+
18
17
  outfile = "#{testname}.out" unless outfile
19
18
 
20
19
  if File.exists?(outfile)
21
20
  FileUtils.rm(outfile)
22
21
  end
23
-
22
+
24
23
  ENV['RDEBUG'] = debug_pgm
25
24
 
26
25
  if old_code
@@ -30,7 +29,7 @@ module TestHelper
30
29
  end
31
30
  puts "'#{cmd}'" if $DEBUG
32
31
  output = `#{cmd}`
33
-
32
+
34
33
  curr_path = Dir.pwd
35
34
  got_lines = File.read(outfile).split(/\n/).map{|s| s.sub(curr_path, '.') }
36
35
  correct_lines = File.read(rightfile).split(/\n/)
@@ -58,14 +57,14 @@ module TestHelper
58
57
  end
59
58
  end
60
59
  if correct_lines.size != got_lines.size
61
- puts("difference in number of lines: " +
60
+ puts("difference in number of lines: " +
62
61
  "#{correct_lines.size} vs. #{got_lines.size}")
63
62
  return false
64
63
  end
65
64
  return true
66
65
  end
67
66
 
68
- # FIXME: using this causes the same test to get run several times
67
+ # FIXME: using this causes the same test to get run several times
69
68
  # and some tests fail probably because of a lack of environment isolation.
70
69
  # Many tests follow a basic pattern: run the debugger with a given
71
70
  # debugger script and compare output produced. The following creates
@@ -77,16 +76,16 @@ module TestHelper
77
76
  cmd = 'gcd.rb 3 5' unless cmd
78
77
  eval <<-EOF
79
78
  def test_#{test_name}
80
- Dir.chdir(\"#{src_dir}\") do
81
- assert_equal(true,
82
- run_debugger(\"#{base_name}\",
79
+ Dir.chdir(\"#{src_dir}\") do
80
+ assert_equal(true,
81
+ run_debugger(\"#{base_name}\",
83
82
  \"--script #{script_name} -- #{cmd}\"))
84
83
  end
85
84
  end
86
85
  EOF
87
86
  end
88
87
  module_function :add_test
89
-
88
+
90
89
  # Adapted from the Ruby Cookbook, Section 6.10: Comparing two files.
91
90
  # def diff_as_string(rightfile, checkfile, format=:unified, context_lines=3)
92
91
  # right_data = File.read(rightfile)
@@ -98,7 +97,7 @@ module TestHelper
98
97
  # file_length_difference = 0
99
98
  # diffs.each do |piece|
100
99
  # begin
101
- # hunk = Diff::LCS::Hunk.new(right_data, check_data, piece,
100
+ # hunk = Diff::LCS::Hunk.new(right_data, check_data, piece,
102
101
  # context_lines, file_length_difference)
103
102
  # next unless oldhunk
104
103
  #
@@ -115,11 +114,11 @@ module TestHelper
115
114
  # output << '\n'
116
115
  # end
117
116
  # end
118
-
119
- # # Handle the last remaining hunk
117
+
118
+ # # Handle the last remaining hunk
120
119
  # output << oldhunk.diff(format) << '\n'
121
120
  # end
122
-
121
+
123
122
  # Loads key from the _config_._yaml_ file.
124
123
  def config_load(key, may_be_nil=false, default_value='')
125
124
  conf = File.join('config.private.yaml') # try private first
@@ -139,6 +138,5 @@ module TestHelper
139
138
  config_load('ruby_params', true)
140
139
  end
141
140
  module_function :load_params
142
-
143
- end
144
141
 
142
+ end
@@ -1,27 +1,19 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  require 'test/unit'
4
+ require 'ruby-debug'
4
5
 
5
6
  class TestCatchCommand < Test::Unit::TestCase
6
-
7
- base_dir = File.expand_path(File.join(File.dirname(__FILE__),
8
- '..', '..', '..'))
9
-
10
- %w(ext lib cli).each do |dir|
11
- $: << File.join(base_dir, dir)
12
- end
13
-
14
- require File.join(base_dir, 'cli', 'ruby-debug')
15
-
7
+
16
8
  class MockState
17
- attr_accessor :message
9
+ attr_accessor :message
18
10
  def context; end
19
11
  def confirm(msg); true end
20
12
  def print(*args)
21
13
  @message = *args
22
14
  end
23
15
  end
24
-
16
+
25
17
  # regression test for bug #20156
26
18
  def test_catch_does_not_blow_up
27
19
  state = MockState.new
@@ -2,13 +2,10 @@ require 'test/unit'
2
2
 
3
3
 
4
4
  class TestCommandREs < Test::Unit::TestCase
5
- base_dir=File.expand_path(File.join(File.dirname(__FILE__),
6
- '..', '..', '..', '..',
7
- 'cli', 'ruby-debug'))
8
- require File.join(base_dir, 'command')
9
- require File.join(base_dir, 'commands', 'frame')
5
+ require 'ruby-debug/command'
6
+ require 'ruby-debug/commands/frame'
10
7
  include Debugger
11
-
8
+
12
9
  def test_quit
13
10
  c = QuitCommand.new(nil)
14
11
  assert c.regexp.match('quit')
@@ -39,4 +36,3 @@ class TestCommandREs < Test::Unit::TestCase
39
36
  assert_equal(nil, c.regexp.match('dow'))
40
37
  end
41
38
  end
42
-
data/test/tdebug.rb CHANGED
@@ -4,11 +4,10 @@
4
4
  # FIXME: use the real rdebug script - DRY.
5
5
 
6
6
  require 'stringio'
7
- require 'rubygems'
8
7
  require 'optparse'
9
8
  require "ostruct"
10
9
 
11
- TOP_SRC_DIR = File.join(File.dirname(__FILE__), "..") unless
10
+ TOP_SRC_DIR = File.join(File.dirname(__FILE__), "..") unless
12
11
  defined?(TOP_SRC_DIR)
13
12
 
14
13
  $:.unshift File.join(TOP_SRC_DIR, "ext")
@@ -17,12 +16,12 @@ $:.unshift File.join(TOP_SRC_DIR, "cli")
17
16
 
18
17
  def debug_program(options)
19
18
  # Make sure Ruby script syntax checks okay.
20
- # Otherwise we get a load message that looks like rdebug has
21
- # a problem.
19
+ # Otherwise we get a load message that looks like rdebug has
20
+ # a problem.
22
21
  output = `ruby -c "#{Debugger::PROG_SCRIPT}" 2>&1`
23
22
  if $?.exitstatus != 0 and RUBY_PLATFORM !~ /mswin/
24
23
  puts output
25
- exit $?.exitstatus
24
+ exit $?.exitstatus
26
25
  end
27
26
  print "\032\032starting\n" if Debugger.annotate and Debugger.annotate > 2
28
27
  unless options.no_rewrite_program
@@ -32,7 +31,7 @@ def debug_program(options)
32
31
  # for the first time and then switching to the debug hook that's
33
32
  # normally used would be helpful. Doing this would also help other
34
33
  # first-time initializations such as reloading debugger state
35
- # after a restart.
34
+ # after a restart.
36
35
 
37
36
  # However This is just a little more than I want to take on right
38
37
  # now, so I think I'll stick with the slightly hacky approach.
@@ -96,20 +95,20 @@ EOB
96
95
  Debugger.annotate = s
97
96
  end
98
97
  opts.on("-d", "--debug", "Set $DEBUG=true") {$DEBUG = true}
99
- opts.on("--emacs-basic", "Activates basic Emacs mode") do
98
+ opts.on("--emacs-basic", "Activates basic Emacs mode") do
100
99
  ENV['EMACS'] = '1'
101
100
  options.emacs = true
102
101
  end
103
- opts.on("-m", "--post-mortem", "Activate post-mortem mode") do
102
+ opts.on("-m", "--post-mortem", "Activate post-mortem mode") do
104
103
  options.post_mortem = true
105
104
  end
106
- opts.on("--no-control", "Do not automatically start control thread") do
105
+ opts.on("--no-control", "Do not automatically start control thread") do
107
106
  options.control = false
108
107
  end
109
108
  opts.on("--no-quit", "Do not quit when script finishes") do
110
109
  options.noquit = true
111
110
  end
112
- opts.on("--no-stop", "Do not stop when script is loaded") do
111
+ opts.on("--no-stop", "Do not stop when script is loaded") do
113
112
  options.nostop = true
114
113
  end
115
114
  opts.on("-nx", "Not run debugger initialization files (e.g. .rdebugrc") do
@@ -141,7 +140,7 @@ EOB
141
140
  puts opts
142
141
  exit
143
142
  end
144
- opts.on_tail("--version",
143
+ opts.on_tail("--version",
145
144
  "Print the version") do
146
145
  puts "ruby-debug #{Debugger::VERSION}"
147
146
  exit
@@ -150,7 +149,7 @@ EOB
150
149
  $VERBOSE = true
151
150
  options.verbose_long = true
152
151
  end
153
- opts.on_tail("-v",
152
+ opts.on_tail("-v",
154
153
  "Print version number, then turn on verbose mode") do
155
154
  puts "ruby-debug #{Debugger::VERSION}"
156
155
  $VERBOSE = true
@@ -183,7 +182,7 @@ if ARGV.empty?
183
182
  puts 'Must specify a script to run'
184
183
  exit(-1)
185
184
  end
186
-
185
+
187
186
  # save script name
188
187
  Debugger::PROG_SCRIPT = ARGV.shift
189
188
 
@@ -204,19 +203,19 @@ Debugger.post_mortem if options.post_mortem
204
203
 
205
204
  # Set up an interface to read commands from a debugger script file.
206
205
  if options.script
207
- Debugger.interface = Debugger::ScriptInterface.new(options.script,
206
+ Debugger.interface = Debugger::ScriptInterface.new(options.script,
208
207
  STDOUT, true)
209
208
  end
210
209
  options.nostop = true if options.tracing
211
210
  Debugger.tracing = options.tracing
212
211
 
213
212
  # Make sure Ruby script syntax checks okay.
214
- # Otherwise we get a load message that looks like rdebug has
215
- # a problem.
213
+ # Otherwise we get a load message that looks like rdebug has
214
+ # a problem.
216
215
  output = `ruby -c #{Debugger::PROG_SCRIPT} 2>&1`
217
216
  if $?.exitstatus != 0 and RUBY_PLATFORM !~ /mswin/
218
217
  puts output
219
- exit $?.exitstatus
218
+ exit $?.exitstatus
220
219
  end
221
220
 
222
221
  # load initrc script (e.g. .rdebugrc)
@@ -236,7 +235,7 @@ if options.noquit
236
235
  until Debugger.stop do end
237
236
  end
238
237
  debug_program(options)
239
- print "The program finished.\n" unless
238
+ print "The program finished.\n" unless
240
239
  Debugger.annotate.to_i > 1 # annotate has its own way
241
240
  interface = Debugger::LocalInterface.new
242
241
  # Not sure if ControlCommandProcessor is really the right
@@ -2,7 +2,6 @@
2
2
  require 'test/unit'
3
3
  require 'fileutils'
4
4
 
5
- # begin require 'rubygems' rescue LoadError end
6
5
  # require 'ruby-debug'; Debugger.start
7
6
 
8
7
  # Test annotate handling.
@@ -15,9 +14,9 @@ class TestAnnotate < Test::Unit::TestCase
15
14
 
16
15
  def test_basic
17
16
  testname='annotate'
18
- Dir.chdir(@@SRC_DIR) do
17
+ Dir.chdir(@@SRC_DIR) do
19
18
  script = File.join('data', testname + '.cmd')
20
- assert_equal(true,
19
+ assert_equal(true,
21
20
  run_debugger(testname,
22
21
  "--script #{script} -- ./gcd.rb 3 5"))
23
22
  end
@@ -1,7 +1,6 @@
1
1
  #!/usr/bin/env ruby
2
2
  require 'test/unit'
3
3
 
4
- # begin require 'rubygems' rescue LoadError end
5
4
  # require 'ruby-debug'; Debugger.start
6
5
 
7
6
  # Test (mostly) invalid breakpoint commands
@@ -15,19 +14,19 @@ class TestBadBreak < Test::Unit::TestCase
15
14
 
16
15
  def test_basic
17
16
  testname='break_bad'
18
- Dir.chdir(@@SRC_DIR) do
17
+ Dir.chdir(@@SRC_DIR) do
19
18
  script = File.join('data', testname + '.cmd')
20
19
  assert_equal(true,
21
20
  run_debugger(testname,
22
21
  "--script #{script} -- ./gcd.rb 3 5"))
23
22
  end
24
23
  end
25
-
24
+
26
25
  def test_break_loop
27
26
  testname='break_loop_bug'
28
- Dir.chdir(@@SRC_DIR) do
27
+ Dir.chdir(@@SRC_DIR) do
29
28
  script = File.join('data', testname + '.cmd')
30
- # FIXME: Issue #1
29
+ # FIXME: Issue #1
31
30
  # assert_equal(true,
32
31
  # run_debugger(testname,
33
32
  # "--script #{script} -- ./bp_loop_issue.rb"))
@@ -1,7 +1,6 @@
1
1
  #!/usr/bin/env ruby
2
2
  require 'test/unit'
3
3
 
4
- # begin require 'rubygems' rescue LoadError end
5
4
  # require 'ruby-debug'; Debugger.start
6
5
 
7
6
  # Test breakpoint commands
@@ -15,9 +14,9 @@ class TestBreakpoints < Test::Unit::TestCase
15
14
 
16
15
  def test_basic
17
16
  testname='breakpoints'
18
- Dir.chdir(@@SRC_DIR) do
17
+ Dir.chdir(@@SRC_DIR) do
19
18
  script = File.join('data', testname + '.cmd')
20
- assert_equal(true,
19
+ assert_equal(true,
21
20
  run_debugger(testname,
22
21
  "--script #{script} -- ./gcd.rb 3 5"))
23
22
  end
data/test/test-catch.rb CHANGED
@@ -1,7 +1,6 @@
1
1
  #!/usr/bin/env ruby
2
2
  require 'test/unit'
3
3
 
4
- # begin require 'rubygems' rescue LoadError end
5
4
  # require 'ruby-debug'; Debugger.start
6
5
 
7
6
  # Test exception catching
@@ -15,7 +14,7 @@ class TestExceptionCatch < Test::Unit::TestCase
15
14
 
16
15
  def test_basic
17
16
  testname='catch'
18
- Dir.chdir(@@SRC_DIR) do
17
+ Dir.chdir(@@SRC_DIR) do
19
18
  script = File.join('data', testname + '.cmd')
20
19
  assert_equal(true,
21
20
  run_debugger(testname,