debugger 1.0.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (261) hide show
  1. data/AUTHORS +10 -0
  2. data/CHANGES +334 -0
  3. data/ChangeLog +5655 -0
  4. data/INSTALL.SVN +154 -0
  5. data/LICENSE +23 -0
  6. data/Makefile.am +14 -0
  7. data/OLD_README +122 -0
  8. data/README.md +10 -0
  9. data/Rakefile +266 -0
  10. data/autogen.sh +4 -0
  11. data/bin/rdebug +398 -0
  12. data/cli/ruby-debug.rb +173 -0
  13. data/cli/ruby-debug/command.rb +228 -0
  14. data/cli/ruby-debug/commands/breakpoints.rb +153 -0
  15. data/cli/ruby-debug/commands/catchpoint.rb +55 -0
  16. data/cli/ruby-debug/commands/condition.rb +49 -0
  17. data/cli/ruby-debug/commands/continue.rb +38 -0
  18. data/cli/ruby-debug/commands/control.rb +107 -0
  19. data/cli/ruby-debug/commands/display.rb +120 -0
  20. data/cli/ruby-debug/commands/edit.rb +48 -0
  21. data/cli/ruby-debug/commands/enable.rb +202 -0
  22. data/cli/ruby-debug/commands/eval.rb +176 -0
  23. data/cli/ruby-debug/commands/finish.rb +42 -0
  24. data/cli/ruby-debug/commands/frame.rb +301 -0
  25. data/cli/ruby-debug/commands/help.rb +56 -0
  26. data/cli/ruby-debug/commands/info.rb +467 -0
  27. data/cli/ruby-debug/commands/irb.rb +123 -0
  28. data/cli/ruby-debug/commands/jump.rb +66 -0
  29. data/cli/ruby-debug/commands/kill.rb +51 -0
  30. data/cli/ruby-debug/commands/list.rb +94 -0
  31. data/cli/ruby-debug/commands/method.rb +84 -0
  32. data/cli/ruby-debug/commands/quit.rb +39 -0
  33. data/cli/ruby-debug/commands/reload.rb +40 -0
  34. data/cli/ruby-debug/commands/save.rb +90 -0
  35. data/cli/ruby-debug/commands/set.rb +221 -0
  36. data/cli/ruby-debug/commands/show.rb +247 -0
  37. data/cli/ruby-debug/commands/skip.rb +35 -0
  38. data/cli/ruby-debug/commands/source.rb +36 -0
  39. data/cli/ruby-debug/commands/stepping.rb +81 -0
  40. data/cli/ruby-debug/commands/threads.rb +189 -0
  41. data/cli/ruby-debug/commands/tmate.rb +36 -0
  42. data/cli/ruby-debug/commands/trace.rb +57 -0
  43. data/cli/ruby-debug/commands/variables.rb +199 -0
  44. data/cli/ruby-debug/debugger.rb +5 -0
  45. data/cli/ruby-debug/helper.rb +69 -0
  46. data/cli/ruby-debug/interface.rb +232 -0
  47. data/cli/ruby-debug/processor.rb +474 -0
  48. data/configure.ac +12 -0
  49. data/debugger.gemspec +24 -0
  50. data/doc/.cvsignore +42 -0
  51. data/doc/Makefile.am +63 -0
  52. data/doc/emacs-notes.txt +38 -0
  53. data/doc/hanoi.rb +35 -0
  54. data/doc/primes.rb +28 -0
  55. data/doc/rdebug-emacs.texi +1030 -0
  56. data/doc/rdebug.1 +241 -0
  57. data/doc/ruby-debug.texi +3791 -0
  58. data/doc/test-tri2.rb +18 -0
  59. data/doc/tri3.rb +8 -0
  60. data/doc/triangle.rb +12 -0
  61. data/emacs/Makefile.am +130 -0
  62. data/emacs/rdebug-annotate.el +385 -0
  63. data/emacs/rdebug-breaks.el +407 -0
  64. data/emacs/rdebug-cmd.el +92 -0
  65. data/emacs/rdebug-core.el +502 -0
  66. data/emacs/rdebug-dbg.el +62 -0
  67. data/emacs/rdebug-error.el +79 -0
  68. data/emacs/rdebug-fns.el +111 -0
  69. data/emacs/rdebug-frames.el +230 -0
  70. data/emacs/rdebug-gud.el +242 -0
  71. data/emacs/rdebug-help.el +104 -0
  72. data/emacs/rdebug-info.el +83 -0
  73. data/emacs/rdebug-layouts.el +180 -0
  74. data/emacs/rdebug-locring.el +118 -0
  75. data/emacs/rdebug-output.el +106 -0
  76. data/emacs/rdebug-regexp.el +118 -0
  77. data/emacs/rdebug-secondary.el +260 -0
  78. data/emacs/rdebug-shortkey.el +175 -0
  79. data/emacs/rdebug-source.el +568 -0
  80. data/emacs/rdebug-track.el +392 -0
  81. data/emacs/rdebug-varbuf.el +150 -0
  82. data/emacs/rdebug-vars.el +125 -0
  83. data/emacs/rdebug-watch.el +132 -0
  84. data/emacs/rdebug.el +326 -0
  85. data/emacs/test/elk-test.el +242 -0
  86. data/emacs/test/test-annotate.el +103 -0
  87. data/emacs/test/test-cmd.el +116 -0
  88. data/emacs/test/test-core.el +104 -0
  89. data/emacs/test/test-fns.el +65 -0
  90. data/emacs/test/test-frames.el +62 -0
  91. data/emacs/test/test-gud.el +35 -0
  92. data/emacs/test/test-indent.el +58 -0
  93. data/emacs/test/test-regexp.el +144 -0
  94. data/emacs/test/test-shortkey.el +61 -0
  95. data/ext/ruby_debug/breakpoint.c +586 -0
  96. data/ext/ruby_debug/extconf.rb +49 -0
  97. data/ext/ruby_debug/ruby_debug.c +2624 -0
  98. data/ext/ruby_debug/ruby_debug.h +148 -0
  99. data/lib/ChangeLog +1065 -0
  100. data/lib/debugger.rb +7 -0
  101. data/lib/debugger/version.rb +3 -0
  102. data/lib/ruby-debug-base.rb +304 -0
  103. data/rdbg.rb +33 -0
  104. data/runner.sh +7 -0
  105. data/svn2cl_usermap +3 -0
  106. data/test/.cvsignore +1 -0
  107. data/test/base/base.rb +74 -0
  108. data/test/base/binding.rb +31 -0
  109. data/test/base/catchpoint.rb +26 -0
  110. data/test/base/load.rb +40 -0
  111. data/test/bp_loop_issue.rb +3 -0
  112. data/test/classes.rb +11 -0
  113. data/test/cli/commands/catchpoint_test.rb +36 -0
  114. data/test/cli/commands/unit/regexp.rb +42 -0
  115. data/test/config.yaml +8 -0
  116. data/test/data/annotate.cmd +29 -0
  117. data/test/data/annotate.right +139 -0
  118. data/test/data/break_bad.cmd +18 -0
  119. data/test/data/break_bad.right +28 -0
  120. data/test/data/break_loop_bug.cmd +5 -0
  121. data/test/data/break_loop_bug.right +15 -0
  122. data/test/data/breakpoints.cmd +38 -0
  123. data/test/data/breakpoints.right +98 -0
  124. data/test/data/catch.cmd +20 -0
  125. data/test/data/catch.right +49 -0
  126. data/test/data/catch2.cmd +19 -0
  127. data/test/data/catch2.right +65 -0
  128. data/test/data/catch3.cmd +11 -0
  129. data/test/data/catch3.right +37 -0
  130. data/test/data/condition.cmd +28 -0
  131. data/test/data/condition.right +65 -0
  132. data/test/data/ctrl.cmd +23 -0
  133. data/test/data/ctrl.right +70 -0
  134. data/test/data/display.cmd +24 -0
  135. data/test/data/display.right +44 -0
  136. data/test/data/dollar-0.right +2 -0
  137. data/test/data/dollar-0a.right +2 -0
  138. data/test/data/dollar-0b.right +2 -0
  139. data/test/data/edit.cmd +12 -0
  140. data/test/data/edit.right +19 -0
  141. data/test/data/emacs_basic.cmd +43 -0
  142. data/test/data/emacs_basic.right +106 -0
  143. data/test/data/enable.cmd +20 -0
  144. data/test/data/enable.right +36 -0
  145. data/test/data/finish.cmd +16 -0
  146. data/test/data/finish.right +31 -0
  147. data/test/data/frame.cmd +26 -0
  148. data/test/data/frame.right +55 -0
  149. data/test/data/help.cmd +20 -0
  150. data/test/data/help.right +21 -0
  151. data/test/data/history.right +7 -0
  152. data/test/data/info-thread.cmd +13 -0
  153. data/test/data/info-thread.right +37 -0
  154. data/test/data/info-var-bug2.cmd +5 -0
  155. data/test/data/info-var-bug2.right +10 -0
  156. data/test/data/info-var.cmd +23 -0
  157. data/test/data/info-var.right +52 -0
  158. data/test/data/info.cmd +21 -0
  159. data/test/data/info.right +65 -0
  160. data/test/data/jump.cmd +16 -0
  161. data/test/data/jump.right +56 -0
  162. data/test/data/jump2.cmd +16 -0
  163. data/test/data/jump2.right +44 -0
  164. data/test/data/linetrace.cmd +6 -0
  165. data/test/data/linetrace.right +23 -0
  166. data/test/data/list.cmd +19 -0
  167. data/test/data/list.right +127 -0
  168. data/test/data/method.cmd +10 -0
  169. data/test/data/method.right +21 -0
  170. data/test/data/methodsig.cmd +10 -0
  171. data/test/data/methodsig.right +20 -0
  172. data/test/data/next.cmd +22 -0
  173. data/test/data/next.right +61 -0
  174. data/test/data/noquit.right +1 -0
  175. data/test/data/output.cmd +6 -0
  176. data/test/data/output.right +31 -0
  177. data/test/data/pm-bug.cmd +7 -0
  178. data/test/data/pm-bug.right +12 -0
  179. data/test/data/post-mortem-next.cmd +8 -0
  180. data/test/data/post-mortem-next.right +14 -0
  181. data/test/data/post-mortem-osx.right +31 -0
  182. data/test/data/post-mortem.cmd +13 -0
  183. data/test/data/post-mortem.right +32 -0
  184. data/test/data/quit.cmd +6 -0
  185. data/test/data/quit.right +0 -0
  186. data/test/data/raise.cmd +11 -0
  187. data/test/data/raise.right +23 -0
  188. data/test/data/save.cmd +34 -0
  189. data/test/data/save.right +59 -0
  190. data/test/data/scope-var.cmd +42 -0
  191. data/test/data/scope-var.right +587 -0
  192. data/test/data/setshow.cmd +56 -0
  193. data/test/data/setshow.right +98 -0
  194. data/test/data/source.cmd +5 -0
  195. data/test/data/source.right +15 -0
  196. data/test/data/stepping.cmd +21 -0
  197. data/test/data/stepping.right +50 -0
  198. data/test/data/test-init-cygwin.right +7 -0
  199. data/test/data/test-init-osx.right +4 -0
  200. data/test/data/test-init.right +5 -0
  201. data/test/data/trace.right +14 -0
  202. data/test/dollar-0.rb +5 -0
  203. data/test/gcd-dbg-nox.rb +31 -0
  204. data/test/gcd-dbg.rb +30 -0
  205. data/test/gcd.rb +18 -0
  206. data/test/helper.rb +144 -0
  207. data/test/info-var-bug.rb +47 -0
  208. data/test/info-var-bug2.rb +2 -0
  209. data/test/jump.rb +14 -0
  210. data/test/jump2.rb +27 -0
  211. data/test/next.rb +18 -0
  212. data/test/null.rb +1 -0
  213. data/test/output.rb +2 -0
  214. data/test/pm-base.rb +22 -0
  215. data/test/pm-bug.rb +3 -0
  216. data/test/pm-catch.rb +12 -0
  217. data/test/pm-catch2.rb +27 -0
  218. data/test/pm-catch3.rb +47 -0
  219. data/test/pm.rb +11 -0
  220. data/test/raise.rb +3 -0
  221. data/test/rdebug-save.1 +7 -0
  222. data/test/runall +12 -0
  223. data/test/scope-var.rb +29 -0
  224. data/test/tdebug.rb +248 -0
  225. data/test/test-annotate.rb +25 -0
  226. data/test/test-break-bad.rb +37 -0
  227. data/test/test-breakpoints.rb +25 -0
  228. data/test/test-catch.rb +25 -0
  229. data/test/test-catch2.rb +25 -0
  230. data/test/test-catch3.rb +25 -0
  231. data/test/test-condition.rb +25 -0
  232. data/test/test-ctrl.rb +55 -0
  233. data/test/test-display.rb +26 -0
  234. data/test/test-dollar-0.rb +40 -0
  235. data/test/test-edit.rb +26 -0
  236. data/test/test-emacs-basic.rb +26 -0
  237. data/test/test-enable.rb +25 -0
  238. data/test/test-finish.rb +34 -0
  239. data/test/test-frame.rb +34 -0
  240. data/test/test-help.rb +60 -0
  241. data/test/test-hist.rb +68 -0
  242. data/test/test-info-thread.rb +32 -0
  243. data/test/test-info-var.rb +47 -0
  244. data/test/test-info.rb +26 -0
  245. data/test/test-init.rb +44 -0
  246. data/test/test-jump.rb +35 -0
  247. data/test/test-list.rb +25 -0
  248. data/test/test-method.rb +34 -0
  249. data/test/test-next.rb +25 -0
  250. data/test/test-output.rb +26 -0
  251. data/test/test-quit.rb +30 -0
  252. data/test/test-raise.rb +25 -0
  253. data/test/test-save.rb +31 -0
  254. data/test/test-scope-var.rb +25 -0
  255. data/test/test-setshow.rb +25 -0
  256. data/test/test-source.rb +25 -0
  257. data/test/test-stepping.rb +26 -0
  258. data/test/test-trace.rb +47 -0
  259. data/test/thread1.rb +26 -0
  260. data/test/trunc-call.rb +31 -0
  261. metadata +364 -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