debugger2 1.0.0.beta1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (183) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +12 -0
  3. data/.travis.yml +3 -0
  4. data/AUTHORS +10 -0
  5. data/CHANGELOG.md +65 -0
  6. data/CONTRIBUTING.md +1 -0
  7. data/Gemfile +3 -0
  8. data/LICENSE +23 -0
  9. data/OLDER_CHANGELOG +334 -0
  10. data/OLD_CHANGELOG +5655 -0
  11. data/OLD_README +122 -0
  12. data/README.md +108 -0
  13. data/Rakefile +78 -0
  14. data/bin/rdebug +397 -0
  15. data/debugger2.gemspec +29 -0
  16. data/doc/.cvsignore +42 -0
  17. data/doc/Makefile.am +63 -0
  18. data/doc/emacs-notes.txt +38 -0
  19. data/doc/hanoi.rb +35 -0
  20. data/doc/primes.rb +28 -0
  21. data/doc/rdebug-emacs.texi +1030 -0
  22. data/doc/ruby-debug.texi +3791 -0
  23. data/doc/test-tri2.rb +18 -0
  24. data/doc/tri3.rb +8 -0
  25. data/doc/triangle.rb +12 -0
  26. data/emacs/Makefile.am +130 -0
  27. data/emacs/rdebug-annotate.el +385 -0
  28. data/emacs/rdebug-breaks.el +407 -0
  29. data/emacs/rdebug-cmd.el +92 -0
  30. data/emacs/rdebug-core.el +502 -0
  31. data/emacs/rdebug-dbg.el +62 -0
  32. data/emacs/rdebug-error.el +79 -0
  33. data/emacs/rdebug-fns.el +111 -0
  34. data/emacs/rdebug-frames.el +230 -0
  35. data/emacs/rdebug-gud.el +242 -0
  36. data/emacs/rdebug-help.el +104 -0
  37. data/emacs/rdebug-info.el +83 -0
  38. data/emacs/rdebug-layouts.el +180 -0
  39. data/emacs/rdebug-locring.el +118 -0
  40. data/emacs/rdebug-output.el +106 -0
  41. data/emacs/rdebug-regexp.el +118 -0
  42. data/emacs/rdebug-secondary.el +260 -0
  43. data/emacs/rdebug-shortkey.el +175 -0
  44. data/emacs/rdebug-source.el +568 -0
  45. data/emacs/rdebug-track.el +392 -0
  46. data/emacs/rdebug-varbuf.el +150 -0
  47. data/emacs/rdebug-vars.el +125 -0
  48. data/emacs/rdebug-watch.el +132 -0
  49. data/emacs/rdebug.el +326 -0
  50. data/emacs/test/elk-test.el +242 -0
  51. data/emacs/test/test-annotate.el +103 -0
  52. data/emacs/test/test-cmd.el +116 -0
  53. data/emacs/test/test-core.el +104 -0
  54. data/emacs/test/test-fns.el +65 -0
  55. data/emacs/test/test-frames.el +62 -0
  56. data/emacs/test/test-gud.el +35 -0
  57. data/emacs/test/test-indent.el +58 -0
  58. data/emacs/test/test-regexp.el +144 -0
  59. data/emacs/test/test-shortkey.el +61 -0
  60. data/ext/ruby_debug/breakpoint.c +630 -0
  61. data/ext/ruby_debug/extconf.rb +11 -0
  62. data/ext/ruby_debug/ruby_debug.c +2203 -0
  63. data/ext/ruby_debug/ruby_debug.h +151 -0
  64. data/lib/debugger.rb +5 -0
  65. data/lib/debugger/version.rb +5 -0
  66. data/lib/debugger2.rb +6 -0
  67. data/lib/ruby-debug-base.rb +307 -0
  68. data/lib/ruby-debug.rb +176 -0
  69. data/lib/ruby-debug/command.rb +227 -0
  70. data/lib/ruby-debug/commands/breakpoints.rb +153 -0
  71. data/lib/ruby-debug/commands/catchpoint.rb +55 -0
  72. data/lib/ruby-debug/commands/condition.rb +49 -0
  73. data/lib/ruby-debug/commands/continue.rb +38 -0
  74. data/lib/ruby-debug/commands/control.rb +107 -0
  75. data/lib/ruby-debug/commands/display.rb +120 -0
  76. data/lib/ruby-debug/commands/edit.rb +48 -0
  77. data/lib/ruby-debug/commands/enable.rb +202 -0
  78. data/lib/ruby-debug/commands/eval.rb +176 -0
  79. data/lib/ruby-debug/commands/finish.rb +42 -0
  80. data/lib/ruby-debug/commands/frame.rb +301 -0
  81. data/lib/ruby-debug/commands/help.rb +56 -0
  82. data/lib/ruby-debug/commands/info.rb +467 -0
  83. data/lib/ruby-debug/commands/irb.rb +123 -0
  84. data/lib/ruby-debug/commands/jump.rb +66 -0
  85. data/lib/ruby-debug/commands/kill.rb +51 -0
  86. data/lib/ruby-debug/commands/list.rb +94 -0
  87. data/lib/ruby-debug/commands/method.rb +84 -0
  88. data/lib/ruby-debug/commands/quit.rb +39 -0
  89. data/lib/ruby-debug/commands/reload.rb +40 -0
  90. data/lib/ruby-debug/commands/save.rb +90 -0
  91. data/lib/ruby-debug/commands/set.rb +223 -0
  92. data/lib/ruby-debug/commands/show.rb +247 -0
  93. data/lib/ruby-debug/commands/skip.rb +35 -0
  94. data/lib/ruby-debug/commands/source.rb +36 -0
  95. data/lib/ruby-debug/commands/stepping.rb +81 -0
  96. data/lib/ruby-debug/commands/threads.rb +189 -0
  97. data/lib/ruby-debug/commands/tmate.rb +36 -0
  98. data/lib/ruby-debug/commands/trace.rb +57 -0
  99. data/lib/ruby-debug/commands/variables.rb +199 -0
  100. data/lib/ruby-debug/debugger.rb +5 -0
  101. data/lib/ruby-debug/helper.rb +69 -0
  102. data/lib/ruby-debug/interface.rb +232 -0
  103. data/lib/ruby-debug/processor.rb +474 -0
  104. data/man/rdebug.1 +241 -0
  105. data/old_scripts/Makefile.am +14 -0
  106. data/old_scripts/README.md +2 -0
  107. data/old_scripts/autogen.sh +4 -0
  108. data/old_scripts/configure.ac +12 -0
  109. data/old_scripts/rdbg.rb +33 -0
  110. data/old_scripts/runner.sh +7 -0
  111. data/old_scripts/svn2cl_usermap +3 -0
  112. data/test/.cvsignore +1 -0
  113. data/test/breakpoints_test.rb +366 -0
  114. data/test/conditions_test.rb +77 -0
  115. data/test/continue_test.rb +28 -0
  116. data/test/display_test.rb +143 -0
  117. data/test/edit_test.rb +55 -0
  118. data/test/eval_test.rb +94 -0
  119. data/test/examples/breakpoint1.rb +15 -0
  120. data/test/examples/breakpoint2.rb +7 -0
  121. data/test/examples/conditions.rb +4 -0
  122. data/test/examples/continue.rb +4 -0
  123. data/test/examples/display.rb +5 -0
  124. data/test/examples/edit.rb +3 -0
  125. data/test/examples/edit2.rb +3 -0
  126. data/test/examples/eval.rb +4 -0
  127. data/test/examples/finish.rb +20 -0
  128. data/test/examples/frame.rb +31 -0
  129. data/test/examples/help.rb +2 -0
  130. data/test/examples/info.rb +48 -0
  131. data/test/examples/info2.rb +3 -0
  132. data/test/examples/irb.rb +6 -0
  133. data/test/examples/jump.rb +14 -0
  134. data/test/examples/kill.rb +2 -0
  135. data/test/examples/list.rb +12 -0
  136. data/test/examples/method.rb +15 -0
  137. data/test/examples/post_mortem.rb +19 -0
  138. data/test/examples/quit.rb +2 -0
  139. data/test/examples/reload.rb +6 -0
  140. data/test/examples/restart.rb +6 -0
  141. data/test/examples/save.rb +3 -0
  142. data/test/examples/set.rb +3 -0
  143. data/test/examples/set_annotate.rb +12 -0
  144. data/test/examples/settings.rb +1 -0
  145. data/test/examples/show.rb +2 -0
  146. data/test/examples/source.rb +3 -0
  147. data/test/examples/stepping.rb +21 -0
  148. data/test/examples/thread.rb +32 -0
  149. data/test/examples/tmate.rb +10 -0
  150. data/test/examples/trace.rb +7 -0
  151. data/test/examples/trace_threads.rb +20 -0
  152. data/test/examples/variables.rb +26 -0
  153. data/test/finish_test.rb +49 -0
  154. data/test/frame_test.rb +140 -0
  155. data/test/help_test.rb +51 -0
  156. data/test/info_test.rb +326 -0
  157. data/test/irb_test.rb +82 -0
  158. data/test/jump_test.rb +70 -0
  159. data/test/kill_test.rb +49 -0
  160. data/test/list_test.rb +147 -0
  161. data/test/method_test.rb +72 -0
  162. data/test/post_mortem_test.rb +25 -0
  163. data/test/quit_test.rb +56 -0
  164. data/test/reload_test.rb +47 -0
  165. data/test/restart_test.rb +145 -0
  166. data/test/save_test.rb +94 -0
  167. data/test/set_test.rb +183 -0
  168. data/test/show_test.rb +294 -0
  169. data/test/source_test.rb +46 -0
  170. data/test/stepping_test.rb +122 -0
  171. data/test/support/breakpoint.rb +12 -0
  172. data/test/support/context.rb +14 -0
  173. data/test/support/matchers.rb +67 -0
  174. data/test/support/mocha_extensions.rb +71 -0
  175. data/test/support/processor.rb +7 -0
  176. data/test/support/test_dsl.rb +206 -0
  177. data/test/support/test_interface.rb +66 -0
  178. data/test/test_helper.rb +9 -0
  179. data/test/thread_test.rb +124 -0
  180. data/test/tmate_test.rb +45 -0
  181. data/test/trace_test.rb +156 -0
  182. data/test/variables_test.rb +116 -0
  183. metadata +319 -0
