annotate lisp/comint/gdb.el @ 70:131b0175ea99 r20-0b30

Import from CVS: tag r20-0b30
author cvs
date Mon, 13 Aug 2007 09:02:59 +0200
parents 8fc7fe29b841
children b9518feda344
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1 ;;; gdb.el --- run gdb under Emacs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3 ;; Author: W. Schelter, University of Texas
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4 ;; wfs@rascal.ics.utexas.edu
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5 ;; Rewritten by rms.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6 ;; Keywords: c, unix, tools, debugging
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
8 ;; Some ideas are due to Masanobu.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
9
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
10 ;; This file is part of XEmacs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
11
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
12 ;; XEmacs is free software; you can redistribute it and/or modify it
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
13 ;; under the terms of the GNU General Public License as published by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
14 ;; the Free Software Foundation; either version 2, or (at your option)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
15 ;; any later version.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
16
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
17 ;; XEmacs is distributed in the hope that it will be useful, but
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
18 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
20 ;; General Public License for more details.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
21
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
22 ;; You should have received a copy of the GNU General Public License
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 22
diff changeset
23 ;; along with XEmacs; see the file COPYING. If not, write to the
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 22
diff changeset
24 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 22
diff changeset
25 ;; Boston, MA 02111-1307, USA.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
26
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
27 ;; Description of GDB interface:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
28
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
29 ;; A facility is provided for the simultaneous display of the source code
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
30 ;; in one window, while using gdb to step through a function in the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
31 ;; other. A small arrow in the source window, indicates the current
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
32 ;; line.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
33
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
34 ;; Starting up:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
35
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
36 ;; In order to use this facility, invoke the command GDB to obtain a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
37 ;; shell window with the appropriate command bindings. You will be asked
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
38 ;; for the name of a file to run. Gdb will be invoked on this file, in a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
39 ;; window named *gdb-foo* if the file is foo.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
40
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
41 ;; M-s steps by one line, and redisplays the source file and line.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
42
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
43 ;; You may easily create additional commands and bindings to interact
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
44 ;; with the display. For example to put the gdb command next on \M-n
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
45 ;; (def-gdb next "\M-n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
46
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
47 ;; This causes the emacs command gdb-next to be defined, and runs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
48 ;; gdb-display-frame after the command.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
49
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
50 ;; gdb-display-frame is the basic display function. It tries to display
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
51 ;; in the other window, the file and line corresponding to the current
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
52 ;; position in the gdb window. For example after a gdb-step, it would
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
53 ;; display the line corresponding to the position for the last step. Or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
54 ;; if you have done a backtrace in the gdb buffer, and move the cursor
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
55 ;; into one of the frames, it would display the position corresponding to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
56 ;; that frame.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
57
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
58 ;; gdb-display-frame is invoked automatically when a filename-and-line-number
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
59 ;; appears in the output.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
60
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
61 (require 'comint)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
62 (require 'shell)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
63
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
64 (condition-case nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
65 (if (featurep 'toolbar)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
66 (require 'eos-toolbar "sun-eos-toolbar"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
67 (error nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
68
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
69 (defvar gdb-last-frame)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
70 (defvar gdb-delete-prompt-marker)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
71 (defvar gdb-filter-accumulator)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
72 (defvar gdb-last-frame-displayed-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
73 (defvar gdb-arrow-extent nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
74 (or (fboundp 'make-glyph) (fset 'make-glyph 'identity)) ; work w/ pre beta v12
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
75 (defvar gdb-arrow-glyph (make-glyph "=>"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
76
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
77 (make-face 'gdb-arrow-face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
78 (or (face-differs-from-default-p 'gdb-arrow-face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
79 ;; Usually has a better default value than highlight does
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
80 (copy-face 'isearch 'gdb-arrow-face))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
81
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
82 ;; Hooks can side-effect extent arg to change extent properties
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
83 (defvar gdb-arrow-extent-hooks '())
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
84
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
85 (defvar gdb-prompt-pattern "^>\\|^(.*gdb[+]?) *\\|^---Type <return> to.*--- *"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
86 "A regexp to recognize the prompt for gdb or gdb+.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
87
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
88 (defvar gdb-mode-map nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
89 "Keymap for gdb-mode.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
90
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
91 (defvar gdb-toolbar
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
92 '([eos::toolbar-stop-at-icon
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
93 gdb-toolbar-break
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
94 t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
95 "Stop at selected position"]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
96 [eos::toolbar-stop-in-icon
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
97 gdb-toolbar-break
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
98 t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
99 "Stop in function whose name is selected"]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
100 [eos::toolbar-clear-at-icon
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
101 gdb-toolbar-clear
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
102 t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
103 "Clear at selected position"]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
104 [eos::toolbar-evaluate-icon
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
105 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
106 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
107 "Evaluate selected expression; shows in separate XEmacs frame"]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
108 [eos::toolbar-evaluate-star-icon
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
109 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
110 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
111 "Evaluate selected expression as a pointer; shows in separate XEmacs frame"]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
112 [eos::toolbar-run-icon
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
113 gdb-run
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
114 t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
115 "Run current program"]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
116 [eos::toolbar-cont-icon
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
117 gdb-cont
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
118 t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
119 "Continue current program"]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
120 [eos::toolbar-step-into-icon
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
121 gdb-step
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
122 t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
123 "Step into (aka step)"]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
124 [eos::toolbar-step-over-icon
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
125 gdb-next
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
126 t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
127 "Step over (aka next)"]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
128 [eos::toolbar-up-icon
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
129 gdb-up
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
130 t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
131 "Stack Up (towards \"cooler\" - less recently visited - frames)"]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
132 [eos::toolbar-down-icon
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
133 gdb-down
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
134 t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
135 "Stack Down (towards \"warmer\" - more recently visited - frames)"]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
136 [eos::toolbar-fix-icon nil nil "Fix (not available with gdb)"]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
137 [eos::toolbar-build-icon
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
138 toolbar-compile
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
139 t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
140 "Build (aka make -NYI)"]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
141 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
142
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
143 (if gdb-mode-map
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
144 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
145 (setq gdb-mode-map (make-sparse-keymap))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
146 (set-keymap-name gdb-mode-map 'gdb-mode-map)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
147 (set-keymap-parents gdb-mode-map (list comint-mode-map))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
148 (define-key gdb-mode-map "\C-l" 'gdb-refresh)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
149 (define-key gdb-mode-map "\C-c\C-c" 'gdb-control-c-subjob)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
150 (define-key gdb-mode-map "\t" 'comint-dynamic-complete)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
151 (define-key gdb-mode-map "\M-?" 'comint-dynamic-list-completions))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
152
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
153 (define-key ctl-x-map " " 'gdb-break)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
154 (define-key ctl-x-map "&" 'send-gdb-command)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
155
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
156 ;;Of course you may use `def-gdb' with any other gdb command, including
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
157 ;;user defined ones.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
158
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
159 (defmacro def-gdb (name key &optional doc &rest forms)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
160 (let* ((fun (intern (format "gdb-%s" name)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
161 (cstr (list 'if '(not (= 1 arg))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
162 (list 'format "%s %s" name 'arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
163 name)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
164 (list 'progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
165 (nconc (list 'defun fun '(arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
166 (or doc "")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
167 '(interactive "p")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
168 (list 'gdb-call cstr))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
169 forms)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
170 (and key (list 'define-key 'gdb-mode-map key (list 'quote fun))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
171
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
172 (def-gdb "step" "\M-s" "Step one source line with display"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
173 (gdb-delete-arrow-extent))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
174 (def-gdb "stepi" "\M-i" "Step one instruction with display"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
175 (gdb-delete-arrow-extent))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
176 (def-gdb "finish" "\C-c\C-f" "Finish executing current function"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
177 (gdb-delete-arrow-extent))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
178 (def-gdb "run" nil "Run the current program"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
179 (gdb-delete-arrow-extent))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
180
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
181 ;;"next" and "cont" were bound to M-n and M-c in Emacs 18, but these are
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
182 ;;poor choices, since M-n is used for history navigation and M-c is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
183 ;;capitalize-word. These are defined without key bindings so that users
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
184 ;;may choose their own bindings.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
185 (def-gdb "next" "\C-c\C-n" "Step one source line (skip functions)"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
186 (gdb-delete-arrow-extent))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
187 (def-gdb "cont" "\C-c\M-c" "Proceed with the program"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
188 (gdb-delete-arrow-extent))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
189
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
190 (def-gdb "up" "\C-c<" "Go up N stack frames (numeric arg) with display")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
191 (def-gdb "down" "\C-c>" "Go down N stack frames (numeric arg) with display")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
192
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
193 (defvar gdb-display-mode nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
194 "Minor mode for gdb frame display")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
195 (or (assq 'gdb-display-mode minor-mode-alist)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
196 (setq minor-mode-alist
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
197 (purecopy
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
198 (append minor-mode-alist
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
199 '((gdb-display-mode " Frame"))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
200
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
201 (defun gdb-display-mode (&optional arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
202 "Toggle GDB Frame display mode
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
203 With arg, turn display mode on if and only if arg is positive.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
204 In the display minor mode, source file are displayed in another
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
205 window for repective \\[gdb-display-frame] commands."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
206 (interactive "P")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
207 (setq gdb-display-mode (if (null arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
208 (not gdb-display-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
209 (> (prefix-numeric-value arg) 0))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
210
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
211
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
212 (defun gdb-mode ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
213 "Major mode for interacting with an inferior Gdb process.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
214 The following commands are available:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
215
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
216 \\{gdb-mode-map}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
217
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
218 \\[gdb-display-frame] displays in the other window
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
219 the last line referred to in the gdb buffer. See also
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
220 \\[gdb-display-mode].
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
221
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
222 \\[gdb-step],\\[gdb-next], and \\[gdb-nexti] in the gdb window,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
223 call gdb to step,next or nexti and then update the other window
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
224 with the current file and position.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
225
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
226 If you are in a source file, you may select a point to break
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
227 at, by doing \\[gdb-break].
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
228
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
229 Commands:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
230 Many commands are inherited from comint mode.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
231 Additionally we have:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
232
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
233 \\[gdb-display-frame] display frames file in other window
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
234 \\[gdb-step] advance one line in program
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
235 \\[send-gdb-command] used for special printing of an arg at the current point.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
236 C-x SPACE sets break point at current line."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
237 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
238 (comint-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
239 (use-local-map gdb-mode-map)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
240 (set-syntax-table c-mode-syntax-table)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
241 (make-local-variable 'gdb-last-frame-displayed-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
242 (make-local-variable 'gdb-last-frame)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
243 (make-local-variable 'gdb-delete-prompt-marker)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
244 (make-local-variable 'gdb-display-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
245 (make-local-variable' gdb-filter-accumulator)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
246 (setq gdb-last-frame nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
247 gdb-delete-prompt-marker nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
248 gdb-filter-accumulator nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
249 gdb-display-mode t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
250 major-mode 'gdb-mode
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
251 mode-name "Inferior GDB"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
252 comint-prompt-regexp gdb-prompt-pattern
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
253 gdb-last-frame-displayed-p t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
254 (set (make-local-variable 'shell-dirtrackp) t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
255 ;;(make-local-variable 'gdb-arrow-extent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
256 (and (extentp gdb-arrow-extent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
257 (delete-extent gdb-arrow-extent))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
258 (setq gdb-arrow-extent nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
259 ;; XEmacs change:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
260 (make-local-hook 'kill-buffer-hook)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
261 (add-hook 'kill-buffer-hook 'gdb-delete-arrow-extent nil t)
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 22
diff changeset
262 (setq comint-input-sentinel 'shell-directory-tracker)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
263 (run-hooks 'gdb-mode-hook))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
264
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
265 (defun gdb-delete-arrow-extent ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
266 (let ((inhibit-quit t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
267 (if gdb-arrow-extent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
268 (delete-extent gdb-arrow-extent))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
269 (setq gdb-arrow-extent nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
270
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
271 (defvar current-gdb-buffer nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
272
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
273 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
274 (defvar gdb-command-name "gdb"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
275 "Pathname for executing gdb.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
276
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
277 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
278 (defun gdb (path &optional corefile)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
279 "Run gdb on program FILE in buffer *gdb-FILE*.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
280 The directory containing FILE becomes the initial working directory
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
281 and source-file directory for GDB. If you wish to change this, use
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
282 the GDB commands `cd DIR' and `directory'."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
283 (interactive "FRun gdb on file: ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
284 (setq path (file-truename (expand-file-name path)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
285 (let ((file (file-name-nondirectory path)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
286 (switch-to-buffer (concat "*gdb-" file "*"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
287 (setq default-directory (file-name-directory path))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
288 (or (bolp) (newline))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
289 (insert "Current directory is " default-directory "\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
290 (apply 'make-comint
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
291 (concat "gdb-" file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
292 (substitute-in-file-name gdb-command-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
293 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
294 "-fullname"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
295 "-cd" default-directory
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
296 file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
297 (and corefile (list corefile)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
298 (set-process-filter (get-buffer-process (current-buffer)) 'gdb-filter)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
299 (set-process-sentinel (get-buffer-process (current-buffer)) 'gdb-sentinel)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
300 ;; XEmacs change: turn on gdb mode after setting up the proc filters
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
301 ;; for the benefit of shell-font.el
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
302 (gdb-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
303 (gdb-set-buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
304
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
305 ;;;####autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
306 (defun gdb-with-core (file corefile)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
307 "Debug a program using a corefile."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
308 (interactive "fProgram to debug: \nfCore file to use: ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
309 (gdb file corefile))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
310
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
311 (defun gdb-set-buffer ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
312 (cond ((eq major-mode 'gdb-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
313 (setq current-gdb-buffer (current-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
314 (if (featurep 'eos-toolbar)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
315 (set-specifier default-toolbar (cons (current-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
316 gdb-toolbar))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
317
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
318
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
319 ;; This function is responsible for inserting output from GDB
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
320 ;; into the buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
321 ;; Aside from inserting the text, it notices and deletes
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
322 ;; each filename-and-line-number;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
323 ;; that GDB prints to identify the selected frame.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
324 ;; It records the filename and line number, and maybe displays that file.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
325 (defun gdb-filter (proc string)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
326 (let ((inhibit-quit t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
327 (save-current-buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
328 (set-buffer (process-buffer proc))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
329 (if gdb-filter-accumulator
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
330 (gdb-filter-accumulate-marker
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
331 proc (concat gdb-filter-accumulator string))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
332 (gdb-filter-scan-input proc string)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
333
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
334 (defun gdb-filter-accumulate-marker (proc string)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
335 (setq gdb-filter-accumulator nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
336 (if (> (length string) 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
337 (if (= (aref string 1) ?\032)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
338 (let ((end (string-match "\n" string)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
339 (if end
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
340 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
341 (let* ((first-colon (string-match ":" string 2))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
342 (second-colon
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
343 (string-match ":" string (1+ first-colon))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
344 (setq gdb-last-frame
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
345 (cons (substring string 2 first-colon)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
346 (string-to-int
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
347 (substring string (1+ first-colon)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
348 second-colon)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
349 (setq gdb-last-frame-displayed-p nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
350 (gdb-filter-scan-input proc
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
351 (substring string (1+ end))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
352 (setq gdb-filter-accumulator string)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
353 (gdb-filter-insert proc "\032")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
354 (gdb-filter-scan-input proc (substring string 1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
355 (setq gdb-filter-accumulator string)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
356
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
357 (defun gdb-filter-scan-input (proc string)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
358 (if (equal string "")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
359 (setq gdb-filter-accumulator nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
360 (let ((start (string-match "\032" string)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
361 (if start
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
362 (progn (gdb-filter-insert proc (substring string 0 start))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
363 (gdb-filter-accumulate-marker proc
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
364 (substring string start)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
365 (gdb-filter-insert proc string)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
366
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
367 (defun gdb-filter-insert (proc string)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
368 (let ((moving (= (point) (process-mark proc)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
369 (output-after-point (< (point) (process-mark proc))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
370 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
371 ;; Insert the text, moving the process-marker.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
372 (goto-char (process-mark proc))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
373 (insert-before-markers string)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
374 (set-marker (process-mark proc) (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
375 (gdb-maybe-delete-prompt)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
376 ;; Check for a filename-and-line number.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
377 (gdb-display-frame
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
378 ;; Don't display the specified file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
379 ;; unless (1) point is at or after the position where output appears
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
380 ;; and (2) this buffer is on the screen.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
381 (or output-after-point
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
382 (not (get-buffer-window (current-buffer))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
383 ;; Display a file only when a new filename-and-line-number appears.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
384 t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
385 (if moving (goto-char (process-mark proc))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
386
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
387 (let (s)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
388 (if (and (should-use-dialog-box-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
389 (setq s (or (string-match " (y or n) *\\'" string)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
390 (string-match " (yes or no) *\\'" string))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
391 (gdb-mouse-prompt-hack (substring string 0 s) (current-buffer))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
392 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
393
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
394 (defun gdb-mouse-prompt-hack (prompt buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
395 (popup-dialog-box
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
396 (list prompt
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
397 (vector "Yes" (list 'gdb-mouse-prompt-hack-answer 't buffer) t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
398 (vector "No" (list 'gdb-mouse-prompt-hack-answer 'nil buffer) t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
399 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
400 (vector "Cancel" (list 'gdb-mouse-prompt-hack-answer 'nil buffer) t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
401 )))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
402
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
403 (defun gdb-mouse-prompt-hack-answer (answer buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
404 (let ((b (current-buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
405 (unwind-protect
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
406 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
407 (set-buffer buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
408 (goto-char (process-mark (get-buffer-process buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
409 (delete-region (point) (point-max))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
410 (insert (if answer "yes" "no"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
411 (comint-send-input))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
412 (set-buffer b))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
413
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
414 (defun gdb-sentinel (proc msg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
415 (cond ((null (buffer-name (process-buffer proc)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
416 ;; buffer killed
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
417 ;; Stop displaying an arrow in a source file.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
418 ;(setq overlay-arrow-position nil) -- done by kill-buffer-hook
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
419 (set-process-buffer proc nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
420 ((memq (process-status proc) '(signal exit))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
421 ;; Stop displaying an arrow in a source file.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
422 (gdb-delete-arrow-extent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
423 ;; Fix the mode line.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
424 (setq modeline-process
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
425 (concat ": gdb " (symbol-name (process-status proc))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
426 (let* ((obuf (current-buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
427 ;; save-excursion isn't the right thing if
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
428 ;; process-buffer is current-buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
429 (unwind-protect
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
430 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
431 ;; Write something in *compilation* and hack its mode line,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
432 (set-buffer (process-buffer proc))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
433 ;; Force mode line redisplay soon
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
434 (set-buffer-modified-p (buffer-modified-p))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
435 (if (eobp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
436 (insert ?\n mode-name " " msg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
437 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
438 (goto-char (point-max))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
439 (insert ?\n mode-name " " msg)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
440 ;; If buffer and mode line will show that the process
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
441 ;; is dead, we can delete it now. Otherwise it
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
442 ;; will stay around until M-x list-processes.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
443 (delete-process proc))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
444 ;; Restore old buffer, but don't restore old point
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
445 ;; if obuf is the gdb buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
446 (set-buffer obuf))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
447
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
448
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
449 (defun gdb-refresh (&optional arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
450 "Fix up a possibly garbled display, and redraw the arrow."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
451 (interactive "P")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
452 (recenter arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
453 (gdb-display-frame))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
454
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
455 (defun gdb-display-frame (&optional nodisplay noauto)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
456 "Find, obey and delete the last filename-and-line marker from GDB.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
457 The marker looks like \\032\\032FILENAME:LINE:CHARPOS\\n.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
458 Obeying it means displaying in another window the specified file and line."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
459 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
460 (gdb-set-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
461 (and gdb-last-frame (not nodisplay)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
462 gdb-display-mode
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
463 (or (not gdb-last-frame-displayed-p) (not noauto))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
464 (progn (gdb-display-line (car gdb-last-frame) (cdr gdb-last-frame))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
465 (setq gdb-last-frame-displayed-p t))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
466
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
467 ;; Make sure the file named TRUE-FILE is in a buffer that appears on the screen
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
468 ;; and that its line LINE is visible.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
469 ;; Put the overlay-arrow on the line LINE in that buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
470
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
471 (defun gdb-display-line (true-file line &optional select-method)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
472 ;; FILE to display
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
473 ;; LINE number to highlight and make visible
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
474 ;; SELECT-METHOD 'source, 'debugger, or 'none. (default is 'debugger)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
475 (and (null select-method) (setq select-method 'debugger))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
476 (let* ((pre-display-buffer-function nil) ; screw it, put it all in one screen
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
477 (pop-up-windows t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
478 (source-buffer (find-file-noselect true-file))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
479 (source-window (display-buffer source-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
480 (debugger-window (get-buffer-window current-gdb-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
481 (extent gdb-arrow-extent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
482 pos)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
483 ;; XEmacs change: make sure we find a window displaying the source file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
484 ;; even if we are already sitting in it when a breakpoint is hit.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
485 ;; Otherwise the t argument to display-buffer will prevent it from being
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
486 ;; displayed.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
487 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
488 (cond ((eq select-method 'debugger)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
489 ;; might not already be displayed
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
490 (setq debugger-window (display-buffer current-gdb-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
491 (select-window debugger-window))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
492 ((eq select-method 'source)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
493 (select-window source-window))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
494 (and extent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
495 (not (eq (extent-object extent) source-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
496 (setq extent (delete-extent extent)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
497 (or extent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
498 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
499 (setq extent (make-extent 1 1 source-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
500 (set-extent-face extent 'gdb-arrow-face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
501 (set-extent-begin-glyph extent gdb-arrow-glyph)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
502 (set-extent-begin-glyph-layout extent 'whitespace)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
503 (set-extent-priority extent 2000)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
504 (setq gdb-arrow-extent extent)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
505 (save-current-buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
506 (set-buffer source-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
507 (save-restriction
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
508 (widen)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
509 (goto-line line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
510 (set-window-point source-window (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
511 (setq pos (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
512 (end-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
513 (set-extent-endpoints extent pos (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
514 (run-hook-with-args 'gdb-arrow-extent-hooks extent))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
515 (cond ((or (< pos (point-min)) (> pos (point-max)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
516 (widen)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
517 (goto-char pos))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
518 ;; Added by Stig. It caused lots of problems for several users
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
519 ;; and since its purpose is unclear it is getting commented out.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
520 ;;(and debugger-window
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
521 ;; (set-window-point debugger-window pos))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
522 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
523
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
524 (defun gdb-call (command)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
525 "Invoke gdb COMMAND displaying source in other window."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
526 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
527 (goto-char (point-max))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
528 ;; Record info on the last prompt in the buffer and its position.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
529 ;; This is used in gdb-maybe-delete-prompt
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
530 ;; to prevent multiple prompts from accumulating.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
531 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
532 (goto-char (process-mark (get-buffer-process current-gdb-buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
533 (let ((pt (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
534 (beginning-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
535 (setq gdb-delete-prompt-marker
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
536 (if (= (point) pt)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
537 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
538 (list (point-marker) (- pt (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
539 (buffer-substring (point) pt))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
540 (gdb-set-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
541 (process-send-string (get-buffer-process current-gdb-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
542 (concat command "\n")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
543
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
544 (defun gdb-maybe-delete-prompt ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
545 (if gdb-delete-prompt-marker
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
546 ;; Get the string that we used as the prompt before.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
547 (let ((prompt (nth 2 gdb-delete-prompt-marker))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
548 (length (nth 1 gdb-delete-prompt-marker)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
549 ;; Position after it.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
550 (goto-char (+ (car gdb-delete-prompt-marker) length))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
551 ;; Delete any duplicates of it which follow right after.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
552 (while (and (<= (+ (point) length) (point-max))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
553 (string= prompt
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
554 (buffer-substring (point) (+ (point) length))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
555 (delete-region (point) (+ (point) length)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
556 ;; If that didn't take us to where output is arriving,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
557 ;; we have encountered something other than a prompt,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
558 ;; so stop trying to delete any more prompts.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
559 (if (not (= (point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
560 (process-mark (get-buffer-process current-gdb-buffer))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
561 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
562 (set-marker (car gdb-delete-prompt-marker) nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
563 (setq gdb-delete-prompt-marker nil))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
564
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
565 (defun gdb-break (temp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
566 "Set GDB breakpoint at this source line. With ARG set temporary breakpoint."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
567 (interactive "P")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
568 (let* ((file-name (file-name-nondirectory buffer-file-name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
569 (line (save-restriction
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
570 (widen)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
571 (beginning-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
572 (1+ (count-lines 1 (point)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
573 (cmd (concat (if temp "tbreak " "break ") file-name ":"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
574 (int-to-string line))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
575 (set-buffer current-gdb-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
576 (goto-char (process-mark (get-buffer-process current-gdb-buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
577 (delete-region (point) (point-max))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
578 (insert cmd)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
579 (comint-send-input)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
580 ;;(process-send-string (get-buffer-process current-gdb-buffer) cmd)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
581 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
582
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
583 (defun gdb-clear ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
584 "Set GDB breakpoint at this source line."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
585 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
586 (let* ((file-name (file-name-nondirectory buffer-file-name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
587 (line (save-restriction
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
588 (widen)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
589 (beginning-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
590 (1+ (count-lines 1 (point)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
591 (cmd (concat "clear " file-name ":"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
592 (int-to-string line))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
593 (set-buffer current-gdb-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
594 (goto-char (process-mark (get-buffer-process current-gdb-buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
595 (delete-region (point) (point-max))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
596 (insert cmd)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
597 (comint-send-input)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
598 ;;(process-send-string (get-buffer-process current-gdb-buffer) cmd)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
599 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
600
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
601 (defun gdb-read-address()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
602 "Return a string containing the core-address found in the buffer at point."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
603 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
604 (let ((pt (point)) found begin)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
605 (setq found (if (search-backward "0x" (- pt 7) t)(point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
606 (cond (found (forward-char 2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
607 (buffer-substring found
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
608 (progn (re-search-forward "[^0-9a-f]")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
609 (forward-char -1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
610 (point))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
611 (t (setq begin (progn (re-search-backward "[^0-9]") (forward-char 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
612 (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
613 (forward-char 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
614 (re-search-forward "[^0-9]")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
615 (forward-char -1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
616 (buffer-substring begin (point)))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
617
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
618
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
619 (defvar gdb-commands nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
620 "List of strings or functions used by send-gdb-command.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
621 It is for customization by you.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
622
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
623 (defun send-gdb-command (arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
624
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
625 "This command reads the number where the cursor is positioned. It
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
626 then inserts this ADDR at the end of the gdb buffer. A numeric arg
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
627 selects the ARG'th member COMMAND of the list gdb-print-command. If
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
628 COMMAND is a string, (format COMMAND ADDR) is inserted, otherwise
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
629 (funcall COMMAND ADDR) is inserted. eg. \"p (rtx)%s->fld[0].rtint\"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
630 is a possible string to be a member of gdb-commands. "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
631
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
632
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
633 (interactive "P")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
634 (let (comm addr)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
635 (if arg (setq comm (nth arg gdb-commands)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
636 (setq addr (gdb-read-address))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
637 (if (eq (current-buffer) current-gdb-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
638 (set-mark (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
639 (cond (comm
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
640 (setq comm
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
641 (if (stringp comm) (format comm addr) (funcall comm addr))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
642 (t (setq comm addr)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
643 (switch-to-buffer current-gdb-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
644 (goto-char (point-max))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
645 (insert comm)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
646
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 22
diff changeset
647 (defun gdb-control-c-subjob ()
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 22
diff changeset
648 "Send a Control-C to the subprocess."
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 22
diff changeset
649 (interactive)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 22
diff changeset
650 (process-send-string (get-buffer-process (current-buffer))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 22
diff changeset
651 "\C-c"))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
652
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
653 (defun gdb-toolbar-break ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
654 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
655 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
656 (message (car gdb-last-frame))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
657 (set-buffer (find-file-noselect (car gdb-last-frame)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
658 (gdb-break nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
659
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
660 (defun gdb-toolbar-clear ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
661 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
662 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
663 (message (car gdb-last-frame))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
664 (set-buffer (find-file-noselect (car gdb-last-frame)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
665 (gdb-clear)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
666
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
667 (provide 'gdb)