annotate lisp/comint/gud.el @ 2:ac2d302a0011 r19-15b2

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