annotate lisp/comint/gud.el @ 108:360340f9fd5f r20-1b6

Import from CVS: tag r20-1b6
author cvs
date Mon, 13 Aug 2007 09:18:39 +0200
parents 131b0175ea99
children
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 ;;; gud.el --- Grand Unified Debugger mode for gdb, sdb, dbx, or xdb
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2 ;;; under Emacs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4 ;; Author: Eric S. Raymond <esr@snark.thyrsus.com>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5 ;; Maintainer: FSF
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6 ;; Version: 1.3
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7 ;; Keywords: c, unix, tools, debugging
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
8
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
9 ;; Copyright (C) 1992, 1993 Free Software Foundation, Inc.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
10
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
11 ;; This file is part of XEmacs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
12
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
13 ;; XEmacs is free software; you can redistribute it and/or modify it
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
14 ;; under the terms of the GNU General Public License as published by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
15 ;; the Free Software Foundation; either version 2, or (at your option)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
16 ;; any later version.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
17
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
18 ;; XEmacs is distributed in the hope that it will be useful, but
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
19 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
20 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
21 ;; General Public License for more details.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
22
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
23 ;; You should have received a copy of the GNU General Public License
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
24 ;; along with XEmacs; see the file COPYING. If not, write to the
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
25 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
26 ;; Boston, MA 02111-1307, USA.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
27
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
28 ;;; Commentary:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
29
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
30 ;; The ancestral gdb.el was by W. Schelter <wfs@rascal.ics.utexas.edu>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
31 ;; It was later rewritten by rms. Some ideas were due to Masanobu.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
32 ;; Grand Unification (sdb/dbx support) by Eric S. Raymond <esr@thyrsus.com>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
33 ;; The overloading code was then rewritten by Barry Warsaw <bwarsaw@cen.com>,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
34 ;; who also hacked the mode to use comint.el. Shane Hartman <shane@spr.com>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
35 ;; added support for xdb (HPUX debugger).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
36
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
37 ;; Cygnus Support added support for gdb's --annotate=2.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
38
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
39 ;;; Code:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
40
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
41 (require 'comint)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
42 (require 'etags)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
43
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
44 ;; ======================================================================
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
45 ;; GUD commands must be visible in C buffers visited by GUD
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
46
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
47 (defvar gud-key-prefix "\C-x\C-a"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
48 "Prefix of all GUD commands valid in C buffers.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
49
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
50 (global-set-key (concat gud-key-prefix "\C-l") 'gud-refresh)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
51 (global-set-key "\C-x " 'gud-break) ;; backward compatibility hack
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
52
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
53 ;; ======================================================================
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
54 ;; the overloading mechanism
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
55
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
56 (defun gud-overload-functions (gud-overload-alist)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
57 "Overload functions defined in GUD-OVERLOAD-ALIST.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
58 This association list has elements of the form
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
59 (ORIGINAL-FUNCTION-NAME OVERLOAD-FUNCTION)"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
60 (mapcar
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
61 (function (lambda (p) (fset (car p) (symbol-function (cdr p)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
62 gud-overload-alist))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
63
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
64 (defun gud-massage-args (file args)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
65 (error "GUD not properly entered."))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
66
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
67 (defun gud-marker-filter (str)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
68 (error "GUD not properly entered."))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
69
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
70 (defun gud-find-file (f)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
71 (error "GUD not properly entered."))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
72
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
73 ;; ======================================================================
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
74 ;; command definition
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
75
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
76 ;; This macro is used below to define some basic debugger interface commands.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
77 ;; Of course you may use `gud-def' with any other debugger command, including
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
78 ;; user defined ones.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
79
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
80 ;; A macro call like (gud-def FUNC NAME KEY DOC) expands to a form
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
81 ;; which defines FUNC to send the command NAME to the debugger, gives
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
82 ;; it the docstring DOC, and binds that function to KEY in the GUD
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
83 ;; major mode. The function is also bound in the global keymap with the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
84 ;; GUD prefix.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
85
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
86 (defmacro gud-def (func cmd key &optional doc)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
87 "Define FUNC to be a command sending STR and bound to KEY, with
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
88 optional doc string DOC. Certain %-escapes in the string arguments
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
89 are interpreted specially if present. These are:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
90
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
91 %f name (without directory) of current source file.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
92 %d directory of current source file.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
93 %l number of current source line
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
94 %e text of the C lvalue or function-call expression surrounding point.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
95 %a text of the hexadecimal address surrounding point
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
96 %p prefix argument to the command (if any) as a number
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
97
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
98 The `current' source file is the file of the current buffer (if
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
99 we're in a C file) or the source file current at the last break or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
100 step (if we're in the GUD buffer).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
101 The `current' line is that of the current buffer (if we're in a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
102 source file) or the source line number at the last break or step (if
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
103 we're in the GUD buffer)."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
104 (list 'progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
105 (list 'defun func '(arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
106 (or doc "")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
107 '(interactive "p")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
108 (list 'gud-call cmd 'arg))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
109 (if key
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
110 (list 'define-key
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
111 '(current-local-map)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
112 (concat "\C-c" key)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
113 (list 'quote func)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
114 (if key
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
115 (list 'global-set-key
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
116 (list 'concat 'gud-key-prefix key)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
117 (list 'quote func)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
118
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
119 ;; Where gud-display-frame should put the debugging arrow. This is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
120 ;; set by the marker-filter, which scans the debugger's output for
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
121 ;; indications of the current program counter.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
122 (defvar gud-last-frame nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
123
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
124 ;; Used by gud-refresh, which should cause gud-display-frame to redisplay
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
125 ;; the last frame, even if it's been called before and gud-last-frame has
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
126 ;; been set to nil.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
127 (defvar gud-last-last-frame nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
128
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
129 ;; All debugger-specific information is collected here.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
130 ;; Here's how it works, in case you ever need to add a debugger to the mode.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
131 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
132 ;; Each entry must define the following at startup:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
133 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
134 ;;<name>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
135 ;; comint-prompt-regexp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
136 ;; gud-<name>-massage-args
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
137 ;; gud-<name>-marker-filter
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
138 ;; gud-<name>-find-file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
139 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
140 ;; The job of the massage-args method is to modify the given list of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
141 ;; debugger arguments before running the debugger.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
142 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
143 ;; The job of the marker-filter method is to detect file/line markers in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
144 ;; strings and set the global gud-last-frame to indicate what display
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
145 ;; action (if any) should be triggered by the marker. Note that only
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
146 ;; whatever the method *returns* is displayed in the buffer; thus, you
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
147 ;; can filter the debugger's output, interpreting some and passing on
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
148 ;; the rest.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
149 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
150 ;; The job of the find-file method is to visit and return the buffer indicated
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
151 ;; by the car of gud-tag-frame. This may be a file name, a tag name, or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
152 ;; something else.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
153
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
154 ;; ======================================================================
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
155 ;; gdb functions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
156
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
157 ;;; History of argument lists passed to gdb.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
158 (defvar gud-gdb-history nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
159
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
160 (defun gud-gdb-massage-args (file args)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
161 (cons "--annotate=2" (cons file args)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
162
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
163
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
164 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
165 ;; In this world, there are gdb instance objects (of unspecified
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
166 ;; representation) and buffers associated with those objects.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
167 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
168
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
169 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
170 ;; gdb-instance objects
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
171 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
172
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
173 (defun make-gdb-instance (proc)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
174 "Create a gdb instance object from a gdb process."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
175 (setq last-proc proc)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
176 (let ((instance (cons 'gdb-instance proc)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
177 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
178 (set-buffer (process-buffer proc))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
179 (setq gdb-buffer-instance instance)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
180 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
181 (mapcar 'make-variable-buffer-local gdb-instance-variables)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
182 (setq gdb-buffer-type 'gud)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
183 ;; If we're taking over the buffer of another process,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
184 ;; take over it's ancillery buffers as well.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
185 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
186 (let ((dead (or old-gdb-buffer-instance)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
187 (mapcar
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
188 (function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
189 (lambda (b)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
190 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
191 (set-buffer b)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
192 (if (eq dead gdb-buffer-instance)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
193 (setq gdb-buffer-instance instance)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
194 (buffer-list)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
195 instance))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
196
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
197 (defun gdb-instance-process (inst) (cdr inst))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
198
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
199 ;;; The list of instance variables is built up by the expansions of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
200 ;;; DEF-GDB-VARIABLE
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
201 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
202 (defvar gdb-instance-variables '()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
203 "A list of variables that are local to the gud buffer associated
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
204 with a gdb instance.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
205
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
206 (defmacro def-gdb-variable
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
207 (name accessor setter &optional default doc)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
208 (`
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
209 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
210 (defvar (, name) (, default) (, (or doc "undocumented")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
211 (if (not (memq '(, name) gdb-instance-variables))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
212 (setq gdb-instance-variables
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
213 (cons '(, name) gdb-instance-variables)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
214 (, (and accessor
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
215 (`
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
216 (defun (, accessor) (instance)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
217 (let
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
218 ((buffer (gdb-get-instance-buffer instance 'gud)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
219 (and buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
220 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
221 (set-buffer buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
222 (, name))))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
223 (, (and setter
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
224 (`
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
225 (defun (, setter) (instance val)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
226 (let
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
227 ((buffer (gdb-get-instance-buffer instance 'gud)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
228 (and buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
229 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
230 (set-buffer buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
231 (setq (, name) val)))))))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
232
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
233 (defmacro def-gdb-var (root-symbol &optional default doc)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
234 (let* ((root (symbol-name root-symbol))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
235 (accessor (intern (concat "gdb-instance-" root)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
236 (setter (intern (concat "set-gdb-instance-" root)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
237 (var-name (intern (concat "gdb-" root))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
238 (` (def-gdb-variable
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
239 (, var-name) (, accessor) (, setter)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
240 (, default) (, doc)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
241
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
242 (def-gdb-var buffer-instance nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
243 "In an instance buffer, the buffer's instance.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
244
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
245 (def-gdb-var buffer-type nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
246 "One of the symbols bound in gdb-instance-buffer-rules")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
247
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
248 (def-gdb-var burst ""
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
249 "A string of characters from gdb that have not yet been processed.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
250
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
251 (def-gdb-var input-queue ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
252 "A list of high priority gdb command objects.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
253
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
254 (def-gdb-var idle-input-queue ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
255 "A list of low priority gdb command objects.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
256
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
257 (def-gdb-var prompting nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
258 "True when gdb is idle with no pending input.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
259
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
260 (def-gdb-var output-sink 'user
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
261 "The disposition of the output of the current gdb command.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
262 Possible values are these symbols:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
263
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
264 user -- gdb output should be copied to the gud buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
265 for the user to see.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
266
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
267 inferior -- gdb output should be copied to the inferior-io buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
268
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
269 pre-emacs -- output should be ignored util the post-prompt
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
270 annotation is received. Then the output-sink
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
271 becomes:...
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
272 emacs -- output should be collected in the partial-output-buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
273 for subsequent processing by a command. This is the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
274 disposition of output generated by commands that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
275 gud mode sends to gdb on its own behalf.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
276 post-emacs -- ignore input until the prompt annotation is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
277 received, then go to USER disposition.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
278 ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
279
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
280 (def-gdb-var current-item nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
281 "The most recent command item sent to gdb.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
282
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
283 (def-gdb-var pending-triggers '()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
284 "A list of trigger functions that have run later than their output
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
285 handlers.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
286
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
287 (defun in-gdb-instance-context (instance form)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
288 "Funcall `form' in the gud buffer of `instance'"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
289 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
290 (set-buffer (gdb-get-instance-buffer instance 'gud))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
291 (funcall form)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
292
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
293 ;; end of instance vars
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
294
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
295 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
296 ;; finding instances
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
297 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
298
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
299 (defun gdb-proc->instance (proc)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
300 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
301 (set-buffer (process-buffer proc))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
302 gdb-buffer-instance))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
303
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
304 (defun gdb-mru-instance-buffer ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
305 "Return the most recently used (non-auxiliary) gdb gud buffer."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
306 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
307 (gdb-goto-first-gdb-instance (buffer-list))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
308
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
309 (defun gdb-goto-first-gdb-instance (blist)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
310 "Use gdb-mru-instance-buffer -- not this."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
311 (and blist
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
312 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
313 (set-buffer (car blist))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
314 (or (and gdb-buffer-instance
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
315 (eq gdb-buffer-type 'gud)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
316 (car blist))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
317 (gdb-goto-first-gdb-instance (cdr blist))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
318
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
319 (defun buffer-gdb-instance (buf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
320 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
321 (set-buffer buf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
322 gdb-buffer-instance))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
323
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
324 (defun gdb-needed-default-instance ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
325 "Return the most recently used gdb instance or signal an error."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
326 (let ((buffer (gdb-mru-instance-buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
327 (or (and buffer (buffer-gdb-instance buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
328 (error "No instance of gdb found."))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
329
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
330 (defun gdb-instance-target-string (instance)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
331 "The apparent name of the program being debugged by a gdb instance.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
332 For sure this the root string used in smashing together the gud
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
333 buffer's name, even if that doesn't happen to be the name of a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
334 program."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
335 (in-gdb-instance-context
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
336 instance
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
337 (function (lambda () gud-target-name))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
338
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
339
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
340
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
341 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
342 ;; Instance Buffers.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
343 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
344
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
345 ;; More than one buffer can be associated with a gdb instance.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
346 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
347 ;; Each buffer has a TYPE -- a symbol that identifies the function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
348 ;; of that particular buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
349 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
350 ;; The usual gud interaction buffer is given the type `gud' and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
351 ;; is constructed specially.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
352 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
353 ;; Others are constructed by gdb-get-create-instance-buffer and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
354 ;; named according to the rules set forth in the gdb-instance-buffer-rules-assoc
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
355
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
356 (defun gdb-get-instance-buffer (instance key)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
357 "Return the instance buffer for `instance' tagged with type `key'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
358 The key should be one of the cars in `gdb-instance-buffer-rules-assoc'."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
359 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
360 (gdb-look-for-tagged-buffer instance key (buffer-list))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
361
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
362 (defun gdb-get-create-instance-buffer (instance key)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
363 "Create a new gdb instance buffer of the type specified by `key'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
364 The key should be one of the cars in `gdb-instance-buffer-rules-assoc'."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
365 (or (gdb-get-instance-buffer instance key)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
366 (let* ((rules (assoc key gdb-instance-buffer-rules-assoc))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
367 (name (funcall (gdb-rules-name-maker rules) instance))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
368 (new (get-buffer-create name)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
369 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
370 (set-buffer new)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
371 (make-variable-buffer-local 'gdb-buffer-type)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
372 (setq gdb-buffer-type key)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
373 (make-variable-buffer-local 'gdb-buffer-instance)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
374 (setq gdb-buffer-instance instance)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
375 (if (cdr (cdr rules))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
376 (funcall (car (cdr (cdr rules)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
377 new))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
378
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
379 (defun gdb-rules-name-maker (rules) (car (cdr rules)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
380
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
381 (defun gdb-look-for-tagged-buffer (instance key bufs)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
382 (let ((retval nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
383 (while (and (not retval) bufs)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
384 (set-buffer (car bufs))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
385 (if (and (eq gdb-buffer-instance instance)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
386 (eq gdb-buffer-type key))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
387 (setq retval (car bufs)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
388 (setq bufs (cdr bufs))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
389 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
390 retval))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
391
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
392 (defun gdb-instance-buffer-p (buf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
393 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
394 (set-buffer buf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
395 (and gdb-buffer-type
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
396 (not (eq gdb-buffer-type 'gud)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
397
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
398 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
399 ;; This assoc maps buffer type symbols to rules. Each rule is a list of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
400 ;; at least one and possible more functions. The functions have these
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
401 ;; roles in defining a buffer type:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
402 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
403 ;; NAME - take an instance, return a name for this type buffer for that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
404 ;; instance.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
405 ;; The remaining function(s) are optional:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
406 ;;
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
407 ;; MODE - called in the new buffer with no arguments, should establish
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
408 ;; the proper mode for the buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
409 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
410
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
411 (defvar gdb-instance-buffer-rules-assoc '())
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 gdb-set-instance-buffer-rules (buffer-type &rest rules)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
414 (let ((binding (assoc buffer-type gdb-instance-buffer-rules-assoc)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
415 (if binding
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
416 (setcdr binding rules)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
417 (setq gdb-instance-buffer-rules-assoc
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
418 (cons (cons buffer-type rules)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
419 gdb-instance-buffer-rules-assoc)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
420
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
421 (gdb-set-instance-buffer-rules 'gud 'error) ; gud buffers are an exception to the rules
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
422
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
423 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
424 ;; partial-output buffers
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
425 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
426 ;; These accumulate output from a command executed on
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
427 ;; behalf of emacs (rather than the user).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
428 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
429
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
430 (gdb-set-instance-buffer-rules 'gdb-partial-output-buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
431 'gdb-partial-output-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
432
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
433 (defun gdb-partial-output-name (instance)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
434 (concat "*partial-output-"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
435 (gdb-instance-target-string instance)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
436 "*"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
437
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
438
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
439 (gdb-set-instance-buffer-rules 'gdb-inferior-io
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
440 'gdb-inferior-io-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
441 'gud-inferior-io-mode)
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 gdb-inferior-io-name (instance)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
444 (concat "*input/output of "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
445 (gdb-instance-target-string instance)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
446 "*"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
447
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
448 (defvar gdb-inferior-io-mode-map (copy-keymap comint-mode-map))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
449 (define-key gdb-inferior-io-mode-map "\C-c\C-c" 'gdb-inferior-io-interrupt)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
450 (define-key gdb-inferior-io-mode-map "\C-c\C-z" 'gdb-inferior-io-stop)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
451 (define-key gdb-inferior-io-mode-map "\C-c\C-\\" 'gdb-inferior-io-quit)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
452 (define-key gdb-inferior-io-mode-map "\C-c\C-d" 'gdb-inferior-io-eof)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
453
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
454 (defun gud-inferior-io-mode ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
455 "Major mode for gud inferior-io.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
456
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
457 \\{comint-mode-map}"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
458 ;; We want to use comint because it has various nifty and familiar
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
459 ;; features. We don't need a process, but comint wants one, so create
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
460 ;; a dummy one.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
461 (make-comint (substring (buffer-name) 1 (- (length (buffer-name)) 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
462 "/bin/cat")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
463 (setq major-mode 'gud-inferior-io-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
464 (setq mode-name "Debuggee I/O")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
465 (setq comint-input-sender 'gud-inferior-io-sender)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
466 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
467
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
468 (defun gud-inferior-io-sender (proc string)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
469 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
470 (set-buffer (process-buffer proc))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
471 (let ((instance gdb-buffer-instance))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
472 (set-buffer (gdb-get-instance-buffer instance 'gud))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
473 (let ((gud-proc (get-buffer-process (current-buffer))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
474 (process-send-string gud-proc string)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
475 (process-send-string gud-proc "\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
476 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
477 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
478
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
479 (defun gdb-inferior-io-interrupt (instance)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
480 "Interrupt the program being debugged."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
481 (interactive (list (gdb-needed-default-instance)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
482 (interrupt-process
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
483 (get-buffer-process (gdb-get-instance-buffer instance 'gud)) comint-ptyp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
484
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
485 (defun gdb-inferior-io-quit (instance)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
486 "Send quit signal to the program being debugged."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
487 (interactive (list (gdb-needed-default-instance)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
488 (quit-process
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
489 (get-buffer-process (gdb-get-instance-buffer instance 'gud)) comint-ptyp))
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 gdb-inferior-io-stop (instance)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
492 "Stop the program being debugged."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
493 (interactive (list (gdb-needed-default-instance)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
494 (stop-process
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
495 (get-buffer-process (gdb-get-instance-buffer instance 'gud)) comint-ptyp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
496
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
497 (defun gdb-inferior-io-eof (instance)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
498 "Send end-of-file to the program being debugged."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
499 (interactive (list (gdb-needed-default-instance)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
500 (process-send-eof
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
501 (get-buffer-process (gdb-get-instance-buffer instance 'gud))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
502
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
503
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
504 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
505 ;; gdb communications
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
506 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
507
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
508 ;; INPUT: things sent to gdb
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
509 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
510 ;; Each instance has a high and low priority
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
511 ;; input queue. Low priority input is sent only
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
512 ;; when the high priority queue is idle.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
513 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
514 ;; The queues are lists. Each element is either
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
515 ;; a string (indicating user or user-like input)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
516 ;; or a list of the form:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
517 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
518 ;; (INPUT-STRING HANDLER-FN)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
519 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
520 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
521 ;; The handler function will be called from the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
522 ;; partial-output buffer when the command completes.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
523 ;; This is the way to write commands which
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
524 ;; invoke gdb commands autonomously.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
525 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
526 ;; These lists are consumed tail first.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
527 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
528
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
529 (defun gdb-send (proc string)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
530 "A comint send filter for gdb.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
531 This filter may simply queue output for a later time."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
532 (let ((instance (gdb-proc->instance proc)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
533 (gdb-instance-enqueue-input instance (concat string "\n"))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
534
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
535 ;; Note: Stuff enqueued here will be sent to the next prompt, even if it
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
536 ;; is a query, or other non-top-level prompt. To guarantee stuff will get
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
537 ;; sent to the top-level prompt, currently it must be put in the idle queue.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
538 ;; ^^^^^^^^^
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
539 ;; [This should encourage gud extentions that invoke gdb commands to let
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
540 ;; the user go first; it is not a bug. -t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
541 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
542
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
543 (defun gdb-instance-enqueue-input (instance item)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
544 (if (gdb-instance-prompting instance)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
545 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
546 (gdb-send-item instance item)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
547 (set-gdb-instance-prompting instance nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
548 (set-gdb-instance-input-queue
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
549 instance
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
550 (cons item (gdb-instance-input-queue instance)))))
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-instance-dequeue-input (instance)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
553 (let ((queue (gdb-instance-input-queue instance)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
554 (and queue
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
555 (if (not (cdr queue))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
556 (let ((answer (car queue)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
557 (set-gdb-instance-input-queue instance '())
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
558 answer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
559 (gdb-take-last-elt queue)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
560
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
561 (defun gdb-instance-enqueue-idle-input (instance item)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
562 (if (and (gdb-instance-prompting instance)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
563 (not (gdb-instance-input-queue instance)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
564 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
565 (gdb-send-item instance item)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
566 (set-gdb-instance-prompting instance nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
567 (set-gdb-instance-idle-input-queue
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
568 instance
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
569 (cons item (gdb-instance-idle-input-queue instance)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
570
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
571 (defun gdb-instance-dequeue-idle-input (instance)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
572 (let ((queue (gdb-instance-idle-input-queue instance)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
573 (and queue
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
574 (if (not (cdr queue))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
575 (let ((answer (car queue)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
576 (set-gdb-instance-idle-input-queue instance '())
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
577 answer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
578 (gdb-take-last-elt queue)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
579
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
580 ; Don't use this in general.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
581 (defun gdb-take-last-elt (l)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
582 (if (cdr (cdr l))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
583 (gdb-take-last-elt (cdr l))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
584 (let ((answer (car (cdr l))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
585 (setcdr l '())
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
586 answer)))
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 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
590 ;; output -- things gdb prints to emacs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
591 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
592 ;; GDB output is a stream interrupted by annotations.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
593 ;; Annotations can be recognized by their beginning
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
594 ;; with \C-j\C-z\C-z<tag><opt>\C-j
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
595 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
596 ;; The tag is a string obeying symbol syntax.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
597 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
598 ;; The optional part `<opt>' can be either the empty string
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
599 ;; or a space followed by more data relating to the annotation.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
600 ;; For example, the SOURCE annotation is followed by a filename,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
601 ;; line number and various useless goo. This data must not include
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
602 ;; any newlines.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
603 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
604
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
605
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
606 (defun gud-gdb-marker-filter (string)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
607 "A gud marker filter for gdb."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
608 ;; Bogons don't tell us the process except through scoping crud.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
609 (let ((instance (gdb-proc->instance proc)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
610 (gdb-output-burst instance string)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
611
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
612 (defvar gdb-annotation-rules
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
613 '(("frames-invalid" gdb-invalidate-frames)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
614 ("breakpoints-invalid" gdb-invalidate-breakpoints)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
615 ("pre-prompt" gdb-pre-prompt)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
616 ("prompt" gdb-prompt)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
617 ("commands" gdb-subprompt)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
618 ("overload-choice" gdb-subprompt)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
619 ("query" gdb-subprompt)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
620 ("prompt-for-continue" gdb-subprompt)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
621 ("post-prompt" gdb-post-prompt)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
622 ("source" gdb-source)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
623 ("starting" gdb-starting)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
624 ("exited" gdb-stopping)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
625 ("signalled" gdb-stopping)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
626 ("signal" gdb-stopping)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
627 ("breakpoint" gdb-stopping)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
628 ("watchpoint" gdb-stopping)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
629 ("stopped" gdb-stopped)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
630 ("display-begin" gdb-display-begin)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
631 ("display-end" gdb-display-end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
632 ("error-begin" gdb-error-begin)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
633 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
634 "An assoc mapping annotation tags to functions which process them.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
635
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
636
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
637 (defun gdb-ignore-annotation (instance args)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
638 nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
639
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
640 (defconst gdb-source-spec-regexp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
641 "\\(.*\\):\\([0-9]*\\):[0-9]*:[a-z]*:0x[a-f0-9]*")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
642
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
643 ;; Do not use this except as an annotation handler."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
644 (defun gdb-source (instance args)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
645 (string-match gdb-source-spec-regexp args)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
646 ;; Extract the frame position from the marker.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
647 (setq gud-last-frame
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
648 (cons
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
649 (substring args (match-beginning 1) (match-end 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
650 (string-to-int (substring args
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
651 (match-beginning 2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
652 (match-end 2))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
653
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
654 ;; An annotation handler for `prompt'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
655 ;; This sends the next command (if any) to gdb.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
656 (defun gdb-prompt (instance ignored)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
657 (let ((sink (gdb-instance-output-sink instance)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
658 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
659 ((eq sink 'user) t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
660 ((eq sink 'post-emacs)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
661 (set-gdb-instance-output-sink instance 'user))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
662 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
663 (set-gdb-instance-output-sink instance 'user)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
664 (error "Phase error in gdb-prompt (got %s)" sink))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
665 (let ((highest (gdb-instance-dequeue-input instance)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
666 (if highest
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
667 (gdb-send-item instance highest)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
668 (let ((lowest (gdb-instance-dequeue-idle-input instance)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
669 (if lowest
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
670 (gdb-send-item instance lowest)
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 (set-gdb-instance-prompting instance t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
673 (gud-display-frame)))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
674
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
675 ;; An annotation handler for non-top-level prompts.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
676 (defun gdb-subprompt (instance ignored)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
677 (let ((highest (gdb-instance-dequeue-input instance)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
678 (if highest
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
679 (gdb-send-item instance highest)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
680 (set-gdb-instance-prompting instance t))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
681
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
682 (defun gdb-send-item (instance item)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
683 (set-gdb-instance-current-item instance item)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
684 (if (stringp item)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
685 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
686 (set-gdb-instance-output-sink instance 'user)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
687 (process-send-string (gdb-instance-process instance)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
688 item))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
689 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
690 (gdb-clear-partial-output instance)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
691 (set-gdb-instance-output-sink instance 'pre-emacs)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
692 (process-send-string (gdb-instance-process instance)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
693 (car item)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
694
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
695 ;; This terminates the collection of output from a previous
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
696 ;; command if that happens to be in effect.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
697 (defun gdb-pre-prompt (instance ignored)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
698 (let ((sink (gdb-instance-output-sink instance)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
699 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
700 ((eq sink 'user) t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
701 ((eq sink 'emacs)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
702 (set-gdb-instance-output-sink instance 'post-emacs)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
703 (let ((handler
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
704 (car (cdr (gdb-instance-current-item instance)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
705 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
706 (set-buffer (gdb-get-create-instance-buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
707 instance 'gdb-partial-output-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
708 (funcall handler))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
709 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
710 (set-gdb-instance-output-sink instance 'user)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
711 (error "Output sink phase error 1.")))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
712
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
713 ;; An annotation handler for `starting'. This says that I/O for the subprocess
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
714 ;; is now the program being debugged, not GDB.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
715 (defun gdb-starting (instance ignored)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
716 (let ((sink (gdb-instance-output-sink instance)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
717 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
718 ((eq sink 'user)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
719 (set-gdb-instance-output-sink instance 'inferior)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
720 ;; FIXME: need to send queued input
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
721 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
722 (t (error "Unexpected `starting' annotation")))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
723
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
724 ;; An annotation handler for `exited' and other annotations which say that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
725 ;; I/O for the subprocess is now GDB, not the program being debugged.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
726 (defun gdb-stopping (instance ignored)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
727 (let ((sink (gdb-instance-output-sink instance)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
728 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
729 ((eq sink 'inferior)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
730 (set-gdb-instance-output-sink instance 'user)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
731 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
732 (t (error "Unexpected stopping annotation")))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
733
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
734 ;; An annotation handler for `stopped'. It is just like gdb-stopping, except
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
735 ;; that if we already set the output sink to 'user in gdb-stopping, that is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
736 ;; fine.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
737 (defun gdb-stopped (instance ignored)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
738 (let ((sink (gdb-instance-output-sink instance)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
739 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
740 ((eq sink 'inferior)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
741 (set-gdb-instance-output-sink instance 'user)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
742 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
743 ((eq sink 'user)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
744 t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
745 (t (error "Unexpected stopping annotation")))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
746
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
747 ;; An annotation handler for `post-prompt'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
748 ;; This begins the collection of output from the current
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
749 ;; command if that happens to be appropriate."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
750 (defun gdb-post-prompt (instance ignored)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
751 (if (not (gdb-instance-pending-triggers instance))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
752 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
753 (gdb-invalidate-registers instance ignored)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
754 (gdb-invalidate-locals instance ignored)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
755 (gdb-invalidate-display instance ignored)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
756 (let ((sink (gdb-instance-output-sink instance)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
757 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
758 ((eq sink 'user) t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
759 ((eq sink 'pre-emacs)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
760 (set-gdb-instance-output-sink instance 'emacs))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
761
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
762 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
763 (set-gdb-instance-output-sink instance 'user)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
764 (error "Output sink phase error 3.")))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
765
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
766 ;; Handle a burst of output from a gdb instance.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
767 ;; This function is (indirectly) used as a gud-marker-filter.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
768 ;; It must return output (if any) to be insterted in the gud
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
769 ;; buffer.
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 gdb-output-burst (instance string)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
772 "Handle a burst of output from a gdb instance.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
773 This function is (indirectly) used as a gud-marker-filter.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
774 It must return output (if any) to be insterted in the gud
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
775 buffer."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
776
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
777 (save-match-data
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
778 (let (
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
779 ;; Recall the left over burst from last time
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
780 (burst (concat (gdb-instance-burst instance) string))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
781 ;; Start accumulating output for the gud buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
782 (output ""))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
783
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
784 ;; Process all the complete markers in this chunk.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
785
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
786 (while (string-match "\n\032\032\\(.*\\)\n" burst)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
787 (let ((annotation (substring burst
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
788 (match-beginning 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
789 (match-end 1))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
790
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
791 ;; Stuff prior to the match is just ordinary output.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
792 ;; It is either concatenated to OUTPUT or directed
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
793 ;; elsewhere.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
794 (setq output
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
795 (gdb-concat-output
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
796 instance
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
797 output
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
798 (substring burst 0 (match-beginning 0))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
799
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
800 ;; Take that stuff off the burst.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
801 (setq burst (substring burst (match-end 0)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
802
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
803 ;; Parse the tag from the annotation, and maybe its arguments.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
804 (string-match "\\(\\S-*\\) ?\\(.*\\)" annotation)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
805 (let* ((annotation-type (substring annotation
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
806 (match-beginning 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
807 (match-end 1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
808 (annotation-arguments (substring annotation
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
809 (match-beginning 2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
810 (match-end 2)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
811 (annotation-rule (assoc annotation-type
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
812 gdb-annotation-rules)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
813 ;; Call the handler for this annotation.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
814 (if annotation-rule
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
815 (funcall (car (cdr annotation-rule))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
816 instance
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
817 annotation-arguments)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
818 ;; Else the annotation is not recognized. Ignore it silently,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
819 ;; so that GDB can add new annotations without causing
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
820 ;; us to blow up.
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
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
824 ;; Does the remaining text end in a partial line?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
825 ;; If it does, then keep part of the burst until we get more.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
826 (if (string-match "\n\\'\\|\n\032\\'\\|\n\032\032.*\\'"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
827 burst)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
828 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
829 ;; Everything before the potential marker start can be output.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
830 (setq output
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
831 (gdb-concat-output
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
832 instance
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
833 output
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
834 (substring burst 0 (match-beginning 0))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
835
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
836 ;; Everything after, we save, to combine with later input.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
837 (setq burst (substring burst (match-beginning 0))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
838
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
839 ;; In case we know the burst contains no partial annotations:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
840 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
841 (setq output (gdb-concat-output instance output burst))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
842 (setq burst "")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
843
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
844 ;; Save the remaining burst for the next call to this function.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
845 (set-gdb-instance-burst instance burst)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
846 output)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
847
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
848 (defun gdb-concat-output (instance so-far new)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
849 (let ((sink (gdb-instance-output-sink instance)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
850 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
851 ((eq sink 'user) (concat so-far new))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
852 ((or (eq sink 'pre-emacs) (eq sink 'post-emacs)) so-far)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
853 ((eq sink 'emacs)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
854 (gdb-append-to-partial-output instance new)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
855 so-far)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
856 ((eq sink 'inferior)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
857 (gdb-append-to-inferior-io instance new)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
858 so-far)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
859 (t (error "Bogon output sink %S" sink)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
860
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
861 (defun gdb-append-to-partial-output (instance string)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
862 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
863 (buffer-disable-undo ; Don't need undo in partial output buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
864 (set-buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
865 (gdb-get-create-instance-buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
866 instance 'gdb-partial-output-buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
867 (goto-char (point-max))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
868 (insert string)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
869
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
870 (defun gdb-clear-partial-output (instance)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
871 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
872 (set-buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
873 (gdb-get-create-instance-buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
874 instance 'gdb-partial-output-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
875 (delete-region (point-min) (point-max))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
876
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
877 (defun gdb-append-to-inferior-io (instance string)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
878 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
879 (set-buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
880 (gdb-get-create-instance-buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
881 instance 'gdb-inferior-io))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
882 (goto-char (point-max))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
883 (insert-before-markers string))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
884 (gud-display-buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
885 (gdb-get-create-instance-buffer instance
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
886 'gdb-inferior-io)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
887
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
888 (defun gdb-clear-inferior-io (instance)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
889 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
890 (set-buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
891 (gdb-get-create-instance-buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
892 instance 'gdb-inferior-io))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
893 (delete-region (point-min) (point-max))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
894
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
895
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
896
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
897 ;; One trick is to have a command who's output is always available in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
898 ;; a buffer of it's own, and is always up to date. We build several
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
899 ;; buffers of this type.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
900 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
901 ;; There are two aspects to this: gdb has to tell us when the output
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
902 ;; for that command might have changed, and we have to be able to run
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
903 ;; the command behind the user's back.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
904 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
905 ;; The idle input queue and the output phasing associated with
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
906 ;; the instance variable `(gdb-instance-output-sink instance)' help
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
907 ;; us to run commands behind the user's back.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
908 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
909 ;; Below is the code for specificly managing buffers of output from one
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
910 ;; command.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
911 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
912
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
913
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
914 ;; The trigger function is suitable for use in the assoc GDB-ANNOTATION-RULES
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
915 ;; It adds an idle input for the command we are tracking. It should be the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
916 ;; annotation rule binding of whatever gdb sends to tell us this command
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
917 ;; might have changed it's output.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
918 ;;
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 70
diff changeset
919 ;; NAME is the function name. DEMAND-PREDICATE tests if output is really needed.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
920 ;; GDB-COMMAND is a string of such. OUTPUT-HANDLER is the function bound to the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
921 ;; input in the input queue (see comment about ``gdb communications'' above).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
922 (defmacro def-gdb-auto-update-trigger (name demand-predicate gdb-command output-handler)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
923 (`
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
924 (defun (, name) (instance &optional ignored)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
925 (if (and ((, demand-predicate) instance)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
926 (not (member '(, name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
927 (gdb-instance-pending-triggers instance))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
928 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
929 (gdb-instance-enqueue-idle-input
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
930 instance
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
931 (list (, gdb-command) '(, output-handler)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
932 (set-gdb-instance-pending-triggers
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
933 instance
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
934 (cons '(, name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
935 (gdb-instance-pending-triggers instance)))) ))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
936
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
937 (defmacro def-gdb-auto-update-handler (name trigger buf-key)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
938 (`
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
939 (defun (, name) ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
940 (set-gdb-instance-pending-triggers
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
941 instance
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
942 (delq '(, trigger)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
943 (gdb-instance-pending-triggers instance)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
944 (let ((buf (gdb-get-instance-buffer instance
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
945 '(, buf-key))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
946 (and buf
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
947 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
948 (set-buffer buf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
949 (buffer-disable-undo buf) ; don't need undo
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
950 (let ((p (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
951 (buffer-read-only nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
952 (instance-buf (gdb-get-create-instance-buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
953 instance
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
954 'gdb-partial-output-buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
955 (if (gud-buffers-differ buf instance-buf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
956 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
957 (delete-region (point-min) (point-max))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
958 (insert-buffer instance-buf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
959 (if (buffer-dedicated-frame)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
960 (fit-frame-to-buffer (buffer-dedicated-frame) buf))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
961 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
962 (goto-char p))))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
963
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
964 (defmacro def-gdb-auto-updated-buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
965 (buffer-key trigger-name gdb-command output-handler-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
966 (`
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
967 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
968 (def-gdb-auto-update-trigger (, trigger-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
969 ;; The demand predicate:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
970 (lambda (instance)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
971 (gdb-get-instance-buffer instance '(, buffer-key)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
972 (, gdb-command)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
973 (, output-handler-name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
974 (def-gdb-auto-update-handler (, output-handler-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
975 (, trigger-name) (, buffer-key)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
976
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
977
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
978 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
979 ;; Breakpoint buffers
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
980 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
981 ;; These display the output of `info breakpoints'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
982 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
983
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
984
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
985 (gdb-set-instance-buffer-rules 'gdb-breakpoints-buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
986 'gdb-breakpoints-buffer-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
987 'gud-breakpoints-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
988
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
989 (def-gdb-auto-updated-buffer gdb-breakpoints-buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
990 ;; This defines the auto update rule for buffers of type
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
991 ;; `gdb-breakpoints-buffer'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
992 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
993 ;; It defines a function to serve as the annotation handler that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
994 ;; handles the `foo-invalidated' message. That function is called:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
995 gdb-invalidate-breakpoints
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
996
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
997 ;; To update the buffer, this command is sent to gdb.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
998 "server info breakpoints\n"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
999
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1000 ;; This also defines a function to be the handler for the output
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1001 ;; from the command above. That function will copy the output into
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1002 ;; the appropriately typed buffer. That function will be called:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1003 gdb-info-breakpoints-handler)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1004
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1005 (defun gdb-breakpoints-buffer-name (instance)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1006 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1007 (set-buffer (process-buffer (gdb-instance-process instance)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1008 (concat "*breakpoints of " (gdb-instance-target-string instance) "*")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1009
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1010 (defun gud-display-breakpoints-buffer (instance)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1011 (interactive (list (gdb-needed-default-instance)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1012 (gud-display-buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1013 (gdb-get-create-instance-buffer instance
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1014 'gdb-breakpoints-buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1015
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1016 (defun gud-frame-breakpoints-buffer (instance)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1017 (interactive (list (gdb-needed-default-instance)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1018 (gud-display-buffer-new-frame
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1019 (gdb-get-create-instance-buffer instance
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1020 'gdb-breakpoints-buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1021
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1022 (defvar gud-breakpoints-mode-map nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1023 (defvar gud-breakpoints-mode-menu
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1024 '("GDB Breakpoint Commands"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1025 "----"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1026 ["Toggle" gud-toggle-bp-this-line t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1027 ["Delete" gud-delete-bp-this-line t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1028 ["Condition" gud-bp-condition t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1029 ["Ignore" gud-bp-ignore t])
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1030 "*menu for gud-breakpoints-mode")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1031
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1032 (setq gud-breakpoints-mode-map (make-keymap))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1033 (suppress-keymap gud-breakpoints-mode-map)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1034 (define-key gud-breakpoints-mode-map " " 'gud-toggle-bp-this-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1035 (define-key gud-breakpoints-mode-map "d" 'gud-delete-bp-this-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1036 (define-key gud-breakpoints-mode-map "c" 'gud-bp-condition)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1037 (define-key gud-breakpoints-mode-map "i" 'gud-bp-ignore)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1038 (define-key gud-breakpoints-mode-map 'button3 'gud-breakpoints-popup-menu)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1039 (defun gud-breakpoints-mode ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1040 "Major mode for gud breakpoints.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1041
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1042 \\{gud-breakpoints-mode-map}"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1043 (setq major-mode 'gud-breakpoints-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1044 (setq mode-name "Breakpoints")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1045 (use-local-map gud-breakpoints-mode-map)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1046 (setq buffer-read-only t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1047 (require 'mode-motion)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1048 (setq mode-motion-hook 'gud-breakpoints-mode-motion-hook)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1049 (gdb-invalidate-breakpoints gdb-buffer-instance))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1050
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1051 (defun gud-toggle-bp-this-line ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1052 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1053 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1054 (set-buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1055 (gdb-get-instance-buffer gdb-buffer-instance 'gdb-breakpoints-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1056 (if (key-press-event-p last-input-event)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1057 (beginning-of-line 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1058 (and mode-motion-extent (extent-buffer mode-motion-extent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1059 (goto-char (extent-start-position mode-motion-extent))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1060 (if (not (looking-at "\\([0-9]*\\)\\s-*\\S-*\\s-*\\S-*\\s-*\\(.\\)"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1061 (error "Not recognized as breakpoint line (demo foo).")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1062 (gdb-instance-enqueue-idle-input
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1063 gdb-buffer-instance
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1064 (list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1065 (concat
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1066 (if (eq ?y (char-after (match-beginning 2)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1067 "server disable "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1068 "server enable ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1069 (buffer-substring (match-beginning 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1070 (match-end 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1071 "\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1072 '(lambda () nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1073 )))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1074
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1075 (defun gud-delete-bp-this-line ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1076 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1077 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1078 (set-buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1079 (gdb-get-instance-buffer gdb-buffer-instance 'gdb-breakpoints-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1080 (if (key-press-event-p last-input-event)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1081 (beginning-of-line 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1082 (and mode-motion-extent (extent-buffer mode-motion-extent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1083 (goto-char (extent-start-position mode-motion-extent))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1084 (if (not (looking-at "\\([0-9]*\\)\\s-*\\S-*\\s-*\\S-*\\s-*\\(.\\)"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1085 (error "Not recognized as breakpoint line (demo foo).")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1086 (gdb-instance-enqueue-idle-input
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1087 gdb-buffer-instance
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1088 (list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1089 (concat
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1090 "server delete "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1091 (buffer-substring (match-beginning 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1092 (match-end 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1093 "\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1094 '(lambda () nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1095 )))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1096
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1097 (defun gud-bp-condition (condition)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1098 (interactive "sCondition for breakpoint: ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1099 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1100 (set-buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1101 (gdb-get-instance-buffer gdb-buffer-instance 'gdb-breakpoints-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1102 (if (key-press-event-p last-input-event)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1103 (beginning-of-line 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1104 (and mode-motion-extent (extent-buffer mode-motion-extent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1105 (goto-char (extent-start-position mode-motion-extent))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1106 (if (not (looking-at "\\([0-9]*\\)\\s-*\\S-*\\s-*\\S-*\\s-*\\(.\\)"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1107 (error "Not recognized as breakpoint line (demo foo).")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1108 (gdb-instance-enqueue-idle-input
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1109 gdb-buffer-instance
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1110 (list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1111 (concat
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1112 "server condition "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1113 (buffer-substring (match-beginning 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1114 (match-end 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1115 (if (> (length condition) 0) (concat " " condition) "")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1116 "\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1117 '(lambda () nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1118 (gdb-invalidate-breakpoints gdb-buffer-instance)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1119 )))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1120
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1121 (defun gud-bp-ignore (count)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1122 (interactive "nNumber of times to ignore breakpoint: ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1123 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1124 (set-buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1125 (gdb-get-instance-buffer gdb-buffer-instance 'gdb-breakpoints-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1126 (if (key-press-event-p last-input-event)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1127 (beginning-of-line 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1128 (and mode-motion-extent (extent-buffer mode-motion-extent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1129 (goto-char (extent-start-position mode-motion-extent))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1130 (if (not (looking-at "\\([0-9]*\\)\\s-*\\S-*\\s-*\\S-*\\s-*\\(.\\)"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1131 (error "Not recognized as breakpoint line (demo foo).")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1132 (gdb-instance-enqueue-idle-input
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1133 gdb-buffer-instance
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1134 (list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1135 (concat
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1136 "server ignore "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1137 (buffer-substring (match-beginning 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1138 (match-end 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1139 " "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1140 (int-to-string count)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1141 "\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1142 '(lambda () nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1143 (gdb-invalidate-breakpoints gdb-buffer-instance)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1144 )))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1145
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1146 (defun gud-breakpoints-mode-motion-hook (event)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1147 (gud-breakpoints-mode-motion-internal event "^[0-9]+[ \t]"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1148
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1149 (defun gud-breakpoints-mode-motion-internal (event regexp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1150 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1151 ;; This is mostly ripped off from mode-motion-highlight-internal but
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1152 ;; we set the extent's face rather than setting it to highlight. That
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1153 ;; way if we're somewhere in the breakpoint's list of commands or other
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1154 ;; info we still highlight it.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1155 (if (event-buffer event)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1156 (let* ((buffer (event-buffer event))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1157 point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1158 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1159 (set-buffer buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1160 (mouse-set-point event)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1161 (beginning-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1162 (if (not (looking-at regexp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1163 (re-search-backward regexp (point-min) 't))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1164 (setq point (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1165 (if (looking-at regexp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1166 (end-of-line))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1167 (if (and mode-motion-extent (extent-buffer mode-motion-extent))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1168 (if (eq point (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1169 (delete-extent mode-motion-extent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1170 (set-extent-endpoints mode-motion-extent point (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1171 (if (eq point (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1172 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1173 (setq mode-motion-extent (make-extent point (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1174 (set-extent-property mode-motion-extent 'face
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1175 (get-face 'highlight)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1176 )))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1177
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1178 (defun gud-breakpoints-popup-menu (event)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1179 (interactive "@e")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1180 (mouse-set-point event)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1181 (popup-menu gud-breakpoints-mode-menu))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1182
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1183 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1184 ;; Display expression buffers
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1185 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1186 ;; These show the current list of expressions which the debugger
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1187 ;; prints when the inferior stops and their values. Note that there
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1188 ;; isn't a "display-invalid" annotation so we have to a bit more
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1189 ;; work than for the other auto-update buffers
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1190 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1191
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1192 (gdb-set-instance-buffer-rules 'gdb-display-buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1193 'gdb-display-buffer-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1194 'gud-display-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1195
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1196
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1197 (def-gdb-auto-updated-buffer gdb-display-buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1198 ;; This defines the auto update rule for buffers of type
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1199 ;; `gdb-display-buffer'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1200 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1201 ;; It defines a function to serve as the annotation handler that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1202 ;; handles the `foo-invalidated' message. That function is called:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1203 gdb-invalidate-display
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1204
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1205 ;; To update the buffer, this command is sent to gdb.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1206 "server info display\n"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1207
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1208 ;; This also defines a function to be the handler for the output
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1209 ;; from the command above. That function will copy the output into
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1210 ;; the appropriately typed buffer. That function will be called:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1211 gdb-info-display-handler)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1212
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1213
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1214 ;; Since the displayed expressions buffer is not simply a copy of what gdb
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1215 ;; prints for the "info display" command we need a slightly more complex
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1216 ;; handler for it than the standard one which def-gdb-auto-updated-buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1217 ;; defines.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1218
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1219 (defun gdb-info-display-handler ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1220
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1221 (set-gdb-instance-pending-triggers
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1222 instance (delq 'gdb-invalidate-display
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1223 (gdb-instance-pending-triggers instance)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1224
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1225 (let ((buf (gdb-get-instance-buffer instance 'gdb-display-buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1226 (and buf
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1227 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1228 (let ((instance-buf (gdb-get-create-instance-buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1229 instance 'gdb-partial-output-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1230 expr-alist point expr highlight-expr)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1231 (set-buffer instance-buf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1232 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1233 (while
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1234 (re-search-forward "^\\([0-9]+\\): \\([ny] .*$\\)" (point-max) t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1235 (setq expr-alist
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1236 (cons
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1237 (cons (buffer-substring (match-beginning 1) (match-end 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1238 (buffer-substring (match-beginning 2) (match-end 2)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1239 expr-alist)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1240 (set-buffer buf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1241 (setq buffer-read-only nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1242 (if (and mode-motion-extent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1243 (extent-buffer mode-motion-extent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1244 (extent-start-position mode-motion-extent))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1245 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1246 (goto-char (extent-start-position mode-motion-extent))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1247 (if (looking-at "^[0-9]+:")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1248 (setq highlight-expr (buffer-substring (match-beginning 0) (match-end 0))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1249 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1250 (delete-region (point-min)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1251 (if (not (re-search-forward "^\\([0-9]+\\): " (point-max) t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1252 (point-max)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1253 (beginning-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1254 (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1255 (if (not expr-alist)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1256 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1257 (insert "There are no auto-display expressions now.\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1258 (delete-region (point) (point-max)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1259 (insert "Auto-display expressions now in effect:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1260 Num Enb Expression = value\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1261 (while
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1262 (re-search-forward "^\\([0-9]+\\): \\([ny]\\)" (point-max) t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1263 (if (setq expr (assoc (buffer-substring (match-beginning 1) (match-end 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1264 expr-alist))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1265 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1266 (if (string-equal (substring (cdr expr) 0 1) "y")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1267 (replace-match "\\1: y")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1268 (replace-match (format "\\1: %s" (cdr expr)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1269 (setq point (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1270 (if (re-search-forward "^[0-9]+: " (point-max) 'move)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1271 (beginning-of-line))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1272 (delete-region point (if (eobp) (point) (1- (point)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1273 (setq expr-alist (delq expr expr-alist)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1274 (beginning-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1275 (setq point (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1276 (if (re-search-forward "^[0-9]+: " (point-max) 'move 2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1277 (beginning-of-line))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1278 (delete-region point (point))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1279 (goto-char (point-max))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1280 (while expr-alist
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1281 (insert (concat (car (car expr-alist)) ": "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1282 (cdr (car expr-alist)) "\n" ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1283 (setq expr-alist (cdr expr-alist))) )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1284 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1285 (if (and mode-motion-extent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1286 (extent-buffer mode-motion-extent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1287 highlight-expr
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1288 (re-search-forward (concat "^" highlight-expr ".*$") (point-max) t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1289 (set-extent-endpoints mode-motion-extent (match-beginning 0) (match-end 0)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1290 (setq buffer-read-only t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1291 (if (buffer-dedicated-frame)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1292 (fit-frame-to-buffer (buffer-dedicated-frame) buf))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1293 )))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1294
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1295 (defvar gud-display-mode-map nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1296 (setq gud-display-mode-map (make-keymap))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1297 (suppress-keymap gud-display-mode-map)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1298
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1299 (defvar gud-display-mode-menu
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1300 '("GDB Display Commands"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1301 "----"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1302 ["Toggle enable" gud-toggle-disp-this-line t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1303 ["Delete" gud-delete-disp-this-line t])
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1304 "*menu for gud-display-mode")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1305
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1306 (define-key gud-display-mode-map " " 'gud-toggle-disp-this-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1307 (define-key gud-display-mode-map "d" 'gud-delete-disp-this-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1308 (define-key gud-display-mode-map 'button3 'gud-display-popup-menu)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1309
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1310 (defun gud-display-mode ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1311 "Major mode for gud display.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1312
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1313 \\{gud-display-mode-map}"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1314 (setq major-mode 'gud-display-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1315 (setq mode-name "Display")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1316 (setq buffer-read-only t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1317 (use-local-map gud-display-mode-map)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1318 (require 'mode-motion)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1319 (setq mode-motion-hook 'gud-display-mode-motion-hook)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1320 (gdb-invalidate-display gdb-buffer-instance)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1321 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1322
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1323 (defun gdb-display-buffer-name (instance)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1324 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1325 (set-buffer (process-buffer (gdb-instance-process instance)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1326 (concat "*Displayed expressions of " (gdb-instance-target-string instance) "*")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1327
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1328 (defun gud-display-display-buffer (instance)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1329 (interactive (list (gdb-needed-default-instance)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1330 (let ((buf (gdb-get-create-instance-buffer instance
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1331 'gdb-display-buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1332 (gdb-invalidate-display instance)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1333 (gud-display-buffer buf)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1334
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1335
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1336 (defun gud-frame-display-buffer (instance)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1337 (interactive (list (gdb-needed-default-instance)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1338 (let ((buf (gdb-get-create-instance-buffer instance
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1339 'gdb-display-buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1340 (gdb-invalidate-display instance)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1341 (gud-display-buffer-new-frame buf)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1342
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1343 (defun gud-toggle-disp-this-line ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1344 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1345 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1346 (set-buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1347 (gdb-get-instance-buffer gdb-buffer-instance 'gdb-display-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1348 (if (key-press-event-p last-input-event)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1349 (beginning-of-line 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1350 (and mode-motion-extent (extent-buffer mode-motion-extent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1351 (goto-char (extent-start-position mode-motion-extent))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1352 (if (not (looking-at "\\([0-9]+\\): \\([ny]\\)"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1353 (error "No expression on this line.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1354 (gdb-instance-enqueue-idle-input
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1355 gdb-buffer-instance
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1356 (list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1357 (concat
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1358 (if (eq ?y (char-after (match-beginning 2)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1359 "server disable display "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1360 "server enable display ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1361 (buffer-substring (match-beginning 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1362 (match-end 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1363 "\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1364 '(lambda () nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1365 )))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1366
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1367 (defun gud-delete-disp-this-line ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1368 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1369 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1370 (set-buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1371 (gdb-get-instance-buffer gdb-buffer-instance 'gdb-display-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1372 (if (key-press-event-p last-input-event)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1373 (beginning-of-line 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1374 (and mode-motion-extent (extent-buffer mode-motion-extent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1375 (goto-char (extent-start-position mode-motion-extent))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1376 (if (not (looking-at "\\([0-9]+\\): \\([ny]\\)"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1377 (error "No expression on this line.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1378 (gdb-instance-enqueue-idle-input
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1379 gdb-buffer-instance
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1380 (list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1381 (concat
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1382 "server delete display "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1383 (buffer-substring (match-beginning 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1384 (match-end 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1385 "\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1386 '(lambda () nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1387 )))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1388
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1389 (defun gud-display-mode-motion-hook (event)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1390 (gud-breakpoints-mode-motion-internal event "^[0-9]+: "))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1391
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1392 (defun gud-display-popup-menu (event)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1393 (interactive "@e")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1394 (mouse-set-point event)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1395 (popup-menu gud-display-mode-menu))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1396
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1397 ;; If we get an error whilst evaluating one of the expressions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1398 ;; we won't get the display-end annotation. Set the sink back to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1399 ;; user to make sure that the error message is seen
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1400
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1401 (defun gdb-error-begin (instance ignored)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1402 (set-gdb-instance-output-sink instance 'user))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1403
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1404 (defun gdb-display-begin (instance ignored)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1405 (if (gdb-get-instance-buffer instance 'gdb-display-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1406 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1407 (set-gdb-instance-output-sink instance 'emacs)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1408 (gdb-clear-partial-output instance))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1409 (set-gdb-instance-output-sink instance 'user))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1410 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1411
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1412 (defun gdb-display-end (instance ignored)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1413 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1414 (let ((display-output (gdb-get-instance-buffer instance 'gdb-display-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1415 display-index
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1416 display-value
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1417 highlight-expr)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1418 (if display-output
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1419 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1420 (set-buffer (gdb-get-instance-buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1421 instance 'gdb-partial-output-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1422 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1423 (looking-at "\\([0-9]+\\): ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1424 (setq display-index (buffer-substring (match-beginning 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1425 (match-end 1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1426 (setq display-value (+ 2 (match-end 1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1427 (set-buffer display-output)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1428 (if (and mode-motion-extent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1429 (extent-buffer mode-motion-extent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1430 (extent-start-position mode-motion-extent))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1431 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1432 (goto-char (extent-start-position mode-motion-extent))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1433 (if (looking-at "^[0-9]+:")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1434 (setq highlight-expr (buffer-substring (match-beginning 0) (match-end 0))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1435 (setq buffer-read-only nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1436 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1437 (if (not (re-search-forward (concat "^" display-index ": [ny] ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1438 (point-max) 'move))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1439 (insert (format "%s: y " display-index))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1440 (goto-char (match-end 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1441 (if (save-match-data
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1442 (re-search-forward "^[0-9]+: " (point-max) 'move))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1443 (beginning-of-line))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1444 (delete-region (match-end 0) (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1445 (insert-buffer-substring (gdb-get-instance-buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1446 instance 'gdb-partial-output-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1447 display-value)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1448 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1449 (if (and mode-motion-extent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1450 (extent-buffer mode-motion-extent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1451 highlight-expr
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1452 (re-search-forward (concat "^" highlight-expr ".*$") (point-max) t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1453 (set-extent-endpoints mode-motion-extent (match-beginning 0) (match-end 0)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1454 (setq buffer-read-only t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1455 )))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1456 (gdb-clear-partial-output instance)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1457 (set-gdb-instance-output-sink instance 'user)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1458 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1459
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1460
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1461 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1462 ;; Frames buffers. These display a perpetually correct bactracktrace
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1463 ;; (from the command `where').
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1464 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1465 ;; Alas, if your stack is deep, they are costly.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1466 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1467
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1468 (gdb-set-instance-buffer-rules 'gdb-stack-buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1469 'gdb-stack-buffer-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1470 'gud-frames-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1471
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1472 (def-gdb-auto-updated-buffer gdb-stack-buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1473 gdb-invalidate-frames
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1474 "server where\n"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1475 gdb-info-frames-handler)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1476
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1477 (defun gdb-stack-buffer-name (instance)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1478 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1479 (set-buffer (process-buffer (gdb-instance-process instance)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1480 (concat "*stack frames of "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1481 (gdb-instance-target-string instance) "*")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1482
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1483 (defun gud-display-stack-buffer (instance)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1484 (interactive (list (gdb-needed-default-instance)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1485 (gud-display-buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1486 (gdb-get-create-instance-buffer instance
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1487 'gdb-stack-buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1488
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1489 (defun gud-frame-stack-buffer (instance)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1490 (interactive (list (gdb-needed-default-instance)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1491 (gud-display-buffer-new-frame
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1492 (gdb-get-create-instance-buffer instance
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1493 'gdb-stack-buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1494
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1495 (defvar gud-frames-mode-map nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1496 (setq gud-frames-mode-map (make-keymap))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1497 (suppress-keymap gud-frames-mode-map)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1498
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1499 ;;; XEmacs change
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1500 ;(define-key gud-frames-mode-map [mouse-2]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1501 ; 'gud-frames-select-by-mouse)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1502
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1503 (define-key gud-frames-mode-map [button2]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1504 'gud-frames-select-by-mouse)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1505
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1506
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1507 (defun gud-frames-mode ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1508 "Major mode for gud frames.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1509
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1510 \\{gud-frames-mode-map}"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1511 (setq major-mode 'gud-frames-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1512 (setq mode-name "Frames")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1513 (setq buffer-read-only t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1514 (use-local-map gud-frames-mode-map)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1515 (gdb-invalidate-frames gdb-buffer-instance))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1516
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1517 (defun gud-get-frame-number ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1518 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1519 (let* ((pos (re-search-backward "^#\\([0-9]*\\)" nil t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1520 (n (or (and pos
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1521 (string-to-int
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1522 (buffer-substring (match-beginning 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1523 (match-end 1))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1524 0)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1525 n)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1526
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1527 (defun gud-frames-select-by-mouse (e)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1528 (interactive "e")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1529 (let (selection)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1530 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1531 (set-buffer (window-buffer (posn-window (event-end e))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1532 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1533 (goto-char (posn-point (event-end e)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1534 (setq selection (gud-get-frame-number))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1535 (select-window (posn-window (event-end e)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1536 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1537 (set-buffer (gdb-get-instance-buffer (gdb-needed-default-instance) 'gud))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1538 (gud-call "fr %p" selection)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1539 (gud-display-frame))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1540
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1541
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1542 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1543 ;; Registers buffers
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1544 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1545
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1546 (def-gdb-auto-updated-buffer gdb-registers-buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1547 gdb-invalidate-registers
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1548 "server info registers\n"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1549 gdb-info-registers-handler)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1550
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1551 (gdb-set-instance-buffer-rules 'gdb-registers-buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1552 'gdb-registers-buffer-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1553 'gud-registers-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1554
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1555 (defvar gud-registers-mode-map nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1556 (setq gud-registers-mode-map (make-keymap))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1557 (suppress-keymap gud-registers-mode-map)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1558
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1559 (defun gud-registers-mode ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1560 "Major mode for gud registers.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1561
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1562 \\{gud-registers-mode-map}"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1563 (setq major-mode 'gud-registers-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1564 (setq mode-name "Registers")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1565 (setq buffer-read-only t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1566 (use-local-map gud-registers-mode-map)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1567 (gdb-invalidate-registers gdb-buffer-instance))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1568
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1569 (defun gdb-registers-buffer-name (instance)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1570 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1571 (set-buffer (process-buffer (gdb-instance-process instance)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1572 (concat "*registers of " (gdb-instance-target-string instance) "*")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1573
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1574 (defun gud-display-registers-buffer (instance)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1575 (interactive (list (gdb-needed-default-instance)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1576 (gud-display-buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1577 (gdb-get-create-instance-buffer instance
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1578 'gdb-registers-buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1579
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1580 (defun gud-frame-registers-buffer (instance)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1581 (interactive (list (gdb-needed-default-instance)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1582 (gud-display-buffer-new-frame
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1583 (gdb-get-create-instance-buffer instance
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1584 'gdb-registers-buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1585
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1586 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1587 ;; Locals buffers
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1588 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1589
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1590 (def-gdb-auto-updated-buffer gdb-locals-buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1591 gdb-invalidate-locals
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1592 "server info locals\n"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1593 gdb-info-locals-handler)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1594
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1595 (gdb-set-instance-buffer-rules 'gdb-locals-buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1596 'gdb-locals-buffer-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1597 'gud-locals-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1598
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1599 (defvar gud-locals-mode-map nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1600 (setq gud-locals-mode-map (make-keymap))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1601 (suppress-keymap gud-locals-mode-map)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1602
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1603 (defun gud-locals-mode ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1604 "Major mode for gud locals.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1605
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1606 \\{gud-locals-mode-map}"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1607 (setq major-mode 'gud-locals-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1608 (setq mode-name "Locals")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1609 (setq buffer-read-only t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1610 (use-local-map gud-locals-mode-map)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1611 (gdb-invalidate-locals gdb-buffer-instance))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1612
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1613 (defun gdb-locals-buffer-name (instance)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1614 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1615 (set-buffer (process-buffer (gdb-instance-process instance)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1616 (concat "*locals of " (gdb-instance-target-string instance) "*")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1617
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1618 (defun gud-display-locals-buffer (instance)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1619 (interactive (list (gdb-needed-default-instance)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1620 (gud-display-buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1621 (gdb-get-create-instance-buffer instance
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1622 'gdb-locals-buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1623
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1624 (defun gud-frame-locals-buffer (instance)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1625 (interactive (list (gdb-needed-default-instance)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1626 (gud-display-buffer-new-frame
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1627 (gdb-get-create-instance-buffer instance
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1628 'gdb-locals-buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1629
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1630
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1631 ;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1632 ;;;; Put a friendly face on the GDB on-line help.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1633 ;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1634
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1635 ;; Keymap for extents in the help buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1636 (setq gdb-help-extent-map (make-keymap))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1637 (suppress-keymap gdb-help-extent-map)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1638 (define-key gdb-help-extent-map 'button2 'gdb-help-xref)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1639 (define-key gdb-help-extent-map 'button3 'gdb-help-popup-menu)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1640
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1641 ;; Keymap for elsewhere in the help buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1642 (setq gdb-help-map (make-keymap))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1643 (define-key gdb-help-map 'button3 'gdb-help-popup-menu)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1644
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1645 (defvar gud-help-menu
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1646 '("GDB Help Topics"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1647 "----"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1648 ("Classes of GDB Commands"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1649 "----"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1650 ["running" (gdb-help "running") t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1651 ["stack" (gdb-help "stack") t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1652 ["data" (gdb-help "data") t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1653 ["breakpoints" (gdb-help "breakpoints") t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1654 ["files" (gdb-help "files") t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1655 ["status" (gdb-help "status") t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1656 ["support" (gdb-help "support") t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1657 ["user-defined" (gdb-help "user-defined") t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1658 ["aliases" (gdb-help "aliases") t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1659 ["obscure" (gdb-help "obscure") t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1660 ["internals" (gdb-help "internals") t])
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1661 "----"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1662 ("Prefix Commands"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1663 "----"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1664 ["info" (gdb-help "info") t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1665 ["delete" (gdb-help "delete") t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1666 ["disable" (gdb-help "disable") t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1667 ["enable" (gdb-help "enable") t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1668 ["maintenance" (gdb-help "maintenance") t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1669 ["maintenance info" (gdb-help "maintenance info") t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1670 ["maintenance print" (gdb-help "maintenance print") t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1671 ["show" (gdb-help "show") t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1672 ["show check" (gdb-help "show check") t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1673 ["show history" (gdb-help "show history") t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1674 ["show print" (gdb-help "show print") t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1675 ["set" (gdb-help "set") t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1676 ["set check" (gdb-help "set check") t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1677 ["set history" (gdb-help "set history") t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1678 ["set print" (gdb-help "set print") t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1679 ["thread" (gdb-help "thread") t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1680 ["thread apply" (gdb-help "thread apply") t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1681 ["unset" (gdb-help "unset") t])
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1682 ; Only if you build this into gdb
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1683 ; ("Duel"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1684 ; ["summary" (gdb-help "duel help") t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1685 ; ["ops" (gdb-help "duel ops") t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1686 ; ["examples" (gdb-help "duel examples") t])
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1687 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1688 "*menu for gdb-help")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1689
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1690 (defun gdb-help-popup-menu (event)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1691 (interactive "@e")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1692 (mouse-set-point event)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1693 (popup-menu gud-help-menu))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1694
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1695 (defun gdb-help-xref (event)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1696 (interactive "e")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1697 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1698 (set-buffer (get-buffer (gettext "*Debugger Help*")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1699 (let ((extent (extent-at (event-point event))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1700 (gdb-help
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1701 (or (extent-property extent 'back-to)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1702 (buffer-substring (extent-start-position extent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1703 (extent-end-position extent)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1704 gdb-help-topic)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1705 )))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1706
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1707 (defun gdb-help-info ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1708 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1709 (require 'info)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1710 (Info-goto-node "(gdb)Top"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1711
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1712 ;; Format the help page. We lightly edit the GDB output to add instructions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1713 ;; on getting help on listed commands using the mouse rather than typing
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1714 ;; "help" at gdb.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1715 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1716 ;; We're not trying to re-produce Info's or w3's navigational and cross
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1717 ;; referencing here but just to put a simple mouse-driven front end over
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1718 ;; GDB's help.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1719 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1720 ;; The help buffer *ought* to be in gdb-help-mode but we only ever create
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1721 ;; one buffer so just setting a buffer local keymap should be good enough
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1722 ;; for now.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1723
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1724 (defun gdb-format-help-page nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1725 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1726 (display-buffer (set-buffer (get-buffer-create
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1727 (gettext "*Debugger Help*"))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1728 (erase-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1729 (map-extents '(lambda (extent) (delete-extent extent) nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1730 (use-local-map gdb-help-map)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1731 (insert-buffer (gdb-get-instance-buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1732 instance 'gdb-partial-output-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1733 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1734 (forward-line 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1735 (while (re-search-forward "\\(^.*\\) -- .*$" (point-max) t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1736 (let ((extent (make-extent (match-beginning 1) (match-end 1))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1737 (set-extent-property extent 'face (find-face 'bold))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1738 (set-extent-property extent 'highlight t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1739 (set-extent-property extent 'keymap gdb-help-extent-map)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1740 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1741 ;; We use the message at the end of the help to distinguish between
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1742 ;; help on a class of commands, help on a prefix command and help
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1743 ;; on a command.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1744 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1745 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1746 ((looking-at "List of classes of commands:")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1747 ;; It's the list of classes
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1748 (end-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1749 (insert " Click on a highlighted class to see the list of commands
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1750 in that class.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1751 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1752 ((and (not (looking-at "List of classes of commands:"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1753 (re-search-forward "^Type \"help\" followed by command name" (point-max) t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1754 ;; It's help on a specific class
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1755 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1756 (insert "Help on ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1757 (downcase-word 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1758 (end-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1759 (insert " Click on a highlighted command to see the help
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1760 for that command or click ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1761 (setq point (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1762 (insert "here")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1763 (setq extent (make-extent point (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1764 (set-extent-property extent 'back-to "")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1765 (insert " to see the list of classes of commands.\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1766 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1767 ((re-search-forward "^Type \"help.*subcommand" (point-max) t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1768 ;; It's a prefix command
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1769 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1770 (insert (concat "Help on \"" gdb-help-topic "\" - "))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1771 (downcase-word 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1772 (end-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1773 (insert " Click on a highlighted topic to see the help
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1774 for that topic or click ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1775 (setq point (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1776 (insert "here")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1777 (setq extent (make-extent point (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1778 (string-match " ?[^ \t]*$" gdb-help-topic)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1779 (if (equal ""
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1780 (set-extent-property extent 'back-to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1781 (substring gdb-help-topic
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1782 0 (match-beginning 0))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1783 (insert " to see the list of classes of commands.\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1784 (insert (concat " to see the help on " (extent-property extent 'back-to ))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1785 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1786 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1787 ;; Must be an ordinary command
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1788 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1789 (insert (concat "Help on \"" gdb-help-topic "\" - "))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1790 (insert " Click ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1791 (setq point (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1792 (insert "here")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1793 (setq extent (make-extent point (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1794 (if (equal "" (set-extent-property extent 'back-to gdb-previous-help-topic))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1795 (insert " to see the list of classes of commands.\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1796 (insert (concat " to see the help on " (extent-property extent 'back-to ))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1797 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1798 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1799 (and extent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1800 (set-extent-property extent 'face (find-face 'bold))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1801 (set-extent-property extent 'highlight t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1802 (set-extent-property extent 'keymap gdb-help-extent-map))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1803 (setq fill-column 78)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1804 (fill-region (point-min) (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1805 (insert "\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1806 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1807
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1808 (defun gdb-help (topic &optional previous-topic)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1809 (interactive "sGdb Help Topic: ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1810 (let ((instance (gdb-needed-default-instance))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1811 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1812 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1813 (set-buffer (get-buffer-create (gettext "*Debugger Help*")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1814 (make-variable-buffer-local 'gdb-help-topic)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1815 (make-variable-buffer-local 'gdb-previous-help-topic)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1816 (setq gdb-help-topic topic)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1817 (setq gdb-previous-help-topic (or previous-topic "")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1818 (gdb-clear-partial-output instance)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1819 (gdb-instance-enqueue-idle-input
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1820 instance
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1821 (list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1822 (concat
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1823 "server "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1824 (if (string-match "^duel" topic)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1825 ""
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1826 "help ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1827 topic
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1828 "\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1829 'gdb-format-help-page))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1830
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1831 ;;;; Menus and stuff
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1832
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1833 (defun gdb-install-menubar ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1834 "Installs the Gdb menu at the menubar."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1835
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1836 ;; We can't define the menu at load-time because many of the functions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1837 ;; that we will call won't be bound then.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1838 (defvar gdb-menu
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1839 '("GDB Commands"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1840 "----"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1841 ("Help"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1842 ["info" gdb-help-info t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1843 "----"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1844 ["running -- Running the program" (gdb-help "running") t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1845 ["stack -- Examining the stack" (gdb-help "stack") t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1846 ["data -- Examining data" (gdb-help "data") t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1847 ["breakpoints -- Making program stop at certain points" (gdb-help "breakpoints") t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1848 ["files -- Specifying and examining files" (gdb-help "files") t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1849 ["status -- Status inquiries" (gdb-help "status") t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1850 ["support -- Support facilities" (gdb-help "support") t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1851 ["user-defined -- User-defined commands" (gdb-help "user-defined") t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1852 ["aliases -- Aliases of other commands" (gdb-help "aliases") t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1853 ["obscure -- Obscure features" (gdb-help "obscure") t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1854 ["internals -- Maintenance commands" (gdb-help "internals") t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1855 "---"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1856 ; Only if you build this into gdb
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1857 ; ["Duel summary" (gdb-help "duel help") t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1858 ; ["Duel ops" (gdb-help "duel ops") t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1859 ; ["Duel examples" (gdb-help "duel examples") t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1860 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1861 "---"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1862 ("New window showing"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1863 ["Local variables" gud-display-locals-buffer t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1864 ["Displayed expressions" gud-display-display-buffer t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1865 ["Breakpoints" gud-display-breakpoints-buffer t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1866 ["Stack trace" gud-display-stack-buffer t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1867 ["Machine registers" gud-display-registers-buffer t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1868 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1869 ("New frame showing"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1870 ["Local variables" gud-frame-locals-buffer t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1871 ["Displayed expressions" gud-frame-display-buffer t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1872 ["Breakpoints" gud-frame-breakpoints-buffer t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1873 ["Stack trace" gud-frame-stack-buffer t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1874 ["Machine registers" gud-frame-registers-buffer t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1875 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1876 "----"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1877 ["step" gud-step t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1878 ["next" gud-next t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1879 ["finish" gud-finish t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1880 ["continue" gud-cont t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1881 ["run" gud-run t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1882 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1883 "*The menu for GDB mode.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1884 (if (and current-menubar (not (assoc "Gdb" current-menubar)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1885 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1886 (set-buffer-menubar (copy-sequence current-menubar))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1887 (add-menu nil "Gdb" (cdr gdb-menu))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1888 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1889 (add-hook 'gdb-mode-hook 'gdb-install-menubar)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1890
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1891
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1892 (gdb-set-instance-buffer-rules 'gdb-command-buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1893 'gdb-command-buffer-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1894 'gud-command-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1895
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1896 (defvar gud-command-mode-map nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1897 (setq gud-command-mode-map (make-keymap))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1898 (suppress-keymap gud-command-mode-map)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1899 ;;; XEmacs change
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1900 ;(define-key gud-command-mode-map [mouse-2] 'gud-menu-pick)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1901 (define-key gud-command-mode-map [button2] 'gud-menu-pick)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1902
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1903
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1904 (defun gud-command-mode ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1905 "Major mode for gud menu.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1906
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1907 \\{gud-command-mode-map}" (interactive) (setq major-mode 'gud-command-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1908 (setq mode-name "Menu") (setq buffer-read-only t) (use-local-map
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1909 gud-command-mode-map) (make-variable-buffer-local 'gud-menu-position)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1910 (if (not gud-menu-position) (gud-goto-menu gud-running-menu)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1911
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1912 (defun gdb-command-buffer-name (instance)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1913 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1914 (set-buffer (process-buffer (gdb-instance-process instance)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1915 (concat "*menu of " (gdb-instance-target-string instance) "*")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1916
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1917 (defun gud-display-command-buffer (instance)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1918 (interactive (list (gdb-needed-default-instance)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1919 (gud-display-buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1920 (gdb-get-create-instance-buffer instance
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1921 'gdb-command-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1922 6))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1923
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1924 (defun gud-frame-command-buffer (instance)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1925 (interactive (list (gdb-needed-default-instance)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1926 (gud-display-buffer-new-frame
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1927 (gdb-get-create-instance-buffer instance
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1928 'gdb-command-buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1929
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1930
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1931
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1932 (defun gdb-call-showing-gud (instance command)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1933 (gud-display-gud-buffer instance)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1934 (comint-input-sender (gdb-instance-process instance) command))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1935
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1936 (defvar gud-target-history ())
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1937
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1938 (defun gud-temp-buffer-show (buf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1939 (let ((ow (selected-window)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1940 (unwind-protect
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1941 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1942 (pop-to-buffer buf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1943
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1944 ;; This insertion works around a bug in emacs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1945 ;; The bug is that all the empty space after a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1946 ;; highlighted word that terminates a buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1947 ;; gets highlighted. That's really ugly, so
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1948 ;; make sure a highlighted word can't ever
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1949 ;; terminate the buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1950 (goto-char (point-max))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1951 (insert "\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1952 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1953
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1954 (if (< (window-height) 10)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1955 (enlarge-window (- 10 (window-height)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1956 (select-window ow))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1957
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1958 (defun gud-target (instance command)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1959 (interactive
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1960 (let* ((instance (gdb-needed-default-instance))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1961 (temp-buffer-show-function (function gud-temp-buffer-show))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1962 (target-name (completing-read (format "Target type: ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1963 '(("remote")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1964 ("core")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1965 ("child")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1966 ("exec"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1967 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1968 t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1969 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1970 'gud-target-history)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1971 (list instance
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1972 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1973 ((equal target-name "child") "run")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1974
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1975 ((equal target-name "core")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1976 (concat "target core "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1977 (read-file-name "core file: "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1978 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1979 "core"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1980 t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1981
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1982 ((equal target-name "exec")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1983 (concat "target exec "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1984 (read-file-name "exec file: "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1985 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1986 "a.out"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1987 t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1988
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1989 ((equal target-name "remote")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1990 (concat "target remote "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1991 (read-file-name "serial line for remote: "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1992 "/dev/"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1993 "ttya"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1994 t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1995
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1996 (t "echo No such target command!")))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1997
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1998 (gud-display-gud-buffer instance)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1999 (apply comint-input-sender
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2000 (list (gdb-instance-process instance) command)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2001
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2002 (defun gud-backtrace ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2003 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2004 (let ((instance (gdb-needed-default-instance)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2005 (gud-display-gud-buffer instance)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2006 (apply comint-input-sender
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2007 (list (gdb-instance-process instance)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2008 "backtrace"))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2009
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2010 (defun gud-frame ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2011 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2012 (let ((instance (gdb-needed-default-instance)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2013 (apply comint-input-sender
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2014 (list (gdb-instance-process instance)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2015 "frame"))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2016
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2017 (defun gud-return (instance command)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2018 (interactive
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2019 (let ((temp-buffer-show-function (function gud-temp-buffer-show)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2020 (list (gdb-needed-default-instance)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2021 (concat "return " (read-string "Expression to return: ")))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2022 (gud-display-gud-buffer instance)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2023 (apply comint-input-sender
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2024 (list (gdb-instance-process instance) command)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2025
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2026
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2027 (defun gud-file (instance command)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2028 (interactive
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2029 (let ((temp-buffer-show-function (function gud-temp-buffer-show)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2030 (list (gdb-needed-default-instance)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2031 (concat "file " (read-file-name "Executable to debug: "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2032 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2033 "a.out"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2034 t)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2035 (gud-display-gud-buffer instance)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2036 (apply comint-input-sender
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2037 (list (gdb-instance-process instance) command)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2038
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2039 (defun gud-core-file (instance command)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2040 (interactive
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2041 (let ((temp-buffer-show-function (function gud-temp-buffer-show)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2042 (list (gdb-needed-default-instance)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2043 (concat "core " (read-file-name "Core file to debug: "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2044 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2045 "core-file"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2046 t)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2047 (gud-display-gud-buffer instance)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2048 (apply comint-input-sender
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2049 (list (gdb-instance-process instance) command)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2050
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2051 (defun gud-cd (dir)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2052 (interactive "FChange GDB's default directory: ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2053 (let ((instance (gdb-needed-default-instance)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2054 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2055 (set-buffer (gdb-get-instance-buffer instance 'gud))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2056 (cd dir))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2057 (gud-display-gud-buffer instance)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2058 (apply comint-input-sender
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2059 (list (gdb-instance-process instance)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2060 (concat "cd " dir)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2061
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2062
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2063 (defun gud-exec-file (instance command)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2064 (interactive
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2065 (let ((temp-buffer-show-function (function gud-temp-buffer-show)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2066 (list (gdb-needed-default-instance)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2067 (concat "exec-file " (read-file-name "Init memory from executable: "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2068 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2069 "a.out"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2070 t)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2071 (gud-display-gud-buffer instance)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2072 (apply comint-input-sender
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2073 (list (gdb-instance-process instance) command)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2074
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2075 (defun gud-load (instance command)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2076 (interactive
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2077 (let ((temp-buffer-show-function (function gud-temp-buffer-show)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2078 (list (gdb-needed-default-instance)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2079 (concat "load " (read-file-name "Dynamicly load from file: "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2080 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2081 "a.out"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2082 t)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2083 (gud-display-gud-buffer instance)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2084 (apply comint-input-sender
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2085 (list (gdb-instance-process instance) command)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2086
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2087 (defun gud-symbol-file (instance command)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2088 (interactive
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2089 (let ((temp-buffer-show-function (function gud-temp-buffer-show)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2090 (list (gdb-needed-default-instance)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2091 (concat "symbol-file " (read-file-name "Read symbol table from file: "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2092 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2093 "a.out"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2094 t)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2095 (gud-display-gud-buffer instance)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2096 (apply comint-input-sender
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2097 (list (gdb-instance-process instance) command)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2098
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2099
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2100 (defun gud-add-symbol-file (instance command)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2101 (interactive
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2102 (let ((temp-buffer-show-function (function gud-temp-buffer-show)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2103 (list (gdb-needed-default-instance)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2104 (concat "add-symbol-file "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2105 (read-file-name "Add symbols from file: "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2106 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2107 "a.out"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2108 t)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2109 (gud-display-gud-buffer instance)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2110 (apply comint-input-sender
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2111 (list (gdb-instance-process instance) command)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2112
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2113
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2114 (defun gud-sharedlibrary (instance command)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2115 (interactive
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2116 (let ((temp-buffer-show-function (function gud-temp-buffer-show)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2117 (list (gdb-needed-default-instance)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2118 (concat "sharedlibrary "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2119 (read-string "Load symbols for files matching regexp: ")))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2120 (gud-display-gud-buffer instance)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2121 (apply comint-input-sender
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2122 (list (gdb-instance-process instance) command)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2123
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2124
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2125 ;;;; Help
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2126
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2127
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2128
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2129 ;;;; Window management
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2130
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2131
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2132 ;;; FIXME: This should only return true for buffers in the current instance
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2133 (defun gud-protected-buffer-p (buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2134 "Is BUFFER a buffer which we want to leave displayed?"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2135 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2136 (set-buffer buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2137 (or gdb-buffer-type
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2138 overlay-arrow-position)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2139
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2140 ;;; The way we abuse the dedicated-p flag is pretty gross, but seems
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2141 ;;; to do the right thing. Seeing as there is no way for Lisp code to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2142 ;;; get at the use_time field of a window, I'm not sure there exists a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2143 ;;; more elegant solution without writing C code.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2144
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2145 (defun gud-display-buffer (buf &optional size)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2146 (let ((must-split nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2147 (answer nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2148 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2149 (unwind-protect
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2150 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2151 (walk-windows
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2152 '(lambda (win)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2153 (if (gud-protected-buffer-p (window-buffer win))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2154 (set-window-buffer-dedicated win (window-buffer win)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2155 (setq answer (get-buffer-window buf))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2156 (if (not answer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2157 (let ((window (get-lru-window)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2158 (if (not (window-dedicated-p window))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2159 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2160 (set-window-buffer window buf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2161 (setq answer window))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2162 (setq must-split t)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2163 (walk-windows
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2164 '(lambda (win)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2165 (if (gud-protected-buffer-p (window-buffer win))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2166 (set-window-buffer-dedicated win nil)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2167 (if must-split
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2168 (let* ((largest (get-largest-window))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2169 (cur-size (window-height largest))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2170 (new-size (and size (< size cur-size) (- cur-size size))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2171 (setq answer (split-window largest new-size))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2172 (set-window-buffer answer buf)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2173 answer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2174
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2175 (defun existing-source-window (buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2176 (catch 'found
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2177 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2178 (walk-windows
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2179 (function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2180 (lambda (win)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2181 (if (and overlay-arrow-position
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2182 (eq (window-buffer win)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2183 (marker-buffer overlay-arrow-position)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2184 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2185 (set-window-buffer win buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2186 (throw 'found win))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2187 nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2188
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2189 (defun gud-display-source-buffer (buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2190 (or (existing-source-window buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2191 (gud-display-buffer buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2192
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2193 (defun gud-display-buffer-new-frame (buf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2194 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2195 (set-buffer buf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2196 (let* ((buf-height (+ 4 (count-lines (point-min) (point-max))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2197 (frame-params (list (cons 'height buf-height)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2198 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2199 ;; This is a hack so that we can re-size this window to occupy just as
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2200 ;; much space is needed.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2201 (setq truncate-lines t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2202 (set-buffer-dedicated-frame buf (make-frame frame-params)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2203
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2204
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2205
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2206 ;;; Shared keymap initialization:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2207
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2208 (defun gud-display-gud-buffer (instance)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2209 (interactive (list (gdb-needed-default-instance)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2210 (gud-display-buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2211 (gdb-get-create-instance-buffer instance 'gud)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2212
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2213 (defun gud-frame-gud-buffer (instance)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2214 (interactive (list (gdb-needed-default-instance)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2215 (gud-display-buffer-new-frame
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2216 (gdb-get-create-instance-buffer instance 'gud)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2217
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2218
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2219 (defun gud-gdb-find-file (f)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2220 (find-file-noselect f))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2221
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2222 ;;; XEmacs: don't autoload this yet since it's still buggy - use the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2223 ;;; one in gdb.el instead
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2224 (defun gdb (command-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2225 "Run gdb on program FILE in buffer *gud-FILE*.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2226 The directory containing FILE becomes the initial working directory
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2227 and source-file directory for your debugger."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2228 (interactive
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2229 (list (read-shell-command "Run gdb (like this): "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2230 (if (consp gud-gdb-history)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2231 (car gud-gdb-history)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2232 "gdb ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2233 '(gud-gdb-history . 1))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2234 (gud-overload-functions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2235 '((gud-massage-args . gud-gdb-massage-args)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2236 (gud-marker-filter . gud-gdb-marker-filter)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2237 (gud-find-file . gud-gdb-find-file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2238 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2239
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2240 (let* ((words (gud-chop-words command-line))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2241 (program (car words))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2242 (file-word (let ((w (cdr words)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2243 (while (and w (= ?- (aref (car w) 0)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2244 (setq w (cdr w)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2245 (car w)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2246 (args (delq file-word (cdr words)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2247 (file (and file-word (expand-file-name file-word)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2248 (filepart (if file (file-name-nondirectory file) ""))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2249 (buffer-name (concat "*" "gdb"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2250 (and (string< "" filepart)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2251 (concat "-" filepart)) "*")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2252 (setq gdb-first-time (not (get-buffer-process buffer-name))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2253
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2254 (gud-common-init command-line "gdb")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2255
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2256 (gud-def gud-break "break %f:%l" "\C-b" "Set breakpoint at current line.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2257 (gud-def gud-tbreak "tbreak %f:%l" "\C-t" "Set breakpoint at current line.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2258 (gud-def gud-remove "clear %l" "\C-d" "Remove breakpoint at current line")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2259 (gud-def gud-kill "kill" nil "Kill the program.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2260 (gud-def gud-run "run" nil "Run the program.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2261 (gud-def gud-stepi "stepi %p" "\C-i" "Step one instruction with display.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2262 (gud-def gud-step "step %p" "\C-s" "Step one source line with display.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2263 (gud-def gud-next "next %p" "\C-n" "Step one line (skip functions).")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2264 (gud-def gud-finish "finish" "\C-f" "Finish executing current function.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2265 (gud-def gud-cont "cont" "\C-r" "Continue with display.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2266 (gud-def gud-up "up %p" "<" "Up N stack frames (numeric arg).")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2267 (gud-def gud-down "down %p" ">" "Down N stack frames (numeric arg).")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2268 (gud-def gud-print "print %e" "\C-p" "Evaluate C expression at point.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2269
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2270 (setq comint-prompt-regexp "^(.*gdb[+]?) *")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2271 (setq comint-input-sender 'gdb-send)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2272 (run-hooks 'gdb-mode-hook)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2273 (let ((instance
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2274 (make-gdb-instance (get-buffer-process (current-buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2275 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2276 (if gdb-first-time (gdb-clear-inferior-io instance)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2277 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2278
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2279
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2280 ;; ======================================================================
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2281 ;; sdb functions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2282
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2283 ;;; History of argument lists passed to sdb.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2284 (defvar gud-sdb-history nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2285
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2286 (defvar gud-sdb-needs-tags (not (file-exists-p "/var"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2287 "If nil, we're on a System V Release 4 and don't need the tags hack.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2288
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2289 (defvar gud-sdb-lastfile nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2290
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2291 (defun gud-sdb-massage-args (file args)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2292 (cons file args))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2293
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2294 (defun gud-sdb-marker-filter (string)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2295 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2296 ;; System V Release 3.2 uses this format
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2297 ((string-match "\\(^0x\\w* in \\|^\\|\n\\)\\([^:\n]*\\):\\([0-9]*\\):.*\n"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2298 string)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2299 (setq gud-last-frame
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2300 (cons
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2301 (substring string (match-beginning 2) (match-end 2))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2302 (string-to-int
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2303 (substring string (match-beginning 3) (match-end 3))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2304 ;; System V Release 4.0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2305 ((string-match "^\\(BREAKPOINT\\|STEPPED\\) process [0-9]+ function [^ ]+ in \\(.+\\)\n"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2306 string)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2307 (setq gud-sdb-lastfile
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2308 (substring string (match-beginning 2) (match-end 2))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2309 ((and gud-sdb-lastfile (string-match "^\\([0-9]+\\):" string))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2310 (setq gud-last-frame
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2311 (cons
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2312 gud-sdb-lastfile
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2313 (string-to-int
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2314 (substring string (match-beginning 1) (match-end 1))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2315 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2316 (setq gud-sdb-lastfile nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2317 string)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2318
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2319 (defun gud-sdb-find-file (f)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2320 (if gud-sdb-needs-tags
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2321 (find-tag-noselect f)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2322 (find-file-noselect f)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2323
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2324 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2325 (defun sdb (command-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2326 "Run sdb on program FILE in buffer *gud-FILE*.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2327 The directory containing FILE becomes the initial working directory
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2328 and source-file directory for your debugger."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2329 (interactive
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2330 (list (read-from-minibuffer "Run sdb (like this): "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2331 (if (consp gud-sdb-history)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2332 (car gud-sdb-history)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2333 "sdb ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2334 nil nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2335 '(gud-sdb-history . 1))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2336 (if (and gud-sdb-needs-tags
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2337 (not (and (boundp 'tags-file-name) (file-exists-p tags-file-name))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2338 (error "The sdb support requires a valid tags table to work."))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2339 (gud-overload-functions '((gud-massage-args . gud-sdb-massage-args)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2340 (gud-marker-filter . gud-sdb-marker-filter)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2341 (gud-find-file . gud-sdb-find-file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2342 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2343
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2344 (gud-common-init command-line "sdb")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2345
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2346 (gud-def gud-break "%l b" "\C-b" "Set breakpoint at current line.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2347 (gud-def gud-tbreak "%l c" "\C-t" "Set temporary breakpoint at current line.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2348 (gud-def gud-remove "%l d" "\C-d" "Remove breakpoint at current line")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2349 (gud-def gud-step "s %p" "\C-s" "Step one source line with display.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2350 (gud-def gud-stepi "i %p" "\C-i" "Step one instruction with display.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2351 (gud-def gud-next "S %p" "\C-n" "Step one line (skip functions).")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2352 (gud-def gud-cont "c" "\C-r" "Continue with display.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2353 (gud-def gud-print "%e/" "\C-p" "Evaluate C expression at point.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2354
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2355 (setq comint-prompt-regexp "\\(^\\|\n\\)\\*")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2356 (run-hooks 'sdb-mode-hook)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2357 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2358
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2359 ;; ======================================================================
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2360 ;; dbx functions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2361
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2362 ;;; History of argument lists passed to dbx.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2363 (defvar gud-dbx-history nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2364
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2365 (defun gud-dbx-massage-args (file args)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2366 (cons file args))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2367
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2368 (defun gud-dbx-marker-filter (string)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2369 (if (or (string-match
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2370 "stopped in .* at line \\([0-9]*\\) in file \"\\([^\"]*\\)\""
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2371 string)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2372 (string-match
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2373 "signal .* in .* at line \\([0-9]*\\) in file \"\\([^\"]*\\)\""
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2374 string))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2375 (setq gud-last-frame
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2376 (cons
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2377 (substring string (match-beginning 2) (match-end 2))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2378 (string-to-int
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2379 (substring string (match-beginning 1) (match-end 1))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2380 string)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2381
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2382 (defun gud-dbx-find-file (f)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2383 (find-file-noselect f))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2384
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2385 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2386 (defun dbx (command-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2387 "Run dbx on program FILE in buffer *gud-FILE*.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2388 The directory containing FILE becomes the initial working directory
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2389 and source-file directory for your debugger."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2390 (interactive
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2391 (list (read-from-minibuffer "Run dbx (like this): "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2392 (if (consp gud-dbx-history)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2393 (car gud-dbx-history)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2394 "dbx ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2395 nil nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2396 '(gud-dbx-history . 1))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2397 (gud-overload-functions '((gud-massage-args . gud-dbx-massage-args)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2398 (gud-marker-filter . gud-dbx-marker-filter)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2399 (gud-find-file . gud-dbx-find-file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2400 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2401
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2402 (gud-common-init command-line "dbx")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2403
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2404 (gud-def gud-break "file \"%d%f\"\nstop at %l"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2405 "\C-b" "Set breakpoint at current line.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2406 ;; (gud-def gud-break "stop at \"%f\":%l"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2407 ;; "\C-b" "Set breakpoint at current line.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2408 (gud-def gud-remove "clear %l" "\C-d" "Remove breakpoint at current line")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2409 (gud-def gud-step "step %p" "\C-s" "Step one line with display.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2410 (gud-def gud-stepi "stepi %p" "\C-i" "Step one instruction with display.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2411 (gud-def gud-next "next %p" "\C-n" "Step one line (skip functions).")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2412 (gud-def gud-cont "cont" "\C-r" "Continue with display.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2413 (gud-def gud-up "up %p" "<" "Up (numeric arg) stack frames.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2414 (gud-def gud-down "down %p" ">" "Down (numeric arg) stack frames.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2415 (gud-def gud-print "print %e" "\C-p" "Evaluate C expression at point.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2416
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2417 (setq comint-prompt-regexp "^[^)]*dbx) *")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2418 (run-hooks 'dbx-mode-hook)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2419 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2420
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2421 ;; ======================================================================
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2422 ;; xdb (HP PARISC debugger) functions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2423
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2424 ;;; History of argument lists passed to xdb.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2425 (defvar gud-xdb-history nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2426
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2427 (defvar gud-xdb-directories nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2428 "*A list of directories that xdb should search for source code.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2429 If nil, only source files in the program directory
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2430 will be known to xdb.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2431
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2432 The file names should be absolute, or relative to the directory
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2433 containing the executable being debugged.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2434
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2435 (defun gud-xdb-massage-args (file args)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2436 (nconc (let ((directories gud-xdb-directories)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2437 (result nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2438 (while directories
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2439 (setq result (cons (car directories) (cons "-d" result)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2440 (setq directories (cdr directories)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2441 (nreverse (cons file result)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2442 args))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2443
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2444 (defun gud-xdb-file-name (f)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2445 "Transform a relative pathname to a full pathname in xdb mode"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2446 (let ((result nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2447 (if (file-exists-p f)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2448 (setq result (expand-file-name f))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2449 (let ((directories gud-xdb-directories))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2450 (while directories
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2451 (let ((path (concat (car directories) "/" f)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2452 (if (file-exists-p path)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2453 (setq result (expand-file-name path)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2454 directories nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2455 (setq directories (cdr directories)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2456 result))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2457
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2458 ;; xdb does not print the lines all at once, so we have to accumulate them
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2459 (defvar gud-xdb-accumulation "")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2460
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2461 (defun gud-xdb-marker-filter (string)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2462 (let (result)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2463 (if (or (string-match comint-prompt-regexp string)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2464 (string-match ".*\012" string))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2465 (setq result (concat gud-xdb-accumulation string)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2466 gud-xdb-accumulation "")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2467 (setq gud-xdb-accumulation (concat gud-xdb-accumulation string)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2468 (if result
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2469 (if (or (string-match "\\([^\n \t:]+\\): [^:]+: \\([0-9]+\\):" result)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2470 (string-match "[^: \t]+:[ \t]+\\([^:]+\\): [^:]+: \\([0-9]+\\):"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2471 result))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2472 (let ((line (string-to-int
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2473 (substring result (match-beginning 2) (match-end 2))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2474 (file (gud-xdb-file-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2475 (substring result (match-beginning 1) (match-end 1)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2476 (if file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2477 (setq gud-last-frame (cons file line))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2478 (or result "")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2479
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2480 (defun gud-xdb-find-file (f)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2481 (let ((realf (gud-xdb-file-name f)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2482 (if realf (find-file-noselect realf))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2483
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2484 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2485 (defun xdb (command-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2486 "Run xdb on program FILE in buffer *gud-FILE*.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2487 The directory containing FILE becomes the initial working directory
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2488 and source-file directory for your debugger.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2489
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2490 You can set the variable 'gud-xdb-directories' to a list of program source
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2491 directories if your program contains sources from more than one directory."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2492 (interactive
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2493 (list (read-from-minibuffer "Run xdb (like this): "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2494 (if (consp gud-xdb-history)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2495 (car gud-xdb-history)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2496 "xdb ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2497 nil nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2498 '(gud-xdb-history . 1))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2499 (gud-overload-functions '((gud-massage-args . gud-xdb-massage-args)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2500 (gud-marker-filter . gud-xdb-marker-filter)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2501 (gud-find-file . gud-xdb-find-file)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2502
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2503 (gud-common-init command-line "xdb")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2504
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2505 (gud-def gud-break "b %f:%l" "\C-b" "Set breakpoint at current line.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2506 (gud-def gud-tbreak "b %f:%l\\t" "\C-t"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2507 "Set temporary breakpoint at current line.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2508 (gud-def gud-remove "db" "\C-d" "Remove breakpoint at current line")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2509 (gud-def gud-step "s %p" "\C-s" "Step one line with display.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2510 (gud-def gud-next "S %p" "\C-n" "Step one line (skip functions).")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2511 (gud-def gud-cont "c" "\C-r" "Continue with display.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2512 (gud-def gud-up "up %p" "<" "Up (numeric arg) stack frames.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2513 (gud-def gud-down "down %p" ">" "Down (numeric arg) stack frames.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2514 (gud-def gud-finish "bu\\t" "\C-f" "Finish executing current function.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2515 (gud-def gud-print "p %e" "\C-p" "Evaluate C expression at point.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2516
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2517 (setq comint-prompt-regexp "^>")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2518 (make-local-variable 'gud-xdb-accumulation)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2519 (setq gud-xdb-accumulation "")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2520 (run-hooks 'xdb-mode-hook))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2521
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2522 ;; ======================================================================
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2523 ;; perldb functions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2524
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2525 ;;; History of argument lists passed to perldb.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2526 (defvar gud-perldb-history nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2527
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2528 (defun gud-perldb-massage-args (file args)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2529 (cons "-d" (cons file (cons "-emacs" args))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2530
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2531 ;; There's no guarantee that Emacs will hand the filter the entire
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2532 ;; marker at once; it could be broken up across several strings. We
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2533 ;; might even receive a big chunk with several markers in it. If we
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2534 ;; receive a chunk of text which looks like it might contain the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2535 ;; beginning of a marker, we save it here between calls to the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2536 ;; filter.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2537 (defvar gud-perldb-marker-acc "")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2538
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2539 (defun gud-perldb-marker-filter (string)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2540 (save-match-data
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2541 (setq gud-perldb-marker-acc (concat gud-perldb-marker-acc string))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2542 (let ((output ""))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2543
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2544 ;; Process all the complete markers in this chunk.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2545 (while (string-match "^\032\032\\([^:\n]*\\):\\([0-9]*\\):.*\n"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2546 gud-perldb-marker-acc)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2547 (setq
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2548
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2549 ;; Extract the frame position from the marker.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2550 gud-last-frame
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2551 (cons (substring gud-perldb-marker-acc (match-beginning 1) (match-end 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2552 (string-to-int (substring gud-perldb-marker-acc
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2553 (match-beginning 2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2554 (match-end 2))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2555
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2556 ;; Append any text before the marker to the output we're going
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2557 ;; to return - we don't include the marker in this text.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2558 output (concat output
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2559 (substring gud-perldb-marker-acc 0 (match-beginning 0)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2560
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2561 ;; Set the accumulator to the remaining text.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2562 gud-perldb-marker-acc (substring gud-perldb-marker-acc (match-end 0))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2563
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2564 ;; Does the remaining text look like it might end with the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2565 ;; beginning of another marker? If it does, then keep it in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2566 ;; gud-perldb-marker-acc until we receive the rest of it. Since we
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2567 ;; know the full marker regexp above failed, it's pretty simple to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2568 ;; test for marker starts.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2569 (if (string-match "^\032.*\\'" gud-perldb-marker-acc)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2570 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2571 ;; Everything before the potential marker start can be output.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2572 (setq output (concat output (substring gud-perldb-marker-acc
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2573 0 (match-beginning 0))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2574
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2575 ;; Everything after, we save, to combine with later input.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2576 (setq gud-perldb-marker-acc
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2577 (substring gud-perldb-marker-acc (match-beginning 0))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2578
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2579 (setq output (concat output gud-perldb-marker-acc)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2580 gud-perldb-marker-acc ""))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2581
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2582 output)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2583
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2584 (defun gud-perldb-find-file (f)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2585 (find-file-noselect f))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2586
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2587 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2588 (defun perldb (command-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2589 "Run perldb on program FILE in buffer *gud-FILE*.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2590 The directory containing FILE becomes the initial working directory
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2591 and source-file directory for your debugger."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2592 (interactive
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2593 (list (read-from-minibuffer "Run perldb (like this): "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2594 (if (consp gud-perldb-history)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2595 (car gud-perldb-history)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2596 "perl ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2597 nil nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2598 '(gud-perldb-history . 1))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2599 (gud-overload-functions '((gud-massage-args . gud-perldb-massage-args)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2600 (gud-marker-filter . gud-perldb-marker-filter)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2601 (gud-find-file . gud-perldb-find-file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2602 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2603
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2604 (gud-common-init command-line "perldb")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2605
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2606 (gud-def gud-break "b %l" "\C-b" "Set breakpoint at current line.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2607 (gud-def gud-remove "d %l" "\C-d" "Remove breakpoint at current line")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2608 (gud-def gud-step "s" "\C-s" "Step one source line with display.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2609 (gud-def gud-next "n" "\C-n" "Step one line (skip functions).")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2610 (gud-def gud-cont "c" "\C-r" "Continue with display.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2611 ; (gud-def gud-finish "finish" "\C-f" "Finish executing current function.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2612 ; (gud-def gud-up "up %p" "<" "Up N stack frames (numeric arg).")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2613 ; (gud-def gud-down "down %p" ">" "Down N stack frames (numeric arg).")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2614 (gud-def gud-print "%e" "\C-p" "Evaluate perl expression at point.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2615
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2616 (setq comint-prompt-regexp "^ DB<[0-9]+> ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2617 (run-hooks 'perldb-mode-hook)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2618 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2619
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2620 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2621 ;; End of debugger-specific information
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2622 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2623
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2624
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2625 ;;; When we send a command to the debugger via gud-call, it's annoying
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2626 ;;; to see the command and the new prompt inserted into the debugger's
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2627 ;;; buffer; we have other ways of knowing the command has completed.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2628 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2629 ;;; If the buffer looks like this:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2630 ;;; --------------------
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2631 ;;; (gdb) set args foo bar
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2632 ;;; (gdb) -!-
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2633 ;;; --------------------
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2634 ;;; (the -!- marks the location of point), and we type `C-x SPC' in a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2635 ;;; source file to set a breakpoint, we want the buffer to end up like
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2636 ;;; this:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2637 ;;; --------------------
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2638 ;;; (gdb) set args foo bar
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2639 ;;; Breakpoint 1 at 0x92: file make-docfile.c, line 49.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2640 ;;; (gdb) -!-
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2641 ;;; --------------------
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2642 ;;; Essentially, the old prompt is deleted, and the command's output
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2643 ;;; and the new prompt take its place.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2644 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2645 ;;; Not echoing the command is easy enough; you send it directly using
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2646 ;;; comint-input-sender, and it never enters the buffer. However,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2647 ;;; getting rid of the old prompt is trickier; you don't want to do it
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2648 ;;; when you send the command, since that will result in an annoying
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2649 ;;; flicker as the prompt is deleted, redisplay occurs while Emacs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2650 ;;; waits for a response from the debugger, and the new prompt is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2651 ;;; inserted. Instead, we'll wait until we actually get some output
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2652 ;;; from the subprocess before we delete the prompt. If the command
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2653 ;;; produced no output other than a new prompt, that prompt will most
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2654 ;;; likely be in the first chunk of output received, so we will delete
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2655 ;;; the prompt and then replace it with an identical one. If the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2656 ;;; command produces output, the prompt is moving anyway, so the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2657 ;;; flicker won't be annoying.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2658 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2659 ;;; So - when we want to delete the prompt upon receipt of the next
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2660 ;;; chunk of debugger output, we position gud-delete-prompt-marker at
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2661 ;;; the start of the prompt; the process filter will notice this, and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2662 ;;; delete all text between it and the process output marker. If
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2663 ;;; gud-delete-prompt-marker points nowhere, we leave the current
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2664 ;;; prompt alone.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2665 (defvar gud-delete-prompt-marker nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2666
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2667
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2668 (defvar gdbish-comint-mode-map (copy-keymap comint-mode-map))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2669 (define-key gdbish-comint-mode-map "\C-c\M-\C-r" 'gud-display-registers-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2670 (define-key gdbish-comint-mode-map "\C-c\M-\C-f" 'gud-display-stack-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2671 (define-key gdbish-comint-mode-map "\C-c\M-\C-b" 'gud-display-breakpoints-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2672
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2673 (defun gud-mode ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2674 "Major mode for interacting with an inferior debugger process.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2675
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2676 You start it up with one of the commands M-x gdb, M-x sdb, M-x dbx,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2677 or M-x xdb. Each entry point finishes by executing a hook; `gdb-mode-hook',
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2678 `sdb-mode-hook', `dbx-mode-hook' or `xdb-mode-hook' respectively.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2679
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2680 After startup, the following commands are available in both the GUD
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2681 interaction buffer and any source buffer GUD visits due to a breakpoint stop
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2682 or step operation:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2683
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2684 \\[gud-break] sets a breakpoint at the current file and line. In the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2685 GUD buffer, the current file and line are those of the last breakpoint or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2686 step. In a source buffer, they are the buffer's file and current line.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2687
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2688 \\[gud-remove] removes breakpoints on the current file and line.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2689
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2690 \\[gud-refresh] displays in the source window the last line referred to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2691 in the gud buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2692
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2693 \\[gud-step], \\[gud-next], and \\[gud-stepi] do a step-one-line,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2694 step-one-line (not entering function calls), and step-one-instruction
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2695 and then update the source window with the current file and position.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2696 \\[gud-cont] continues execution.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2697
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2698 \\[gud-print] tries to find the largest C lvalue or function-call expression
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2699 around point, and sends it to the debugger for value display.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2700
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2701 The above commands are common to all supported debuggers except xdb which
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2702 does not support stepping instructions.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2703
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2704 Under gdb, sdb and xdb, \\[gud-tbreak] behaves exactly like \\[gud-break],
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2705 except that the breakpoint is temporary; that is, it is removed when
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2706 execution stops on it.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2707
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2708 Under gdb, dbx, and xdb, \\[gud-up] pops up through an enclosing stack
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2709 frame. \\[gud-down] drops back down through one.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2710
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2711 If you are using gdb or xdb, \\[gud-finish] runs execution to the return from
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2712 the current function and stops.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2713
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2714 All the keystrokes above are accessible in the GUD buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2715 with the prefix C-c, and in all buffers through the prefix C-x C-a.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2716
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2717 All pre-defined functions for which the concept make sense repeat
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2718 themselves the appropriate number of times if you give a prefix
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2719 argument.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2720
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2721 You may use the `gud-def' macro in the initialization hook to define other
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2722 commands.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2723
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2724 Other commands for interacting with the debugger process are inherited from
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2725 comint mode, which see."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2726 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2727 (comint-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2728 (setq major-mode 'gud-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2729 (setq mode-name "Debugger")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2730 (setq mode-line-process '(": %s"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2731 (use-local-map (copy-keymap gdbish-comint-mode-map))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2732 (setq gud-last-frame nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2733 (make-local-variable 'comint-prompt-regexp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2734 (make-local-variable 'gud-delete-prompt-marker)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2735 (setq gud-delete-prompt-marker (make-marker))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2736 (run-hooks 'gud-mode-hook)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2737 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2738
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2739 (defvar gud-comint-buffer nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2740
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2741 ;; Chop STRING into words separated by SPC or TAB and return a list of them.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2742 (defun gud-chop-words (string)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2743 (let ((i 0) (beg 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2744 (len (length string))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2745 (words nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2746 (while (< i len)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2747 (if (memq (aref string i) '(?\t ? ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2748 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2749 (setq words (cons (substring string beg i) words)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2750 beg (1+ i))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2751 (while (and (< beg len) (memq (aref string beg) '(?\t ? )))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2752 (setq beg (1+ beg)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2753 (setq i (1+ beg)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2754 (setq i (1+ i))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2755 (if (< beg len)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2756 (setq words (cons (substring string beg) words)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2757 (nreverse words)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2758
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2759 (defvar gud-target-name "--unknown--"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2760 "The apparent name of the program being debugged in a gud buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2761 For sure this the root string used in smashing together the gud
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2762 buffer's name, even if that doesn't happen to be the name of a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2763 program.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2764
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2765 ;; Perform initializations common to all debuggers.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2766 (defun gud-common-init (command-line debugger-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2767 (let* ((words (gud-chop-words command-line))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2768 (program (car words))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2769 (file-word (let ((w (cdr words)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2770 (while (and w (= ?- (aref (car w) 0)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2771 (setq w (cdr w)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2772 (car w)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2773 (args (delq file-word (cdr words)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2774 (file (and file-word (expand-file-name file-word)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2775 (filepart (if file (file-name-nondirectory file) ""))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2776 (buffer-name (concat "*" debugger-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2777 (and (string< "" filepart)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2778 (concat "-" filepart)) "*")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2779 (switch-to-buffer buffer-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2780 (if file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2781 (setq default-directory (file-name-directory file)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2782 (or (bolp) (newline))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2783 (insert "Current directory is " default-directory "\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2784 (let ((old-instance gdb-buffer-instance))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2785 (apply 'make-comint (concat debugger-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2786 (and (string< "" filepart)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2787 (concat "-" filepart)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2788 program nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2789 ;; There *has* to be an easier way to strip "nil"s from the output
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2790 ;; of gud-massage-args
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2791 (apply 'append (mapcar '(lambda (arg) (if (stringp arg) (list arg) arg))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2792 (gud-massage-args file args))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2793 (gud-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2794 (make-variable-buffer-local 'old-gdb-buffer-instance)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2795 (setq old-gdb-buffer-instance old-instance))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2796 (make-variable-buffer-local 'gud-target-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2797 (setq gud-target-name filepart))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2798 (set-process-filter (get-buffer-process (current-buffer)) 'gud-filter)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2799 (set-process-sentinel (get-buffer-process (current-buffer)) 'gud-sentinel)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2800 (gud-set-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2801 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2802
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2803 (defun gud-set-buffer ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2804 (cond ((eq major-mode 'gud-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2805 (setq gud-comint-buffer (current-buffer)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2806
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2807 ;; These functions are responsible for inserting output from your debugger
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2808 ;; into the buffer. The hard work is done by the method that is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2809 ;; the value of gud-marker-filter.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2810
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2811 (defun gud-filter (proc string)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2812 ;; Here's where the actual buffer insertion is done
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2813 (let ((inhibit-quit t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2814 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2815 (set-buffer (process-buffer proc))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2816 (let (moving output-after-point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2817 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2818 (goto-char (process-mark proc))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2819 ;; If we have been so requested, delete the debugger prompt.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2820 (if (marker-buffer gud-delete-prompt-marker)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2821 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2822 (delete-region (point) gud-delete-prompt-marker)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2823 (set-marker gud-delete-prompt-marker nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2824 (insert-before-markers (gud-marker-filter string))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2825 (setq moving (= (point) (process-mark proc)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2826 (setq output-after-point (< (point) (process-mark proc)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2827 ;; Check for a filename-and-line number.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2828 ;; Don't display the specified file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2829 ;; unless (1) point is at or after the position where output appears
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2830 ;; and (2) this buffer is on the screen.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2831 (if (and gud-last-frame
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2832 (not output-after-point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2833 (get-buffer-window (current-buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2834 (gud-display-frame)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2835 (if moving (goto-char (process-mark proc)))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2836
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2837 (defun gud-proc-died (proc)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2838 ;; Stop displaying an arrow in a source file.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2839 (setq overlay-arrow-position nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2840
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2841 ;; Kill the dummy process, so that C-x C-c won't worry about it.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2842 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2843 (set-buffer (process-buffer proc))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2844 (let ((buf (gdb-get-instance-buffer gdb-buffer-instance
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2845 'gdb-inferior-io)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2846 (if buf
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2847 (kill-process (get-buffer-process buf)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2848 )))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2849
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2850 (defun gud-sentinel (proc msg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2851 (cond ((null (buffer-name (process-buffer proc)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2852 ;; buffer killed
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2853 (gud-proc-died proc)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2854 (set-process-buffer proc nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2855 ((memq (process-status proc) '(signal exit))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2856 (gud-proc-died proc)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2857
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2858 ;; Fix the mode line.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2859 (setq mode-line-process
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2860 (concat ": "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2861 (symbol-name (process-status proc))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2862 (let* ((obuf (current-buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2863 ;; save-excursion isn't the right thing if
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2864 ;; process-buffer is current-buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2865 (unwind-protect
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2866 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2867 ;; Write something in *compilation* and hack its mode line,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2868 (set-buffer (process-buffer proc))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2869 ;; Force mode line redisplay soon
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2870 (set-buffer-modified-p (buffer-modified-p))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2871 (if (eobp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2872 (insert ?\n mode-name " " msg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2873 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2874 (goto-char (point-max))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2875 (insert ?\n mode-name " " msg)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2876 ;; If buffer and mode line will show that the process
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2877 ;; is dead, we can delete it now. Otherwise it
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2878 ;; will stay around until M-x list-processes.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2879 (delete-process proc))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2880 ;; Restore old buffer, but don't restore old point
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2881 ;; if obuf is the gud buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2882 (set-buffer obuf))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2883
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2884 (defun gud-display-frame ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2885 "Find and obey the last filename-and-line marker from the debugger.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2886 Obeying it means displaying in another window the specified file and line."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2887 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2888 (if gud-last-frame
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2889 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2890 ; (gud-set-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2891 (gud-display-line (car gud-last-frame) (cdr gud-last-frame))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2892 (setq gud-last-last-frame gud-last-frame
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2893 gud-last-frame nil))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2894
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2895 ;; Make sure the file named TRUE-FILE is in a buffer that appears on the screen
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2896 ;; and that its line LINE is visible.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2897 ;; Put the overlay-arrow on the line LINE in that buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2898 ;; Most of the trickiness in here comes from wanting to preserve the current
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2899 ;; region-restriction if that's possible. We use an explicit display-buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2900 ;; to get around the fact that this is called inside a save-excursion.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2901
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2902 (defun gud-display-line (true-file line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2903 (let* ((buffer (gud-find-file true-file))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2904 (window (gud-display-source-buffer buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2905 (pos))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2906 (if (not window)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2907 (error "foo bar baz"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2908 ;;; (if (equal buffer (current-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2909 ;;; nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2910 ;;; (setq buffer-read-only nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2911 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2912 ;;; (setq buffer-read-only t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2913 (set-buffer buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2914 (save-restriction
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2915 (widen)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2916 (goto-line line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2917 (setq pos (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2918 (setq overlay-arrow-string "=>")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2919 (or overlay-arrow-position
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2920 (setq overlay-arrow-position (make-marker)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2921 (set-marker overlay-arrow-position (point) (current-buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2922 (cond ((or (< pos (point-min)) (> pos (point-max)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2923 (widen)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2924 (goto-char pos))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2925 (set-window-point window overlay-arrow-position)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2926
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2927 ;;; The gud-call function must do the right thing whether its invoking
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2928 ;;; keystroke is from the GUD buffer itself (via major-mode binding)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2929 ;;; or a C buffer. In the former case, we want to supply data from
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2930 ;;; gud-last-frame. Here's how we do it:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2931
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2932 (defun gud-format-command (str arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2933 (let ((insource (not (eq (current-buffer) gud-comint-buffer))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2934 (if (string-match "\\(.*\\)%f\\(.*\\)" str)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2935 (setq str (concat
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2936 (substring str (match-beginning 1) (match-end 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2937 (file-name-nondirectory (if insource
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2938 (buffer-file-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2939 (car gud-last-frame)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2940 (substring str (match-beginning 2) (match-end 2)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2941 (if (string-match "\\(.*\\)%d\\(.*\\)" str)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2942 (setq str (concat
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2943 (substring str (match-beginning 1) (match-end 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2944 (file-name-directory (if insource
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2945 (buffer-file-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2946 (car gud-last-frame)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2947 (substring str (match-beginning 2) (match-end 2)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2948 (if (string-match "\\(.*\\)%l\\(.*\\)" str)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2949 (setq str (concat
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2950 (substring str (match-beginning 1) (match-end 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2951 (if insource
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2952 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2953 (beginning-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2954 (save-restriction (widen)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2955 (1+ (count-lines 1 (point)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2956 (cdr gud-last-frame))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2957 (substring str (match-beginning 2) (match-end 2)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2958 (if (string-match "\\(.*\\)%e\\(.*\\)" str)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2959 (setq str (concat
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2960 (substring str (match-beginning 1) (match-end 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2961 (find-c-expr)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2962 (substring str (match-beginning 2) (match-end 2)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2963 (if (string-match "\\(.*\\)%a\\(.*\\)" str)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2964 (setq str (concat
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2965 (substring str (match-beginning 1) (match-end 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2966 (gud-read-address)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2967 (substring str (match-beginning 2) (match-end 2)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2968 (if (string-match "\\(.*\\)%p\\(.*\\)" str)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2969 (setq str (concat
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2970 (substring str (match-beginning 1) (match-end 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2971 (if arg (int-to-string arg) "")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2972 (substring str (match-beginning 2) (match-end 2)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2973 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2974 str
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2975 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2976
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2977 (defun gud-read-address ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2978 "Return a string containing the core-address found in the buffer at point."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2979 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2980 (let ((pt (point)) found begin)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2981 (setq found (if (search-backward "0x" (- pt 7) t) (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2982 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2983 (found (forward-char 2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2984 (buffer-substring found
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2985 (progn (re-search-forward "[^0-9a-f]")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2986 (forward-char -1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2987 (point))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2988 (t (setq begin (progn (re-search-backward "[^0-9]")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2989 (forward-char 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2990 (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2991 (forward-char 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2992 (re-search-forward "[^0-9]")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2993 (forward-char -1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2994 (buffer-substring begin (point)))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2995
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2996 (defun gud-call (fmt &optional arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2997 (let ((msg (gud-format-command fmt arg)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2998 (message "Command: %s" msg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2999 (sit-for 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3000 (gud-basic-call msg)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3001
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3002 (defun gud-basic-call (command)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3003 "Invoke the debugger COMMAND displaying source in other window."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3004 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3005 (gud-set-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3006 (let ((proc (get-buffer-process gud-comint-buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3007
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3008 ;; Arrange for the current prompt to get deleted.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3009 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3010 (set-buffer gud-comint-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3011 (goto-char (process-mark proc))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3012 (beginning-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3013 (if (looking-at comint-prompt-regexp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3014 (set-marker gud-delete-prompt-marker (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3015 (apply comint-input-sender (list proc command)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3016
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3017 (defun gud-refresh (&optional arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3018 "Fix up a possibly garbled display, and redraw the arrow."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3019 (interactive "P")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3020 (recenter arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3021 (or gud-last-frame (setq gud-last-frame gud-last-last-frame))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3022 (gud-display-frame))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3023
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3024 ;;; Count windows on a given frame
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3025 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3026 (defun count-frame-windows (frame &optional minibuf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3027 "Returns the number of visible windows on FRAME.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3028 Optional arg NO-MINI non-nil means don't count the minibuffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3029 even if it is active."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3030 (let ((count 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3031 (walk-windows (function (lambda (w)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3032 (if (eq (window-frame w) frame)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3033 (setq count (+ count 1)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3034 minibuf t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3035 count))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3036
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3037
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3038 ;; Attempt to fit a frame so that it is just large enough to display buf
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3039 ;; Only changes the frame size if it has just one window and we can only
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3040 ;; make the attempt if the buffer has truncate-lines set (otherwise it's
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3041 ;; too painful to work out how many lines we need.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3042 ;; Doesn't even *attempt* to cope with fontified buffers.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3043
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3044 (defun fit-frame-to-buffer (frame buf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3045 (let (height-needed)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3046 (if (and frame
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3047 truncate-lines
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3048 (<= (count-frame-windows frame) 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3049 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3050 (setq height-needed
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3051 (+ (count-lines (point-min) (point-max)) 2))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3052 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3053 ((> (frame-height frame) height-needed)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3054 (set-frame-height frame height-needed))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3055 ((< height-needed 24)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3056 (set-frame-height frame height-needed))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3057 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3058 (set-frame-height frame 24)))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3059
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3060 ;;; Code for parsing expressions out of C code. The single entry point is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3061 ;;; find-c-expr, which tries to return an lvalue expression from around point.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3062 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3063 ;;; The rest of this file is a hacked version of gdbsrc.el by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3064 ;;; Debby Ayers <ayers@asc.slb.com>,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3065 ;;; Rich Schaefer <schaefer@asc.slb.com> Schlumberger, Austin, Tx.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3066
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3067 (defun find-c-expr ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3068 "Returns the C expr that surrounds point."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3069 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3070 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3071 (let ((p) (expr) (test-expr))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3072 (setq p (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3073 (setq expr (expr-cur))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3074 (setq test-expr (expr-prev))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3075 (while (expr-compound test-expr expr)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3076 (setq expr (cons (car test-expr) (cdr expr)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3077 (goto-char (car expr))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3078 (setq test-expr (expr-prev)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3079 (goto-char p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3080 (setq test-expr (expr-next))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3081 (while (expr-compound expr test-expr)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3082 (setq expr (cons (car expr) (cdr test-expr)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3083 (setq test-expr (expr-next))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3084 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3085 (buffer-substring (car expr) (cdr expr)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3086
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3087 (defun expr-cur ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3088 "Returns the expr that point is in; point is set to beginning of expr.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3089 The expr is represented as a cons cell, where the car specifies the point in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3090 the current buffer that marks the beginning of the expr and the cdr specifies
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3091 the character after the end of the expr."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3092 (let ((p (point)) (begin) (end))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3093 (expr-backward-sexp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3094 (setq begin (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3095 (expr-forward-sexp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3096 (setq end (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3097 (if (>= p end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3098 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3099 (setq begin p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3100 (goto-char p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3101 (expr-forward-sexp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3102 (setq end (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3103 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3104 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3105 (goto-char begin)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3106 (cons begin end)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3107
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3108 (defun expr-backward-sexp ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3109 "Version of `backward-sexp' that catches errors."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3110 (condition-case nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3111 (backward-sexp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3112 (error t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3113
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3114 (defun expr-forward-sexp ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3115 "Version of `forward-sexp' that catches errors."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3116 (condition-case nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3117 (forward-sexp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3118 (error t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3119
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3120 (defun expr-prev ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3121 "Returns the previous expr, point is set to beginning of that expr.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3122 The expr is represented as a cons cell, where the car specifies the point in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3123 the current buffer that marks the beginning of the expr and the cdr specifies
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3124 the character after the end of the expr"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3125 (let ((begin) (end))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3126 (expr-backward-sexp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3127 (setq begin (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3128 (expr-forward-sexp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3129 (setq end (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3130 (goto-char begin)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3131 (cons begin end)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3132
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3133 (defun expr-next ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3134 "Returns the following expr, point is set to beginning of that expr.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3135 The expr is represented as a cons cell, where the car specifies the point in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3136 the current buffer that marks the beginning of the expr and the cdr specifies
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3137 the character after the end of the expr."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3138 (let ((begin) (end))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3139 (expr-forward-sexp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3140 (expr-forward-sexp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3141 (setq end (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3142 (expr-backward-sexp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3143 (setq begin (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3144 (cons begin end)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3145
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3146 (defun expr-compound-sep (span-start span-end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3147 "Returns '.' for '->' & '.', returns ' ' for white space,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3148 returns '?' for other punctuation."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3149 (let ((result ? )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3150 (syntax))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3151 (while (< span-start span-end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3152 (setq syntax (char-syntax (char-after span-start)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3153 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3154 ((= syntax ? ) t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3155 ((= syntax ?.) (setq syntax (char-after span-start))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3156 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3157 ((= syntax ?.) (setq result ?.))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3158 ((and (= syntax ?-) (= (char-after (+ span-start 1)) ?>))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3159 (setq result ?.)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3160 (setq span-start (+ span-start 1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3161 (t (setq span-start span-end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3162 (setq result ??)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3163 (setq span-start (+ span-start 1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3164 result))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3165
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3166 (defun expr-compound (first second)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3167 "Non-nil if concatenating FIRST and SECOND makes a single C token.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3168 The two exprs are represented as a cons cells, where the car
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3169 specifies the point in the current buffer that marks the beginning of the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3170 expr and the cdr specifies the character after the end of the expr.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3171 Link exprs of the form:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3172 Expr -> Expr
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3173 Expr . Expr
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3174 Expr (Expr)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3175 Expr [Expr]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3176 (Expr) Expr
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3177 [Expr] Expr"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3178 (let ((span-start (cdr first))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3179 (span-end (car second))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3180 (syntax))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3181 (setq syntax (expr-compound-sep span-start span-end))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3182 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3183 ((= (car first) (car second)) nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3184 ((= (cdr first) (cdr second)) nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3185 ((= syntax ?.) t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3186 ((= syntax ? )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3187 (setq span-start (char-after (- span-start 1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3188 (setq span-end (char-after span-end))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3189 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3190 ((= span-start ?) ) t )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3191 ((= span-start ?] ) t )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3192 ((= span-end ?( ) t )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3193 ((= span-end ?[ ) t )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3194 (t nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3195 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3196 (t nil))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3197
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3198
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3199 ;;; Compare two buffers. We assume that they're not narrowed.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3200 (defun gud-buffers-differ (buffer1 buffer2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3201 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3202 (let ((size1 (progn (set-buffer buffer1) (buffer-size)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3203 (size2 (progn (set-buffer buffer2) (buffer-size))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3204 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3205 ((not (= size1 size2))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3206 t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3207 ((= (compare-buffer-substrings
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3208 buffer1 1 size1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3209 buffer2 1 size2) 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3210 nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3211 (t)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3212
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3213
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3214 (provide 'gud)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3215
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3216 ;; WTF
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3217 (defmacro gud (form)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3218 (` (save-excursion (set-buffer "*gud-a.out*") (, form))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3219
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3220 (defun dbug (foo &optional fun)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3221 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3222 (set-buffer (get-buffer-create "*trace*"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3223 (goto-char (point-max))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3224 (insert "***" (symbol-name foo) "\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3225 (if fun
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3226 (funcall fun))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3227
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3228
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3229
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3230 ;;; gud.el ends here