debugger2 1.0.0.beta1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +12 -0
- data/.travis.yml +3 -0
- data/AUTHORS +10 -0
- data/CHANGELOG.md +65 -0
- data/CONTRIBUTING.md +1 -0
- data/Gemfile +3 -0
- data/LICENSE +23 -0
- data/OLDER_CHANGELOG +334 -0
- data/OLD_CHANGELOG +5655 -0
- data/OLD_README +122 -0
- data/README.md +108 -0
- data/Rakefile +78 -0
- data/bin/rdebug +397 -0
- data/debugger2.gemspec +29 -0
- data/doc/.cvsignore +42 -0
- data/doc/Makefile.am +63 -0
- data/doc/emacs-notes.txt +38 -0
- data/doc/hanoi.rb +35 -0
- data/doc/primes.rb +28 -0
- data/doc/rdebug-emacs.texi +1030 -0
- data/doc/ruby-debug.texi +3791 -0
- data/doc/test-tri2.rb +18 -0
- data/doc/tri3.rb +8 -0
- data/doc/triangle.rb +12 -0
- data/emacs/Makefile.am +130 -0
- data/emacs/rdebug-annotate.el +385 -0
- data/emacs/rdebug-breaks.el +407 -0
- data/emacs/rdebug-cmd.el +92 -0
- data/emacs/rdebug-core.el +502 -0
- data/emacs/rdebug-dbg.el +62 -0
- data/emacs/rdebug-error.el +79 -0
- data/emacs/rdebug-fns.el +111 -0
- data/emacs/rdebug-frames.el +230 -0
- data/emacs/rdebug-gud.el +242 -0
- data/emacs/rdebug-help.el +104 -0
- data/emacs/rdebug-info.el +83 -0
- data/emacs/rdebug-layouts.el +180 -0
- data/emacs/rdebug-locring.el +118 -0
- data/emacs/rdebug-output.el +106 -0
- data/emacs/rdebug-regexp.el +118 -0
- data/emacs/rdebug-secondary.el +260 -0
- data/emacs/rdebug-shortkey.el +175 -0
- data/emacs/rdebug-source.el +568 -0
- data/emacs/rdebug-track.el +392 -0
- data/emacs/rdebug-varbuf.el +150 -0
- data/emacs/rdebug-vars.el +125 -0
- data/emacs/rdebug-watch.el +132 -0
- data/emacs/rdebug.el +326 -0
- data/emacs/test/elk-test.el +242 -0
- data/emacs/test/test-annotate.el +103 -0
- data/emacs/test/test-cmd.el +116 -0
- data/emacs/test/test-core.el +104 -0
- data/emacs/test/test-fns.el +65 -0
- data/emacs/test/test-frames.el +62 -0
- data/emacs/test/test-gud.el +35 -0
- data/emacs/test/test-indent.el +58 -0
- data/emacs/test/test-regexp.el +144 -0
- data/emacs/test/test-shortkey.el +61 -0
- data/ext/ruby_debug/breakpoint.c +630 -0
- data/ext/ruby_debug/extconf.rb +11 -0
- data/ext/ruby_debug/ruby_debug.c +2203 -0
- data/ext/ruby_debug/ruby_debug.h +151 -0
- data/lib/debugger.rb +5 -0
- data/lib/debugger/version.rb +5 -0
- data/lib/debugger2.rb +6 -0
- data/lib/ruby-debug-base.rb +307 -0
- data/lib/ruby-debug.rb +176 -0
- data/lib/ruby-debug/command.rb +227 -0
- data/lib/ruby-debug/commands/breakpoints.rb +153 -0
- data/lib/ruby-debug/commands/catchpoint.rb +55 -0
- data/lib/ruby-debug/commands/condition.rb +49 -0
- data/lib/ruby-debug/commands/continue.rb +38 -0
- data/lib/ruby-debug/commands/control.rb +107 -0
- data/lib/ruby-debug/commands/display.rb +120 -0
- data/lib/ruby-debug/commands/edit.rb +48 -0
- data/lib/ruby-debug/commands/enable.rb +202 -0
- data/lib/ruby-debug/commands/eval.rb +176 -0
- data/lib/ruby-debug/commands/finish.rb +42 -0
- data/lib/ruby-debug/commands/frame.rb +301 -0
- data/lib/ruby-debug/commands/help.rb +56 -0
- data/lib/ruby-debug/commands/info.rb +467 -0
- data/lib/ruby-debug/commands/irb.rb +123 -0
- data/lib/ruby-debug/commands/jump.rb +66 -0
- data/lib/ruby-debug/commands/kill.rb +51 -0
- data/lib/ruby-debug/commands/list.rb +94 -0
- data/lib/ruby-debug/commands/method.rb +84 -0
- data/lib/ruby-debug/commands/quit.rb +39 -0
- data/lib/ruby-debug/commands/reload.rb +40 -0
- data/lib/ruby-debug/commands/save.rb +90 -0
- data/lib/ruby-debug/commands/set.rb +223 -0
- data/lib/ruby-debug/commands/show.rb +247 -0
- data/lib/ruby-debug/commands/skip.rb +35 -0
- data/lib/ruby-debug/commands/source.rb +36 -0
- data/lib/ruby-debug/commands/stepping.rb +81 -0
- data/lib/ruby-debug/commands/threads.rb +189 -0
- data/lib/ruby-debug/commands/tmate.rb +36 -0
- data/lib/ruby-debug/commands/trace.rb +57 -0
- data/lib/ruby-debug/commands/variables.rb +199 -0
- data/lib/ruby-debug/debugger.rb +5 -0
- data/lib/ruby-debug/helper.rb +69 -0
- data/lib/ruby-debug/interface.rb +232 -0
- data/lib/ruby-debug/processor.rb +474 -0
- data/man/rdebug.1 +241 -0
- data/old_scripts/Makefile.am +14 -0
- data/old_scripts/README.md +2 -0
- data/old_scripts/autogen.sh +4 -0
- data/old_scripts/configure.ac +12 -0
- data/old_scripts/rdbg.rb +33 -0
- data/old_scripts/runner.sh +7 -0
- data/old_scripts/svn2cl_usermap +3 -0
- data/test/.cvsignore +1 -0
- data/test/breakpoints_test.rb +366 -0
- data/test/conditions_test.rb +77 -0
- data/test/continue_test.rb +28 -0
- data/test/display_test.rb +143 -0
- data/test/edit_test.rb +55 -0
- data/test/eval_test.rb +94 -0
- data/test/examples/breakpoint1.rb +15 -0
- data/test/examples/breakpoint2.rb +7 -0
- data/test/examples/conditions.rb +4 -0
- data/test/examples/continue.rb +4 -0
- data/test/examples/display.rb +5 -0
- data/test/examples/edit.rb +3 -0
- data/test/examples/edit2.rb +3 -0
- data/test/examples/eval.rb +4 -0
- data/test/examples/finish.rb +20 -0
- data/test/examples/frame.rb +31 -0
- data/test/examples/help.rb +2 -0
- data/test/examples/info.rb +48 -0
- data/test/examples/info2.rb +3 -0
- data/test/examples/irb.rb +6 -0
- data/test/examples/jump.rb +14 -0
- data/test/examples/kill.rb +2 -0
- data/test/examples/list.rb +12 -0
- data/test/examples/method.rb +15 -0
- data/test/examples/post_mortem.rb +19 -0
- data/test/examples/quit.rb +2 -0
- data/test/examples/reload.rb +6 -0
- data/test/examples/restart.rb +6 -0
- data/test/examples/save.rb +3 -0
- data/test/examples/set.rb +3 -0
- data/test/examples/set_annotate.rb +12 -0
- data/test/examples/settings.rb +1 -0
- data/test/examples/show.rb +2 -0
- data/test/examples/source.rb +3 -0
- data/test/examples/stepping.rb +21 -0
- data/test/examples/thread.rb +32 -0
- data/test/examples/tmate.rb +10 -0
- data/test/examples/trace.rb +7 -0
- data/test/examples/trace_threads.rb +20 -0
- data/test/examples/variables.rb +26 -0
- data/test/finish_test.rb +49 -0
- data/test/frame_test.rb +140 -0
- data/test/help_test.rb +51 -0
- data/test/info_test.rb +326 -0
- data/test/irb_test.rb +82 -0
- data/test/jump_test.rb +70 -0
- data/test/kill_test.rb +49 -0
- data/test/list_test.rb +147 -0
- data/test/method_test.rb +72 -0
- data/test/post_mortem_test.rb +25 -0
- data/test/quit_test.rb +56 -0
- data/test/reload_test.rb +47 -0
- data/test/restart_test.rb +145 -0
- data/test/save_test.rb +94 -0
- data/test/set_test.rb +183 -0
- data/test/show_test.rb +294 -0
- data/test/source_test.rb +46 -0
- data/test/stepping_test.rb +122 -0
- data/test/support/breakpoint.rb +12 -0
- data/test/support/context.rb +14 -0
- data/test/support/matchers.rb +67 -0
- data/test/support/mocha_extensions.rb +71 -0
- data/test/support/processor.rb +7 -0
- data/test/support/test_dsl.rb +206 -0
- data/test/support/test_interface.rb +66 -0
- data/test/test_helper.rb +9 -0
- data/test/thread_test.rb +124 -0
- data/test/tmate_test.rb +45 -0
- data/test/trace_test.rb +156 -0
- data/test/variables_test.rb +116 -0
- metadata +319 -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
|