needy_debugger 1.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (187) hide show
  1. data/.gitignore +14 -0
  2. data/.travis.yml +8 -0
  3. data/AUTHORS +10 -0
  4. data/CHANGELOG.md +68 -0
  5. data/CONTRIBUTING.md +1 -0
  6. data/Gemfile +3 -0
  7. data/LICENSE +23 -0
  8. data/OLDER_CHANGELOG +334 -0
  9. data/OLD_CHANGELOG +5655 -0
  10. data/OLD_README +122 -0
  11. data/README.md +141 -0
  12. data/Rakefile +78 -0
  13. data/bin/rdebug +397 -0
  14. data/doc/.cvsignore +42 -0
  15. data/doc/Makefile.am +63 -0
  16. data/doc/emacs-notes.txt +38 -0
  17. data/doc/hanoi.rb +35 -0
  18. data/doc/primes.rb +28 -0
  19. data/doc/rdebug-emacs.texi +1030 -0
  20. data/doc/ruby-debug.texi +3791 -0
  21. data/doc/test-tri2.rb +18 -0
  22. data/doc/tri3.rb +8 -0
  23. data/doc/triangle.rb +12 -0
  24. data/emacs/Makefile.am +130 -0
  25. data/emacs/rdebug-annotate.el +385 -0
  26. data/emacs/rdebug-breaks.el +407 -0
  27. data/emacs/rdebug-cmd.el +92 -0
  28. data/emacs/rdebug-core.el +502 -0
  29. data/emacs/rdebug-dbg.el +62 -0
  30. data/emacs/rdebug-error.el +79 -0
  31. data/emacs/rdebug-fns.el +111 -0
  32. data/emacs/rdebug-frames.el +230 -0
  33. data/emacs/rdebug-gud.el +242 -0
  34. data/emacs/rdebug-help.el +104 -0
  35. data/emacs/rdebug-info.el +83 -0
  36. data/emacs/rdebug-layouts.el +180 -0
  37. data/emacs/rdebug-locring.el +118 -0
  38. data/emacs/rdebug-output.el +106 -0
  39. data/emacs/rdebug-regexp.el +118 -0
  40. data/emacs/rdebug-secondary.el +260 -0
  41. data/emacs/rdebug-shortkey.el +175 -0
  42. data/emacs/rdebug-source.el +568 -0
  43. data/emacs/rdebug-track.el +392 -0
  44. data/emacs/rdebug-varbuf.el +150 -0
  45. data/emacs/rdebug-vars.el +125 -0
  46. data/emacs/rdebug-watch.el +132 -0
  47. data/emacs/rdebug.el +326 -0
  48. data/emacs/test/elk-test.el +242 -0
  49. data/emacs/test/test-annotate.el +103 -0
  50. data/emacs/test/test-cmd.el +116 -0
  51. data/emacs/test/test-core.el +104 -0
  52. data/emacs/test/test-fns.el +65 -0
  53. data/emacs/test/test-frames.el +62 -0
  54. data/emacs/test/test-gud.el +35 -0
  55. data/emacs/test/test-indent.el +58 -0
  56. data/emacs/test/test-regexp.el +144 -0
  57. data/emacs/test/test-shortkey.el +61 -0
  58. data/ext/ruby_debug/192/breakpoint.c +586 -0
  59. data/ext/ruby_debug/192/ruby_debug.c +2645 -0
  60. data/ext/ruby_debug/192/ruby_debug.h +148 -0
  61. data/ext/ruby_debug/193/breakpoint.c +586 -0
  62. data/ext/ruby_debug/193/ruby_debug.c +2626 -0
  63. data/ext/ruby_debug/193/ruby_debug.h +148 -0
  64. data/ext/ruby_debug/200/breakpoint.c +586 -0
  65. data/ext/ruby_debug/200/ruby_debug.c +2692 -0
  66. data/ext/ruby_debug/200/ruby_debug.h +148 -0
  67. data/ext/ruby_debug/extconf.rb +94 -0
  68. data/lib/debugger.rb +5 -0
  69. data/lib/debugger/version.rb +5 -0
  70. data/lib/ruby-debug-base.rb +305 -0
  71. data/lib/ruby-debug.rb +177 -0
  72. data/lib/ruby-debug/command.rb +227 -0
  73. data/lib/ruby-debug/commands/breakpoints.rb +153 -0
  74. data/lib/ruby-debug/commands/catchpoint.rb +55 -0
  75. data/lib/ruby-debug/commands/condition.rb +49 -0
  76. data/lib/ruby-debug/commands/continue.rb +38 -0
  77. data/lib/ruby-debug/commands/control.rb +107 -0
  78. data/lib/ruby-debug/commands/display.rb +120 -0
  79. data/lib/ruby-debug/commands/edit.rb +48 -0
  80. data/lib/ruby-debug/commands/enable.rb +202 -0
  81. data/lib/ruby-debug/commands/eval.rb +176 -0
  82. data/lib/ruby-debug/commands/finish.rb +42 -0
  83. data/lib/ruby-debug/commands/frame.rb +301 -0
  84. data/lib/ruby-debug/commands/help.rb +56 -0
  85. data/lib/ruby-debug/commands/info.rb +467 -0
  86. data/lib/ruby-debug/commands/irb.rb +123 -0
  87. data/lib/ruby-debug/commands/jump.rb +66 -0
  88. data/lib/ruby-debug/commands/kill.rb +51 -0
  89. data/lib/ruby-debug/commands/list.rb +94 -0
  90. data/lib/ruby-debug/commands/method.rb +84 -0
  91. data/lib/ruby-debug/commands/quit.rb +50 -0
  92. data/lib/ruby-debug/commands/reload.rb +40 -0
  93. data/lib/ruby-debug/commands/save.rb +90 -0
  94. data/lib/ruby-debug/commands/set.rb +223 -0
  95. data/lib/ruby-debug/commands/show.rb +247 -0
  96. data/lib/ruby-debug/commands/skip.rb +35 -0
  97. data/lib/ruby-debug/commands/source.rb +36 -0
  98. data/lib/ruby-debug/commands/stepping.rb +81 -0
  99. data/lib/ruby-debug/commands/threads.rb +189 -0
  100. data/lib/ruby-debug/commands/tmate.rb +36 -0
  101. data/lib/ruby-debug/commands/trace.rb +57 -0
  102. data/lib/ruby-debug/commands/variables.rb +199 -0
  103. data/lib/ruby-debug/debugger.rb +5 -0
  104. data/lib/ruby-debug/helper.rb +69 -0
  105. data/lib/ruby-debug/interface.rb +232 -0
  106. data/lib/ruby-debug/processor.rb +474 -0
  107. data/man/rdebug.1 +241 -0
  108. data/needy_debugger.gemspec +31 -0
  109. data/old_scripts/Makefile.am +14 -0
  110. data/old_scripts/README.md +2 -0
  111. data/old_scripts/autogen.sh +4 -0
  112. data/old_scripts/configure.ac +12 -0
  113. data/old_scripts/rdbg.rb +33 -0
  114. data/old_scripts/runner.sh +7 -0
  115. data/old_scripts/svn2cl_usermap +3 -0
  116. data/test/.cvsignore +1 -0
  117. data/test/breakpoints_test.rb +365 -0
  118. data/test/conditions_test.rb +76 -0
  119. data/test/continue_test.rb +28 -0
  120. data/test/display_test.rb +141 -0
  121. data/test/edit_test.rb +55 -0
  122. data/test/eval_test.rb +92 -0
  123. data/test/examples/breakpoint1.rb +15 -0
  124. data/test/examples/breakpoint2.rb +7 -0
  125. data/test/examples/conditions.rb +4 -0
  126. data/test/examples/continue.rb +4 -0
  127. data/test/examples/display.rb +5 -0
  128. data/test/examples/edit.rb +3 -0
  129. data/test/examples/edit2.rb +3 -0
  130. data/test/examples/eval.rb +4 -0
  131. data/test/examples/finish.rb +20 -0
  132. data/test/examples/frame.rb +31 -0
  133. data/test/examples/help.rb +2 -0
  134. data/test/examples/info.rb +48 -0
  135. data/test/examples/info2.rb +3 -0
  136. data/test/examples/irb.rb +6 -0
  137. data/test/examples/jump.rb +14 -0
  138. data/test/examples/kill.rb +2 -0
  139. data/test/examples/list.rb +12 -0
  140. data/test/examples/method.rb +15 -0
  141. data/test/examples/post_mortem.rb +19 -0
  142. data/test/examples/quit.rb +2 -0
  143. data/test/examples/reload.rb +6 -0
  144. data/test/examples/restart.rb +6 -0
  145. data/test/examples/save.rb +3 -0
  146. data/test/examples/set.rb +3 -0
  147. data/test/examples/set_annotate.rb +12 -0
  148. data/test/examples/settings.rb +1 -0
  149. data/test/examples/show.rb +2 -0
  150. data/test/examples/source.rb +3 -0
  151. data/test/examples/stepping.rb +21 -0
  152. data/test/examples/thread.rb +32 -0
  153. data/test/examples/tmate.rb +10 -0
  154. data/test/examples/trace.rb +7 -0
  155. data/test/examples/trace_threads.rb +20 -0
  156. data/test/examples/variables.rb +26 -0
  157. data/test/finish_test.rb +48 -0
  158. data/test/frame_test.rb +140 -0
  159. data/test/help_test.rb +50 -0
  160. data/test/info_test.rb +325 -0
  161. data/test/irb_test.rb +81 -0
  162. data/test/jump_test.rb +70 -0
  163. data/test/kill_test.rb +47 -0
  164. data/test/list_test.rb +145 -0
  165. data/test/method_test.rb +70 -0
  166. data/test/post_mortem_test.rb +25 -0
  167. data/test/quit_test.rb +55 -0
  168. data/test/reload_test.rb +43 -0
  169. data/test/restart_test.rb +143 -0
  170. data/test/save_test.rb +92 -0
  171. data/test/set_test.rb +177 -0
  172. data/test/show_test.rb +292 -0
  173. data/test/source_test.rb +44 -0
  174. data/test/stepping_test.rb +118 -0
  175. data/test/support/breakpoint.rb +12 -0
  176. data/test/support/context.rb +14 -0
  177. data/test/support/matchers.rb +67 -0
  178. data/test/support/mocha_extensions.rb +71 -0
  179. data/test/support/processor.rb +7 -0
  180. data/test/support/test_dsl.rb +205 -0
  181. data/test/support/test_interface.rb +66 -0
  182. data/test/test_helper.rb +8 -0
  183. data/test/thread_test.rb +122 -0
  184. data/test/tmate_test.rb +43 -0
  185. data/test/trace_test.rb +154 -0
  186. data/test/variables_test.rb +114 -0
  187. metadata +352 -0
