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,118 @@
1
+ ;;; rdebug-locring.el --- Ruby debugger location ring
2
+
3
+ ;; Copyright (C) 2008, 2009 Rocky Bernstein (rocky@gnu.org)
4
+ ;; Copyright (C) 2008 Anders Lindgren
5
+
6
+ ;; $Id: rdebug-locring.el 917 2009-03-31 09:49:37Z 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
+ ;; This file manages a ring of (recently stopped) positions to allow
26
+ ;; the programmer to move back and forth between them.
27
+
28
+ ;;; Code:
29
+
30
+ (defvar rdebug-source-location-ring nil
31
+ "Ring of the last `rdebug-source-location-ring-size' positions we've stopped aft.")
32
+
33
+ (defvar rdebug-source-location-ring-index -1
34
+ "Position in `rdebug-source-location-ring' of where we are.")
35
+
36
+ (defun rdebug-locring-add (frame location-history-ring)
37
+ "Add FRAME to LOCATION-HISTORY-RING if we are on the top frame and have a frame to add."
38
+ ;; Switching frames shouldn't save a new ring
39
+ ;; position. Also make sure no position is different.
40
+ ;; Perhaps duplicates should be controlled by an option.
41
+ (unless (and (not (ring-empty-p location-history-ring))
42
+ (equal (ring-ref location-history-ring
43
+ (ring-length location-history-ring)) frame))
44
+ (ring-insert-at-beginning location-history-ring frame)))
45
+
46
+ (defun rdebug-locring-clear ()
47
+ "Clear out all source locations in `Go to the source location of the first stopping point."
48
+ (interactive)
49
+ (setq rdebug-source-location-ring-index -1)
50
+ (while (not (ring-empty-p rdebug-source-location-ring))
51
+ (ring-remove rdebug-source-location-ring)))
52
+
53
+ (defun rdebug-locring-goto (ring-position)
54
+ "Go the source position RING-POSITION in the stopping history."
55
+ (interactive "NSource location ring position (0 is oldest): ")
56
+ (with-current-buffer gud-comint-buffer
57
+ (setq rdebug-source-location-ring-index ring-position)
58
+ (let* ((frame (ring-ref rdebug-source-location-ring ring-position))
59
+ (file (car frame))
60
+ (line (cdr frame)))
61
+ (when file
62
+ (rdebug-display-line file line)
63
+ (message (format "%d %s:%d" rdebug-source-location-ring-index
64
+ file line))))))
65
+
66
+ (defun rdebug-locring-newer ()
67
+ "Cycle through source location stopping history to get the next newer (more recently visited) location."
68
+ (interactive)
69
+ (with-current-buffer gud-comint-buffer
70
+ (if (equal (+ 1 rdebug-source-location-ring-index)
71
+ (ring-length rdebug-source-location-ring))
72
+ (progn
73
+ (message "At newest - Will set to wrap to oldest.")
74
+ (setq rdebug-source-location-ring-index -1))
75
+ ;; else
76
+ (rdebug-locring-goto
77
+ (if (> rdebug-source-location-ring-index
78
+ (ring-length rdebug-source-location-ring))
79
+ 0
80
+ ;; else
81
+ (ring-plus1 rdebug-source-location-ring-index
82
+ (ring-length rdebug-source-location-ring)))))))
83
+
84
+ (defun rdebug-locring-newest ()
85
+ "Go to the source location of the first stopping point."
86
+ (interactive)
87
+ (rdebug-locring-goto (- (ring-length rdebug-source-location-ring) 1)))
88
+
89
+ (defun rdebug-locring-older ()
90
+ "Cycle through source location stopping history to get the next older (least recently visited) location."
91
+ (interactive)
92
+ (with-current-buffer gud-comint-buffer
93
+ (if (equal rdebug-source-location-ring-index 0)
94
+ (progn
95
+ (message "At oldest - Will set to wrap to newest.")
96
+ (setq rdebug-source-location-ring-index
97
+ (+ 1 (ring-length rdebug-source-location-ring))))
98
+ ;; else
99
+ (rdebug-locring-goto
100
+ (if (or (not rdebug-source-location-ring-index)
101
+ (< rdebug-source-location-ring-index 0))
102
+ 0
103
+ ;; else
104
+ (ring-minus1 rdebug-source-location-ring-index
105
+ (ring-length rdebug-source-location-ring)))))))
106
+
107
+ (defun rdebug-locring-oldest ()
108
+ "Go to the oldest source position location."
109
+ (interactive)
110
+ (ring-ref rdebug-source-location-ring 0))
111
+
112
+ (provide 'rdebug-locring)
113
+
114
+ ;;; Local variables:
115
+ ;;; eval:(put 'rdebug-debug-enter 'lisp-indent-hook 1)
116
+ ;;; End:
117
+
118
+ ;;; rdebug-locring.el ends here
@@ -0,0 +1,106 @@
1
+ ;;; rdebug-output.el --- Ruby debugger output buffer
2
+
3
+ ;; Copyright (C) 2008 Rocky Bernstein (rocky@gnu.org)
4
+ ;; Copyright (C) 2008 Anders Lindgren
5
+
6
+ ;; $Id: rdebug-output.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 output secondary buffer.
28
+
29
+ ;;; Code:
30
+
31
+ (require 'rdebug-dbg)
32
+ (require 'rdebug-secondary)
33
+
34
+ (defun rdebug-display-output-buffer ()
35
+ "Display the rdebug output buffer."
36
+ (interactive)
37
+ (rdebug-display-secondary-buffer "output"))
38
+
39
+ ;; FIXME add a macro to toggle read-only and run command.
40
+ (defun rdebug-output-add-divider ()
41
+ (interactive "")
42
+ (save-excursion
43
+ (goto-char (point-max))
44
+ (setq buffer-read-only nil)
45
+ ;; FIXME Cooler would be to pick up stack position in stack line
46
+ ;; and prepend a buffer-local marker number
47
+ (insert (format "%d: ============================\n"
48
+ rdebug-output-marker-number))
49
+ (setq rdebug-output-marker-number (+ rdebug-output-marker-number 1))
50
+ (setq buffer-read-only t)))
51
+
52
+ (defun rdebug-output-delete-output ()
53
+ (interactive)
54
+ (setq buffer-read-only nil)
55
+ (delete-region (point-min) (point-max))
56
+ (setq buffer-read-only t))
57
+
58
+ (defun rdebug-output-undo () ;FIXME make more global?
59
+ (interactive "")
60
+ (setq buffer-read-only nil)
61
+ (undo)
62
+ (setq buffer-read-only t))
63
+
64
+ (defvar rdebug-output-mode-map
65
+ (let ((map (make-sparse-keymap)))
66
+ (define-key map "d" 'rdebug-output-delete-output)
67
+ (define-key map "t" 'rdebug-goto-traceback-line)
68
+ (define-key map "!" 'rdebug-goto-dollarbang-traceback-line)
69
+ (define-key map "=" 'rdebug-output-add-divider)
70
+ (define-key map "\C-_" 'rdebug-output-undo) ; FIXME get from keymap
71
+ (define-key map "u" 'rdebug-output-undo)
72
+ (suppress-keymap map)
73
+ (rdebug-populate-secondary-buffer-map map)
74
+ map)
75
+ "Keymap used in the output buffer in the `rdebug' Ruby debugger.")
76
+
77
+ (defun rdebug-output-mode ()
78
+ "Major mode for displaying the script output in the `rdebug' Ruby debugger.
79
+
80
+ \\{rdebug-output-mode}"
81
+ (interactive)
82
+ (let ((old-marker-number rdebug-output-marker-number))
83
+ (kill-all-local-variables)
84
+ (setq major-mode 'rdebug-output-mode)
85
+ (setq mode-name "RDEBUG Output")
86
+ (setq buffer-read-only t)
87
+ (set (make-local-variable 'rdebug-secondary-buffer) t)
88
+ (setq mode-line-process 'rdebug-mode-line-process)
89
+ (set (make-local-variable 'rdebug-accumulative-buffer) t)
90
+ (use-local-map rdebug-output-mode-map)
91
+ (set (make-local-variable 'rdebug-output-marker-number) old-marker-number)
92
+ (run-mode-hooks 'rdebug-output-mode-hook)))
93
+
94
+ (defun rdebug-setup-output-buffer (buf comint-buffer)
95
+ (rdebug-debug-enter "rdebug-setup-output-buffer"
96
+ (with-current-buffer buf
97
+ (rdebug-output-mode)
98
+ (set (make-local-variable 'gud-comint-buffer) comint-buffer))))
99
+
100
+ (provide 'rdebug-output)
101
+
102
+ ;;; Local variables:
103
+ ;;; eval:(put 'rdebug-debug-enter 'lisp-indent-hook 1)
104
+ ;;; End:
105
+
106
+ ;;; rdebug-output.el ends here
@@ -0,0 +1,118 @@
1
+ ;;; rdebug-regexp.el --- Ruby debugger regular expressions
2
+
3
+ ;; Copyright (C) 2007, 2008 Rocky Bernstein (rocky@gnu.org)
4
+ ;; Copyright (C) 2007, 2008 Anders Lindgren
5
+
6
+ ;; $Id: rdebug-regexp.el 724 2008-02-24 16:14:52Z 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
+ ;; Here we have regular expressions and names for matched patterns
28
+ ;; of those regular expressions.
29
+
30
+ ;;; Code:
31
+
32
+ ;; -------------------------------------------------------------------
33
+ ;; Variables defining regular expressions (regexp:s).
34
+ ;;
35
+
36
+ (defconst gud-rdebug-marker-regexp
37
+ "\\(?:source \\)?\\(\\(?:[a-zA-Z]:\\)?[^:\n]*\\):\\([0-9]*\\).*\n"
38
+ "Regular expression used to find a file location given by rdebug.
39
+
40
+ Program-location lines look like this:
41
+ source /tmp/gcd.rb:29: gcd
42
+ /tmp/gcd.rb:29: gcd
43
+ source /tmp/gcd.rb:29
44
+ source C:/tmp/gcd.rb:29
45
+ source \\sources\\capfilterscanner\\capanalyzer.rb:3: <module>")
46
+
47
+ (defconst rdebug-annotation-end-regexp
48
+ "\n"
49
+ "Regular expression to match the end of an annotation.")
50
+
51
+ ;; Examples of annotations:
52
+ ;; ^Z^Z\n
53
+ ;; ^Z^Zfoo\n
54
+ ;; ^Z^Zpre-prompt\n
55
+ ;; ^Z^Zsource foo.rb:10\n
56
+
57
+ (defconst rdebug-annotation-start-regexp
58
+ "\\(\\([a-z][-a-z]*\\)?\n\\|source \\)"
59
+ "Regular expression to match the start of an annotation.")
60
+
61
+ (defconst rdebug-breakpoint-regexp
62
+ "^\\ +\\([0-9]+\\) \\([yn]\\) +at +\\(.+\\):\\([0-9]+\\)\\( if .*\\)?$"
63
+ "Regexp to recognize breakpoint lines in rdebug breakpoint buffers.")
64
+
65
+ (defconst rdebug-marker-regexp-file-group 2
66
+ "Group position in `rdebug-position-regexp' that matches the file name.")
67
+
68
+ (defconst rdebug-marker-regexp-line-group 3
69
+ "Group position in `rdebug-position-regexp' that matches the line number.")
70
+
71
+ (defconst rdebug-position-regexp
72
+ "\\(\\)\\([-a-zA-Z0-9_/.]*\\):\\([0-9]+\\)"
73
+ "Regular expression for a rdebug position.")
74
+
75
+ (defconst rdebug-traceback-line-re
76
+ "^[ \t]+from \\([^:]+\\):\\([0-9]+\\)\\( in `.*'\\)?"
77
+ "Regular expression that describes a Ruby traceback line.")
78
+
79
+ (defconst rdebug-dollarbang-traceback-line-re
80
+ "^[ \t]+[[]?\\([^:]+\\):\\([0-9]+\\):in `.*'"
81
+ "Regular expression that describes a Ruby traceback line from $! list.")
82
+
83
+ (defconst rdebug-stack-frame-1st-regexp
84
+ "^\\(-->\\| \\) +#\\([0-9]+\\)\\(.*\\)"
85
+ "Regexp to match the first line of a stack frame in rdebug stack buffers.")
86
+
87
+ (defconst rdebug-stack-frame-number-group 2
88
+ "The group position in `rdebug-stack-frame-1st-regexp' that matches the frame number.")
89
+
90
+ (defconst rdebug-stack-frame-2nd-regexp
91
+ "\s+at line +\\([^:]+\\):\\([0-9]+\\)$"
92
+ "Regexp to match the second line of a stack frame in rdebug stack buffers.")
93
+
94
+ (defconst rdebug-stack-frame-2nd-file-group 1
95
+ "Group position in `rdebug-stack-frame-2nd-regexp' that matches the file name.")
96
+
97
+ (defconst rdebug-stack-frame-2nd-line-group 2
98
+ "Group position in `rdebug-stack-frame-2nd-regexp' that matches the line number.")
99
+ (defconst rdebug-stack-frame-regexp
100
+ (concat rdebug-stack-frame-1st-regexp rdebug-stack-frame-2nd-regexp)
101
+ "Regexp to recognize a stack frame line in rdebug stack buffers.")
102
+
103
+ (defconst rdebug-stack-frame-file-group 4
104
+ "Group position in `rdebug-stack-frame-regexp' that matches the file name.")
105
+
106
+ (defconst rdebug-stack-frame-line-group 5
107
+ "Group position in `rdebug-stack-frame-regexp' that matches the line number.")
108
+
109
+ (defconst rdebug-input-prompt-regexp "(+rdb:\\([0-9]+\\|post-mortem\\)) "
110
+ "Regular expression to recognize a rdebug prompt. Some uses may prepend an anchor to the front.")
111
+
112
+ (provide 'rdebug-regexp)
113
+
114
+ ;;; Local variables:
115
+ ;;; eval:(put 'rdebug-debug-enter 'lisp-indent-hook 1)
116
+ ;;; End:
117
+
118
+ ;;; rdebug-regexp.el ends here
@@ -0,0 +1,260 @@
1
+ ;;; rdebug-secondary.el --- Rdebug support windows.
2
+
3
+ ;; Copyright (C) 2008 Rocky Bernstein (rocky@gnu.org)
4
+ ;; Copyright (C) 2008 Anders Lindgren
5
+
6
+ ;; $Id: rdebug-secondary.el 733 2008-02-29 04:34:44Z 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
+ ;; Key bindings and menu for secondary buffers.
28
+
29
+ ;;; Code:
30
+
31
+ (require 'rdebug)
32
+
33
+ (defun rdebug-populate-secondary-buffer-map (map)
34
+ "Bind all common keys and menu used in the rdebug secondary buffers.
35
+ This includes the keys bound to `gud-key-prefix' (typically C-x
36
+ C-a)."
37
+ (rdebug-populate-secondary-buffer-map-plain map)
38
+ (rdebug-populate-common-keys map)
39
+ (rdebug-populate-debugger-menu map)
40
+ (let ((prefix-map (make-sparse-keymap)))
41
+ (rdebug-populate-secondary-buffer-map-plain prefix-map)
42
+ (define-key map gud-key-prefix prefix-map)))
43
+
44
+
45
+ (defun rdebug-display-cmd-buffer ()
46
+ "Display the rdebug debugger command buffer."
47
+ (interactive)
48
+ (rdebug-display-secondary-buffer "cmd"))
49
+
50
+ (defun rdebug-pick-secondary-window-categorize (win name orig-win)
51
+ "Return how suiteable this window is to display the a secondary buffer.
52
+ The higher score the better."
53
+ (let ((buffer (window-buffer win)))
54
+ (save-current-buffer
55
+ (set-buffer buffer)
56
+ (cond (rdebug-secondary-buffer
57
+ (cond ((eq win orig-win)
58
+ ;; If the user issued the command inside a
59
+ ;; secondary window, use that window.
60
+ 5)
61
+ ((and (member name '("variables" "watch"))
62
+ (memq major-mode '(rdebug-variables-mode
63
+ rdebug-watch-mode)))
64
+ ;; Let "Watch" and "Variables" switch content.
65
+ 4)
66
+ (t
67
+ ;; Any other secondary window.
68
+ 3)))
69
+ ((eq major-mode 'ruby-mode)
70
+ ;; Avoid source windows.
71
+ 0)
72
+ ((eq major-mode 'gud-mode)
73
+ ;; Avoid the debugger shell window.
74
+ 1)
75
+ (t
76
+ ;; Just any other window.
77
+ 2)))))
78
+
79
+
80
+ (defun rdebug-display-secondary-buffer (name)
81
+ "Display one of the rdebug secondary buffers.
82
+ If the buffer doesn't exist, do nothing. If the buffer is already
83
+ displayed, switch to it. Otherwise if the current buffer is a
84
+ secondary buffer, bury it replacing with the requested
85
+ buffer. Failing that, if there is secondary buffer visible, that
86
+ is replaced instead. And finally failing all of the preceding,
87
+ we'll just pick a visible buffer to bury and replace."
88
+ (let* ((buf-name (rdebug-get-secondary-buffer-name name))
89
+ (buf (get-buffer buf-name))
90
+ (orig-win (selected-window)))
91
+ (if (null buf)
92
+ (message "Buffer %s not found" buf-name)
93
+ ;; Find a suitable window to display the buffer in.
94
+ (let ((win (get-buffer-window buf (selected-frame))))
95
+ (if win
96
+ ;; Buffer already displayed, switch to it.
97
+ (select-window win)
98
+ ;;
99
+ (let ((candidate nil)
100
+ (candidate-score -1))
101
+ (dolist (win (window-list (selected-frame)))
102
+ (let ((score (rdebug-pick-secondary-window-categorize
103
+ win name orig-win)))
104
+ (if (> score candidate-score)
105
+ (progn
106
+ (setq candidate win)
107
+ (setq candidate-score score)))))
108
+ (select-window candidate)))))
109
+ (switch-to-buffer buf)))
110
+
111
+
112
+ ;; Note: The generic `gud' framework contains special code to handle
113
+ ;; this for GDB (see `gud-display-line') which we, unfortuately can't
114
+ ;; use. Instead, we call `rdebug-pick-source-window' from
115
+ ;; `gud-rdebug-marker-filter'. When gud becomes more generic we could
116
+ ;; hopefully solve this in another way.
117
+ ;;
118
+ ;; The machanism is that `rdebug-pick-source-window' displays the
119
+ ;; source file in the window of our choice, and gud kindly re-uses
120
+ ;; that window.
121
+
122
+
123
+ (defun rdebug-display-source-window-categorize (win)
124
+ "Return how suitable this window WIN is to display the source buffer.
125
+ The higher score the better."
126
+ (let ((buffer (window-buffer win)))
127
+ (cond ((eq buffer gud-comint-buffer)
128
+ 0)
129
+ ((buffer-local-value 'rdebug-secondary-buffer buffer)
130
+ 1)
131
+ ((eq (buffer-local-value 'major-mode buffer) 'ruby-mode)
132
+ 3) ; Pick me! Pick me!
133
+ (t
134
+ 2))))
135
+
136
+ (defun rdebug-display-pick-source-window ()
137
+ "Return the window that should get replaced by the source window."
138
+ (rdebug-debug-enter "rdebug-display-pick-source-window"
139
+ (let ((candidate nil)
140
+ (candidate-score -1))
141
+ (dolist (win (window-list (selected-frame)))
142
+ (let ((score
143
+ (rdebug-display-source-window-categorize win)))
144
+ (if (> score candidate-score)
145
+ (progn
146
+ (setq candidate win)
147
+ (setq candidate-score score)))))
148
+ candidate)))
149
+
150
+ (defun rdebug-frame-source-buffer (frame)
151
+ "Return the buffer corresponding to the source file given in FRAME, or nil if none."
152
+ (and frame
153
+ gud-comint-buffer
154
+ (save-current-buffer
155
+ (set-buffer gud-comint-buffer)
156
+ (gud-find-file (car frame)))))
157
+
158
+
159
+ (defun rdebug-current-source-buffer ()
160
+ "Return the latest source buffer, or nil."
161
+ (or (rdebug-frame-source-buffer gud-last-frame)
162
+ (rdebug-frame-source-buffer gud-last-last-frame)))
163
+
164
+
165
+ (defun rdebug-display-source-buffer ()
166
+ "Display the current source buffer."
167
+ (interactive)
168
+ (rdebug-debug-enter "rdebug-display-source-buffer"
169
+ (let ((buffer (rdebug-current-source-buffer))
170
+ (last-buffer (rdebug-frame-source-buffer gud-last-last-frame)))
171
+ (if buffer
172
+ (let ((window
173
+ (or
174
+ ;; Buffer is already visible, re-use the window.
175
+ (get-buffer-window buffer)
176
+ ;; Re-use the last window
177
+ (and last-buffer
178
+ (get-buffer-window last-buffer))
179
+ ;; Find a non-rdebug window.
180
+ (rdebug-display-pick-source-window))))
181
+ (select-window window)
182
+ (switch-to-buffer buffer))))))
183
+
184
+
185
+ (defun rdebug-pick-source-window ()
186
+ "Display the source file, but do not switch window."
187
+ (save-selected-window
188
+ (rdebug-display-source-buffer)))
189
+
190
+
191
+ (defun rdebug-display-source-buffer-resync ()
192
+ "Resync output and display the source buffer."
193
+ (interactive)
194
+ (call-interactively 'gud-source-resync)
195
+ (rdebug-display-source-buffer))
196
+
197
+
198
+ (defun rdebug-delete-frame-or-window ()
199
+ "Delete frame if there is only one window. Otherwise delete the window."
200
+ (interactive)
201
+ (if (one-window-p) (delete-frame)
202
+ (delete-window)))
203
+
204
+ (defun rdebug-goto-entry-try (str)
205
+ "See if thre is an entry with number STR. If not return nil."
206
+ (goto-char (point-min))
207
+ (if (re-search-forward (concat "^[^0-9]*\\(" str "\\)[^0-9]") nil t)
208
+ (progn
209
+ (goto-char (match-end 1))
210
+ t)
211
+ nil))
212
+
213
+
214
+ ;; The following is split in two to facilitate debugging.
215
+ (defun rdebug-goto-entry-n-internal (keys)
216
+ (if (and (stringp keys)
217
+ (= (length keys) 1))
218
+ (progn
219
+ (setq rdebug-goto-entry-acc (concat rdebug-goto-entry-acc keys))
220
+ ;; Try to find the longest suffix.
221
+ (let ((acc rdebug-goto-entry-acc)
222
+ (p (point)))
223
+ (while (not (string= acc ""))
224
+ (if (not (rdebug-goto-entry-try acc))
225
+ (setq acc (substring acc 1))
226
+ (setq p (point))
227
+ ;; Break loop.
228
+ (setq acc "")))
229
+ (goto-char p)))
230
+ (message "`rdebug-goto-entry-n' must be bound to a number key")))
231
+
232
+
233
+ (defun rdebug-goto-entry-n ()
234
+ "Go to an entry number.
235
+
236
+ Breakpoints, Display expressions and Stack Frames all have
237
+ numbers associated with them which are distinct from line
238
+ numbers. In a secondary buffer, this function is usually bound to
239
+ a numeric key which will position you at that entry number. To
240
+ go to an entry above 9, just keep entering the number. For
241
+ example, if you press 1 and then 9, you should jump to entry
242
+ 1 (if it exists) and then 19 (if that exists). Entering any
243
+ non-digit will start entry number from the beginning again."
244
+ (interactive)
245
+ (if (not (eq last-command 'rdebug-goto-entry-n))
246
+ (setq rdebug-goto-entry-acc ""))
247
+ (rdebug-goto-entry-n-internal (this-command-keys)))
248
+
249
+
250
+ ;; -------------------------------------------------------------------
251
+ ;; The end.
252
+ ;;
253
+
254
+ (provide 'rdebug-secondary)
255
+
256
+ ;;; Local variables:
257
+ ;;; eval:(put 'rdebug-debug-enter 'lisp-indent-hook 1)
258
+ ;;; End:
259
+
260
+ ;;; rdebug-secondary.el ends here