debugger 1.0.0.rc1
Sign up to get free protection for your applications and to get access to all the features.
- data/AUTHORS +10 -0
- data/CHANGES +334 -0
- data/ChangeLog +5655 -0
- data/INSTALL.SVN +154 -0
- data/LICENSE +23 -0
- data/Makefile.am +14 -0
- data/OLD_README +122 -0
- data/README.md +10 -0
- data/Rakefile +266 -0
- data/autogen.sh +4 -0
- data/bin/rdebug +398 -0
- data/cli/ruby-debug.rb +173 -0
- data/cli/ruby-debug/command.rb +228 -0
- data/cli/ruby-debug/commands/breakpoints.rb +153 -0
- data/cli/ruby-debug/commands/catchpoint.rb +55 -0
- data/cli/ruby-debug/commands/condition.rb +49 -0
- data/cli/ruby-debug/commands/continue.rb +38 -0
- data/cli/ruby-debug/commands/control.rb +107 -0
- data/cli/ruby-debug/commands/display.rb +120 -0
- data/cli/ruby-debug/commands/edit.rb +48 -0
- data/cli/ruby-debug/commands/enable.rb +202 -0
- data/cli/ruby-debug/commands/eval.rb +176 -0
- data/cli/ruby-debug/commands/finish.rb +42 -0
- data/cli/ruby-debug/commands/frame.rb +301 -0
- data/cli/ruby-debug/commands/help.rb +56 -0
- data/cli/ruby-debug/commands/info.rb +467 -0
- data/cli/ruby-debug/commands/irb.rb +123 -0
- data/cli/ruby-debug/commands/jump.rb +66 -0
- data/cli/ruby-debug/commands/kill.rb +51 -0
- data/cli/ruby-debug/commands/list.rb +94 -0
- data/cli/ruby-debug/commands/method.rb +84 -0
- data/cli/ruby-debug/commands/quit.rb +39 -0
- data/cli/ruby-debug/commands/reload.rb +40 -0
- data/cli/ruby-debug/commands/save.rb +90 -0
- data/cli/ruby-debug/commands/set.rb +221 -0
- data/cli/ruby-debug/commands/show.rb +247 -0
- data/cli/ruby-debug/commands/skip.rb +35 -0
- data/cli/ruby-debug/commands/source.rb +36 -0
- data/cli/ruby-debug/commands/stepping.rb +81 -0
- data/cli/ruby-debug/commands/threads.rb +189 -0
- data/cli/ruby-debug/commands/tmate.rb +36 -0
- data/cli/ruby-debug/commands/trace.rb +57 -0
- data/cli/ruby-debug/commands/variables.rb +199 -0
- data/cli/ruby-debug/debugger.rb +5 -0
- data/cli/ruby-debug/helper.rb +69 -0
- data/cli/ruby-debug/interface.rb +232 -0
- data/cli/ruby-debug/processor.rb +474 -0
- data/configure.ac +12 -0
- data/debugger.gemspec +24 -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/rdebug.1 +241 -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 +586 -0
- data/ext/ruby_debug/extconf.rb +49 -0
- data/ext/ruby_debug/ruby_debug.c +2624 -0
- data/ext/ruby_debug/ruby_debug.h +148 -0
- data/lib/ChangeLog +1065 -0
- data/lib/debugger.rb +7 -0
- data/lib/debugger/version.rb +3 -0
- data/lib/ruby-debug-base.rb +304 -0
- data/rdbg.rb +33 -0
- data/runner.sh +7 -0
- data/svn2cl_usermap +3 -0
- data/test/.cvsignore +1 -0
- data/test/base/base.rb +74 -0
- data/test/base/binding.rb +31 -0
- data/test/base/catchpoint.rb +26 -0
- data/test/base/load.rb +40 -0
- data/test/bp_loop_issue.rb +3 -0
- data/test/classes.rb +11 -0
- data/test/cli/commands/catchpoint_test.rb +36 -0
- data/test/cli/commands/unit/regexp.rb +42 -0
- data/test/config.yaml +8 -0
- data/test/data/annotate.cmd +29 -0
- data/test/data/annotate.right +139 -0
- data/test/data/break_bad.cmd +18 -0
- data/test/data/break_bad.right +28 -0
- data/test/data/break_loop_bug.cmd +5 -0
- data/test/data/break_loop_bug.right +15 -0
- data/test/data/breakpoints.cmd +38 -0
- data/test/data/breakpoints.right +98 -0
- data/test/data/catch.cmd +20 -0
- data/test/data/catch.right +49 -0
- data/test/data/catch2.cmd +19 -0
- data/test/data/catch2.right +65 -0
- data/test/data/catch3.cmd +11 -0
- data/test/data/catch3.right +37 -0
- data/test/data/condition.cmd +28 -0
- data/test/data/condition.right +65 -0
- data/test/data/ctrl.cmd +23 -0
- data/test/data/ctrl.right +70 -0
- data/test/data/display.cmd +24 -0
- data/test/data/display.right +44 -0
- data/test/data/dollar-0.right +2 -0
- data/test/data/dollar-0a.right +2 -0
- data/test/data/dollar-0b.right +2 -0
- data/test/data/edit.cmd +12 -0
- data/test/data/edit.right +19 -0
- data/test/data/emacs_basic.cmd +43 -0
- data/test/data/emacs_basic.right +106 -0
- data/test/data/enable.cmd +20 -0
- data/test/data/enable.right +36 -0
- data/test/data/finish.cmd +16 -0
- data/test/data/finish.right +31 -0
- data/test/data/frame.cmd +26 -0
- data/test/data/frame.right +55 -0
- data/test/data/help.cmd +20 -0
- data/test/data/help.right +21 -0
- data/test/data/history.right +7 -0
- data/test/data/info-thread.cmd +13 -0
- data/test/data/info-thread.right +37 -0
- data/test/data/info-var-bug2.cmd +5 -0
- data/test/data/info-var-bug2.right +10 -0
- data/test/data/info-var.cmd +23 -0
- data/test/data/info-var.right +52 -0
- data/test/data/info.cmd +21 -0
- data/test/data/info.right +65 -0
- data/test/data/jump.cmd +16 -0
- data/test/data/jump.right +56 -0
- data/test/data/jump2.cmd +16 -0
- data/test/data/jump2.right +44 -0
- data/test/data/linetrace.cmd +6 -0
- data/test/data/linetrace.right +23 -0
- data/test/data/list.cmd +19 -0
- data/test/data/list.right +127 -0
- data/test/data/method.cmd +10 -0
- data/test/data/method.right +21 -0
- data/test/data/methodsig.cmd +10 -0
- data/test/data/methodsig.right +20 -0
- data/test/data/next.cmd +22 -0
- data/test/data/next.right +61 -0
- data/test/data/noquit.right +1 -0
- data/test/data/output.cmd +6 -0
- data/test/data/output.right +31 -0
- data/test/data/pm-bug.cmd +7 -0
- data/test/data/pm-bug.right +12 -0
- data/test/data/post-mortem-next.cmd +8 -0
- data/test/data/post-mortem-next.right +14 -0
- data/test/data/post-mortem-osx.right +31 -0
- data/test/data/post-mortem.cmd +13 -0
- data/test/data/post-mortem.right +32 -0
- data/test/data/quit.cmd +6 -0
- data/test/data/quit.right +0 -0
- data/test/data/raise.cmd +11 -0
- data/test/data/raise.right +23 -0
- data/test/data/save.cmd +34 -0
- data/test/data/save.right +59 -0
- data/test/data/scope-var.cmd +42 -0
- data/test/data/scope-var.right +587 -0
- data/test/data/setshow.cmd +56 -0
- data/test/data/setshow.right +98 -0
- data/test/data/source.cmd +5 -0
- data/test/data/source.right +15 -0
- data/test/data/stepping.cmd +21 -0
- data/test/data/stepping.right +50 -0
- data/test/data/test-init-cygwin.right +7 -0
- data/test/data/test-init-osx.right +4 -0
- data/test/data/test-init.right +5 -0
- data/test/data/trace.right +14 -0
- data/test/dollar-0.rb +5 -0
- data/test/gcd-dbg-nox.rb +31 -0
- data/test/gcd-dbg.rb +30 -0
- data/test/gcd.rb +18 -0
- data/test/helper.rb +144 -0
- data/test/info-var-bug.rb +47 -0
- data/test/info-var-bug2.rb +2 -0
- data/test/jump.rb +14 -0
- data/test/jump2.rb +27 -0
- data/test/next.rb +18 -0
- data/test/null.rb +1 -0
- data/test/output.rb +2 -0
- data/test/pm-base.rb +22 -0
- data/test/pm-bug.rb +3 -0
- data/test/pm-catch.rb +12 -0
- data/test/pm-catch2.rb +27 -0
- data/test/pm-catch3.rb +47 -0
- data/test/pm.rb +11 -0
- data/test/raise.rb +3 -0
- data/test/rdebug-save.1 +7 -0
- data/test/runall +12 -0
- data/test/scope-var.rb +29 -0
- data/test/tdebug.rb +248 -0
- data/test/test-annotate.rb +25 -0
- data/test/test-break-bad.rb +37 -0
- data/test/test-breakpoints.rb +25 -0
- data/test/test-catch.rb +25 -0
- data/test/test-catch2.rb +25 -0
- data/test/test-catch3.rb +25 -0
- data/test/test-condition.rb +25 -0
- data/test/test-ctrl.rb +55 -0
- data/test/test-display.rb +26 -0
- data/test/test-dollar-0.rb +40 -0
- data/test/test-edit.rb +26 -0
- data/test/test-emacs-basic.rb +26 -0
- data/test/test-enable.rb +25 -0
- data/test/test-finish.rb +34 -0
- data/test/test-frame.rb +34 -0
- data/test/test-help.rb +60 -0
- data/test/test-hist.rb +68 -0
- data/test/test-info-thread.rb +32 -0
- data/test/test-info-var.rb +47 -0
- data/test/test-info.rb +26 -0
- data/test/test-init.rb +44 -0
- data/test/test-jump.rb +35 -0
- data/test/test-list.rb +25 -0
- data/test/test-method.rb +34 -0
- data/test/test-next.rb +25 -0
- data/test/test-output.rb +26 -0
- data/test/test-quit.rb +30 -0
- data/test/test-raise.rb +25 -0
- data/test/test-save.rb +31 -0
- data/test/test-scope-var.rb +25 -0
- data/test/test-setshow.rb +25 -0
- data/test/test-source.rb +25 -0
- data/test/test-stepping.rb +26 -0
- data/test/test-trace.rb +47 -0
- data/test/thread1.rb +26 -0
- data/test/trunc-call.rb +31 -0
- metadata +364 -0
@@ -0,0 +1,502 @@
|
|
1
|
+
;;; rdebug-core.el --- Core parts of the Ruby debugger user
|
2
|
+
;;; interface. It pulls in other parts of the debugger.
|
3
|
+
|
4
|
+
;; Copyright (C) 2006, 2007, 2008 Rocky Bernstein (rocky@gnu.org)
|
5
|
+
;; Copyright (C) 2007, 2008 Anders Lindgren
|
6
|
+
|
7
|
+
;; $Id: rdebug-core.el 909 2009-03-11 18:57:08Z rockyb $
|
8
|
+
|
9
|
+
;; This program is free software; you can redistribute it and/or modify
|
10
|
+
;; it under the terms of the GNU General Public License as published by
|
11
|
+
;; the Free Software Foundation; either version 2, or (at your option)
|
12
|
+
;; any later version.
|
13
|
+
|
14
|
+
;; This program is distributed in the hope that it will be useful,
|
15
|
+
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
16
|
+
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
17
|
+
;; GNU General Public License for more details.
|
18
|
+
|
19
|
+
;; You should have received a copy of the GNU General Public License
|
20
|
+
;; along with GNU Emacs; see the file COPYING. If not, write to the
|
21
|
+
;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
22
|
+
;; Boston, MA 02111-1307, USA.
|
23
|
+
|
24
|
+
;;; Commentary:
|
25
|
+
|
26
|
+
;; See the manual and the file `rdebug.el' for more information.
|
27
|
+
|
28
|
+
;; This file implements the core of the debugger.
|
29
|
+
|
30
|
+
;;; Code:
|
31
|
+
|
32
|
+
;; -------------------------------------------------------------------
|
33
|
+
;; Consistency checks.
|
34
|
+
;;
|
35
|
+
|
36
|
+
(if (< emacs-major-version 22)
|
37
|
+
(error
|
38
|
+
"This version of rdebug.el needs at least Emacs 22 or greater - you have version %d"
|
39
|
+
emacs-major-version))
|
40
|
+
|
41
|
+
|
42
|
+
;; -------------------------------------------------------------------
|
43
|
+
;; Dependencies.
|
44
|
+
;;
|
45
|
+
|
46
|
+
(require 'gud)
|
47
|
+
(require 'cl)
|
48
|
+
|
49
|
+
(require 'rdebug)
|
50
|
+
(require 'rdebug-annotate)
|
51
|
+
(require 'rdebug-dbg)
|
52
|
+
(require 'rdebug-cmd)
|
53
|
+
(require 'rdebug-layouts)
|
54
|
+
(require 'rdebug-source)
|
55
|
+
(require 'rdebug-regexp)
|
56
|
+
(require 'rdebug-vars)
|
57
|
+
|
58
|
+
(defun rdebug-get-script-name (args)
|
59
|
+
"Parse command line ARGS.
|
60
|
+
|
61
|
+
A list containing the script name, and whether the annotate
|
62
|
+
option was set is returned.
|
63
|
+
|
64
|
+
Initially annotate should be set to nil. Argument ARGS contains
|
65
|
+
a tokenized list of the command line."
|
66
|
+
;; Parse the following:
|
67
|
+
;;
|
68
|
+
;; [ruby ruby-options] rdebug rdebug-options script-name script-options
|
69
|
+
(and args
|
70
|
+
(let ((name nil)
|
71
|
+
(annotate-p nil))
|
72
|
+
;; Strip of optional "ruby" or "ruby182" etc.
|
73
|
+
(when (string-match "^ruby[0-9]*$"
|
74
|
+
(file-name-sans-extension
|
75
|
+
(file-name-nondirectory (car args))))
|
76
|
+
(pop args)
|
77
|
+
(while (and args
|
78
|
+
(string-match "^-" (car args)))
|
79
|
+
(if (member (car args) '("-e" "-r" "-I" "-C" "-F" "-K"))
|
80
|
+
(pop args))
|
81
|
+
(pop args)))
|
82
|
+
;; Remove "rdebug" from "rdebug --rdebug-options script
|
83
|
+
;; --script-options"
|
84
|
+
(pop args)
|
85
|
+
;; Skip to the first non-option argument.
|
86
|
+
(while (and args
|
87
|
+
(not name))
|
88
|
+
(let ((arg (pop args)))
|
89
|
+
(cond
|
90
|
+
;; Annotation or emacs option with level number.
|
91
|
+
((or (member arg '("--annotate" "-A"))
|
92
|
+
(equal arg "--emacs"))
|
93
|
+
(setq annotate-p t)
|
94
|
+
(pop args))
|
95
|
+
;; Combined annotation and level option.
|
96
|
+
((string-match "^--annotate=[0-9]" arg)
|
97
|
+
(setq annotate-p t))
|
98
|
+
;; Options with arguments.
|
99
|
+
((member arg '("-h" "--host" "-p" "--port"
|
100
|
+
"-I" "--include" "-r" "--require"))
|
101
|
+
(pop args))
|
102
|
+
((string-match "^-" arg)
|
103
|
+
nil)
|
104
|
+
(t
|
105
|
+
(setq name arg)))))
|
106
|
+
(and name
|
107
|
+
(list name annotate-p)))))
|
108
|
+
|
109
|
+
;; -------------------------------------------------------------------
|
110
|
+
;; Window configuration state support.
|
111
|
+
;;
|
112
|
+
|
113
|
+
(defun rdebug-set-window-configuration-state (state &optional dont-restore)
|
114
|
+
"Change window configuration state.
|
115
|
+
|
116
|
+
Two states are supported, `original' and `debugger'.
|
117
|
+
|
118
|
+
When `dont-restore' is non-nil, the old window layout is not
|
119
|
+
restored. This is used when a new layout is being drawn, for
|
120
|
+
example when the debugger starts."
|
121
|
+
(rdebug-debug-message "Setting state to %s (was %s)"
|
122
|
+
state rdebug-window-configuration-state)
|
123
|
+
(when (not (eq state rdebug-window-configuration-state))
|
124
|
+
;; Save the previous state.
|
125
|
+
(cond ((not (eq rdebug-window-configuration-state 'original))
|
126
|
+
(setq rdebug-debugger-window-configuration
|
127
|
+
(current-window-configuration)))
|
128
|
+
((eq rdebug-window-configuration-state 'original)
|
129
|
+
(setq rdebug-original-window-configuration
|
130
|
+
(current-window-configuration))))
|
131
|
+
(unless dont-restore
|
132
|
+
;; Switch to the saved state,
|
133
|
+
(cond
|
134
|
+
((not (eq state 'original))
|
135
|
+
(if rdebug-debugger-window-configuration
|
136
|
+
(set-window-configuration rdebug-debugger-window-configuration)))
|
137
|
+
((eq state 'original)
|
138
|
+
(if rdebug-original-window-configuration
|
139
|
+
(set-window-configuration rdebug-original-window-configuration)))))
|
140
|
+
(setq rdebug-window-configuration-state state)))
|
141
|
+
|
142
|
+
|
143
|
+
;; have to bind rdebug-file-queue before installing the kill-emacs-hook
|
144
|
+
(defvar rdebug-file-queue nil
|
145
|
+
"Queue of Makefile temp files awaiting execution.
|
146
|
+
Currently-active file is at the head of the list.")
|
147
|
+
|
148
|
+
(defun rdebug-goto-traceback-line (pt)
|
149
|
+
"Display the location PT in a source file of the Ruby traceback line."
|
150
|
+
(interactive "d")
|
151
|
+
(save-excursion
|
152
|
+
(goto-char pt)
|
153
|
+
(let ((s (buffer-substring (line-beginning-position) (line-end-position)))
|
154
|
+
(gud-comint-buffer (current-buffer)))
|
155
|
+
(when (string-match rdebug-traceback-line-re s)
|
156
|
+
(rdebug-display-line
|
157
|
+
(substring s (match-beginning 1) (match-end 1))
|
158
|
+
(string-to-number (substring s (match-beginning 2) (match-end 2))))
|
159
|
+
))))
|
160
|
+
|
161
|
+
(defun rdebug-goto-dollarbang-traceback-line (pt)
|
162
|
+
"Display the location PT in a source file of the Ruby $! traceback line."
|
163
|
+
(interactive "d")
|
164
|
+
(save-excursion
|
165
|
+
(goto-char pt)
|
166
|
+
(let ((s (buffer-substring (line-beginning-position) (line-end-position)))
|
167
|
+
(gud-comint-buffer (current-buffer)))
|
168
|
+
(when (string-match rdebug-dollarbang-traceback-line-re s)
|
169
|
+
(rdebug-display-line
|
170
|
+
(substring s (match-beginning 1) (match-end 1))
|
171
|
+
(string-to-number (substring s (match-beginning 2) (match-end 2))))
|
172
|
+
))))
|
173
|
+
|
174
|
+
;; -------------------------------------------------------------------
|
175
|
+
;; Secondary buffers.
|
176
|
+
;;
|
177
|
+
|
178
|
+
(require 'rdebug-secondary)
|
179
|
+
(require 'rdebug-breaks)
|
180
|
+
(require 'rdebug-frames)
|
181
|
+
(require 'rdebug-help)
|
182
|
+
(require 'rdebug-output)
|
183
|
+
(require 'rdebug-varbuf)
|
184
|
+
(require 'rdebug-watch)
|
185
|
+
|
186
|
+
|
187
|
+
;; -------------------------------------------------------------------
|
188
|
+
;; Windows.
|
189
|
+
;;
|
190
|
+
|
191
|
+
(defun rdebug-setup-windows (&optional erase)
|
192
|
+
"Create the debugger user interface window layout.
|
193
|
+
|
194
|
+
If ERASE is non-nil, the content of the windows are erased
|
195
|
+
\(this does not apply to accumulative windows).
|
196
|
+
|
197
|
+
This function displays the source file (or, in some cases, a
|
198
|
+
buffer list) and creates the window layout. The variable
|
199
|
+
`rdebug-window-layout-function' controls the function that is
|
200
|
+
used to perform the actual layout.
|
201
|
+
|
202
|
+
This is only used when `rdebug-many-windows' is non-nil."
|
203
|
+
(rdebug-debug-enter "rdebug-setup-windows"
|
204
|
+
(rdebug-set-window-configuration-state 'debugger t)
|
205
|
+
(pop-to-buffer gud-comint-buffer)
|
206
|
+
(maphash
|
207
|
+
(lambda (name func)
|
208
|
+
(if erase
|
209
|
+
(let ((buf (rdebug-get-existing-buffer name gud-target-name)))
|
210
|
+
(if buf
|
211
|
+
(with-current-buffer buf
|
212
|
+
(let ((inhibit-read-only t))
|
213
|
+
(erase-buffer))))))
|
214
|
+
(rdebug-process-annotation name ""))
|
215
|
+
rdebug-annotation-setup-map)
|
216
|
+
(let ((buf
|
217
|
+
(cond (gud-last-last-frame
|
218
|
+
(gud-find-file (car gud-last-last-frame)))
|
219
|
+
(gud-target-name
|
220
|
+
(gud-find-file gud-target-name)))))
|
221
|
+
;; Put a buffer in window if we can't find a source file.
|
222
|
+
(unless buf (setq buf (get-buffer-create "*scratch*")))
|
223
|
+
(funcall rdebug-window-layout-function buf gud-target-name))))
|
224
|
+
|
225
|
+
|
226
|
+
(defun rdebug-setup-windows-initially ()
|
227
|
+
"Like `rdebug-setup-windows', but erase the content of accumulative windows.
|
228
|
+
This is called when the debugger starts."
|
229
|
+
(rdebug-setup-windows t))
|
230
|
+
|
231
|
+
|
232
|
+
(defun rdebug-restore-debugger-window-layout ()
|
233
|
+
"Restore the initial ruby debugger window layout."
|
234
|
+
(interactive)
|
235
|
+
(when rdebug-many-windows
|
236
|
+
(rdebug-setup-windows)))
|
237
|
+
|
238
|
+
(defun rdebug-display-debugger-window-configuration ()
|
239
|
+
"Switch from the \"original\" to the \"debugger\" window layout.
|
240
|
+
|
241
|
+
The rdebug debugger remembers, and can switch between, two window layouts:
|
242
|
+
* original -- the window layout when the debugger was started.
|
243
|
+
* debugger -- the window layout of the debugger, plus all changes made
|
244
|
+
since the debugger started.
|
245
|
+
|
246
|
+
The check-marks in the \"Window Layout\" menu indicates the
|
247
|
+
active window layout.
|
248
|
+
|
249
|
+
The function `rdebug-display-original-window-configuration'
|
250
|
+
switch to the \"original\" window configuration.
|
251
|
+
|
252
|
+
The function `rdebug-restore-debugger-window-layout' restores the
|
253
|
+
window layout to the state it was when the debugger started."
|
254
|
+
(interactive)
|
255
|
+
(rdebug-set-window-configuration-state 'debugger)
|
256
|
+
(message
|
257
|
+
"Type `M-x rdebug-display-original-window-configuration RET' to restore."))
|
258
|
+
|
259
|
+
|
260
|
+
;;This function is called upon quitting the debugger and
|
261
|
+
;;`rdebug-many-windows' is not nil. See also
|
262
|
+
;;`rdebug-display-debugger-window-configuration'."
|
263
|
+
|
264
|
+
(defun rdebug-display-original-window-configuration ()
|
265
|
+
"Switch from the \"debugger\" to the \"original\" window layout.
|
266
|
+
|
267
|
+
The rdebug debugger remembers, and can switch between, two window layouts:
|
268
|
+
* original -- the window layout when the debugger was started.
|
269
|
+
* debugger -- the window layout of the debugger, plus all changes made
|
270
|
+
since the debugger started.
|
271
|
+
|
272
|
+
The check-marks in the \"Window Layout\" menu indicates the
|
273
|
+
active window layout.
|
274
|
+
|
275
|
+
The function `rdebug-display-debugger-window-configuration'
|
276
|
+
switch to the \"debugger\" window configuration."
|
277
|
+
(interactive)
|
278
|
+
(rdebug-set-window-configuration-state 'original)
|
279
|
+
(message
|
280
|
+
"Type `M-x rdebug-display-debugger-window-configuration RET' to restore."))
|
281
|
+
|
282
|
+
|
283
|
+
;; -------------------------------------------------------------------
|
284
|
+
;; The `rdebug' command and support functions.
|
285
|
+
;;
|
286
|
+
|
287
|
+
(defun rdebug-process-sentinel (process event)
|
288
|
+
"Restore the original window configuration when the debugger process exits."
|
289
|
+
(rdebug-debug-enter "rdebug-process-sentinel"
|
290
|
+
(rdebug-debug-message "status=%S event=%S state=%S"
|
291
|
+
(process-status process)
|
292
|
+
event
|
293
|
+
rdebug-window-configuration-state)
|
294
|
+
(gud-sentinel process event)
|
295
|
+
;; This will "flush" the last annotation. Especially "output"
|
296
|
+
;; (a.k.a. "starting") annotations don't have an end markers, if
|
297
|
+
;; the last command printed something.
|
298
|
+
(if (string= event "finished\n")
|
299
|
+
(gud-rdebug-marker-filter "\032\032\n"))
|
300
|
+
;; When the debugger process exited, when the comint buffer has no
|
301
|
+
;; buffer process (nil). When the debugger processes is replaced
|
302
|
+
;; with another process we should not restore the window
|
303
|
+
;; configuration.
|
304
|
+
(when (and (or (eq rdebug-restore-original-window-configuration t)
|
305
|
+
(and (eq rdebug-restore-original-window-configuration :many)
|
306
|
+
rdebug-many-windows))
|
307
|
+
(or (rdebug-dead-process-p)
|
308
|
+
(eq process (get-buffer-process gud-comint-buffer)))
|
309
|
+
(eq rdebug-window-configuration-state 'debugger)
|
310
|
+
(not (eq (process-status process) 'run)))
|
311
|
+
(rdebug-internal-short-key-mode-off)
|
312
|
+
(rdebug-set-window-configuration-state 'original)
|
313
|
+
(rdebug-reset-keymaps))))
|
314
|
+
|
315
|
+
|
316
|
+
;; Perform initializations common to all debuggers.
|
317
|
+
;; The first arg is the specified command line,
|
318
|
+
;; which starts with the program to debug.
|
319
|
+
;; The other three args specify the values to use
|
320
|
+
;; for local variables in the debugger buffer.
|
321
|
+
(defun rdebug-common-init (rdebug-buffer-name rdebug-cmd-buffer target-name
|
322
|
+
program args
|
323
|
+
marker-filter
|
324
|
+
&optional find-file)
|
325
|
+
"Perform initializations common to all debuggers.
|
326
|
+
|
327
|
+
RDEBUG-BUFFER-NAME is the specified command line, which starts
|
328
|
+
with the program to debug. PROGRAM, ARGS and MARKER-FILTER
|
329
|
+
specify the values to use for local variables in the debugger
|
330
|
+
buffer."
|
331
|
+
(if rdebug-cmd-buffer
|
332
|
+
(progn
|
333
|
+
(pop-to-buffer rdebug-cmd-buffer)
|
334
|
+
(when (and rdebug-cmd-buffer (get-buffer-process rdebug-cmd-buffer))
|
335
|
+
(error "This program is already being debugged"))
|
336
|
+
(apply 'make-comint rdebug-buffer-name program nil args)
|
337
|
+
(or (bolp) (newline)))
|
338
|
+
(pop-to-buffer (setq rdebug-cmd-buffer
|
339
|
+
(apply 'make-comint rdebug-buffer-name program nil
|
340
|
+
args))))
|
341
|
+
|
342
|
+
;; Since comint clobbered the mode, we don't set it until now.
|
343
|
+
(gud-mode)
|
344
|
+
(set (make-local-variable 'gud-target-name) target-name)
|
345
|
+
(set (make-local-variable 'gud-marker-filter) marker-filter)
|
346
|
+
(set (make-local-variable 'gud-minor-mode) 'rdebug)
|
347
|
+
(set (make-local-variable 'gud-last-frame) nil)
|
348
|
+
(set (make-local-variable 'gud-last-last-frame) nil)
|
349
|
+
|
350
|
+
(let ((buffer-process (get-buffer-process (current-buffer))))
|
351
|
+
(if buffer-process
|
352
|
+
(progn
|
353
|
+
(set-process-filter buffer-process 'gud-filter)
|
354
|
+
(set-process-sentinel buffer-process 'gud-sentinel))))
|
355
|
+
(gud-set-buffer))
|
356
|
+
|
357
|
+
;;;###autoload
|
358
|
+
(defun rdebug (command-line)
|
359
|
+
"Invoke the rdebug Ruby debugger and start the Emacs user interface.
|
360
|
+
|
361
|
+
String COMMAND-LINE specifies how to run rdebug.
|
362
|
+
|
363
|
+
By default, the \"standard\" user window layout looks like the following:
|
364
|
+
|
365
|
+
+----------------------------------------------------------------------+
|
366
|
+
| Toolbar |
|
367
|
+
+-----------------------------------+----------------------------------+
|
368
|
+
| Debugger shell | Variables buffer |
|
369
|
+
+-----------------------------------+----------------------------------+
|
370
|
+
| | |
|
371
|
+
| Source buffer | Output buffer |
|
372
|
+
| | |
|
373
|
+
+-----------------------------------+----------------------------------+
|
374
|
+
| Stack Frame buffer | Breakpoints buffer |
|
375
|
+
+-----------------------------------+----------------------------------+
|
376
|
+
|
377
|
+
The variable `rdebug-window-layout-function' can be
|
378
|
+
customized so that another layout is used. In addition to a
|
379
|
+
number of predefined layouts it's possible to define a function
|
380
|
+
to perform a custom layout.
|
381
|
+
|
382
|
+
If `rdebug-many-windows' is nil, only a traditional debugger
|
383
|
+
shell and source window is opened.
|
384
|
+
|
385
|
+
The directory containing the debugged script becomes the initial
|
386
|
+
working directory and source-file directory for your debugger.
|
387
|
+
|
388
|
+
The custom variable `gud-rdebug-command-name' sets the command
|
389
|
+
and options used to invoke rdebug."
|
390
|
+
(interactive
|
391
|
+
(let ((init (buffer-file-name)))
|
392
|
+
(setq init (and init
|
393
|
+
(file-name-nondirectory init)))
|
394
|
+
(list (gud-query-cmdline 'rdebug init))))
|
395
|
+
(rdebug-debug-enter "rdebug"
|
396
|
+
(rdebug-set-window-configuration-state 'debugger t)
|
397
|
+
;; Parse the command line and pick out the script name and whether
|
398
|
+
;; --annotate has been set.
|
399
|
+
(let* ((words (with-no-warnings
|
400
|
+
(split-string-and-unquote command-line)))
|
401
|
+
(script-name-annotate-p (rdebug-get-script-name
|
402
|
+
(gud-rdebug-massage-args "1" words)))
|
403
|
+
(target-name (file-name-nondirectory (car script-name-annotate-p)))
|
404
|
+
(annotate-p (cadr script-name-annotate-p))
|
405
|
+
(cmd-buffer-name (format "rdebug-cmd-%s" target-name))
|
406
|
+
(rdebug-cmd-buffer-name (format "*%s*" cmd-buffer-name))
|
407
|
+
(rdebug-cmd-buffer (get-buffer rdebug-cmd-buffer-name))
|
408
|
+
(program (car words))
|
409
|
+
(args (cdr words))
|
410
|
+
(gud-chdir-before-run nil))
|
411
|
+
|
412
|
+
;; `gud-rdebug-massage-args' needs whole `command-line'.
|
413
|
+
;; command-line is refered through dynamic scope.
|
414
|
+
(rdebug-common-init cmd-buffer-name rdebug-cmd-buffer target-name
|
415
|
+
program args
|
416
|
+
'gud-rdebug-marker-filter
|
417
|
+
'gud-rdebug-find-file)
|
418
|
+
(setq comint-process-echoes t)
|
419
|
+
|
420
|
+
(setq rdebug-inferior-status "running")
|
421
|
+
|
422
|
+
(rdebug-command-initialization)
|
423
|
+
|
424
|
+
;; Setup exit callback so that the original frame configuration
|
425
|
+
;; can be restored.
|
426
|
+
(let ((process (get-buffer-process gud-comint-buffer)))
|
427
|
+
(when process
|
428
|
+
(unless (equal rdebug-line-width 120)
|
429
|
+
(gud-call (format "set width %d" rdebug-line-width)))
|
430
|
+
(set-process-sentinel process
|
431
|
+
'rdebug-process-sentinel)))
|
432
|
+
|
433
|
+
|
434
|
+
;; Add the buffer-displaying commands to the Gud buffer,
|
435
|
+
;; FIXME: combine with code in rdebug-track.el; make common
|
436
|
+
;; command buffer mode map.
|
437
|
+
(let ((prefix-map (make-sparse-keymap)))
|
438
|
+
(define-key (current-local-map) gud-key-prefix prefix-map)
|
439
|
+
(define-key prefix-map "t" 'rdebug-goto-traceback-line)
|
440
|
+
(define-key prefix-map "!" 'rdebug-goto-dollarbang-traceback-line)
|
441
|
+
(rdebug-populate-secondary-buffer-map-plain prefix-map))
|
442
|
+
|
443
|
+
(rdebug-populate-common-keys (current-local-map))
|
444
|
+
(rdebug-populate-debugger-menu (current-local-map))
|
445
|
+
|
446
|
+
(setq comint-prompt-regexp (concat "^" rdebug-input-prompt-regexp))
|
447
|
+
(setq paragraph-start comint-prompt-regexp)
|
448
|
+
|
449
|
+
(setcdr (assq 'rdebug-debugger-support-minor-mode minor-mode-map-alist)
|
450
|
+
rdebug-debugger-support-minor-mode-map-when-active)
|
451
|
+
(when rdebug-many-windows
|
452
|
+
(rdebug-setup-windows-initially))
|
453
|
+
|
454
|
+
(run-hooks 'rdebug-mode-hook))))
|
455
|
+
|
456
|
+
|
457
|
+
(defadvice gud-reset (before rdebug-reset)
|
458
|
+
"Rdebug cleanup - remove debugger's internal buffers (frame, breakpoints, etc.)."
|
459
|
+
(rdebug-breakpoint-remove-all-icons)
|
460
|
+
(dolist (buffer (buffer-list))
|
461
|
+
(when (string-match "\\*rdebug-[a-z]+\\*" (buffer-name buffer))
|
462
|
+
(let ((w (get-buffer-window buffer)))
|
463
|
+
(when w
|
464
|
+
(delete-window w)))
|
465
|
+
(kill-buffer buffer))))
|
466
|
+
(ad-activate 'gud-reset)
|
467
|
+
|
468
|
+
(defun rdebug-reset ()
|
469
|
+
"Rdebug cleanup - remove debugger's internal buffers (frame, breakpoints, etc.)."
|
470
|
+
(interactive)
|
471
|
+
(rdebug-breakpoint-remove-all-icons)
|
472
|
+
(dolist (buffer (buffer-list))
|
473
|
+
(when (string-match "\\*rdebug-[a-z]+\\*" (buffer-name buffer))
|
474
|
+
(let ((w (get-buffer-window buffer)))
|
475
|
+
(when w
|
476
|
+
(delete-window w)))
|
477
|
+
(kill-buffer buffer))))
|
478
|
+
|
479
|
+
(defun rdebug-reset-keymaps()
|
480
|
+
"This unbinds the special debugger keys of the source buffers."
|
481
|
+
(interactive)
|
482
|
+
(setcdr (assq 'rdebug-debugger-support-minor-mode minor-mode-map-alist)
|
483
|
+
rdebug-debugger-support-minor-mode-map-when-deactive))
|
484
|
+
|
485
|
+
|
486
|
+
(defun rdebug-customize ()
|
487
|
+
"Use `customize' to edit the settings of the `rdebug' debugger."
|
488
|
+
(interactive)
|
489
|
+
(customize-group 'rdebug))
|
490
|
+
|
491
|
+
|
492
|
+
;; -------------------------------------------------------------------
|
493
|
+
;; The end.
|
494
|
+
;;
|
495
|
+
|
496
|
+
(provide 'rdebug-core)
|
497
|
+
|
498
|
+
;;; Local variables:
|
499
|
+
;;; eval:(put 'rdebug-debug-enter 'lisp-indent-hook 1)
|
500
|
+
;;; End:
|
501
|
+
|
502
|
+
;;; rdebug-core.el ends here
|