ruby-debug 0.9.3 → 0.10.0

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.
Files changed (64) hide show
  1. data/AUTHORS +1 -0
  2. data/CHANGES +41 -0
  3. data/ChangeLog +0 -0
  4. data/README +27 -13
  5. data/Rakefile +220 -0
  6. data/bin/rdebug +116 -42
  7. data/cli/ruby-debug.rb +33 -3
  8. data/cli/ruby-debug/command.rb +49 -12
  9. data/cli/ruby-debug/commands/breakpoints.rb +47 -64
  10. data/cli/ruby-debug/commands/control.rb +41 -13
  11. data/cli/ruby-debug/commands/display.rb +35 -18
  12. data/cli/ruby-debug/commands/enable.rb +159 -0
  13. data/cli/ruby-debug/commands/eval.rb +78 -4
  14. data/cli/ruby-debug/commands/frame.rb +67 -42
  15. data/cli/ruby-debug/commands/help.rb +21 -17
  16. data/cli/ruby-debug/commands/info.rb +210 -0
  17. data/cli/ruby-debug/commands/irb.rb +9 -1
  18. data/cli/ruby-debug/commands/list.rb +11 -8
  19. data/cli/ruby-debug/commands/method.rb +12 -23
  20. data/cli/ruby-debug/commands/script.rb +14 -9
  21. data/cli/ruby-debug/commands/settings.rb +174 -39
  22. data/cli/ruby-debug/commands/show.rb +193 -0
  23. data/cli/ruby-debug/commands/stepping.rb +15 -10
  24. data/cli/ruby-debug/commands/threads.rb +55 -56
  25. data/cli/ruby-debug/commands/variables.rb +27 -27
  26. data/cli/ruby-debug/helper.rb +134 -0
  27. data/cli/ruby-debug/interface.rb +46 -15
  28. data/cli/ruby-debug/processor.rb +156 -25
  29. data/doc/rdebug.1 +236 -0
  30. data/runner.sh +7 -0
  31. data/test/breakpoints.cmd +43 -0
  32. data/test/breakpoints.right +94 -0
  33. data/test/display.cmd +18 -0
  34. data/test/display.right +37 -0
  35. data/test/frame.cmd +21 -0
  36. data/test/frame.right +45 -0
  37. data/test/gcd.rb +18 -0
  38. data/test/help.cmd +12 -0
  39. data/test/help.right +4 -0
  40. data/test/helper.rb +87 -0
  41. data/test/info-var-bug.rb +45 -0
  42. data/test/info-var.cmd +23 -0
  43. data/test/info-var.right +47 -0
  44. data/test/info.cmd +12 -0
  45. data/test/info.right +35 -0
  46. data/test/quit.cmd +9 -0
  47. data/test/quit.right +22 -0
  48. data/test/setshow.cmd +44 -0
  49. data/test/setshow.right +73 -0
  50. data/test/stepping.cmd +17 -0
  51. data/test/stepping.right +40 -0
  52. data/test/tdebug.rb +196 -0
  53. data/test/test-breakpoints.rb +28 -0
  54. data/test/test-columnize.rb +46 -0
  55. data/test/test-display.rb +26 -0
  56. data/test/test-frame.rb +27 -0
  57. data/test/test-help.rb +44 -0
  58. data/test/test-info-var.rb +33 -0
  59. data/test/test-info.rb +28 -0
  60. data/test/test-quit.rb +28 -0
  61. data/test/test-ruby-debug-base.rb +76 -0
  62. data/test/test-setshow.rb +24 -0
  63. data/test/test-stepping.rb +26 -0
  64. metadata +63 -22
