ruby-debug 0.10.0 → 0.10.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGES +94 -2
- data/ChangeLog +5225 -0
- data/README +30 -1
- data/Rakefile +55 -24
- data/bin/rdebug +249 -128
- data/cli/ruby-debug/command.rb +30 -3
- data/cli/ruby-debug/commands/breakpoints.rb +54 -24
- data/cli/ruby-debug/commands/catchpoint.rb +13 -12
- data/cli/ruby-debug/commands/condition.rb +49 -0
- data/cli/ruby-debug/commands/continue.rb +32 -0
- data/cli/ruby-debug/commands/control.rb +19 -43
- data/cli/ruby-debug/commands/disassemble.RB +38 -0
- data/cli/ruby-debug/commands/display.rb +1 -1
- data/cli/ruby-debug/commands/edit.rb +48 -0
- data/cli/ruby-debug/commands/enable.rb +78 -35
- data/cli/ruby-debug/commands/eval.rb +6 -5
- data/cli/ruby-debug/commands/finish.rb +42 -0
- data/cli/ruby-debug/commands/frame.rb +64 -33
- data/cli/ruby-debug/commands/help.rb +19 -15
- data/cli/ruby-debug/commands/info.rb +295 -36
- data/cli/ruby-debug/commands/irb.rb +3 -1
- data/cli/ruby-debug/commands/list.rb +27 -50
- data/cli/ruby-debug/commands/quit.rb +38 -0
- data/cli/ruby-debug/commands/reload.rb +40 -0
- data/cli/ruby-debug/commands/save.rb +80 -0
- data/cli/ruby-debug/commands/{settings.rb → set.rb} +50 -12
- data/cli/ruby-debug/commands/show.rb +83 -27
- data/cli/ruby-debug/commands/source.rb +36 -0
- data/cli/ruby-debug/commands/stepping.rb +36 -72
- data/cli/ruby-debug/commands/threads.rb +32 -23
- data/cli/ruby-debug/commands/variables.rb +34 -4
- data/cli/ruby-debug/helper.rb +10 -75
- data/cli/ruby-debug/interface.rb +72 -9
- data/cli/ruby-debug/processor.rb +203 -100
- data/doc/rdebug.1 +7 -2
- data/rdbg.rb +33 -0
- data/test/{test-ruby-debug-base.rb → base/base.rb} +27 -29
- data/test/base/binding.rb +31 -0
- data/test/base/catchpoint.rb +26 -0
- data/test/base/load.rb +40 -0
- data/test/data/annotate.cmd +29 -0
- data/test/data/annotate.right +137 -0
- data/test/data/break_bad.cmd +18 -0
- data/test/data/break_bad.right +28 -0
- data/test/data/breakpoints.cmd +38 -0
- data/test/data/breakpoints.right +98 -0
- data/test/data/condition.cmd +28 -0
- data/test/data/condition.right +65 -0
- data/test/data/ctrl.cmd +23 -0
- data/test/data/ctrl.right +69 -0
- data/test/{display.cmd → data/display.cmd} +7 -1
- data/test/{display.right → data/display.right} +13 -6
- data/test/data/dollar-0.right +2 -0
- data/test/data/dollar-0a.right +2 -0
- data/test/data/dollar-0b.right +2 -0
- data/test/data/edit.cmd +12 -0
- data/test/data/edit.right +19 -0
- data/test/{breakpoints.cmd → data/emacs_basic.cmd} +0 -0
- data/test/{breakpoints.right → data/emacs_basic.right} +24 -12
- data/test/data/enable.cmd +20 -0
- data/test/data/enable.right +36 -0
- data/test/data/finish.cmd +16 -0
- data/test/data/finish.right +43 -0
- data/test/{frame.cmd → data/frame.cmd} +2 -0
- data/test/{frame.right → data/frame.right} +8 -2
- data/test/{help.cmd → data/help.cmd} +8 -0
- data/test/data/help.right +21 -0
- data/test/data/history.right +7 -0
- data/test/data/info-thread.cmd +13 -0
- data/test/data/info-thread.right +37 -0
- data/test/data/info-var-bug2.cmd +5 -0
- data/test/data/info-var-bug2.right +10 -0
- data/test/{info-var.cmd → data/info-var.cmd} +3 -3
- data/test/{info-var.right → data/info-var.right} +20 -15
- data/test/{info.cmd → data/info.cmd} +10 -1
- data/test/data/info.right +65 -0
- data/test/data/linetrace.cmd +6 -0
- data/test/data/linetrace.right +32 -0
- data/test/data/linetracep.cmd +7 -0
- data/test/data/linetracep.right +25 -0
- data/test/data/list.cmd +19 -0
- data/test/data/list.right +127 -0
- data/test/data/noquit.right +1 -0
- data/test/data/output.cmd +6 -0
- data/test/data/output.right +41 -0
- data/test/data/post-mortem-next.cmd +8 -0
- data/test/data/post-mortem-next.right +14 -0
- data/test/data/post-mortem-osx.right +31 -0
- data/test/data/post-mortem.cmd +13 -0
- data/test/data/post-mortem.right +31 -0
- data/test/{quit.cmd → data/quit.cmd} +2 -5
- data/test/data/quit.right +9 -0
- data/test/data/raise.cmd +11 -0
- data/test/data/raise.right +26 -0
- data/test/{setshow.cmd → data/setshow.cmd} +0 -1
- data/test/{setshow.right → data/setshow.right} +0 -1
- data/test/data/source.cmd +5 -0
- data/test/data/source.right +15 -0
- data/test/{stepping.cmd → data/stepping.cmd} +6 -2
- data/test/{stepping.right → data/stepping.right} +13 -3
- data/test/data/test-init-cygwin.right +7 -0
- data/test/data/test-init-osx.right +4 -0
- data/test/data/test-init.right +5 -0
- data/test/data/trace.right +23 -0
- data/test/dollar-0.rb +5 -0
- data/test/except-bug2.rb +7 -0
- data/test/gcd-dbg-nox.rb +31 -0
- data/test/gcd-dbg.rb +30 -0
- data/test/helper.rb +44 -14
- data/test/info-var-bug.rb +2 -0
- data/test/info-var-bug2.rb +2 -0
- data/test/null.rb +1 -0
- data/test/output.rb +2 -0
- data/test/pm-base.rb +22 -0
- data/test/pm.rb +11 -0
- data/test/raise.rb +3 -0
- data/test/tdebug.rb +88 -40
- data/test/test-annotate.rb +25 -0
- data/test/test-break-bad.rb +25 -0
- data/test/test-breakpoints.rb +14 -17
- data/test/test-condition.rb +25 -0
- data/test/test-ctrl.rb +54 -0
- data/test/test-display.rb +15 -15
- data/test/test-dollar-0.rb +39 -0
- data/test/test-edit.rb +26 -0
- data/test/test-emacs-basic.rb +26 -0
- data/test/test-enable.rb +25 -0
- data/test/test-finish.rb +34 -0
- data/test/test-frame.rb +15 -16
- data/test/test-help.rb +34 -18
- data/test/test-hist.rb +68 -0
- data/test/test-info-thread.rb +32 -0
- data/test/test-info-var.rb +28 -14
- data/test/test-info.rb +15 -17
- data/test/test-init.rb +41 -0
- data/test/test-list.rb +25 -0
- data/test/test-output.rb +26 -0
- data/test/test-pm.rb +46 -0
- data/test/test-quit.rb +19 -17
- data/test/test-raise.rb +25 -0
- data/test/test-setshow.rb +14 -13
- data/test/test-source.rb +25 -0
- data/test/test-stepping.rb +14 -14
- data/test/test-trace.rb +63 -0
- data/test/thread1.rb +26 -0
- metadata +125 -31
- data/cli/ruby-debug/commands/script.rb +0 -64
- data/runner.sh +0 -7
- data/test/help.right +0 -4
- data/test/info.right +0 -35
- data/test/quit.right +0 -22
- data/test/test-columnize.rb +0 -46
data/test/raise.rb
ADDED
data/test/tdebug.rb
CHANGED
|
@@ -1,20 +1,68 @@
|
|
|
1
1
|
#!/usr/bin/env ruby
|
|
2
2
|
# -*- Ruby -*-
|
|
3
3
|
# This is a hacked down copy of rdebug which can be used for testing
|
|
4
|
+
# FIXME: use the real rdebug script - DRY.
|
|
4
5
|
|
|
5
6
|
require 'stringio'
|
|
6
7
|
require 'rubygems'
|
|
7
8
|
require 'optparse'
|
|
8
9
|
require "ostruct"
|
|
9
10
|
|
|
10
|
-
TOP_SRC_DIR = File.join(File.
|
|
11
|
+
TOP_SRC_DIR = File.join(File.dirname(__FILE__), "..") unless
|
|
11
12
|
defined?(TOP_SRC_DIR)
|
|
12
13
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
$:.unshift File.join(TOP_SRC_DIR, "ext")
|
|
15
|
+
$:.unshift File.join(TOP_SRC_DIR, "lib")
|
|
16
|
+
$:.unshift File.join(TOP_SRC_DIR, "cli")
|
|
17
|
+
|
|
18
|
+
def debug_program(options)
|
|
19
|
+
# Make sure Ruby script syntax checks okay.
|
|
20
|
+
# Otherwise we get a load message that looks like rdebug has
|
|
21
|
+
# a problem.
|
|
22
|
+
output = `ruby -c #{Debugger::PROG_SCRIPT} 2>&1`
|
|
23
|
+
if $?.exitstatus != 0 and RUBY_PLATFORM !~ /mswin/
|
|
24
|
+
puts output
|
|
25
|
+
exit $?.exitstatus
|
|
26
|
+
end
|
|
27
|
+
print "\032\032starting\n" if Debugger.annotate and Debugger.annotate > 2
|
|
28
|
+
unless options.no_rewrite_program
|
|
29
|
+
# Set $0 so things like __FILE == $0 work.
|
|
30
|
+
# A more reliable way to do this is to put $0 = __FILE__ *after*
|
|
31
|
+
# loading the script to be debugged. For this, adding a debug hook
|
|
32
|
+
# for the first time and then switching to the debug hook that's
|
|
33
|
+
# normally used would be helpful. Doing this would also help other
|
|
34
|
+
# first-time initializations such as reloading debugger state
|
|
35
|
+
# after a restart.
|
|
36
|
+
|
|
37
|
+
# However This is just a little more than I want to take on right
|
|
38
|
+
# now, so I think I'll stick with the slightly hacky approach.
|
|
39
|
+
$RDEBUG_0 = $0
|
|
40
|
+
|
|
41
|
+
# cygwin does some sort of funky truncation on $0 ./abcdef => ./ab
|
|
42
|
+
# probably something to do with 3-letter extension truncation.
|
|
43
|
+
# The hacky workaround is to do slice assignment. Ugh.
|
|
44
|
+
d0 = if '.' == File.dirname(Debugger::PROG_SCRIPT) and
|
|
45
|
+
Debugger::PROG_SCRIPT[0..0] != '.'
|
|
46
|
+
File.join('.', Debugger::PROG_SCRIPT)
|
|
47
|
+
else
|
|
48
|
+
Debugger::PROG_SCRIPT
|
|
49
|
+
end
|
|
50
|
+
$0[0..-1] = d0
|
|
51
|
+
end
|
|
52
|
+
bt = Debugger.debug_load(Debugger::PROG_SCRIPT, !options.nostop)
|
|
53
|
+
if bt
|
|
54
|
+
if options.post_mortem
|
|
55
|
+
Debugger.handle_post_mortem(bt)
|
|
56
|
+
else
|
|
57
|
+
print bt.backtrace.map{|l| "\t#{l}"}.join("\n"), "\n"
|
|
58
|
+
print "Uncaught exception: #{bt}\n"
|
|
59
|
+
end
|
|
60
|
+
end
|
|
61
|
+
end
|
|
16
62
|
|
|
17
63
|
options = OpenStruct.new(
|
|
64
|
+
'annotate' => false,
|
|
65
|
+
'emacs' => false,
|
|
18
66
|
'frame_bind' => false,
|
|
19
67
|
'no-quit' => false,
|
|
20
68
|
'no-stop' => false,
|
|
@@ -37,23 +85,31 @@ EOB
|
|
|
37
85
|
opts.separator ""
|
|
38
86
|
opts.separator "Options:"
|
|
39
87
|
opts.on("-A", "--annotate LEVEL", Integer, "Set annotation level") do
|
|
40
|
-
|Debugger
|
|
88
|
+
|Debugger.annotate|
|
|
41
89
|
end
|
|
42
90
|
opts.on("-d", "--debug", "Set $DEBUG=true") {$DEBUG = true}
|
|
91
|
+
opts.on("--emacs-basic", "Activates basic Emacs mode") do
|
|
92
|
+
ENV['EMACS'] = '1'
|
|
93
|
+
options.emacs = true
|
|
94
|
+
end
|
|
43
95
|
opts.on("--keep-frame-binding", "Keep frame bindings") do
|
|
44
96
|
options.frame_bind = true
|
|
45
97
|
end
|
|
98
|
+
opts.on("-m", "--post-mortem", "Activate post-mortem mode") do
|
|
99
|
+
options.post_mortem = true
|
|
100
|
+
end
|
|
46
101
|
opts.on("--no-control", "Do not automatically start control thread") do
|
|
47
102
|
options.control = false
|
|
48
103
|
end
|
|
49
|
-
opts.on("--no-quit", "Do not quit when script finishes")
|
|
104
|
+
opts.on("--no-quit", "Do not quit when script finishes") do
|
|
50
105
|
options.noquit = true
|
|
51
|
-
|
|
52
|
-
opts.on("
|
|
106
|
+
end
|
|
107
|
+
opts.on("--no-stop", "Do not stop when script is loaded") do
|
|
108
|
+
options.nostop = true
|
|
109
|
+
end
|
|
53
110
|
opts.on("-nx", "Not run debugger initialization files (e.g. .rdebugrc") do
|
|
54
111
|
options.nx = true
|
|
55
112
|
end
|
|
56
|
-
opts.on("-m", "--post-mortem", "Activate post-mortem mode") {options.post_mortem = true}
|
|
57
113
|
opts.on("-I", "--include PATH", String, "Add PATH to $LOAD_PATH") do |path|
|
|
58
114
|
$LOAD_PATH.unshift(path)
|
|
59
115
|
end
|
|
@@ -72,7 +128,7 @@ EOB
|
|
|
72
128
|
end
|
|
73
129
|
end
|
|
74
130
|
opts.on("-x", "--trace", "Turn on line tracing") {options.tracing = true}
|
|
75
|
-
ENV['EMACS'] = nil
|
|
131
|
+
ENV['EMACS'] = nil unless options.emacs
|
|
76
132
|
opts.separator ""
|
|
77
133
|
opts.separator "Common options:"
|
|
78
134
|
opts.on_tail("--help", "Show this message") do
|
|
@@ -101,9 +157,10 @@ begin
|
|
|
101
157
|
end
|
|
102
158
|
rdebug_path = File.expand_path($0)
|
|
103
159
|
if RUBY_PLATFORM =~ /mswin/
|
|
104
|
-
rdebug_path +=
|
|
160
|
+
rdebug_path += '.cmd' unless rdebug_path =~ /\.cmd$/i
|
|
105
161
|
end
|
|
106
162
|
Debugger::RDEBUG_SCRIPT = rdebug_path
|
|
163
|
+
Debugger::RDEBUG_FILE = __FILE__
|
|
107
164
|
Debugger::INITIAL_DIR = Dir.pwd
|
|
108
165
|
opts.parse! ARGV
|
|
109
166
|
rescue StandardError => e
|
|
@@ -117,7 +174,7 @@ if ARGV.empty?
|
|
|
117
174
|
exit if $VERBOSE and not options.verbose_long
|
|
118
175
|
puts opts
|
|
119
176
|
puts
|
|
120
|
-
puts
|
|
177
|
+
puts 'Must specify a script to run'
|
|
121
178
|
exit(-1)
|
|
122
179
|
end
|
|
123
180
|
|
|
@@ -138,9 +195,12 @@ Debugger.start
|
|
|
138
195
|
Debugger.post_mortem if options.post_mortem
|
|
139
196
|
|
|
140
197
|
# Set up an interface to read commands from a debugger script file.
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
198
|
+
if options.script
|
|
199
|
+
Debugger.interface = Debugger::ScriptInterface.new(options.script,
|
|
200
|
+
STDOUT, true)
|
|
201
|
+
end
|
|
202
|
+
options.nostop = true if options.tracing
|
|
203
|
+
Debugger.tracing = options.tracing
|
|
144
204
|
|
|
145
205
|
# Make sure Ruby script syntax checks okay.
|
|
146
206
|
# Otherwise we get a load message that looks like rdebug has
|
|
@@ -164,33 +224,21 @@ if options.script
|
|
|
164
224
|
end
|
|
165
225
|
# activate post-mortem
|
|
166
226
|
Debugger.post_mortem if options.post_mortem
|
|
167
|
-
|
|
227
|
+
options.stop = false if options.tracing
|
|
228
|
+
Debugger.tracing = options.tracing
|
|
168
229
|
|
|
169
|
-
# Make sure Ruby script syntax checks okay.
|
|
170
|
-
# Otherwise we get a load message that looks like rdebug has
|
|
171
|
-
# a problem.
|
|
172
|
-
output = `ruby -c #{Debugger::PROG_SCRIPT} 2>&1`
|
|
173
|
-
if $?.exitstatus != 0 and RUBY_PLATFORM !~ /mswin/
|
|
174
|
-
puts output
|
|
175
|
-
exit $?.exitstatus
|
|
176
|
-
end
|
|
177
230
|
if options.noquit
|
|
178
|
-
|
|
179
|
-
Debugger.stop
|
|
180
|
-
begin
|
|
181
|
-
Debugger.debug_load Debugger::PROG_SCRIPT, !options.nostop
|
|
182
|
-
rescue
|
|
183
|
-
print $!.backtrace.map{|l| "\t#{l}"}.join("\n"), "\n"
|
|
184
|
-
print "Uncaught exception: #{$!}\n"
|
|
185
|
-
end
|
|
186
|
-
# FIXME: add status for whether we are interactive or not.
|
|
187
|
-
# if STDIN.tty? and !options.nostop
|
|
188
|
-
if !options.nostop
|
|
189
|
-
print "The program has finished and will be restarted.\n"
|
|
190
|
-
else
|
|
191
|
-
break
|
|
192
|
-
end
|
|
231
|
+
if Debugger.started?
|
|
232
|
+
until Debugger.stop do end
|
|
193
233
|
end
|
|
234
|
+
debug_program(options)
|
|
235
|
+
print "The program finished.\n" unless
|
|
236
|
+
Debugger.annotate.to_i > 1 # annotate has its own way
|
|
237
|
+
interface = Debugger::LocalInterface.new
|
|
238
|
+
# Not sure if ControlCommandProcessor is really the right
|
|
239
|
+
# thing to use. CommandProcessor requires a state.
|
|
240
|
+
processor = Debugger::ControlCommandProcessor.new(interface)
|
|
241
|
+
processor.process_commands
|
|
194
242
|
else
|
|
195
|
-
|
|
243
|
+
debug_program(options)
|
|
196
244
|
end
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
require 'test/unit'
|
|
3
|
+
require 'fileutils'
|
|
4
|
+
|
|
5
|
+
# begin require 'rubygems' rescue LoadError end
|
|
6
|
+
# require 'ruby-debug'; Debugger.start
|
|
7
|
+
|
|
8
|
+
# Test annotate handling.
|
|
9
|
+
class TestAnnotate < Test::Unit::TestCase
|
|
10
|
+
@@SRC_DIR = File.dirname(__FILE__) unless
|
|
11
|
+
defined?(@@SRC_DIR)
|
|
12
|
+
|
|
13
|
+
require File.join(@@SRC_DIR, 'helper')
|
|
14
|
+
include TestHelper
|
|
15
|
+
|
|
16
|
+
def test_basic
|
|
17
|
+
testname='annotate'
|
|
18
|
+
Dir.chdir(@@SRC_DIR) do
|
|
19
|
+
script = File.join('data', testname + '.cmd')
|
|
20
|
+
assert_equal(true,
|
|
21
|
+
run_debugger(testname,
|
|
22
|
+
"--script #{script} -- gcd.rb 3 5"))
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
require 'test/unit'
|
|
3
|
+
|
|
4
|
+
# begin require 'rubygems' rescue LoadError end
|
|
5
|
+
# require 'ruby-debug'; Debugger.start
|
|
6
|
+
|
|
7
|
+
# Test (mostly) invalid breakpoint commands
|
|
8
|
+
class TestBadBreak < Test::Unit::TestCase
|
|
9
|
+
|
|
10
|
+
@@SRC_DIR = File.dirname(__FILE__) unless
|
|
11
|
+
defined?(@@SRC_DIR)
|
|
12
|
+
|
|
13
|
+
require File.join(@@SRC_DIR, 'helper')
|
|
14
|
+
include TestHelper
|
|
15
|
+
|
|
16
|
+
def test_basic
|
|
17
|
+
testname='break_bad'
|
|
18
|
+
Dir.chdir(@@SRC_DIR) do
|
|
19
|
+
script = File.join('data', testname + '.cmd')
|
|
20
|
+
assert_equal(true,
|
|
21
|
+
run_debugger(testname,
|
|
22
|
+
"--script #{script} -- gcd.rb 3 5"))
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
data/test/test-breakpoints.rb
CHANGED
|
@@ -1,28 +1,25 @@
|
|
|
1
1
|
#!/usr/bin/env ruby
|
|
2
|
-
require
|
|
3
|
-
require "fileutils"
|
|
2
|
+
require 'test/unit'
|
|
4
3
|
|
|
5
|
-
# require
|
|
6
|
-
# require
|
|
7
|
-
# Debugger.start
|
|
4
|
+
# begin require 'rubygems' rescue LoadError end
|
|
5
|
+
# require 'ruby-debug'; Debugger.start
|
|
8
6
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
require File.join(SRC_DIR, "helper.rb")
|
|
7
|
+
# Test breakpoint commands
|
|
8
|
+
class TestBreakpoints < Test::Unit::TestCase
|
|
13
9
|
|
|
14
|
-
|
|
10
|
+
@@SRC_DIR = File.dirname(__FILE__) unless
|
|
11
|
+
defined?(@@SRC_DIR)
|
|
15
12
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
require 'stringio'
|
|
13
|
+
require File.join(@@SRC_DIR, 'helper')
|
|
14
|
+
include TestHelper
|
|
19
15
|
|
|
20
|
-
# Test commands in stepping.rb
|
|
21
16
|
def test_basic
|
|
22
|
-
|
|
17
|
+
testname='breakpoints'
|
|
18
|
+
Dir.chdir(@@SRC_DIR) do
|
|
19
|
+
script = File.join('data', testname + '.cmd')
|
|
23
20
|
assert_equal(true,
|
|
24
|
-
run_debugger(
|
|
25
|
-
"--script
|
|
21
|
+
run_debugger(testname,
|
|
22
|
+
"--script #{script} -- gcd.rb 3 5"))
|
|
26
23
|
end
|
|
27
24
|
end
|
|
28
25
|
end
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
require 'test/unit'
|
|
3
|
+
|
|
4
|
+
# begin require 'rubygems' rescue LoadError end
|
|
5
|
+
# require 'ruby-debug'; Debugger.start
|
|
6
|
+
|
|
7
|
+
# Test condition command
|
|
8
|
+
class TestBreakpoints < Test::Unit::TestCase
|
|
9
|
+
|
|
10
|
+
@@SRC_DIR = File.dirname(__FILE__) unless
|
|
11
|
+
defined?(@@SRC_DIR)
|
|
12
|
+
|
|
13
|
+
require File.join(@@SRC_DIR, 'helper')
|
|
14
|
+
include TestHelper
|
|
15
|
+
|
|
16
|
+
def test_basic
|
|
17
|
+
testname='condition'
|
|
18
|
+
Dir.chdir(@@SRC_DIR) do
|
|
19
|
+
script = File.join('data', testname + '.cmd')
|
|
20
|
+
assert_equal(true,
|
|
21
|
+
run_debugger(testname,
|
|
22
|
+
"--script #{script} -- gcd.rb 3 5"))
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
data/test/test-ctrl.rb
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
|
|
3
|
+
# begin require 'rubygems' rescue LoadError end
|
|
4
|
+
# require 'ruby-debug' ; Debugger.start
|
|
5
|
+
|
|
6
|
+
require 'test/unit'
|
|
7
|
+
SRC_DIR = File.dirname(__FILE__) unless
|
|
8
|
+
defined?(SRC_DIR)
|
|
9
|
+
%w(ext lib cli).each do |dir|
|
|
10
|
+
$: << File.join(SRC_DIR, '..', dir)
|
|
11
|
+
end
|
|
12
|
+
require 'ruby_debug'
|
|
13
|
+
require File.join(SRC_DIR, '..', 'cli', 'ruby-debug')
|
|
14
|
+
|
|
15
|
+
# Test Local Control Interface
|
|
16
|
+
class TestCtrl < Test::Unit::TestCase
|
|
17
|
+
|
|
18
|
+
def cheap_diff(got_lines, correct_lines, outfile)
|
|
19
|
+
if correct_lines.size != got_lines.size
|
|
20
|
+
puts "Size difference #{correct_lines.size} vs. #{got_lines.size}"
|
|
21
|
+
File.open(outfile, 'w') {|f| f.puts got_lines}
|
|
22
|
+
return false
|
|
23
|
+
end
|
|
24
|
+
correct_lines.each_with_index do |line, i|
|
|
25
|
+
correct_lines[i].chomp!
|
|
26
|
+
if got_lines[i] != correct_lines[i]
|
|
27
|
+
puts "difference found at line #{i+1}"
|
|
28
|
+
puts "got : #{got_lines[i]}"
|
|
29
|
+
puts "need: #{correct_lines[i]}"
|
|
30
|
+
return false
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
require 'stringio'
|
|
36
|
+
|
|
37
|
+
# Test initial variables and setting/getting state.
|
|
38
|
+
def test_ctrl
|
|
39
|
+
ENV['COLUMNS'] = '80'
|
|
40
|
+
ENV['EMACS'] = nil
|
|
41
|
+
testbase = 'ctrl'
|
|
42
|
+
out = StringIO.new('', 'w')
|
|
43
|
+
Dir.chdir(SRC_DIR) do
|
|
44
|
+
script = File.join('data', "#{testbase}.cmd")
|
|
45
|
+
interface = Debugger::ScriptInterface.new(script, out)
|
|
46
|
+
processor = Debugger::ControlCommandProcessor.new(interface)
|
|
47
|
+
processor.process_commands
|
|
48
|
+
got_lines = out.string.split("\n")
|
|
49
|
+
right_file = File.join('data', "#{testbase}.right")
|
|
50
|
+
correct_lines = File.readlines(right_file)
|
|
51
|
+
assert cheap_diff(got_lines, correct_lines, "#{testbase}.out")
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
end
|
data/test/test-display.rb
CHANGED
|
@@ -1,26 +1,26 @@
|
|
|
1
1
|
#!/usr/bin/env ruby
|
|
2
|
-
require
|
|
3
|
-
require "fileutils"
|
|
2
|
+
require 'test/unit'
|
|
4
3
|
|
|
5
|
-
# require
|
|
6
|
-
# Debugger.start
|
|
4
|
+
# begin require 'rubygems' rescue LoadError end
|
|
5
|
+
# require 'ruby-debug'; Debugger.start
|
|
7
6
|
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
# Test Display commands
|
|
8
|
+
class TestDisplay < Test::Unit::TestCase
|
|
10
9
|
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
@@SRC_DIR = File.dirname(__FILE__) unless
|
|
11
|
+
defined?(@@SRC_DIR)
|
|
13
12
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
require 'stringio'
|
|
13
|
+
require File.join(@@SRC_DIR, 'helper')
|
|
14
|
+
include TestHelper
|
|
17
15
|
|
|
18
|
-
# Test commands in
|
|
16
|
+
# Test commands in display.rb
|
|
19
17
|
def test_basic
|
|
20
|
-
|
|
18
|
+
testname='display'
|
|
19
|
+
Dir.chdir(@@SRC_DIR) do
|
|
20
|
+
script = File.join('data', testname + '.cmd')
|
|
21
21
|
assert_equal(true,
|
|
22
|
-
run_debugger(
|
|
23
|
-
"--script
|
|
22
|
+
run_debugger(testname,
|
|
23
|
+
"--script #{script} -- gcd.rb 3 5"))
|
|
24
24
|
end
|
|
25
25
|
end
|
|
26
26
|
end
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
require 'test/unit'
|
|
3
|
+
|
|
4
|
+
# begin require 'rubygems' rescue LoadError end
|
|
5
|
+
# require 'ruby-debug'; Debugger.start
|
|
6
|
+
|
|
7
|
+
# Test --no-stop and $0 setting.
|
|
8
|
+
class TestDollar0 < Test::Unit::TestCase
|
|
9
|
+
|
|
10
|
+
@@SRC_DIR = File.dirname(__FILE__) unless
|
|
11
|
+
defined?(@@SRC_DIR)
|
|
12
|
+
|
|
13
|
+
require File.join(@@SRC_DIR, 'helper')
|
|
14
|
+
include TestHelper
|
|
15
|
+
|
|
16
|
+
def test_basic
|
|
17
|
+
testname='breakpoints'
|
|
18
|
+
Dir.chdir(@@SRC_DIR) do
|
|
19
|
+
home_save = ENV['HOME']
|
|
20
|
+
ENV['HOME'] = '.'
|
|
21
|
+
assert_equal(true,
|
|
22
|
+
run_debugger('dollar-0',
|
|
23
|
+
'-nx --no-stop ./dollar-0.rb',
|
|
24
|
+
nil, nil, false, '../bin/rdebug'))
|
|
25
|
+
# Ruby's __FILE__ seems to prepend ./ when no directory was added.
|
|
26
|
+
assert_equal(true,
|
|
27
|
+
run_debugger('dollar-0a',
|
|
28
|
+
'-nx --no-stop dollar-0.rb',
|
|
29
|
+
nil, nil, false, '../bin/rdebug'))
|
|
30
|
+
# Ruby's __FILE__ seems to prepend ./ when no directory was added.
|
|
31
|
+
assert_equal(true,
|
|
32
|
+
run_debugger('dollar-0b',
|
|
33
|
+
'-nx --no-stop ' +
|
|
34
|
+
File.join('..', 'test', 'dollar-0.rb'),
|
|
35
|
+
nil, nil, false, '../bin/rdebug'))
|
|
36
|
+
ENV['HOME'] = home_save
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
end
|