@@ -0,0 +1,407 @@
1
+ ;;; rdebug-breaks.el --- This file contains code dealing with the Ruby
2
+ ;;; debugger's breakpoints and the breakpoint secondary buffer.
3
+
4
+ ;; Copyright (C) 2008 Rocky Bernstein (rocky@gnu.org)
5
+ ;; Copyright (C) 2008 Anders Lindgren
6
+
7
+ ;; $Id: rdebug-breaks.el 780 2008-03-21 19:04:12Z rockyb $
8
+
9
+ ;; This program is free software; you can redistribute it and/or modify
10
+ ;; it under the terms of the GNU General Public License as published by
11
+ ;; the Free Software Foundation; either version 2, or (at your option)
12
+ ;; any later version.
13
+
14
+ ;; This program is distributed in the hope that it will be useful,
15
+ ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
16
+ ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
+ ;; GNU General Public License for more details.
18
+
19
+ ;; You should have received a copy of the GNU General Public License
20
+ ;; along with GNU Emacs; see the file COPYING. If not, write to the
21
+ ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
22
+ ;; Boston, MA 02111-1307, USA.
23
+
24
+ ;;; Commentary:
25
+
26
+ ;; This file contains code dealing with the breakpoints and the
27
+ ;; breakpoints secondary buffer.
28
+
29
+ ;;; Code:
30
+
31
+ (require 'rdebug-dbg)
32
+ (require 'rdebug-gud)
33
+ (require 'rdebug-regexp)
34
+ (require 'rdebug-secondary)
35
+ (require 'rdebug-source)
36
+ (require 'rdebug-vars)
37
+
38
+ (defun rdebug-display-breakpoints-buffer ()
39
+ "Display the rdebug breakpoints buffer."
40
+ (interactive)
41
+ (rdebug-display-secondary-buffer "breakpoints"))
42
+
43
+ (defvar rdebug-breakpoint-mode-map
44
+ (let ((map (make-sparse-keymap)))
45
+ (define-key map [double-mouse-1] 'rdebug-goto-breakpoint-mouse)
46
+ (define-key map [mouse-2] 'rdebug-goto-breakpoint-mouse)
47
+ (define-key map [mouse-3] 'rdebug-goto-breakpoint-mouse)
48
+ (define-key map "t" 'rdebug-toggle-breakpoint)
49
+ (define-key map "i" 'rdebug-add-breakpoint-condition)
50
+ (define-key map [insert] 'rdebug-add-breakpoint-condition)
51
+ (rdebug-populate-digit-keys map)
52
+ (define-key map [(control m)] 'rdebug-goto-breakpoint)
53
+ (define-key map [?d] 'rdebug-delete-breakpoint)
54
+ (rdebug-populate-secondary-buffer-map map)
55
+
56
+ ;; --------------------
57
+ ;; The "Breakpoints window" submenu.
58
+ (let ((submenu (make-sparse-keymap)))
59
+ (define-key-after map [menu-bar debugger breakpoints]
60
+ (cons "Breakpoints window" submenu)
61
+ 'placeholder))
62
+
63
+ (define-key map [menu-bar debugger breakpoints toggle]
64
+ '(menu-item "Toggle breakpoint" rdebug-toggle-breakpoint))
65
+
66
+ (define-key map [menu-bar debugger breakpoints goto]
67
+ '(menu-item "Goto breakpoint" rdebug-goto-breakpoint))
68
+
69
+ (define-key map [menu-bar debugger breakpoints delete]
70
+ '(menu-item "Delete breakpoint" rdebug-delete-breakpoint))
71
+
72
+ map)
73
+ "Keymap to navigate/set/enable rdebug breakpoints.")
74
+
75
+ ;; Here the "anchored match" method is used, see `font-lock-keywords'
76
+ ;; for details.
77
+ (defvar rdebug-breakpoint-font-lock-keywords
78
+ '(("\\([0-9]+\\) +\\(\\(n\\)\\|\\(y\\)\\) +at "
79
+ (1 font-lock-constant-face)
80
+ (3 font-lock-type-face nil t) ; t = ok if not present
81
+ (4 font-lock-warning-face nil t) ; ditto.
82
+ ;; File name and line
83
+ ("\\(.*\\):\\([0-9]+\\)$"
84
+ nil ; Preform (not used)
85
+ nil ; Postfrom (not used)
86
+ (1 font-lock-warning-face)
87
+ (2 font-lock-constant-face))
88
+ ;; Class:function
89
+ ("\\(.*\\):\\([a-zA-Z_].+\\)$"
90
+ nil ; Preform (not used)
91
+ nil ; Postfrom (not used)
92
+ (1 font-lock-type-face)
93
+ (2 font-lock-function-name-face))))
94
+ "Rules for coloring the rdebug breakpoints buffer.")
95
+
96
+ (defun rdebug-breakpoint-mode ()
97
+ "Major mode for displaying breakpoints in the `rdebug' Ruby debugger.
98
+
99
+ \\{rdebug-breakpoint-mode-map}"
100
+ (kill-all-local-variables)
101
+ (setq major-mode 'rdebug-breakpoint-mode)
102
+ (setq mode-name "RDEBUG Breakpoints")
103
+ (use-local-map rdebug-breakpoint-mode-map)
104
+ (setq buffer-read-only t)
105
+ (set (make-local-variable 'rdebug-secondary-buffer) t)
106
+ (setq mode-line-process 'rdebug-mode-line-process)
107
+ (set (make-local-variable 'font-lock-defaults)
108
+ '(rdebug-breakpoint-font-lock-keywords))
109
+ (run-mode-hooks 'rdebug-breakpoint-mode-hook))
110
+
111
+
112
+ (defun rdebug-setup-breakpoints-buffer (buf comint-buffer)
113
+ "Detect breakpoint lines and set up keymap and mouse navigation.
114
+ Argument BUF is the buffer to set up.
115
+ Argument COMINT-BUFFER is the assocaited gud process buffer."
116
+ (rdebug-debug-enter "rdebug-setup-breakpoints-buffer"
117
+ (with-current-buffer buf
118
+ (let ((inhibit-read-only t)
119
+ (old-line-number (buffer-local-value 'rdebug-current-line-number
120
+ buf)))
121
+ (rdebug-breakpoint-mode)
122
+ (goto-char (point-min))
123
+ (while (not (eobp))
124
+ (let ((b (line-beginning-position)) (e (line-end-position)))
125
+ (when (string-match rdebug-breakpoint-regexp
126
+ (buffer-substring b e))
127
+ (add-text-properties b e
128
+ (list 'mouse-face 'highlight
129
+ 'keymap rdebug-breakpoint-mode-map)))
130
+ (forward-line)))
131
+ (goto-line old-line-number)))
132
+ (rdebug-breakpoint-parse-and-update-cache)
133
+ (rdebug-breakpoint-update-icons (rdebug-breakpoint-all))))
134
+
135
+
136
+ (defvar rdebug-breakpoint-cache '()
137
+ "The cached return value of `rdebug-breakpoint-all'.
138
+
139
+ Buffer-local to the debugger shell window.")
140
+
141
+
142
+ ;; Implementation note: If Emacs could talk directly to the Ruby
143
+ ;; debugger, this would be roughly "Debugger.breakpoints". Since we
144
+ ;; currently can't do that we parse the content of the breakpoints
145
+ ;; window.
146
+ ;;
147
+ ;; Note: The :function kind is not yet implemented.
148
+ (defun rdebug-breakpoint-parse-and-update-cache ()
149
+ "Build up the return value of `rdebug-breakpoint-all'."
150
+ (save-excursion
151
+ (goto-char (point-min))
152
+ (let ((res '()))
153
+ (while (not (eobp))
154
+ (when (looking-at rdebug-breakpoint-regexp)
155
+ (push (list :file
156
+ ;; Break point number
157
+ (string-to-number (match-string 1))
158
+ ;; Enabled
159
+ (string= (match-string 2) "y")
160
+ ;; File name
161
+ (file-truename
162
+ (match-string-no-properties 3))
163
+ ;; Line number
164
+ (string-to-number (match-string 4)))
165
+ res))
166
+ (forward-line 1))
167
+ ;; The result goes into a buffer-local variable in the debugger
168
+ ;; shell. (This ensures that this would work in a multi-session
169
+ ;; environment.)
170
+ (if gud-comint-buffer
171
+ (with-current-buffer gud-comint-buffer
172
+ (set (make-local-variable 'rdebug-breakpoint-cache)
173
+ (nreverse res)))))))
174
+
175
+
176
+ (defun rdebug-breakpoint-all ()
177
+ "Return a list of all breakpoints.
178
+
179
+ Each entry in the list is on the form:
180
+
181
+ (:file number enabled file line)
182
+
183
+ or
184
+
185
+ (:function number enabled class function)"
186
+ (and gud-comint-buffer
187
+ (buffer-local-value 'rdebug-breakpoint-cache gud-comint-buffer)))
188
+
189
+
190
+ (defun rdebug-file-and-line-arg ()
191
+ "Return the current file and line number as a list."
192
+ (save-excursion
193
+ (beginning-of-line)
194
+ (list (buffer-file-name) (+ 1 (count-lines (point-min) (point))))))
195
+
196
+ (defun rdebug-breakpoint-on-line (file line)
197
+ "Return a list of the breakpoints on the file FILE and current source LINE."
198
+ (let ((res '()))
199
+ (dolist (entry (rdebug-breakpoint-all))
200
+ (if (and (eq (nth 0 entry) :file)
201
+ (string= (nth 3 entry) file)
202
+ (equal (nth 4 entry) line))
203
+ (push entry res)))
204
+ res))
205
+
206
+
207
+ (defun rdebug-toggle-source-breakpoint (file line)
208
+ "Toggle break point in FILE on current source LINE."
209
+ (interactive (rdebug-file-and-line-arg))
210
+ (cond ((eq major-mode 'rdebug-breakpoint-mode)
211
+ (rdebug-delete-breakpoint))
212
+ ((null file)
213
+ ;; Do nothing.
214
+ )
215
+ (t
216
+ (let ((bps (rdebug-breakpoint-on-line file line)))
217
+ (if bps
218
+ (gud-call (format "delete %s" (nth 1 (car bps))))
219
+ (gud-call (format "break %s:%d" file line)))))))
220
+
221
+
222
+ (defun rdebug-toggle-source-breakpoint-enabled (file line)
223
+ "Enable or disable a breakpoint in FILE on the current source LINE."
224
+ (interactive (rdebug-file-and-line-arg))
225
+ (cond ((eq major-mode 'rdebug-breakpoint-mode)
226
+ (rdebug-toggle-breakpoint))
227
+ ((null file)
228
+ ;; Do nothing.
229
+ )
230
+ (t
231
+ (let ((bps (rdebug-breakpoint-on-line file line)))
232
+ (if bps
233
+ ;; Note: If the line contains more than one simply use the
234
+ ;; first one.
235
+ (let ((entry (car bps)))
236
+ (if (nth 2 entry)
237
+ (gud-call (format "disable %s" (nth 1 entry)))
238
+ (gud-call (format "enable %s" (nth 1 entry)))))
239
+ (gud-call (format "break %s:%d" file line)))))))
240
+
241
+
242
+ ;; ---------------------------------------------------------
243
+ ;; Commands of the rdebug breakpoints buffer.
244
+ ;;
245
+
246
+ (defun rdebug-delete-breakpoint (&optional pt)
247
+ "Deletes the breakpoint at PT in the breakpoints buffer."
248
+ (interactive "d")
249
+ (save-excursion
250
+ (if pt
251
+ (goto-char pt))
252
+ (let ((s (buffer-substring (line-beginning-position) (line-end-position))))
253
+ (when (string-match rdebug-breakpoint-regexp s)
254
+ (let ((bpnum (substring s (match-beginning 1) (match-end 1))))
255
+ (gud-call (format "delete %s" bpnum)))))))
256
+
257
+ (defun rdebug-goto-breakpoint (pt)
258
+ "Displays the location in a source file of the selected breakpoint.
259
+ Argument PT indicates the file and line where the breakpoint should be set."
260
+ (interactive "d")
261
+ (save-excursion
262
+ (goto-char pt)
263
+ (let ((s (buffer-substring (line-beginning-position) (line-end-position))))
264
+ (when (string-match rdebug-breakpoint-regexp s)
265
+ (rdebug-display-line
266
+ (substring s (match-beginning 3) (match-end 3))
267
+ (string-to-number (substring s (match-beginning 4) (match-end 4))))
268
+ ))))
269
+
270
+
271
+ (defun rdebug-goto-breakpoint-mouse (event)
272
+ "Displays the location in a source file of the selected breakpoint."
273
+ (interactive "e")
274
+ (with-current-buffer (window-buffer (posn-window (event-end event)))
275
+ (rdebug-goto-breakpoint (posn-point (event-end event)))))
276
+
277
+
278
+ (defun rdebug-get-breakpoint-number (pt)
279
+ "Return the current breakpoint number in the breakpoint secondary window or nil if none found."
280
+ (interactive "d")
281
+ (save-excursion
282
+ (goto-char pt)
283
+ (let ((s (buffer-substring (line-beginning-position) (line-end-position))))
284
+ (if (string-match rdebug-breakpoint-regexp s)
285
+ (substring s (match-beginning 1) (match-end 1))
286
+ nil))))
287
+
288
+ (defun rdebug-toggle-breakpoint (&optional pt)
289
+ "Toggle the breakpoint at PT in the breakpoints buffer."
290
+ (interactive "d")
291
+ (save-excursion
292
+ (if pt
293
+ (goto-char pt))
294
+ (let ((s (buffer-substring (line-beginning-position) (line-end-position))))
295
+ (when (string-match rdebug-breakpoint-regexp s)
296
+ (let* ((enabled
297
+ (string= (substring s (match-beginning 2) (match-end 2)) "y"))
298
+ (cmd (if enabled "disable" "enable"))
299
+ (bpnum (substring s (match-beginning 1) (match-end 1))))
300
+ (gud-call (format "%s breakpoint %s" cmd bpnum)))))))
301
+
302
+ (defun rdebug-add-breakpoint-condition (pt)
303
+ "Add an expression as a condition to the break `rdebug' Ruby debugger."
304
+ (interactive "d")
305
+ (let ((bpnum (rdebug-get-breakpoint-number pt))
306
+ (expr (read-string "Ruby expression for breakpoint condition: ")))
307
+ (if bpnum
308
+ (gud-call (format "condition %s %s" bpnum expr))
309
+ (message "Breakpoint number not found"))))
310
+
311
+
312
+ ;; -----------------------------------------------
313
+ ;; Breakpoint icon support.
314
+ ;;
315
+
316
+ ;; This is a trivial implementation, it has the following shortcomings:
317
+ ;;
318
+ ;; * It assumes that the buffer content doesn't change, if it does it
319
+ ;; will not be able to remove the icon.
320
+ ;;
321
+ ;; * No support for displaying an icon in a newly opened file.
322
+ ;;
323
+ ;; * It has no support for more than one session.
324
+
325
+ ;; Note: This is implemented on top of `gdb-ui'. In the future, it
326
+ ;; would be better if that code is generalized.
327
+
328
+ (require 'gdb-ui)
329
+
330
+ ;; This is a local variable, should not be placed in rdebug-vars.el.
331
+ (defvar rdebug-breakpoint-icons-current-state nil)
332
+
333
+ (defun rdebug-breakpoint-remove-icon (entry)
334
+ "Remove the the source buffer the fringe breakpoint icon breakpoint ENTRY."
335
+ (if (eq (nth 0 entry) :file)
336
+ (let ((buf (find-buffer-visiting (nth 3 entry))))
337
+ (if buf
338
+ (save-current-buffer
339
+ (set-buffer buf)
340
+ (save-excursion
341
+ (goto-line (nth 4 entry))
342
+ (gdb-remove-breakpoint-icons (point) (point))))))))
343
+
344
+ (defun rdebug-breakpoint-remove-all-icons ()
345
+ "Remove all breakpoint fringe icons."
346
+ (interactive)
347
+ (dolist (entry rdebug-breakpoint-icons-current-state)
348
+ (rdebug-breakpoint-remove-icon entry))
349
+ (setq rdebug-breakpoint-icons-current-state nil))
350
+
351
+
352
+ (defun rdebug-breakpoint-add-icon (entry)
353
+ (if (eq (nth 0 entry) :file)
354
+ (let ((buf (find-buffer-visiting (nth 3 entry))))
355
+ (if buf
356
+ (save-current-buffer
357
+ (set-buffer buf)
358
+ (save-excursion
359
+ (goto-line (nth 4 entry))
360
+ ;; Workaround for bug in `gdb-ui'. (It checks
361
+ ;; `left-fringe-width' but it doesn't interpret the
362
+ ;; `nil' value correctly.
363
+ (let ((gdb-buffer-fringe-width (car (window-fringes))))
364
+ (gdb-put-breakpoint-icon (nth 2 entry)
365
+ (number-to-string (nth 1 entry))))))))))
366
+
367
+ (defun rdebug-breakpoint-list-member (file line list)
368
+ (let ((res nil))
369
+ (dolist (entry list)
370
+ (if (and (equal file (nth 3 entry))
371
+ (equal line (nth 4 entry)))
372
+ (setq res t)))
373
+ res))
374
+
375
+ ;; bpts has the same representation as returned by `rdebug-breakpoint-all'.
376
+ (defun rdebug-breakpoint-update-icons (bpts)
377
+ ;; Make sure there are is only one reference for each line.
378
+ (let ((state '()))
379
+ ;; An enabled breakpoint take precedence.
380
+ (dolist (enabled '(t nil))
381
+ (dolist (bpt bpts)
382
+ (if (and (eq (nth 0 bpt) :file)
383
+ (eq (nth 2 bpt) enabled)
384
+ (not (rdebug-breakpoint-list-member
385
+ (nth 3 bpt) (nth 4 bpt) state)))
386
+ (setq state (cons bpt state)))))
387
+ (dolist (entry rdebug-breakpoint-icons-current-state)
388
+ (unless (member entry state)
389
+ (rdebug-breakpoint-remove-icon entry)))
390
+ (dolist (entry state)
391
+ (unless (member entry rdebug-breakpoint-icons-current-state)
392
+ (rdebug-breakpoint-add-icon entry)))
393
+ (setq rdebug-breakpoint-icons-current-state state)))
394
+
395
+ ;; -------------------------------------------------------------------
396
+ ;; The end.
397
+ ;;
398
+
399
+ (provide 'rdebug-breaks)
400
+
401
+ ;;; Local variables:
402
+ ;;; eval:(put 'rdebug-debug-enter 'lisp-indent-hook 1)
403
+ ;;; End:
404
+
405
+ (provide 'rdebug-breaks)
406
+
407
+ ;;; rdebug-breaks.el ends here
@@ -0,0 +1,92 @@
1
+ ;;; rdebug-cmd.el --- Ruby debugger command buffer
2
+
3
+ ;; Copyright (C) 2008 Rocky Bernstein (rocky@gnu.org)
4
+ ;; Copyright (C) 2008 Anders Lindgren
5
+
6
+ ;; $Id: rdebug-cmd.el 822 2008-04-27 08:28:29Z rockyb $
7
+
8
+ ;; This program is free software; you can redistribute it and/or modify
9
+ ;; it under the terms of the GNU General Public License as published by
10
+ ;; the Free Software Foundation; either version 2, or (at your option)
11
+ ;; any later version.
12
+
13
+ ;; This program is distributed in the hope that it will be useful,
14
+ ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
+ ;; GNU General Public License for more details.
17
+
18
+ ;; You should have received a copy of the GNU General Public License
19
+ ;; along with GNU Emacs; see the file COPYING. If not, write to the
20
+ ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
21
+ ;; Boston, MA 02111-1307, USA.
22
+
23
+ ;;; Commentary:
24
+
25
+ ;; See the manual and the file `rdebug.el' for more information.
26
+
27
+ ;; This file contains code dealing primarily with the command buffer.
28
+
29
+ ;;; Code:
30
+
31
+ (require 'ring)
32
+ (require 'rdebug-locring)
33
+
34
+ (defun rdebug-command-initialization ()
35
+ "Initialization of command buffer common to `rdebug' and`rdebug-track-attach'."
36
+
37
+ ;; This opens up "Gud" menu, which isn't used since we've got our
38
+ ;; own "Debugger" menu.
39
+ ;; (set (make-local-variable 'gud-minor-mode) 'rdebug)
40
+
41
+ (set (make-local-variable 'rdebug-call-queue) '())
42
+ (set (make-local-variable 'rdebug-original-read-only) buffer-read-only)
43
+ (make-local-variable 'rdebug-source-location-ring-size) ; ...to global val.
44
+ (set (make-local-variable 'rdebug-source-location-ring)
45
+ (make-ring rdebug-source-location-ring-size))
46
+ (make-local-variable 'rdebug-source-location-ring-index)
47
+ (rdebug-locring-clear)
48
+
49
+ (gud-def gud-args "info args" "a"
50
+ "Show arguments of current stack frame.")
51
+ (gud-def gud-break "break %d%f:%l""\C-b"
52
+ "Set breakpoint at current line.")
53
+ (gud-def gud-cont "continue" "\C-r"
54
+ "Continue with display.")
55
+ (gud-def gud-down "down %p" "<"
56
+ "Down N stack frames (numeric arg).")
57
+ (gud-def gud-finish "finish" "\C-f"
58
+ "Finish executing current function.")
59
+ (gud-def gud-source-resync "up 0" "\C-l"
60
+ "Show current source window")
61
+ (gud-def gud-remove "clear %d%f:%l" "\C-d"
62
+ "Remove breakpoint at current line")
63
+ (gud-def gud-quit "quit" "Q"
64
+ "Quit debugger.")
65
+
66
+ (gud-def gud-statement "eval %e" "\C-e"
67
+ "Execute Ruby statement at point.")
68
+ (gud-def gud-tbreak "tbreak %d%f:%l" "\C-t"
69
+ "Set temporary breakpoint at current line.")
70
+ (gud-def gud-up "up %p"
71
+ ">" "Up N stack frames to a newer frame (numeric arg).")
72
+ (gud-def gud-where "where"
73
+ "T" "Show stack trace.")
74
+
75
+ (local-set-key [M-insert] 'rdebug-internal-short-key-mode)
76
+ (local-set-key [M-down] 'rdebug-locring-newer)
77
+ (local-set-key [M-up] 'rdebug-locring-older)
78
+ (local-set-key [M-S-down] 'rdebug-locring-newest)
79
+ (local-set-key [M-S-up] 'rdebug-locring-oldest)
80
+ ;; (local-set-key "\C-i" 'gud-gdb-complete-command)
81
+ (local-set-key "\C-c\C-n" 'comint-next-prompt)
82
+ (local-set-key "\C-c\C-p" 'comint-previous-prompt))
83
+
84
+ ;; stopping location motion routines.
85
+
86
+ (provide 'rdebug-cmd)
87
+
88
+ ;;; Local variables:
89
+ ;;; eval:(put 'rdebug-debug-enter 'lisp-indent-hook 1)
90
+ ;;; End:
91
+
92
+ ;;; rdebug-cmd.el ends here