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,62 @@
1
+ ;;; rdebug-dbg.el --- Ruby debugger frames buffer
2
+
3
+ ;; Copyright (C) 2008 Rocky Bernstein (rocky@gnu.org)
4
+ ;; Copyright (C) 2008 Anders Lindgren
5
+
6
+ ;; $Id: rdebug-dbg.el 702 2008-02-17 22:00:36Z 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 internal debug trace support.
28
+
29
+ ;;; Code:
30
+
31
+ (require 'rdebug-vars)
32
+
33
+ (defun rdebug-debug-message (&rest args)
34
+ (if rdebug-debug-active
35
+ (let ((buf (get-buffer-create "*Xrdebug*")))
36
+ (with-current-buffer buf
37
+ (save-excursion
38
+ (goto-char (point-max))
39
+ ;; 32 = space.
40
+ (insert (make-string (* 4 rdebug-debug-depth) 32))
41
+ (insert (apply #'format args))
42
+ (insert "\n"))))))
43
+
44
+
45
+ (defmacro rdebug-debug-enter (str &rest body)
46
+ (declare (indent 1) (debug t))
47
+ `(progn
48
+ (rdebug-debug-message "--> %s" ,str)
49
+ (setq rdebug-debug-depth (+ rdebug-debug-depth 1))
50
+ (unwind-protect
51
+ (progn
52
+ ,@body)
53
+ (setq rdebug-debug-depth (max 0 (- rdebug-debug-depth 1)))
54
+ (rdebug-debug-message "<-- %s" ,str))))
55
+
56
+ (provide 'rdebug-dbg)
57
+
58
+ ;;; Local variables:
59
+ ;;; eval:(put 'rdebug-debug-enter 'lisp-indent-hook 1)
60
+ ;;; End:
61
+
62
+ ;;; rdebug-dbg.el ends here
@@ -0,0 +1,79 @@
1
+ ;;; rdebug-error.el --- Ruby debugger error buffer
2
+
3
+ ;; Copyright (C) 2008 Rocky Bernstein (rocky@gnu.org)
4
+ ;; Copyright (C) 2008 Anders Lindgren
5
+
6
+ ;; $Id: rdebug-error.el 713 2008-02-21 02:56:48Z 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 with the error secondary buffer.
28
+
29
+ ;;; Code:
30
+
31
+ (require 'rdebug-dbg)
32
+ (require 'rdebug-fns)
33
+ (require 'rdebug-secondary)
34
+ (require 'rdebug-source)
35
+
36
+ (defun rdebug-display-error-buffer ()
37
+ "Display the rdebug error buffer."
38
+ (interactive)
39
+ (rdebug-display-secondary-buffer "error"))
40
+
41
+ (defvar rdebug-error-mode-map
42
+ (let ((map (make-sparse-keymap)))
43
+ (rdebug-populate-secondary-buffer-map map)
44
+ map)
45
+ "Keymap used in the error buffer in the `rdebug' Ruby debugger.")
46
+
47
+ (defun rdebug-error-mode ()
48
+ "Major mode for displaying the script error in the `rdebug' Ruby debugger.
49
+
50
+ \\{rdebug-error-mode}"
51
+ (interactive)
52
+ (kill-all-local-variables)
53
+ (setq major-mode 'rdebug-error-mode)
54
+ (setq mode-name "RDEBUG Error")
55
+ (setq buffer-read-only t)
56
+ (set (make-local-variable 'rdebug-secondary-buffer) t)
57
+ (setq mode-line-process 'rdebug-mode-line-process)
58
+ (use-local-map rdebug-error-mode-map)
59
+ (run-mode-hooks 'rdebug-error-mode-hook))
60
+
61
+ (defun rebug-setup-error-buffer (buf comint-buffer)
62
+ (rdebug-debug-enter "rebug-setup-error-buffer"
63
+ (with-current-buffer buf
64
+ (rdebug-error-mode)
65
+ (set (make-local-variable 'gud-comint-buffer) comint-buffer))))
66
+
67
+ (defun rdebug-errmsg (msg)
68
+ ;;; (with-current-buffer (rdebug-get-buffer "error" gud-target-name)
69
+ ;;; (goto-char (point-max))
70
+ ;;; (insert msg))
71
+ (message (chomp msg)))
72
+
73
+ (provide 'rdebug-error)
74
+
75
+ ;;; Local variables:
76
+ ;;; eval:(put 'rdebug-debug-enter 'lisp-indent-hook 1)
77
+ ;;; End:
78
+
79
+ ;;; rdebug-error.el ends here
@@ -0,0 +1,111 @@
1
+ ;;; rdebug-fns.el --- Ruby debugger miscellaneous functions
2
+
3
+ ;; Copyright (C) 2008 Rocky Bernstein (rocky@gnu.org)
4
+ ;; Copyright (C) 2008 Anders Lindgren
5
+
6
+ ;; $Id: rdebug-frames.el 711 2008-02-20 07:09:17Z andersl $
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 with the frames secondary buffer.
28
+
29
+ ;;; Code:
30
+
31
+ (require 'gud)
32
+ (require 'rdebug-vars)
33
+
34
+ (defun chomp(string &optional multiple)
35
+ "Remove trailing \n if it's there"
36
+ (if multiple
37
+ (progn
38
+ (while (and (> (length string) 0)
39
+ (eq (elt string (- (length string) 1)) ?\n))
40
+ (setq string (substring string 0 -1)))
41
+ string)
42
+ (if (> (length string) 0)
43
+ (let ((s string))
44
+ (if (string= "\n" (substring s -1))
45
+ (substring s 0 -1)
46
+ s))
47
+ "")))
48
+
49
+ (defun rdebug-dead-process-p ()
50
+ "Return true if the rdebug comint-process is dead or exited."
51
+ ;; FIXME? Use a variable in gud-comint-buffer's status?
52
+ (or (not gud-comint-buffer)
53
+ (null (get-buffer-process gud-comint-buffer))
54
+ (not (member (process-status gud-comint-buffer) '(run open)))))
55
+
56
+ (defun rdebug-get-secondary-buffer-name (name)
57
+ "Get the rdebug NAME secondary buffer. If none found return nil."
58
+ (let ((target-name
59
+ (or (and gud-comint-buffer
60
+ (buffer-local-value 'gud-target-name
61
+ gud-comint-buffer))
62
+ gud-target-name)))
63
+ (cond ((and (string= "cmd" name) gud-comint-buffer)
64
+ (buffer-name gud-comint-buffer))
65
+ (t (format "*rdebug-%s-%s*" name target-name)))))
66
+
67
+ (defun rdebug-set-frame-top-arrow (buf)
68
+ "Set the fringe arrow in BUF to indicate the top frame."
69
+ (with-current-buffer buf
70
+ (setq fringe-indicator-alist
71
+ '((overlay-arrow . right-triangle)))))
72
+
73
+ (defun rdebug-set-frame-not-top-arrow (buf)
74
+ "Set the fringe arrow in BUF to indicate a frame other than the top frame."
75
+ (with-current-buffer buf
76
+ (setq fringe-indicator-alist
77
+ '((overlay-arrow . hollow-right-triangle)))))
78
+
79
+ (defun rdebug-set-frame-arrow (buf)
80
+ "Set the fringe arrow in buffer BUF."
81
+ (if (equal 0 rdebug-frames-current-frame-number)
82
+ (rdebug-set-frame-top-arrow buf)
83
+ (rdebug-set-frame-not-top-arrow buf)))
84
+
85
+ ;; From Emacs 23
86
+ (unless (fboundp 'split-string-and-unquote)
87
+ (defun split-string-and-unquote (string &optional separator)
88
+ "Split the STRING into a list of strings.
89
+ It understands Emacs Lisp quoting within STRING, such that
90
+ (split-string-and-unquote (combine-and-quote-strings strs)) == strs
91
+ The SEPARATOR regexp defaults to \"\\s-+\"."
92
+ (let ((sep (or separator "\\s-+"))
93
+ (i (string-match "[\"]" string)))
94
+ (if (null i)
95
+ (split-string string sep t) ; no quoting: easy
96
+ (append (unless (eq i 0) (split-string (substring string 0 i) sep t))
97
+ (let ((rfs (read-from-string string i)))
98
+ (cons (car rfs)
99
+ (with-no-warnings
100
+ (split-string-and-unquote (substring string (cdr rfs))
101
+ sep))))))))
102
+ )
103
+
104
+
105
+ (provide 'rdebug-fns)
106
+
107
+ ;;; Local variables:
108
+ ;;; eval:(put 'rdebug-debug-enter 'lisp-indent-hook 1)
109
+ ;;; End:
110
+
111
+ ;;; rdebug-fns.el ends here
@@ -0,0 +1,230 @@
1
+ ;;; rdebug-frames.el --- Ruby debugger frames buffer
2
+
3
+ ;; Copyright (C) 2008 Rocky Bernstein (rocky@gnu.org)
4
+ ;; Copyright (C) 2008 Anders Lindgren
5
+
6
+ ;; $Id: rdebug-frames.el 735 2008-02-29 15:24:51Z 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 with the frames secondary buffer.
28
+
29
+ ;;; Code:
30
+
31
+ (require 'rdebug-dbg)
32
+ (require 'rdebug-fns)
33
+ (require 'rdebug-regexp)
34
+ (require 'rdebug-secondary)
35
+ (require 'rdebug-source)
36
+
37
+ (defun rdebug-display-frame-buffer ()
38
+ "Display the rdebug stack-frame buffer."
39
+ (interactive)
40
+ (rdebug-display-secondary-buffer "frame"))
41
+
42
+ (defvar rdebug-frames-mode-map
43
+ (let ((map (make-sparse-keymap)))
44
+ (define-key map [double-mouse-1] 'rdebug-goto-frame-mouse)
45
+ (define-key map [mouse-2] 'rdebug-goto-frame-mouse)
46
+ (define-key map [mouse-3] 'rdebug-goto-frame-mouse)
47
+ (define-key map [(control m)] 'rdebug-goto-frame)
48
+ (define-key map "0" 'rdebug-goto-frame-n)
49
+ (define-key map "1" 'rdebug-goto-frame-n)
50
+ (define-key map "2" 'rdebug-goto-frame-n)
51
+ (define-key map "3" 'rdebug-goto-frame-n)
52
+ (define-key map "4" 'rdebug-goto-frame-n)
53
+ (define-key map "5" 'rdebug-goto-frame-n)
54
+ (define-key map "6" 'rdebug-goto-frame-n)
55
+ (define-key map "7" 'rdebug-goto-frame-n)
56
+ (define-key map "8" 'rdebug-goto-frame-n)
57
+ (define-key map "9" 'rdebug-goto-frame-n)
58
+ (rdebug-populate-secondary-buffer-map map)
59
+
60
+ ;; --------------------
61
+ ;; The "Stack window" submenu.
62
+ (let ((submenu (make-sparse-keymap)))
63
+ (define-key-after map [menu-bar debugger stack]
64
+ (cons "Stack window" submenu)
65
+ 'placeholder))
66
+
67
+ (define-key map [menu-bar debugger stack goto]
68
+ '(menu-item "Goto frame" rdebug-goto-frame))
69
+ map)
70
+ "Keymap to navigate rdebug stack frames.")
71
+
72
+ (defun rdebug-goto-frame (pt)
73
+ "Show the rdebug stack frame corresponding at PT in the rdebug stack buffer."
74
+ (interactive "d")
75
+ (save-excursion
76
+ (goto-char pt)
77
+ (let ((s (concat "-->" (buffer-substring (line-beginning-position)
78
+ (line-end-position))))
79
+ (s2 (if (= (line-number-at-pos (line-end-position 2))
80
+ (line-number-at-pos (point-max)))
81
+ nil
82
+ ;;else
83
+ (buffer-substring (line-beginning-position 2)
84
+ (line-end-position 2)))))
85
+ (when (or (string-match rdebug-stack-frame-regexp s)
86
+ ;; need to match 1st line last to get the match position right
87
+ (and s2 (string-match rdebug-stack-frame-2nd-regexp s2)
88
+ (string-match rdebug-stack-frame-1st-regexp s)))
89
+ (let ((frame (substring s (match-beginning 2) (match-end 2))))
90
+ (gud-call (concat "frame " frame)))))))
91
+
92
+ (defun rdebug-goto-frame-mouse (event)
93
+ "Show the rdebug stack frame under the mouse in the rdebug stack buffer."
94
+ (interactive "e")
95
+ (with-current-buffer (window-buffer (posn-window (event-end event)))
96
+ (rdebug-goto-frame (posn-point (event-end event)))))
97
+
98
+ ;; The following is split in two to facilitate debugging.
99
+ (defun rdebug-goto-frame-n-internal (keys)
100
+ (if (and (stringp keys)
101
+ (= (length keys) 1))
102
+ (progn
103
+ (setq rdebug-goto-entry-acc (concat rdebug-goto-entry-acc keys))
104
+ ;; Try to find the longest suffix.
105
+ (let ((acc rdebug-goto-entry-acc))
106
+ (while (not (string= acc ""))
107
+ (if (not (rdebug-goto-entry-try acc))
108
+ (setq acc (substring acc 1))
109
+ (gud-call (format "frame %s" acc))
110
+ ;; Break loop.
111
+ (setq acc "")))))
112
+ (message "`rdebug-goto-frame-n' must be bound to a number key")))
113
+
114
+ (defun rdebug-goto-frame-n ()
115
+ "Go to the frame number indicated by the accumulated numeric keys just entered.
116
+
117
+ This function is usually bound to a numeric key in a 'frame'
118
+ secondary buffer. To go to an entry above 9, just keep entering
119
+ the number. For example, if you press 1 and then 9, frame 1 is selected
120
+ \(if it exists) and then frame 19 (if that exists). Entering any
121
+ non-digit will start entry number from the beginning again."
122
+ (interactive)
123
+ (if (not (eq last-command 'rdebug-goto-frame-n))
124
+ (setq rdebug-goto-entry-acc ""))
125
+ (rdebug-goto-frame-n-internal (this-command-keys)))
126
+
127
+ (defun rdebug-frames-match-current-line (limit)
128
+ (and rdebug-frames-current-frame-number
129
+ (re-search-forward
130
+ (concat "^ *#"
131
+ (number-to-string rdebug-frames-current-frame-number)
132
+ ;; At least one space (so that we don't match #1 when looking for #10).
133
+ " +"
134
+ ;; The entire line.
135
+ ".*"
136
+ "\n"
137
+ ;; And the next, if this entry was split into two.
138
+ "\\( *[^# ].*$\\)?") limit t)))
139
+
140
+ (defvar rdebug-frames-current-frame-face 'highlight)
141
+
142
+ ;; Example of frame buffer content:
143
+ ;;
144
+ ;; #0 Integer.under_cover at line test.rb:13
145
+ ;; #1 ClassA::Nested::DeepDown.under_cover(p#ClassA::Nested::DeepD...)
146
+ ;; at line test.rb:12
147
+ ;; #2 Object.sune(s#String, i#Fixnum) at line test.rb:24
148
+ ;; #3 at line test.rb:27
149
+
150
+ (defvar rdebug-frames-font-lock-keywords
151
+ '(
152
+ ;; Parameters and first type entry.
153
+ ("\\<\\([a-zA-Z_][a-zA-Z0-9_]*\\)#\\([a-zA-Z_][a-zA-Z0-9_]*\\)\\>"
154
+ (1 font-lock-variable-name-face)
155
+ (2 font-lock-type-face))
156
+ ;; "::Type", which occurs in class name of function and in parameter list.
157
+ ("::\\([a-zA-Z_][a-zA-Z0-9_]*\\)"
158
+ (1 font-lock-type-face))
159
+ ;; The frame number and first type name, if present.
160
+ ("^ *#\\([0-9]+\\) *\\(\\([a-zA-Z_][a-zA-Z0-9_]*\\)[.:]\\)?"
161
+ (1 font-lock-constant-face)
162
+ (3 font-lock-type-face nil t)) ; t means optional.
163
+ ;; File name and line number.
164
+ ("at line \\(.*\\):\\([0-9]+\\)$"
165
+ (1 font-lock-warning-face)
166
+ (2 font-lock-constant-face))
167
+ ;; Function name.
168
+ ("\\<\\([a-zA-Z_][a-zA-Z0-9_]*\\)\\.\\([a-zA-Z_][a-zA-Z0-9_]*\\)"
169
+ (1 font-lock-type-face)
170
+ (2 font-lock-function-name-face))
171
+ (rdebug-frames-match-current-line
172
+ (0 rdebug-frames-current-frame-face append)))
173
+ "Font-lock rules for the stack frame window in `rdebug'.")
174
+
175
+ (defun rdebug-frames-mode ()
176
+ "Major mode for displaying the stack trace in the `rdebug' Ruby debugger.
177
+ \\{rdebug-frames-mode-map}"
178
+ (interactive)
179
+ (kill-all-local-variables)
180
+ (setq major-mode 'rdebug-frames-mode)
181
+ (setq mode-name "RDEBUG Stack Frames")
182
+ (set (make-local-variable 'rdebug-secondary-buffer) t)
183
+ (setq mode-line-process 'rdebug-mode-line-process)
184
+ (use-local-map rdebug-frames-mode-map)
185
+ (set (make-local-variable 'font-lock-defaults)
186
+ '(rdebug-frames-font-lock-keywords))
187
+ (run-mode-hooks 'rdebug-frames-mode-hook))
188
+
189
+ ;; Note: This function can't restore the original point alone, since
190
+ ;; the point is already at the end of the buffer when this is called.
191
+ (defun rdebug-setup-frame-buffer (buf comint-buffer)
192
+ "Find the current frame and display the corresponding source line.
193
+
194
+ Also, cleans the buffer somewhat and sets up help for the font-lock rules."
195
+ (rdebug-debug-enter "rdebug-setup-stack-buffer"
196
+ (with-current-buffer buf
197
+ (let ((inhibit-read-only t)
198
+ (current-frame-number 0))
199
+ (rdebug-frames-mode)
200
+ (set (make-local-variable 'gud-comint-buffer) comint-buffer)
201
+ (goto-char (point-min))
202
+ (when (re-search-forward "-->" nil t)
203
+ (beginning-of-line)
204
+ (setq overlay-arrow-position (make-marker))
205
+ (set-marker overlay-arrow-position (point))
206
+ (when (looking-at rdebug-stack-frame-1st-regexp)
207
+ (setq current-frame-number
208
+ (string-to-number
209
+ (match-string rdebug-stack-frame-number-group)))
210
+ (set (make-local-variable 'rdebug-frames-current-frame-number)
211
+ current-frame-number)
212
+ (with-current-buffer comint-buffer
213
+ (setq rdebug-frames-current-frame-number current-frame-number))
214
+ (when gud-last-frame
215
+ (rdebug-set-frame-arrow (gud-find-file (car gud-last-frame))))
216
+ (rdebug-set-frame-arrow buf)))
217
+ ;; Remove initial ' ' or '-->'.
218
+ (save-excursion
219
+ (goto-char (point-max))
220
+ (beginning-of-line)
221
+ (if (> (point) 4)
222
+ (delete-rectangle 4 (point))))))))
223
+
224
+ (provide 'rdebug-frames)
225
+
226
+ ;;; Local variables:
227
+ ;;; eval:(put 'rdebug-debug-enter 'lisp-indent-hook 1)
228
+ ;;; End:
229
+
230
+ ;;; rdebug-frames.el ends here