@@ -0,0 +1,241 @@
1
+ .\" $Id: rdebug.1 516 2007-12-31 05:55:24Z 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
+ https://github.com/cldwalker/debugger
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 full GNU Emacs mode. Is the equivalent of setting the
169
+ options \-\-emacs\-basic, \-\-annotate=3, \-\-no-stop, \-\-no\-control
170
+ and \-\-post\-mortem.
171
+ .TP
172
+ .B \-\-emacs-basic
173
+ Activates GNU Emacs mode. Debugger prompts are prefaced with two octal
174
+ 032 characters.
175
+ .TP
176
+ .B \-h | \-\-host=HOST
177
+ Host name used for remote debugging.
178
+ .TP
179
+ .B \-I | \-\-include PATH
180
+ Add PATH to $LOAD_PATH
181
+ .TP
182
+ .B \-m | \-\-post-mortem
183
+ Activate post-mortem mode.
184
+ .TP
185
+ .B \-\-no-control
186
+ Do not automatically start control thread.
187
+ .TP
188
+ .B \-\-no\-stop
189
+ Do not stop when script is loaded.
190
+ .TP
191
+ .B \-p | \-\-port=PORT
192
+ Host name used for remote debugging.
193
+ .TP
194
+ .B \-r | \-\-require SCRIPT
195
+ Require the library, before executing your script.
196
+ .TP
197
+ .B \-\-script FILE
198
+ Name of the script file to run.
199
+ .TP
200
+ .B \-x | \-\-trace
201
+ Show lines before executing them.
202
+ .TP
203
+ .B \-\-no\-quit
204
+ Do not quit when script terminates. Instead rerun the program.
205
+ .TP
206
+ .B \-\-version
207
+ Show the version number and exit.
208
+ .TP
209
+ .B \-\-verbose
210
+ Turn on verbose mode.
211
+ .TP
212
+ .B \-\-v
213
+ Print the version number, then turn on verbose mode if a script name
214
+ is given. If no script name is given just exit after printing the
215
+ version number.
216
+ .TP
217
+ .B \-\-nx
218
+ Don't execute commands found in any initialization files, e.g. .rdebugrc.
219
+ .TP
220
+ .B \-\-keep-frame-binding
221
+ Keep frame bindings.
222
+ .TP
223
+ .B \-\-script=FILE
224
+ Name of the script file to run
225
+ .B \-s | \-\-server
226
+ Listen for remote connections. Another rdebug session accesses using the \-\-client option.
227
+ See also the \-\-host, \-\-port and
228
+ \-\-cport options
229
+ .TP
230
+ .B \-w | \-\-wait
231
+ Wait for a client connection, implies -s option.
232
+ .TP
233
+ .B \-\-help
234
+ Show invocation help and exit.
235
+ .PD
236
+ .SH "SEE ALSO"
237
+ .Sp
238
+ https://github.com/cldwalker/debugger
239
+ .SH AUTHOR
240
+ rdebug was written by Kent Siblev. This manual page was written by
241
+ Rocky Bernstein <rocky@gnu.org>
@@ -0,0 +1,31 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require 'rubygems' unless defined? Gem
3
+ require File.dirname(__FILE__) + "/lib/debugger/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = %q{needy_debugger}
7
+ s.version = Debugger::VERSION
8
+ s.authors = ["Kent Sibilev", "Mark Moseley", "Gabriel Horner", "Mark Burns"]
9
+ s.email = "markthedeveloper@gmail.com"
10
+ s.homepage = "http://github.com/markburns/needy_debugger"
11
+ s.summary = %q{Fast Ruby debugger - base + cli}
12
+ s.description = %q{needy_debugger is a less needy (or more if needs be), fast
13
+ implementation of the standard Ruby debugger debug.rb.
14
+ It is implemented by utilizing a new Ruby C API hook. The core component
15
+ provides support that front-ends can build on. It provides breakpoint
16
+ handling, bindings for stack frames among other things.
17
+ }
18
+ s.required_rubygems_version = ">= 1.3.6"
19
+ s.extra_rdoc_files = [ "README.md" ]
20
+ s.files = `git ls-files`.split("\n")
21
+ s.extensions << "ext/ruby_debug/extconf.rb"
22
+ s.executables = ["rdebug"]
23
+ s.add_dependency "columnize", ">= 0.3.1"
24
+ s.add_dependency "debugger-ruby_core_source", '~> 1.2.0'
25
+ s.add_dependency "debugger-linecache", '~> 1.1.1'
26
+ s.add_development_dependency 'rake', '~> 0.9.2.2'
27
+ s.add_development_dependency 'rake-compiler', '~> 0.8.0'
28
+ s.add_development_dependency 'minitest', '~> 2.12.1'
29
+ s.add_development_dependency 'mocha', '~> 0.13.0'
30
+ s.license = "BSD"
31
+ end
@@ -0,0 +1,14 @@
1
+ SUBDIRS = doc emacs
2
+ PHONY = test ChangeLogs
3
+ test: check
4
+ ChangeLogs: ChangeLog doc/ChangeLog emacs/ChangeLog lib/ChangeLog
5
+ ChangeLog:
6
+ svn2cl --authors=svn2cl_usermap svn://rubyforge.org/var/svn/ruby-debug/trunk \
7
+ cli test bin AUTHORS CHANGES LICENSE README runner.sh -o ChangeLog
8
+ lib/ChangeLog:
9
+ svn2cl --authors=svn2cl_usermap svn://rubyforge.org/var/svn/ruby-debug/trunk \
10
+ lib ext -o lib/ChangeLog
11
+ doc/ChangeLog:
12
+ svn2cl --authors=svn2cl_usermap svn://rubyforge.org/var/svn/ruby-debug/trunk/doc -o doc/ChangeLog
13
+ emacs/ChangeLog:
14
+ svn2cl --authors=svn2cl_usermap svn://rubyforge.org/var/svn/ruby-debug/trunk/emacs -o emacs/ChangeLog
@@ -0,0 +1,2 @@
1
+ ## Description
2
+ These are old scripts that came with ruby-debug19. Don't have a need for them now but maybe later...
@@ -0,0 +1,4 @@
1
+ #!/bin/sh
2
+ # Things to do after doing a clean SVN update to add the proper files.
3
+ ln -vfs CHANGES NEWS
4
+ autoreconf -i -s
@@ -0,0 +1,12 @@
1
+ AC_INIT(ruby-debug-extra, 0.10.4vc,)
2
+ AC_CONFIG_SRCDIR(doc/ruby-debug.texi)
3
+ AM_INIT_AUTOMAKE
4
+
5
+ ##
6
+ ## Find out where to install the debugger emacs lisp files
7
+ ##
8
+ AM_PATH_LISPDIR
9
+ AM_CONDITIONAL(INSTALL_EMACS_LISP, test "x$lispdir" != "x")
10
+
11
+ AC_CONFIG_FILES([doc/Makefile emacs/Makefile Makefile])
12
+ AC_OUTPUT
@@ -0,0 +1,33 @@
1
+ #!/usr/bin/env ruby
2
+ #!/usr/bin/env ruby
3
+ # $Id: rdbg.rb 756 2008-03-13 02:15:04Z rockyb $
4
+
5
+ # Use this to run rdebug without installing it. We assume that the
6
+ # library directories are stored at the same level the directory
7
+ # this program.
8
+ module RDebugRunner
9
+ def runner(stdout=nil)
10
+
11
+ # Add libraries to load path.
12
+ dirname=File.dirname(__FILE__)
13
+ libs = %w(ext lib cli)
14
+ libs.each { |lib| $:.unshift File.join(dirname, lib) }
15
+
16
+ rdebug=ENV['RDEBUG'] || File.join(dirname, 'bin', 'rdebug')
17
+ if stdout
18
+ old_stdout = $stdout
19
+ $stdout.reopen(stdout)
20
+ else
21
+ old_stdout = nil
22
+ end
23
+ load(rdebug, true)
24
+ $stdout.reopen(old_stdout) if old_stdout
25
+
26
+ # Remove those libraries we just added.
27
+ 1.upto(libs.size) {$:.shift}
28
+ end
29
+ module_function :runner
30
+ end
31
+ if __FILE__ == $0
32
+ RDebugRunner.runner
33
+ end
@@ -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,3 @@
1
+ andersl:Anders Lindgren
2
+ kent:Kent Sibilev
3
+ rockyb:Rocky Bernstein
@@ -0,0 +1 @@
1
+ config.private.yaml
@@ -0,0 +1,365 @@
1
+ require_relative 'test_helper'
2
+
3
+ describe "Breakpoints" do
4
+ include TestDsl
5
+
6
+ describe "setting breakpoint in the current file" do
7
+ before { enter 'break 10' }
8
+ subject { breakpoint }
9
+
10
+ def check_subject(field, value)
11
+ debug_file("breakpoint1") { subject.send(field).must_equal value }
12
+ end
13
+
14
+ it("must have correct pos") { check_subject(:pos, 10) }
15
+ it("must have correct source") { check_subject(:source, fullpath("breakpoint1")) }
16
+ it("must have correct expression") { check_subject(:expr, nil) }
17
+ it("must have correct hit count") { check_subject(:hit_count, 0) }
18
+ it("must have correct hit value") { check_subject(:hit_value, 0) }
19
+ it("must be enabled") { check_subject(:enabled?, true) }
20
+ it("must return right response") do
21
+ id = nil
22
+ debug_file('breakpoint1') { id = subject.id }
23
+ check_output_includes "Breakpoint #{id} file #{fullpath('breakpoint1')}, line 10"
24
+ end
25
+ end
26
+
27
+
28
+ describe "using shortcut for the command" do
29
+ before { enter 'b 10' }
30
+ it "must set a breakpoint" do
31
+ debug_file("breakpoint1") { Debugger.breakpoints.size.must_equal 1 }
32
+ end
33
+ end
34
+
35
+
36
+ describe "setting breakpoint to unexisted line" do
37
+ before { enter 'break 100' }
38
+
39
+ it "must not create a breakpoint" do
40
+ debug_file("breakpoint1") { Debugger.breakpoints.must_be_empty }
41
+ end
42
+
43
+ it "must show an error" do
44
+ debug_file("breakpoint1")
45
+ check_output_includes "There are only #{LineCache.size(fullpath('breakpoint1'))} lines in file \"breakpoint1.rb\".", interface.error_queue
46
+ end
47
+ end
48
+
49
+
50
+ describe "setting breakpoint to incorrect line" do
51
+ before { enter 'break 8' }
52
+
53
+ it "must not create a breakpoint" do
54
+ debug_file("breakpoint1") { Debugger.breakpoints.must_be_empty }
55
+ end
56
+
57
+ it "must show an error" do
58
+ debug_file("breakpoint1")
59
+ check_output_includes 'Line 8 is not a stopping point in file "breakpoint1.rb".', interface.error_queue
60
+ end
61
+ end
62
+
63
+
64
+ describe "stopping at breakpoint" do
65
+ it "must stop at the correct line" do
66
+ enter 'break 14', 'cont'
67
+ debug_file("breakpoint1") { state.line.must_equal 14 }
68
+ end
69
+
70
+ it "must stop at the correct file" do
71
+ enter 'break 14', 'cont'
72
+ debug_file("breakpoint1") { state.file.must_equal fullpath("breakpoint1") }
73
+ end
74
+
75
+ describe "show a message" do
76
+ temporary_change_hash_value(Debugger::Command.settings, :basename, false)
77
+
78
+ it "must show a message with full filename" do
79
+ enter 'break 14', 'cont'
80
+ debug_file("breakpoint1")
81
+ check_output_includes "Breakpoint 1 at #{fullpath('breakpoint1')}:14"
82
+ end
83
+
84
+ it "must show a message with basename" do
85
+ enter 'set basename', 'break 14', 'cont'
86
+ debug_file("breakpoint1")
87
+ check_output_includes "Breakpoint 1 at breakpoint1.rb:14"
88
+ end
89
+ end
90
+ end
91
+
92
+
93
+ describe "reloading source on change" do
94
+ temporary_change_hash_value(Debugger::Command.settings, :reload_source_on_change, false)
95
+
96
+ it "must not reload source if autoreload is not set" do
97
+ enter(
98
+ 'set noautoreload',
99
+ ->{change_line_in_file(fullpath('breakpoint1'), 14, ''); 'break 14'},
100
+ ->{change_line_in_file(fullpath('breakpoint1'), 14, 'c = a + b'); 'cont'}
101
+ )
102
+ debug_file "breakpoint1"
103
+ check_output_includes "Breakpoint 1 at #{fullpath('breakpoint1')}:14"
104
+ end
105
+
106
+ it "must reload source if autoreload is set" do
107
+ enter(
108
+ 'set autoreload',
109
+ ->{change_line_in_file(fullpath('breakpoint1'), 14, ''); 'break 14'},
110
+ # Setting second breakpoint just to reload the source code after rolling the file changes back
111
+ ->{change_line_in_file(fullpath('breakpoint1'), 14, 'c = a + b'); 'break 15'}, 'cont'
112
+ )
113
+ debug_file "breakpoint1"
114
+ check_output_includes "Line 14 is not a stopping point in file \"breakpoint1.rb\".", interface.error_queue
115
+ end
116
+ end
117
+
118
+
119
+ describe "set breakpoint in a file" do
120
+ describe "successfully" do
121
+ before do
122
+ enter "break #{fullpath('breakpoint2')}:3", 'cont'
123
+ end
124
+
125
+ it "must stop at the correct line" do
126
+ debug_file("breakpoint1") { state.line.must_equal 3 }
127
+ end
128
+
129
+ it "must stop at the correct file" do
130
+ debug_file("breakpoint1") { state.file.must_equal fullpath("breakpoint2") }
131
+ end
132
+ end
133
+
134
+ describe "when setting breakpoint to unexisted file" do
135
+ before do
136
+ enter "break asf:324"
137
+ debug_file("breakpoint1")
138
+ end
139
+ it "must show an error" do
140
+ check_output_includes "No source file named asf", interface.error_queue
141
+ end
142
+
143
+ it "must ask about setting breakpoint anyway" do
144
+ check_output_includes "Set breakpoint anyway? (y/n)", interface.confirm_queue
145
+ end
146
+ end
147
+ end
148
+
149
+
150
+ describe "set breakpoint to a method" do
151
+ describe "set breakpoint to an instance method" do
152
+ before do
153
+ enter 'break A#b', 'cont'
154
+ end
155
+
156
+ it "must stop at the correct line" do
157
+ debug_file("breakpoint1") { state.line.must_equal 5 }
158
+ end
159
+
160
+ it "must stop at the correct file" do
161
+ debug_file("breakpoint1") { state.file.must_equal fullpath("breakpoint1") }
162
+ end
163
+ end
164
+
165
+ describe "set breakpoint to a class method" do
166
+ before do
167
+ enter 'break A.a', 'cont'
168
+ end
169
+
170
+ it "must stop at the correct line" do
171
+ debug_file("breakpoint1") { state.line.must_equal 2 }
172
+ end
173
+
174
+ it "must stop at the correct file" do
175
+ debug_file("breakpoint1") { state.file.must_equal fullpath("breakpoint1") }
176
+ end
177
+ end
178
+
179
+ describe "set breakpoint to unexisted class" do
180
+ it "must show an error" do
181
+ enter "break B.a"
182
+ debug_file("breakpoint1")
183
+ check_output_includes "Unknown class B.", interface.error_queue
184
+ end
185
+ end
186
+ end
187
+
188
+
189
+ describe "set breakpoint to an invalid location" do
190
+ before { enter "break foo" }
191
+
192
+ it "must not create a breakpoint" do
193
+ debug_file("breakpoint1") { Debugger.breakpoints.must_be_empty }
194
+ end
195
+
196
+ it "must show an error" do
197
+ debug_file("breakpoint1")
198
+ check_output_includes 'Invalid breakpoint location: foo.', interface.error_queue
199
+ end
200
+ end
201
+
202
+
203
+ describe "disabling a breakpoint" do
204
+ describe "successfully" do
205
+ before { enter "break 14" }
206
+
207
+ describe "short syntax" do
208
+ before { enter ->{"disable #{breakpoint.id}"}, "break 15" }
209
+ it "must have a breakpoint with #enabled? returning false" do
210
+ debug_file("breakpoint1") { breakpoint.enabled?.must_equal false }
211
+ end
212
+
213
+ it "must not stop on the disabled breakpoint" do
214
+ enter "cont"
215
+ debug_file("breakpoint1") { state.line.must_equal 15 }
216
+ end
217
+ end
218
+
219
+ describe "full syntax" do
220
+ before { enter ->{"disable breakpoints #{breakpoint.id}"}, "break 15" }
221
+ it "must have a breakpoint with #enabled? returning false" do
222
+ debug_file("breakpoint1") { breakpoint.enabled?.must_equal false }
223
+ end
224
+ end
225
+ end
226
+
227
+ describe "errors" do
228
+ it "must show an error if syntax is incorrect" do
229
+ enter "disable"
230
+ debug_file("breakpoint1")
231
+ check_output_includes(
232
+ '"disable" must be followed "display", "breakpoints" or breakpoint numbers.',
233
+ interface.error_queue
234
+ )
235
+ end
236
+
237
+ it "must show an error if no breakpoints is set" do
238
+ enter "disable 1"
239
+ debug_file("breakpoint1")
240
+ check_output_includes 'No breakpoints have been set.', interface.error_queue
241
+ end
242
+
243
+ it "must show an error if not a number is provided as an argument to 'disable' command" do
244
+ enter "break 14", "disable foo"
245
+ debug_file("breakpoint1")
246
+ check_output_includes "Disable breakpoints argument 'foo' needs to be a number."
247
+ end
248
+ end
249
+ end
250
+
251
+
252
+ describe "enabling a breakpoint" do
253
+ describe "successfully" do
254
+ before { enter "break 14" }
255
+ describe "short syntax" do
256
+ before { enter ->{"enable #{breakpoint.id}"}, "break 15" }
257
+
258
+ it "must have a breakpoint with #enabled? returning true" do
259
+ debug_file("breakpoint1") { breakpoint.enabled?.must_equal true }
260
+ end
261
+
262
+ it "must stop on the enabled breakpoint" do
263
+ enter "cont"
264
+ debug_file("breakpoint1") { state.line.must_equal 14 }
265
+ end
266
+ end
267
+
268
+ describe "full syntax" do
269
+ before { enter ->{"enable breakpoints #{breakpoint.id}"}, "break 15" }
270
+
271
+ it "must have a breakpoint with #enabled? returning true" do
272
+ debug_file("breakpoint1") { breakpoint.enabled?.must_equal true }
273
+ end
274
+ end
275
+ end
276
+
277
+ describe "errors" do
278
+ it "must show an error if syntax is incorrect" do
279
+ enter "enable"
280
+ debug_file("breakpoint1")
281
+ check_output_includes(
282
+ '"enable" must be followed "display", "breakpoints" or breakpoint numbers.',
283
+ interface.error_queue
284
+ )
285
+ end
286
+ end
287
+ end
288
+
289
+
290
+ describe "deleting a breakpoint" do
291
+ before { enter "break 14", ->{"delete #{breakpoint.id}"}, "break 15" }
292
+
293
+ it "must have only one breakpoint" do
294
+ debug_file("breakpoint1") { Debugger.breakpoints.size.must_equal 1 }
295
+ end
296
+
297
+ it "must not stop on the disabled breakpoint" do
298
+ enter "cont"
299
+ debug_file("breakpoint1") { state.line.must_equal 15 }
300
+ end
301
+ end
302
+
303
+
304
+ describe "Conditional breakpoints" do
305
+ it "must stop if the condition is correct" do
306
+ enter "break 14 if b == 5", "break 15", "cont"
307
+ debug_file("breakpoint1") { state.line.must_equal 14 }
308
+ end
309
+
310
+ it "must skip if the condition is incorrect" do
311
+ enter "break 14 if b == 3", "break 15", "cont"
312
+ debug_file("breakpoint1") { state.line.must_equal 15 }
313
+ end
314
+
315
+ it "must show an error when conditional syntax is wrong" do
316
+ enter "break 14 ifa b == 3", "break 15", "cont"
317
+ debug_file("breakpoint1") { state.line.must_equal 15 }
318
+ check_output_includes "Expecting 'if' in breakpoint condition; got: ifa b == 3.", interface.error_queue
319
+ end
320
+
321
+ describe "enabling with wrong conditional syntax" do
322
+ before do
323
+ enter(
324
+ "break 14",
325
+ ->{"disable #{breakpoint.id}"},
326
+ ->{"cond #{breakpoint.id} b -=( 3"},
327
+ ->{"enable #{breakpoint.id}"}
328
+ )
329
+ end
330
+
331
+ it "must not enable a breakpoint" do
332
+ debug_file("breakpoint1") { breakpoint.enabled?.must_equal false }
333
+ end
334
+
335
+ it "must show an error" do
336
+ debug_file("breakpoint1")
337
+ check_output_includes(
338
+ 'Expression "b -=( 3" syntactically incorrect; breakpoint remains disabled.',
339
+ interface.error_queue
340
+ )
341
+ end
342
+ end
343
+
344
+ it "must show an error if no file or line is specified" do
345
+ enter "break ifa b == 3", "break 15", "cont"
346
+ debug_file("breakpoint1") { state.line.must_equal 15 }
347
+ check_output_includes "Invalid breakpoint location: ifa b == 3.", interface.error_queue
348
+ end
349
+
350
+ it "must show an error if expression syntax is invalid" do
351
+ enter "break if b -=) 3", "break 15", "cont"
352
+ debug_file("breakpoint1") { state.line.must_equal 15 }
353
+ check_output_includes 'Expression "b -=) 3" syntactically incorrect; breakpoint disabled.', interface.error_queue
354
+ end
355
+ end
356
+
357
+
358
+ describe "Post Mortem" do
359
+ it "must be able to set breakpoints in post-mortem mode" do
360
+ enter 'cont', 'break 12', 'cont'
361
+ debug_file("post_mortem") { state.line.must_equal 12 }
362
+ end
363
+ end
364
+
365
+ end