annotate lisp/gud.el @ 2203:12e9bc8a4a7f

* register.el (view-register): Neglect not to avoid failing to properly display all the possible sorts of things one might find in a buffer.
author Jim Blandy <jimb@redhat.com>
date Mon, 15 Mar 1993 09:02:00 +0000
parents 6eb6b48f6bf1
children b626f5b9a0df
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
80303373daae *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 806
diff changeset
3 ;; Author: Eric S. Raymond <eric@snark.thyrsus.com>
80303373daae *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 806
diff changeset
4 ;; Keywords: unix, tools
80303373daae *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 806
diff changeset
5
868
0cda1f7b154e *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 810
diff changeset
6 ;; %W%
810
80303373daae *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 806
diff changeset
7
80303373daae *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 806
diff changeset
8 ;; Copyright (C) 1992 Free Software Foundation, Inc.
460
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
9
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
10 ;; This file is part of GNU Emacs.
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
11
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
12 ;; 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
13 ;; 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
14 ;; 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
15 ;; any later version.
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
16
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
17 ;; 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
18 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
20 ;; GNU General Public License for more details.
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
21
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
22 ;; 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
23 ;; 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
24 ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
25
810
80303373daae *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 806
diff changeset
26 ;;; Commentary:
80303373daae *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 806
diff changeset
27
460
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
28 ;; 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
29 ;; 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
30 ;; 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
31 ;; 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
32 ;; who also hacked the mode to use comint.el.
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
33
810
80303373daae *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 806
diff changeset
34 ;; Note: use of this package with sdb requires that your tags.el support
80303373daae *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 806
diff changeset
35 ;; the find-tag-noselect entry point. Stock distributions up to 18.57 do
80303373daae *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 806
diff changeset
36 ;; *not* include this feature; if it's not included with this file, email
80303373daae *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 806
diff changeset
37 ;; esr@snark.thyrsus.com for it or get 18.58.
80303373daae *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 806
diff changeset
38
80303373daae *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 806
diff changeset
39 ;; Further note: due to lossage in the Emacs-18 byte compiler, compiled
80303373daae *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 806
diff changeset
40 ;; versions of this code will fail with a complaint about gud-step if
80303373daae *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 806
diff changeset
41 ;; you invoke the gdb or sdb initializers. This should be fixed in 19.
80303373daae *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 806
diff changeset
42
80303373daae *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 806
diff changeset
43 ;;; Code:
80303373daae *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 806
diff changeset
44
460
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
45 (require 'comint)
923
9f3cc03dae67 entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 914
diff changeset
46 (require 'etags)
460
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
47
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
48 ;; ======================================================================
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
49 ;; the overloading mechanism
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
50
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
51 (defun gud-overload-functions (gud-overload-alist)
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
52 "Overload functions defined in GUD-OVERLOAD-ALIST.
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
53 This association list has elements of the form
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
54 (ORIGINAL-FUNCTION-NAME OVERLOAD-FUNCTION)"
868
0cda1f7b154e *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 810
diff changeset
55 (mapcar
0cda1f7b154e *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 810
diff changeset
56 (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
57 gud-overload-alist))
460
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
58
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
59 (defun gud-debugger-startup (f d)
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
60 (error "GUD not properly entered."))
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
61
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
62 (defun gud-marker-filter (proc s)
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
63 (error "GUD not properly entered."))
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
64
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
65 (defun gud-visit-file (f)
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
66 (error "GUD not properly entered."))
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
67
1902
6eb6b48f6bf1 * gud.el (gud-break): With a prefix argument, set a temporary
Jim Blandy <jimb@redhat.com>
parents: 1275
diff changeset
68 (defun gud-set-break (proc f n rest)
460
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
69 (error "GUD not properly entered."))
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
70
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
71 ;; 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
72 ;; 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
73 ;; user defined ones.
ff06503c93b4 * gud.el (gud-def): Doc fix.
Jim Blandy <jimb@redhat.com>
parents: 923
diff changeset
74
ff06503c93b4 * gud.el (gud-def): Doc fix.
Jim Blandy <jimb@redhat.com>
parents: 923
diff changeset
75 ;; 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
76 ;; which defines FUNC to send the command NAME to the debugger, gives
ff06503c93b4 * gud.el (gud-def): Doc fix.
Jim Blandy <jimb@redhat.com>
parents: 923
diff changeset
77 ;; it the docstring DOC, and binds that function to KEY. NAME should
ff06503c93b4 * gud.el (gud-def): Doc fix.
Jim Blandy <jimb@redhat.com>
parents: 923
diff changeset
78 ;; be a string. If a numeric prefix argument is given to FUNC, it
ff06503c93b4 * gud.el (gud-def): Doc fix.
Jim Blandy <jimb@redhat.com>
parents: 923
diff changeset
79 ;; gets sent after NAME.
460
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
80
810
80303373daae *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 806
diff changeset
81 (defmacro gud-def (func name key &optional doc)
460
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
82 (let* ((cstr (list 'if '(not (= 1 arg))
1255
ff06503c93b4 * gud.el (gud-def): Doc fix.
Jim Blandy <jimb@redhat.com>
parents: 923
diff changeset
83 (list 'format "%s %s" name 'arg)
ff06503c93b4 * gud.el (gud-def): Doc fix.
Jim Blandy <jimb@redhat.com>
parents: 923
diff changeset
84 name)))
460
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
85 (list 'progn
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
86 (list 'defun func '(arg)
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
87 (or doc "")
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
88 '(interactive "p")
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
89 (list 'gud-call cstr))
914
3122c9756a56 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 889
diff changeset
90 (if key
3122c9756a56 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 889
diff changeset
91 (list 'define-key 'gud-mode-map key (list 'quote func))))))
460
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
92
1275
68f025a5fdaa * gud.el (gud-last-frame): Added defvar for this.
Jim Blandy <jimb@redhat.com>
parents: 1274
diff changeset
93 ;; 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
94 ;; set by the marker-filter, which scans the debugger's output for
68f025a5fdaa * gud.el (gud-last-frame): Added defvar for this.
Jim Blandy <jimb@redhat.com>
parents: 1274
diff changeset
95 ;; indications of the current pc.
68f025a5fdaa * gud.el (gud-last-frame): Added defvar for this.
Jim Blandy <jimb@redhat.com>
parents: 1274
diff changeset
96 (defvar gud-last-frame nil)
68f025a5fdaa * gud.el (gud-last-frame): Added defvar for this.
Jim Blandy <jimb@redhat.com>
parents: 1274
diff changeset
97
460
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
98 ;; All debugger-specific information is collected here
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
99 ;; Here's how it works, in case you ever need to add a debugger to the table.
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
100 ;;
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
101 ;; Each entry must define the following at startup:
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
102 ;;
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
103 ;;<name>
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
104 ;; comint-prompt-regexp
868
0cda1f7b154e *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 810
diff changeset
105 ;; gud-<name>-debugger-startup
460
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
106 ;; gud-<name>-marker-filter
868
0cda1f7b154e *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 810
diff changeset
107 ;; gud-<name>-visit-file
460
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
108 ;; gud-<name>-set-break
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
109 ;;
477
ab9a55b26bd4 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 460
diff changeset
110 ;; The job of the startup-command method is to fire up a copy of the debugger,
ab9a55b26bd4 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 460
diff changeset
111 ;; given an object file and source directory.
ab9a55b26bd4 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 460
diff changeset
112 ;;
ab9a55b26bd4 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 460
diff changeset
113 ;; 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
114 ;; 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
115 ;; action (if any) should be triggered by the marker. Note that only
ab9a55b26bd4 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 460
diff changeset
116 ;; whetever the method *returns* is displayed in the buffer; thus, you
ab9a55b26bd4 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 460
diff changeset
117 ;; can filter the debugger's output, interpreting some and passing on
ab9a55b26bd4 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 460
diff changeset
118 ;; the rest.
ab9a55b26bd4 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 460
diff changeset
119 ;;
ab9a55b26bd4 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 460
diff changeset
120 ;; The job of the visit-file method is to visit and return the buffer indicated
ab9a55b26bd4 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 460
diff changeset
121 ;; 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
122 ;; something else.
ab9a55b26bd4 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 460
diff changeset
123 ;;
1902
6eb6b48f6bf1 * gud.el (gud-break): With a prefix argument, set a temporary
Jim Blandy <jimb@redhat.com>
parents: 1275
diff changeset
124 ;; The job of the gud-set-break method is to send the commands
6eb6b48f6bf1 * gud.el (gud-break): With a prefix argument, set a temporary
Jim Blandy <jimb@redhat.com>
parents: 1275
diff changeset
125 ;; necessary to set a breakpoint at a given line in a given source
6eb6b48f6bf1 * gud.el (gud-break): With a prefix argument, set a temporary
Jim Blandy <jimb@redhat.com>
parents: 1275
diff changeset
126 ;; file. If its third argument TEMP is non-nil, the breakpoint set
6eb6b48f6bf1 * gud.el (gud-break): With a prefix argument, set a temporary
Jim Blandy <jimb@redhat.com>
parents: 1275
diff changeset
127 ;; should be temporary - it should be deleted when it is reached. If
6eb6b48f6bf1 * gud.el (gud-break): With a prefix argument, set a temporary
Jim Blandy <jimb@redhat.com>
parents: 1275
diff changeset
128 ;; the debugger doesn't support such breakpoints, it should set an
6eb6b48f6bf1 * gud.el (gud-break): With a prefix argument, set a temporary
Jim Blandy <jimb@redhat.com>
parents: 1275
diff changeset
129 ;; ordinary breakpoint.
477
ab9a55b26bd4 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 460
diff changeset
130 ;;
ab9a55b26bd4 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 460
diff changeset
131 ;; Debugger-specific information begins here:
460
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
132
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
133 ;; ======================================================================
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
134 ;; gdb functions
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
135
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
136 (defun gud-gdb-debugger-startup (f d)
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
137 (make-comint (concat "gud-" f) "gdb" nil "-fullname" "-cd" d f))
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
138
1255
ff06503c93b4 * gud.el (gud-def): Doc fix.
Jim Blandy <jimb@redhat.com>
parents: 923
diff changeset
139 (defun gud-gdb-marker-filter (proc string)
ff06503c93b4 * gud.el (gud-def): Doc fix.
Jim Blandy <jimb@redhat.com>
parents: 923
diff changeset
140 (if (string-match "\032\032\\([^:\n]*\\):\\([0-9]*\\):.*\n" string)
460
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
141 (progn
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
142 (setq gud-last-frame
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
143 (cons
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
144 (substring string (match-beginning 1) (match-end 1))
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
145 (string-to-int
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
146 (substring string (match-beginning 2) (match-end 2)))))
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
147 ;; this computation means the ^Z^Z-initiated marker in the
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
148 ;; input string is never emitted.
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
149 (concat
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
150 (substring string 0 (match-beginning 0))
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
151 (substring string (match-end 0))
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
152 ))
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
153 string))
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
154
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
155 (defun gud-gdb-visit-file (f)
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
156 (find-file-noselect f))
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
157
1902
6eb6b48f6bf1 * gud.el (gud-break): With a prefix argument, set a temporary
Jim Blandy <jimb@redhat.com>
parents: 1275
diff changeset
158 (defun gud-gdb-set-break (proc f n temp)
6eb6b48f6bf1 * gud.el (gud-break): With a prefix argument, set a temporary
Jim Blandy <jimb@redhat.com>
parents: 1275
diff changeset
159 (gud-call "%s %s:%d" (if temp "tbreak" "break") f n))
460
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
160
477
ab9a55b26bd4 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 460
diff changeset
161 ;;;###autoload
460
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
162 (defun gdb (path)
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
163 "Run gdb on program FILE in buffer *gud-FILE*.
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
164 The directory containing FILE becomes the initial working directory
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
165 and source-file directory for your debugger."
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
166 (interactive "fRun gdb on file: ")
868
0cda1f7b154e *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 810
diff changeset
167 (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
168 (gud-marker-filter . gud-gdb-marker-filter)
0cda1f7b154e *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 810
diff changeset
169 (gud-visit-file . gud-gdb-visit-file)
0cda1f7b154e *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 810
diff changeset
170 (gud-set-break . gud-gdb-set-break)))
460
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
171
889
b2fef2e0c761 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 868
diff changeset
172 (gud-def gud-step "step" "\C-c\C-s" "Step one source line with display")
b2fef2e0c761 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 868
diff changeset
173 (gud-def gud-stepi "stepi" "\C-c\C-i" "Step one instruction with display")
b2fef2e0c761 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 868
diff changeset
174 (gud-def gud-next "next" "\C-c\C-n" "Step one line (skip functions)")
1255
ff06503c93b4 * gud.el (gud-def): Doc fix.
Jim Blandy <jimb@redhat.com>
parents: 923
diff changeset
175 (gud-def gud-cont "cont" "\C-c\C-r" "Continue with display")
460
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
176
810
80303373daae *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 806
diff changeset
177 (gud-def gud-finish "finish" "\C-c\C-f" "Finish executing current function")
80303373daae *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 806
diff changeset
178 (gud-def gud-up "up" "\C-c<" "Up N stack frames (numeric arg)")
80303373daae *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 806
diff changeset
179 (gud-def gud-down "down" "\C-c>" "Down N stack frames (numeric arg)")
460
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
180
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
181 (gud-common-init path)
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
182
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
183 (setq comint-prompt-regexp "^(.*gdb[+]?) *")
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
184 (run-hooks 'gdb-mode-hook)
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
185 )
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
186
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
187
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
188 ;; ======================================================================
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
189 ;; sdb functions
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
190
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
191 (defun gud-sdb-debugger-startup (f d)
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
192 (make-comint (concat "gud-" f) "sdb" nil f "-" d))
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
193
1255
ff06503c93b4 * gud.el (gud-def): Doc fix.
Jim Blandy <jimb@redhat.com>
parents: 923
diff changeset
194 (defun gud-sdb-marker-filter (proc string)
460
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
195 (if (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
196 string)
460
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
197 (setq gud-last-frame
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
198 (cons
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
199 (substring string (match-beginning 2) (match-end 2))
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
200 (string-to-int
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
201 (substring string (match-beginning 3) (match-end 3))))))
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
202 string)
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
203
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
204 (defun gud-sdb-visit-file (f)
868
0cda1f7b154e *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 810
diff changeset
205 (find-tag-noselect f))
460
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
206
1902
6eb6b48f6bf1 * gud.el (gud-break): With a prefix argument, set a temporary
Jim Blandy <jimb@redhat.com>
parents: 1275
diff changeset
207 ;;; We'll just ignore the TEMP argument for now; I don't know how to
6eb6b48f6bf1 * gud.el (gud-break): With a prefix argument, set a temporary
Jim Blandy <jimb@redhat.com>
parents: 1275
diff changeset
208 ;;; set temporary breakpoints in sdb. (See the description of the
6eb6b48f6bf1 * gud.el (gud-break): With a prefix argument, set a temporary
Jim Blandy <jimb@redhat.com>
parents: 1275
diff changeset
209 ;;; gud-set-break method for details.)
6eb6b48f6bf1 * gud.el (gud-break): With a prefix argument, set a temporary
Jim Blandy <jimb@redhat.com>
parents: 1275
diff changeset
210 (defun gud-sdb-set-break (proc f n temp)
460
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
211 (gud-queue-send (format "e %s" f) (format "%d b" n)))
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
212
477
ab9a55b26bd4 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 460
diff changeset
213 ;;;###autoload
460
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
214 (defun sdb (path)
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
215 "Run sdb on program FILE in buffer *gud-FILE*.
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
216 The directory containing FILE becomes the initial working directory
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
217 and source-file directory for your debugger."
923
9f3cc03dae67 entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 914
diff changeset
218 (interactive "fRun sdb on file: ")
460
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
219 (if (not (and (boundp 'tags-file-name) (file-exists-p tags-file-name)))
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
220 (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
221 (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
222 (gud-marker-filter . gud-sdb-marker-filter)
0cda1f7b154e *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 810
diff changeset
223 (gud-visit-file . gud-sdb-visit-file)
0cda1f7b154e *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 810
diff changeset
224 (gud-set-break . gud-sdb-set-break)))
460
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
225
889
b2fef2e0c761 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 868
diff changeset
226 (gud-def gud-step "s" "\C-c\C-s" "Step one source line with display")
b2fef2e0c761 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 868
diff changeset
227 (gud-def gud-stepi "i" "\C-c\C-i" "Step one instruction with display")
b2fef2e0c761 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 868
diff changeset
228 (gud-def gud-next "S" "\C-c\C-n" "Step one source line (skip functions)")
1255
ff06503c93b4 * gud.el (gud-def): Doc fix.
Jim Blandy <jimb@redhat.com>
parents: 923
diff changeset
229 (gud-def gud-cont "c" "\C-c\C-r" "Continue with display (`resume')")
460
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
230
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
231 (gud-common-init path)
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
232
1255
ff06503c93b4 * gud.el (gud-def): Doc fix.
Jim Blandy <jimb@redhat.com>
parents: 923
diff changeset
233 (setq comint-prompt-regexp "\\(^\\|\n\\)\\*")
460
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
234 (run-hooks 'sdb-mode-hook)
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
235 )
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
236
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
237 ;; ======================================================================
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
238 ;; dbx functions
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
239
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
240 (defun gud-dbx-debugger-startup (f d)
1255
ff06503c93b4 * gud.el (gud-def): Doc fix.
Jim Blandy <jimb@redhat.com>
parents: 923
diff changeset
241 (make-comint (concat "gud-" f) "dbx" nil f))
460
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
242
1255
ff06503c93b4 * gud.el (gud-def): Doc fix.
Jim Blandy <jimb@redhat.com>
parents: 923
diff changeset
243 (defun gud-dbx-marker-filter (proc string)
460
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
244 (if (string-match
1255
ff06503c93b4 * gud.el (gud-def): Doc fix.
Jim Blandy <jimb@redhat.com>
parents: 923
diff changeset
245 "stopped in .* at line \\([0-9]*\\) in file \"\\([^\"]*\\)\"" string)
460
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
246 (setq gud-last-frame
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
247 (cons
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
248 (substring string (match-beginning 2) (match-end 2))
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
249 (string-to-int
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
250 (substring string (match-beginning 1) (match-end 1))))))
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
251 string)
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
252
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
253 (defun gud-dbx-visit-file (f)
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
254 (find-file-noselect f))
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
255
1902
6eb6b48f6bf1 * gud.el (gud-break): With a prefix argument, set a temporary
Jim Blandy <jimb@redhat.com>
parents: 1275
diff changeset
256 ;;; We'll just ignore the TEMP argument for now; I don't know how to
6eb6b48f6bf1 * gud.el (gud-break): With a prefix argument, set a temporary
Jim Blandy <jimb@redhat.com>
parents: 1275
diff changeset
257 ;;; set temporary breakpoints in dbx. (See the description of the
6eb6b48f6bf1 * gud.el (gud-break): With a prefix argument, set a temporary
Jim Blandy <jimb@redhat.com>
parents: 1275
diff changeset
258 ;;; gud-set-break method for details.)
6eb6b48f6bf1 * gud.el (gud-break): With a prefix argument, set a temporary
Jim Blandy <jimb@redhat.com>
parents: 1275
diff changeset
259 (defun gud-dbx-set-break (proc f n temp)
460
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
260 (gud-call "stop at \"%s\":%d" f n))
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
261
477
ab9a55b26bd4 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 460
diff changeset
262 ;;;###autoload
460
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
263 (defun dbx (path)
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
264 "Run dbx on program FILE in buffer *gud-FILE*.
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
265 The directory containing FILE becomes the initial working directory
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
266 and source-file directory for your debugger."
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
267 (interactive "fRun dbx on file: ")
868
0cda1f7b154e *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 810
diff changeset
268 (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
269 (gud-marker-filter . gud-dbx-marker-filter)
0cda1f7b154e *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 810
diff changeset
270 (gud-visit-file . gud-dbx-visit-file)
0cda1f7b154e *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 810
diff changeset
271 (gud-set-break . gud-dbx-set-break)))
0cda1f7b154e *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 810
diff changeset
272
889
b2fef2e0c761 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 868
diff changeset
273 (gud-def gud-step "step" "\C-c\C-s" "Step one source line with display")
b2fef2e0c761 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 868
diff changeset
274 (gud-def gud-stepi "stepi" "\C-c\C-i" "Step one instruction with display")
b2fef2e0c761 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 868
diff changeset
275 (gud-def gud-next "next" "\C-c\C-n" "Step one line (skip functions)")
1255
ff06503c93b4 * gud.el (gud-def): Doc fix.
Jim Blandy <jimb@redhat.com>
parents: 923
diff changeset
276 (gud-def gud-cont "cont" "\C-c\C-r" "Continue with display (`resume')")
868
0cda1f7b154e *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 810
diff changeset
277
0cda1f7b154e *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 810
diff changeset
278 (gud-def gud-up "up" "\C-c<" "Up N stack frames (numeric arg)")
0cda1f7b154e *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 810
diff changeset
279 (gud-def gud-down "down" "\C-c>" "Down N stack frames (numeric arg)")
460
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
280
810
80303373daae *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 806
diff changeset
281 (gud-common-init path)
460
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
282 (setq comint-prompt-regexp "^[^)]*dbx) *")
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
283
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
284 (run-hooks 'dbx-mode-hook)
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
285 )
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
286
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
287 ;;
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
288 ;; End of debugger-specific information
477
ab9a55b26bd4 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 460
diff changeset
289 ;;
460
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
290
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
291 (defvar gud-mode-map nil
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
292 "Keymap for gud-mode.")
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
293
868
0cda1f7b154e *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 810
diff changeset
294 (defvar gud-commands nil
0cda1f7b154e *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 810
diff changeset
295 "List of strings or functions used by send-gud-command.
0cda1f7b154e *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 810
diff changeset
296 It is for customization by you.")
0cda1f7b154e *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 810
diff changeset
297
460
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
298 (defvar gud-command-queue nil)
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
299
1256
ff24725192d3 * gud.el: When we send a command to the debugger via gud-call,
Jim Blandy <jimb@redhat.com>
parents: 1255
diff changeset
300 ;;; 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
301 ;;; 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
302 ;;; 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
303 ;;;
ff24725192d3 * gud.el: When we send a command to the debugger via gud-call,
Jim Blandy <jimb@redhat.com>
parents: 1255
diff changeset
304 ;;; 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
305 ;;; --------------------
ff24725192d3 * gud.el: When we send a command to the debugger via gud-call,
Jim Blandy <jimb@redhat.com>
parents: 1255
diff changeset
306 ;;; (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
307 ;;; (gdb) -!-
ff24725192d3 * gud.el: When we send a command to the debugger via gud-call,
Jim Blandy <jimb@redhat.com>
parents: 1255
diff changeset
308 ;;; --------------------
ff24725192d3 * gud.el: When we send a command to the debugger via gud-call,
Jim Blandy <jimb@redhat.com>
parents: 1255
diff changeset
309 ;;; (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
310 ;;; 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
311 ;;; this:
ff24725192d3 * gud.el: When we send a command to the debugger via gud-call,
Jim Blandy <jimb@redhat.com>
parents: 1255
diff changeset
312 ;;; --------------------
ff24725192d3 * gud.el: When we send a command to the debugger via gud-call,
Jim Blandy <jimb@redhat.com>
parents: 1255
diff changeset
313 ;;; (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
314 ;;; 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
315 ;;; (gdb) -!-
ff24725192d3 * gud.el: When we send a command to the debugger via gud-call,
Jim Blandy <jimb@redhat.com>
parents: 1255
diff changeset
316 ;;; --------------------
ff24725192d3 * gud.el: When we send a command to the debugger via gud-call,
Jim Blandy <jimb@redhat.com>
parents: 1255
diff changeset
317 ;;; 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
318 ;;; 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
319 ;;;
ff24725192d3 * gud.el: When we send a command to the debugger via gud-call,
Jim Blandy <jimb@redhat.com>
parents: 1255
diff changeset
320 ;;; 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
321 ;;; 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
322 ;;; 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
323 ;;; 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
324 ;;; 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
325 ;;; 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
326 ;;; 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
327 ;;; 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
328 ;;; 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
329 ;;; 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
330 ;;; 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
331 ;;; 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
332 ;;; 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
333 ;;;
ff24725192d3 * gud.el: When we send a command to the debugger via gud-call,
Jim Blandy <jimb@redhat.com>
parents: 1255
diff changeset
334 ;;; 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
335 ;;; 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
336 ;;; 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
337 ;;; 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
338 ;;; 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
339 ;;; 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
340 (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
341
460
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
342 (if gud-mode-map
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
343 nil
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
344 (setq gud-mode-map (copy-keymap comint-mode-map))
1255
ff06503c93b4 * gud.el (gud-def): Doc fix.
Jim Blandy <jimb@redhat.com>
parents: 923
diff changeset
345 (define-key gud-mode-map "\C-c\C-l" 'gud-refresh))
460
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
346
868
0cda1f7b154e *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 810
diff changeset
347 ;; Global mappings --- we'll invoke these from a source buffer.
460
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
348 (define-key ctl-x-map " " 'gud-break)
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
349 (define-key ctl-x-map "&" 'send-gud-command)
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
350
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
351
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
352 (defun gud-mode ()
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
353 "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
354
0cda1f7b154e *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 810
diff changeset
355 You start it up with one of the commands M-x gdb, M-x sdb, or
0cda1f7b154e *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 810
diff changeset
356 M-x dbx. Each entry point finishes by executing a hook; gdb-mode-hook,
0cda1f7b154e *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 810
diff changeset
357 sdb-mode-hook or dbx-mode-hook respectively.
0cda1f7b154e *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 810
diff changeset
358
0cda1f7b154e *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 810
diff changeset
359 After startup, the following commands are available:
460
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
360
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
361 \\{gud-mode-map}
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
362
868
0cda1f7b154e *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 810
diff changeset
363 \\[gud-refresh] displays in the other window the last line referred to
0cda1f7b154e *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 810
diff changeset
364 in the gud buffer.
460
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
365
868
0cda1f7b154e *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 810
diff changeset
366 \\[gud-step], \\[gud-next], and \\[gud-stepi] in the gud window,
460
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
367 do a step-one-line, step-one-line (not entering function calls), and
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
368 step-one-instruction and then update the other window
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
369 with the current file and position. \\[gud-cont] continues
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
370 execution.
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
371
868
0cda1f7b154e *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 810
diff changeset
372 The above commands are common to all supported debuggers. If you are
0cda1f7b154e *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 810
diff changeset
373 using gdb or dbx, the following additional commands will be available:
0cda1f7b154e *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 810
diff changeset
374
0cda1f7b154e *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 810
diff changeset
375 \\[gud-up] pops up through an enclosing stack frame. \\[gud-down] drops
0cda1f7b154e *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 810
diff changeset
376 back down through one.
0cda1f7b154e *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 810
diff changeset
377
0cda1f7b154e *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 810
diff changeset
378 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
379 the current function and stops.
0cda1f7b154e *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 810
diff changeset
380
0cda1f7b154e *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 810
diff changeset
381 These functions repeat themselves the appropriate number of times if you give a
0cda1f7b154e *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 810
diff changeset
382 prefix argument.
460
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
383
868
0cda1f7b154e *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 810
diff changeset
384 If you are in a source file, you may do the following:
0cda1f7b154e *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 810
diff changeset
385
0cda1f7b154e *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 810
diff changeset
386 Set a breakpoint at the current line by doing \\[gud-break]. This causes
0cda1f7b154e *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 810
diff changeset
387 an appropriate set-break to be send to the debugger; of course, if the file
0cda1f7b154e *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 810
diff changeset
388 you're visiting doesn't correspond to any code in the executable this will
0cda1f7b154e *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 810
diff changeset
389 have no effect or raise an error.
460
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
390
868
0cda1f7b154e *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 810
diff changeset
391 Execute a user-defined command at point with \\[send-gud-command]; the
0cda1f7b154e *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 810
diff changeset
392 prefix argument is taken as an index into the list of strings gud-commands.
0cda1f7b154e *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 810
diff changeset
393 A %s in a gud-commands string is substituted with a number or address picked
0cda1f7b154e *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 810
diff changeset
394 up from point.
0cda1f7b154e *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 810
diff changeset
395
0cda1f7b154e *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 810
diff changeset
396 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
397 comint mode, which see."
460
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
398 (interactive)
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
399 (comint-mode)
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
400 ; (kill-all-local-variables)
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
401 (setq major-mode 'gud-mode)
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
402 (setq mode-name "Debugger")
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
403 (setq mode-line-process '(": %s"))
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
404 (use-local-map gud-mode-map)
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
405 (make-local-variable 'gud-last-frame)
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
406 (setq gud-last-frame nil)
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
407 (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
408 (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
409 (setq gud-delete-prompt-marker (make-marker))
460
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
410 (run-hooks 'gud-mode-hook)
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
411 )
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
412
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
413 (defvar current-gud-buffer nil)
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
414
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
415 (defun gud-common-init (path)
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
416 ;; perform initializations common to all debuggers
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
417 (setq path (expand-file-name path))
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
418 (let ((file (file-name-nondirectory path)))
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
419 (switch-to-buffer (concat "*gud-" file "*"))
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
420 (setq default-directory (file-name-directory path))
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
421 (or (bolp) (newline))
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
422 (insert "Current directory is " default-directory "\n")
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
423 (gud-debugger-startup file default-directory))
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
424 (gud-mode)
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
425 (set-process-filter (get-buffer-process (current-buffer)) 'gud-filter)
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
426 (set-process-sentinel (get-buffer-process (current-buffer)) 'gud-sentinel)
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
427 (setq gud-command-queue nil)
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
428 (gud-set-buffer)
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
429 )
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 (defun gud-set-buffer ()
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
432 (cond ((eq major-mode 'gud-mode)
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
433 (setq current-gud-buffer (current-buffer)))))
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
434
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
435 (defun gud-filter (proc string)
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
436 ;; This function is responsible for inserting output from your debugger
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
437 ;; into the buffer. The hard work is done by the method that is
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
438 ;; the value of gud-marker-filter.
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
439 (let ((inhibit-quit t))
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
440 (gud-filter-insert proc (gud-marker-filter proc string))
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
441 ;; If we've got queued commands and we see a prompt, pop one and send it.
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
442 ;; In theory we should check that a prompt has been issued before sending
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
443 ;; queued commands. In practice, command responses from the first through
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
444 ;; penultimate elements of a command sequence are short enough that we
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
445 ;; don't really have to bother.
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
446 (if gud-command-queue
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
447 (progn
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
448 (gud-call (car gud-command-queue))
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
449 (setq gud-command-queue (cdr gud-command-queue))
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
450 )
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
451 )))
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
452
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
453 (defun gud-filter-insert (proc string)
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
454 ;; Here's where the actual buffer insertion is done
1255
ff06503c93b4 * gud.el (gud-def): Doc fix.
Jim Blandy <jimb@redhat.com>
parents: 923
diff changeset
455 (save-excursion
460
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
456 (set-buffer (process-buffer proc))
1274
4d867d1bedda * gud.el (gud-filter-insert): Previous changes misunderstood
Jim Blandy <jimb@redhat.com>
parents: 1257
diff changeset
457 (let ((moving (= (point) (process-mark proc)))
4d867d1bedda * gud.el (gud-filter-insert): Previous changes misunderstood
Jim Blandy <jimb@redhat.com>
parents: 1257
diff changeset
458 (output-after-point (< (point) (process-mark proc))))
4d867d1bedda * gud.el (gud-filter-insert): Previous changes misunderstood
Jim Blandy <jimb@redhat.com>
parents: 1257
diff changeset
459 (save-excursion
4d867d1bedda * gud.el (gud-filter-insert): Previous changes misunderstood
Jim Blandy <jimb@redhat.com>
parents: 1257
diff changeset
460 (goto-char (process-mark proc))
4d867d1bedda * gud.el (gud-filter-insert): Previous changes misunderstood
Jim Blandy <jimb@redhat.com>
parents: 1257
diff changeset
461 ;; If we have been so requested, delete the debugger prompt.
4d867d1bedda * gud.el (gud-filter-insert): Previous changes misunderstood
Jim Blandy <jimb@redhat.com>
parents: 1257
diff changeset
462 (if (marker-buffer gud-delete-prompt-marker)
4d867d1bedda * gud.el (gud-filter-insert): Previous changes misunderstood
Jim Blandy <jimb@redhat.com>
parents: 1257
diff changeset
463 (progn
4d867d1bedda * gud.el (gud-filter-insert): Previous changes misunderstood
Jim Blandy <jimb@redhat.com>
parents: 1257
diff changeset
464 (delete-region (point) gud-delete-prompt-marker)
4d867d1bedda * gud.el (gud-filter-insert): Previous changes misunderstood
Jim Blandy <jimb@redhat.com>
parents: 1257
diff changeset
465 (set-marker gud-delete-prompt-marker nil)))
4d867d1bedda * gud.el (gud-filter-insert): Previous changes misunderstood
Jim Blandy <jimb@redhat.com>
parents: 1257
diff changeset
466 (insert-before-markers string)
4d867d1bedda * gud.el (gud-filter-insert): Previous changes misunderstood
Jim Blandy <jimb@redhat.com>
parents: 1257
diff changeset
467 ;; Check for a filename-and-line number.
4d867d1bedda * gud.el (gud-filter-insert): Previous changes misunderstood
Jim Blandy <jimb@redhat.com>
parents: 1257
diff changeset
468 ;; Don't display the specified file
4d867d1bedda * gud.el (gud-filter-insert): Previous changes misunderstood
Jim Blandy <jimb@redhat.com>
parents: 1257
diff changeset
469 ;; unless (1) point is at or after the position where output appears
4d867d1bedda * gud.el (gud-filter-insert): Previous changes misunderstood
Jim Blandy <jimb@redhat.com>
parents: 1257
diff changeset
470 ;; and (2) this buffer is on the screen.
4d867d1bedda * gud.el (gud-filter-insert): Previous changes misunderstood
Jim Blandy <jimb@redhat.com>
parents: 1257
diff changeset
471 (if (and gud-last-frame
4d867d1bedda * gud.el (gud-filter-insert): Previous changes misunderstood
Jim Blandy <jimb@redhat.com>
parents: 1257
diff changeset
472 (not output-after-point)
4d867d1bedda * gud.el (gud-filter-insert): Previous changes misunderstood
Jim Blandy <jimb@redhat.com>
parents: 1257
diff changeset
473 (get-buffer-window (current-buffer)))
4d867d1bedda * gud.el (gud-filter-insert): Previous changes misunderstood
Jim Blandy <jimb@redhat.com>
parents: 1257
diff changeset
474 (gud-display-frame)))
4d867d1bedda * gud.el (gud-filter-insert): Previous changes misunderstood
Jim Blandy <jimb@redhat.com>
parents: 1257
diff changeset
475 (if moving (goto-char (process-mark proc))))))
460
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
476
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
477 (defun gud-sentinel (proc msg)
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
478 (cond ((null (buffer-name (process-buffer proc)))
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
479 ;; buffer killed
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
480 ;; Stop displaying an arrow in a source file.
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
481 (setq overlay-arrow-position nil)
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
482 (set-process-buffer proc nil))
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
483 ((memq (process-status proc) '(signal exit))
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
484 ;; Stop displaying an arrow in a source file.
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
485 (setq overlay-arrow-position nil)
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
486 ;; Fix the mode line.
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
487 (setq mode-line-process
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
488 (concat ": "
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
489 (symbol-name (process-status proc))))
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
490 (let* ((obuf (current-buffer)))
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
491 ;; save-excursion isn't the right thing if
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
492 ;; process-buffer is current-buffer
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
493 (unwind-protect
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
494 (progn
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
495 ;; Write something in *compilation* and hack its mode line,
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
496 (set-buffer (process-buffer proc))
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
497 ;; Force mode line redisplay soon
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
498 (set-buffer-modified-p (buffer-modified-p))
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
499 (if (eobp)
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
500 (insert ?\n mode-name " " msg)
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
501 (save-excursion
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
502 (goto-char (point-max))
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
503 (insert ?\n mode-name " " msg)))
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
504 ;; If buffer and mode line will show that the process
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
505 ;; is dead, we can delete it now. Otherwise it
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
506 ;; will stay around until M-x list-processes.
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
507 (delete-process proc))
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
508 ;; Restore old buffer, but don't restore old point
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
509 ;; if obuf is the gud buffer.
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
510 (set-buffer obuf))))))
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
511
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
512
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
513 (defun gud-refresh (&optional arg)
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
514 "Fix up a possibly garbled display, and redraw the arrow."
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
515 (interactive "P")
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
516 (recenter arg)
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
517 (gud-display-frame))
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
518
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
519 (defun gud-display-frame ()
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
520 "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
521 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
522 (interactive)
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
523 (if gud-last-frame
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
524 (progn
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
525 (gud-set-buffer)
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
526 (gud-display-line (car gud-last-frame) (cdr gud-last-frame))
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
527 (setq gud-last-frame nil))))
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
528
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
529 ;; 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
530 ;; and that its line LINE is visible.
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
531 ;; Put the overlay-arrow on the line LINE in that buffer.
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
532
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
533 (defun gud-display-line (true-file line)
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
534 (let* ((buffer (gud-visit-file true-file))
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
535 (window (display-buffer buffer t))
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
536 (pos))
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
537 (save-excursion
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
538 (set-buffer buffer)
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
539 (save-restriction
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
540 (widen)
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
541 (goto-line line)
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
542 (setq pos (point))
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
543 (setq overlay-arrow-string "=>")
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
544 (or overlay-arrow-position
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
545 (setq overlay-arrow-position (make-marker)))
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
546 (set-marker overlay-arrow-position (point) (current-buffer)))
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
547 (cond ((or (< pos (point-min)) (> pos (point-max)))
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
548 (widen)
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
549 (goto-char pos))))
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
550 (set-window-point window overlay-arrow-position)))
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
551
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
552 (defun gud-call (command &rest args)
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
553 "Invoke the debugger COMMAND displaying source in other window."
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
554 (interactive)
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
555 (gud-set-buffer)
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
556 (let ((command (concat (apply 'format command args) "\n"))
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
557 (proc (get-buffer-process current-gud-buffer)))
1256
ff24725192d3 * gud.el: When we send a command to the debugger via gud-call,
Jim Blandy <jimb@redhat.com>
parents: 1255
diff changeset
558
ff24725192d3 * gud.el: When we send a command to the debugger via gud-call,
Jim Blandy <jimb@redhat.com>
parents: 1255
diff changeset
559 ;; Arrange for the current prompt to get deleted.
ff24725192d3 * gud.el: When we send a command to the debugger via gud-call,
Jim Blandy <jimb@redhat.com>
parents: 1255
diff changeset
560 (save-excursion
ff24725192d3 * gud.el: When we send a command to the debugger via gud-call,
Jim Blandy <jimb@redhat.com>
parents: 1255
diff changeset
561 (set-buffer current-gud-buffer)
1257
e712192d20f5 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 1256
diff changeset
562 (goto-char (process-mark proc))
1256
ff24725192d3 * gud.el: When we send a command to the debugger via gud-call,
Jim Blandy <jimb@redhat.com>
parents: 1255
diff changeset
563 (beginning-of-line)
ff24725192d3 * gud.el: When we send a command to the debugger via gud-call,
Jim Blandy <jimb@redhat.com>
parents: 1255
diff changeset
564 (if (looking-at comint-prompt-regexp)
ff24725192d3 * gud.el: When we send a command to the debugger via gud-call,
Jim Blandy <jimb@redhat.com>
parents: 1255
diff changeset
565 (set-marker gud-delete-prompt-marker (point))))
ff24725192d3 * gud.el: When we send a command to the debugger via gud-call,
Jim Blandy <jimb@redhat.com>
parents: 1255
diff changeset
566
ff24725192d3 * gud.el: When we send a command to the debugger via gud-call,
Jim Blandy <jimb@redhat.com>
parents: 1255
diff changeset
567 (goto-char (point-max))
ff24725192d3 * gud.el: When we send a command to the debugger via gud-call,
Jim Blandy <jimb@redhat.com>
parents: 1255
diff changeset
568 (process-send-string proc command)))
460
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
569
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
570 (defun gud-queue-send (&rest cmdlist)
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
571 ;; Send the first command, queue the rest for send after successive
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
572 ;; send on subsequent prompts
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
573 (interactive)
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
574 (gud-call (car cmdlist))
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
575 (setq gud-command-queue (append gud-command-queue (cdr cmdlist))))
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
576
1902
6eb6b48f6bf1 * gud.el (gud-break): With a prefix argument, set a temporary
Jim Blandy <jimb@redhat.com>
parents: 1275
diff changeset
577 (defun gud-apply-from-source (func &rest args)
6eb6b48f6bf1 * gud.el (gud-break): With a prefix argument, set a temporary
Jim Blandy <jimb@redhat.com>
parents: 1275
diff changeset
578 ;; Apply a method from the gud buffer environment, passing it file
6eb6b48f6bf1 * gud.el (gud-break): With a prefix argument, set a temporary
Jim Blandy <jimb@redhat.com>
parents: 1275
diff changeset
579 ;; and line, then ARGS. This is intended to be used for gud
6eb6b48f6bf1 * gud.el (gud-break): With a prefix argument, set a temporary
Jim Blandy <jimb@redhat.com>
parents: 1275
diff changeset
580 ;; commands called from a source file.
460
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
581 (if (not buffer-file-name)
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
582 (error "There is no file associated with this buffer"))
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
583 (let ((file (file-name-nondirectory buffer-file-name))
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
584 (line (save-restriction (widen) (1+ (count-lines 1 (point))))))
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
585 (save-excursion
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
586 (gud-set-buffer)
1902
6eb6b48f6bf1 * gud.el (gud-break): With a prefix argument, set a temporary
Jim Blandy <jimb@redhat.com>
parents: 1275
diff changeset
587 (apply func
6eb6b48f6bf1 * gud.el (gud-break): With a prefix argument, set a temporary
Jim Blandy <jimb@redhat.com>
parents: 1275
diff changeset
588 (get-buffer-process current-gud-buffer)
6eb6b48f6bf1 * gud.el (gud-break): With a prefix argument, set a temporary
Jim Blandy <jimb@redhat.com>
parents: 1275
diff changeset
589 file
6eb6b48f6bf1 * gud.el (gud-break): With a prefix argument, set a temporary
Jim Blandy <jimb@redhat.com>
parents: 1275
diff changeset
590 line
6eb6b48f6bf1 * gud.el (gud-break): With a prefix argument, set a temporary
Jim Blandy <jimb@redhat.com>
parents: 1275
diff changeset
591 args)
460
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
592 )))
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
593
1902
6eb6b48f6bf1 * gud.el (gud-break): With a prefix argument, set a temporary
Jim Blandy <jimb@redhat.com>
parents: 1275
diff changeset
594 (defun gud-break (arg)
6eb6b48f6bf1 * gud.el (gud-break): With a prefix argument, set a temporary
Jim Blandy <jimb@redhat.com>
parents: 1275
diff changeset
595 "Set breakpoint at this source line.
6eb6b48f6bf1 * gud.el (gud-break): With a prefix argument, set a temporary
Jim Blandy <jimb@redhat.com>
parents: 1275
diff changeset
596 With prefix argument, set a temporary breakpoint, if the debugger in
6eb6b48f6bf1 * gud.el (gud-break): With a prefix argument, set a temporary
Jim Blandy <jimb@redhat.com>
parents: 1275
diff changeset
597 use supports such things. (A temporary breakpoint is one which will
6eb6b48f6bf1 * gud.el (gud-break): With a prefix argument, set a temporary
Jim Blandy <jimb@redhat.com>
parents: 1275
diff changeset
598 be deleted when it is reached.)"
6eb6b48f6bf1 * gud.el (gud-break): With a prefix argument, set a temporary
Jim Blandy <jimb@redhat.com>
parents: 1275
diff changeset
599 (interactive "P")
6eb6b48f6bf1 * gud.el (gud-break): With a prefix argument, set a temporary
Jim Blandy <jimb@redhat.com>
parents: 1275
diff changeset
600 (gud-apply-from-source 'gud-set-break arg))
460
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
601
1255
ff06503c93b4 * gud.el (gud-def): Doc fix.
Jim Blandy <jimb@redhat.com>
parents: 923
diff changeset
602 (defun gud-read-address ()
460
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
603 "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
604 (save-excursion
1255
ff06503c93b4 * gud.el (gud-def): Doc fix.
Jim Blandy <jimb@redhat.com>
parents: 923
diff changeset
605 (let ((pt (point)) found begin)
ff06503c93b4 * gud.el (gud-def): Doc fix.
Jim Blandy <jimb@redhat.com>
parents: 923
diff changeset
606 (setq found (if (search-backward "0x" (- pt 7) t)(point)))
ff06503c93b4 * gud.el (gud-def): Doc fix.
Jim Blandy <jimb@redhat.com>
parents: 923
diff changeset
607 (cond
ff06503c93b4 * gud.el (gud-def): Doc fix.
Jim Blandy <jimb@redhat.com>
parents: 923
diff changeset
608 (found (forward-char 2)
ff06503c93b4 * gud.el (gud-def): Doc fix.
Jim Blandy <jimb@redhat.com>
parents: 923
diff changeset
609 (buffer-substring found
ff06503c93b4 * gud.el (gud-def): Doc fix.
Jim Blandy <jimb@redhat.com>
parents: 923
diff changeset
610 (progn (re-search-forward "[^0-9a-f]")
ff06503c93b4 * gud.el (gud-def): Doc fix.
Jim Blandy <jimb@redhat.com>
parents: 923
diff changeset
611 (forward-char -1)
ff06503c93b4 * gud.el (gud-def): Doc fix.
Jim Blandy <jimb@redhat.com>
parents: 923
diff changeset
612 (point))))
ff06503c93b4 * gud.el (gud-def): Doc fix.
Jim Blandy <jimb@redhat.com>
parents: 923
diff changeset
613 (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
614 (forward-char 1)
ff06503c93b4 * gud.el (gud-def): Doc fix.
Jim Blandy <jimb@redhat.com>
parents: 923
diff changeset
615 (point)))
ff06503c93b4 * gud.el (gud-def): Doc fix.
Jim Blandy <jimb@redhat.com>
parents: 923
diff changeset
616 (forward-char 1)
ff06503c93b4 * gud.el (gud-def): Doc fix.
Jim Blandy <jimb@redhat.com>
parents: 923
diff changeset
617 (re-search-forward "[^0-9]")
ff06503c93b4 * gud.el (gud-def): Doc fix.
Jim Blandy <jimb@redhat.com>
parents: 923
diff changeset
618 (forward-char -1)
ff06503c93b4 * gud.el (gud-def): Doc fix.
Jim Blandy <jimb@redhat.com>
parents: 923
diff changeset
619 (buffer-substring begin (point)))))))
460
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
620
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
621
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
622 (defun send-gud-command (arg)
868
0cda1f7b154e *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 810
diff changeset
623 "This command reads the number where the cursor is positioned. A numeric arg
0cda1f7b154e *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 810
diff changeset
624 selects the ARG'th member COMMAND of the list gud-commands. If COMMAND is a
0cda1f7b154e *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 810
diff changeset
625 string, (format COMMAND ADDR) is inserted at the end of the debugger buffer,
0cda1f7b154e *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 810
diff changeset
626 otherwise (funcall COMMAND ADDR) is inserted.
0cda1f7b154e *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 810
diff changeset
627 For example, \"p (rtx)%s->fld[0].rtint\" is a possible string to be a
0cda1f7b154e *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 810
diff changeset
628 member of gud-commands."
460
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
629 (interactive "P")
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
630 (let (comm addr)
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
631 (if arg (setq comm (nth arg gud-commands)))
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
632 (setq addr (gud-read-address))
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
633 (if (eq (current-buffer) current-gud-buffer)
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
634 (set-mark (point)))
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
635 (cond (comm
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
636 (setq comm
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
637 (if (stringp comm) (format comm addr) (funcall comm addr))))
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
638 (t (setq comm addr)))
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
639 (switch-to-buffer current-gud-buffer)
923
9f3cc03dae67 entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 914
diff changeset
640 (goto-char (point-max))
460
c103b99fd872 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
641 (insert-string comm)))
477
ab9a55b26bd4 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 460
diff changeset
642
810
80303373daae *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 806
diff changeset
643 ;;; gud.el ends here