annotate lisp/gud.el @ 3646:4b34cbec2058

* gud.el (gud-last-last-frame): New variable. (gud-display-frame): Save the frame we displayed in gud-last-last-frame. (gud-refresh): Force gud-display-frame to jump to the last frame displayed, even if it has already done so once.
author Jim Blandy <jimb@redhat.com>
date Fri, 11 Jun 1993 11:28:28 +0000
parents 507f64624555
children c5ebd279e007
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
810
80303373daae *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 806
diff changeset
1 ;;; gud.el --- Grand Unified Debugger mode for gdb, sdb, or dbx under Emacs
80303373daae *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 806
diff changeset
2
2489
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
3 ;; Author: Eric S. Raymond <esr@snark.thyrsus.com>
2581
839d67a1dc58 Set no-byte-compile local variable t to work around a byte-compiler bug.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2532
diff changeset
4 ;; Version: 1.3
810
80303373daae *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 806
diff changeset
5 ;; Keywords: unix, tools
80303373daae *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 806
diff changeset
6
2960
372386917f03 (gud-def): Fix inclusion of the define-key.
Richard M. Stallman <rms@gnu.org>
parents: 2594
diff changeset
7 ;; Copyright (C) 1992, 1993 Free Software Foundation, Inc.
460
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
8
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
9 ;; This file is part of GNU Emacs.
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
10
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
11 ;; GNU Emacs is free software; you can redistribute it and/or modify
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
12 ;; it under the terms of the GNU General Public License as published by
868
0cda1f7b154e *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 810
diff changeset
13 ;; the Free Software Foundation; either version 2, or (at your option)
460
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
14 ;; any later version.
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
15
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
16 ;; GNU Emacs is distributed in the hope that it will be useful,
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
19 ;; GNU General Public License for more details.
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
20
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
21 ;; You should have received a copy of the GNU General Public License
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
22 ;; along with GNU Emacs; see the file COPYING. If not, write to
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
23 ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
24
810
80303373daae *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 806
diff changeset
25 ;;; Commentary:
80303373daae *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 806
diff changeset
26
460
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
27 ;; The ancestral gdb.el was by W. Schelter <wfs@rascal.ics.utexas.edu>
868
0cda1f7b154e *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 810
diff changeset
28 ;; It was later rewritten by rms. Some ideas were due to Masanobu.
810
80303373daae *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 806
diff changeset
29 ;; Grand Unification (sdb/dbx support) by Eric S. Raymond <esr@thyrsus.com>
460
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
30 ;; The overloading code was then rewritten by Barry Warsaw <bwarsaw@cen.com>,
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
31 ;; who also hacked the mode to use comint.el.
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
32
810
80303373daae *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 806
diff changeset
33 ;;; Code:
80303373daae *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 806
diff changeset
34
460
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
35 (require 'comint)
923
9f3cc03dae67 entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 914
diff changeset
36 (require 'etags)
460
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
37
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
38 ;; ======================================================================
2581
839d67a1dc58 Set no-byte-compile local variable t to work around a byte-compiler bug.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2532
diff changeset
39 ;; GUD commands must be visible in C buffers visited by GUD
2489
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
40
2532
17a6b6d079cf (gud-mode): Created C-c synonym bindings in the GUD buffer's local map.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2519
diff changeset
41 (defvar gud-key-prefix "\C-x\C-a"
2581
839d67a1dc58 Set no-byte-compile local variable t to work around a byte-compiler bug.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2532
diff changeset
42 "Prefix of all GUD commands valid in C buffers.")
2489
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
43
2581
839d67a1dc58 Set no-byte-compile local variable t to work around a byte-compiler bug.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2532
diff changeset
44 (global-set-key (concat gud-key-prefix "\C-l") 'gud-refresh)
839d67a1dc58 Set no-byte-compile local variable t to work around a byte-compiler bug.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2532
diff changeset
45 (global-set-key "\C-x " 'gud-break) ;; backward compatibility hack
2489
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
46
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
47 ;; ======================================================================
460
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
48 ;; the overloading mechanism
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
49
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
50 (defun gud-overload-functions (gud-overload-alist)
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
51 "Overload functions defined in GUD-OVERLOAD-ALIST.
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
52 This association list has elements of the form
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
53 (ORIGINAL-FUNCTION-NAME OVERLOAD-FUNCTION)"
868
0cda1f7b154e *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 810
diff changeset
54 (mapcar
0cda1f7b154e *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 810
diff changeset
55 (function (lambda (p) (fset (car p) (symbol-function (cdr p)))))
0cda1f7b154e *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 810
diff changeset
56 gud-overload-alist))
460
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
57
2489
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
58 (defun gud-debugger-startup (file args)
460
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
59 (error "GUD not properly entered."))
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
60
2489
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
61 (defun gud-marker-filter (str)
460
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
62 (error "GUD not properly entered."))
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
63
2489
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
64 (defun gud-find-file (f)
460
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
65 (error "GUD not properly entered."))
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
66
2489
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
67 ;; ======================================================================
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
68 ;; command definition
460
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
69
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
70 ;; This macro is used below to define some basic debugger interface commands.
810
80303373daae *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 806
diff changeset
71 ;; Of course you may use `gud-def' with any other debugger command, including
1255
ff06503c93b4 * gud.el (gud-def): Doc fix.
Jim Blandy <jimb@redhat.com>
parents: 923
diff changeset
72 ;; user defined ones.
ff06503c93b4 * gud.el (gud-def): Doc fix.
Jim Blandy <jimb@redhat.com>
parents: 923
diff changeset
73
ff06503c93b4 * gud.el (gud-def): Doc fix.
Jim Blandy <jimb@redhat.com>
parents: 923
diff changeset
74 ;; A macro call like (gud-def FUNC NAME KEY DOC) expands to a form
ff06503c93b4 * gud.el (gud-def): Doc fix.
Jim Blandy <jimb@redhat.com>
parents: 923
diff changeset
75 ;; which defines FUNC to send the command NAME to the debugger, gives
2489
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
76 ;; it the docstring DOC, and binds that function to KEY in the GUD
2581
839d67a1dc58 Set no-byte-compile local variable t to work around a byte-compiler bug.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2532
diff changeset
77 ;; major mode. The function is also bound in the global keymap with the
839d67a1dc58 Set no-byte-compile local variable t to work around a byte-compiler bug.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2532
diff changeset
78 ;; GUD prefix.
2489
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
79
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
80 (defmacro gud-def (func cmd key &optional doc)
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
81 "Define FUNC to be a command sending STR and bound to KEY, with
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
82 optional doc string DOC. Certain %-escapes in the string arguments
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
83 are interpreted specially if present. These are:
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
84
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
85 %f name of current source file.
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
86 %l number of current source line
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
87 %e text of the C lvalue or function-call expression surrounding point.
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
88 %a text of the hexadecimal address surrounding point
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
89 %p prefix argument to the command (if any) as a number
460
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
90
2581
839d67a1dc58 Set no-byte-compile local variable t to work around a byte-compiler bug.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2532
diff changeset
91 The `current' source file is the file of the current buffer (if
839d67a1dc58 Set no-byte-compile local variable t to work around a byte-compiler bug.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2532
diff changeset
92 we're in a C file) or the source file current at the last break or
839d67a1dc58 Set no-byte-compile local variable t to work around a byte-compiler bug.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2532
diff changeset
93 step (if we're in the GUD buffer).
839d67a1dc58 Set no-byte-compile local variable t to work around a byte-compiler bug.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2532
diff changeset
94 The `current' line is that of the current buffer (if we're in a
839d67a1dc58 Set no-byte-compile local variable t to work around a byte-compiler bug.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2532
diff changeset
95 source file) or the source line number at the last break or step (if
839d67a1dc58 Set no-byte-compile local variable t to work around a byte-compiler bug.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2532
diff changeset
96 we're in the GUD buffer)."
2489
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
97 (list 'progn
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
98 (list 'defun func '(arg)
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
99 (or doc "")
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
100 '(interactive "p")
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
101 (list 'gud-call cmd 'arg))
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
102 (if key
2960
372386917f03 (gud-def): Fix inclusion of the define-key.
Richard M. Stallman <rms@gnu.org>
parents: 2594
diff changeset
103 (list 'define-key
372386917f03 (gud-def): Fix inclusion of the define-key.
Richard M. Stallman <rms@gnu.org>
parents: 2594
diff changeset
104 '(current-local-map)
372386917f03 (gud-def): Fix inclusion of the define-key.
Richard M. Stallman <rms@gnu.org>
parents: 2594
diff changeset
105 (concat "\C-c" key)
372386917f03 (gud-def): Fix inclusion of the define-key.
Richard M. Stallman <rms@gnu.org>
parents: 2594
diff changeset
106 (list 'quote func)))
372386917f03 (gud-def): Fix inclusion of the define-key.
Richard M. Stallman <rms@gnu.org>
parents: 2594
diff changeset
107 (if key
372386917f03 (gud-def): Fix inclusion of the define-key.
Richard M. Stallman <rms@gnu.org>
parents: 2594
diff changeset
108 (list 'global-set-key
3343
d5fde107dbe3 (gud-def): Don't use gud-key-prefix at compile time.
Richard M. Stallman <rms@gnu.org>
parents: 2960
diff changeset
109 (list 'concat 'gud-key-prefix key)
2960
372386917f03 (gud-def): Fix inclusion of the define-key.
Richard M. Stallman <rms@gnu.org>
parents: 2594
diff changeset
110 (list 'quote func)))))
460
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
111
1275
68f025a5fdaa * gud.el (gud-last-frame): Added defvar for this.
Jim Blandy <jimb@redhat.com>
parents: 1274
diff changeset
112 ;; Where gud-display-frame should put the debugging arrow. This is
68f025a5fdaa * gud.el (gud-last-frame): Added defvar for this.
Jim Blandy <jimb@redhat.com>
parents: 1274
diff changeset
113 ;; set by the marker-filter, which scans the debugger's output for
2489
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
114 ;; indications of the current program counter.
1275
68f025a5fdaa * gud.el (gud-last-frame): Added defvar for this.
Jim Blandy <jimb@redhat.com>
parents: 1274
diff changeset
115 (defvar gud-last-frame nil)
68f025a5fdaa * gud.el (gud-last-frame): Added defvar for this.
Jim Blandy <jimb@redhat.com>
parents: 1274
diff changeset
116
3646
4b34cbec2058 * gud.el (gud-last-last-frame): New variable.
Jim Blandy <jimb@redhat.com>
parents: 3591
diff changeset
117 ;; Used by gud-refresh, which should cause gud-display-frame to redisplay
4b34cbec2058 * gud.el (gud-last-last-frame): New variable.
Jim Blandy <jimb@redhat.com>
parents: 3591
diff changeset
118 ;; the last frame, even if it's been called before and gud-last-frame has
4b34cbec2058 * gud.el (gud-last-last-frame): New variable.
Jim Blandy <jimb@redhat.com>
parents: 3591
diff changeset
119 ;; been set to nil.
4b34cbec2058 * gud.el (gud-last-last-frame): New variable.
Jim Blandy <jimb@redhat.com>
parents: 3591
diff changeset
120 (defvar gud-last-last-frame)
4b34cbec2058 * gud.el (gud-last-last-frame): New variable.
Jim Blandy <jimb@redhat.com>
parents: 3591
diff changeset
121
2489
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
122 ;; All debugger-specific information is collected here.
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
123 ;; Here's how it works, in case you ever need to add a debugger to the mode.
460
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
124 ;;
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
125 ;; Each entry must define the following at startup:
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
126 ;;
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
127 ;;<name>
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
128 ;; comint-prompt-regexp
868
0cda1f7b154e *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 810
diff changeset
129 ;; gud-<name>-debugger-startup
460
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
130 ;; gud-<name>-marker-filter
2489
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
131 ;; gud-<name>-find-file
460
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
132 ;;
477
ab9a55b26bd4 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 460
diff changeset
133 ;; The job of the startup-command method is to fire up a copy of the debugger,
2489
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
134 ;; given a list of debugger arguments.
477
ab9a55b26bd4 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 460
diff changeset
135 ;;
ab9a55b26bd4 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 460
diff changeset
136 ;; The job of the marker-filter method is to detect file/line markers in
ab9a55b26bd4 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 460
diff changeset
137 ;; strings and set the global gud-last-frame to indicate what display
ab9a55b26bd4 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 460
diff changeset
138 ;; action (if any) should be triggered by the marker. Note that only
3591
507f64624555 Apply typo patches from Paul Eggert.
Jim Blandy <jimb@redhat.com>
parents: 3551
diff changeset
139 ;; whatever the method *returns* is displayed in the buffer; thus, you
477
ab9a55b26bd4 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 460
diff changeset
140 ;; can filter the debugger's output, interpreting some and passing on
ab9a55b26bd4 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 460
diff changeset
141 ;; the rest.
ab9a55b26bd4 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 460
diff changeset
142 ;;
2489
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
143 ;; The job of the find-file method is to visit and return the buffer indicated
477
ab9a55b26bd4 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 460
diff changeset
144 ;; by the car of gud-tag-frame. This may be a file name, a tag name, or
ab9a55b26bd4 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 460
diff changeset
145 ;; something else.
460
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
146
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
147 ;; ======================================================================
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
148 ;; gdb functions
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
149
2489
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
150 (defun gud-gdb-debugger-startup (file args)
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
151 (apply 'make-comint (concat "gud-" file) "gdb" nil "-fullname" args))
460
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
152
2489
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
153 (defun gud-gdb-marker-filter (string)
1255
ff06503c93b4 * gud.el (gud-def): Doc fix.
Jim Blandy <jimb@redhat.com>
parents: 923
diff changeset
154 (if (string-match "\032\032\\([^:\n]*\\):\\([0-9]*\\):.*\n" string)
460
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
155 (progn
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
156 (setq gud-last-frame
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
157 (cons
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
158 (substring string (match-beginning 1) (match-end 1))
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
159 (string-to-int
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
160 (substring string (match-beginning 2) (match-end 2)))))
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
161 ;; this computation means the ^Z^Z-initiated marker in the
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
162 ;; input string is never emitted.
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
163 (concat
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
164 (substring string 0 (match-beginning 0))
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
165 (substring string (match-end 0))
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
166 ))
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
167 string))
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
168
2489
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
169 (defun gud-gdb-find-file (f)
460
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
170 (find-file-noselect f))
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
171
477
ab9a55b26bd4 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 460
diff changeset
172 ;;;###autoload
2489
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
173 (defun gdb (args)
460
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
174 "Run gdb on program FILE in buffer *gud-FILE*.
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
175 The directory containing FILE becomes the initial working directory
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
176 and source-file directory for your debugger."
2519
d567a93d9408 (gdb, sdb, dbx): Improved prompting a la grep.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2489
diff changeset
177 (interactive "sRun gdb (like this): gdb ")
868
0cda1f7b154e *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 810
diff changeset
178 (gud-overload-functions '((gud-debugger-startup . gud-gdb-debugger-startup)
0cda1f7b154e *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 810
diff changeset
179 (gud-marker-filter . gud-gdb-marker-filter)
2489
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
180 (gud-find-file . gud-gdb-find-file)
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
181 ))
460
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
182
2581
839d67a1dc58 Set no-byte-compile local variable t to work around a byte-compiler bug.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2532
diff changeset
183 (gud-common-init args)
839d67a1dc58 Set no-byte-compile local variable t to work around a byte-compiler bug.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2532
diff changeset
184
2960
372386917f03 (gud-def): Fix inclusion of the define-key.
Richard M. Stallman <rms@gnu.org>
parents: 2594
diff changeset
185 (gud-def gud-break "break %f:%l" "\C-b" "Set breakpoint at current line.")
372386917f03 (gud-def): Fix inclusion of the define-key.
Richard M. Stallman <rms@gnu.org>
parents: 2594
diff changeset
186 (gud-def gud-tbreak "tbreak %f:%l" "\C-t" "Set breakpoint at current line.")
372386917f03 (gud-def): Fix inclusion of the define-key.
Richard M. Stallman <rms@gnu.org>
parents: 2594
diff changeset
187 (gud-def gud-remove "clear %l" "\C-d" "Remove breakpoint at current line")
372386917f03 (gud-def): Fix inclusion of the define-key.
Richard M. Stallman <rms@gnu.org>
parents: 2594
diff changeset
188 (gud-def gud-step "step %p" "\C-s" "Step one source line with display.")
372386917f03 (gud-def): Fix inclusion of the define-key.
Richard M. Stallman <rms@gnu.org>
parents: 2594
diff changeset
189 (gud-def gud-stepi "stepi %p" "\C-i" "Step one instruction with display.")
372386917f03 (gud-def): Fix inclusion of the define-key.
Richard M. Stallman <rms@gnu.org>
parents: 2594
diff changeset
190 (gud-def gud-next "next %p" "\C-n" "Step one line (skip functions).")
372386917f03 (gud-def): Fix inclusion of the define-key.
Richard M. Stallman <rms@gnu.org>
parents: 2594
diff changeset
191 (gud-def gud-cont "cont" "\C-r" "Continue with display.")
372386917f03 (gud-def): Fix inclusion of the define-key.
Richard M. Stallman <rms@gnu.org>
parents: 2594
diff changeset
192 (gud-def gud-finish "finish" "\C-f" "Finish executing current function.")
2489
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
193 (gud-def gud-up "up %p" "<" "Up N stack frames (numeric arg).")
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
194 (gud-def gud-down "down %p" ">" "Down N stack frames (numeric arg).")
2960
372386917f03 (gud-def): Fix inclusion of the define-key.
Richard M. Stallman <rms@gnu.org>
parents: 2594
diff changeset
195 (gud-def gud-print "print %e" "\C-p" "Evaluate C expression at point.")
460
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
196
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
197 (setq comint-prompt-regexp "^(.*gdb[+]?) *")
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
198 (run-hooks 'gdb-mode-hook)
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
199 )
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
200
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
201
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
202 ;; ======================================================================
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
203 ;; sdb functions
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
204
2489
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
205 (defvar gud-sdb-needs-tags (not (file-exists-p "/var"))
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
206 "If nil, we're on a System V Release 4 and don't need the tags hack.")
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
207
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
208 (defvar gud-sdb-lastfile nil)
460
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
209
2489
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
210 (defun gud-sdb-debugger-startup (file args)
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
211 (apply 'make-comint (concat "gud-" file) "sdb" nil args))
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
212
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
213 (defun gud-sdb-marker-filter (string)
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
214 (cond
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
215 ;; System V Release 3.2 uses this format
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
216 ((string-match "\\(^0x\\w* in \\|^\\|\n\\)\\([^:\n]*\\):\\([0-9]*\\):.*\n"
1255
ff06503c93b4 * gud.el (gud-def): Doc fix.
Jim Blandy <jimb@redhat.com>
parents: 923
diff changeset
217 string)
2489
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
218 (setq gud-last-frame
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
219 (cons
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
220 (substring string (match-beginning 2) (match-end 2))
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
221 (string-to-int
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
222 (substring string (match-beginning 3) (match-end 3))))))
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
223 ;; System V Release 4.0
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
224 ((string-match "^\\(BREAKPOINT\\|STEPPED\\) process [0-9]+ function [^ ]+ in \\(.+\\)\n"
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
225 string)
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
226 (setq gud-sdb-lastfile
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
227 (substring string (match-beginning 2) (match-end 2))))
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
228 ((and gud-sdb-lastfile (string-match "^\\([0-9]+\\):" string))
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
229 (setq gud-last-frame
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
230 (cons
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
231 gud-sdb-lastfile
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
232 (string-to-int
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
233 (substring string (match-beginning 1) (match-end 1))))))
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
234 (t
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
235 (setq gud-sdb-lastfile nil)))
460
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
236 string)
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
237
2489
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
238 (defun gud-sdb-find-file (f)
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
239 (if gud-sdb-needs-tags
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
240 (find-tag-noselect f)
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
241 (find-file-noselect f)))
460
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
242
477
ab9a55b26bd4 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 460
diff changeset
243 ;;;###autoload
2489
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
244 (defun sdb (args)
460
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
245 "Run sdb on program FILE in buffer *gud-FILE*.
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
246 The directory containing FILE becomes the initial working directory
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
247 and source-file directory for your debugger."
2519
d567a93d9408 (gdb, sdb, dbx): Improved prompting a la grep.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2489
diff changeset
248 (interactive "sRun sdb (like this): sdb ")
2489
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
249 (if (and gud-sdb-needs-tags
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
250 (not (and (boundp 'tags-file-name) (file-exists-p tags-file-name))))
460
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
251 (error "The sdb support requires a valid tags table to work."))
868
0cda1f7b154e *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 810
diff changeset
252 (gud-overload-functions '((gud-debugger-startup . gud-sdb-debugger-startup)
0cda1f7b154e *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 810
diff changeset
253 (gud-marker-filter . gud-sdb-marker-filter)
2489
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
254 (gud-find-file . gud-sdb-find-file)
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
255 ))
460
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
256
2581
839d67a1dc58 Set no-byte-compile local variable t to work around a byte-compiler bug.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2532
diff changeset
257 (gud-common-init args)
839d67a1dc58 Set no-byte-compile local variable t to work around a byte-compiler bug.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2532
diff changeset
258
2960
372386917f03 (gud-def): Fix inclusion of the define-key.
Richard M. Stallman <rms@gnu.org>
parents: 2594
diff changeset
259 (gud-def gud-break "%l b" "\C-b" "Set breakpoint at current line.")
372386917f03 (gud-def): Fix inclusion of the define-key.
Richard M. Stallman <rms@gnu.org>
parents: 2594
diff changeset
260 (gud-def gud-tbreak "%l c" "\C-t" "Set temporary breakpoint at current line.")
372386917f03 (gud-def): Fix inclusion of the define-key.
Richard M. Stallman <rms@gnu.org>
parents: 2594
diff changeset
261 (gud-def gud-remove "%l d" "\C-d" "Remove breakpoint at current line")
372386917f03 (gud-def): Fix inclusion of the define-key.
Richard M. Stallman <rms@gnu.org>
parents: 2594
diff changeset
262 (gud-def gud-step "s %p" "\C-s" "Step one source line with display.")
372386917f03 (gud-def): Fix inclusion of the define-key.
Richard M. Stallman <rms@gnu.org>
parents: 2594
diff changeset
263 (gud-def gud-stepi "i %p" "\C-i" "Step one instruction with display.")
372386917f03 (gud-def): Fix inclusion of the define-key.
Richard M. Stallman <rms@gnu.org>
parents: 2594
diff changeset
264 (gud-def gud-next "S %p" "\C-n" "Step one line (skip functions).")
372386917f03 (gud-def): Fix inclusion of the define-key.
Richard M. Stallman <rms@gnu.org>
parents: 2594
diff changeset
265 (gud-def gud-cont "c" "\C-r" "Continue with display.")
372386917f03 (gud-def): Fix inclusion of the define-key.
Richard M. Stallman <rms@gnu.org>
parents: 2594
diff changeset
266 (gud-def gud-print "%e/" "\C-p" "Evaluate C expression at point.")
460
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
267
1255
ff06503c93b4 * gud.el (gud-def): Doc fix.
Jim Blandy <jimb@redhat.com>
parents: 923
diff changeset
268 (setq comint-prompt-regexp "\\(^\\|\n\\)\\*")
460
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
269 (run-hooks 'sdb-mode-hook)
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
270 )
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
271
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
272 ;; ======================================================================
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
273 ;; dbx functions
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
274
2489
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
275 (defun gud-dbx-debugger-startup (file args)
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
276 (apply 'make-comint (concat "gud-" file) "dbx" nil args))
460
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
277
2489
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
278 (defun gud-dbx-marker-filter (string)
460
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
279 (if (string-match
1255
ff06503c93b4 * gud.el (gud-def): Doc fix.
Jim Blandy <jimb@redhat.com>
parents: 923
diff changeset
280 "stopped in .* at line \\([0-9]*\\) in file \"\\([^\"]*\\)\"" string)
460
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
281 (setq gud-last-frame
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
282 (cons
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
283 (substring string (match-beginning 2) (match-end 2))
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
284 (string-to-int
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
285 (substring string (match-beginning 1) (match-end 1))))))
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
286 string)
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
287
2489
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
288 (defun gud-dbx-find-file (f)
460
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
289 (find-file-noselect f))
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
290
477
ab9a55b26bd4 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 460
diff changeset
291 ;;;###autoload
2489
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
292 (defun dbx (args)
460
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
293 "Run dbx on program FILE in buffer *gud-FILE*.
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
294 The directory containing FILE becomes the initial working directory
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
295 and source-file directory for your debugger."
2519
d567a93d9408 (gdb, sdb, dbx): Improved prompting a la grep.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2489
diff changeset
296 (interactive "sRun dbx (like this): dbx")
868
0cda1f7b154e *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 810
diff changeset
297 (gud-overload-functions '((gud-debugger-startup . gud-dbx-debugger-startup)
0cda1f7b154e *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 810
diff changeset
298 (gud-marker-filter . gud-dbx-marker-filter)
2489
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
299 (gud-find-file . gud-dbx-find-file)
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
300 ))
868
0cda1f7b154e *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 810
diff changeset
301
2581
839d67a1dc58 Set no-byte-compile local variable t to work around a byte-compiler bug.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2532
diff changeset
302 (gud-common-init args)
839d67a1dc58 Set no-byte-compile local variable t to work around a byte-compiler bug.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2532
diff changeset
303
2489
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
304 (gud-def gud-break "stop at \"%f\":%l"
2960
372386917f03 (gud-def): Fix inclusion of the define-key.
Richard M. Stallman <rms@gnu.org>
parents: 2594
diff changeset
305 "\C-b" "Set breakpoint at current line.")
372386917f03 (gud-def): Fix inclusion of the define-key.
Richard M. Stallman <rms@gnu.org>
parents: 2594
diff changeset
306 (gud-def gud-remove "clear %l" "\C-d" "Remove breakpoint at current line")
372386917f03 (gud-def): Fix inclusion of the define-key.
Richard M. Stallman <rms@gnu.org>
parents: 2594
diff changeset
307 (gud-def gud-step "step %p" "\C-s" "Step one line with display.")
372386917f03 (gud-def): Fix inclusion of the define-key.
Richard M. Stallman <rms@gnu.org>
parents: 2594
diff changeset
308 (gud-def gud-stepi "stepi %p" "\C-i" "Step one instruction with display.")
372386917f03 (gud-def): Fix inclusion of the define-key.
Richard M. Stallman <rms@gnu.org>
parents: 2594
diff changeset
309 (gud-def gud-next "next %p" "\C-n" "Step one line (skip functions).")
372386917f03 (gud-def): Fix inclusion of the define-key.
Richard M. Stallman <rms@gnu.org>
parents: 2594
diff changeset
310 (gud-def gud-cont "cont" "\C-r" "Continue with display.")
2489
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
311 (gud-def gud-up "up %p" "<" "Up (numeric arg) stack frames.")
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
312 (gud-def gud-down "down %p" ">" "Down (numeric arg) stack frames.")
2960
372386917f03 (gud-def): Fix inclusion of the define-key.
Richard M. Stallman <rms@gnu.org>
parents: 2594
diff changeset
313 (gud-def gud-print "print %e" "\C-p" "Evaluate C expression at point.")
868
0cda1f7b154e *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 810
diff changeset
314
460
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
315 (setq comint-prompt-regexp "^[^)]*dbx) *")
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
316 (run-hooks 'dbx-mode-hook)
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
317 )
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
318
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
319 ;;
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
320 ;; End of debugger-specific information
477
ab9a55b26bd4 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 460
diff changeset
321 ;;
460
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
322
1256
ff24725192d3 * gud.el: When we send a command to the debugger via gud-call,
Jim Blandy <jimb@redhat.com>
parents: 1255
diff changeset
323 ;;; When we send a command to the debugger via gud-call, it's annoying
ff24725192d3 * gud.el: When we send a command to the debugger via gud-call,
Jim Blandy <jimb@redhat.com>
parents: 1255
diff changeset
324 ;;; to see the command and the new prompt inserted into the debugger's
ff24725192d3 * gud.el: When we send a command to the debugger via gud-call,
Jim Blandy <jimb@redhat.com>
parents: 1255
diff changeset
325 ;;; buffer; we have other ways of knowing the command has completed.
ff24725192d3 * gud.el: When we send a command to the debugger via gud-call,
Jim Blandy <jimb@redhat.com>
parents: 1255
diff changeset
326 ;;;
ff24725192d3 * gud.el: When we send a command to the debugger via gud-call,
Jim Blandy <jimb@redhat.com>
parents: 1255
diff changeset
327 ;;; If the buffer looks like this:
ff24725192d3 * gud.el: When we send a command to the debugger via gud-call,
Jim Blandy <jimb@redhat.com>
parents: 1255
diff changeset
328 ;;; --------------------
ff24725192d3 * gud.el: When we send a command to the debugger via gud-call,
Jim Blandy <jimb@redhat.com>
parents: 1255
diff changeset
329 ;;; (gdb) set args foo bar
ff24725192d3 * gud.el: When we send a command to the debugger via gud-call,
Jim Blandy <jimb@redhat.com>
parents: 1255
diff changeset
330 ;;; (gdb) -!-
ff24725192d3 * gud.el: When we send a command to the debugger via gud-call,
Jim Blandy <jimb@redhat.com>
parents: 1255
diff changeset
331 ;;; --------------------
ff24725192d3 * gud.el: When we send a command to the debugger via gud-call,
Jim Blandy <jimb@redhat.com>
parents: 1255
diff changeset
332 ;;; (the -!- marks the location of point), and we type `C-x SPC' in a
ff24725192d3 * gud.el: When we send a command to the debugger via gud-call,
Jim Blandy <jimb@redhat.com>
parents: 1255
diff changeset
333 ;;; source file to set a breakpoint, we want the buffer to end up like
ff24725192d3 * gud.el: When we send a command to the debugger via gud-call,
Jim Blandy <jimb@redhat.com>
parents: 1255
diff changeset
334 ;;; this:
ff24725192d3 * gud.el: When we send a command to the debugger via gud-call,
Jim Blandy <jimb@redhat.com>
parents: 1255
diff changeset
335 ;;; --------------------
ff24725192d3 * gud.el: When we send a command to the debugger via gud-call,
Jim Blandy <jimb@redhat.com>
parents: 1255
diff changeset
336 ;;; (gdb) set args foo bar
ff24725192d3 * gud.el: When we send a command to the debugger via gud-call,
Jim Blandy <jimb@redhat.com>
parents: 1255
diff changeset
337 ;;; Breakpoint 1 at 0x92: file make-docfile.c, line 49.
ff24725192d3 * gud.el: When we send a command to the debugger via gud-call,
Jim Blandy <jimb@redhat.com>
parents: 1255
diff changeset
338 ;;; (gdb) -!-
ff24725192d3 * gud.el: When we send a command to the debugger via gud-call,
Jim Blandy <jimb@redhat.com>
parents: 1255
diff changeset
339 ;;; --------------------
ff24725192d3 * gud.el: When we send a command to the debugger via gud-call,
Jim Blandy <jimb@redhat.com>
parents: 1255
diff changeset
340 ;;; Essentially, the old prompt is deleted, and the command's output
ff24725192d3 * gud.el: When we send a command to the debugger via gud-call,
Jim Blandy <jimb@redhat.com>
parents: 1255
diff changeset
341 ;;; and the new prompt take its place.
ff24725192d3 * gud.el: When we send a command to the debugger via gud-call,
Jim Blandy <jimb@redhat.com>
parents: 1255
diff changeset
342 ;;;
ff24725192d3 * gud.el: When we send a command to the debugger via gud-call,
Jim Blandy <jimb@redhat.com>
parents: 1255
diff changeset
343 ;;; Not echoing the command is easy enough; you send it directly using
ff24725192d3 * gud.el: When we send a command to the debugger via gud-call,
Jim Blandy <jimb@redhat.com>
parents: 1255
diff changeset
344 ;;; process-send-string, and it never enters the buffer. However,
ff24725192d3 * gud.el: When we send a command to the debugger via gud-call,
Jim Blandy <jimb@redhat.com>
parents: 1255
diff changeset
345 ;;; getting rid of the old prompt is trickier; you don't want to do it
ff24725192d3 * gud.el: When we send a command to the debugger via gud-call,
Jim Blandy <jimb@redhat.com>
parents: 1255
diff changeset
346 ;;; when you send the command, since that will result in an annoying
ff24725192d3 * gud.el: When we send a command to the debugger via gud-call,
Jim Blandy <jimb@redhat.com>
parents: 1255
diff changeset
347 ;;; flicker as the prompt is deleted, redisplay occurs while Emacs
ff24725192d3 * gud.el: When we send a command to the debugger via gud-call,
Jim Blandy <jimb@redhat.com>
parents: 1255
diff changeset
348 ;;; waits for a response from the debugger, and the new prompt is
ff24725192d3 * gud.el: When we send a command to the debugger via gud-call,
Jim Blandy <jimb@redhat.com>
parents: 1255
diff changeset
349 ;;; inserted. Instead, we'll wait until we actually get some output
ff24725192d3 * gud.el: When we send a command to the debugger via gud-call,
Jim Blandy <jimb@redhat.com>
parents: 1255
diff changeset
350 ;;; from the subprocess before we delete the prompt. If the command
ff24725192d3 * gud.el: When we send a command to the debugger via gud-call,
Jim Blandy <jimb@redhat.com>
parents: 1255
diff changeset
351 ;;; produced no output other than a new prompt, that prompt will most
ff24725192d3 * gud.el: When we send a command to the debugger via gud-call,
Jim Blandy <jimb@redhat.com>
parents: 1255
diff changeset
352 ;;; likely be in the first chunk of output received, so we will delete
ff24725192d3 * gud.el: When we send a command to the debugger via gud-call,
Jim Blandy <jimb@redhat.com>
parents: 1255
diff changeset
353 ;;; the prompt and then replace it with an identical one. If the
ff24725192d3 * gud.el: When we send a command to the debugger via gud-call,
Jim Blandy <jimb@redhat.com>
parents: 1255
diff changeset
354 ;;; command produces output, the prompt is moving anyway, so the
ff24725192d3 * gud.el: When we send a command to the debugger via gud-call,
Jim Blandy <jimb@redhat.com>
parents: 1255
diff changeset
355 ;;; flicker won't be annoying.
ff24725192d3 * gud.el: When we send a command to the debugger via gud-call,
Jim Blandy <jimb@redhat.com>
parents: 1255
diff changeset
356 ;;;
ff24725192d3 * gud.el: When we send a command to the debugger via gud-call,
Jim Blandy <jimb@redhat.com>
parents: 1255
diff changeset
357 ;;; So - when we want to delete the prompt upon receipt of the next
ff24725192d3 * gud.el: When we send a command to the debugger via gud-call,
Jim Blandy <jimb@redhat.com>
parents: 1255
diff changeset
358 ;;; chunk of debugger output, we position gud-delete-prompt-marker at
ff24725192d3 * gud.el: When we send a command to the debugger via gud-call,
Jim Blandy <jimb@redhat.com>
parents: 1255
diff changeset
359 ;;; the start of the prompt; the process filter will notice this, and
ff24725192d3 * gud.el: When we send a command to the debugger via gud-call,
Jim Blandy <jimb@redhat.com>
parents: 1255
diff changeset
360 ;;; delete all text between it and the process output marker. If
ff24725192d3 * gud.el: When we send a command to the debugger via gud-call,
Jim Blandy <jimb@redhat.com>
parents: 1255
diff changeset
361 ;;; gud-delete-prompt-marker points nowhere, we leave the current
ff24725192d3 * gud.el: When we send a command to the debugger via gud-call,
Jim Blandy <jimb@redhat.com>
parents: 1255
diff changeset
362 ;;; prompt alone.
ff24725192d3 * gud.el: When we send a command to the debugger via gud-call,
Jim Blandy <jimb@redhat.com>
parents: 1255
diff changeset
363 (defvar gud-delete-prompt-marker nil)
ff24725192d3 * gud.el: When we send a command to the debugger via gud-call,
Jim Blandy <jimb@redhat.com>
parents: 1255
diff changeset
364
460
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
365
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
366 (defun gud-mode ()
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
367 "Major mode for interacting with an inferior debugger process.
868
0cda1f7b154e *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 810
diff changeset
368
0cda1f7b154e *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 810
diff changeset
369 You start it up with one of the commands M-x gdb, M-x sdb, or
3551
8b5fa2d1755f Doc fixes. Delete local variable list at the end.
Richard M. Stallman <rms@gnu.org>
parents: 3343
diff changeset
370 M-x dbx. Each entry point finishes by executing a hook; `gdb-mode-hook',
8b5fa2d1755f Doc fixes. Delete local variable list at the end.
Richard M. Stallman <rms@gnu.org>
parents: 3343
diff changeset
371 `sdb-mode-hook' or `dbx-mode-hook' respectively.
868
0cda1f7b154e *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 810
diff changeset
372
2489
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
373 After startup, the following commands are available in both the GUD
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
374 interaction buffer and any source buffer GUD visits due to a breakpoint stop
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
375 or step operation:
460
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
376
2489
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
377 \\[gud-break] sets a breakpoint at the current file and line. In the
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
378 GUD buffer, the current file and line are those of the last breakpoint or
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
379 step. In a source buffer, they are the buffer's file and current line.
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
380
2532
17a6b6d079cf (gud-mode): Created C-c synonym bindings in the GUD buffer's local map.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2519
diff changeset
381 \\[gud-remove] removes breakpoints on the current file and line.
17a6b6d079cf (gud-mode): Created C-c synonym bindings in the GUD buffer's local map.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2519
diff changeset
382
2489
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
383 \\[gud-refresh] displays in the source window the last line referred to
868
0cda1f7b154e *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 810
diff changeset
384 in the gud buffer.
460
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
385
2489
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
386 \\[gud-step], \\[gud-next], and \\[gud-stepi] do a step-one-line,
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
387 step-one-line (not entering function calls), and step-one-instruction
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
388 and then update the source window with the current file and position.
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
389 \\[gud-cont] continues execution.
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
390
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
391 \\[gud-print] tries to find the largest C lvalue or function-call expression
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
392 around point, and sends it to the debugger for value display.
460
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
393
2489
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
394 The above commands are common to all supported debuggers.
868
0cda1f7b154e *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 810
diff changeset
395
2489
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
396 Under gdb and sdb, \\[gud-tbreak] behaves exactly like \\[gud-break],
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
397 except that the breakpoint is temporary; that is, it is removed when
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
398 execution stops on it.
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
399
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
400 Under gdb and dbx, \\[gud-up] pops up through an enclosing stack
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
401 frame. \\[gud-down] drops back down through one.
868
0cda1f7b154e *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 810
diff changeset
402
0cda1f7b154e *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 810
diff changeset
403 If you are using gdb, \\[gdb-finish] runs execution to the return from
0cda1f7b154e *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 810
diff changeset
404 the current function and stops.
0cda1f7b154e *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 810
diff changeset
405
3551
8b5fa2d1755f Doc fixes. Delete local variable list at the end.
Richard M. Stallman <rms@gnu.org>
parents: 3343
diff changeset
406 All the keystrokes above are accessible in the GUD buffer
8b5fa2d1755f Doc fixes. Delete local variable list at the end.
Richard M. Stallman <rms@gnu.org>
parents: 3343
diff changeset
407 with the prefix C-c, and in all buffers through the prefix C-x C-a.
2532
17a6b6d079cf (gud-mode): Created C-c synonym bindings in the GUD buffer's local map.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2519
diff changeset
408
2489
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
409 All pre-defined functions for which the concept make sense repeat
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
410 themselves the appropriate number of times if you give a prefix
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
411 argument.
868
0cda1f7b154e *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 810
diff changeset
412
3551
8b5fa2d1755f Doc fixes. Delete local variable list at the end.
Richard M. Stallman <rms@gnu.org>
parents: 3343
diff changeset
413 You may use the `gud-def' macro in the initialization hook to define other
2489
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
414 commands.
868
0cda1f7b154e *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 810
diff changeset
415
0cda1f7b154e *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 810
diff changeset
416 Other commands for interacting with the debugger process are inherited from
0cda1f7b154e *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 810
diff changeset
417 comint mode, which see."
460
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
418 (interactive)
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
419 (comint-mode)
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
420 (setq major-mode 'gud-mode)
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
421 (setq mode-name "Debugger")
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
422 (setq mode-line-process '(": %s"))
2489
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
423 (use-local-map (copy-keymap comint-mode-map))
460
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
424 (make-local-variable 'gud-last-frame)
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
425 (setq gud-last-frame nil)
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
426 (make-local-variable 'comint-prompt-regexp)
1256
ff24725192d3 * gud.el: When we send a command to the debugger via gud-call,
Jim Blandy <jimb@redhat.com>
parents: 1255
diff changeset
427 (make-local-variable 'gud-delete-prompt-marker)
ff24725192d3 * gud.el: When we send a command to the debugger via gud-call,
Jim Blandy <jimb@redhat.com>
parents: 1255
diff changeset
428 (setq gud-delete-prompt-marker (make-marker))
460
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
429 (run-hooks 'gud-mode-hook)
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
430 )
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
431
2489
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
432 (defvar gud-comint-buffer nil)
460
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
433
2489
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
434 (defun gud-common-init (args)
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
435 ;; Perform initializations common to all debuggers
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
436 ;; There *must* be a cleaner way to lex the arglist...
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
437 (let (file i)
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
438 (if (string= args "")
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
439 (setq args nil)
2960
372386917f03 (gud-def): Fix inclusion of the define-key.
Richard M. Stallman <rms@gnu.org>
parents: 2594
diff changeset
440 (save-excursion
372386917f03 (gud-def): Fix inclusion of the define-key.
Richard M. Stallman <rms@gnu.org>
parents: 2594
diff changeset
441 (set-buffer (get-buffer-create "*gud-scratch*"))
372386917f03 (gud-def): Fix inclusion of the define-key.
Richard M. Stallman <rms@gnu.org>
parents: 2594
diff changeset
442 (erase-buffer)
372386917f03 (gud-def): Fix inclusion of the define-key.
Richard M. Stallman <rms@gnu.org>
parents: 2594
diff changeset
443 (insert args)
372386917f03 (gud-def): Fix inclusion of the define-key.
Richard M. Stallman <rms@gnu.org>
parents: 2594
diff changeset
444 (goto-char (point-max))
372386917f03 (gud-def): Fix inclusion of the define-key.
Richard M. Stallman <rms@gnu.org>
parents: 2594
diff changeset
445 (insert "\")")
372386917f03 (gud-def): Fix inclusion of the define-key.
Richard M. Stallman <rms@gnu.org>
parents: 2594
diff changeset
446 (goto-char (point-min))
372386917f03 (gud-def): Fix inclusion of the define-key.
Richard M. Stallman <rms@gnu.org>
parents: 2594
diff changeset
447 (insert "(\"")
372386917f03 (gud-def): Fix inclusion of the define-key.
Richard M. Stallman <rms@gnu.org>
parents: 2594
diff changeset
448 (while (re-search-forward " +" nil t)
372386917f03 (gud-def): Fix inclusion of the define-key.
Richard M. Stallman <rms@gnu.org>
parents: 2594
diff changeset
449 (replace-match "\" \"" nil nil))
372386917f03 (gud-def): Fix inclusion of the define-key.
Richard M. Stallman <rms@gnu.org>
parents: 2594
diff changeset
450 (goto-char (point-min))
372386917f03 (gud-def): Fix inclusion of the define-key.
Richard M. Stallman <rms@gnu.org>
parents: 2594
diff changeset
451 (while (re-search-forward "\"\"" nil t)
372386917f03 (gud-def): Fix inclusion of the define-key.
Richard M. Stallman <rms@gnu.org>
parents: 2594
diff changeset
452 (replace-match "" nil nil))
372386917f03 (gud-def): Fix inclusion of the define-key.
Richard M. Stallman <rms@gnu.org>
parents: 2594
diff changeset
453 (setq args (read (buffer-string)))
372386917f03 (gud-def): Fix inclusion of the define-key.
Richard M. Stallman <rms@gnu.org>
parents: 2594
diff changeset
454 (kill-buffer (current-buffer))))
2489
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
455 (setq i (1- (length args)))
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
456 (while (and (>= i 0) (not (= (aref (nth i args) 0) ?-)))
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
457 (setq file (nth i args)) (setq i (1- i)))
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
458 (let* ((path (expand-file-name file))
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
459 (filepart (file-name-nondirectory path)))
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
460 (switch-to-buffer (concat "*gud-" filepart "*"))
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
461 (setq default-directory (file-name-directory path))
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
462 (or (bolp) (newline))
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
463 (insert "Current directory is " default-directory "\n")
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
464 (gud-debugger-startup filepart args)))
460
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
465 (gud-mode)
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
466 (set-process-filter (get-buffer-process (current-buffer)) 'gud-filter)
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
467 (set-process-sentinel (get-buffer-process (current-buffer)) 'gud-sentinel)
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
468 (gud-set-buffer)
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
469 )
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
470
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
471 (defun gud-set-buffer ()
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
472 (cond ((eq major-mode 'gud-mode)
2489
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
473 (setq gud-comint-buffer (current-buffer)))))
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
474
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
475 ;; These functions are responsible for inserting output from your debugger
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
476 ;; into the buffer. The hard work is done by the method that is
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
477 ;; the value of gud-marker-filter.
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
478
460
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
479 (defun gud-filter (proc string)
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
480 ;; Here's where the actual buffer insertion is done
2489
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
481 (let ((inhibit-quit t))
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
482 (save-excursion
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
483 (set-buffer (process-buffer proc))
2960
372386917f03 (gud-def): Fix inclusion of the define-key.
Richard M. Stallman <rms@gnu.org>
parents: 2594
diff changeset
484 (let (moving output-after-point)
2489
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
485 (save-excursion
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
486 (goto-char (process-mark proc))
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
487 ;; If we have been so requested, delete the debugger prompt.
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
488 (if (marker-buffer gud-delete-prompt-marker)
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
489 (progn
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
490 (delete-region (point) gud-delete-prompt-marker)
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
491 (set-marker gud-delete-prompt-marker nil)))
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
492 (insert-before-markers (gud-marker-filter string))
2960
372386917f03 (gud-def): Fix inclusion of the define-key.
Richard M. Stallman <rms@gnu.org>
parents: 2594
diff changeset
493 (setq moving (= (point) (process-mark proc)))
372386917f03 (gud-def): Fix inclusion of the define-key.
Richard M. Stallman <rms@gnu.org>
parents: 2594
diff changeset
494 (setq output-after-point (< (point) (process-mark proc)))
2489
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
495 ;; Check for a filename-and-line number.
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
496 ;; Don't display the specified file
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
497 ;; unless (1) point is at or after the position where output appears
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
498 ;; and (2) this buffer is on the screen.
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
499 (if (and gud-last-frame
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
500 (not output-after-point)
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
501 (get-buffer-window (current-buffer)))
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
502 (gud-display-frame)))
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
503 (if moving (goto-char (process-mark proc)))))))
460
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
504
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
505 (defun gud-sentinel (proc msg)
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
506 (cond ((null (buffer-name (process-buffer proc)))
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
507 ;; buffer killed
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
508 ;; Stop displaying an arrow in a source file.
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
509 (setq overlay-arrow-position nil)
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
510 (set-process-buffer proc nil))
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
511 ((memq (process-status proc) '(signal exit))
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
512 ;; Stop displaying an arrow in a source file.
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
513 (setq overlay-arrow-position nil)
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
514 ;; Fix the mode line.
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
515 (setq mode-line-process
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
516 (concat ": "
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
517 (symbol-name (process-status proc))))
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
518 (let* ((obuf (current-buffer)))
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
519 ;; save-excursion isn't the right thing if
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
520 ;; process-buffer is current-buffer
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
521 (unwind-protect
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
522 (progn
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
523 ;; Write something in *compilation* and hack its mode line,
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
524 (set-buffer (process-buffer proc))
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
525 ;; Force mode line redisplay soon
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
526 (set-buffer-modified-p (buffer-modified-p))
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
527 (if (eobp)
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
528 (insert ?\n mode-name " " msg)
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
529 (save-excursion
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
530 (goto-char (point-max))
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
531 (insert ?\n mode-name " " msg)))
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
532 ;; If buffer and mode line will show that the process
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
533 ;; is dead, we can delete it now. Otherwise it
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
534 ;; will stay around until M-x list-processes.
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
535 (delete-process proc))
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
536 ;; Restore old buffer, but don't restore old point
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
537 ;; if obuf is the gud buffer.
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
538 (set-buffer obuf))))))
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
539
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
540 (defun gud-display-frame ()
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
541 "Find and obey the last filename-and-line marker from the debugger.
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
542 Obeying it means displaying in another window the specified file and line."
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
543 (interactive)
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
544 (if gud-last-frame
2489
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
545 (progn
460
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
546 (gud-set-buffer)
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
547 (gud-display-line (car gud-last-frame) (cdr gud-last-frame))
3646
4b34cbec2058 * gud.el (gud-last-last-frame): New variable.
Jim Blandy <jimb@redhat.com>
parents: 3591
diff changeset
548 (setq gud-last-last-frame gud-last-frame
4b34cbec2058 * gud.el (gud-last-last-frame): New variable.
Jim Blandy <jimb@redhat.com>
parents: 3591
diff changeset
549 gud-last-frame nil))))
460
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
550
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
551 ;; Make sure the file named TRUE-FILE is in a buffer that appears on the screen
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
552 ;; and that its line LINE is visible.
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
553 ;; Put the overlay-arrow on the line LINE in that buffer.
2489
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
554 ;; Most of the trickiness in here comes from wanting to preserve the current
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
555 ;; region-restriction if that's possible. We use an explicit display-buffer
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
556 ;; to get around the fact that this is called inside a save-excursion.
460
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
557
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
558 (defun gud-display-line (true-file line)
2489
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
559 (let* ((buffer (gud-find-file true-file))
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
560 (window (display-buffer buffer))
460
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
561 (pos))
2960
372386917f03 (gud-def): Fix inclusion of the define-key.
Richard M. Stallman <rms@gnu.org>
parents: 2594
diff changeset
562 ;;; (if (equal buffer (current-buffer))
372386917f03 (gud-def): Fix inclusion of the define-key.
Richard M. Stallman <rms@gnu.org>
parents: 2594
diff changeset
563 ;;; nil
372386917f03 (gud-def): Fix inclusion of the define-key.
Richard M. Stallman <rms@gnu.org>
parents: 2594
diff changeset
564 ;;; (setq buffer-read-only nil))
460
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
565 (save-excursion
2960
372386917f03 (gud-def): Fix inclusion of the define-key.
Richard M. Stallman <rms@gnu.org>
parents: 2594
diff changeset
566 ;;; (setq buffer-read-only t)
460
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
567 (set-buffer buffer)
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
568 (save-restriction
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
569 (widen)
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
570 (goto-line line)
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
571 (setq pos (point))
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
572 (setq overlay-arrow-string "=>")
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
573 (or overlay-arrow-position
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
574 (setq overlay-arrow-position (make-marker)))
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
575 (set-marker overlay-arrow-position (point) (current-buffer)))
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
576 (cond ((or (< pos (point-min)) (> pos (point-max)))
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
577 (widen)
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
578 (goto-char pos))))
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
579 (set-window-point window overlay-arrow-position)))
1256
ff24725192d3 * gud.el: When we send a command to the debugger via gud-call,
Jim Blandy <jimb@redhat.com>
parents: 1255
diff changeset
580
2489
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
581 ;;; The gud-call function must do the right thing whether its invoking
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
582 ;;; keystroke is from the GUD buffer itself (via major-mode binding)
2581
839d67a1dc58 Set no-byte-compile local variable t to work around a byte-compiler bug.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2532
diff changeset
583 ;;; or a C buffer. In the former case, we want to supply data from
839d67a1dc58 Set no-byte-compile local variable t to work around a byte-compiler bug.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2532
diff changeset
584 ;;; gud-last-frame. Here's how we do it:
460
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
585
2489
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
586 (defun gud-format-command (str arg)
2581
839d67a1dc58 Set no-byte-compile local variable t to work around a byte-compiler bug.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2532
diff changeset
587 (let ((insource (not (eq (current-buffer) gud-comint-buffer))))
2489
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
588 (if (string-match "\\(.*\\)%f\\(.*\\)" str)
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
589 (progn
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
590 (setq str (concat
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
591 (substring str (match-beginning 1) (match-end 1))
2594
e1277aec1738 (gud-format-command): Fix %f expansuuin to send ondly the basename of
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2581
diff changeset
592 (file-name-nondirectory (if insource
e1277aec1738 (gud-format-command): Fix %f expansuuin to send ondly the basename of
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2581
diff changeset
593 (buffer-file-name)
e1277aec1738 (gud-format-command): Fix %f expansuuin to send ondly the basename of
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2581
diff changeset
594 (car gud-last-frame)))
2489
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
595 (substring str (match-beginning 2) (match-end 2))))))
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
596 (if (string-match "\\(.*\\)%l\\(.*\\)" str)
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
597 (progn
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
598 (setq str (concat
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
599 (substring str (match-beginning 1) (match-end 1))
2581
839d67a1dc58 Set no-byte-compile local variable t to work around a byte-compiler bug.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2532
diff changeset
600 (if insource
2489
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
601 (save-excursion
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
602 (beginning-of-line)
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
603 (save-restriction (widen)
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
604 (1+ (count-lines 1 (point)))))
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
605 (cdr gud-last-frame))
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
606 (substring str (match-beginning 2) (match-end 2))))))
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
607 (if (string-match "\\(.*\\)%e\\(.*\\)" str)
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
608 (progn
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
609 (setq str (concat
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
610 (substring str (match-beginning 1) (match-end 1))
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
611 (find-c-expr)
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
612 (substring str (match-beginning 2) (match-end 2))))))
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
613 (if (string-match "\\(.*\\)%a\\(.*\\)" str)
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
614 (progn
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
615 (setq str (concat
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
616 (substring str (match-beginning 1) (match-end 1))
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
617 (gud-read-address)
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
618 (substring str (match-beginning 2) (match-end 2))))))
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
619 (if (string-match "\\(.*\\)%p\\(.*\\)" str)
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
620 (progn
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
621 (setq str (concat
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
622 (substring str (match-beginning 1) (match-end 1))
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
623 (if arg (int-to-string arg) "")
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
624 (substring str (match-beginning 2) (match-end 2))))))
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
625 )
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
626 str
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
627 )
460
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
628
1255
ff06503c93b4 * gud.el (gud-def): Doc fix.
Jim Blandy <jimb@redhat.com>
parents: 923
diff changeset
629 (defun gud-read-address ()
460
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
630 "Return a string containing the core-address found in the buffer at point."
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
631 (save-excursion
1255
ff06503c93b4 * gud.el (gud-def): Doc fix.
Jim Blandy <jimb@redhat.com>
parents: 923
diff changeset
632 (let ((pt (point)) found begin)
2489
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
633 (setq found (if (search-backward "0x" (- pt 7) t) (point)))
1255
ff06503c93b4 * gud.el (gud-def): Doc fix.
Jim Blandy <jimb@redhat.com>
parents: 923
diff changeset
634 (cond
ff06503c93b4 * gud.el (gud-def): Doc fix.
Jim Blandy <jimb@redhat.com>
parents: 923
diff changeset
635 (found (forward-char 2)
ff06503c93b4 * gud.el (gud-def): Doc fix.
Jim Blandy <jimb@redhat.com>
parents: 923
diff changeset
636 (buffer-substring found
ff06503c93b4 * gud.el (gud-def): Doc fix.
Jim Blandy <jimb@redhat.com>
parents: 923
diff changeset
637 (progn (re-search-forward "[^0-9a-f]")
ff06503c93b4 * gud.el (gud-def): Doc fix.
Jim Blandy <jimb@redhat.com>
parents: 923
diff changeset
638 (forward-char -1)
ff06503c93b4 * gud.el (gud-def): Doc fix.
Jim Blandy <jimb@redhat.com>
parents: 923
diff changeset
639 (point))))
ff06503c93b4 * gud.el (gud-def): Doc fix.
Jim Blandy <jimb@redhat.com>
parents: 923
diff changeset
640 (t (setq begin (progn (re-search-backward "[^0-9]")
ff06503c93b4 * gud.el (gud-def): Doc fix.
Jim Blandy <jimb@redhat.com>
parents: 923
diff changeset
641 (forward-char 1)
ff06503c93b4 * gud.el (gud-def): Doc fix.
Jim Blandy <jimb@redhat.com>
parents: 923
diff changeset
642 (point)))
ff06503c93b4 * gud.el (gud-def): Doc fix.
Jim Blandy <jimb@redhat.com>
parents: 923
diff changeset
643 (forward-char 1)
ff06503c93b4 * gud.el (gud-def): Doc fix.
Jim Blandy <jimb@redhat.com>
parents: 923
diff changeset
644 (re-search-forward "[^0-9]")
ff06503c93b4 * gud.el (gud-def): Doc fix.
Jim Blandy <jimb@redhat.com>
parents: 923
diff changeset
645 (forward-char -1)
ff06503c93b4 * gud.el (gud-def): Doc fix.
Jim Blandy <jimb@redhat.com>
parents: 923
diff changeset
646 (buffer-substring begin (point)))))))
460
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
647
2489
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
648 (defun gud-call (fmt &optional arg)
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
649 (let ((msg (gud-format-command fmt arg)))
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
650 (message "Command: %s" msg)
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
651 (sit-for 0)
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
652 (gud-basic-call msg)))
460
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
653
2489
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
654 (defun gud-basic-call (command)
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
655 "Invoke the debugger COMMAND displaying source in other window."
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
656 (interactive)
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
657 (gud-set-buffer)
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
658 (let ((command (concat command "\n"))
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
659 (proc (get-buffer-process gud-comint-buffer)))
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
660
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
661 ;; Arrange for the current prompt to get deleted.
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
662 (save-excursion
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
663 (set-buffer gud-comint-buffer)
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
664 (goto-char (process-mark proc))
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
665 (beginning-of-line)
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
666 (if (looking-at comint-prompt-regexp)
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
667 (set-marker gud-delete-prompt-marker (point))))
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
668 (process-send-string proc command)))
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
669
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
670 (defun gud-refresh (&optional arg)
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
671 "Fix up a possibly garbled display, and redraw the arrow."
460
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
672 (interactive "P")
2489
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
673 (recenter arg)
3646
4b34cbec2058 * gud.el (gud-last-last-frame): New variable.
Jim Blandy <jimb@redhat.com>
parents: 3591
diff changeset
674 (or gud-last-frame (setq gud-last-frame gud-last-last-frame))
2489
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
675 (gud-display-frame))
3551
8b5fa2d1755f Doc fixes. Delete local variable list at the end.
Richard M. Stallman <rms@gnu.org>
parents: 3343
diff changeset
676
2489
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
677 ;;; Code for parsing expressions out of C code. The single entry point is
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
678 ;;; find-c-expr, which tries to return an lvalue expression from around point.
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
679 ;;;
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
680 ;;; The rest of this file is a hacked version of gdbsrc.el by
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
681 ;;; Debby Ayers <ayers@asc.slb.com>,
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
682 ;;; Rich Schaefer <schaefer@asc.slb.com> Schlumberger, Austin, Tx.
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
683
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
684 (defun find-c-expr ()
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
685 "Returns the C expr that surrounds point."
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
686 (interactive)
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
687 (save-excursion
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
688 (let ((p) (expr) (test-expr))
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
689 (setq p (point))
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
690 (setq expr (expr-cur))
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
691 (setq test-expr (expr-prev))
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
692 (while (expr-compound test-expr expr)
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
693 (setq expr (cons (car test-expr) (cdr expr)))
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
694 (goto-char (car expr))
3551
8b5fa2d1755f Doc fixes. Delete local variable list at the end.
Richard M. Stallman <rms@gnu.org>
parents: 3343
diff changeset
695 (setq test-expr (expr-prev)))
2489
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
696 (goto-char p)
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
697 (setq test-expr (expr-next))
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
698 (while (expr-compound expr test-expr)
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
699 (setq expr (cons (car expr) (cdr test-expr)))
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
700 (setq test-expr (expr-next))
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
701 )
3551
8b5fa2d1755f Doc fixes. Delete local variable list at the end.
Richard M. Stallman <rms@gnu.org>
parents: 3343
diff changeset
702 (buffer-substring (car expr) (cdr expr)))))
2489
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
703
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
704 (defun expr-cur ()
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
705 "Returns the expr that point is in; point is set to beginning of expr.
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
706 The expr is represented as a cons cell, where the car specifies the point in
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
707 the current buffer that marks the beginning of the expr and the cdr specifies
3551
8b5fa2d1755f Doc fixes. Delete local variable list at the end.
Richard M. Stallman <rms@gnu.org>
parents: 3343
diff changeset
708 the character after the end of the expr."
2489
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
709 (let ((p (point)) (begin) (end))
3551
8b5fa2d1755f Doc fixes. Delete local variable list at the end.
Richard M. Stallman <rms@gnu.org>
parents: 3343
diff changeset
710 (expr-backward-sexp)
2489
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
711 (setq begin (point))
3551
8b5fa2d1755f Doc fixes. Delete local variable list at the end.
Richard M. Stallman <rms@gnu.org>
parents: 3343
diff changeset
712 (expr-forward-sexp)
2489
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
713 (setq end (point))
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
714 (if (>= p end)
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
715 (progn
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
716 (setq begin p)
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
717 (goto-char p)
3551
8b5fa2d1755f Doc fixes. Delete local variable list at the end.
Richard M. Stallman <rms@gnu.org>
parents: 3343
diff changeset
718 (expr-forward-sexp)
2489
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
719 (setq end (point))
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
720 )
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
721 )
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
722 (goto-char begin)
3551
8b5fa2d1755f Doc fixes. Delete local variable list at the end.
Richard M. Stallman <rms@gnu.org>
parents: 3343
diff changeset
723 (cons begin end)))
2489
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
724
3551
8b5fa2d1755f Doc fixes. Delete local variable list at the end.
Richard M. Stallman <rms@gnu.org>
parents: 3343
diff changeset
725 (defun expr-backward-sexp ()
8b5fa2d1755f Doc fixes. Delete local variable list at the end.
Richard M. Stallman <rms@gnu.org>
parents: 3343
diff changeset
726 "Version of `backward-sexp' that catches errors."
2489
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
727 (condition-case nil
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
728 (backward-sexp)
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
729 (error t)))
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
730
3551
8b5fa2d1755f Doc fixes. Delete local variable list at the end.
Richard M. Stallman <rms@gnu.org>
parents: 3343
diff changeset
731 (defun expr-forward-sexp ()
8b5fa2d1755f Doc fixes. Delete local variable list at the end.
Richard M. Stallman <rms@gnu.org>
parents: 3343
diff changeset
732 "Version of `forward-sexp' that catches errors."
2489
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
733 (condition-case nil
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
734 (forward-sexp)
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
735 (error t)))
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
736
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
737 (defun expr-prev ()
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
738 "Returns the previous expr, point is set to beginning of that expr.
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
739 The expr is represented as a cons cell, where the car specifies the point in
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
740 the current buffer that marks the beginning of the expr and the cdr specifies
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
741 the character after the end of the expr"
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
742 (let ((begin) (end))
3551
8b5fa2d1755f Doc fixes. Delete local variable list at the end.
Richard M. Stallman <rms@gnu.org>
parents: 3343
diff changeset
743 (expr-backward-sexp)
2489
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
744 (setq begin (point))
3551
8b5fa2d1755f Doc fixes. Delete local variable list at the end.
Richard M. Stallman <rms@gnu.org>
parents: 3343
diff changeset
745 (expr-forward-sexp)
2489
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
746 (setq end (point))
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
747 (goto-char begin)
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
748 (cons begin end)))
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
749
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
750 (defun expr-next ()
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
751 "Returns the following expr, point is set to beginning of that expr.
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
752 The expr is represented as a cons cell, where the car specifies the point in
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
753 the current buffer that marks the beginning of the expr and the cdr specifies
3551
8b5fa2d1755f Doc fixes. Delete local variable list at the end.
Richard M. Stallman <rms@gnu.org>
parents: 3343
diff changeset
754 the character after the end of the expr."
2489
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
755 (let ((begin) (end))
3551
8b5fa2d1755f Doc fixes. Delete local variable list at the end.
Richard M. Stallman <rms@gnu.org>
parents: 3343
diff changeset
756 (expr-forward-sexp)
8b5fa2d1755f Doc fixes. Delete local variable list at the end.
Richard M. Stallman <rms@gnu.org>
parents: 3343
diff changeset
757 (expr-forward-sexp)
2489
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
758 (setq end (point))
3551
8b5fa2d1755f Doc fixes. Delete local variable list at the end.
Richard M. Stallman <rms@gnu.org>
parents: 3343
diff changeset
759 (expr-backward-sexp)
2489
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
760 (setq begin (point))
3551
8b5fa2d1755f Doc fixes. Delete local variable list at the end.
Richard M. Stallman <rms@gnu.org>
parents: 3343
diff changeset
761 (cons begin end)))
2489
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
762
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
763 (defun expr-compound-sep (span-start span-end)
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
764 "Returns '.' for '->' & '.', returns ' ' for white space,
3591
507f64624555 Apply typo patches from Paul Eggert.
Jim Blandy <jimb@redhat.com>
parents: 3551
diff changeset
765 returns '?' for other punctuation."
2489
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
766 (let ((result ? )
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
767 (syntax))
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
768 (while (< span-start span-end)
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
769 (setq syntax (char-syntax (char-after span-start)))
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
770 (cond
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
771 ((= syntax ? ) t)
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
772 ((= syntax ?.) (setq syntax (char-after span-start))
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
773 (cond
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
774 ((= syntax ?.) (setq result ?.))
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
775 ((and (= syntax ?-) (= (char-after (+ span-start 1)) ?>))
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
776 (setq result ?.)
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
777 (setq span-start (+ span-start 1)))
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
778 (t (setq span-start span-end)
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
779 (setq result ??)))))
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
780 (setq span-start (+ span-start 1)))
3551
8b5fa2d1755f Doc fixes. Delete local variable list at the end.
Richard M. Stallman <rms@gnu.org>
parents: 3343
diff changeset
781 result))
2489
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
782
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
783 (defun expr-compound (first second)
3551
8b5fa2d1755f Doc fixes. Delete local variable list at the end.
Richard M. Stallman <rms@gnu.org>
parents: 3343
diff changeset
784 "Non-nil if concatenating FIRST and SECOND makes a single C token.
8b5fa2d1755f Doc fixes. Delete local variable list at the end.
Richard M. Stallman <rms@gnu.org>
parents: 3343
diff changeset
785 The two exprs are represented as a cons cells, where the car
2489
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
786 specifies the point in the current buffer that marks the beginning of the
3551
8b5fa2d1755f Doc fixes. Delete local variable list at the end.
Richard M. Stallman <rms@gnu.org>
parents: 3343
diff changeset
787 expr and the cdr specifies the character after the end of the expr.
2489
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
788 Link exprs of the form:
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
789 Expr -> Expr
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
790 Expr . Expr
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
791 Expr (Expr)
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
792 Expr [Expr]
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
793 (Expr) Expr
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
794 [Expr] Expr"
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
795 (let ((span-start (cdr first))
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
796 (span-end (car second))
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
797 (syntax))
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
798 (setq syntax (expr-compound-sep span-start span-end))
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
799 (cond
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
800 ((= (car first) (car second)) nil)
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
801 ((= (cdr first) (cdr second)) nil)
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
802 ((= syntax ?.) t)
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
803 ((= syntax ? )
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
804 (setq span-start (char-after (- span-start 1)))
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
805 (setq span-end (char-after span-end))
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
806 (cond
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
807 ((= span-start ?) ) t )
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
808 ((= span-start ?] ) t )
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
809 ((= span-end ?( ) t )
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
810 ((= span-end ?[ ) t )
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
811 (t nil))
b626f5b9a0df Massive changes, amounting nearly to a rewrite. The new features
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1902
diff changeset
812 )
3551
8b5fa2d1755f Doc fixes. Delete local variable list at the end.
Richard M. Stallman <rms@gnu.org>
parents: 3343
diff changeset
813 (t nil))))
2581
839d67a1dc58 Set no-byte-compile local variable t to work around a byte-compiler bug.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2532
diff changeset
814
810
80303373daae *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 806
diff changeset
815 ;;; gud.el ends here