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,392 @@
1
+ ;;; rdebug-track.el --- Tracking the Ruby debugger from a shell
2
+ ;; $Id: rdebug-track.el 909 2009-03-11 18:57:08Z rockyb $
3
+
4
+ ;; Copyright (C) 2006, 2007, 2008 Rocky Bernstein (rocky@gnu.org)
5
+ ;; Copyright (C) 2007, 2008 Anders Lindgren
6
+ ;; Modified from python-mode in particular the part:
7
+ ;; pdbtrack support contributed by Ken Manheimer, April 2001.
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
+ ;; See the manual and the file `rdebug.el' for more information.
27
+
28
+ ;; `rdebug-track-mode' allows access to full debugger user interface
29
+ ;; for Ruby debugger sessions started in a standard shell window.
30
+ ;; `turn-on-rdebug-track-mode' turns the mode on and
31
+ ;; `turn-off-rdebug-track-mode' turns it off.
32
+ ;;
33
+ ;;; Customization:
34
+ ;; `rdebug-track' sets whether file tracking is done by the shell prompt.
35
+ ;; `rdebug-track-minor-mode-string' sets the mode indicator to show that
36
+ ;; tracking is in effect.
37
+ ;;
38
+
39
+ ;;; Code:
40
+
41
+ ;; -------------------------------------------------------------------
42
+ ;; Customizable variables.
43
+ ;;
44
+
45
+ (defgroup rdebug-track nil
46
+ "Ruby debug and rdebug file tracking by watching the shell prompt."
47
+ :prefix "rdebug-track"
48
+ :group 'shell)
49
+
50
+ (defcustom rdebug-track-do-tracking-p nil
51
+ "*Controls whether the rdebug-track feature is enabled or not.
52
+ When non-nil, rdebug-track is enabled in all comint-based buffers,
53
+ e.g. shell buffers and the *Ruby* buffer. When using rdebug to debug a
54
+ Ruby program, rdebug-track notices the rdebug prompt and displays the
55
+ source file and line that the program is stopped at, much the same way
56
+ as gud-mode does for debugging C programs with gdb."
57
+ :type 'boolean
58
+ :group 'rdebug)
59
+ (make-variable-buffer-local 'rdebug-track-do-tracking-p)
60
+
61
+ (defcustom rdebug-track-minor-mode-string " rdebug"
62
+ "*String to use in the minor mode list when rdebug-track is enabled."
63
+ :type 'string
64
+ :group 'rdebug)
65
+
66
+
67
+ ;; -------------------------------------------------------------------
68
+ ;; Variables.
69
+ ;;
70
+
71
+ (defvar gud-rdebug-history nil
72
+ "History of argument lists passed to rdebug.")
73
+
74
+ ;; rdebug-track constants
75
+ (defconst rdebug-track-stack-entry-regexp
76
+ "^(\\([-a-zA-Z0-9_/.]*\\):\\([0-9]+\\)):[ \t]?\\(.*\n\\)"
77
+ "Regular expression rdebug-track uses to find a stack trace entry.")
78
+
79
+ (defconst rdebug-track-track-range 10000
80
+ "Max number of characters from end of buffer to search for stack entry.")
81
+
82
+
83
+ ;; -------------------------------------------------------------------
84
+ ;; Dependencies.
85
+ ;;
86
+
87
+ (require 'comint)
88
+ (require 'custom)
89
+ (require 'cl)
90
+ (require 'compile)
91
+ (require 'gud)
92
+ (require 'shell)
93
+ (require 'rdebug-breaks)
94
+ (require 'rdebug-cmd)
95
+ (require 'rdebug-core)
96
+
97
+
98
+ ;; -------------------------------------------------------------------
99
+ ;; Rdebug track -- support for attaching the `rdebug' ruby debugger to
100
+ ;; a process running in a shell buffer.
101
+ ;;
102
+
103
+ (defvar rdebug-track-is-tracking-p t)
104
+
105
+ (defun rdebug-track-overlay-arrow (activation)
106
+ "Activate or de arrow at beginning-of-line in current buffer."
107
+ ;; This was derived/simplified from edebug-overlay-arrow
108
+ (cond (activation
109
+ (setq overlay-arrow-position (make-marker))
110
+ (setq overlay-arrow-string "=>")
111
+ (set-marker overlay-arrow-position (point) (current-buffer))
112
+ (setq rdebug-track-is-tracking-p t))
113
+ (rdebug-track-is-tracking-p
114
+ (setq overlay-arrow-position nil)
115
+ (setq rdebug-track-is-tracking-p nil))
116
+ ))
117
+
118
+ (defun rdebug-track-track-stack-file (text)
119
+ "Show the file indicated by the rdebug stack entry line, in a separate window.
120
+ Activity is disabled if the buffer-local variable
121
+ `rdebug-track-do-tracking-p' is nil.
122
+
123
+ We depend on the rdebug input prompt matching `rdebug-input-prompt-regexp'
124
+ at the beginning of the line."
125
+ ;; Instead of trying to piece things together from partial text
126
+ ;; (which can be almost useless depending on Emacs version), we
127
+ ;; monitor to the point where we have the next rdebug prompt, and then
128
+ ;; check all text from comint-last-input-end to process-mark.
129
+ ;;
130
+ ;; Also, we're very conservative about clearing the overlay arrow,
131
+ ;; to minimize residue. This means, for instance, that executing
132
+ ;; other rdebug commands wipe out the highlight. You can always do a
133
+ ;; 'where' (aka 'w') command to reveal the overlay arrow.
134
+ (rdebug-debug-enter "rdebug-track-track-stack-file"
135
+ (let* ((origbuf (current-buffer))
136
+ (currproc (get-buffer-process origbuf)))
137
+
138
+ (if (not (and currproc rdebug-track-do-tracking-p))
139
+ (rdebug-track-overlay-arrow nil)
140
+ ;;else
141
+ (let* ((procmark (process-mark currproc))
142
+ (block-start (max comint-last-input-end
143
+ (- procmark rdebug-track-track-range)))
144
+ (block-str (buffer-substring block-start procmark))
145
+ target target_fname target_lineno target_buffer)
146
+
147
+ (if (not (string-match rdebug-input-prompt-regexp block-str))
148
+ (rdebug-track-overlay-arrow nil)
149
+ ;;else
150
+ (setq target (rdebug-track-get-source-buffer block-str))
151
+
152
+ (if (stringp target)
153
+ (rdebug-debug-message "rdebug-track: %s" target)
154
+ ;;else
155
+ (gud-rdebug-marker-filter block-str)
156
+ (setq target_lineno (car target))
157
+ (setq target_buffer (cadr target))
158
+ (setq target_fname (buffer-file-name target_buffer))
159
+ (setq gud-last-frame (cons target_fname target_lineno))
160
+ (switch-to-buffer-other-window target_buffer)
161
+ (goto-line target_lineno)
162
+ (rdebug-debug-message "rdebug-track: line %s, file %s"
163
+ target_lineno target_fname)
164
+ (rdebug-track-overlay-arrow t)
165
+ (rdebug-set-frame-top-arrow (current-buffer))
166
+ (set (make-local-variable 'gud-comint-buffer) origbuf)
167
+ (set (make-local-variable 'gud-delete-prompt-marker)
168
+ (make-marker))
169
+ (pop-to-buffer origbuf t)
170
+ (rdebug-locring-add gud-last-frame
171
+ rdebug-source-location-ring))
172
+
173
+ ;; Delete processed annotations from buffer.
174
+ (save-excursion
175
+ (let ((annotate-start)
176
+ (annotate-end (point-max)))
177
+ (goto-char block-start)
178
+ (while (re-search-forward
179
+ rdebug-annotation-start-regexp annotate-end t)
180
+ (let* ((start (match-beginning 0))
181
+ (end (match-end 0))
182
+ (name (or (match-string 1) "source")))
183
+ (cond ((string= name "prompt\n")
184
+ (delete-region (- start 1) end))
185
+ ((string= name "pre-prompt\n")
186
+ (delete-region start end))
187
+ ((string= name "error-begin\n")
188
+ (delete-region start end))
189
+ ((re-search-forward rdebug-annotation-end-regexp
190
+ annotate-end t)
191
+ (delete-region start (point)))
192
+ (t (forward-line)))))))
193
+ ))))))
194
+
195
+ (defun rdebug-track-get-source-buffer (block-str)
196
+ "Return line and buffer of code indicated by block-str's traceback text.
197
+
198
+ We look first to visit the file indicated in the trace.
199
+
200
+ Failing that, we look for the most recently visited ruby-mode buffer
201
+ with the same name or having having the named function.
202
+
203
+ If we're unable find the source code we return a string describing the
204
+ problem as best as we can determine."
205
+
206
+ (if (not (string-match rdebug-position-regexp block-str))
207
+ "line number cue not found"
208
+ ;;else
209
+ (let* ((filename (match-string rdebug-marker-regexp-file-group block-str))
210
+ (lineno (string-to-number
211
+ (match-string rdebug-marker-regexp-line-group block-str)))
212
+ funcbuffer)
213
+
214
+ (cond ((file-exists-p filename)
215
+ (list lineno (find-file-noselect filename)))
216
+
217
+ ((= (elt filename 0) ?\<)
218
+ (format "(Non-file source: '%s')" filename))
219
+
220
+ (t (format "Not found: %s" filename))))))
221
+
222
+
223
+
224
+ ;; -----------------------------------------------
225
+ ;; Rdebug track mode
226
+ ;;
227
+
228
+
229
+ (defcustom rdebug-track-mode-text " rdebug"
230
+ "*String to display in the mode line when rdebug-track mode is active.
231
+
232
+ \(When the string is not empty, make sure that it has a leading space.)"
233
+ :tag "rdebug mode text" ; To separate it from `global-...'
234
+ :group 'rdebug
235
+ :type 'string)
236
+
237
+ (define-minor-mode rdebug-track-mode
238
+ "Minor mode for tracking ruby debugging inside a process shell."
239
+ :init-value nil
240
+ ;; The indicator for the mode line.
241
+ :lighter rdebug-track-mode-text
242
+ ;; The minor mode bindings.
243
+ :global nil
244
+ :group 'rdebug
245
+ (rdebug-track-toggle-stack-tracking 1)
246
+ (setq rdebug-track-is-tracking-p t)
247
+ (local-set-key "\C-cg" 'rdebug-goto-traceback-line)
248
+ (local-set-key "\C-cG" 'rdebug-goto-dollarbang-traceback-line)
249
+
250
+ (add-hook 'comint-output-filter-functions 'rdebug-track-track-stack-file)
251
+ (run-mode-hooks 'rdebug-track-mode-hook))
252
+
253
+
254
+ (defun rdebug-track-toggle-stack-tracking (arg)
255
+ (interactive "P")
256
+ (if (not (get-buffer-process (current-buffer)))
257
+ (message "No process associated with buffer '%s'" (current-buffer))
258
+ ;;else
259
+ ;; missing or 0 is toggle, >0 turn on, <0 turn off
260
+ (if (or (not arg)
261
+ (zerop (setq arg (prefix-numeric-value arg))))
262
+ (setq rdebug-track-do-tracking-p (not rdebug-track-do-tracking-p))
263
+ (setq rdebug-track-do-tracking-p (> arg 0)))
264
+ (message "%sabled rdebug's rdebug-track"
265
+ (if rdebug-track-do-tracking-p "En" "Dis"))))
266
+
267
+
268
+ ;;;###autoload
269
+ (defun turn-on-rdebug-track-mode ()
270
+ "Turn on rdebug-track mode.
271
+
272
+ This function is designed to be added to hooks, for example:
273
+ (add-hook 'comint-mode-hook 'turn-on-rdebug-track-mode)"
274
+ (interactive)
275
+ (set (make-local-variable 'gud-last-last-frame) nil)
276
+ (set (make-local-variable 'gud-last-frame) nil)
277
+ (set (make-local-variable 'gud-comint-buffer) (current-buffer))
278
+
279
+ (set (make-local-variable 'gud-marker-filter) 'gud-rdebug-marker-filter)
280
+ (set (make-local-variable 'gud-minor-mode) 'rdebug)
281
+ (set (make-local-variable 'comint-prompt-regexp) (concat "^" rdebug-input-prompt-regexp))
282
+
283
+ (set (make-local-variable 'gud-find-file) 'gud-rdebug-find-file)
284
+
285
+ (rdebug-command-initialization)
286
+
287
+ (rdebug-track-mode 1))
288
+
289
+
290
+ (defun turn-off-rdebug-track-mode ()
291
+ "Turn off rdebug-track mode."
292
+ (interactive)
293
+ (setq rdebug-track-is-tracking-p nil)
294
+
295
+ (rdebug-track-toggle-stack-tracking 0)
296
+ (if (local-variable-p 'gud-last-frame)
297
+ (setq gud-last-frame nil))
298
+ (while (not (ring-empty-p rdebug-source-location-ring))
299
+ (ring-remove rdebug-source-location-ring))
300
+ (remove-hook 'comint-output-filter-functions
301
+ 'rdebug-track-track-stack-file))
302
+
303
+
304
+ ;; -----------------------------------------------
305
+ ;; The `attach' function.
306
+ ;;
307
+
308
+ (defun rdebug-track-attach (&optional name rename-shell)
309
+ "Do things to make the current process buffer work like a
310
+ rdebug command buffer. In particular, the buffer is renamed,
311
+ gud-mode is set, and rdebug-track-mode is turned on, among other
312
+ things. When `rdebug-many-windows' is non-nil, the initial debugger
313
+ window layout is used."
314
+ (interactive "sProgram name: ")
315
+ (rdebug-debug-enter "rdebug-set-windows"
316
+ (rdebug-set-window-configuration-state 'debugger t)
317
+
318
+ ;; from rdebug-common-init
319
+ (gud-mode)
320
+ (set (make-local-variable 'gud-marker-filter) 'gud-rdebug-marker-filter)
321
+ (set (make-local-variable 'gud-minor-mode) 'rdebug)
322
+ (set (make-local-variable 'gud-last-frame) nil)
323
+ (set (make-local-variable 'gud-last-last-frame) nil)
324
+
325
+ (set (make-local-variable 'gud-find-file) 'gud-rdebug-find-file)
326
+ (set-process-filter (get-buffer-process (current-buffer)) 'gud-filter)
327
+ (gud-set-buffer)
328
+ ;;
329
+
330
+ (rdebug-track-mode 1)
331
+ (rdebug-command-initialization)
332
+
333
+ (when name
334
+ (if rename-shell
335
+ (rename-buffer (format "*rdebug-cmd-%s*" gud-target-name)))
336
+ (setq gud-target-name name)
337
+ (setq gud-comint-buffer (current-buffer)))
338
+
339
+ ;; Setup exit callback so that the original frame configuration
340
+ ;; can be restored.
341
+ (let ((process (get-buffer-process gud-comint-buffer)))
342
+ (when process
343
+ (unless (equal rdebug-line-width 120)
344
+ (gud-call (format "set width %d" rdebug-line-width)))
345
+ (set-process-sentinel process
346
+ 'rdebug-process-sentinel)))
347
+
348
+ (when gud-last-frame
349
+ (setq gud-last-last-frame gud-last-frame))
350
+
351
+ ;; Add the buffer-displaying commands to the Gud buffer,
352
+ ;; FIXME: combine with code in rdebug-track.el; make common
353
+ ;; command buffer mode map.
354
+ (let ((prefix-map (make-sparse-keymap))
355
+ (map (current-local-map)))
356
+ (define-key map [M-down] 'rdebug-locring-newer)
357
+ (define-key map [M-up] 'rdebug-locring-older)
358
+ (define-key map [M-S-down] 'rdebug-locring-newest)
359
+ (define-key map [M-S-up] 'rdebug-locring-oldest)
360
+ (define-key map gud-key-prefix prefix-map)
361
+ (define-key prefix-map "t" 'rdebug-goto-traceback-line)
362
+ (define-key prefix-map "!" 'rdebug-goto-dollarbang-traceback-line)
363
+
364
+ (rdebug-populate-secondary-buffer-map-plain prefix-map))
365
+
366
+ (rdebug-populate-common-keys (current-local-map))
367
+ (rdebug-populate-debugger-menu (current-local-map))
368
+
369
+ (set (make-local-variable 'comint-prompt-regexp) (concat "^" rdebug-input-prompt-regexp))
370
+ (setq paragraph-start comint-prompt-regexp)
371
+
372
+ (setcdr (assq 'rdebug-debugger-support-minor-mode minor-mode-map-alist)
373
+ rdebug-debugger-support-minor-mode-map-when-active)
374
+
375
+ (gud-call "set annotate 3")
376
+ (gud-call "frame 0")
377
+ (when rdebug-many-windows
378
+ (rdebug-setup-windows))
379
+ (run-hooks 'rdebug-mode-hook)))
380
+
381
+
382
+ ;; -------------------------------------------------------------------
383
+ ;; The end.
384
+ ;;
385
+
386
+ (provide 'rdebug-track)
387
+
388
+ ;;; Local variables:
389
+ ;;; eval:(put 'rdebug-debug-enter 'lisp-indent-hook 1)
390
+ ;;; End:
391
+
392
+ ;;; rdebug-track.el ends here
@@ -0,0 +1,150 @@
1
+ ;;; rdebug-varbuf.el --- This file contains code dealing with the Ruby
2
+ ;;; debugger's "variables" secondary buffer.
3
+
4
+ ;; Copyright (C) 2008 Rocky Bernstein (rocky@gnu.org)
5
+ ;; Copyright (C) 2008 Anders Lindgren
6
+
7
+ ;; $Id: rdebug-varbuf.el 711 2008-02-20 07:09:17Z andersl $
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
+ ;; See the manual and the file `rdebug.el' for more information.
27
+
28
+ ;;; Code:
29
+
30
+ (defvar rdebug-variables-mode-map
31
+ (let ((map (make-sparse-keymap)))
32
+ (suppress-keymap map)
33
+ (define-key map "\r" 'rdebug-variables-edit)
34
+ ;; (define-key map "e" 'rdebug-edit-variables-value)
35
+ (define-key map [mouse-2] 'rdebug-variables-edit-mouse)
36
+ (define-key map "e" 'rdebug-variables-print)
37
+ (define-key map "x" 'rdebug-variables-pretty-print)
38
+ (rdebug-populate-secondary-buffer-map map)
39
+
40
+ ;; --------------------
41
+ ;; The "Variables window" submenu.
42
+
43
+ (let ((submenu (make-sparse-keymap)))
44
+ (define-key-after map [menu-bar debugger variables]
45
+ (cons "Variables window" submenu)
46
+ 'placeholder))
47
+
48
+ (define-key map [menu-bar debugger variables edit]
49
+ '(menu-item "Edit" rdebug-variables-edit
50
+ :enable (eq major-mode 'rdebug-variables-mode)))
51
+
52
+ map)
53
+ "Keymap used in the variables buffer in the `rdebug' Ruby debugger.")
54
+
55
+ (defvar rdebug-variables-font-lock-keywords
56
+ '(("@[a-zA-Z0-9_]+" 0 font-lock-variable-name-face)
57
+ ("\\<\\(nil\\|true\\|false\\)\\>" 0 font-lock-constant-face)
58
+ ("#<\\([a-zA-Z0-9_]+\\):\\([0-9a-fx]*\\)"
59
+ (1 font-lock-type-face)
60
+ (2 font-lock-constant-face)))
61
+ "Font-lock rules for the variables and watch windows in `rdebug'.")
62
+
63
+ (defun rdebug-display-variables-buffer ()
64
+ "Display the rdebug variables buffer."
65
+ (interactive)
66
+ (rdebug-display-secondary-buffer "variables"))
67
+
68
+ (defun rdebug-variables-mode ()
69
+ "Major mode for the variables buffer in the `rdebug' Ruby debugger.
70
+
71
+ \\{rdebug-variables-mode-map}"
72
+ (interactive)
73
+ (kill-all-local-variables)
74
+ (setq major-mode 'rdebug-variables-mode)
75
+ (setq mode-name "RDEBUG Variables")
76
+ (setq buffer-read-only t)
77
+ (setq truncate-lines t)
78
+ (set (make-local-variable 'rdebug-secondary-buffer) t)
79
+ (setq mode-line-process 'rdebug-mode-line-process)
80
+ (set (make-local-variable 'font-lock-defaults)
81
+ '(rdebug-variables-font-lock-keywords))
82
+ (use-local-map rdebug-variables-mode-map)
83
+ (run-mode-hooks 'rdebug-variables-mode-hook))
84
+
85
+ (defun rdebug-setup-variables-buffer (buf comint-buffer)
86
+ (rdebug-debug-enter "rdebug-setup-variables-buffer"
87
+ (with-current-buffer buf
88
+ (rdebug-variables-mode)
89
+ (set (make-local-variable 'gud-comint-buffer) comint-buffer))))
90
+
91
+ (defun rdebug-variables-edit-mouse (&optional event)
92
+ "Assign a value to a variable displayed in the variables buffer.
93
+ This function is intended to be bound to a mouse key"
94
+ (interactive (list last-input-event))
95
+ (save-excursion
96
+ (if event (posn-set-point (event-end event)))
97
+ (call-interactively 'rdebug-variables-edit)))
98
+
99
+ (defun rdebug-variables-edit (var value)
100
+ "Assign a value to a variable displayed in the variables buffer."
101
+ (interactive
102
+ (let ((var nil)
103
+ (value nil))
104
+ (save-excursion
105
+ (beginning-of-line)
106
+ (when (looking-at "^\\(@?[a-zA-Z_0-9]+\\) *= *\\(.*\\)$")
107
+ (setq var (match-string 1))
108
+ (setq value (match-string 2))
109
+ (setq value (read-from-minibuffer
110
+ (format "New value (%s): " var) value)))
111
+ (list var value))))
112
+ (gud-call (format "p %s=%s" var value)))
113
+
114
+ (defun rdebug-variables-pretty-print (var)
115
+ "Pretty print a variable in the variables buffer."
116
+ (interactive
117
+ (let ((var nil))
118
+ (save-excursion
119
+ (beginning-of-line)
120
+ (when (looking-at "^\\(@?[a-zA-Z_0-9]+\\) *= *\\(.*\\)$")
121
+ (setq var (match-string 1)))
122
+ (list var))))
123
+ (rdebug-print-cmd var "pp"))
124
+
125
+ (defun rdebug-variables-pretty-print-mouse (&optional event)
126
+ "Assign a value to a variable displayed in the variables buffer.
127
+ This function is intended to be bound to a mouse key"
128
+ (interactive (list last-input-event))
129
+ (save-excursion
130
+ (if event (posn-set-point (event-end event)))
131
+ (call-interactively 'rdebug-variables-pretty-print)))
132
+
133
+ (defun rdebug-variables-print (var)
134
+ "Print a variable in the variables buffer."
135
+ (interactive
136
+ (let ((var nil))
137
+ (save-excursion
138
+ (beginning-of-line)
139
+ (when (looking-at "^\\(@?[a-zA-Z_0-9]+\\) *= *\\(.*\\)$")
140
+ (setq var (match-string 1)))
141
+ (list var))))
142
+ (rdebug-print-cmd var "p"))
143
+
144
+ (provide 'rdebug-varbuf)
145
+
146
+ ;;; Local variables:
147
+ ;;; eval:(put 'rdebug-debug-enter 'lisp-indent-hook 1)
148
+ ;;; End:
149
+
150
+ ;;; rdebug-varbuf.el ends here