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,175 @@
|
|
1
|
+
;;; rdebug-watch.el --- Ruby debugger (short and simple) key bindings
|
2
|
+
;;; and minor mode.
|
3
|
+
|
4
|
+
;; Copyright (C) 2008 Rocky Bernstein (rocky@gnu.org)
|
5
|
+
;; Copyright (C) 2008 Anders Lindgren
|
6
|
+
|
7
|
+
;; $Id: rdebug-shortkey.el 807 2008-04-08 19:55:37Z andersl $
|
8
|
+
|
9
|
+
;; This program is free software; you can redistribute it and/or modify
|
10
|
+
;; it under the terms of the GNU General Public License as published by
|
11
|
+
;; the Free Software Foundation; either version 2, or (at your option)
|
12
|
+
;; any later version.
|
13
|
+
|
14
|
+
;; This program is distributed in the hope that it will be useful,
|
15
|
+
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
16
|
+
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
17
|
+
;; GNU General Public License for more details.
|
18
|
+
|
19
|
+
;; You should have received a copy of the GNU General Public License
|
20
|
+
;; along with GNU Emacs; see the file COPYING. If not, write to the
|
21
|
+
;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
22
|
+
;; Boston, MA 02111-1307, USA.
|
23
|
+
|
24
|
+
;;; Commentary:
|
25
|
+
|
26
|
+
;; This file contains code which add short simple key bindings to buffers
|
27
|
+
;; which are part of an part of an rdebug session. It also handles
|
28
|
+
;; minor mode setting of these buffers.
|
29
|
+
|
30
|
+
;;; Code:
|
31
|
+
;; -------------------------------------------------------------------
|
32
|
+
;; Source short key mode.
|
33
|
+
;;
|
34
|
+
;; When this minor mode is active and the debugger is running, the
|
35
|
+
;; source window displaying the current debugger frame is marked as
|
36
|
+
;; read-only and the short keys of the secondary windows can be used,
|
37
|
+
;; for example, you can use the space-bar to single-step the program.
|
38
|
+
|
39
|
+
;; Implementation note:
|
40
|
+
;;
|
41
|
+
;; This is presented to the user as one global minor mode. However,
|
42
|
+
;; under the surface the real work is done by another, non-global,
|
43
|
+
;; minor mode named "local short key mode". This is activated and
|
44
|
+
;; deactivated appropriately by the Rdebug filter functions.
|
45
|
+
|
46
|
+
;; Implementation note: This is the user-level command. It only
|
47
|
+
;; controls if `rdebug-internal-short-key-mode' should be activated or
|
48
|
+
;; not.
|
49
|
+
|
50
|
+
(require 'rdebug-source)
|
51
|
+
|
52
|
+
(define-minor-mode rdebug-short-key-mode
|
53
|
+
"When enabled, short keys can be used in source buffers in `rdebug'."
|
54
|
+
:group 'rdebug
|
55
|
+
:global t
|
56
|
+
:init-value nil
|
57
|
+
;; Unless the debugger is running, activating this doesn't do
|
58
|
+
;; anything.
|
59
|
+
(if (featurep 'rdebug-core)
|
60
|
+
(with-no-warnings
|
61
|
+
(rdebug-short-key-mode-maybe-activate))))
|
62
|
+
|
63
|
+
(defvar rdebug-internal-short-key-mode-map
|
64
|
+
(let ((map (make-sparse-keymap)))
|
65
|
+
(define-key map "b" 'gud-break)
|
66
|
+
(define-key map "t" 'rdebug-toggle-source-breakpoint-enabled)
|
67
|
+
(define-key map [insert] 'rdebug-short-key-mode)
|
68
|
+
;;(define-key map "p" 'gud-print)
|
69
|
+
(rdebug-populate-secondary-buffer-map-plain map)
|
70
|
+
map)
|
71
|
+
"Keymap used in `rdebug-internal-short-key-mode'.")
|
72
|
+
|
73
|
+
(defvar rdebug-original-read-only nil
|
74
|
+
"The value `buffer-read-only' should be restored to after short key mode.")
|
75
|
+
|
76
|
+
;; `define-minor-mode' does not set if the mode was on or off prior to being called.
|
77
|
+
(defvar rdebug-internal-short-key-mode-previous-state nil
|
78
|
+
"Used to determine when 'rdebug-internal-short-key-mode' changed state.")
|
79
|
+
|
80
|
+
;; Implementation note: This is the mode that does all the work, it's
|
81
|
+
;; local to the buffer that is affected.
|
82
|
+
(define-minor-mode rdebug-internal-short-key-mode
|
83
|
+
"Minor mode with short keys for source buffers for the `rdebug' debugger.
|
84
|
+
The buffer is read-only when the minor mode is active.
|
85
|
+
|
86
|
+
Note that this is for internal use only, please use the global
|
87
|
+
mode `rdebug-short-key-mode'.
|
88
|
+
|
89
|
+
\\{rdebug-internal-short-key-mode-map}"
|
90
|
+
:group 'rdebug
|
91
|
+
:global nil
|
92
|
+
:init-value nil
|
93
|
+
:lighter " ShortKeys"
|
94
|
+
:keymap rdebug-internal-short-key-mode-map
|
95
|
+
(make-local-variable 'rdebug-original-read-only)
|
96
|
+
(make-local-variable 'rdebug-internal-short-key-mode-previous-state)
|
97
|
+
;; Ensure action only is performed when the state actually is toggled.
|
98
|
+
(unless (eq rdebug-internal-short-key-mode-previous-state
|
99
|
+
rdebug-internal-short-key-mode)
|
100
|
+
(if rdebug-internal-short-key-mode
|
101
|
+
;; Mode is being turned on.
|
102
|
+
(progn
|
103
|
+
(setq rdebug-original-read-only buffer-read-only)
|
104
|
+
(setq buffer-read-only t))
|
105
|
+
;; Mode is being turned off.
|
106
|
+
(setq buffer-read-only rdebug-original-read-only))
|
107
|
+
;; Save the current state, so we can determine when the state is
|
108
|
+
;; toggled in the future.
|
109
|
+
(setq rdebug-internal-short-key-mode-previous-state
|
110
|
+
rdebug-internal-short-key-mode)))
|
111
|
+
|
112
|
+
(defun rdebug-buffer-killed-p (buffer)
|
113
|
+
"Return t if BUFFER is killed."
|
114
|
+
(not (buffer-name buffer)))
|
115
|
+
|
116
|
+
(defun rdebug-internal-short-key-mode-on ()
|
117
|
+
"Turn on `rdebug-internal-short-key-mode' in the current debugger frame."
|
118
|
+
(rdebug-debug-enter "rdebug-internal-short-key-mode-on"
|
119
|
+
(save-current-buffer
|
120
|
+
(if (and gud-comint-buffer
|
121
|
+
(not (rdebug-buffer-killed-p gud-comint-buffer)))
|
122
|
+
(set-buffer gud-comint-buffer))
|
123
|
+
(let ((frame (or gud-last-frame
|
124
|
+
gud-last-last-frame)))
|
125
|
+
(if (and frame
|
126
|
+
rdebug-short-key-mode)
|
127
|
+
(ignore-errors
|
128
|
+
;; `gud-find-file' calls `error' if it doesn't find the file.
|
129
|
+
(let ((buffer (gud-find-file (car frame))))
|
130
|
+
(save-current-buffer
|
131
|
+
(set-buffer buffer)
|
132
|
+
;; Make gud-comint-buffer local
|
133
|
+
(if gud-comint-buffer
|
134
|
+
(make-local-variable 'gud-comint-buffer))
|
135
|
+
(rdebug-internal-short-key-mode 1)))))))))
|
136
|
+
|
137
|
+
|
138
|
+
(defun rdebug-turn-on-short-key-mode ()
|
139
|
+
"Turn on `rdebug-short-key-mode'.
|
140
|
+
|
141
|
+
This function is designed to be used in a user hook, for example:
|
142
|
+
|
143
|
+
(add-hook 'rdebug-mode-hook 'rdebug-turn-on-short-key-mode)"
|
144
|
+
(interactive)
|
145
|
+
(rdebug-short-key-mode 1))
|
146
|
+
|
147
|
+
|
148
|
+
(defun rdebug-turn-off-short-key-mode ()
|
149
|
+
"Turn off `rdebug-short-key-mode'."
|
150
|
+
(interactive)
|
151
|
+
(rdebug-short-key-mode -1))
|
152
|
+
|
153
|
+
|
154
|
+
(defun rdebug-short-key-mode-maybe-activate ()
|
155
|
+
(if rdebug-short-key-mode
|
156
|
+
(rdebug-internal-short-key-mode-on)
|
157
|
+
(rdebug-internal-short-key-mode-off)))
|
158
|
+
|
159
|
+
|
160
|
+
(defun rdebug-internal-short-key-mode-off ()
|
161
|
+
"Turn off `rdebug-internal-short-key-mode' in all buffers."
|
162
|
+
(rdebug-debug-enter "rdebug-internal-short-key-mode-off"
|
163
|
+
(save-current-buffer
|
164
|
+
(dolist (buf (buffer-list))
|
165
|
+
(set-buffer buf)
|
166
|
+
(when rdebug-internal-short-key-mode
|
167
|
+
(rdebug-internal-short-key-mode -1))))))
|
168
|
+
|
169
|
+
(provide 'rdebug-shortkey)
|
170
|
+
|
171
|
+
;;; Local variables:
|
172
|
+
;;; eval:(put 'rdebug-debug-enter 'lisp-indent-hook 1)
|
173
|
+
;;; End:
|
174
|
+
|
175
|
+
;;; rdebug-shortkey.el ends here
|
@@ -0,0 +1,568 @@
|
|
1
|
+
;;; rdebug-source.el --- Ruby debugger user interface.
|
2
|
+
|
3
|
+
;; Copyright (C) 2006, 2007, 2008 Rocky Bernstein (rocky@gnu.org)
|
4
|
+
;; Copyright (C) 2007, 2008 Anders Lindgren
|
5
|
+
|
6
|
+
;; $Id: rdebug-source.el 821 2008-04-25 02:54: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
|
+
;; This file is loaded when a Ruby source buffer is loaded. It
|
28
|
+
;; contains, among else, the Debugger menu.
|
29
|
+
|
30
|
+
;;; Code:
|
31
|
+
|
32
|
+
;; -------------------------------------------------------------------
|
33
|
+
;; Consistency checks.
|
34
|
+
;;
|
35
|
+
|
36
|
+
(if (< emacs-major-version 22)
|
37
|
+
(error
|
38
|
+
"Rdebug needs at least Emacs 22 or greater - you have version %d."
|
39
|
+
emacs-major-version))
|
40
|
+
|
41
|
+
|
42
|
+
;; -------------------------------------------------------------------
|
43
|
+
;; Dependencies.
|
44
|
+
;;
|
45
|
+
|
46
|
+
(require 'cl)
|
47
|
+
|
48
|
+
(require 'gud) ; For gud-key-prefix, sigh...
|
49
|
+
(require 'rdebug)
|
50
|
+
(require 'rdebug-vars)
|
51
|
+
|
52
|
+
|
53
|
+
;; -------------------------------------------------------------------
|
54
|
+
;; Key bindings
|
55
|
+
;;
|
56
|
+
|
57
|
+
(defun rdebug-populate-common-keys-standard (map)
|
58
|
+
"Bind the basic debugger key layout used by many debuggers.
|
59
|
+
|
60
|
+
\\{rdebug-example-map-standard}"
|
61
|
+
(define-key map [f5] 'gud-cont)
|
62
|
+
(define-key map [S-f5] 'rdebug-quit)
|
63
|
+
(define-key map [f9] 'rdebug-toggle-source-breakpoint)
|
64
|
+
(define-key map [C-f9] 'rdebug-toggle-source-breakpoint-enabled)
|
65
|
+
(define-key map [f10] 'rdebug-next)
|
66
|
+
(define-key map [f11] 'rdebug-step)
|
67
|
+
(define-key map [S-f11] 'gud-finish))
|
68
|
+
|
69
|
+
|
70
|
+
;; TODO: Verify and complement.
|
71
|
+
(defun rdebug-populate-common-keys-eclipse (map)
|
72
|
+
"Bind the basic debugger key layout used by Eclipse.
|
73
|
+
|
74
|
+
\\{rdebug-example-map-eclipse}"
|
75
|
+
;;(define-key map [] 'gud-cont)
|
76
|
+
;;(define-key map [] 'rdebug-quit)
|
77
|
+
(define-key map [S-C-b] 'rdebug-toggle-source-breakpoint)
|
78
|
+
(define-key map [f6] 'rdebug-next)
|
79
|
+
(define-key map [f5] 'rdebug-step)
|
80
|
+
(define-key map [f7] 'gud-finish))
|
81
|
+
|
82
|
+
|
83
|
+
;; TODO: Verify and complement.
|
84
|
+
(defun rdebug-populate-common-keys-netbeans (map)
|
85
|
+
"Bind the basic debugger key layout used by NetBeans.
|
86
|
+
|
87
|
+
\\{rdebug-example-map-netbeans}"
|
88
|
+
;;(define-key map [] 'gud-cont)
|
89
|
+
;;(define-key map [] 'rdebug-quit)
|
90
|
+
;; F4 - Run to cursor.
|
91
|
+
(define-key map [S-f8] 'rdebug-toggle-source-breakpoint)
|
92
|
+
(define-key map [f8] 'rdebug-next)
|
93
|
+
(define-key map [f7] 'rdebug-step)
|
94
|
+
(define-key map [M-S-f7] 'gud-finish))
|
95
|
+
|
96
|
+
|
97
|
+
;; Note: This is only used in doc-strings.
|
98
|
+
(defvar rdebug-example-map-standard
|
99
|
+
(let ((map (make-sparse-keymap)))
|
100
|
+
(rdebug-populate-common-keys-standard map)
|
101
|
+
map)
|
102
|
+
"Rdebug Standard common keymap used only in doc-string.")
|
103
|
+
|
104
|
+
|
105
|
+
(defvar rdebug-example-map-eclipse
|
106
|
+
(let ((map (make-sparse-keymap)))
|
107
|
+
(rdebug-populate-common-keys-eclipse map)
|
108
|
+
map)
|
109
|
+
"Rdebug Eclipse compatibility common keymap used only in doc-string.")
|
110
|
+
|
111
|
+
|
112
|
+
(defvar rdebug-example-map-netbeans
|
113
|
+
(let ((map (make-sparse-keymap)))
|
114
|
+
(rdebug-populate-common-keys-netbeans map)
|
115
|
+
map)
|
116
|
+
"Rdebug NetBeans compatibility common keymap used only in doc-string.")
|
117
|
+
|
118
|
+
|
119
|
+
(defun rdebug-populate-common-keys (map)
|
120
|
+
"Define the keys that are used by all debugger windows, even by the source.
|
121
|
+
|
122
|
+
The variable `rdebug-populate-common-keys-function' controls the layout."
|
123
|
+
(define-key map "\C-x\C-a\C-q" 'rdebug-short-key-mode)
|
124
|
+
(if rdebug-populate-common-keys-function
|
125
|
+
(funcall rdebug-populate-common-keys-function map)))
|
126
|
+
|
127
|
+
|
128
|
+
(defun rdebug-populate-digit-keys (map)
|
129
|
+
(define-key map "0" 'rdebug-goto-entry-n)
|
130
|
+
(define-key map "1" 'rdebug-goto-entry-n)
|
131
|
+
(define-key map "2" 'rdebug-goto-entry-n)
|
132
|
+
(define-key map "3" 'rdebug-goto-entry-n)
|
133
|
+
(define-key map "4" 'rdebug-goto-entry-n)
|
134
|
+
(define-key map "5" 'rdebug-goto-entry-n)
|
135
|
+
(define-key map "6" 'rdebug-goto-entry-n)
|
136
|
+
(define-key map "7" 'rdebug-goto-entry-n)
|
137
|
+
(define-key map "8" 'rdebug-goto-entry-n)
|
138
|
+
(define-key map "9" 'rdebug-goto-entry-n))
|
139
|
+
|
140
|
+
|
141
|
+
;; -------------------------------------------------------------------
|
142
|
+
;; Menu support.
|
143
|
+
;;
|
144
|
+
|
145
|
+
|
146
|
+
;; Note: We want the key binding to show in the menu. However, our
|
147
|
+
;; situation is a little bit complex:
|
148
|
+
;;
|
149
|
+
;; 1) We want the binding of the `common' man (i.e. the function key
|
150
|
+
;; the user has selected.)
|
151
|
+
;;
|
152
|
+
;; 2) We want this even when the menu is disabled and the key isn't
|
153
|
+
;; bound, typically when the debugger isn't running.
|
154
|
+
;;
|
155
|
+
;; This has been solved by setting up an explicit ":keys" properly.
|
156
|
+
(defun rdebug-menu-item (common-map name cmd &rest args)
|
157
|
+
"Return a menu item entry with the correct key bindings.
|
158
|
+
|
159
|
+
A command can be bound to a number of different key sequences. If
|
160
|
+
the rdebug common map contains a binding it is displayed in the
|
161
|
+
menu. (The common map typically contains function key bindings.)"
|
162
|
+
(let ((key-binding (where-is-internal cmd (list common-map) t))
|
163
|
+
(hint '()))
|
164
|
+
(if key-binding
|
165
|
+
(setq hint (list :keys (key-description key-binding))))
|
166
|
+
(append (list 'menu-item name cmd)
|
167
|
+
hint
|
168
|
+
args)))
|
169
|
+
|
170
|
+
|
171
|
+
;; Note, we re-populate the menus of the different minor and major
|
172
|
+
;; modes. The reason is that Emacs caches the key bindings, which
|
173
|
+
;; means that wrong ones are shown when buffers are changed.
|
174
|
+
|
175
|
+
;; Remember, all menu items are added in the reverse order!
|
176
|
+
|
177
|
+
(defun rdebug-populate-debugger-menu (map)
|
178
|
+
"Populate the Rdebug 'Debugger' menu."
|
179
|
+
(let ((menu (make-sparse-keymap))
|
180
|
+
(common-map (make-sparse-keymap)))
|
181
|
+
;; Use a simple common map to find the best key sequence to
|
182
|
+
;; display in menu.
|
183
|
+
(rdebug-populate-common-keys common-map)
|
184
|
+
|
185
|
+
(define-key map [menu-bar debugger] (cons "Debugger" menu))
|
186
|
+
|
187
|
+
(define-key menu [break-delete]
|
188
|
+
(rdebug-menu-item common-map "Enable/disable breakpoint"
|
189
|
+
'rdebug-toggle-source-breakpoint-enabled
|
190
|
+
:enable '(get-buffer-process gud-comint-buffer)))
|
191
|
+
|
192
|
+
(define-key menu [break]
|
193
|
+
(rdebug-menu-item common-map "Toggle breakpoint"
|
194
|
+
'rdebug-toggle-source-breakpoint
|
195
|
+
:enable '(get-buffer-process gud-comint-buffer)))
|
196
|
+
|
197
|
+
(define-key menu [finish]
|
198
|
+
(rdebug-menu-item common-map "Step out" 'gud-finish
|
199
|
+
:enable '(get-buffer-process gud-comint-buffer)))
|
200
|
+
|
201
|
+
(define-key menu [step]
|
202
|
+
(rdebug-menu-item common-map "Step into" 'rdebug-step
|
203
|
+
:enable '(get-buffer-process gud-comint-buffer)))
|
204
|
+
|
205
|
+
(define-key menu [next]
|
206
|
+
(rdebug-menu-item common-map "Step over" 'rdebug-next
|
207
|
+
:enable '(get-buffer-process gud-comint-buffer)))
|
208
|
+
|
209
|
+
(define-key menu [cont]
|
210
|
+
(rdebug-menu-item common-map "Continue" 'rdebug-continue
|
211
|
+
:enable '(get-buffer-process gud-comint-buffer)))
|
212
|
+
|
213
|
+
(define-key map [menu-bar debugger line1] '(menu-item "--"))
|
214
|
+
|
215
|
+
(define-key menu [stop]
|
216
|
+
(rdebug-menu-item
|
217
|
+
common-map "Stop the debugger" 'rdebug-quit
|
218
|
+
:enable '(get-buffer-process gud-comint-buffer)))
|
219
|
+
|
220
|
+
(define-key menu [start]
|
221
|
+
(rdebug-menu-item common-map "Start the debugger" 'rdebug))
|
222
|
+
|
223
|
+
(define-key map [menu-bar debugger line2] '(menu-item "--"))
|
224
|
+
|
225
|
+
;; --------------------
|
226
|
+
;; The "Options" submenu.
|
227
|
+
|
228
|
+
(let ((submenu (make-sparse-keymap)))
|
229
|
+
(define-key menu [options] (cons "Options" submenu)))
|
230
|
+
|
231
|
+
(define-key map [menu-bar debugger options customize]
|
232
|
+
(rdebug-menu-item common-map
|
233
|
+
"Customize Rdebug" 'rdebug-customize))
|
234
|
+
|
235
|
+
(define-key map [menu-bar debugger options line1] '(menu-item "--"))
|
236
|
+
|
237
|
+
|
238
|
+
|
239
|
+
;; ----------------
|
240
|
+
;; The "short key" toggle.
|
241
|
+
|
242
|
+
(define-key map [menu-bar debugger options short-key-mode]
|
243
|
+
(rdebug-menu-item common-map
|
244
|
+
"Short keys in source" 'rdebug-short-key-mode
|
245
|
+
:button
|
246
|
+
'(:toggle
|
247
|
+
. rdebug-short-key-mode)))
|
248
|
+
|
249
|
+
(define-key map [menu-bar debugger options line2] '(menu-item "--"))
|
250
|
+
|
251
|
+
;; ----------------
|
252
|
+
;; Separate I/O buffer.
|
253
|
+
|
254
|
+
(define-key map [menu-bar debugger options io-buffer]
|
255
|
+
(rdebug-menu-item common-map
|
256
|
+
"Separate I/O buffer"
|
257
|
+
'rdebug-toggle-use-separate-io-buffer
|
258
|
+
:button
|
259
|
+
'(:toggle
|
260
|
+
. rdebug-use-separate-io-buffer)))
|
261
|
+
|
262
|
+
;; --------------------
|
263
|
+
;; The optional secondary windows submenu.
|
264
|
+
|
265
|
+
|
266
|
+
;; Placeholder used when populating the menu of the secondary buffers.
|
267
|
+
(define-key menu [placeholder] nil)
|
268
|
+
|
269
|
+
;; --------------------
|
270
|
+
;; The "Window Layout" submenu.
|
271
|
+
(let ((submenu (make-sparse-keymap)))
|
272
|
+
(define-key menu [layout] (cons "Window Layout" submenu)))
|
273
|
+
|
274
|
+
;; ----------------
|
275
|
+
;; The "Window Layout" submenu.
|
276
|
+
|
277
|
+
|
278
|
+
;; TODO: The following is a somewhat clumsy implementation. Maybe we can
|
279
|
+
;; automatically generate the entries, or use the `dynamic' menu kind?
|
280
|
+
;;
|
281
|
+
;; Also, there might be other situations where the list might be
|
282
|
+
;; handy, e.g. completion.
|
283
|
+
(let ((predefined '(rdebug-window-layout-standard
|
284
|
+
rdebug-window-layout-no-shell
|
285
|
+
rdebug-window-layout-conservative
|
286
|
+
rdebug-window-layout-stack-of-windows
|
287
|
+
rdebug-window-layout-rocky
|
288
|
+
rdebug-window-layout-rocky2)))
|
289
|
+
|
290
|
+
(define-key map [menu-bar debugger layout other]
|
291
|
+
(rdebug-menu-item
|
292
|
+
common-map
|
293
|
+
"Other"
|
294
|
+
'rdebug-set-window-layout
|
295
|
+
:button
|
296
|
+
`(:radio
|
297
|
+
. (not (memq rdebug-window-layout-function (quote ,predefined))))))
|
298
|
+
|
299
|
+
(define-key map [menu-bar debugger layout rocky]
|
300
|
+
(rdebug-menu-item
|
301
|
+
common-map
|
302
|
+
"Rocky's Own"
|
303
|
+
(lambda ()
|
304
|
+
(interactive)
|
305
|
+
(rdebug-set-window-layout 'rdebug-window-layout-rocky))
|
306
|
+
:button
|
307
|
+
'(:radio
|
308
|
+
. (eq rdebug-window-layout-function
|
309
|
+
'rdebug-window-layout-rocky))))
|
310
|
+
|
311
|
+
(define-key map [menu-bar debugger layout rocky2]
|
312
|
+
(rdebug-menu-item
|
313
|
+
common-map
|
314
|
+
"Rocky II"
|
315
|
+
(lambda ()
|
316
|
+
(interactive)
|
317
|
+
(rdebug-set-window-layout 'rdebug-window-layout-rocky2))
|
318
|
+
:button
|
319
|
+
'(:radio
|
320
|
+
. (eq rdebug-window-layout-function
|
321
|
+
'rdebug-window-layout-rocky2))))
|
322
|
+
|
323
|
+
(define-key map [menu-bar debugger layout stack]
|
324
|
+
(rdebug-menu-item
|
325
|
+
common-map
|
326
|
+
"Stack of Windows"
|
327
|
+
(lambda ()
|
328
|
+
(interactive)
|
329
|
+
(rdebug-set-window-layout 'rdebug-window-layout-stack-of-windows))
|
330
|
+
:button
|
331
|
+
'(:radio
|
332
|
+
. (eq rdebug-window-layout-function
|
333
|
+
'rdebug-window-layout-stack-of-windows))))
|
334
|
+
|
335
|
+
(define-key map [menu-bar debugger layout conservative]
|
336
|
+
(rdebug-menu-item
|
337
|
+
common-map
|
338
|
+
"Conservative"
|
339
|
+
(lambda ()
|
340
|
+
(interactive)
|
341
|
+
(rdebug-set-window-layout 'rdebug-window-layout-conservative))
|
342
|
+
:button
|
343
|
+
'(:radio
|
344
|
+
. (eq rdebug-window-layout-function
|
345
|
+
'rdebug-window-layout-conservative))))
|
346
|
+
|
347
|
+
(define-key map [menu-bar debugger layout no-shell]
|
348
|
+
(rdebug-menu-item
|
349
|
+
common-map
|
350
|
+
"No Shell"
|
351
|
+
(lambda ()
|
352
|
+
(interactive)
|
353
|
+
(rdebug-set-window-layout 'rdebug-window-layout-no-shell))
|
354
|
+
:button
|
355
|
+
'(:radio
|
356
|
+
. (eq rdebug-window-layout-function
|
357
|
+
'rdebug-window-layout-no-shell))))
|
358
|
+
|
359
|
+
(define-key map [menu-bar debugger layout standard]
|
360
|
+
(rdebug-menu-item
|
361
|
+
common-map
|
362
|
+
"Standard"
|
363
|
+
(lambda ()
|
364
|
+
(interactive)
|
365
|
+
(rdebug-set-window-layout 'rdebug-window-layout-standard))
|
366
|
+
:button
|
367
|
+
'(:radio
|
368
|
+
. (eq rdebug-window-layout-function
|
369
|
+
'rdebug-window-layout-standard)))))
|
370
|
+
|
371
|
+
(define-key map [menu-bar debugger layout line3] '(menu-item "--"))
|
372
|
+
|
373
|
+
(define-key map [menu-bar debugger layout initial]
|
374
|
+
(rdebug-menu-item common-map
|
375
|
+
"Restore Debugger Layout"
|
376
|
+
'rdebug-restore-debugger-window-layout
|
377
|
+
:enable '(fboundp 'rdebug-restore-debugger-window-layout)))
|
378
|
+
|
379
|
+
(define-key map [menu-bar debugger layout line1] '(menu-item "--"))
|
380
|
+
|
381
|
+
;; Note: It seems as though :enable doesn't work when :button is used.
|
382
|
+
(define-key map [menu-bar debugger layout debugger]
|
383
|
+
(rdebug-menu-item common-map "Current Debugger Layout"
|
384
|
+
'rdebug-display-debugger-window-configuration
|
385
|
+
:button
|
386
|
+
'(:radio
|
387
|
+
. (eq rdebug-window-configuration-state 'debugger))))
|
388
|
+
|
389
|
+
(define-key map [menu-bar debugger layout original]
|
390
|
+
(rdebug-menu-item common-map "Original Layout"
|
391
|
+
'rdebug-display-original-window-configuration
|
392
|
+
:button
|
393
|
+
'(:radio
|
394
|
+
. (eq rdebug-window-configuration-state 'original))))
|
395
|
+
|
396
|
+
;; --------------------
|
397
|
+
;; The "View" submenu.
|
398
|
+
(let ((submenu (make-sparse-keymap)))
|
399
|
+
(define-key menu [view] (cons "View" submenu)))
|
400
|
+
|
401
|
+
(define-key map [menu-bar debugger view output]
|
402
|
+
(rdebug-menu-item common-map "Output" 'rdebug-display-output-buffer
|
403
|
+
:enable '(get-buffer-process gud-comint-buffer)))
|
404
|
+
|
405
|
+
(define-key map [menu-bar debugger view watch]
|
406
|
+
(rdebug-menu-item common-map "Watch" 'rdebug-display-watch-buffer
|
407
|
+
:enable '(get-buffer-process gud-comint-buffer)))
|
408
|
+
|
409
|
+
(define-key map [menu-bar debugger view stack]
|
410
|
+
(rdebug-menu-item common-map "Stack-Frame trace"
|
411
|
+
'rdebug-display-frame-buffer
|
412
|
+
:enable '(get-buffer-process gud-comint-buffer)))
|
413
|
+
|
414
|
+
(define-key map [menu-bar debugger view shell]
|
415
|
+
(rdebug-menu-item common-map "Debugger Shell" 'rdebug-display-cmd-buffer
|
416
|
+
:enable '(get-buffer-process gud-comint-buffer)))
|
417
|
+
|
418
|
+
(define-key map [menu-bar debugger view variables]
|
419
|
+
(rdebug-menu-item common-map "Variables" 'rdebug-display-variables-buffer
|
420
|
+
:enable '(get-buffer-process gud-comint-buffer)))
|
421
|
+
|
422
|
+
(define-key map [menu-bar debugger view breakpoints]
|
423
|
+
(rdebug-menu-item common-map
|
424
|
+
"Breakpoints" 'rdebug-display-breakpoints-buffer
|
425
|
+
:enable '(get-buffer-process gud-comint-buffer)))
|
426
|
+
|
427
|
+
(define-key map [menu-bar debugger view source]
|
428
|
+
(rdebug-menu-item common-map
|
429
|
+
"Source" 'rdebug-display-source-buffer
|
430
|
+
:enable '(get-buffer-process gud-comint-buffer)))
|
431
|
+
menu))
|
432
|
+
|
433
|
+
|
434
|
+
;; -----------------------------------------------
|
435
|
+
;; Key bindings and menu for secondary buffers.
|
436
|
+
;;
|
437
|
+
|
438
|
+
(defun rdebug-populate-secondary-buffer-map-plain (map)
|
439
|
+
"Bind the plain keys used in rdebug secondary buffers.
|
440
|
+
|
441
|
+
This does not menus or prefix keys."
|
442
|
+
;; Keys to view other buffers.
|
443
|
+
(let ((prefix-map (make-sparse-keymap)))
|
444
|
+
(define-key map "?" 'rdebug-display-secondary-window-help-buffer)
|
445
|
+
(define-key map "B" 'rdebug-display-breakpoints-buffer)
|
446
|
+
(define-key map "C" 'rdebug-display-cmd-buffer)
|
447
|
+
(define-key map "E" 'rdebug-display-error-buffer)
|
448
|
+
(define-key map "F" 'rdebug-display-frame-buffer)
|
449
|
+
(define-key map "I" 'rdebug-display-info-buffer)
|
450
|
+
(define-key map "O" 'rdebug-display-output-buffer)
|
451
|
+
(define-key map "S" 'rdebug-display-source-buffer)
|
452
|
+
(define-key map "V" 'rdebug-display-variables-buffer)
|
453
|
+
(define-key map "W" 'rdebug-display-watch-buffer)
|
454
|
+
;; Common debugger commands.
|
455
|
+
(define-key map " " 'rdebug-step)
|
456
|
+
(define-key map "_" 'rdebug-set-stepping-prefix)
|
457
|
+
(define-key map "+" 'rdebug-set-stepping-prefix)
|
458
|
+
(define-key map "-" 'rdebug-set-stepping-prefix)
|
459
|
+
(define-key map "<" 'rdebug-newer-frame)
|
460
|
+
(define-key map ">" 'rdebug-older-frame)
|
461
|
+
;; (define-key map "a" 'gud-args)
|
462
|
+
;; (define-key map "b" 'gud-break)
|
463
|
+
(define-key map "c" 'rdebug-continue)
|
464
|
+
;; (define-key map "d" 'gud-remove)
|
465
|
+
(define-key map "f" 'gud-finish)
|
466
|
+
(define-key map "n" 'rdebug-next)
|
467
|
+
(define-key map "p" prefix-map)
|
468
|
+
(define-key map "q" 'rdebug-quit)
|
469
|
+
(define-key map "r" 'rdebug-restart)
|
470
|
+
(define-key map "R" 'rdebug-restart)
|
471
|
+
(define-key map "s" 'rdebug-step)
|
472
|
+
(define-key map [M-down] 'rdebug-locring-newer)
|
473
|
+
(define-key map [M-up] 'rdebug-locring-older)
|
474
|
+
(define-key map [M-S-down] 'rdebug-locring-newest)
|
475
|
+
(define-key map [M-S-up] 'rdebug-locring-oldest)
|
476
|
+
(define-key map [mouse-3] 'rdebug-variables-pretty-print-mouse)
|
477
|
+
(define-key prefix-map "l" 'rdebug-print-list-region)
|
478
|
+
(define-key prefix-map "p" 'rdebug-pretty-print-region)
|
479
|
+
(define-key prefix-map "s" 'rdebug-print-sorted-region)
|
480
|
+
))
|
481
|
+
|
482
|
+
|
483
|
+
;; -------------------------------------------------------------------
|
484
|
+
;; Window layout.
|
485
|
+
;;
|
486
|
+
|
487
|
+
;; This function is intended for the Options submenu.
|
488
|
+
(defun rdebug-set-window-layout (func)
|
489
|
+
"Set and, if the debugger is running, display the window layout."
|
490
|
+
(interactive "aWindow layout function: ")
|
491
|
+
(setq rdebug-window-layout-function func)
|
492
|
+
(if gud-comint-buffer
|
493
|
+
(with-no-warnings
|
494
|
+
(rdebug-setup-windows))))
|
495
|
+
|
496
|
+
|
497
|
+
;; -------------------------------------------------------------------
|
498
|
+
;; The source buffer rdebug support mode.
|
499
|
+
;;
|
500
|
+
;; This is a minor mode that is active in Ruby source buffers. It
|
501
|
+
;; provides the menu and, when the debugger is active, the debugger
|
502
|
+
;; key bindings.
|
503
|
+
|
504
|
+
(defvar rdebug-debugger-support-minor-mode-map-when-deactive
|
505
|
+
(let ((map (make-sparse-keymap))
|
506
|
+
(prefix-map (make-sparse-keymap)))
|
507
|
+
(rdebug-populate-debugger-menu map)
|
508
|
+
(rdebug-populate-secondary-buffer-map-plain prefix-map)
|
509
|
+
(define-key map gud-key-prefix prefix-map)
|
510
|
+
map)
|
511
|
+
"Keymap used by rdebugs support minor mode when the debugger is active.")
|
512
|
+
|
513
|
+
(defvar rdebug-debugger-support-minor-mode-map-when-active
|
514
|
+
(let ((map (make-sparse-keymap))
|
515
|
+
(prefix-map (make-sparse-keymap)))
|
516
|
+
(rdebug-populate-debugger-menu map)
|
517
|
+
(rdebug-populate-secondary-buffer-map-plain prefix-map)
|
518
|
+
(define-key prefix-map [insert] 'rdebug-short-key-mode)
|
519
|
+
(define-key map gud-key-prefix prefix-map)
|
520
|
+
(rdebug-populate-common-keys map)
|
521
|
+
map)
|
522
|
+
"Keymap used by rdebugs support minor mode when the debugger not active.")
|
523
|
+
|
524
|
+
|
525
|
+
(define-minor-mode rdebug-debugger-support-minor-mode
|
526
|
+
"Minor mode active in source buffers that use the `rdebug' Ruby debugger."
|
527
|
+
:group rdebug
|
528
|
+
:global nil
|
529
|
+
:init-value nil
|
530
|
+
:keymap rdebug-debugger-support-minor-mode-map-when-deactive
|
531
|
+
(setq mode-line-process (and rdebug-debugger-support-minor-mode
|
532
|
+
'rdebug-mode-line-process)))
|
533
|
+
|
534
|
+
|
535
|
+
;;;###autoload
|
536
|
+
(defun rdebug-turn-on-debugger-support ()
|
537
|
+
"Enable extra source buffer support for the `rdebug' Ruby debugger.
|
538
|
+
|
539
|
+
This includes a 'Debugger' menu and special key bindings when the
|
540
|
+
debugger is active."
|
541
|
+
(rdebug-debugger-support-minor-mode 1))
|
542
|
+
|
543
|
+
|
544
|
+
;; -------------------------------------------------------------------
|
545
|
+
;; Use separate I/O buffer
|
546
|
+
;;
|
547
|
+
|
548
|
+
(defun rdebug-toggle-use-separate-io-buffer ()
|
549
|
+
"Toggle `rdebug-use-separate-io-buffer'.
|
550
|
+
This is used by the menu."
|
551
|
+
(interactive)
|
552
|
+
(setq rdebug-use-separate-io-buffer (not rdebug-use-separate-io-buffer))
|
553
|
+
(if (interactive-p)
|
554
|
+
(message "Issue M-x rdebug-restore-debugger-window-layout \
|
555
|
+
RET to update display.")))
|
556
|
+
|
557
|
+
|
558
|
+
;; -------------------------------------------------------------------
|
559
|
+
;; The end.
|
560
|
+
;;
|
561
|
+
|
562
|
+
(provide 'rdebug-source)
|
563
|
+
|
564
|
+
;;; Local variables:
|
565
|
+
;;; eval:(put 'rdebug-debug-enter 'lisp-indent-hook 1)
|
566
|
+
;;; End:
|
567
|
+
|
568
|
+
;;; rdebug-source.el ends here
|