data/doc/rdebug.1 ADDED
@@ -0,0 +1,236 @@
1
+ .\" $Id: rdebug.1 461 2007-12-22 11:18:14Z rockyb $
2
+ .TH rdebug 1
3
+ .SH NAME
4
+ rdebug \- Fast Ruby debugger
5
+ .SH SYNOPSIS
6
+ .B rdebug
7
+ [debugger-options]
8
+ rdebug
9
+ [script-options...]
10
+ .SH "DESCRIPTION"
11
+ This manual page documents briefly the
12
+ .BR rdebug
13
+ command.
14
+ .PP
15
+ .B rdebug
16
+ is a fast implementation of the standard Ruby debugger debug.rb. It
17
+ is implemented by utilizing a Ruby C API hook, allows for remote
18
+ debugging and can be used as the Ruby debugger backend interface for a
19
+ development environment.
20
+ .PP
21
+ The commands generally follow gdb's command set unless there's good
22
+ reason not to.
23
+
24
+ .PP
25
+ rdebug can do four main kinds of things (plus other things in support of
26
+ these) to help you catch bugs in the act:
27
+
28
+ .TP
29
+ \ \ \ \(bu
30
+ Start or restart your Ruby script, specifying arguments that might
31
+ affect its behavior.
32
+
33
+ .TP
34
+ \ \ \ \(bu
35
+ Make your program stop at various points possibly determined by
36
+ specified conditions.
37
+
38
+ .TP
39
+ \ \ \ \(bu
40
+ Examine what has happened when your program has stopped.
41
+
42
+ .TP
43
+ \ \ \ \(bu
44
+ Change things in your program, so you can experiment with correcting the
45
+ effects of one bug and go on to learn about another.
46
+ .PP
47
+
48
+ Here are some of the most frequently-needed commands:
49
+ .TP
50
+ .B break \fR[\|\fIfile\fB:\fIline\fR\fR|\fIclass.method\fR] \fR[if \fIexpr\fR]
51
+ \&
52
+ Set a breakpoint at \c
53
+ .I class.method\c
54
+ \& or at the specified file and line.
55
+ .TP
56
+ .B continue \fR[\fIline\fR]
57
+ Continue running your program (after stopping, e.g. at a
58
+ breakpoint). If a line is given a one-time breakpoint is set there.
59
+ .TP
60
+ .B delete \fR[\fIbreakpoint-numbers\fR]
61
+ \&
62
+ Delete breakpoints by number. If no number is given delete all breakpoints.
63
+ .TP
64
+ .B down \fR[\|\fIcount\fR\|]
65
+ Move down one block frame. If count is given move up that many frames. A negative number
66
+ goes the other direction and is like the up command
67
+ .TP
68
+ .B finish
69
+ Run until the completion of the current function or method.
70
+ .TP
71
+ .BI frame " frame-number"
72
+ Set the stack frame to \fIframe-number\fR for purposes of examinine local variables. For positioning relative to the current frame, use
73
+ .B up
74
+ or
75
+ .B down. A negative number starts counting from the other end.
76
+ .TP
77
+ .B help \fR[\|\fIname\fR\|]
78
+ Show information about rdebug command \c
79
+ .I name\c
80
+ \&, or general information
81
+ about using rdebug.
82
+ .TP
83
+ .B info \fR[\|\fIname\fR\|]
84
+ Get the various information usually about the debugged program.
85
+ .TP
86
+ .B irb \fIcommand\fR
87
+ Run an interactive ruby shell (irb) using the current environment.
88
+ .TP
89
+ .B list \fR[\|\fIfile\fB:\fIline\fR|\fIfunction]
90
+ type the text of the program in the vicinity of where it is presently stopped
91
+ or at the specified function or file and line.
92
+ .TP
93
+ .B next \fR[\|\fIcount\fR\|]
94
+ Execute next program line(s) (after stopping); step \c
95
+ .I over\c
96
+ \& any
97
+ function calls in the line.
98
+ .TP
99
+ .BI pp " expr"\c
100
+ \&
101
+ Pretty print the value of an expression.
102
+ .TP
103
+ .BI print " expr"\c
104
+ \&
105
+ Display the value of an expression.
106
+ .TP
107
+ .BI ps " expr"\c
108
+ \&
109
+ Print an array as a columized sorted list.
110
+ .TP
111
+ .B quit
112
+ Exit from the debugger.
113
+ .TP
114
+ .B run \fR[\|\fIarglist\fR\|]
115
+ (Re)start your program (with \c
116
+ .I arglist\c
117
+ \&, if specified). If you want the debugger to get reloaded, use
118
+ .B restart
119
+ instead.
120
+ .TP
121
+ .B set
122
+ Modify parts of the debugger environment.
123
+ .TP
124
+ .B show
125
+ See the debugger environment settings
126
+ .TP
127
+ .BI source " filename"\c
128
+ \&
129
+ Read and execute the lines in file \fIfilename\fR as a series of debugger
130
+ commands.
131
+ .TP
132
+ .B step \fR[\|\fIcount\fR\|]
133
+ Execute next program line(s) (after stopping); step \c
134
+ .I into\c
135
+ \& any
136
+ function calls in the line.
137
+ .TP
138
+ .B up \fR[\|\fIcount\fR\|]
139
+ Move up one block frame. If count is given move up that many frames. A negative number
140
+ goes the other direction and is like the down command
141
+ .TP
142
+ .B where \fR[\|\fIcount\fR\|]
143
+ Display all or \fIcount\fR items of the program stack.
144
+ .PP
145
+ For full details on rdebug, see \c
146
+ http://rubyforge.org/projects/ruby-debug/
147
+ .SH OPTIONS
148
+ .PP
149
+ .TP 10
150
+ .TP
151
+ .B \-A | \-\-annotate LEVEL
152
+ Set gdb-style annotation to LEVEL, a number. Additional information is output
153
+ automatically when program state is changed. This can be used by
154
+ front-ends such as GNU Emacs to post this updated information without
155
+ having to poll for it.
156
+ .TP
157
+ .B \-\-client
158
+ Connect to a remote debugger. Used with another rdebug invocation using \-\-server.
159
+ See also \-\-host and \-\-cport options
160
+ .TP
161
+ .B \-\-cport=PORT
162
+ Port used for control commands.
163
+ .TP
164
+ .B \-d | \-\-debug
165
+ Set $DEBUG true.
166
+ .TP
167
+ .B \-\-emacs
168
+ Activates GNU Emacs mode. Debugger prompts are prefaced with two octal
169
+ 032 characters.
170
+ .TP
171
+ .B \-h | \-\-host=HOST
172
+ Host name used for remote debugging.
173
+ .TP
174
+ .B \-I | \-\-include PATH
175
+ Add PATH to $LOAD_PATH
176
+ .TP
177
+ .B \-m | \-\-post-mortem
178
+ Activate post-mortem mode.
179
+ .TP
180
+ .B \-\-no-control
181
+ Do not automatically start control thread.
182
+ .TP
183
+ .B \-n | \-\-no\-stop
184
+ Do not stop when script is loaded.
185
+ .TP
186
+ .B \-p | \-\-port=PORT
187
+ Host name used for remote debugging.
188
+ .TP
189
+ .B \-r | \-\-require SCRIPT
190
+ Require the library, before executing your script.
191
+ .TP
192
+ .B \-\-script FILE
193
+ Name of the script file to run.
194
+ .TP
195
+ .B \-x | \-\-trace
196
+ Show lines before executing them.
197
+ .TP
198
+ .B \-\-no\-quit
199
+ Do not quit when script terminates. Instead rerun the program.
200
+ .TP
201
+ .B \-\-version
202
+ Show the version number and exit.
203
+ .TP
204
+ .B \-\-verbose
205
+ Turn on verbose mode.
206
+ .TP
207
+ .B \-\-v
208
+ Print the version number, then turn on verbose mode if a script name
209
+ is given. If no script name is given just exit after printing the
210
+ version number.
211
+ .TP
212
+ .B \-\-nx
213
+ Don't execute commands found in any initialization files, e.g. .rdebugrc.
214
+ .TP
215
+ .B \-\-keep-frame-binding
216
+ Keep frame bindings.
217
+ .TP
218
+ .B \-\-script=FILE
219
+ Name of the script file to run
220
+ .B \-s | \-\-server
221
+ Listen for remote connections. Another rdebug session accesses using the \-\-client option.
222
+ See also the \-\-host, \-\-port and
223
+ \-\-cport options
224
+ .TP
225
+ .B \-w | \-\-wait
226
+ Wait for a client connection, implies -s option.
227
+ .TP
228
+ .B \-\-help
229
+ Show invocation help and exit.
230
+ .PD
231
+ .SH "SEE ALSO"
232
+ .Sp
233
+ http://rubyforge.org/projects/ruby-debug/
234
+ .SH AUTHOR
235
+ rdebug was written by Kent Siblev. This manual page was written by
236
+ Rocky Bernstein <rocky@gnu.org>
data/runner.sh ADDED
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env bash
2
+
3
+ ruby=${RUBY:-ruby}
4
+ dir=`dirname $0`
5
+ rdebug=${RDEBUG:-${dir}/bin/rdebug}
6
+ $ruby -I${dir}/ext:${dir}/lib:${dir}/cli -- $rdebug $*
7
+ exit $?
@@ -0,0 +1,43 @@
1
+ # ********************************************************
2
+ # This tests step, next, finish, continue, disable and
3
+ # enable.
4
+ # FIXME: break out enable/disable
5
+ # ********************************************************
6
+ set debuggertesting on
7
+ set callstyle last
8
+ set autoeval off
9
+ break 6
10
+ break 10
11
+ continue
12
+ where
13
+ break Foo.bar
14
+ break Object.gcd
15
+ info break
16
+ continue
17
+ where
18
+ info program
19
+ c 10
20
+ info break
21
+ break foo
22
+ info break
23
+ disable 1
24
+ info break
25
+ enable breakpoint 1
26
+ enable br 10
27
+ delete 1
28
+ # We should see breakpoint 2 but not 1
29
+ info break
30
+ # We should still be able to access 2
31
+ disable 2
32
+ enable
33
+ enable foo
34
+ disable bar
35
+ disable
36
+ # We should be able to delete 2
37
+ delete 2 3
38
+ info break
39
+ # Should get a message about having no breakpoints.
40
+ disable 1
41
+ enable 1
42
+ # finish
43
+ quit
@@ -0,0 +1,94 @@
1
+ gcd.rb:4
2
+ def gcd(a, b)
3
+ # # ********************************************************
4
+ # # This tests step, next, finish, continue, disable and
5
+ # # enable.
6
+ # # FIXME: break out enable/disable
7
+ # # ********************************************************
8
+ # set debuggertesting on
9
+ Currently testing the debugger is on.
10
+ # set callstyle last
11
+ Frame call-display style is last.
12
+ # set autoeval off
13
+ autoeval is off.
14
+ # break 6
15
+ Breakpoint 1 file gcd.rb, line 6
16
+ # break 10
17
+ Breakpoint 2 file gcd.rb, line 10
18
+ # continue
19
+ Breakpoint 1 at gcd.rb:6
20
+ gcd.rb:6
21
+ if a > b
22
+ # where
23
+ --> #0 Object.gcd(a#Fixnum, b#Fixnum) at line gcd.rb:6
24
+ #1 at line gcd.rb:18
25
+ # break Foo.bar
26
+ Unknown class Foo.
27
+ # break Object.gcd
28
+ Breakpoint 3 at Object::gcd
29
+ # info break
30
+ Num Enb What
31
+ 1 y at gcd.rb:6
32
+ 2 y at gcd.rb:10
33
+ 3 y at Object:gcd
34
+ # continue
35
+ Breakpoint 2 at gcd.rb:10
36
+ gcd.rb:10
37
+ return nil if a <= 0
38
+ # where
39
+ --> #0 Object.gcd(a#Fixnum, b#Fixnum) at line gcd.rb:10
40
+ #1 at line gcd.rb:18
41
+ # info program
42
+ Program stopped. It stopped at a breakpoint.
43
+ # c 10
44
+ Breakpoint 3 at Object:gcd
45
+ gcd.rb:4
46
+ def gcd(a, b)
47
+ # info break
48
+ Num Enb What
49
+ 1 y at gcd.rb:6
50
+ 2 y at gcd.rb:10
51
+ 3 y at Object:gcd
52
+ # break foo
53
+ Unknown command
54
+ # info break
55
+ Num Enb What
56
+ 1 y at gcd.rb:6
57
+ 2 y at gcd.rb:10
58
+ 3 y at Object:gcd
59
+ # disable 1
60
+ # info break
61
+ Num Enb What
62
+ 1 n at gcd.rb:6
63
+ 2 y at gcd.rb:10
64
+ 3 y at Object:gcd
65
+ # enable breakpoint 1
66
+ # enable br 10
67
+ Enable breakpoints argument '10' needs to at most 3.
68
+ # delete 1
69
+ # # We should see breakpoint 2 but not 1
70
+ # info break
71
+ Num Enb What
72
+ 2 y at gcd.rb:10
73
+ 3 y at Object:gcd
74
+ # # We should still be able to access 2
75
+ # disable 2
76
+ # enable
77
+ "enable" must be followed "display", "breakpoints" or breakpoint numbers.
78
+ # enable foo
79
+ Enable breakpoints argument 'foo' needs to be a number.
80
+ # disable bar
81
+ Disable breakpoints argument 'bar' needs to be a number.
82
+ # disable
83
+ "disable" must be followed "display", "breakpoints" or breakpoint numbers.
84
+ # # We should be able to delete 2
85
+ # delete 2 3
86
+ # info break
87
+ No breakpoints.
88
+ # # Should get a message about having no breakpoints.
89
+ # disable 1
90
+ No breakpoints have been set.
91
+ # enable 1
92
+ No breakpoints have been set.
93
+ # # finish
94
+ # quit
data/test/display.cmd ADDED
@@ -0,0 +1,18 @@
1
+ # ***************************************************
2
+ # This tests display expressions.
3
+ # ***************************************************
4
+ set debuggertesting on
5
+ b 6
6
+ c
7
+ display a
8
+ display b
9
+ disable display b
10
+ disable display 1
11
+ c
12
+ enable display b
13
+ enable display 1
14
+ undisplay a
15
+ undisplay 2
16
+ c
17
+ q
18
+
@@ -0,0 +1,37 @@
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
+ # b 6
9
+ Breakpoint 1 file gcd.rb, line 6
10
+ # c
11
+ Breakpoint 1 at gcd.rb:6
12
+ gcd.rb:6
13
+ if a > b
14
+ # display a
15
+ 1: a = 3
16
+ # display b
17
+ 2: b = 5
18
+ # disable display b
19
+ Disable display argument 'b' needs to be a number.
20
+ # disable display 1
21
+ # c
22
+ Breakpoint 1 at gcd.rb:6
23
+ 2: b = 3
24
+ gcd.rb:6
25
+ if a > b
26
+ # enable display b
27
+ Enable display argument 'b' needs to be a number.
28
+ # enable display 1
29
+ # undisplay a
30
+ Undisplay argument 'a' needs to be a number.
31
+ # undisplay 2
32
+ # c
33
+ Breakpoint 1 at gcd.rb:6
34
+ 1: a = 1
35
+ gcd.rb:6
36
+ if a > b
37
+ # q
data/test/frame.cmd ADDED
@@ -0,0 +1,21 @@
1
+ # ***************************************************
2
+ # This tests step, next, finish and continue
3
+ # ***************************************************
4
+ set debuggertesting on
5
+ set callstyle last
6
+ continue 6
7
+ where
8
+ up
9
+ where
10
+ down
11
+ where
12
+ frame 0
13
+ where
14
+ frame -1
15
+ where
16
+ up 2
17
+ where
18
+ down 2
19
+ where
20
+ # finish
21
+ quit