annotate lisp/comint/gdbsrc.el @ 58:8b0bdfdf0cf0 r19-16-pre4

Import from CVS: tag r19-16-pre4
author cvs
date Mon, 13 Aug 2007 08:58:37 +0200
parents 441bb1e64a06
children 131b0175ea99
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 ;;; gdbsrc.el -- Source-based (as opposed to comint-based) debugger
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2 ;; interaction mode eventually, this will be unified with GUD
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3 ;; (after gud works reliably w/ XEmacs...)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4 ;; Keywords: c, unix, tools, debugging
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6 ;; Copyright (C) 1990 Debby Ayers <ayers@austin.ibm.com>, and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7 ;; Rich Schaefer <schaefer@asc.slb.com>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
8 ;; Copyright (C) 1994, 1995 Tinker Systems and INS Engineering Corp.
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
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
13 ;; it 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 of the License, or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
15 ;; (at your option) 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,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
18 ;; but 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
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
20 ;; GNU 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
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
23 ;; along with XEmacs; if not, write to the Free Software
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
24 ;; Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
25
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
26 ;; Based upon code for version18 by Debra Ayers <ayers@austin.ibm.com>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
27
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
28 ;;; GDBSRC::
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
29 ;;; Gdbsrc extends the emacs GDB interface to accept gdb commands issued
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
30 ;;; from the source code buffer. Gdbsrc behaves similar to gdb except
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
31 ;;; now most debugging may be done from the source code using the *gdb*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
32 ;;; buffer to view output. Supports a point and click model under X to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
33 ;;; evaluate source code expressions (no more typing long variable names).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
34 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
35 ;;; Supports C source at the moment but C++ support will be added if there
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
36 ;;; is sufficient interest.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
37 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
38
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
39 ;; GDBSRC::Gdb Source Mode Interface description.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
40 ;; Gdbsrc extends the emacs GDB interface to accept gdb commands issued
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
41 ;; from the source code buffer. Gdbsrc behaves similar to gdb except now all
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
42 ;; debugging may be done from the currently focused source buffer using
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
43 ;; the *gdb* buffer to view output.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
44
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
45 ;; When source files are displayed through gdbsrc, buffers are put in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
46 ;; gdbsrc-mode minor mode. This mode puts the buffer in read-only state
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
47 ;; and sets up a special key and mouse map to invoke communication with
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
48 ;; the current gdb process. The minor mode may be toggled on/off as needed.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
49 ;; (ESC-T)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
50
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
51 ;; C-expressions may be evaluated by gdbsrc by simply pointing at text in the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
52 ;; current source buffer with the mouse or by centering the cursor over text
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
53 ;; and typing a single key command. ('p' for print, '*' for print *).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
54
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
55 ;; As code is debugged and new buffers are displayed, the focus of gdbsrc
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
56 ;; follows to each new source buffer. Makes debugging fun. (sound like a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
57 ;; commercial or what!)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
58 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
59
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
60 ;; Current Listing ::
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
61 ;;key binding Comment
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
62 ;;--- ------- -------
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
63 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
64 ;; r gdb-return-from-src GDB return command
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
65 ;; n gdb-next-from-src GDB next command
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
66 ;; b gdb-back-from-src GDB back command
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
67 ;; w gdb-where-from-src GDB where command
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
68 ;; f gdb-finish-from-src GDB finish command
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
69 ;; u gdb-up-from-src GDB up command
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
70 ;; d gdb-down-from-src GDB down command
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
71 ;; c gdb-cont-from-src GDB continue command
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
72 ;; i gdb-stepi-from-src GDB step instruction command
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
73 ;; s gdb-step-from-src GDB step command
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
74 ;; ? gdb-whatis-c-sexp GDB whatis command for data at
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
75 ;; buffer point
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
76 ;; x gdbsrc-delete GDB Delete all breakpoints if no arg
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
77 ;; given or delete arg (C-u arg x)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
78 ;; m gdbsrc-frame GDB Display current frame if no arg,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
79 ;; given or display frame arg
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
80 ;; * gdb-*print-c-sexp GDB print * command for data at
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
81 ;; buffer point
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
82 ;; ! gdbsrc-goto-gdb Goto the GDB output buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
83 ;; p gdb-print-c-sexp GDB print * command for data at
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
84 ;; buffer point
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
85 ;; g gdbsrc-goto-gdb Goto the GDB output buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
86 ;; t gdbsrc-mode Toggles Gdbsrc mode (turns it off)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
87 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
88 ;; C-c C-f gdb-finish-from-src GDB finish command
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
89 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
90 ;; C-x SPC gdb-break Set break for line with point
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
91 ;; ESC t gdbsrc-mode Toggle Gdbsrc mode
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
92 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
93 ;; Local Bindings for buffer when you exit Gdbsrc minor mode
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
94 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
95 ;; C-x SPC gdb-break Set break for line with point
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
96 ;; ESC t gdbsrc-mode Toggle Gdbsrc mode
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
97 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
98
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
99 ;;; (eval-when-compile
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
100 ;;; (or noninteractive
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
101 ;;; (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
102 ;;; (message "ONLY compile gdbsrc except with -batch because of advice")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
103 ;;; (ding)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
104 ;;; )))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
105
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
106 (require 'gdb "gdb") ; NOT gud! (yet...)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
107
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
108 (defvar gdbsrc-active-p t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
109 "*Set to nil if you do not want source files put in gdbsrc-mode")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
110
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
111 (defvar gdbsrc-call-p nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
112 "True if gdb command issued from a source buffer")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
113
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
114 (defvar gdbsrc-associated-buffer nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
115 "Buffer name of attached gdb process")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
116
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
117 (defvar gdbsrc-mode nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
118 "Indicates whether buffer is in gdbsrc-mode or not")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
119 (make-variable-buffer-local 'gdbsrc-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
120
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
121 (defvar gdbsrc-global-mode nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
122 "Indicates whether global gdbsrc bindings are in effect or not")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
123
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
124 (defvar gdb-prompt-pattern "^[^)#$%>\n]*[)#$%>] *"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
125 "A regexp for matching the end of the gdb prompt")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
126
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
127 ;;; bindings
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
128
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
129 (defvar gdbsrc-global-map
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
130 (let ((map (make-sparse-keymap)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
131 (set-keymap-name map 'gdbsrc-global-map)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
132 (define-key map "\C-x " 'gdb-break)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
133 (define-key map "\M-\C-t" 'gdbsrc-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
134 (define-key map "\M-\C-g" 'gdbsrc-goto-gdb)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
135
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
136 ;; middle button to select and print expressions...
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
137 (define-key map '(meta button2) 'gdbsrc-print-csexp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
138 (define-key map '(meta shift button2) 'gdbsrc-*print-csexp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
139 ;; left button to position breakpoints
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
140 (define-key map '(meta button1) 'gdbsrc-set-break)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
141 (define-key map '(meta shift button1) 'gdbsrc-set-tbreak-continue)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
142 map)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
143 "Global minor keymap that is active whenever gdbsrc is running.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
144
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
145 (add-minor-mode 'gdbsrc-global-mode " GdbGlobal" gdbsrc-global-map)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
146
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
147 (defvar gdbsrc-mode-map
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
148 (let ((map (make-sparse-keymap)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
149 (suppress-keymap map)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
150 (set-keymap-name map 'gdbsrc-mode-map)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
151 ;; inherit keys from global gdbsrc map just in case that somehow gets turned off.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
152 (set-keymap-parents map (list gdbsrc-global-map))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
153 (define-key map "\C-x\C-q" 'gdbsrc-mode) ; toggle read-only
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
154 (define-key map "\C-c\C-c" 'gdbsrc-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
155 (define-key map "b" 'gdb-break)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
156 (define-key map "g" 'gdbsrc-goto-gdb)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
157 (define-key map "!" 'gdbsrc-goto-gdb)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
158 (define-key map "p" 'gdb-print-c-sexp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
159 (define-key map "*" 'gdb-*print-c-sexp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
160 (define-key map "?" 'gdb-whatis-c-sexp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
161 (define-key map "R" 'gdbsrc-reset)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
162 map)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
163 "Minor keymap for buffers in gdbsrc-mode")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
164
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
165 (add-minor-mode 'gdbsrc-mode " GdbSrc" gdbsrc-mode-map)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
166
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
167 (defvar gdbsrc-toolbar
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
168 '([eos::toolbar-stop-at-icon
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
169 gdb-break
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
170 t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
171 "Stop at selected position"]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
172 [eos::toolbar-stop-in-icon
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
173 gdb-break
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
174 t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
175 "Stop in function whose name is selected"]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
176 [eos::toolbar-clear-at-icon
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
177 gdbsrc-delete
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
178 t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
179 "Clear at selected position"]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
180 [eos::toolbar-evaluate-icon
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
181 gdb-print-c-sexp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
182 t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
183 "Evaluate selected expression; shows in separate XEmacs frame"]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
184 [eos::toolbar-evaluate-star-icon
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
185 gdb-*print-c-sexp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
186 t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
187 "Evaluate selected expression as a pointer; shows in separate XEmacs frame"]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
188 [eos::toolbar-run-icon
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
189 gdbsrc-run
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
190 t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
191 "Run current program"]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
192 [eos::toolbar-cont-icon
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
193 gdbsrc-cont
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
194 t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
195 "Continue current program"]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
196 [eos::toolbar-step-into-icon
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
197 gdbsrc-step
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
198 t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
199 "Step into (aka step)"]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
200 [eos::toolbar-step-over-icon
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
201 gdbsrc-next
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
202 t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
203 "Step over (aka next)"]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
204 [eos::toolbar-up-icon
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
205 gdbsrc-up
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
206 t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
207 "Stack Up (towards \"cooler\" - less recently visited - frames)"]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
208 [eos::toolbar-down-icon
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
209 gdbsrc-down
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
210 t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
211 "Stack Down (towards \"warmer\" - more recently visited - frames)"]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
212 [eos::toolbar-fix-icon
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
213 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
214 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
215 "Fix (not available with gdb)"]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
216 [eos::toolbar-build-icon
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
217 toolbar-compile
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
218 t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
219 "Build (aka make -NYI)"]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
220 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
221
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
222 (defmacro def-gdb-from-src (gdb-command key &optional doc &rest forms)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
223 "Create a function that will call GDB-COMMAND with KEY."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
224 (let* ((fname (format "gdbsrc-%s" gdb-command))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
225 (cstr (list 'if 'arg
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
226 (list 'format "%s %s" gdb-command '(prefix-numeric-value arg))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
227 gdb-command))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
228 fun)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
229 (while (string-match " " fname)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
230 (aset fname (match-beginning 0) ?-))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
231 (setq fun (intern fname))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
232
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
233 (list 'progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
234 (nconc (list 'defun fun '(arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
235 (or doc "")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
236 '(interactive "P")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
237 (list 'gdb-call-from-src cstr))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
238 forms)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
239 (list 'define-key 'gdbsrc-mode-map key (list 'quote fun)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
240
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
241 (def-gdb-from-src "step" "s" "Step one instruction in src"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
242 (gdb-delete-arrow-extent))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
243 (def-gdb-from-src "stepi" "i" "Step one source line (skip functions)"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
244 (gdb-delete-arrow-extent))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
245 (def-gdb-from-src "cont" "c" "Continue with display"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
246 (gdb-delete-arrow-extent))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
247 (def-gdb-from-src "down" "d" "Go down N stack frames (numeric arg) ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
248 (def-gdb-from-src "up" "u" "Go up N stack frames (numeric arg)")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
249 (def-gdb-from-src "finish" "f" "Finish frame")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
250 (def-gdb-from-src "where" "w" "Display (N frames of) backtrace")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
251 (def-gdb-from-src "next" "n" "Step one line with display"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
252 (gdb-delete-arrow-extent))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
253 (def-gdb-from-src "run" "r" "Run program from start"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
254 (gdb-delete-arrow-extent))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
255 (def-gdb-from-src "return" "R" "Return from selected stack frame")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
256 (def-gdb-from-src "disable" "x" "Disable all breakpoints")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
257 (def-gdb-from-src "delete" "X" "Delete all breakpoints")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
258 (def-gdb-from-src "quit" "Q" "Quit gdb."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
259 (gdb-delete-arrow-extent))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
260 (def-gdb-from-src "info locals" "l" "Show local variables")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
261 (def-gdb-from-src "info break" "B" "Show breakpoints")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
262 (def-gdb-from-src "" "\r" "Repeat last command")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
263 (def-gdb-from-src "frame" "m" "Show frame if no arg, with arg go to frame")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
264
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
265 ;;; code
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
266
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
267 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
268 (defun gdbsrc (path &optional core-or-pid)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
269 "Activates a gdb session with gdbsrc-mode turned on. A numeric prefix
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
270 argument can be used to specify a running process to attach, and a non-numeric
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
271 prefix argument will cause you to be prompted for a core file to debug."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
272 (interactive (let ((file (read-file-name "Program to debug: " nil nil t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
273 (cond ((numberp current-prefix-arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
274 (list file (int-to-string current-prefix-arg)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
275 (current-prefix-arg
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
276 (list file (read-file-name "Core file: " nil nil t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
277 (t (list file)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
278 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
279 ;; FIXME - this is perhaps an uncool thing to do --Stig
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
280 (delete-other-windows)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
281 (split-window-vertically)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
282 (other-window 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
283
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
284 (gdb path core-or-pid)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
285 (local-set-key 'button2 'gdbsrc-select-or-yank)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
286 (setq mode-motion-hook 'gdbsrc-mode-motion)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
287 ;; XEmacs change:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
288 (make-local-hook 'kill-buffer-hook)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
289 (add-hook 'kill-buffer-hook 'gdbsrc-reset nil t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
290
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
291 (defun gdbsrc-global-mode ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
292 ;; this can be used as a hook for gdb-mode....
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
293 (or current-gdb-buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
294 (and (eq major-mode 'gdb-mode) ; doesn't work w/ energize yet
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
295 (setq current-gdb-buffer (current-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
296 ;; XEmacs change:
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 0
diff changeset
297 (progn
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 0
diff changeset
298 (make-local-hook 'kill-buffer-hook)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 0
diff changeset
299 (add-hook 'kill-buffer-hook 'gdbsrc-reset nil t)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
300 (error "Cannot determine current-gdb-buffer"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
301 ;;; (set-process-filter
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
302 ;;; (get-buffer-process current-gdb-buffer) 'gdbsrc-mode-filter)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
303 ;;; (set-process-sentinel
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
304 ;;; (get-buffer-process current-gdb-buffer) 'gdbsrc-mode-sentinel)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
305 ;; gdbsrc-global-mode was set to t here but that tended to piss
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
306 ;; people off
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
307 (setq gdbsrc-global-mode nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
308 gdbsrc-active-p t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
309 gdbsrc-call-p nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
310 gdbsrc-mode nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
311 (message "Gbd source mode active"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
312
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
313 (add-hook 'gdb-mode-hook 'gdbsrc-global-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
314
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
315 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
316 ;;; Gdb Source minor mode.
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 (defvar gdbsrc-associated-buffer nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
320 "The gdb buffer to send commands to.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
321 (defvar gdbsrc-initial-readonly 'undefined
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
322 "read-only status of buffer when not in gdbsrc-mode")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
323 (defvar gdbsrc-old-toolbar nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
324 "saved toolbar for buffer")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
325
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
326 (defun gdbsrc-mode (arg &optional quiet)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
327 "Minor mode for interacting with gdb from a c source file.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
328 With arg, turn gdbsrc-mode on iff arg is positive. In gdbsrc-mode,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
329 you may send an associated gdb buffer commands from the current buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
330 containing c source code."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
331 (interactive "P")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
332 (setq gdbsrc-mode
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
333 (if (null arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
334 (not gdbsrc-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
335 (> (prefix-numeric-value arg) 0)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
336
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
337 (cond (gdbsrc-mode
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
338 (cond ((not (local-variable-p 'gdbsrc-initial-readonly (current-buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
339 (set (make-local-variable 'gdbsrc-initial-readonly)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
340 buffer-read-only)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
341 (set (make-local-variable 'gdbsrc-associated-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
342 current-gdb-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
343 (if (featurep 'toolbar)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
344 (set (make-local-variable 'gdbsrc-old-toolbar)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
345 (specifier-specs default-toolbar (current-buffer))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
346 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
347 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
348 (if (featurep 'toolbar)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
349 (set-specifier default-toolbar (cons (current-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
350 gdbsrc-toolbar)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
351 (setq buffer-read-only t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
352 (or quiet (message "Entering gdbsrc-mode...")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
353 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
354 (and (local-variable-p 'gdbsrc-initial-readonly (current-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
355 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
356 (if (featurep 'toolbar)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
357 (if gdbsrc-old-toolbar
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
358 (set-specifier default-toolbar
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
359 (cons (current-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
360 gdbsrc-old-toolbar))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
361 (remove-specifier default-toolbar (current-buffer))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
362 (kill-local-variable 'gdbsrc-old-toolbar)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
363 (setq buffer-read-only gdbsrc-initial-readonly)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
364 (kill-local-variable 'gdbsrc-initial-readonly)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
365 (kill-local-variable 'gdbsrc-associated-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
366 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
367 (or quiet (message "Exiting gdbsrc-mode..."))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
368 (redraw-modeline t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
369
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
370 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
371 ;; Sends commands to gdb process.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
372
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
373 (defun gdb-call-from-src (command)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
374 "Send associated gdb process COMMAND displaying source in this window."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
375 (setq gdbsrc-call-p t)
26
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 4
diff changeset
376 (let ((src-win (selected-window))
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 4
diff changeset
377 (buf (or gdbsrc-associated-buffer current-gdb-buffer)))
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 4
diff changeset
378 (or (buffer-name buf)
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 4
diff changeset
379 (error "GDB buffer deleted"))
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 4
diff changeset
380 (pop-to-buffer buf)
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 4
diff changeset
381 (goto-char (point-max))
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 4
diff changeset
382 (beginning-of-line)
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 4
diff changeset
383 ;; Go past gdb prompt
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 4
diff changeset
384 (re-search-forward
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 4
diff changeset
385 gdb-prompt-pattern (save-excursion (end-of-line) (point)) t)
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 4
diff changeset
386 ;; Delete any not-supposed-to-be-there text
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 4
diff changeset
387 (delete-region (point) (point-max))
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 4
diff changeset
388 (insert command)
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 4
diff changeset
389 (comint-send-input)
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 4
diff changeset
390 (select-window src-win)
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 4
diff changeset
391 ))
0
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 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
395 ;;; Define Commands for GDB SRC Mode Buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
396 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
397
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
398 ;;; ;; #### - move elsewhere
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
399 (or (fboundp 'event-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
400 (defun event-buffer (event)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
401 "Return buffer assocaited with EVENT, or nil."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
402 (let ((win (event-window event)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
403 (and win (window-buffer win)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
404
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
405 (defun set-gdbsrc-mode-motion-extent (st en action)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
406 ;; by Stig@hackvan.com
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
407 (let ((ex (make-extent st en)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
408 (set-extent-face ex 'highlight)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
409 (set-extent-property ex 'gdbsrc t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
410 (set-extent-property ex 'action action)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
411 (setq mode-motion-extent ex)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
412
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
413 (defun nuke-mode-motion-extent ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
414 ;; by Stig@hackvan.com
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
415 (cond (mode-motion-extent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
416 (delete-extent mode-motion-extent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
417 (setq mode-motion-extent nil))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
418
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
419 (defun looking-at-any (regex-list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
420 ;; by Stig@hackvan.com
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
421 (catch 'found
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
422 (while regex-list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
423 (and (looking-at (car regex-list))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
424 (throw 'found t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
425 (setq regex-list (cdr regex-list)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
426
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
427 (defconst gdb-breakpoint-patterns
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
428 '(
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
429 ;; when execution stops...
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
430 ;;Breakpoint 1, XlwMenuRedisplay (w=0x4d2e00, ev=0xefffe3f8, region=0x580e60)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
431 ;; at /net/stig/src/xemacs/lwlib/xlwmenu.c:2518
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
432 "^[BW][ra][et][ac][kh]point [0-9]+, .*\\(\n\\s .*\\)*"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
433 ;; output of the breakpoint command:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
434 ;;Breakpoint 1 at 0x19f5c8: file /net/stig/src/xemacs/lwlib/xlwmenu.c, line 2715.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
435 "^[BW][ra][et][ac][kh]point [0-9]+ at .*: file \\([^ ,\n]+\\), line \\([0-9]+\\)."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
436 ;;Num Type Disp Enb Address What
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
437 ;;1 breakpoint keep y 0x0019ee60 in XlwMenuRedisplay
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
438 ;; at /net/stig/src/xemacs/lwlib/xlwmenu.c:2518
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
439 "^[0-9]+\\s +[bw][ra][et][ac][kh]point.* in .*\\(\n\\s +\\)?at [^ :\n]+:[0-9]+\\(\n\\s .*\\)*"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
440 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
441 "list of patterns to match gdb's various ways of displaying a breakpoint")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
442
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
443 (defun gdbsrc-make-breakpoint-action (string)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
444 ;; by Stig@hackvan.com
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
445 (if (or (string-match "file \\([^ ,\n]+\\), line \\([0-9]+\\)" string)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
446 (string-match "at \\([^ :\n]+\\):\\([0-9]+\\)" string))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
447 (list 'gdbsrc-display
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
448 (match-string 1 string)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
449 (string-to-int (match-string 2 string)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
450
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
451 (defconst gdb-stack-frame-pattern
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
452 ;;#9 0x62f08 in emacs_Xt_next_event (emacs_event=0x4cf804)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
453 ;; at /net/stig/src/xemacs/src/event-Xt.c:1778
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
454 "^#\\([0-9]+\\)\\s +\\(0x[0-9a-f]+ in .*\\|.*\\sw+.* (.*) at .*\\)\\(\n\\s .*\\)*"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
455 "matches the first line of a gdb stack frame and all continuation lines.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
456 subex 1 is frame number.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
457
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
458 (defun gdbsrc-mode-motion (ee)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
459 ;; by Stig@hackvan.com
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
460 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
461 (set-buffer (event-buffer ee))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
462 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
463 (if (not (event-point ee))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
464 (nuke-mode-motion-extent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
465 (goto-char (event-point ee))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
466 (beginning-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
467 (while (and (not (bobp)) (eq ? (char-syntax (following-char))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
468 (forward-line -1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
469 (if (extent-at (point) (current-buffer) 'gdbsrc)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
470 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
471 (nuke-mode-motion-extent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
472 (cond ((looking-at-any gdb-breakpoint-patterns)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
473 (set-gdbsrc-mode-motion-extent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
474 (match-beginning 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
475 (match-end 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
476 (gdbsrc-make-breakpoint-action (match-string 0))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
477 ((looking-at gdb-stack-frame-pattern)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
478 (set-gdbsrc-mode-motion-extent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
479 (match-beginning 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
480 (match-end 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
481 (list 'gdbsrc-frame
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
482 (string-to-int (match-string 1)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
483 )))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
484 )))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
485
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
486 (defun gdbsrc-display (file line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
487 ;; by Stig@hackvan.com
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
488 (select-window (display-buffer (find-file-noselect file)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
489 (goto-line line))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
490
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
491 (defun click-inside-selection-p (click)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
492 (or (click-inside-extent-p click primary-selection-extent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
493 (click-inside-extent-p click zmacs-region-extent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
494 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
495
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
496 (defun click-inside-extent-p (click extent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
497 "Returns non-nil if the button event is within the bounds of the primary
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
498 selection-extent, nil otherwise."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
499 ;; stig@hackvan.com
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
500 (let ((ewin (event-window click))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
501 (epnt (event-point click)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
502 (and ewin
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
503 epnt
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
504 extent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
505 (eq (window-buffer ewin)
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 0
diff changeset
506 (extent-object extent))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
507 (extent-start-position extent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
508 (> epnt (extent-start-position extent))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
509 (> (extent-end-position extent) epnt))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
510
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
511 (defun point-inside-extent-p (extent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
512 "Returns non-nil if the point is within or just after the bounds of the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
513 primary selection-extent, nil otherwise."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
514 ;; stig@hackvan.com
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
515 (and extent ; FIXME - I'm such a sinner...
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
516 (eq (current-buffer)
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 0
diff changeset
517 (extent-object extent))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
518 (> (point) (extent-start-position extent))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
519 (>= (extent-end-position extent) (point))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
520
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
521 (defun gdbsrc-select-or-yank (ee)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
522 ;; by Stig@hackvan.com
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
523 (interactive "e")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
524 (let ((action (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
525 (set-buffer (event-buffer ee))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
526 (and mode-motion-extent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
527 (click-inside-extent-p ee mode-motion-extent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
528 (extent-property mode-motion-extent 'action)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
529 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
530 (if action
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
531 (eval action)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
532 (mouse-yank ee))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
533
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
534 (defvar gdb-print-format ""
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
535 "Set this variable to a valid format string to print c-sexps in a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
536 different way (hex,octal, etc).")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
537
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
538 (defun gdb-print-c-sexp ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
539 "Find the nearest c-mode sexp. Send it to gdb with print command."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
540 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
541 (let* ((tag (find-c-sexp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
542 (command (concat "print " gdb-print-format tag)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
543 (gdb-call-from-src command)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
544
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
545 (defun gdb-*print-c-sexp ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
546 "Find the nearest c-mode sexp. Send it to gdb with the print * command."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
547 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
548 (let* ((tag (find-c-sexp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
549 (command (concat "print " gdb-print-format "*" tag)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
550 (gdb-call-from-src command)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
551
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
552 (defun gdb-whatis-c-sexp ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
553 "Find the nearest c-mode sexp. Send it to gdb with the whatis command. "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
554 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
555 (let* ((tag (gdbsrc-selection-or-sexp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
556 (command (concat "whatis " tag)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
557 (gdb-call-from-src command)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
558
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
559 (defun gdbsrc-goto-gdb ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
560 "Hop back and forth between the gdb interaction buffer and the gdb source
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
561 buffer. "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
562 ;; by Stig@hackvan.com
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
563 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
564 (let ((gbuf (or gdbsrc-associated-buffer current-gdb-buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
565 (cond ((eq (current-buffer) gbuf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
566 (and gdb-arrow-extent
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 0
diff changeset
567 (extent-object gdb-arrow-extent)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 0
diff changeset
568 (progn (pop-to-buffer (extent-object gdb-arrow-extent))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
569 (goto-char (extent-start-position gdb-arrow-extent)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
570 ((buffer-name gbuf) (pop-to-buffer gbuf))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
571 ((y-or-n-p "No debugger. Start a new one? ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
572 (call-interactively 'gdbsrc))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
573 (t (error "No gdb buffer."))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
574 )))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
575
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
576 (defvar gdbsrc-last-src-buffer nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
577
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
578 (defun gdbsrc-goto-src ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
579 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
580 (let* ((valid (and gdbsrc-last-src-buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
581 (memq gdbsrc-last-src-buffer (buffer-list))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
582 (win (and valid
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
583 (get-buffer-window gdbsrc-last-src-buffer))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
584 (cond (win (select-window win))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
585 (valid (pop-to-buffer gdbsrc-last-src-buffer)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
586
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
587 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
588 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
589 ;;; The following functions are used to extract the closest surrounding
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
590 ;;; c expression from point
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
591 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
592 (defun back-sexp ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
593 "Version of backward-sexp that catches errors"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
594 (condition-case nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
595 (backward-sexp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
596 (error t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
597
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
598 (defun forw-sexp ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
599 "Version of forward-sexp that catches errors"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
600 (condition-case nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
601 (forward-sexp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
602 (error t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
603
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
604 (defun sexp-compound-sep (span-start span-end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
605 "Returns '.' for '->' & '.', returns ' ' for white space,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
606 returns '?' for other puctuation"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
607 (let ((result ? )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
608 (syntax))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
609 (while (< span-start span-end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
610 (setq syntax (char-syntax (char-after span-start)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
611 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
612 ((= syntax ? ) t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
613 ((= syntax ?.) (setq syntax (char-after span-start))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
614 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
615 ((= syntax ?.) (setq result ?.))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
616 ((and (= syntax ?-) (= (char-after (+ span-start 1)) ?>))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
617 (setq result ?.)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
618 (setq span-start (+ span-start 1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
619 (t (setq span-start span-end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
620 (setq result ??)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
621 (setq span-start (+ span-start 1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
622 result
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
623 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
624 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
625
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
626 (defun sexp-compound (first second)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
627 "Returns non-nil if the concatenation of two S-EXPs result in a Single C
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
628 token. The two S-EXPs are represented as a cons cells, where the car
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
629 specifies the point in the current buffer that marks the begging of the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
630 S-EXP and the cdr specifies the character after the end of the S-EXP
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
631 Link S-Exps of the form:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
632 Sexp -> SexpC
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
633 Sexp . Sexp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
634 Sexp (Sexp) Maybe exclude if first Sexp is: if, while, do, for, switch
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
635 Sexp [Sexp]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
636 (Sexp) Sexp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
637 [Sexp] Sexp"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
638 (let ((span-start (cdr first))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
639 (span-end (car second))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
640 (syntax))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
641 (setq syntax (sexp-compound-sep span-start span-end))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
642 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
643 ((= (car first) (car second)) nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
644 ((= (cdr first) (cdr second)) nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
645 ((= syntax ?.) t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
646 ((= syntax ? )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
647 (setq span-start (char-after (- span-start 1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
648 (setq span-end (char-after span-end))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
649 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
650 ((= span-start ?) ) t )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
651 ((= span-start ?] ) t )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
652 ((= span-end ?( ) t )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
653 ((= span-end ?[ ) t )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
654 (t nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
655 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
656 (t nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
657 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
658 )
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 sexp-cur ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
661 "Returns the S-EXP that Point is a member, Point is set to begging of S-EXP.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
662 The S-EXPs is represented as a cons cell, where the car specifies the point in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
663 the current buffer that marks the begging of the S-EXP and the cdr specifies
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
664 the character after the end of the S-EXP"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
665 (let ((p (point)) (begin) (end))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
666 (back-sexp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
667 (setq begin (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
668 (forw-sexp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
669 (setq end (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
670 (if (>= p end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
671 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
672 (setq begin p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
673 (goto-char p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
674 (forw-sexp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
675 (setq end (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
676 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
677 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
678 (goto-char begin)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
679 (cons begin end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
680 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
681 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
682
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
683 (defun sexp-prev ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
684 "Returns the previous S-EXP, Point is set to begging of that S-EXP.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
685 The S-EXPs is represented as a cons cell, where the car specifies the point in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
686 the current buffer that marks the begging of the S-EXP and the cdr specifies
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
687 the character after the end of the S-EXP"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
688 (let ((begin) (end))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
689 (back-sexp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
690 (setq begin (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
691 (forw-sexp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
692 (setq end (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
693 (goto-char begin)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
694 (cons begin end))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
695 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
696
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
697 (defun sexp-next ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
698 "Returns the following S-EXP, Point is set to begging of that S-EXP.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
699 The S-EXPs is represented as a cons cell, where the car specifies the point in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
700 the current buffer that marks the begging of the S-EXP and the cdr specifies
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
701 the character after the end of the S-EXP"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
702 (let ((begin) (end))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
703 (forw-sexp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
704 (forw-sexp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
705 (setq end (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
706 (back-sexp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
707 (setq begin (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
708 (cons begin end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
709 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
710 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
711
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
712 (defun find-c-sexp ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
713 "Returns the Complex S-EXP that surrounds Point"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
714 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
715 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
716 (let ((p) (sexp) (test-sexp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
717 (setq p (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
718 (setq sexp (sexp-cur))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
719 (setq test-sexp (sexp-prev))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
720 (while (sexp-compound test-sexp sexp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
721 (setq sexp (cons (car test-sexp) (cdr sexp)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
722 (goto-char (car sexp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
723 (setq test-sexp (sexp-prev))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
724 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
725 (goto-char p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
726 (setq test-sexp (sexp-next))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
727 (while (sexp-compound sexp test-sexp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
728 (setq sexp (cons (car sexp) (cdr test-sexp)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
729 (setq test-sexp (sexp-next))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
730 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
731 (buffer-substring (car sexp) (cdr sexp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
732 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
733 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
734 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
735
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
736 (defun gdbsrc-selection-or-sexp (&optional ee)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
737 ;; FIXME - fix this docstring
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
738 "If the EVENT is within the primary selection, then return the selected
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
739 text, otherwise parse the expression at the point of the mouse click and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
740 return that. If EVENT is nil, then return the C sexp at point."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
741 ;; stig@hackvan.com
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
742 (cond ((or (and ee (click-inside-selection-p ee))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
743 (and (not ee) (point-inside-selection-p)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
744 (replace-in-string (extent-string primary-selection-extent) "\n\\s *" " "))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
745 (ee
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
746 (gdbsrc-get-csexp-at-click ee))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
747 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
748 (find-c-sexp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
749 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
750
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
751 (defun gdbsrc-get-csexp-at-click (ee)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
752 "Returns the containing s-expression located at the mouse cursor to point."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
753 ;; "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
754 ;; by Stig@hackvan.com
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
755 (let ((ewin (event-window ee))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
756 (epnt (event-point ee)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
757 (or (and ewin epnt)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
758 (error "Must click within a window"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
759 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
760 (set-buffer (window-buffer ewin))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
761 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
762 (goto-char epnt)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
763 (find-c-sexp)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
764
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
765 (defun gdbsrc-print-csexp (&optional ee)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
766 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
767 (or ee (setq ee current-mouse-event))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
768 (gdb-call-from-src
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
769 (concat "print " gdb-print-format (gdbsrc-selection-or-sexp ee))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
770
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
771 (defun gdbsrc-*print-csexp (&optional ee)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
772 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
773 (or ee (setq ee current-mouse-event))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
774 (gdb-call-from-src
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
775 (concat "print *" gdb-print-format (gdbsrc-selection-or-sexp ee))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
776
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
777 ;; (defun gdbsrc-print-region (arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
778 ;; (let (( command (concat "print " gdb-print-format (x-get-cut-buffer))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
779 ;; (gdb-call-from-src command)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
780 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
781 ;; (defun gdbsrc-*print-region (arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
782 ;; (let (( command (concat "print *" gdb-print-format (x-get-cut-buffer))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
783 ;; (gdb-call-from-src command)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
784
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
785 (defun gdbsrc-file:lno ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
786 "returns \"file:lno\" specification for location of point. "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
787 ;; by Stig@hackvan.com
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
788 (format "%s:%d"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
789 (file-name-nondirectory buffer-file-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
790 (save-restriction
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
791 (widen)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
792 (1+ (count-lines (point-min)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
793 (save-excursion (beginning-of-line) (point)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
794 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
795
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
796 (defun gdbsrc-set-break (ee)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
797 "Sets a breakpoint. Click on the selection and it will set a breakpoint
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
798 using the selected text. Click anywhere in a source file, and it will set
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
799 a breakpoint at that line number of that file."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
800 ;; by Stig@hackvan.com
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
801 ;; there is already gdb-break, so this only needs to work with mouse clicks.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
802 (interactive "e")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
803 (gdb-call-from-src
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
804 (concat "break "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
805 (if (click-inside-selection-p ee)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
806 (extent-string primary-selection-extent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
807 (mouse-set-point ee)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
808 (or buffer-file-name (error "No file in window"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
809 (gdbsrc-file:lno)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
810 ))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
811
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
812 (defun gdbsrc-set-tbreak-continue (&optional ee)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
813 "Set a temporary breakpoint at the position of the mouse click and then
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
814 continues. This can be bound to either a key or a mouse button."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
815 ;; by Stig@hackvan.com
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
816 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
817 (or ee (setq ee current-mouse-event))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
818 (and ee (mouse-set-point ee))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
819 (gdb-call-from-src (concat "tbreak " (gdbsrc-file:lno)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
820 (gdb-call-from-src "c"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
821
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
822 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
823 ;; Functions extended from gdb.el for gdbsrc.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
824 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
825 ;; gdbsrc-set-buffer - added a check to set buffer to gdbsrc-associated-buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
826 ;; to handle multiple gdb sessions being driven from src
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
827 ;; files.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
828
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
829 (require 'advice)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
830
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
831 (defadvice gdb-set-buffer (after gdbsrc activate) ; ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
832 "Advised to work from a source buffer instead of just the gdb buffer."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
833 ;; by Stig@hackvan.com
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
834 ;; the operations below have tests which are disjoint from the tests in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
835 ;; the original `gdb-set-buffer'. Current-gdb-buffer cannot be set twice.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
836 (and gdbsrc-call-p
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
837 gdbsrc-associated-buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
838 (setq current-gdb-buffer gdbsrc-associated-buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
839
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
840 (defadvice gdb-display-line (around gdbsrc activate)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
841 ;; (true-file line &optional select-method)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
842 "Advised to select the source buffer instead of the gdb-buffer"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
843 ;; by Stig@hackvan.com
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
844 (ad-set-arg 2 'source) ; tell it not to select the gdb window
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
845 ad-do-it
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
846 (save-excursion
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 0
diff changeset
847 (let* ((buf (extent-object gdb-arrow-extent))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
848 (win (get-buffer-window buf)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
849 (setq gdbsrc-last-src-buffer buf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
850 (select-window win)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
851 (set-window-point win (extent-start-position gdb-arrow-extent))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
852 (set-buffer buf))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
853 (and gdbsrc-active-p
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
854 (not gdbsrc-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
855 (not (eq (current-buffer) current-gdb-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
856 (gdbsrc-mode 1))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
857
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
858 (defadvice gdb-filter (after gdbsrc activate) ; (proc string)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
859 ;; by Stig@hackvan.com
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
860 ;; if we got a gdb prompt and it wasn't a gdbsrc command, then it's gdb
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
861 ;; hitting a breakpoint or having a core dump, so bounce back to the gdb
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
862 ;; window.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
863 (let* ((selbuf (window-buffer (selected-window)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
864 win)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
865 ;; if we're at a gdb prompt, then display the buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
866 (and (save-match-data (string-match gdb-prompt-pattern (ad-get-arg 1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
867 (prog1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
868 (not gdbsrc-call-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
869 (setq gdbsrc-call-p nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
870 (setq win (display-buffer current-gdb-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
871 ;; if we're not in either the source buffer or the gdb buffer,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
872 ;; then select the window too...
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
873 (not (eq selbuf current-gdb-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
874 (not (eq selbuf gdbsrc-last-src-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
875 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
876 (ding nil 'warp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
877 (select-window win)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
878 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
879
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
880 (defun gdbsrc-reset ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
881 ;; tidy house and turn off gdbsrc-mode in all buffers
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
882 ;; by Stig@hackvan.com
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
883 (gdb-delete-arrow-extent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
884 (setq gdbsrc-global-mode nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
885 (mapcar #'(lambda (buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
886 (set-buffer buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
887 (cond ((eq gdbsrc-associated-buffer current-gdb-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
888 (gdbsrc-mode -1))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
889 (buffer-list)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
890
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
891 (defadvice gdb-sentinel (after gdbsrc freeze) ; (proc msg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
892 ;; by Stig@hackvan.com
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
893 (gdbsrc-reset)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
894 (message "Gdbsrc finished"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
895
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
896 (provide 'gdbsrc)