ruby-debug 0.9.3 → 0.10.0
Sign up to get free protection for your applications and to get access to all the features.
- data/AUTHORS +1 -0
- data/CHANGES +41 -0
- data/ChangeLog +0 -0
- data/README +27 -13
- data/Rakefile +220 -0
- data/bin/rdebug +116 -42
- data/cli/ruby-debug.rb +33 -3
- data/cli/ruby-debug/command.rb +49 -12
- data/cli/ruby-debug/commands/breakpoints.rb +47 -64
- data/cli/ruby-debug/commands/control.rb +41 -13
- data/cli/ruby-debug/commands/display.rb +35 -18
- data/cli/ruby-debug/commands/enable.rb +159 -0
- data/cli/ruby-debug/commands/eval.rb +78 -4
- data/cli/ruby-debug/commands/frame.rb +67 -42
- data/cli/ruby-debug/commands/help.rb +21 -17
- data/cli/ruby-debug/commands/info.rb +210 -0
- data/cli/ruby-debug/commands/irb.rb +9 -1
- data/cli/ruby-debug/commands/list.rb +11 -8
- data/cli/ruby-debug/commands/method.rb +12 -23
- data/cli/ruby-debug/commands/script.rb +14 -9
- data/cli/ruby-debug/commands/settings.rb +174 -39
- data/cli/ruby-debug/commands/show.rb +193 -0
- data/cli/ruby-debug/commands/stepping.rb +15 -10
- data/cli/ruby-debug/commands/threads.rb +55 -56
- data/cli/ruby-debug/commands/variables.rb +27 -27
- data/cli/ruby-debug/helper.rb +134 -0
- data/cli/ruby-debug/interface.rb +46 -15
- data/cli/ruby-debug/processor.rb +156 -25
- data/doc/rdebug.1 +236 -0
- data/runner.sh +7 -0
- data/test/breakpoints.cmd +43 -0
- data/test/breakpoints.right +94 -0
- data/test/display.cmd +18 -0
- data/test/display.right +37 -0
- data/test/frame.cmd +21 -0
- data/test/frame.right +45 -0
- data/test/gcd.rb +18 -0
- data/test/help.cmd +12 -0
- data/test/help.right +4 -0
- data/test/helper.rb +87 -0
- data/test/info-var-bug.rb +45 -0
- data/test/info-var.cmd +23 -0
- data/test/info-var.right +47 -0
- data/test/info.cmd +12 -0
- data/test/info.right +35 -0
- data/test/quit.cmd +9 -0
- data/test/quit.right +22 -0
- data/test/setshow.cmd +44 -0
- data/test/setshow.right +73 -0
- data/test/stepping.cmd +17 -0
- data/test/stepping.right +40 -0
- data/test/tdebug.rb +196 -0
- data/test/test-breakpoints.rb +28 -0
- data/test/test-columnize.rb +46 -0
- data/test/test-display.rb +26 -0
- data/test/test-frame.rb +27 -0
- data/test/test-help.rb +44 -0
- data/test/test-info-var.rb +33 -0
- data/test/test-info.rb +28 -0
- data/test/test-quit.rb +28 -0
- data/test/test-ruby-debug-base.rb +76 -0
- data/test/test-setshow.rb +24 -0
- data/test/test-stepping.rb +26 -0
- metadata +63 -22
data/test/frame.right
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
gcd.rb:4
|
2
|
+
def gcd(a, b)
|
3
|
+
# # ***************************************************
|
4
|
+
# # This tests step, next, finish and continue
|
5
|
+
# # ***************************************************
|
6
|
+
# set debuggertesting on
|
7
|
+
Currently testing the debugger is on.
|
8
|
+
# set callstyle last
|
9
|
+
Frame call-display style is last.
|
10
|
+
# continue 6
|
11
|
+
gcd.rb:6
|
12
|
+
if a > b
|
13
|
+
# where
|
14
|
+
--> #0 Object.gcd(a#Fixnum, b#Fixnum) at line gcd.rb:6
|
15
|
+
#1 at line gcd.rb:18
|
16
|
+
# up
|
17
|
+
#1 at line gcd.rb:18
|
18
|
+
# where
|
19
|
+
#0 Object.gcd(a#Fixnum, b#Fixnum) at line gcd.rb:6
|
20
|
+
--> #1 at line gcd.rb:18
|
21
|
+
# down
|
22
|
+
#0 Object.gcd(a#Fixnum, b#Fixnum) at line gcd.rb:6
|
23
|
+
# where
|
24
|
+
--> #0 Object.gcd(a#Fixnum, b#Fixnum) at line gcd.rb:6
|
25
|
+
#1 at line gcd.rb:18
|
26
|
+
# frame 0
|
27
|
+
#0 Object.gcd(a#Fixnum, b#Fixnum) at line gcd.rb:6
|
28
|
+
# where
|
29
|
+
--> #0 Object.gcd(a#Fixnum, b#Fixnum) at line gcd.rb:6
|
30
|
+
#1 at line gcd.rb:18
|
31
|
+
# frame -1
|
32
|
+
#1 at line gcd.rb:18
|
33
|
+
# where
|
34
|
+
#0 Object.gcd(a#Fixnum, b#Fixnum) at line gcd.rb:6
|
35
|
+
--> #1 at line gcd.rb:18
|
36
|
+
# up 2
|
37
|
+
Adjusting would put us beyond the oldest (initial) frame.# where
|
38
|
+
#0 Object.gcd(a#Fixnum, b#Fixnum) at line gcd.rb:6
|
39
|
+
--> #1 at line gcd.rb:18
|
40
|
+
# down 2
|
41
|
+
Adjusting would put us beyond the newest (innermost) frame.# where
|
42
|
+
#0 Object.gcd(a#Fixnum, b#Fixnum) at line gcd.rb:6
|
43
|
+
--> #1 at line gcd.rb:18
|
44
|
+
# # finish
|
45
|
+
# quit
|
data/test/gcd.rb
ADDED
data/test/help.cmd
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
# $Id: setshow.cmd 298 2007-08-28 10:07:35Z rockyb $
|
2
|
+
# This tests the functioning of some set/show debugger commands
|
3
|
+
set debuggertesting on
|
4
|
+
set autoeval off
|
5
|
+
set width 80
|
6
|
+
### *******************************
|
7
|
+
### *** help commands ***
|
8
|
+
### *******************************
|
9
|
+
help foo
|
10
|
+
# FIXME - the below should work
|
11
|
+
# help
|
12
|
+
# help step
|
data/test/help.right
ADDED
data/test/helper.rb
ADDED
@@ -0,0 +1,87 @@
|
|
1
|
+
# Some common routines used in testing.
|
2
|
+
|
3
|
+
require "fileutils"
|
4
|
+
# require "diff/lcs"
|
5
|
+
# require "diff/lcs/hunk"
|
6
|
+
|
7
|
+
module TestHelper
|
8
|
+
|
9
|
+
def run_debugger(testname, args='', outfile=nil, filter=nil)
|
10
|
+
rightfile = File.join(SRC_DIR, "#{testname}.right")
|
11
|
+
|
12
|
+
outfile = File.join(SRC_DIR, "#{testname}.out") unless outfile
|
13
|
+
|
14
|
+
if File.exists?(outfile)
|
15
|
+
FileUtils.rm(outfile)
|
16
|
+
end
|
17
|
+
|
18
|
+
ENV['RDEBUG'] = "#{SRC_DIR}tdebug.rb"
|
19
|
+
cmd = "/bin/sh #{File.join(SRC_DIR, '../runner.sh')} #{args} >#{outfile}"
|
20
|
+
output = `#{cmd}`
|
21
|
+
|
22
|
+
got_lines = File.read(outfile).split(/\n/)
|
23
|
+
correct_lines = File.read(rightfile).split(/\n/)
|
24
|
+
filter.call(got_lines, correct_lines) if filter
|
25
|
+
if cheap_diff(got_lines, correct_lines)
|
26
|
+
FileUtils.rm(outfile)
|
27
|
+
return true
|
28
|
+
end
|
29
|
+
return false
|
30
|
+
end
|
31
|
+
|
32
|
+
def cheap_diff(got_lines, correct_lines)
|
33
|
+
puts got_lines if $DEBUG
|
34
|
+
correct_lines.each_with_index do |line, i|
|
35
|
+
correct_lines[i].chomp!
|
36
|
+
if got_lines[i] != correct_lines[i]
|
37
|
+
puts "difference found at line #{i+1}"
|
38
|
+
puts "got : #{got_lines[i]}"
|
39
|
+
puts "need: #{correct_lines[i]}"
|
40
|
+
return false
|
41
|
+
end
|
42
|
+
end
|
43
|
+
if correct_lines.size != got_lines.size
|
44
|
+
puts("difference in number of lines: " +
|
45
|
+
"#{correct_lines.size} vs. #{got_lines.size}")
|
46
|
+
return false
|
47
|
+
end
|
48
|
+
return true
|
49
|
+
end
|
50
|
+
|
51
|
+
|
52
|
+
# Adapted from the Ruby Cookbook, Section 6.10: Comparing two files.
|
53
|
+
# def diff_as_string(rightfile, checkfile, format=:unified, context_lines=3)
|
54
|
+
# right_data = File.read(rightfile)
|
55
|
+
# check_data = File.read(checkfile)
|
56
|
+
# output = ""
|
57
|
+
# diffs = Diff::LCS.diff(right_data, check_data)
|
58
|
+
# return output if diffs.empty?
|
59
|
+
# oldhunk = hunk = nil
|
60
|
+
# debugger
|
61
|
+
# file_length_difference = 0
|
62
|
+
# diffs.each do |piece|
|
63
|
+
# begin
|
64
|
+
# hunk = Diff::LCS::Hunk.new(right_data, check_data, piece,
|
65
|
+
# context_lines, file_length_difference)
|
66
|
+
# next unless oldhunk
|
67
|
+
#
|
68
|
+
# # Hunks may overlap, which is why we need to be careful when our
|
69
|
+
# # diff includes lines of context. Otherwise, we might print
|
70
|
+
# # redundant lines.
|
71
|
+
# if (context_lines > 0) and hunk.overlaps?(oldhunk)
|
72
|
+
# hunk.unshift(oldhunk)
|
73
|
+
# else
|
74
|
+
# output << oldhunk.diff(format)
|
75
|
+
# end
|
76
|
+
# ensure
|
77
|
+
# oldhunk = hunk
|
78
|
+
# output << "\n"
|
79
|
+
# end
|
80
|
+
# end
|
81
|
+
|
82
|
+
# # Handle the last remaining hunk
|
83
|
+
# output << oldhunk.diff(format) << "\n"
|
84
|
+
# end
|
85
|
+
|
86
|
+
end
|
87
|
+
|
@@ -0,0 +1,45 @@
|
|
1
|
+
class Lousy_inspect
|
2
|
+
attr_accessor :var
|
3
|
+
def inspect # An unhelpful inspect
|
4
|
+
throw "Foo" # Raises an exception
|
5
|
+
end
|
6
|
+
def initialize
|
7
|
+
@var = 'initialized'
|
8
|
+
end
|
9
|
+
end
|
10
|
+
class Lousy_inspect_and_to_s
|
11
|
+
attr_accessor :var
|
12
|
+
def inspect # An unhelpful inspect
|
13
|
+
throw "Foo" # Raises an exception
|
14
|
+
end
|
15
|
+
def to_s # An unhelpful to_s
|
16
|
+
throw "bar" # Raises an exception
|
17
|
+
end
|
18
|
+
def initialize
|
19
|
+
@var = 'initialized' # Something to inspect
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
# Something that will be passed objects with
|
24
|
+
# bad inspect or to_s methods
|
25
|
+
class UnsuspectingClass
|
26
|
+
def initialize(a)
|
27
|
+
@a = a # "info locals" will try to use
|
28
|
+
# inspect or to_s here
|
29
|
+
@b = 5
|
30
|
+
end
|
31
|
+
end
|
32
|
+
def test_Lousy_inspect
|
33
|
+
x = Lousy_inspect.new
|
34
|
+
return x
|
35
|
+
end
|
36
|
+
def test_lousy_inspect_and_to_s
|
37
|
+
x = Lousy_inspect_and_to_s.new
|
38
|
+
return x
|
39
|
+
end
|
40
|
+
x = test_Lousy_inspect
|
41
|
+
y = test_lousy_inspect_and_to_s
|
42
|
+
UnsuspectingClass.new(10)
|
43
|
+
UnsuspectingClass.new(x)
|
44
|
+
UnsuspectingClass.new(y)
|
45
|
+
y = 2
|
data/test/info-var.cmd
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
# ***************************************************
|
2
|
+
# Test handling of info variables when we have
|
3
|
+
# redefined inspect or to_s which give an error.
|
4
|
+
# ***************************************************
|
5
|
+
set debuggertesting on
|
6
|
+
# Go to where we have a bad "inspect" of a local variable
|
7
|
+
continue 34
|
8
|
+
info variables
|
9
|
+
# Go to where we have a bad "inspect" and "to_s" of a local variable
|
10
|
+
continue 38
|
11
|
+
info variables
|
12
|
+
break 29
|
13
|
+
# The first time through, we can do inspect.
|
14
|
+
continue
|
15
|
+
info locals
|
16
|
+
# Now go to where we have a bad "inspect" of an class variable
|
17
|
+
continue
|
18
|
+
info locals
|
19
|
+
info variables
|
20
|
+
# Now go to where we have a bad "inspect" and "to_s" of an class variable
|
21
|
+
continue
|
22
|
+
info locals
|
23
|
+
quit
|
data/test/info-var.right
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
info-var-bug.rb:1
|
2
|
+
class Lousy_inspect
|
3
|
+
# # ***************************************************
|
4
|
+
# # Test handling of info variables when we have
|
5
|
+
# # redefined inspect or to_s which give an error.
|
6
|
+
# # ***************************************************
|
7
|
+
# set debuggertesting on
|
8
|
+
Currently testing the debugger is on.
|
9
|
+
# # Go to where we have a bad "inspect" of a local variable
|
10
|
+
# continue 34
|
11
|
+
info-var-bug.rb:34
|
12
|
+
return x
|
13
|
+
# info variables
|
14
|
+
x = #<Lousy_inspect:0xb784945c>
|
15
|
+
# # Go to where we have a bad "inspect" and "to_s" of a local variable
|
16
|
+
# continue 38
|
17
|
+
info-var-bug.rb:38
|
18
|
+
return x
|
19
|
+
# info variables
|
20
|
+
x = *Error in evaluation*
|
21
|
+
# break 29
|
22
|
+
Breakpoint 1 file info-var-bug.rb, line 29
|
23
|
+
# # The first time through, we can do inspect.
|
24
|
+
# continue
|
25
|
+
Breakpoint 1 at info-var-bug.rb:29
|
26
|
+
info-var-bug.rb:29
|
27
|
+
@b = 5
|
28
|
+
# info locals
|
29
|
+
a = 10
|
30
|
+
# # Now go to where we have a bad "inspect" of an class variable
|
31
|
+
# continue
|
32
|
+
Breakpoint 1 at info-var-bug.rb:29
|
33
|
+
info-var-bug.rb:29
|
34
|
+
@b = 5
|
35
|
+
# info locals
|
36
|
+
a = #<Lousy_inspect:0xb784945c>
|
37
|
+
# info variables
|
38
|
+
a = #<Lousy_inspect:0xb784945c>
|
39
|
+
@a = #<Lousy_inspect:0xb784945c>
|
40
|
+
# # Now go to where we have a bad "inspect" and "to_s" of an class variable
|
41
|
+
# continue
|
42
|
+
Breakpoint 1 at info-var-bug.rb:29
|
43
|
+
info-var-bug.rb:29
|
44
|
+
@b = 5
|
45
|
+
# info locals
|
46
|
+
*Error in evaluation*
|
47
|
+
# quit
|
data/test/info.cmd
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
# ***************************************************
|
2
|
+
# This tests step, next, finish and continue
|
3
|
+
# ***************************************************
|
4
|
+
set debuggertesting on
|
5
|
+
set callstyle last
|
6
|
+
help info
|
7
|
+
info args
|
8
|
+
info line
|
9
|
+
info locals
|
10
|
+
info stack
|
11
|
+
info display
|
12
|
+
quit
|
data/test/info.right
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
gcd.rb:4
|
2
|
+
def gcd(a, b)
|
3
|
+
# # ***************************************************
|
4
|
+
# # This tests step, next, finish and continue
|
5
|
+
# # ***************************************************
|
6
|
+
# set debuggertesting on
|
7
|
+
Currently testing the debugger is on.
|
8
|
+
# set callstyle last
|
9
|
+
Frame call-display style is last.
|
10
|
+
# help info
|
11
|
+
Generic command for showing things about the program being debugged.
|
12
|
+
--
|
13
|
+
List of info subcommands:
|
14
|
+
--
|
15
|
+
info args -- Argument variables of current stack frame
|
16
|
+
info breakpoints -- Status of user-settable breakpoints
|
17
|
+
info display -- Expressions to display when program stops
|
18
|
+
info file -- File names and timestamps of files read in
|
19
|
+
info global_variables -- global variables
|
20
|
+
info instance_variables -- instance variables
|
21
|
+
info line -- Line number and file name of current position in source
|
22
|
+
info locals -- Local variables of the current stack frame
|
23
|
+
info program -- Execution status of the program
|
24
|
+
info stack -- Backtrace of the stack
|
25
|
+
info threads -- IDs of currently known threads
|
26
|
+
info variables -- local and instance variables
|
27
|
+
# info args
|
28
|
+
# info line
|
29
|
+
Line 4 of "./gcd.rb"
|
30
|
+
# info locals
|
31
|
+
# info stack
|
32
|
+
--> #0 at line gcd.rb:4
|
33
|
+
# info display
|
34
|
+
There are no auto-display expressions now.
|
35
|
+
# quit
|
data/test/quit.cmd
ADDED
data/test/quit.right
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
gcd.rb:4
|
2
|
+
def gcd(a, b)
|
3
|
+
# # ***************************************************
|
4
|
+
# # This tests display expressions.
|
5
|
+
# # ***************************************************
|
6
|
+
# set debuggertesting on
|
7
|
+
Currently testing the debugger is on.
|
8
|
+
# c
|
9
|
+
The program has finished and will be restarted.
|
10
|
+
gcd.rb:4
|
11
|
+
def gcd(a, b)
|
12
|
+
# break 18
|
13
|
+
Breakpoint 1 file gcd.rb, line 18
|
14
|
+
# c
|
15
|
+
Breakpoint 1 at gcd.rb:18
|
16
|
+
gcd.rb:18
|
17
|
+
gcd(3,5)
|
18
|
+
# next
|
19
|
+
The program has finished and will be restarted.
|
20
|
+
gcd.rb:4
|
21
|
+
def gcd(a, b)
|
22
|
+
# quit
|
data/test/setshow.cmd
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
# $Id: setshow.cmd 346 2007-11-14 01:39:05Z rockyb $
|
2
|
+
# This tests the functioning of some set/show debugger commands
|
3
|
+
set debuggertesting on
|
4
|
+
### *******************************
|
5
|
+
### *** Set/show commands ***
|
6
|
+
### *******************************
|
7
|
+
########################################
|
8
|
+
### test args and baseneme...
|
9
|
+
########################################
|
10
|
+
set args this is a test
|
11
|
+
show args
|
12
|
+
show basename
|
13
|
+
set basename foo
|
14
|
+
show base
|
15
|
+
set basename off
|
16
|
+
show basename
|
17
|
+
set basename 0
|
18
|
+
show basename
|
19
|
+
set basename 1
|
20
|
+
show basename
|
21
|
+
########################################
|
22
|
+
### test listsize tests...
|
23
|
+
########################################
|
24
|
+
show listsize
|
25
|
+
show listsi
|
26
|
+
set listsize abc
|
27
|
+
set listsize -20
|
28
|
+
########################################
|
29
|
+
### test linetrace...
|
30
|
+
########################################
|
31
|
+
set linetrace on
|
32
|
+
show linetrace
|
33
|
+
set linetrace off
|
34
|
+
show linetrace
|
35
|
+
########################################
|
36
|
+
### show history
|
37
|
+
########################################
|
38
|
+
set history
|
39
|
+
set history size 10
|
40
|
+
show history size
|
41
|
+
set history save off
|
42
|
+
show history save
|
43
|
+
set history save 1
|
44
|
+
show history save
|
data/test/setshow.right
ADDED
@@ -0,0 +1,73 @@
|
|
1
|
+
gcd.rb:4
|
2
|
+
def gcd(a, b)
|
3
|
+
# # $Id: setshow.cmd 346 2007-11-14 01:39:05Z rockyb $
|
4
|
+
# # This tests the functioning of some set/show debugger commands
|
5
|
+
# set debuggertesting on
|
6
|
+
Currently testing the debugger is on.
|
7
|
+
# ### *******************************
|
8
|
+
# ### *** Set/show commands ***
|
9
|
+
# ### *******************************
|
10
|
+
# ########################################
|
11
|
+
# ### test args and baseneme...
|
12
|
+
# ########################################
|
13
|
+
# set args this is a test
|
14
|
+
Argument list to give program being debugged when it is started is "this is a test".
|
15
|
+
# show args
|
16
|
+
Argument list to give program being debugged when it is started is "this is a test".
|
17
|
+
# show basename
|
18
|
+
basename is on.
|
19
|
+
# set basename foo
|
20
|
+
Expecting 'on', 1, 'off', or 0. Got: foo.
|
21
|
+
# show base
|
22
|
+
basename is on.
|
23
|
+
# set basename off
|
24
|
+
basename is off.
|
25
|
+
# show basename
|
26
|
+
basename is off.
|
27
|
+
# set basename 0
|
28
|
+
basename is off.
|
29
|
+
# show basename
|
30
|
+
basename is off.
|
31
|
+
# set basename 1
|
32
|
+
basename is on.
|
33
|
+
# show basename
|
34
|
+
basename is on.
|
35
|
+
# ########################################
|
36
|
+
# ### test listsize tests...
|
37
|
+
# ########################################
|
38
|
+
# show listsize
|
39
|
+
Number of source lines to list by default is 10.
|
40
|
+
# show listsi
|
41
|
+
Number of source lines to list by default is 10.
|
42
|
+
# set listsize abc
|
43
|
+
Set listsize argument 'abc' needs to be a number.
|
44
|
+
# set listsize -20
|
45
|
+
Set listsize argument '-20' needs to at least 1.
|
46
|
+
# ########################################
|
47
|
+
# ### test linetrace...
|
48
|
+
# ########################################
|
49
|
+
# set linetrace on
|
50
|
+
line tracing is on.
|
51
|
+
# show linetrace
|
52
|
+
line tracing is on.
|
53
|
+
# set linetrace off
|
54
|
+
line tracing is off.
|
55
|
+
# show linetrace
|
56
|
+
line tracing is off.
|
57
|
+
# ########################################
|
58
|
+
# ### show history
|
59
|
+
# ########################################
|
60
|
+
# set history
|
61
|
+
Need two parameters for 'set history'; got 0.
|
62
|
+
# set history size 10
|
63
|
+
Debugger history size is 10
|
64
|
+
# show history size
|
65
|
+
Debugger history size is 10
|
66
|
+
# set history save off
|
67
|
+
Saving of history save is off.
|
68
|
+
# show history save
|
69
|
+
Saving of history save is off.
|
70
|
+
# set history save 1
|
71
|
+
Saving of history save is on.
|
72
|
+
# show history save
|
73
|
+
Saving of history save is on.
|