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,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