annotate lisp/progmodes/gdb-ui.el @ 61052:f49b6692433d

(Specify Coding): Document recode-region and recode-file-name.
author Richard M. Stallman <rms@gnu.org>
date Mon, 28 Mar 2005 21:07:34 +0000
parents a44ce059d2d1
children c1538e237b52 2006100ee57e 4da4a09e8b1b
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1 ;;; gdb-ui.el --- User Interface for running GDB
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2
54993
08b0ee9a9b35 (gdb-frame-parameters): New constant.
Nick Roberts <nickrob@snap.net.nz>
parents: 54962
diff changeset
3 ;; Author: Nick Roberts <nickrob@gnu.org>
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
4 ;; Maintainer: FSF
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
5 ;; Keywords: unix, tools
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
6
59922
79e9767b47c8 Update copyright. Put GDB-Frames before
Nick Roberts <nickrob@snap.net.nz>
parents: 59852
diff changeset
7 ;; Copyright (C) 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
8
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
9 ;; This file is part of GNU Emacs.
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
10
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
11 ;; GNU Emacs is free software; you can redistribute it and/or modify
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
12 ;; it under the terms of the GNU General Public License as published by
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
13 ;; the Free Software Foundation; either version 2, or (at your option)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
14 ;; any later version.
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
15
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
16 ;; GNU Emacs is distributed in the hope that it will be useful,
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
19 ;; GNU General Public License for more details.
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
20
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
21 ;; You should have received a copy of the GNU General Public License
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
22 ;; along with GNU Emacs; see the file COPYING. If not, write to the
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
23 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
24 ;; Boston, MA 02111-1307, USA.
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
25
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
26 ;;; Commentary:
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
27
57791
d1b93fc4ce47 Docstring fixes.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57664
diff changeset
28 ;; This mode acts as a graphical user interface to GDB. You can interact with
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
29 ;; GDB through the GUD buffer in the usual way, but there are also further
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
30 ;; buffers which control the execution and describe the state of your program.
54729
7bfccd78beed (gdb-use-inferior-io-buffer): New option.
Nick Roberts <nickrob@snap.net.nz>
parents: 54668
diff changeset
31 ;; It separates the input/output of your program from that of GDB, if
57791
d1b93fc4ce47 Docstring fixes.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57664
diff changeset
32 ;; required, and watches expressions in the speedbar. It also uses features of
56258
3b1880995ace (gdb-toggle-breakpoint)
Nick Roberts <nickrob@snap.net.nz>
parents: 55850
diff changeset
33 ;; Emacs 21 such as the fringe/display margin for breakpoints, and the toolbar
3b1880995ace (gdb-toggle-breakpoint)
Nick Roberts <nickrob@snap.net.nz>
parents: 55850
diff changeset
34 ;; (see the GDB Graphical Interface section in the Emacs info manual).
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
35
59617
4988bdf5db77 (gdb-put-string): Copy/create strings so
Nick Roberts <nickrob@snap.net.nz>
parents: 58534
diff changeset
36 ;; By default, M-x gdb will start the debugger. However, if you have customised
4988bdf5db77 (gdb-put-string): Copy/create strings so
Nick Roberts <nickrob@snap.net.nz>
parents: 58534
diff changeset
37 ;; gud-gdb-command-name, then start it with M-x gdba.
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
38
59617
4988bdf5db77 (gdb-put-string): Copy/create strings so
Nick Roberts <nickrob@snap.net.nz>
parents: 58534
diff changeset
39 ;; This file has evolved from gdba.el that was included with GDB 5.0 and
4988bdf5db77 (gdb-put-string): Copy/create strings so
Nick Roberts <nickrob@snap.net.nz>
parents: 58534
diff changeset
40 ;; written by Tom Lord and Jim Kingdon. It uses GDB's annotation interface.
4988bdf5db77 (gdb-put-string): Copy/create strings so
Nick Roberts <nickrob@snap.net.nz>
parents: 58534
diff changeset
41 ;; You don't need to know about annotations to use this mode as a debugger,
4988bdf5db77 (gdb-put-string): Copy/create strings so
Nick Roberts <nickrob@snap.net.nz>
parents: 58534
diff changeset
42 ;; but if you are interested developing the mode itself, then see the
4988bdf5db77 (gdb-put-string): Copy/create strings so
Nick Roberts <nickrob@snap.net.nz>
parents: 58534
diff changeset
43 ;; Annotations section in the GDB info manual.
55850
63ca25eb73a1 (gdb-current-frame, gud-watch)
Nick Roberts <nickrob@snap.net.nz>
parents: 55764
diff changeset
44 ;;
57791
d1b93fc4ce47 Docstring fixes.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57664
diff changeset
45 ;; GDB developers plan to make the annotation interface obsolete. A new
55850
63ca25eb73a1 (gdb-current-frame, gud-watch)
Nick Roberts <nickrob@snap.net.nz>
parents: 55764
diff changeset
46 ;; interface called GDB/MI (machine interface) has been designed to replace
57791
d1b93fc4ce47 Docstring fixes.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57664
diff changeset
47 ;; it. Some GDB/MI commands are used in this file through the CLI command
59617
4988bdf5db77 (gdb-put-string): Copy/create strings so
Nick Roberts <nickrob@snap.net.nz>
parents: 58534
diff changeset
48 ;; 'interpreter mi <mi-command>'. A file called gdb-mi.el is included with
4988bdf5db77 (gdb-put-string): Copy/create strings so
Nick Roberts <nickrob@snap.net.nz>
parents: 58534
diff changeset
49 ;; GDB (6.2 onwards) that uses GDB/MI as the primary interface to GDB. It is
4988bdf5db77 (gdb-put-string): Copy/create strings so
Nick Roberts <nickrob@snap.net.nz>
parents: 58534
diff changeset
50 ;; still under development and is part of a process to migrate Emacs from
4988bdf5db77 (gdb-put-string): Copy/create strings so
Nick Roberts <nickrob@snap.net.nz>
parents: 58534
diff changeset
51 ;; annotations to GDB/MI.
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
52 ;;
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
53 ;; Known Bugs:
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
54 ;;
59617
4988bdf5db77 (gdb-put-string): Copy/create strings so
Nick Roberts <nickrob@snap.net.nz>
parents: 58534
diff changeset
55 ;; TODO:
59808
37a65df00ab2 (gdb-memory-address)
Nick Roberts <nickrob@snap.net.nz>
parents: 59766
diff changeset
56 ;; 1) Use MI command -data-read-memory for memory window.
37a65df00ab2 (gdb-memory-address)
Nick Roberts <nickrob@snap.net.nz>
parents: 59766
diff changeset
57 ;; 2) Highlight changed register values (use MI commands
37a65df00ab2 (gdb-memory-address)
Nick Roberts <nickrob@snap.net.nz>
parents: 59766
diff changeset
58 ;; -data-list-register-values and -data-list-changed-registers instead
37a65df00ab2 (gdb-memory-address)
Nick Roberts <nickrob@snap.net.nz>
parents: 59766
diff changeset
59 ;; of 'info registers'.
37a65df00ab2 (gdb-memory-address)
Nick Roberts <nickrob@snap.net.nz>
parents: 59766
diff changeset
60 ;; 3) Use tree-widget.el instead of the speedbar for watch-expressions?
37a65df00ab2 (gdb-memory-address)
Nick Roberts <nickrob@snap.net.nz>
parents: 59766
diff changeset
61 ;; 4) Mark breakpoint locations on scroll-bar of source buffer?
59996
aac0a33f5772 Change release version from 21.4 to 22.1 throughout.
Kim F. Storm <storm@cua.dk>
parents: 59988
diff changeset
62 ;; 5) After release of 22.1 use '-var-list-children --all-values'
59808
37a65df00ab2 (gdb-memory-address)
Nick Roberts <nickrob@snap.net.nz>
parents: 59766
diff changeset
63 ;; and '-stack-list-locals 2' which need GDB 6.1 onwards.
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
64
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
65 ;;; Code:
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
66
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
67 (require 'gud)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
68
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
69 (defvar gdb-current-address "main" "Initialisation for Assembler buffer.")
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
70 (defvar gdb-previous-address nil)
59808
37a65df00ab2 (gdb-memory-address)
Nick Roberts <nickrob@snap.net.nz>
parents: 59766
diff changeset
71 (defvar gdb-memory-address "main")
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
72 (defvar gdb-previous-frame nil)
55850
63ca25eb73a1 (gdb-current-frame, gud-watch)
Nick Roberts <nickrob@snap.net.nz>
parents: 55764
diff changeset
73 (defvar gdb-current-frame nil)
58049
fd0093bd412a (gdb-current-stack-level): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 57982
diff changeset
74 (defvar gdb-current-stack-level nil)
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
75 (defvar gdb-current-language nil)
57791
d1b93fc4ce47 Docstring fixes.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57664
diff changeset
76 (defvar gdb-var-list nil "List of variables in watch window.")
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
77 (defvar gdb-var-changed nil "Non-nil means that gdb-var-list has changed.")
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
78 (defvar gdb-buffer-type nil)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
79 (defvar gdb-overlay-arrow-position nil)
55749
230865f1c59d (gdb-server-prefix): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 55696
diff changeset
80 (defvar gdb-server-prefix nil)
58431
da65edef151e (gdb-flush-pending-output): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 58420
diff changeset
81 (defvar gdb-flush-pending-output nil)
60073
6fba1da8f37e (gdb-find-file-unhook): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 59998
diff changeset
82 (defvar gdb-location-list nil "List of directories for source files.")
6fba1da8f37e (gdb-find-file-unhook): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 59998
diff changeset
83 (defvar gdb-find-file-unhook nil)
56285
313e3a9f34ca (breakpoint-enabled-bitmap-face)
Kim F. Storm <storm@cua.dk>
parents: 56258
diff changeset
84
58420
97e4fc5c7297 (gdb-resync): New function.
Nick Roberts <nickrob@snap.net.nz>
parents: 58049
diff changeset
85 (defvar gdb-buffer-type nil
97e4fc5c7297 (gdb-resync): New function.
Nick Roberts <nickrob@snap.net.nz>
parents: 58049
diff changeset
86 "One of the symbols bound in `gdb-buffer-rules'.")
97e4fc5c7297 (gdb-resync): New function.
Nick Roberts <nickrob@snap.net.nz>
parents: 58049
diff changeset
87
97e4fc5c7297 (gdb-resync): New function.
Nick Roberts <nickrob@snap.net.nz>
parents: 58049
diff changeset
88 (defvar gdb-input-queue ()
97e4fc5c7297 (gdb-resync): New function.
Nick Roberts <nickrob@snap.net.nz>
parents: 58049
diff changeset
89 "A list of gdb command objects.")
97e4fc5c7297 (gdb-resync): New function.
Nick Roberts <nickrob@snap.net.nz>
parents: 58049
diff changeset
90
97e4fc5c7297 (gdb-resync): New function.
Nick Roberts <nickrob@snap.net.nz>
parents: 58049
diff changeset
91 (defvar gdb-prompting nil
97e4fc5c7297 (gdb-resync): New function.
Nick Roberts <nickrob@snap.net.nz>
parents: 58049
diff changeset
92 "True when gdb is idle with no pending input.")
97e4fc5c7297 (gdb-resync): New function.
Nick Roberts <nickrob@snap.net.nz>
parents: 58049
diff changeset
93
97e4fc5c7297 (gdb-resync): New function.
Nick Roberts <nickrob@snap.net.nz>
parents: 58049
diff changeset
94 (defvar gdb-output-sink 'user
97e4fc5c7297 (gdb-resync): New function.
Nick Roberts <nickrob@snap.net.nz>
parents: 58049
diff changeset
95 "The disposition of the output of the current gdb command.
97e4fc5c7297 (gdb-resync): New function.
Nick Roberts <nickrob@snap.net.nz>
parents: 58049
diff changeset
96 Possible values are these symbols:
97e4fc5c7297 (gdb-resync): New function.
Nick Roberts <nickrob@snap.net.nz>
parents: 58049
diff changeset
97
97e4fc5c7297 (gdb-resync): New function.
Nick Roberts <nickrob@snap.net.nz>
parents: 58049
diff changeset
98 `user' -- gdb output should be copied to the GUD buffer
97e4fc5c7297 (gdb-resync): New function.
Nick Roberts <nickrob@snap.net.nz>
parents: 58049
diff changeset
99 for the user to see.
97e4fc5c7297 (gdb-resync): New function.
Nick Roberts <nickrob@snap.net.nz>
parents: 58049
diff changeset
100
97e4fc5c7297 (gdb-resync): New function.
Nick Roberts <nickrob@snap.net.nz>
parents: 58049
diff changeset
101 `inferior' -- gdb output should be copied to the inferior-io buffer
97e4fc5c7297 (gdb-resync): New function.
Nick Roberts <nickrob@snap.net.nz>
parents: 58049
diff changeset
102
97e4fc5c7297 (gdb-resync): New function.
Nick Roberts <nickrob@snap.net.nz>
parents: 58049
diff changeset
103 `pre-emacs' -- output should be ignored util the post-prompt
97e4fc5c7297 (gdb-resync): New function.
Nick Roberts <nickrob@snap.net.nz>
parents: 58049
diff changeset
104 annotation is received. Then the output-sink
97e4fc5c7297 (gdb-resync): New function.
Nick Roberts <nickrob@snap.net.nz>
parents: 58049
diff changeset
105 becomes:...
97e4fc5c7297 (gdb-resync): New function.
Nick Roberts <nickrob@snap.net.nz>
parents: 58049
diff changeset
106 `emacs' -- output should be collected in the partial-output-buffer
97e4fc5c7297 (gdb-resync): New function.
Nick Roberts <nickrob@snap.net.nz>
parents: 58049
diff changeset
107 for subsequent processing by a command. This is the
97e4fc5c7297 (gdb-resync): New function.
Nick Roberts <nickrob@snap.net.nz>
parents: 58049
diff changeset
108 disposition of output generated by commands that
97e4fc5c7297 (gdb-resync): New function.
Nick Roberts <nickrob@snap.net.nz>
parents: 58049
diff changeset
109 gdb mode sends to gdb on its own behalf.
97e4fc5c7297 (gdb-resync): New function.
Nick Roberts <nickrob@snap.net.nz>
parents: 58049
diff changeset
110 `post-emacs' -- ignore output until the prompt annotation is
97e4fc5c7297 (gdb-resync): New function.
Nick Roberts <nickrob@snap.net.nz>
parents: 58049
diff changeset
111 received, then go to USER disposition.
97e4fc5c7297 (gdb-resync): New function.
Nick Roberts <nickrob@snap.net.nz>
parents: 58049
diff changeset
112
97e4fc5c7297 (gdb-resync): New function.
Nick Roberts <nickrob@snap.net.nz>
parents: 58049
diff changeset
113 gdba (gdb-ui.el) uses all five values, gdbmi (gdb-mi.el) only two
97e4fc5c7297 (gdb-resync): New function.
Nick Roberts <nickrob@snap.net.nz>
parents: 58049
diff changeset
114 \(`user' and `emacs').")
97e4fc5c7297 (gdb-resync): New function.
Nick Roberts <nickrob@snap.net.nz>
parents: 58049
diff changeset
115
97e4fc5c7297 (gdb-resync): New function.
Nick Roberts <nickrob@snap.net.nz>
parents: 58049
diff changeset
116 (defvar gdb-current-item nil
97e4fc5c7297 (gdb-resync): New function.
Nick Roberts <nickrob@snap.net.nz>
parents: 58049
diff changeset
117 "The most recent command item sent to gdb.")
97e4fc5c7297 (gdb-resync): New function.
Nick Roberts <nickrob@snap.net.nz>
parents: 58049
diff changeset
118
97e4fc5c7297 (gdb-resync): New function.
Nick Roberts <nickrob@snap.net.nz>
parents: 58049
diff changeset
119 (defvar gdb-pending-triggers '()
97e4fc5c7297 (gdb-resync): New function.
Nick Roberts <nickrob@snap.net.nz>
parents: 58049
diff changeset
120 "A list of trigger functions that have run later than their output
97e4fc5c7297 (gdb-resync): New function.
Nick Roberts <nickrob@snap.net.nz>
parents: 58049
diff changeset
121 handlers.")
97e4fc5c7297 (gdb-resync): New function.
Nick Roberts <nickrob@snap.net.nz>
parents: 58049
diff changeset
122
97e4fc5c7297 (gdb-resync): New function.
Nick Roberts <nickrob@snap.net.nz>
parents: 58049
diff changeset
123 ;; end of gdb variables
97e4fc5c7297 (gdb-resync): New function.
Nick Roberts <nickrob@snap.net.nz>
parents: 58049
diff changeset
124
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
125 ;;;###autoload
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
126 (defun gdba (command-line)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
127 "Run gdb on program FILE in buffer *gud-FILE*.
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
128 The directory containing FILE becomes the initial working directory
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
129 and source-file directory for your debugger.
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
130
54668
69a699e79a0d (gdb-view-source-function, gdb-view-assembler)
Nick Roberts <nickrob@snap.net.nz>
parents: 54617
diff changeset
131 If `gdb-many-windows' is nil (the default value) then gdb just
69a699e79a0d (gdb-view-source-function, gdb-view-assembler)
Nick Roberts <nickrob@snap.net.nz>
parents: 54617
diff changeset
132 pops up the GUD buffer unless `gdb-show-main' is t. In this case
69a699e79a0d (gdb-view-source-function, gdb-view-assembler)
Nick Roberts <nickrob@snap.net.nz>
parents: 54617
diff changeset
133 it starts with two windows: one displaying the GUD buffer and the
55749
230865f1c59d (gdb-server-prefix): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 55696
diff changeset
134 other with the source file with the main routine of the inferior.
54668
69a699e79a0d (gdb-view-source-function, gdb-view-assembler)
Nick Roberts <nickrob@snap.net.nz>
parents: 54617
diff changeset
135
54901
fa4feb8b3c34 (gdb-goto-info): New function.
Nick Roberts <nickrob@snap.net.nz>
parents: 54760
diff changeset
136 If `gdb-many-windows' is t, regardless of the value of
fa4feb8b3c34 (gdb-goto-info): New function.
Nick Roberts <nickrob@snap.net.nz>
parents: 54760
diff changeset
137 `gdb-show-main', the layout below will appear unless
54760
c6ccb7a82f9f (gdb-source-window): Remove variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 54729
diff changeset
138 `gdb-use-inferior-io-buffer' is nil when the source buffer
57791
d1b93fc4ce47 Docstring fixes.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57664
diff changeset
139 occupies the full width of the frame. Keybindings are given in
54760
c6ccb7a82f9f (gdb-source-window): Remove variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 54729
diff changeset
140 relevant buffer.
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
141
54901
fa4feb8b3c34 (gdb-goto-info): New function.
Nick Roberts <nickrob@snap.net.nz>
parents: 54760
diff changeset
142 Watch expressions appear in the speedbar/slowbar.
fa4feb8b3c34 (gdb-goto-info): New function.
Nick Roberts <nickrob@snap.net.nz>
parents: 54760
diff changeset
143
57791
d1b93fc4ce47 Docstring fixes.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57664
diff changeset
144 The following commands help control operation :
54901
fa4feb8b3c34 (gdb-goto-info): New function.
Nick Roberts <nickrob@snap.net.nz>
parents: 54760
diff changeset
145
fa4feb8b3c34 (gdb-goto-info): New function.
Nick Roberts <nickrob@snap.net.nz>
parents: 54760
diff changeset
146 `gdb-many-windows' - Toggle the number of windows gdb uses.
fa4feb8b3c34 (gdb-goto-info): New function.
Nick Roberts <nickrob@snap.net.nz>
parents: 54760
diff changeset
147 `gdb-restore-windows' - To restore the window layout.
fa4feb8b3c34 (gdb-goto-info): New function.
Nick Roberts <nickrob@snap.net.nz>
parents: 54760
diff changeset
148
fa4feb8b3c34 (gdb-goto-info): New function.
Nick Roberts <nickrob@snap.net.nz>
parents: 54760
diff changeset
149 See Info node `(emacs)GDB Graphical Interface' for a more
fa4feb8b3c34 (gdb-goto-info): New function.
Nick Roberts <nickrob@snap.net.nz>
parents: 54760
diff changeset
150 detailed description of this mode.
fa4feb8b3c34 (gdb-goto-info): New function.
Nick Roberts <nickrob@snap.net.nz>
parents: 54760
diff changeset
151
fa4feb8b3c34 (gdb-goto-info): New function.
Nick Roberts <nickrob@snap.net.nz>
parents: 54760
diff changeset
152
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
153 ---------------------------------------------------------------------
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
154 GDB Toolbar
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
155 ---------------------------------------------------------------------
54901
fa4feb8b3c34 (gdb-goto-info): New function.
Nick Roberts <nickrob@snap.net.nz>
parents: 54760
diff changeset
156 GUD buffer (I/O of GDB) | Locals buffer
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
157 |
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
158 |
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
159 |
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
160 ---------------------------------------------------------------------
55749
230865f1c59d (gdb-server-prefix): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 55696
diff changeset
161 Source buffer | Input/Output (of inferior) buffer
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
162 | (comint-mode)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
163 |
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
164 |
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
165 |
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
166 |
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
167 |
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
168 |
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
169 ---------------------------------------------------------------------
54901
fa4feb8b3c34 (gdb-goto-info): New function.
Nick Roberts <nickrob@snap.net.nz>
parents: 54760
diff changeset
170 Stack buffer | Breakpoints buffer
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
171 RET gdb-frames-select | SPC gdb-toggle-breakpoint
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
172 | RET gdb-goto-breakpoint
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
173 | d gdb-delete-breakpoint
57791
d1b93fc4ce47 Docstring fixes.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57664
diff changeset
174 ---------------------------------------------------------------------"
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
175 ;;
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
176 (interactive (list (gud-query-cmdline 'gdba)))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
177 ;;
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
178 ;; Let's start with a basic gud-gdb buffer and then modify it a bit.
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
179 (gdb command-line)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
180 (gdb-ann3))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
181
54616
47c4cb867a84 (gdb-ann3, gdb-send-item)
Nick Roberts <nickrob@snap.net.nz>
parents: 54538
diff changeset
182 (defvar gdb-debug-log nil)
47c4cb867a84 (gdb-ann3, gdb-send-item)
Nick Roberts <nickrob@snap.net.nz>
parents: 54538
diff changeset
183
47c4cb867a84 (gdb-ann3, gdb-send-item)
Nick Roberts <nickrob@snap.net.nz>
parents: 54538
diff changeset
184 (defcustom gdb-enable-debug-log nil
59617
4988bdf5db77 (gdb-put-string): Copy/create strings so
Nick Roberts <nickrob@snap.net.nz>
parents: 58534
diff changeset
185 "Non-nil means record the process input and output in `gdb-debug-log'."
54616
47c4cb867a84 (gdb-ann3, gdb-send-item)
Nick Roberts <nickrob@snap.net.nz>
parents: 54538
diff changeset
186 :type 'boolean
57851
67b88e92a24d (gdb-enable-debug-log)
Nick Roberts <nickrob@snap.net.nz>
parents: 57791
diff changeset
187 :group 'gud
59996
aac0a33f5772 Change release version from 21.4 to 22.1 throughout.
Kim F. Storm <storm@cua.dk>
parents: 59988
diff changeset
188 :version "22.1")
54616
47c4cb867a84 (gdb-ann3, gdb-send-item)
Nick Roberts <nickrob@snap.net.nz>
parents: 54538
diff changeset
189
54729
7bfccd78beed (gdb-use-inferior-io-buffer): New option.
Nick Roberts <nickrob@snap.net.nz>
parents: 54668
diff changeset
190 (defcustom gdb-use-inferior-io-buffer nil
59617
4988bdf5db77 (gdb-put-string): Copy/create strings so
Nick Roberts <nickrob@snap.net.nz>
parents: 58534
diff changeset
191 "Non-nil means display output from the inferior in a separate buffer."
54729
7bfccd78beed (gdb-use-inferior-io-buffer): New option.
Nick Roberts <nickrob@snap.net.nz>
parents: 54668
diff changeset
192 :type 'boolean
57851
67b88e92a24d (gdb-enable-debug-log)
Nick Roberts <nickrob@snap.net.nz>
parents: 57791
diff changeset
193 :group 'gud
59996
aac0a33f5772 Change release version from 21.4 to 22.1 throughout.
Kim F. Storm <storm@cua.dk>
parents: 59988
diff changeset
194 :version "22.1")
54729
7bfccd78beed (gdb-use-inferior-io-buffer): New option.
Nick Roberts <nickrob@snap.net.nz>
parents: 54668
diff changeset
195
60073
6fba1da8f37e (gdb-find-file-unhook): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 59998
diff changeset
196 (defun gdb-set-gud-minor-mode (buffer)
6fba1da8f37e (gdb-find-file-unhook): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 59998
diff changeset
197 "Set gud-minor-mode from find-file if appropriate."
6fba1da8f37e (gdb-find-file-unhook): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 59998
diff changeset
198 (goto-char (point-min))
6fba1da8f37e (gdb-find-file-unhook): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 59998
diff changeset
199 (unless (search-forward "No source file named " nil t)
6fba1da8f37e (gdb-find-file-unhook): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 59998
diff changeset
200 (condition-case nil
6fba1da8f37e (gdb-find-file-unhook): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 59998
diff changeset
201 (gdb-enqueue-input
6fba1da8f37e (gdb-find-file-unhook): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 59998
diff changeset
202 (list (concat gdb-server-prefix "info source\n")
6fba1da8f37e (gdb-find-file-unhook): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 59998
diff changeset
203 `(lambda () (gdb-set-gud-minor-mode-1 ,buffer))))
6fba1da8f37e (gdb-find-file-unhook): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 59998
diff changeset
204 (error (setq gdb-find-file-unhook t)))))
6fba1da8f37e (gdb-find-file-unhook): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 59998
diff changeset
205
6fba1da8f37e (gdb-find-file-unhook): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 59998
diff changeset
206 (defun gdb-set-gud-minor-mode-1 (buffer)
6fba1da8f37e (gdb-find-file-unhook): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 59998
diff changeset
207 (goto-char (point-min))
6fba1da8f37e (gdb-find-file-unhook): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 59998
diff changeset
208 (if (and (search-forward "Located in " nil t)
6fba1da8f37e (gdb-find-file-unhook): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 59998
diff changeset
209 (looking-at "\\S-*")
6fba1da8f37e (gdb-find-file-unhook): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 59998
diff changeset
210 (string-equal (buffer-file-name buffer)
6fba1da8f37e (gdb-find-file-unhook): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 59998
diff changeset
211 (match-string 0)))
6fba1da8f37e (gdb-find-file-unhook): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 59998
diff changeset
212 (with-current-buffer buffer
6fba1da8f37e (gdb-find-file-unhook): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 59998
diff changeset
213 (set (make-local-variable 'gud-minor-mode) 'gdba)
6fba1da8f37e (gdb-find-file-unhook): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 59998
diff changeset
214 (set (make-local-variable 'tool-bar-map) gud-tool-bar-map))))
6fba1da8f37e (gdb-find-file-unhook): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 59998
diff changeset
215
6fba1da8f37e (gdb-find-file-unhook): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 59998
diff changeset
216 (defun gdb-set-gud-minor-mode-existing-buffers ()
6fba1da8f37e (gdb-find-file-unhook): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 59998
diff changeset
217 (dolist (buffer (buffer-list))
6fba1da8f37e (gdb-find-file-unhook): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 59998
diff changeset
218 (let ((file (buffer-file-name buffer)))
6fba1da8f37e (gdb-find-file-unhook): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 59998
diff changeset
219 (if file
6fba1da8f37e (gdb-find-file-unhook): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 59998
diff changeset
220 (progn
6fba1da8f37e (gdb-find-file-unhook): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 59998
diff changeset
221 (gdb-enqueue-input
60124
106946a8423d (gdb-set-gud-minor-mode-existing-buffers)
Nick Roberts <nickrob@snap.net.nz>
parents: 60073
diff changeset
222 (list (concat gdb-server-prefix "list "
106946a8423d (gdb-set-gud-minor-mode-existing-buffers)
Nick Roberts <nickrob@snap.net.nz>
parents: 60073
diff changeset
223 (file-name-nondirectory file) ":1\n")
60073
6fba1da8f37e (gdb-find-file-unhook): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 59998
diff changeset
224 `(lambda () (gdb-set-gud-minor-mode ,buffer)))))))))
6fba1da8f37e (gdb-find-file-unhook): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 59998
diff changeset
225
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
226 (defun gdb-ann3 ()
54616
47c4cb867a84 (gdb-ann3, gdb-send-item)
Nick Roberts <nickrob@snap.net.nz>
parents: 54538
diff changeset
227 (setq gdb-debug-log nil)
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
228 (set (make-local-variable 'gud-minor-mode) 'gdba)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
229 (set (make-local-variable 'gud-marker-filter) 'gud-gdba-marker-filter)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
230 ;;
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
231 (gud-def gud-break (if (not (string-equal mode-name "Machine"))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
232 (gud-call "break %f:%l" arg)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
233 (save-excursion
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
234 (beginning-of-line)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
235 (forward-char 2)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
236 (gud-call "break *%a" arg)))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
237 "\C-b" "Set breakpoint at current line or address.")
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
238 ;;
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
239 (gud-def gud-remove (if (not (string-equal mode-name "Machine"))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
240 (gud-call "clear %f:%l" arg)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
241 (save-excursion
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
242 (beginning-of-line)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
243 (forward-char 2)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
244 (gud-call "clear *%a" arg)))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
245 "\C-d" "Remove breakpoint at current line or address.")
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
246 ;;
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
247 (gud-def gud-until (if (not (string-equal mode-name "Machine"))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
248 (gud-call "until %f:%l" arg)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
249 (save-excursion
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
250 (beginning-of-line)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
251 (forward-char 2)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
252 (gud-call "until *%a" arg)))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
253 "\C-u" "Continue to current line or address.")
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
254
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
255 (define-key gud-minor-mode-map [left-margin mouse-1]
59617
4988bdf5db77 (gdb-put-string): Copy/create strings so
Nick Roberts <nickrob@snap.net.nz>
parents: 58534
diff changeset
256 'gdb-mouse-set-clear-breakpoint)
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
257 (define-key gud-minor-mode-map [left-fringe mouse-1]
59617
4988bdf5db77 (gdb-put-string): Copy/create strings so
Nick Roberts <nickrob@snap.net.nz>
parents: 58534
diff changeset
258 'gdb-mouse-set-clear-breakpoint)
4988bdf5db77 (gdb-put-string): Copy/create strings so
Nick Roberts <nickrob@snap.net.nz>
parents: 58534
diff changeset
259 (define-key gud-minor-mode-map [left-margin mouse-3]
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
260 'gdb-mouse-toggle-breakpoint)
59617
4988bdf5db77 (gdb-put-string): Copy/create strings so
Nick Roberts <nickrob@snap.net.nz>
parents: 58534
diff changeset
261 ; (define-key gud-minor-mode-map [left-fringe mouse-3]
4988bdf5db77 (gdb-put-string): Copy/create strings so
Nick Roberts <nickrob@snap.net.nz>
parents: 58534
diff changeset
262 ; 'gdb-mouse-toggle-breakpoint)
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
263
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
264 (setq comint-input-sender 'gdb-send)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
265 ;;
57664
4d6eec4c1ef8 * progmodes/gdb-ui.el (gdb-assembler-font-lock-keywords): Handle
Masatake YAMATO <jet@gyve.org>
parents: 57661
diff changeset
266 ;; (re-)initialize
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
267 (setq gdb-current-address "main")
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
268 (setq gdb-previous-address nil)
59808
37a65df00ab2 (gdb-memory-address)
Nick Roberts <nickrob@snap.net.nz>
parents: 59766
diff changeset
269 (setq gdb-memory-address "main")
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
270 (setq gdb-previous-frame nil)
55850
63ca25eb73a1 (gdb-current-frame, gud-watch)
Nick Roberts <nickrob@snap.net.nz>
parents: 55764
diff changeset
271 (setq gdb-current-frame nil)
58049
fd0093bd412a (gdb-current-stack-level): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 57982
diff changeset
272 (setq gdb-current-stack-level nil)
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
273 (setq gdb-var-list nil)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
274 (setq gdb-var-changed nil)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
275 (setq gdb-first-prompt nil)
55749
230865f1c59d (gdb-server-prefix): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 55696
diff changeset
276 (setq gdb-prompting nil)
57350
11b8de2051f3 (gdb-ann3): (Re-)initialise gdb-input-queue.
Nick Roberts <nickrob@snap.net.nz>
parents: 57262
diff changeset
277 (setq gdb-input-queue nil)
55749
230865f1c59d (gdb-server-prefix): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 55696
diff changeset
278 (setq gdb-current-item nil)
230865f1c59d (gdb-server-prefix): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 55696
diff changeset
279 (setq gdb-pending-triggers nil)
230865f1c59d (gdb-server-prefix): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 55696
diff changeset
280 (setq gdb-output-sink 'user)
230865f1c59d (gdb-server-prefix): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 55696
diff changeset
281 (setq gdb-server-prefix "server ")
58431
da65edef151e (gdb-flush-pending-output): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 58420
diff changeset
282 (setq gdb-flush-pending-output nil)
59988
fb52ec059049 (gdb-location-list): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 59922
diff changeset
283 (setq gdb-location-list nil)
60073
6fba1da8f37e (gdb-find-file-unhook): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 59998
diff changeset
284 (setq gdb-find-file-unhook nil)
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
285 ;;
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
286 (setq gdb-buffer-type 'gdba)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
287 ;;
54729
7bfccd78beed (gdb-use-inferior-io-buffer): New option.
Nick Roberts <nickrob@snap.net.nz>
parents: 54668
diff changeset
288 (if gdb-use-inferior-io-buffer (gdb-clear-inferior-io))
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
289 ;;
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
290 (if (eq window-system 'w32)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
291 (gdb-enqueue-input (list "set new-console off\n" 'ignore)))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
292 (gdb-enqueue-input (list "set height 0\n" 'ignore))
59998
c2d7ae01e91d (gdb-ann3): Re-instate GDB command "set
Nick Roberts <nickrob@snap.net.nz>
parents: 59996
diff changeset
293 (gdb-enqueue-input (list "set width 0\n" 'ignore))
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
294 ;; find source file and compilation directory here
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
295 (gdb-enqueue-input (list "server list main\n" 'ignore)) ; C program
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
296 (gdb-enqueue-input (list "server list MAIN__\n" 'ignore)) ; Fortran program
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
297 (gdb-enqueue-input (list "server info source\n" 'gdb-source-info))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
298 ;;
60073
6fba1da8f37e (gdb-find-file-unhook): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 59998
diff changeset
299 (gdb-set-gud-minor-mode-existing-buffers)
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
300 (run-hooks 'gdba-mode-hook))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
301
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
302 (defcustom gdb-use-colon-colon-notation nil
57791
d1b93fc4ce47 Docstring fixes.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57664
diff changeset
303 "If non-nil use FUN::VAR format to display variables in the speedbar." ;
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
304 :type 'boolean
57851
67b88e92a24d (gdb-enable-debug-log)
Nick Roberts <nickrob@snap.net.nz>
parents: 57791
diff changeset
305 :group 'gud
59996
aac0a33f5772 Change release version from 21.4 to 22.1 throughout.
Kim F. Storm <storm@cua.dk>
parents: 59988
diff changeset
306 :version "22.1")
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
307
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
308 (defun gud-watch ()
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
309 "Watch expression at point."
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
310 (interactive)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
311 (require 'tooltip)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
312 (let ((expr (tooltip-identifier-from-point (point))))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
313 (if (and (string-equal gdb-current-language "c")
55850
63ca25eb73a1 (gdb-current-frame, gud-watch)
Nick Roberts <nickrob@snap.net.nz>
parents: 55764
diff changeset
314 gdb-use-colon-colon-notation gdb-current-frame)
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
315 (setq expr (concat gdb-current-frame "::" expr)))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
316 (catch 'already-watched
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
317 (dolist (var gdb-var-list)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
318 (if (string-equal expr (car var)) (throw 'already-watched nil)))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
319 (set-text-properties 0 (length expr) nil expr)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
320 (gdb-enqueue-input
56285
313e3a9f34ca (breakpoint-enabled-bitmap-face)
Kim F. Storm <storm@cua.dk>
parents: 56258
diff changeset
321 (list
55749
230865f1c59d (gdb-server-prefix): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 55696
diff changeset
322 (if (eq gud-minor-mode 'gdba)
230865f1c59d (gdb-server-prefix): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 55696
diff changeset
323 (concat "server interpreter mi \"-var-create - * " expr "\"\n")
230865f1c59d (gdb-server-prefix): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 55696
diff changeset
324 (concat"-var-create - * " expr "\n"))
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
325 `(lambda () (gdb-var-create-handler ,expr))))))
58534
c655bc81dfc0 (gdb-view-source, gdb-selected-view):
Nick Roberts <nickrob@snap.net.nz>
parents: 58521
diff changeset
326 (select-window (get-buffer-window gud-comint-buffer 0)))
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
327
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
328 (defconst gdb-var-create-regexp
59617
4988bdf5db77 (gdb-put-string): Copy/create strings so
Nick Roberts <nickrob@snap.net.nz>
parents: 58534
diff changeset
329 "name=\"\\(.*?\\)\",numchild=\"\\(.*?\\)\",type=\"\\(.*?\\)\"")
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
330
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
331 (defun gdb-var-create-handler (expr)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
332 (with-current-buffer (gdb-get-create-buffer 'gdb-partial-output-buffer)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
333 (goto-char (point-min))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
334 (if (re-search-forward gdb-var-create-regexp nil t)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
335 (let ((var (list expr
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
336 (match-string 1)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
337 (match-string 2)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
338 (match-string 3)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
339 nil nil)))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
340 (push var gdb-var-list)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
341 (speedbar 1)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
342 (if (equal (nth 2 var) "0")
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
343 (gdb-enqueue-input
60477
2b7513e741b1 (gdb-var-create-handler): Handle just MI case.
Nick Roberts <nickrob@snap.net.nz>
parents: 60326
diff changeset
344 (list
2b7513e741b1 (gdb-var-create-handler): Handle just MI case.
Nick Roberts <nickrob@snap.net.nz>
parents: 60326
diff changeset
345 (if (with-current-buffer
2b7513e741b1 (gdb-var-create-handler): Handle just MI case.
Nick Roberts <nickrob@snap.net.nz>
parents: 60326
diff changeset
346 gud-comint-buffer (eq gud-minor-mode 'gdba))
2b7513e741b1 (gdb-var-create-handler): Handle just MI case.
Nick Roberts <nickrob@snap.net.nz>
parents: 60326
diff changeset
347 (concat "server interpreter mi \"-var-evaluate-expression "
2b7513e741b1 (gdb-var-create-handler): Handle just MI case.
Nick Roberts <nickrob@snap.net.nz>
parents: 60326
diff changeset
348 (nth 1 var) "\"\n")
2b7513e741b1 (gdb-var-create-handler): Handle just MI case.
Nick Roberts <nickrob@snap.net.nz>
parents: 60326
diff changeset
349 (concat "-var-evaluate-expression " (nth 1 var) "\n"))
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
350 `(lambda () (gdb-var-evaluate-expression-handler
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
351 ,(nth 1 var) nil))))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
352 (setq gdb-var-changed t)))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
353 (if (re-search-forward "Undefined command" nil t)
60541
fbf903562871 (gdb-var-create-handler, gdb-get-location):
Nick Roberts <nickrob@snap.net.nz>
parents: 60477
diff changeset
354 (message-box "Watching expressions requires gdb 6.0 onwards")
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
355 (message "No symbol %s in current context." expr)))))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
356
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
357 (defun gdb-var-evaluate-expression-handler (varnum changed)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
358 (with-current-buffer (gdb-get-create-buffer 'gdb-partial-output-buffer)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
359 (goto-char (point-min))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
360 (re-search-forward ".*value=\"\\(.*?\\)\"" nil t)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
361 (catch 'var-found
58485
31d7630f91d4 (gdb-breakpoints-mode-map)
Nick Roberts <nickrob@snap.net.nz>
parents: 58470
diff changeset
362 (let ((num 0))
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
363 (dolist (var gdb-var-list)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
364 (if (string-equal varnum (cadr var))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
365 (progn
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
366 (if changed (setcar (nthcdr 5 var) t))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
367 (setcar (nthcdr 4 var) (match-string 1))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
368 (setcar (nthcdr num gdb-var-list) var)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
369 (throw 'var-found nil)))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
370 (setq num (+ num 1))))))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
371 (setq gdb-var-changed t))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
372
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
373 (defun gdb-var-list-children (varnum)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
374 (gdb-enqueue-input
60477
2b7513e741b1 (gdb-var-create-handler): Handle just MI case.
Nick Roberts <nickrob@snap.net.nz>
parents: 60326
diff changeset
375 (list (concat "server interpreter mi \"-var-list-children " varnum "\"\n")
2b7513e741b1 (gdb-var-create-handler): Handle just MI case.
Nick Roberts <nickrob@snap.net.nz>
parents: 60326
diff changeset
376 `(lambda () (gdb-var-list-children-handler ,varnum)))))
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
377
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
378 (defconst gdb-var-list-children-regexp
59617
4988bdf5db77 (gdb-put-string): Copy/create strings so
Nick Roberts <nickrob@snap.net.nz>
parents: 58534
diff changeset
379 "name=\"\\(.*?\\)\",exp=\"\\(.*?\\)\",numchild=\"\\(.*?\\)\"")
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
380
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
381 (defun gdb-var-list-children-handler (varnum)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
382 (with-current-buffer (gdb-get-create-buffer 'gdb-partial-output-buffer)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
383 (goto-char (point-min))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
384 (let ((var-list nil))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
385 (catch 'child-already-watched
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
386 (dolist (var gdb-var-list)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
387 (if (string-equal varnum (cadr var))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
388 (progn
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
389 (push var var-list)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
390 (while (re-search-forward gdb-var-list-children-regexp nil t)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
391 (let ((varchild (list (match-string 2)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
392 (match-string 1)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
393 (match-string 3)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
394 nil nil nil)))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
395 (if (looking-at ",type=\"\\(.*?\\)\"")
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
396 (setcar (nthcdr 3 varchild) (match-string 1)))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
397 (dolist (var1 gdb-var-list)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
398 (if (string-equal (cadr var1) (cadr varchild))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
399 (throw 'child-already-watched nil)))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
400 (push varchild var-list)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
401 (if (equal (nth 2 varchild) "0")
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
402 (gdb-enqueue-input
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
403 (list
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
404 (concat
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
405 "server interpreter mi \"-var-evaluate-expression "
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
406 (nth 1 varchild) "\"\n")
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
407 `(lambda () (gdb-var-evaluate-expression-handler
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
408 ,(nth 1 varchild) nil))))))))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
409 (push var var-list)))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
410 (setq gdb-var-list (nreverse var-list))))))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
411
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
412 (defun gdb-var-update ()
55749
230865f1c59d (gdb-server-prefix): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 55696
diff changeset
413 (if (not (member 'gdb-var-update gdb-pending-triggers))
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
414 (progn
55764
25f133a490aa (gdb-var-update, gdb-var-update-handler, gdb-var-delete)
Nick Roberts <nickrob@snap.net.nz>
parents: 55762
diff changeset
415 (gdb-enqueue-input
56285
313e3a9f34ca (breakpoint-enabled-bitmap-face)
Kim F. Storm <storm@cua.dk>
parents: 56258
diff changeset
416 (list
55764
25f133a490aa (gdb-var-update, gdb-var-update-handler, gdb-var-delete)
Nick Roberts <nickrob@snap.net.nz>
parents: 55762
diff changeset
417 (if (with-current-buffer gud-comint-buffer (eq gud-minor-mode 'gdba))
25f133a490aa (gdb-var-update, gdb-var-update-handler, gdb-var-delete)
Nick Roberts <nickrob@snap.net.nz>
parents: 55762
diff changeset
418 "server interpreter mi \"-var-update *\"\n"
25f133a490aa (gdb-var-update, gdb-var-update-handler, gdb-var-delete)
Nick Roberts <nickrob@snap.net.nz>
parents: 55762
diff changeset
419 "-var-update *\n")
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
420 'gdb-var-update-handler))
55749
230865f1c59d (gdb-server-prefix): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 55696
diff changeset
421 (push 'gdb-var-update gdb-pending-triggers))))
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
422
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
423 (defconst gdb-var-update-regexp "name=\"\\(.*?\\)\"")
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
424
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
425 (defun gdb-var-update-handler ()
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
426 (with-current-buffer (gdb-get-create-buffer 'gdb-partial-output-buffer)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
427 (goto-char (point-min))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
428 (while (re-search-forward gdb-var-update-regexp nil t)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
429 (let ((varnum (match-string 1)))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
430 (gdb-enqueue-input
55764
25f133a490aa (gdb-var-update, gdb-var-update-handler, gdb-var-delete)
Nick Roberts <nickrob@snap.net.nz>
parents: 55762
diff changeset
431 (list
25f133a490aa (gdb-var-update, gdb-var-update-handler, gdb-var-delete)
Nick Roberts <nickrob@snap.net.nz>
parents: 55762
diff changeset
432 (if (with-current-buffer gud-comint-buffer (eq gud-minor-mode 'gdba))
25f133a490aa (gdb-var-update, gdb-var-update-handler, gdb-var-delete)
Nick Roberts <nickrob@snap.net.nz>
parents: 55762
diff changeset
433 (concat "server interpreter mi \"-var-evaluate-expression "
25f133a490aa (gdb-var-update, gdb-var-update-handler, gdb-var-delete)
Nick Roberts <nickrob@snap.net.nz>
parents: 55762
diff changeset
434 varnum "\"\n")
25f133a490aa (gdb-var-update, gdb-var-update-handler, gdb-var-delete)
Nick Roberts <nickrob@snap.net.nz>
parents: 55762
diff changeset
435 (concat "-var-evaluate-expression " varnum "\n"))
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
436 `(lambda () (gdb-var-evaluate-expression-handler
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
437 ,varnum t)))))))
55749
230865f1c59d (gdb-server-prefix): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 55696
diff changeset
438 (setq gdb-pending-triggers
60153
10993bad7aee (gdb-var-update-handler)
Nick Roberts <nickrob@snap.net.nz>
parents: 60124
diff changeset
439 (delq 'gdb-var-update gdb-pending-triggers))
10993bad7aee (gdb-var-update-handler)
Nick Roberts <nickrob@snap.net.nz>
parents: 60124
diff changeset
440 (when (and (boundp 'speedbar-frame) (frame-live-p speedbar-frame))
10993bad7aee (gdb-var-update-handler)
Nick Roberts <nickrob@snap.net.nz>
parents: 60124
diff changeset
441 ;; dummy command to update speedbar at right time
10993bad7aee (gdb-var-update-handler)
Nick Roberts <nickrob@snap.net.nz>
parents: 60124
diff changeset
442 (gdb-enqueue-input (list "server pwd\n" 'gdb-speedbar-timer-fn))
10993bad7aee (gdb-var-update-handler)
Nick Roberts <nickrob@snap.net.nz>
parents: 60124
diff changeset
443 ;; keep gdb-pending-triggers non-nil till end
10993bad7aee (gdb-var-update-handler)
Nick Roberts <nickrob@snap.net.nz>
parents: 60124
diff changeset
444 (push 'gdb-speedbar-timer gdb-pending-triggers)))
10993bad7aee (gdb-var-update-handler)
Nick Roberts <nickrob@snap.net.nz>
parents: 60124
diff changeset
445
10993bad7aee (gdb-var-update-handler)
Nick Roberts <nickrob@snap.net.nz>
parents: 60124
diff changeset
446 (defun gdb-speedbar-timer-fn ()
10993bad7aee (gdb-var-update-handler)
Nick Roberts <nickrob@snap.net.nz>
parents: 60124
diff changeset
447 (setq gdb-pending-triggers
10993bad7aee (gdb-var-update-handler)
Nick Roberts <nickrob@snap.net.nz>
parents: 60124
diff changeset
448 (delq 'gdb-speedbar-timer gdb-pending-triggers))
10993bad7aee (gdb-var-update-handler)
Nick Roberts <nickrob@snap.net.nz>
parents: 60124
diff changeset
449 (with-current-buffer gud-comint-buffer
10993bad7aee (gdb-var-update-handler)
Nick Roberts <nickrob@snap.net.nz>
parents: 60124
diff changeset
450 (speedbar-timer-fn)))
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
451
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
452 (defun gdb-var-delete ()
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
453 "Delete watched expression from the speedbar."
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
454 (interactive)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
455 (if (with-current-buffer gud-comint-buffer (eq gud-minor-mode 'gdba))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
456 (let ((text (speedbar-line-text)))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
457 (string-match "\\(\\S-+\\)" text)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
458 (let* ((expr (match-string 1 text))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
459 (var (assoc expr gdb-var-list))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
460 (varnum (cadr var)))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
461 (unless (string-match "\\." varnum)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
462 (gdb-enqueue-input
56285
313e3a9f34ca (breakpoint-enabled-bitmap-face)
Kim F. Storm <storm@cua.dk>
parents: 56258
diff changeset
463 (list
55764
25f133a490aa (gdb-var-update, gdb-var-update-handler, gdb-var-delete)
Nick Roberts <nickrob@snap.net.nz>
parents: 55762
diff changeset
464 (if (with-current-buffer gud-comint-buffer
25f133a490aa (gdb-var-update, gdb-var-update-handler, gdb-var-delete)
Nick Roberts <nickrob@snap.net.nz>
parents: 55762
diff changeset
465 (eq gud-minor-mode 'gdba))
25f133a490aa (gdb-var-update, gdb-var-update-handler, gdb-var-delete)
Nick Roberts <nickrob@snap.net.nz>
parents: 55762
diff changeset
466 (concat "server interpreter mi \"-var-delete " varnum "\"\n")
25f133a490aa (gdb-var-update, gdb-var-update-handler, gdb-var-delete)
Nick Roberts <nickrob@snap.net.nz>
parents: 55762
diff changeset
467 (concat "-var-delete " varnum "\n"))
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
468 'ignore))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
469 (setq gdb-var-list (delq var gdb-var-list))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
470 (dolist (varchild gdb-var-list)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
471 (if (string-match (concat (nth 1 var) "\\.") (nth 1 varchild))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
472 (setq gdb-var-list (delq varchild gdb-var-list))))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
473 (setq gdb-var-changed t))))))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
474
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
475 (defun gdb-edit-value (text token indent)
57791
d1b93fc4ce47 Docstring fixes.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57664
diff changeset
476 "Assign a value to a variable displayed in the speedbar."
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
477 (let* ((var (nth (- (count-lines (point-min) (point)) 2) gdb-var-list))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
478 (varnum (cadr var)) (value))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
479 (setq value (read-string "New value: "))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
480 (gdb-enqueue-input
55764
25f133a490aa (gdb-var-update, gdb-var-update-handler, gdb-var-delete)
Nick Roberts <nickrob@snap.net.nz>
parents: 55762
diff changeset
481 (list
25f133a490aa (gdb-var-update, gdb-var-update-handler, gdb-var-delete)
Nick Roberts <nickrob@snap.net.nz>
parents: 55762
diff changeset
482 (if (with-current-buffer gud-comint-buffer
25f133a490aa (gdb-var-update, gdb-var-update-handler, gdb-var-delete)
Nick Roberts <nickrob@snap.net.nz>
parents: 55762
diff changeset
483 (eq gud-minor-mode 'gdba))
25f133a490aa (gdb-var-update, gdb-var-update-handler, gdb-var-delete)
Nick Roberts <nickrob@snap.net.nz>
parents: 55762
diff changeset
484 (concat "server interpreter mi \"-var-assign " varnum " " value "\"\n")
25f133a490aa (gdb-var-update, gdb-var-update-handler, gdb-var-delete)
Nick Roberts <nickrob@snap.net.nz>
parents: 55762
diff changeset
485 (concat "-var-assign " varnum " " value "\n"))
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
486 'ignore))))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
487
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
488 (defcustom gdb-show-changed-values t
57791
d1b93fc4ce47 Docstring fixes.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57664
diff changeset
489 "If non-nil highlight values that have recently changed in the speedbar.
d1b93fc4ce47 Docstring fixes.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57664
diff changeset
490 The highlighting is done with `font-lock-warning-face'."
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
491 :type 'boolean
58049
fd0093bd412a (gdb-current-stack-level): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 57982
diff changeset
492 :group 'gud
59996
aac0a33f5772 Change release version from 21.4 to 22.1 throughout.
Kim F. Storm <storm@cua.dk>
parents: 59988
diff changeset
493 :version "22.1")
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
494
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
495 (defun gdb-speedbar-expand-node (text token indent)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
496 "Expand the node the user clicked on.
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
497 TEXT is the text of the button we clicked on, a + or - item.
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
498 TOKEN is data related to this node.
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
499 INDENT is the current indentation depth."
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
500 (cond ((string-match "+" text) ;expand this node
55764
25f133a490aa (gdb-var-update, gdb-var-update-handler, gdb-var-delete)
Nick Roberts <nickrob@snap.net.nz>
parents: 55762
diff changeset
501 (if (with-current-buffer gud-comint-buffer (eq gud-minor-mode 'gdba))
25f133a490aa (gdb-var-update, gdb-var-update-handler, gdb-var-delete)
Nick Roberts <nickrob@snap.net.nz>
parents: 55762
diff changeset
502 (gdb-var-list-children token)
25f133a490aa (gdb-var-update, gdb-var-update-handler, gdb-var-delete)
Nick Roberts <nickrob@snap.net.nz>
parents: 55762
diff changeset
503 (gdbmi-var-list-children token)))
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
504 ((string-match "-" text) ;contract this node
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
505 (dolist (var gdb-var-list)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
506 (if (string-match (concat token "\\.") (nth 1 var))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
507 (setq gdb-var-list (delq var gdb-var-list))))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
508 (setq gdb-var-changed t))))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
509
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
510 (defun gdb-get-target-string ()
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
511 (with-current-buffer gud-comint-buffer
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
512 gud-target-name))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
513
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
514
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
515 ;;
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
516 ;; gdb buffers.
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
517 ;;
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
518 ;; Each buffer has a TYPE -- a symbol that identifies the function
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
519 ;; of that particular buffer.
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
520 ;;
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
521 ;; The usual gdb interaction buffer is given the type `gdba' and
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
522 ;; is constructed specially.
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
523 ;;
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
524 ;; Others are constructed by gdb-get-create-buffer and
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
525 ;; named according to the rules set forth in the gdb-buffer-rules-assoc
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
526
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
527 (defvar gdb-buffer-rules-assoc '())
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
528
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
529 (defun gdb-get-buffer (key)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
530 "Return the gdb buffer tagged with type KEY.
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
531 The key should be one of the cars in `gdb-buffer-rules-assoc'."
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
532 (save-excursion
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
533 (gdb-look-for-tagged-buffer key (buffer-list))))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
534
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
535 (defun gdb-get-create-buffer (key)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
536 "Create a new gdb buffer of the type specified by KEY.
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
537 The key should be one of the cars in `gdb-buffer-rules-assoc'."
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
538 (or (gdb-get-buffer key)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
539 (let* ((rules (assoc key gdb-buffer-rules-assoc))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
540 (name (funcall (gdb-rules-name-maker rules)))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
541 (new (get-buffer-create name)))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
542 (with-current-buffer new
59996
aac0a33f5772 Change release version from 21.4 to 22.1 throughout.
Kim F. Storm <storm@cua.dk>
parents: 59988
diff changeset
543 (let ((trigger))
57661
b59713cd72a2 (gdb-get-create-buffer): Allow modes to run
Nick Roberts <nickrob@snap.net.nz>
parents: 57350
diff changeset
544 (if (cdr (cdr rules))
b59713cd72a2 (gdb-get-create-buffer): Allow modes to run
Nick Roberts <nickrob@snap.net.nz>
parents: 57350
diff changeset
545 (setq trigger (funcall (car (cdr (cdr rules))))))
b59713cd72a2 (gdb-get-create-buffer): Allow modes to run
Nick Roberts <nickrob@snap.net.nz>
parents: 57350
diff changeset
546 (set (make-local-variable 'gdb-buffer-type) key)
b59713cd72a2 (gdb-get-create-buffer): Allow modes to run
Nick Roberts <nickrob@snap.net.nz>
parents: 57350
diff changeset
547 (set (make-local-variable 'gud-minor-mode)
b59713cd72a2 (gdb-get-create-buffer): Allow modes to run
Nick Roberts <nickrob@snap.net.nz>
parents: 57350
diff changeset
548 (with-current-buffer gud-comint-buffer gud-minor-mode))
b59713cd72a2 (gdb-get-create-buffer): Allow modes to run
Nick Roberts <nickrob@snap.net.nz>
parents: 57350
diff changeset
549 (set (make-local-variable 'tool-bar-map) gud-tool-bar-map)
b59713cd72a2 (gdb-get-create-buffer): Allow modes to run
Nick Roberts <nickrob@snap.net.nz>
parents: 57350
diff changeset
550 (if trigger (funcall trigger)))
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
551 new))))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
552
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
553 (defun gdb-rules-name-maker (rules) (car (cdr rules)))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
554
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
555 (defun gdb-look-for-tagged-buffer (key bufs)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
556 (let ((retval nil))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
557 (while (and (not retval) bufs)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
558 (set-buffer (car bufs))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
559 (if (eq gdb-buffer-type key)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
560 (setq retval (car bufs)))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
561 (setq bufs (cdr bufs)))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
562 retval))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
563
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
564 ;;
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
565 ;; This assoc maps buffer type symbols to rules. Each rule is a list of
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
566 ;; at least one and possible more functions. The functions have these
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
567 ;; roles in defining a buffer type:
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
568 ;;
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
569 ;; NAME - Return a name for this buffer type.
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
570 ;;
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
571 ;; The remaining function(s) are optional:
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
572 ;;
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
573 ;; MODE - called in a new buffer with no arguments, should establish
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
574 ;; the proper mode for the buffer.
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
575 ;;
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
576
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
577 (defun gdb-set-buffer-rules (buffer-type &rest rules)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
578 (let ((binding (assoc buffer-type gdb-buffer-rules-assoc)))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
579 (if binding
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
580 (setcdr binding rules)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
581 (push (cons buffer-type rules)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
582 gdb-buffer-rules-assoc))))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
583
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
584 ;; GUD buffers are an exception to the rules
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
585 (gdb-set-buffer-rules 'gdba 'error)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
586
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
587 ;;
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
588 ;; Partial-output buffer : This accumulates output from a command executed on
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
589 ;; behalf of emacs (rather than the user).
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
590 ;;
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
591 (gdb-set-buffer-rules 'gdb-partial-output-buffer
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
592 'gdb-partial-output-name)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
593
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
594 (defun gdb-partial-output-name ()
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
595 (concat "*partial-output-"
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
596 (gdb-get-target-string)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
597 "*"))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
598
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
599
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
600 (gdb-set-buffer-rules 'gdb-inferior-io
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
601 'gdb-inferior-io-name
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
602 'gdb-inferior-io-mode)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
603
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
604 (defun gdb-inferior-io-name ()
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
605 (concat "*input/output of "
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
606 (gdb-get-target-string)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
607 "*"))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
608
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
609 (defvar gdb-inferior-io-mode-map
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
610 (let ((map (make-sparse-keymap)))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
611 (define-key map "\C-c\C-c" 'gdb-inferior-io-interrupt)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
612 (define-key map "\C-c\C-z" 'gdb-inferior-io-stop)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
613 (define-key map "\C-c\C-\\" 'gdb-inferior-io-quit)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
614 (define-key map "\C-c\C-d" 'gdb-inferior-io-eof)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
615 map))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
616
55749
230865f1c59d (gdb-server-prefix): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 55696
diff changeset
617 (define-derived-mode gdb-inferior-io-mode comint-mode "Inferior I/O"
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
618 "Major mode for gdb inferior-io."
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
619 :syntax-table nil :abbrev-table nil
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
620 ;; We want to use comint because it has various nifty and familiar
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
621 ;; features. We don't need a process, but comint wants one, so create
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
622 ;; a dummy one.
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
623 (make-comint-in-buffer
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
624 (substring (buffer-name) 1 (- (length (buffer-name)) 1))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
625 (current-buffer) "hexl")
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
626 (setq comint-input-sender 'gdb-inferior-io-sender))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
627
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
628 (defun gdb-inferior-io-sender (proc string)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
629 ;; PROC is the pseudo-process created to satisfy comint.
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
630 (with-current-buffer (process-buffer proc)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
631 (setq proc (get-buffer-process gud-comint-buffer))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
632 (process-send-string proc string)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
633 (process-send-string proc "\n")))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
634
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
635 (defun gdb-inferior-io-interrupt ()
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
636 "Interrupt the program being debugged."
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
637 (interactive)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
638 (interrupt-process
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
639 (get-buffer-process gud-comint-buffer) comint-ptyp))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
640
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
641 (defun gdb-inferior-io-quit ()
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
642 "Send quit signal to the program being debugged."
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
643 (interactive)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
644 (quit-process
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
645 (get-buffer-process gud-comint-buffer) comint-ptyp))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
646
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
647 (defun gdb-inferior-io-stop ()
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
648 "Stop the program being debugged."
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
649 (interactive)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
650 (stop-process
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
651 (get-buffer-process gud-comint-buffer) comint-ptyp))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
652
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
653 (defun gdb-inferior-io-eof ()
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
654 "Send end-of-file to the program being debugged."
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
655 (interactive)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
656 (process-send-eof
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
657 (get-buffer-process gud-comint-buffer)))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
658
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
659
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
660 ;;
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
661 ;; gdb communications
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
662 ;;
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
663
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
664 ;; INPUT: things sent to gdb
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
665 ;;
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
666 ;; The queues are lists. Each element is either a string (indicating user or
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
667 ;; user-like input) or a list of the form:
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
668 ;;
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
669 ;; (INPUT-STRING HANDLER-FN)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
670 ;;
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
671 ;; The handler function will be called from the partial-output buffer when the
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
672 ;; command completes. This is the way to write commands which invoke gdb
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
673 ;; commands autonomously.
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
674 ;;
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
675 ;; These lists are consumed tail first.
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
676 ;;
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
677
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
678 (defun gdb-send (proc string)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
679 "A comint send filter for gdb.
57791
d1b93fc4ce47 Docstring fixes.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57664
diff changeset
680 This filter may simply queue input for a later time."
60477
2b7513e741b1 (gdb-var-create-handler): Handle just MI case.
Nick Roberts <nickrob@snap.net.nz>
parents: 60326
diff changeset
681 (let ((item (concat string "\n")))
2b7513e741b1 (gdb-var-create-handler): Handle just MI case.
Nick Roberts <nickrob@snap.net.nz>
parents: 60326
diff changeset
682 (if gud-running
2b7513e741b1 (gdb-var-create-handler): Handle just MI case.
Nick Roberts <nickrob@snap.net.nz>
parents: 60326
diff changeset
683 (progn
2b7513e741b1 (gdb-var-create-handler): Handle just MI case.
Nick Roberts <nickrob@snap.net.nz>
parents: 60326
diff changeset
684 (if gdb-enable-debug-log (push (cons 'send item) gdb-debug-log))
2b7513e741b1 (gdb-var-create-handler): Handle just MI case.
Nick Roberts <nickrob@snap.net.nz>
parents: 60326
diff changeset
685 (process-send-string proc item))
2b7513e741b1 (gdb-var-create-handler): Handle just MI case.
Nick Roberts <nickrob@snap.net.nz>
parents: 60326
diff changeset
686 (gdb-enqueue-input item))))
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
687
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
688 ;; Note: Stuff enqueued here will be sent to the next prompt, even if it
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
689 ;; is a query, or other non-top-level prompt.
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
690
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
691 (defun gdb-enqueue-input (item)
55749
230865f1c59d (gdb-server-prefix): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 55696
diff changeset
692 (if gdb-prompting
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
693 (progn
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
694 (gdb-send-item item)
55749
230865f1c59d (gdb-server-prefix): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 55696
diff changeset
695 (setq gdb-prompting nil))
230865f1c59d (gdb-server-prefix): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 55696
diff changeset
696 (push item gdb-input-queue)))
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
697
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
698 (defun gdb-dequeue-input ()
55749
230865f1c59d (gdb-server-prefix): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 55696
diff changeset
699 (let ((queue gdb-input-queue))
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
700 (and queue
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
701 (let ((last (car (last queue))))
55749
230865f1c59d (gdb-server-prefix): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 55696
diff changeset
702 (unless (nbutlast queue) (setq gdb-input-queue '()))
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
703 last))))
58420
97e4fc5c7297 (gdb-resync): New function.
Nick Roberts <nickrob@snap.net.nz>
parents: 58049
diff changeset
704
97e4fc5c7297 (gdb-resync): New function.
Nick Roberts <nickrob@snap.net.nz>
parents: 58049
diff changeset
705 (defun gdb-send-item (item)
58431
da65edef151e (gdb-flush-pending-output): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 58420
diff changeset
706 (setq gdb-flush-pending-output nil)
60477
2b7513e741b1 (gdb-var-create-handler): Handle just MI case.
Nick Roberts <nickrob@snap.net.nz>
parents: 60326
diff changeset
707 (if gdb-enable-debug-log (push (cons 'send-item item) gdb-debug-log))
58420
97e4fc5c7297 (gdb-resync): New function.
Nick Roberts <nickrob@snap.net.nz>
parents: 58049
diff changeset
708 (setq gdb-current-item item)
97e4fc5c7297 (gdb-resync): New function.
Nick Roberts <nickrob@snap.net.nz>
parents: 58049
diff changeset
709 (with-current-buffer gud-comint-buffer
97e4fc5c7297 (gdb-resync): New function.
Nick Roberts <nickrob@snap.net.nz>
parents: 58049
diff changeset
710 (if (eq gud-minor-mode 'gdba)
97e4fc5c7297 (gdb-resync): New function.
Nick Roberts <nickrob@snap.net.nz>
parents: 58049
diff changeset
711 (if (stringp item)
97e4fc5c7297 (gdb-resync): New function.
Nick Roberts <nickrob@snap.net.nz>
parents: 58049
diff changeset
712 (progn
97e4fc5c7297 (gdb-resync): New function.
Nick Roberts <nickrob@snap.net.nz>
parents: 58049
diff changeset
713 (setq gdb-output-sink 'user)
97e4fc5c7297 (gdb-resync): New function.
Nick Roberts <nickrob@snap.net.nz>
parents: 58049
diff changeset
714 (process-send-string (get-buffer-process gud-comint-buffer) item))
97e4fc5c7297 (gdb-resync): New function.
Nick Roberts <nickrob@snap.net.nz>
parents: 58049
diff changeset
715 (progn
97e4fc5c7297 (gdb-resync): New function.
Nick Roberts <nickrob@snap.net.nz>
parents: 58049
diff changeset
716 (gdb-clear-partial-output)
97e4fc5c7297 (gdb-resync): New function.
Nick Roberts <nickrob@snap.net.nz>
parents: 58049
diff changeset
717 (setq gdb-output-sink 'pre-emacs)
97e4fc5c7297 (gdb-resync): New function.
Nick Roberts <nickrob@snap.net.nz>
parents: 58049
diff changeset
718 (process-send-string (get-buffer-process gud-comint-buffer)
97e4fc5c7297 (gdb-resync): New function.
Nick Roberts <nickrob@snap.net.nz>
parents: 58049
diff changeset
719 (car item))))
97e4fc5c7297 (gdb-resync): New function.
Nick Roberts <nickrob@snap.net.nz>
parents: 58049
diff changeset
720 ;; case: eq gud-minor-mode 'gdbmi
97e4fc5c7297 (gdb-resync): New function.
Nick Roberts <nickrob@snap.net.nz>
parents: 58049
diff changeset
721 (gdb-clear-partial-output)
97e4fc5c7297 (gdb-resync): New function.
Nick Roberts <nickrob@snap.net.nz>
parents: 58049
diff changeset
722 (setq gdb-output-sink 'emacs)
97e4fc5c7297 (gdb-resync): New function.
Nick Roberts <nickrob@snap.net.nz>
parents: 58049
diff changeset
723 (process-send-string (get-buffer-process gud-comint-buffer)
97e4fc5c7297 (gdb-resync): New function.
Nick Roberts <nickrob@snap.net.nz>
parents: 58049
diff changeset
724 (car item)))))
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
725
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
726 ;;
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
727 ;; output -- things gdb prints to emacs
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
728 ;;
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
729 ;; GDB output is a stream interrupted by annotations.
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
730 ;; Annotations can be recognized by their beginning
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
731 ;; with \C-j\C-z\C-z<tag><opt>\C-j
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
732 ;;
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
733 ;; The tag is a string obeying symbol syntax.
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
734 ;;
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
735 ;; The optional part `<opt>' can be either the empty string
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
736 ;; or a space followed by more data relating to the annotation.
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
737 ;; For example, the SOURCE annotation is followed by a filename,
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
738 ;; line number and various useless goo. This data must not include
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
739 ;; any newlines.
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
740 ;;
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
741
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
742 (defcustom gud-gdba-command-name "gdb -annotate=3"
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
743 "Default command to execute an executable under the GDB-UI debugger."
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
744 :type 'string
57851
67b88e92a24d (gdb-enable-debug-log)
Nick Roberts <nickrob@snap.net.nz>
parents: 57791
diff changeset
745 :group 'gud
59996
aac0a33f5772 Change release version from 21.4 to 22.1 throughout.
Kim F. Storm <storm@cua.dk>
parents: 59988
diff changeset
746 :version "22.1")
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
747
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
748 (defvar gdb-annotation-rules
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
749 '(("pre-prompt" gdb-pre-prompt)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
750 ("prompt" gdb-prompt)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
751 ("commands" gdb-subprompt)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
752 ("overload-choice" gdb-subprompt)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
753 ("query" gdb-subprompt)
55749
230865f1c59d (gdb-server-prefix): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 55696
diff changeset
754 ;; Need this prompt for GDB 6.1
55507
e266c6d6bd7a (gdb-annotation-rules): Add nquery annotation
Nick Roberts <nickrob@snap.net.nz>
parents: 55400
diff changeset
755 ("nquery" gdb-subprompt)
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
756 ("prompt-for-continue" gdb-subprompt)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
757 ("post-prompt" gdb-post-prompt)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
758 ("source" gdb-source)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
759 ("starting" gdb-starting)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
760 ("exited" gdb-stopping)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
761 ("signalled" gdb-stopping)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
762 ("signal" gdb-stopping)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
763 ("breakpoint" gdb-stopping)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
764 ("watchpoint" gdb-stopping)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
765 ("frame-begin" gdb-frame-begin)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
766 ("stopped" gdb-stopped)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
767 ) "An assoc mapping annotation tags to functions which process them.")
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
768
58420
97e4fc5c7297 (gdb-resync): New function.
Nick Roberts <nickrob@snap.net.nz>
parents: 58049
diff changeset
769 (defun gdb-resync()
58431
da65edef151e (gdb-flush-pending-output): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 58420
diff changeset
770 (setq gdb-flush-pending-output t)
58420
97e4fc5c7297 (gdb-resync): New function.
Nick Roberts <nickrob@snap.net.nz>
parents: 58049
diff changeset
771 (setq gud-running nil)
97e4fc5c7297 (gdb-resync): New function.
Nick Roberts <nickrob@snap.net.nz>
parents: 58049
diff changeset
772 (setq gdb-output-sink 'user)
97e4fc5c7297 (gdb-resync): New function.
Nick Roberts <nickrob@snap.net.nz>
parents: 58049
diff changeset
773 (setq gdb-input-queue nil)
97e4fc5c7297 (gdb-resync): New function.
Nick Roberts <nickrob@snap.net.nz>
parents: 58049
diff changeset
774 (setq gdb-pending-triggers nil)
97e4fc5c7297 (gdb-resync): New function.
Nick Roberts <nickrob@snap.net.nz>
parents: 58049
diff changeset
775 (setq gdb-prompting t))
97e4fc5c7297 (gdb-resync): New function.
Nick Roberts <nickrob@snap.net.nz>
parents: 58049
diff changeset
776
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
777 (defconst gdb-source-spec-regexp
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
778 "\\(.*\\):\\([0-9]*\\):[0-9]*:[a-z]*:\\(0x[a-f0-9]*\\)")
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
779
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
780 ;; Do not use this except as an annotation handler.
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
781 (defun gdb-source (args)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
782 (string-match gdb-source-spec-regexp args)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
783 ;; Extract the frame position from the marker.
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
784 (setq gud-last-frame
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
785 (cons
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
786 (match-string 1 args)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
787 (string-to-int (match-string 2 args))))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
788 (setq gdb-current-address (match-string 3 args))
54962
c3272c09f927 (gdb-goto-info): Require 'info.
Nick Roberts <nickrob@snap.net.nz>
parents: 54901
diff changeset
789 ;; cover for auto-display output which comes *before*
c3272c09f927 (gdb-goto-info): Require 'info.
Nick Roberts <nickrob@snap.net.nz>
parents: 54901
diff changeset
790 ;; stopped annotation
55749
230865f1c59d (gdb-server-prefix): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 55696
diff changeset
791 (if (eq gdb-output-sink 'inferior) (setq gdb-output-sink 'user)))
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
792
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
793 (defun gdb-pre-prompt (ignored)
57791
d1b93fc4ce47 Docstring fixes.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57664
diff changeset
794 "An annotation handler for `pre-prompt'.
d1b93fc4ce47 Docstring fixes.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57664
diff changeset
795 This terminates the collection of output from a previous command if that
d1b93fc4ce47 Docstring fixes.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57664
diff changeset
796 happens to be in effect."
55749
230865f1c59d (gdb-server-prefix): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 55696
diff changeset
797 (let ((sink gdb-output-sink))
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
798 (cond
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
799 ((eq sink 'user) t)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
800 ((eq sink 'emacs)
55749
230865f1c59d (gdb-server-prefix): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 55696
diff changeset
801 (setq gdb-output-sink 'post-emacs))
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
802 (t
58420
97e4fc5c7297 (gdb-resync): New function.
Nick Roberts <nickrob@snap.net.nz>
parents: 58049
diff changeset
803 (gdb-resync)
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
804 (error "Phase error in gdb-pre-prompt (got %s)" sink)))))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
805
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
806 (defun gdb-prompt (ignored)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
807 "An annotation handler for `prompt'.
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
808 This sends the next command (if any) to gdb."
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
809 (when gdb-first-prompt (gdb-ann3))
55749
230865f1c59d (gdb-server-prefix): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 55696
diff changeset
810 (let ((sink gdb-output-sink))
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
811 (cond
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
812 ((eq sink 'user) t)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
813 ((eq sink 'post-emacs)
55749
230865f1c59d (gdb-server-prefix): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 55696
diff changeset
814 (setq gdb-output-sink 'user)
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
815 (let ((handler
55749
230865f1c59d (gdb-server-prefix): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 55696
diff changeset
816 (car (cdr gdb-current-item))))
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
817 (with-current-buffer (gdb-get-create-buffer 'gdb-partial-output-buffer)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
818 (funcall handler))))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
819 (t
58420
97e4fc5c7297 (gdb-resync): New function.
Nick Roberts <nickrob@snap.net.nz>
parents: 58049
diff changeset
820 (gdb-resync)
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
821 (error "Phase error in gdb-prompt (got %s)" sink))))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
822 (let ((input (gdb-dequeue-input)))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
823 (if input
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
824 (gdb-send-item input)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
825 (progn
55749
230865f1c59d (gdb-server-prefix): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 55696
diff changeset
826 (setq gdb-prompting t)
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
827 (gud-display-frame)))))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
828
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
829 (defun gdb-subprompt (ignored)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
830 "An annotation handler for non-top-level prompts."
55749
230865f1c59d (gdb-server-prefix): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 55696
diff changeset
831 (setq gdb-prompting t))
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
832
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
833 (defun gdb-starting (ignored)
57791
d1b93fc4ce47 Docstring fixes.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57664
diff changeset
834 "An annotation handler for `starting'.
d1b93fc4ce47 Docstring fixes.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57664
diff changeset
835 This says that I/O for the subprocess is now the program being debugged,
d1b93fc4ce47 Docstring fixes.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57664
diff changeset
836 not GDB."
55749
230865f1c59d (gdb-server-prefix): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 55696
diff changeset
837 (let ((sink gdb-output-sink))
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
838 (cond
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
839 ((eq sink 'user)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
840 (progn
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
841 (setq gud-running t)
54729
7bfccd78beed (gdb-use-inferior-io-buffer): New option.
Nick Roberts <nickrob@snap.net.nz>
parents: 54668
diff changeset
842 (if gdb-use-inferior-io-buffer
55749
230865f1c59d (gdb-server-prefix): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 55696
diff changeset
843 (setq gdb-output-sink 'inferior))))
59996
aac0a33f5772 Change release version from 21.4 to 22.1 throughout.
Kim F. Storm <storm@cua.dk>
parents: 59988
diff changeset
844 (t
58420
97e4fc5c7297 (gdb-resync): New function.
Nick Roberts <nickrob@snap.net.nz>
parents: 58049
diff changeset
845 (gdb-resync)
97e4fc5c7297 (gdb-resync): New function.
Nick Roberts <nickrob@snap.net.nz>
parents: 58049
diff changeset
846 (error "Unexpected `starting' annotation")))))
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
847
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
848 (defun gdb-stopping (ignored)
57791
d1b93fc4ce47 Docstring fixes.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57664
diff changeset
849 "An annotation handler for `exited' and other annotations.
d1b93fc4ce47 Docstring fixes.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57664
diff changeset
850 They say that I/O for the subprocess is now GDB, not the program
d1b93fc4ce47 Docstring fixes.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57664
diff changeset
851 being debugged."
54729
7bfccd78beed (gdb-use-inferior-io-buffer): New option.
Nick Roberts <nickrob@snap.net.nz>
parents: 54668
diff changeset
852 (if gdb-use-inferior-io-buffer
55749
230865f1c59d (gdb-server-prefix): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 55696
diff changeset
853 (let ((sink gdb-output-sink))
54729
7bfccd78beed (gdb-use-inferior-io-buffer): New option.
Nick Roberts <nickrob@snap.net.nz>
parents: 54668
diff changeset
854 (cond
7bfccd78beed (gdb-use-inferior-io-buffer): New option.
Nick Roberts <nickrob@snap.net.nz>
parents: 54668
diff changeset
855 ((eq sink 'inferior)
55749
230865f1c59d (gdb-server-prefix): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 55696
diff changeset
856 (setq gdb-output-sink 'user))
58420
97e4fc5c7297 (gdb-resync): New function.
Nick Roberts <nickrob@snap.net.nz>
parents: 58049
diff changeset
857 (t
97e4fc5c7297 (gdb-resync): New function.
Nick Roberts <nickrob@snap.net.nz>
parents: 58049
diff changeset
858 (gdb-resync)
97e4fc5c7297 (gdb-resync): New function.
Nick Roberts <nickrob@snap.net.nz>
parents: 58049
diff changeset
859 (error "Unexpected stopping annotation"))))))
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
860
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
861 (defun gdb-frame-begin (ignored)
55749
230865f1c59d (gdb-server-prefix): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 55696
diff changeset
862 (let ((sink gdb-output-sink))
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
863 (cond
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
864 ((eq sink 'inferior)
55749
230865f1c59d (gdb-server-prefix): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 55696
diff changeset
865 (setq gdb-output-sink 'user))
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
866 ((eq sink 'user) t)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
867 ((eq sink 'emacs) t)
58420
97e4fc5c7297 (gdb-resync): New function.
Nick Roberts <nickrob@snap.net.nz>
parents: 58049
diff changeset
868 (t
97e4fc5c7297 (gdb-resync): New function.
Nick Roberts <nickrob@snap.net.nz>
parents: 58049
diff changeset
869 (gdb-resync)
97e4fc5c7297 (gdb-resync): New function.
Nick Roberts <nickrob@snap.net.nz>
parents: 58049
diff changeset
870 (error "Unexpected frame-begin annotation (%S)" sink)))))
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
871
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
872 (defun gdb-stopped (ignored)
57791
d1b93fc4ce47 Docstring fixes.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57664
diff changeset
873 "An annotation handler for `stopped'.
d1b93fc4ce47 Docstring fixes.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57664
diff changeset
874 It is just like `gdb-stopping', except that if we already set the output
d1b93fc4ce47 Docstring fixes.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57664
diff changeset
875 sink to `user' in `gdb-stopping', that is fine."
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
876 (setq gud-running nil)
55749
230865f1c59d (gdb-server-prefix): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 55696
diff changeset
877 (let ((sink gdb-output-sink))
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
878 (cond
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
879 ((eq sink 'inferior)
55749
230865f1c59d (gdb-server-prefix): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 55696
diff changeset
880 (setq gdb-output-sink 'user))
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
881 ((eq sink 'user) t)
58420
97e4fc5c7297 (gdb-resync): New function.
Nick Roberts <nickrob@snap.net.nz>
parents: 58049
diff changeset
882 (t
97e4fc5c7297 (gdb-resync): New function.
Nick Roberts <nickrob@snap.net.nz>
parents: 58049
diff changeset
883 (gdb-resync)
97e4fc5c7297 (gdb-resync): New function.
Nick Roberts <nickrob@snap.net.nz>
parents: 58049
diff changeset
884 (error "Unexpected stopped annotation")))))
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
885
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
886 (defun gdb-post-prompt (ignored)
57791
d1b93fc4ce47 Docstring fixes.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57664
diff changeset
887 "An annotation handler for `post-prompt'.
d1b93fc4ce47 Docstring fixes.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57664
diff changeset
888 This begins the collection of output from the current command if that
d1b93fc4ce47 Docstring fixes.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57664
diff changeset
889 happens to be appropriate."
60326
47c96976e43d (gdb-get-location): Use a warning instead
Nick Roberts <nickrob@snap.net.nz>
parents: 60153
diff changeset
890 (unless gdb-pending-triggers
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
891 (gdb-get-current-frame)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
892 (gdb-invalidate-frames)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
893 (gdb-invalidate-breakpoints)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
894 (gdb-invalidate-assembler)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
895 (gdb-invalidate-registers)
59808
37a65df00ab2 (gdb-memory-address)
Nick Roberts <nickrob@snap.net.nz>
parents: 59766
diff changeset
896 (gdb-invalidate-memory)
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
897 (gdb-invalidate-locals)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
898 (gdb-invalidate-threads)
54617
9049edac1117 (gdb-post-prompt): Fix test.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 54616
diff changeset
899 (unless (eq system-type 'darwin) ;Breaks on Darwin's GDB-5.3.
9049edac1117 (gdb-post-prompt): Fix test.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 54616
diff changeset
900 ;; FIXME: with GDB-6 on Darwin, this might very well work.
60153
10993bad7aee (gdb-var-update-handler)
Nick Roberts <nickrob@snap.net.nz>
parents: 60124
diff changeset
901 ;; only needed/used with speedbar/watch expressions
10993bad7aee (gdb-var-update-handler)
Nick Roberts <nickrob@snap.net.nz>
parents: 60124
diff changeset
902 (when (and (boundp 'speedbar-frame) (frame-live-p speedbar-frame))
10993bad7aee (gdb-var-update-handler)
Nick Roberts <nickrob@snap.net.nz>
parents: 60124
diff changeset
903 (setq gdb-var-changed t) ; force update
10993bad7aee (gdb-var-update-handler)
Nick Roberts <nickrob@snap.net.nz>
parents: 60124
diff changeset
904 (dolist (var gdb-var-list)
10993bad7aee (gdb-var-update-handler)
Nick Roberts <nickrob@snap.net.nz>
parents: 60124
diff changeset
905 (setcar (nthcdr 5 var) nil))
60326
47c96976e43d (gdb-get-location): Use a warning instead
Nick Roberts <nickrob@snap.net.nz>
parents: 60153
diff changeset
906 (gdb-var-update))))
55749
230865f1c59d (gdb-server-prefix): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 55696
diff changeset
907 (let ((sink gdb-output-sink))
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
908 (cond
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
909 ((eq sink 'user) t)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
910 ((eq sink 'pre-emacs)
55749
230865f1c59d (gdb-server-prefix): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 55696
diff changeset
911 (setq gdb-output-sink 'emacs))
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
912 (t
58420
97e4fc5c7297 (gdb-resync): New function.
Nick Roberts <nickrob@snap.net.nz>
parents: 58049
diff changeset
913 (gdb-resync)
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
914 (error "Phase error in gdb-post-prompt (got %s)" sink)))))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
915
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
916 (defun gud-gdba-marker-filter (string)
57791
d1b93fc4ce47 Docstring fixes.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57664
diff changeset
917 "A gud marker filter for gdb. Handle a burst of output from GDB."
58431
da65edef151e (gdb-flush-pending-output): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 58420
diff changeset
918 (if gdb-flush-pending-output
da65edef151e (gdb-flush-pending-output): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 58420
diff changeset
919 nil
da65edef151e (gdb-flush-pending-output): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 58420
diff changeset
920 (if gdb-enable-debug-log (push (cons 'recv string) gdb-debug-log))
da65edef151e (gdb-flush-pending-output): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 58420
diff changeset
921 ;; Recall the left over gud-marker-acc from last time
da65edef151e (gdb-flush-pending-output): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 58420
diff changeset
922 (setq gud-marker-acc (concat gud-marker-acc string))
da65edef151e (gdb-flush-pending-output): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 58420
diff changeset
923 ;; Start accumulating output for the GUD buffer
da65edef151e (gdb-flush-pending-output): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 58420
diff changeset
924 (let ((output ""))
da65edef151e (gdb-flush-pending-output): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 58420
diff changeset
925 ;;
da65edef151e (gdb-flush-pending-output): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 58420
diff changeset
926 ;; Process all the complete markers in this chunk.
da65edef151e (gdb-flush-pending-output): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 58420
diff changeset
927 (while (string-match "\n\032\032\\(.*\\)\n" gud-marker-acc)
da65edef151e (gdb-flush-pending-output): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 58420
diff changeset
928 (let ((annotation (match-string 1 gud-marker-acc)))
da65edef151e (gdb-flush-pending-output): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 58420
diff changeset
929 ;;
da65edef151e (gdb-flush-pending-output): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 58420
diff changeset
930 ;; Stuff prior to the match is just ordinary output.
da65edef151e (gdb-flush-pending-output): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 58420
diff changeset
931 ;; It is either concatenated to OUTPUT or directed
da65edef151e (gdb-flush-pending-output): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 58420
diff changeset
932 ;; elsewhere.
da65edef151e (gdb-flush-pending-output): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 58420
diff changeset
933 (setq output
da65edef151e (gdb-flush-pending-output): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 58420
diff changeset
934 (gdb-concat-output
da65edef151e (gdb-flush-pending-output): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 58420
diff changeset
935 output
da65edef151e (gdb-flush-pending-output): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 58420
diff changeset
936 (substring gud-marker-acc 0 (match-beginning 0))))
da65edef151e (gdb-flush-pending-output): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 58420
diff changeset
937 ;;
da65edef151e (gdb-flush-pending-output): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 58420
diff changeset
938 ;; Take that stuff off the gud-marker-acc.
da65edef151e (gdb-flush-pending-output): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 58420
diff changeset
939 (setq gud-marker-acc (substring gud-marker-acc (match-end 0)))
da65edef151e (gdb-flush-pending-output): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 58420
diff changeset
940 ;;
da65edef151e (gdb-flush-pending-output): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 58420
diff changeset
941 ;; Parse the tag from the annotation, and maybe its arguments.
da65edef151e (gdb-flush-pending-output): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 58420
diff changeset
942 (string-match "\\(\\S-*\\) ?\\(.*\\)" annotation)
da65edef151e (gdb-flush-pending-output): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 58420
diff changeset
943 (let* ((annotation-type (match-string 1 annotation))
da65edef151e (gdb-flush-pending-output): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 58420
diff changeset
944 (annotation-arguments (match-string 2 annotation))
da65edef151e (gdb-flush-pending-output): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 58420
diff changeset
945 (annotation-rule (assoc annotation-type
da65edef151e (gdb-flush-pending-output): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 58420
diff changeset
946 gdb-annotation-rules)))
da65edef151e (gdb-flush-pending-output): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 58420
diff changeset
947 ;; Call the handler for this annotation.
da65edef151e (gdb-flush-pending-output): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 58420
diff changeset
948 (if annotation-rule
da65edef151e (gdb-flush-pending-output): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 58420
diff changeset
949 (funcall (car (cdr annotation-rule))
da65edef151e (gdb-flush-pending-output): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 58420
diff changeset
950 annotation-arguments)
da65edef151e (gdb-flush-pending-output): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 58420
diff changeset
951 ;; Else the annotation is not recognized. Ignore it silently,
da65edef151e (gdb-flush-pending-output): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 58420
diff changeset
952 ;; so that GDB can add new annotations without causing
da65edef151e (gdb-flush-pending-output): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 58420
diff changeset
953 ;; us to blow up.
da65edef151e (gdb-flush-pending-output): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 58420
diff changeset
954 ))))
da65edef151e (gdb-flush-pending-output): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 58420
diff changeset
955 ;;
da65edef151e (gdb-flush-pending-output): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 58420
diff changeset
956 ;; Does the remaining text end in a partial line?
da65edef151e (gdb-flush-pending-output): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 58420
diff changeset
957 ;; If it does, then keep part of the gud-marker-acc until we get more.
da65edef151e (gdb-flush-pending-output): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 58420
diff changeset
958 (if (string-match "\n\\'\\|\n\032\\'\\|\n\032\032.*\\'"
da65edef151e (gdb-flush-pending-output): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 58420
diff changeset
959 gud-marker-acc)
da65edef151e (gdb-flush-pending-output): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 58420
diff changeset
960 (progn
da65edef151e (gdb-flush-pending-output): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 58420
diff changeset
961 ;; Everything before the potential marker start can be output.
da65edef151e (gdb-flush-pending-output): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 58420
diff changeset
962 (setq output
da65edef151e (gdb-flush-pending-output): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 58420
diff changeset
963 (gdb-concat-output output
da65edef151e (gdb-flush-pending-output): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 58420
diff changeset
964 (substring gud-marker-acc 0
da65edef151e (gdb-flush-pending-output): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 58420
diff changeset
965 (match-beginning 0))))
da65edef151e (gdb-flush-pending-output): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 58420
diff changeset
966 ;;
da65edef151e (gdb-flush-pending-output): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 58420
diff changeset
967 ;; Everything after, we save, to combine with later input.
da65edef151e (gdb-flush-pending-output): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 58420
diff changeset
968 (setq gud-marker-acc (substring gud-marker-acc (match-beginning 0))))
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
969 ;;
58431
da65edef151e (gdb-flush-pending-output): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 58420
diff changeset
970 ;; In case we know the gud-marker-acc contains no partial annotations:
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
971 (progn
58431
da65edef151e (gdb-flush-pending-output): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 58420
diff changeset
972 (setq output (gdb-concat-output output gud-marker-acc))
da65edef151e (gdb-flush-pending-output): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 58420
diff changeset
973 (setq gud-marker-acc "")))
da65edef151e (gdb-flush-pending-output): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 58420
diff changeset
974 output)))
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
975
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
976 (defun gdb-concat-output (so-far new)
55749
230865f1c59d (gdb-server-prefix): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 55696
diff changeset
977 (let ((sink gdb-output-sink))
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
978 (cond
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
979 ((eq sink 'user) (concat so-far new))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
980 ((or (eq sink 'pre-emacs) (eq sink 'post-emacs)) so-far)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
981 ((eq sink 'emacs)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
982 (gdb-append-to-partial-output new)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
983 so-far)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
984 ((eq sink 'inferior)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
985 (gdb-append-to-inferior-io new)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
986 so-far)
58420
97e4fc5c7297 (gdb-resync): New function.
Nick Roberts <nickrob@snap.net.nz>
parents: 58049
diff changeset
987 (t
97e4fc5c7297 (gdb-resync): New function.
Nick Roberts <nickrob@snap.net.nz>
parents: 58049
diff changeset
988 (gdb-resync)
97e4fc5c7297 (gdb-resync): New function.
Nick Roberts <nickrob@snap.net.nz>
parents: 58049
diff changeset
989 (error "Bogon output sink %S" sink)))))
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
990
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
991 (defun gdb-append-to-partial-output (string)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
992 (with-current-buffer (gdb-get-create-buffer 'gdb-partial-output-buffer)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
993 (goto-char (point-max))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
994 (insert string)))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
995
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
996 (defun gdb-clear-partial-output ()
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
997 (with-current-buffer (gdb-get-create-buffer 'gdb-partial-output-buffer)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
998 (erase-buffer)))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
999
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1000 (defun gdb-append-to-inferior-io (string)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1001 (with-current-buffer (gdb-get-create-buffer 'gdb-inferior-io)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1002 (goto-char (point-max))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1003 (insert-before-markers string))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1004 (if (not (string-equal string ""))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1005 (gdb-display-buffer (gdb-get-create-buffer 'gdb-inferior-io))))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1006
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1007 (defun gdb-clear-inferior-io ()
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1008 (with-current-buffer (gdb-get-create-buffer 'gdb-inferior-io)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1009 (erase-buffer)))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1010
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1011
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1012 ;; One trick is to have a command who's output is always available in a buffer
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1013 ;; of it's own, and is always up to date. We build several buffers of this
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1014 ;; type.
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1015 ;;
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1016 ;; There are two aspects to this: gdb has to tell us when the output for that
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1017 ;; command might have changed, and we have to be able to run the command
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1018 ;; behind the user's back.
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1019 ;;
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1020 ;; The output phasing associated with the variable gdb-output-sink
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1021 ;; help us to run commands behind the user's back.
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1022 ;;
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1023 ;; Below is the code for specificly managing buffers of output from one
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1024 ;; command.
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1025 ;;
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1026
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1027 ;; The trigger function is suitable for use in the assoc GDB-ANNOTATION-RULES
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1028 ;; It adds an input for the command we are tracking. It should be the
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1029 ;; annotation rule binding of whatever gdb sends to tell us this command
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1030 ;; might have changed it's output.
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1031 ;;
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1032 ;; NAME is the function name. DEMAND-PREDICATE tests if output is really needed.
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1033 ;; GDB-COMMAND is a string of such. OUTPUT-HANDLER is the function bound to the
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1034 ;; input in the input queue (see comment about ``gdb communications'' above).
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1035
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1036 (defmacro def-gdb-auto-update-trigger (name demand-predicate gdb-command
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1037 output-handler)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1038 `(defun ,name (&optional ignored)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1039 (if (and (,demand-predicate)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1040 (not (member ',name
55749
230865f1c59d (gdb-server-prefix): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 55696
diff changeset
1041 gdb-pending-triggers)))
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1042 (progn
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1043 (gdb-enqueue-input
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1044 (list ,gdb-command ',output-handler))
55749
230865f1c59d (gdb-server-prefix): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 55696
diff changeset
1045 (push ',name gdb-pending-triggers)))))
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1046
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1047 (defmacro def-gdb-auto-update-handler (name trigger buf-key custom-defun)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1048 `(defun ,name ()
55749
230865f1c59d (gdb-server-prefix): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 55696
diff changeset
1049 (setq gdb-pending-triggers
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1050 (delq ',trigger
55749
230865f1c59d (gdb-server-prefix): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 55696
diff changeset
1051 gdb-pending-triggers))
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1052 (let ((buf (gdb-get-buffer ',buf-key)))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1053 (and buf
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1054 (with-current-buffer buf
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1055 (let ((p (point))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1056 (buffer-read-only nil))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1057 (erase-buffer)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1058 (insert-buffer-substring (gdb-get-create-buffer
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1059 'gdb-partial-output-buffer))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1060 (goto-char p)))))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1061 ;; put customisation here
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1062 (,custom-defun)))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1063
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1064 (defmacro def-gdb-auto-updated-buffer (buffer-key trigger-name gdb-command
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1065 output-handler-name custom-defun)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1066 `(progn
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1067 (def-gdb-auto-update-trigger ,trigger-name
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1068 ;; The demand predicate:
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1069 (lambda () (gdb-get-buffer ',buffer-key))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1070 ,gdb-command
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1071 ,output-handler-name)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1072 (def-gdb-auto-update-handler ,output-handler-name
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1073 ,trigger-name ,buffer-key ,custom-defun)))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1074
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1075
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1076 ;;
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1077 ;; Breakpoint buffer : This displays the output of `info breakpoints'.
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1078 ;;
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1079 (gdb-set-buffer-rules 'gdb-breakpoints-buffer
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1080 'gdb-breakpoints-buffer-name
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1081 'gdb-breakpoints-mode)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1082
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1083 (def-gdb-auto-updated-buffer gdb-breakpoints-buffer
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1084 ;; This defines the auto update rule for buffers of type
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1085 ;; `gdb-breakpoints-buffer'.
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1086 ;;
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1087 ;; It defines a function to serve as the annotation handler that
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1088 ;; handles the `foo-invalidated' message. That function is called:
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1089 gdb-invalidate-breakpoints
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1090 ;;
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1091 ;; To update the buffer, this command is sent to gdb.
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1092 "server info breakpoints\n"
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1093 ;;
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1094 ;; This also defines a function to be the handler for the output
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1095 ;; from the command above. That function will copy the output into
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1096 ;; the appropriately typed buffer. That function will be called:
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1097 gdb-info-breakpoints-handler
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1098 ;; buffer specific functions
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1099 gdb-info-breakpoints-custom)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1100
59617
4988bdf5db77 (gdb-put-string): Copy/create strings so
Nick Roberts <nickrob@snap.net.nz>
parents: 58534
diff changeset
1101 (defconst breakpoint-xpm-data
4988bdf5db77 (gdb-put-string): Copy/create strings so
Nick Roberts <nickrob@snap.net.nz>
parents: 58534
diff changeset
1102 "/* XPM */
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1103 static char *magick[] = {
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1104 /* columns rows colors chars-per-pixel */
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1105 \"10 10 2 1\",
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1106 \" c red\",
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1107 \"+ c None\",
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1108 /* pixels */
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1109 \"+++ +++\",
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1110 \"++ ++\",
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1111 \"+ +\",
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1112 \" \",
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1113 \" \",
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1114 \" \",
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1115 \" \",
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1116 \"+ +\",
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1117 \"++ ++\",
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1118 \"+++ +++\",
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1119 };"
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1120 "XPM data used for breakpoint icon.")
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1121
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1122 (defconst breakpoint-enabled-pbm-data
59617
4988bdf5db77 (gdb-put-string): Copy/create strings so
Nick Roberts <nickrob@snap.net.nz>
parents: 58534
diff changeset
1123 "P1
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1124 10 10\",
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1125 0 0 0 0 1 1 1 1 0 0 0 0
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1126 0 0 0 1 1 1 1 1 1 0 0 0
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1127 0 0 1 1 1 1 1 1 1 1 0 0
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1128 0 1 1 1 1 1 1 1 1 1 1 0
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1129 0 1 1 1 1 1 1 1 1 1 1 0
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1130 0 1 1 1 1 1 1 1 1 1 1 0
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1131 0 1 1 1 1 1 1 1 1 1 1 0
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1132 0 0 1 1 1 1 1 1 1 1 0 0
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1133 0 0 0 1 1 1 1 1 1 0 0 0
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1134 0 0 0 0 1 1 1 1 0 0 0 0"
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1135 "PBM data used for enabled breakpoint icon.")
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1136
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1137 (defconst breakpoint-disabled-pbm-data
59617
4988bdf5db77 (gdb-put-string): Copy/create strings so
Nick Roberts <nickrob@snap.net.nz>
parents: 58534
diff changeset
1138 "P1
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1139 10 10\",
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1140 0 0 1 0 1 0 1 0 0 0
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1141 0 1 0 1 0 1 0 1 0 0
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1142 1 0 1 0 1 0 1 0 1 0
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1143 0 1 0 1 0 1 0 1 0 1
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1144 1 0 1 0 1 0 1 0 1 0
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1145 0 1 0 1 0 1 0 1 0 1
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1146 1 0 1 0 1 0 1 0 1 0
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1147 0 1 0 1 0 1 0 1 0 1
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1148 0 0 1 0 1 0 1 0 1 0
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1149 0 0 0 1 0 1 0 1 0 0"
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1150 "PBM data used for disabled breakpoint icon.")
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1151
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1152 (defvar breakpoint-enabled-icon nil
57791
d1b93fc4ce47 Docstring fixes.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57664
diff changeset
1153 "Icon for enabled breakpoint in display margin.")
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1154
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1155 (defvar breakpoint-disabled-icon nil
57791
d1b93fc4ce47 Docstring fixes.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57664
diff changeset
1156 "Icon for disabled breakpoint in display margin.")
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1157
57262
df4b0ff293d8 (breakpoint): Define as fringe bitmap.
Kim F. Storm <storm@cua.dk>
parents: 56330
diff changeset
1158 ;; Bitmap for breakpoint in fringe
57982
641cb7192482 Don't call define-fringe-bitmap if the display doesn't support images.
Eli Zaretskii <eliz@gnu.org>
parents: 57851
diff changeset
1159 (and (display-images-p)
641cb7192482 Don't call define-fringe-bitmap if the display doesn't support images.
Eli Zaretskii <eliz@gnu.org>
parents: 57851
diff changeset
1160 (define-fringe-bitmap 'breakpoint
641cb7192482 Don't call define-fringe-bitmap if the display doesn't support images.
Eli Zaretskii <eliz@gnu.org>
parents: 57851
diff changeset
1161 "\x3c\x7e\xff\xff\xff\xff\x7e\x3c"))
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1162
60760
a706fe4203bc Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-193
Miles Bader <miles@gnu.org>
parents: 60541
diff changeset
1163 (defface breakpoint-enabled
60869
88ef15014617 Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-204
Miles Bader <miles@gnu.org>
parents: 60839
diff changeset
1164 '((t
88ef15014617 Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-204
Miles Bader <miles@gnu.org>
parents: 60839
diff changeset
1165 :foreground "red"
88ef15014617 Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-204
Miles Bader <miles@gnu.org>
parents: 60839
diff changeset
1166 :weight bold))
56285
313e3a9f34ca (breakpoint-enabled-bitmap-face)
Kim F. Storm <storm@cua.dk>
parents: 56258
diff changeset
1167 "Face for enabled breakpoint icon in fringe."
313e3a9f34ca (breakpoint-enabled-bitmap-face)
Kim F. Storm <storm@cua.dk>
parents: 56258
diff changeset
1168 :group 'gud)
60760
a706fe4203bc Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-193
Miles Bader <miles@gnu.org>
parents: 60541
diff changeset
1169 ;; compatibility alias for old name
a706fe4203bc Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-193
Miles Bader <miles@gnu.org>
parents: 60541
diff changeset
1170 (put 'breakpoint-enabled-bitmap-face 'face-alias 'breakpoint-enabled)
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1171
60760
a706fe4203bc Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-193
Miles Bader <miles@gnu.org>
parents: 60541
diff changeset
1172 (defface breakpoint-disabled
60810
6eef5fcb0572 Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-199
Miles Bader <miles@gnu.org>
parents: 60760
diff changeset
1173 ;; We use different values of grey for different background types,
6eef5fcb0572 Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-199
Miles Bader <miles@gnu.org>
parents: 60760
diff changeset
1174 ;; so that on low-color displays it will end up as something visible
60839
7a4f7626e4dc (breakpoint-enabled, breakpoint-disabled):
Kim F. Storm <storm@cua.dk>
parents: 60810
diff changeset
1175 ;; if it has to be approximated.
60869
88ef15014617 Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-204
Miles Bader <miles@gnu.org>
parents: 60839
diff changeset
1176 '((((background dark)) :foreground "grey60")
88ef15014617 Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-204
Miles Bader <miles@gnu.org>
parents: 60839
diff changeset
1177 (((background light)) :foreground "grey40"))
56285
313e3a9f34ca (breakpoint-enabled-bitmap-face)
Kim F. Storm <storm@cua.dk>
parents: 56258
diff changeset
1178 "Face for disabled breakpoint icon in fringe."
313e3a9f34ca (breakpoint-enabled-bitmap-face)
Kim F. Storm <storm@cua.dk>
parents: 56258
diff changeset
1179 :group 'gud)
60760
a706fe4203bc Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-193
Miles Bader <miles@gnu.org>
parents: 60541
diff changeset
1180 ;; compatibility alias for old name
a706fe4203bc Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-193
Miles Bader <miles@gnu.org>
parents: 60541
diff changeset
1181 (put 'breakpoint-disabled-bitmap-face 'face-alias 'breakpoint-disabled)
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1182
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1183 ;;-put breakpoint icons in relevant margins (even those set in the GUD buffer)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1184 (defun gdb-info-breakpoints-custom ()
59617
4988bdf5db77 (gdb-put-string): Copy/create strings so
Nick Roberts <nickrob@snap.net.nz>
parents: 58534
diff changeset
1185 (let ((flag) (bptno))
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1186 ;; remove all breakpoint-icons in source buffers but not assembler buffer
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1187 (dolist (buffer (buffer-list))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1188 (with-current-buffer buffer
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1189 (if (and (eq gud-minor-mode 'gdba)
55749
230865f1c59d (gdb-server-prefix): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 55696
diff changeset
1190 (not (string-match "\\`\\*.+\\*\\'" (buffer-name))))
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1191 (gdb-remove-breakpoint-icons (point-min) (point-max)))))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1192 (with-current-buffer (gdb-get-buffer 'gdb-breakpoints-buffer)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1193 (save-excursion
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1194 (goto-char (point-min))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1195 (while (< (point) (- (point-max) 1))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1196 (forward-line 1)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1197 (if (looking-at "[^\t].*breakpoint")
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1198 (progn
59617
4988bdf5db77 (gdb-put-string): Copy/create strings so
Nick Roberts <nickrob@snap.net.nz>
parents: 58534
diff changeset
1199 (looking-at "\\([0-9]+\\)\\s-+\\S-+\\s-+\\S-+\\s-+\\(.\\)")
4988bdf5db77 (gdb-put-string): Copy/create strings so
Nick Roberts <nickrob@snap.net.nz>
parents: 58534
diff changeset
1200 (setq bptno (match-string 1))
4988bdf5db77 (gdb-put-string): Copy/create strings so
Nick Roberts <nickrob@snap.net.nz>
parents: 58534
diff changeset
1201 (setq flag (char-after (match-beginning 2)))
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1202 (beginning-of-line)
59988
fb52ec059049 (gdb-location-list): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 59922
diff changeset
1203 (if (re-search-forward " in .* at\\s-+" nil t)
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1204 (progn
59617
4988bdf5db77 (gdb-put-string): Copy/create strings so
Nick Roberts <nickrob@snap.net.nz>
parents: 58534
diff changeset
1205 (looking-at "\\(\\S-+\\):\\([0-9]+\\)")
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1206 (let ((line (match-string 2)) (buffer-read-only nil)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1207 (file (match-string 1)))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1208 (add-text-properties (point-at-bol) (point-at-eol)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1209 '(mouse-face highlight
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1210 help-echo "mouse-2, RET: visit breakpoint"))
59988
fb52ec059049 (gdb-location-list): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 59922
diff changeset
1211 (unless (file-exists-p file)
fb52ec059049 (gdb-location-list): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 59922
diff changeset
1212 (setq file (cdr (assoc bptno gdb-location-list))))
fb52ec059049 (gdb-location-list): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 59922
diff changeset
1213 (unless (string-equal file "File not found")
fb52ec059049 (gdb-location-list): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 59922
diff changeset
1214 (if file
60073
6fba1da8f37e (gdb-find-file-unhook): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 59998
diff changeset
1215 (with-current-buffer (find-file-noselect file)
6fba1da8f37e (gdb-find-file-unhook): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 59998
diff changeset
1216 (set (make-local-variable 'gud-minor-mode)
59988
fb52ec059049 (gdb-location-list): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 59922
diff changeset
1217 'gdba)
60073
6fba1da8f37e (gdb-find-file-unhook): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 59998
diff changeset
1218 (set (make-local-variable 'tool-bar-map)
6fba1da8f37e (gdb-find-file-unhook): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 59998
diff changeset
1219 gud-tool-bar-map)
59988
fb52ec059049 (gdb-location-list): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 59922
diff changeset
1220 ;; only want one breakpoint icon at each location
fb52ec059049 (gdb-location-list): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 59922
diff changeset
1221 (save-excursion
fb52ec059049 (gdb-location-list): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 59922
diff changeset
1222 (goto-line (string-to-number line))
fb52ec059049 (gdb-location-list): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 59922
diff changeset
1223 (gdb-put-breakpoint-icon (eq flag ?y) bptno)))
fb52ec059049 (gdb-location-list): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 59922
diff changeset
1224 (gdb-enqueue-input
60326
47c96976e43d (gdb-get-location): Use a warning instead
Nick Roberts <nickrob@snap.net.nz>
parents: 60153
diff changeset
1225 (list (concat "list "
59988
fb52ec059049 (gdb-location-list): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 59922
diff changeset
1226 (match-string-no-properties 1) ":1\n")
fb52ec059049 (gdb-location-list): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 59922
diff changeset
1227 'ignore))
fb52ec059049 (gdb-location-list): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 59922
diff changeset
1228 (gdb-enqueue-input
60326
47c96976e43d (gdb-get-location): Use a warning instead
Nick Roberts <nickrob@snap.net.nz>
parents: 60153
diff changeset
1229 (list "info source\n"
47c96976e43d (gdb-get-location): Use a warning instead
Nick Roberts <nickrob@snap.net.nz>
parents: 60153
diff changeset
1230 `(lambda () (gdb-get-location
47c96976e43d (gdb-get-location): Use a warning instead
Nick Roberts <nickrob@snap.net.nz>
parents: 60153
diff changeset
1231 ,bptno ,line ,flag)))))))))))
54962
c3272c09f927 (gdb-goto-info): Require 'info.
Nick Roberts <nickrob@snap.net.nz>
parents: 54901
diff changeset
1232 (end-of-line)))))
c3272c09f927 (gdb-goto-info): Require 'info.
Nick Roberts <nickrob@snap.net.nz>
parents: 54901
diff changeset
1233 (if (gdb-get-buffer 'gdb-assembler-buffer) (gdb-assembler-custom)))
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1234
59617
4988bdf5db77 (gdb-put-string): Copy/create strings so
Nick Roberts <nickrob@snap.net.nz>
parents: 58534
diff changeset
1235 (defun gdb-mouse-set-clear-breakpoint (event)
4988bdf5db77 (gdb-put-string): Copy/create strings so
Nick Roberts <nickrob@snap.net.nz>
parents: 58534
diff changeset
1236 "Set/clear breakpoint in left fringe/margin with mouse click."
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1237 (interactive "e")
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1238 (mouse-minibuffer-check event)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1239 (let ((posn (event-end event)))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1240 (if (numberp (posn-point posn))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1241 (with-selected-window (posn-window posn)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1242 (save-excursion
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1243 (goto-char (posn-point posn))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1244 (if (or (posn-object posn)
57262
df4b0ff293d8 (breakpoint): Define as fringe bitmap.
Kim F. Storm <storm@cua.dk>
parents: 56330
diff changeset
1245 (eq (car (fringe-bitmaps-at-pos (posn-point posn)))
df4b0ff293d8 (breakpoint): Define as fringe bitmap.
Kim F. Storm <storm@cua.dk>
parents: 56330
diff changeset
1246 'breakpoint))
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1247 (gud-remove nil)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1248 (gud-break nil)))))))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1249
59617
4988bdf5db77 (gdb-put-string): Copy/create strings so
Nick Roberts <nickrob@snap.net.nz>
parents: 58534
diff changeset
1250 (defun gdb-mouse-toggle-breakpoint (event)
4988bdf5db77 (gdb-put-string): Copy/create strings so
Nick Roberts <nickrob@snap.net.nz>
parents: 58534
diff changeset
1251 "Enable/disable breakpoint in left fringe/margin with mouse click."
4988bdf5db77 (gdb-put-string): Copy/create strings so
Nick Roberts <nickrob@snap.net.nz>
parents: 58534
diff changeset
1252 (interactive "e")
4988bdf5db77 (gdb-put-string): Copy/create strings so
Nick Roberts <nickrob@snap.net.nz>
parents: 58534
diff changeset
1253 (mouse-minibuffer-check event)
4988bdf5db77 (gdb-put-string): Copy/create strings so
Nick Roberts <nickrob@snap.net.nz>
parents: 58534
diff changeset
1254 (let ((posn (event-end event)))
4988bdf5db77 (gdb-put-string): Copy/create strings so
Nick Roberts <nickrob@snap.net.nz>
parents: 58534
diff changeset
1255 (if (numberp (posn-point posn))
4988bdf5db77 (gdb-put-string): Copy/create strings so
Nick Roberts <nickrob@snap.net.nz>
parents: 58534
diff changeset
1256 (with-selected-window (posn-window posn)
4988bdf5db77 (gdb-put-string): Copy/create strings so
Nick Roberts <nickrob@snap.net.nz>
parents: 58534
diff changeset
1257 (save-excursion
4988bdf5db77 (gdb-put-string): Copy/create strings so
Nick Roberts <nickrob@snap.net.nz>
parents: 58534
diff changeset
1258 (goto-char (posn-point posn))
59996
aac0a33f5772 Change release version from 21.4 to 22.1 throughout.
Kim F. Storm <storm@cua.dk>
parents: 59988
diff changeset
1259 (if
59617
4988bdf5db77 (gdb-put-string): Copy/create strings so
Nick Roberts <nickrob@snap.net.nz>
parents: 58534
diff changeset
1260 ; (or
4988bdf5db77 (gdb-put-string): Copy/create strings so
Nick Roberts <nickrob@snap.net.nz>
parents: 58534
diff changeset
1261 (posn-object posn)
4988bdf5db77 (gdb-put-string): Copy/create strings so
Nick Roberts <nickrob@snap.net.nz>
parents: 58534
diff changeset
1262 ; (eq (car (fringe-bitmaps-at-pos (posn-point posn)))
4988bdf5db77 (gdb-put-string): Copy/create strings so
Nick Roberts <nickrob@snap.net.nz>
parents: 58534
diff changeset
1263 ; 'breakpoint))
4988bdf5db77 (gdb-put-string): Copy/create strings so
Nick Roberts <nickrob@snap.net.nz>
parents: 58534
diff changeset
1264 (gdb-enqueue-input
4988bdf5db77 (gdb-put-string): Copy/create strings so
Nick Roberts <nickrob@snap.net.nz>
parents: 58534
diff changeset
1265 (list
4988bdf5db77 (gdb-put-string): Copy/create strings so
Nick Roberts <nickrob@snap.net.nz>
parents: 58534
diff changeset
1266 (let ((bptno (get-text-property
4988bdf5db77 (gdb-put-string): Copy/create strings so
Nick Roberts <nickrob@snap.net.nz>
parents: 58534
diff changeset
1267 0 'gdb-bptno (car (posn-string posn)))))
4988bdf5db77 (gdb-put-string): Copy/create strings so
Nick Roberts <nickrob@snap.net.nz>
parents: 58534
diff changeset
1268 (concat
4988bdf5db77 (gdb-put-string): Copy/create strings so
Nick Roberts <nickrob@snap.net.nz>
parents: 58534
diff changeset
1269 (if (get-text-property
4988bdf5db77 (gdb-put-string): Copy/create strings so
Nick Roberts <nickrob@snap.net.nz>
parents: 58534
diff changeset
1270 0 'gdb-enabled (car (posn-string posn)))
4988bdf5db77 (gdb-put-string): Copy/create strings so
Nick Roberts <nickrob@snap.net.nz>
parents: 58534
diff changeset
1271 "disable "
4988bdf5db77 (gdb-put-string): Copy/create strings so
Nick Roberts <nickrob@snap.net.nz>
parents: 58534
diff changeset
1272 "enable ")
4988bdf5db77 (gdb-put-string): Copy/create strings so
Nick Roberts <nickrob@snap.net.nz>
parents: 58534
diff changeset
1273 bptno "\n")) 'ignore))))))))
4988bdf5db77 (gdb-put-string): Copy/create strings so
Nick Roberts <nickrob@snap.net.nz>
parents: 58534
diff changeset
1274
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1275 (defun gdb-breakpoints-buffer-name ()
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1276 (with-current-buffer gud-comint-buffer
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1277 (concat "*breakpoints of " (gdb-get-target-string) "*")))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1278
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1279 (defun gdb-display-breakpoints-buffer ()
55400
1aaa031e318c Improve/extend documentation strings.
Nick Roberts <nickrob@snap.net.nz>
parents: 55330
diff changeset
1280 "Display status of user-settable breakpoints."
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1281 (interactive)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1282 (gdb-display-buffer
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1283 (gdb-get-create-buffer 'gdb-breakpoints-buffer)))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1284
54993
08b0ee9a9b35 (gdb-frame-parameters): New constant.
Nick Roberts <nickrob@snap.net.nz>
parents: 54962
diff changeset
1285 (defconst gdb-frame-parameters
58521
54bb21951d18 (gdb-frame-parameters): Match height and
Nick Roberts <nickrob@snap.net.nz>
parents: 58485
diff changeset
1286 '((height . 14) (width . 80)
54993
08b0ee9a9b35 (gdb-frame-parameters): New constant.
Nick Roberts <nickrob@snap.net.nz>
parents: 54962
diff changeset
1287 (unsplittable . t)
08b0ee9a9b35 (gdb-frame-parameters): New constant.
Nick Roberts <nickrob@snap.net.nz>
parents: 54962
diff changeset
1288 (tool-bar-lines . nil)
08b0ee9a9b35 (gdb-frame-parameters): New constant.
Nick Roberts <nickrob@snap.net.nz>
parents: 54962
diff changeset
1289 (menu-bar-lines . nil)
08b0ee9a9b35 (gdb-frame-parameters): New constant.
Nick Roberts <nickrob@snap.net.nz>
parents: 54962
diff changeset
1290 (minibuffer . nil)))
08b0ee9a9b35 (gdb-frame-parameters): New constant.
Nick Roberts <nickrob@snap.net.nz>
parents: 54962
diff changeset
1291
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1292 (defun gdb-frame-breakpoints-buffer ()
55400
1aaa031e318c Improve/extend documentation strings.
Nick Roberts <nickrob@snap.net.nz>
parents: 55330
diff changeset
1293 "Display status of user-settable breakpoints in a new frame."
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1294 (interactive)
58521
54bb21951d18 (gdb-frame-parameters): Match height and
Nick Roberts <nickrob@snap.net.nz>
parents: 58485
diff changeset
1295 (let ((special-display-regexps (append special-display-regexps '(".*")))
54bb21951d18 (gdb-frame-parameters): Match height and
Nick Roberts <nickrob@snap.net.nz>
parents: 58485
diff changeset
1296 (special-display-frame-alist gdb-frame-parameters))
54bb21951d18 (gdb-frame-parameters): Match height and
Nick Roberts <nickrob@snap.net.nz>
parents: 58485
diff changeset
1297 (display-buffer (gdb-get-create-buffer 'gdb-breakpoints-buffer))))
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1298
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1299 (defvar gdb-breakpoints-mode-map
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1300 (let ((map (make-sparse-keymap))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1301 (menu (make-sparse-keymap "Breakpoints")))
60946
a44ce059d2d1 (gdb-breakpoints-mode-map)
Nick Roberts <nickrob@snap.net.nz>
parents: 60869
diff changeset
1302 (define-key menu [quit] '("Quit" . kill-this-buffer))
a44ce059d2d1 (gdb-breakpoints-mode-map)
Nick Roberts <nickrob@snap.net.nz>
parents: 60869
diff changeset
1303 (define-key menu [goto] '("Goto" . gdb-goto-breakpoint))
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1304 (define-key menu [delete] '("Delete" . gdb-delete-breakpoint))
60946
a44ce059d2d1 (gdb-breakpoints-mode-map)
Nick Roberts <nickrob@snap.net.nz>
parents: 60869
diff changeset
1305 (define-key menu [toggle] '("Toggle" . gdb-toggle-breakpoint))
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1306 (suppress-keymap map)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1307 (define-key map [menu-bar breakpoints] (cons "Breakpoints" menu))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1308 (define-key map " " 'gdb-toggle-breakpoint)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1309 (define-key map "d" 'gdb-delete-breakpoint)
58485
31d7630f91d4 (gdb-breakpoints-mode-map)
Nick Roberts <nickrob@snap.net.nz>
parents: 58470
diff changeset
1310 (define-key map "q" 'kill-this-buffer)
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1311 (define-key map "\r" 'gdb-goto-breakpoint)
59708
9ce7d8f69f2c (gdb-goto-breakpoint, gdb-frames-select)
Nick Roberts <nickrob@snap.net.nz>
parents: 59635
diff changeset
1312 (define-key map [mouse-2] 'gdb-goto-breakpoint)
60946
a44ce059d2d1 (gdb-breakpoints-mode-map)
Nick Roberts <nickrob@snap.net.nz>
parents: 60869
diff changeset
1313 (define-key map [follow-link] 'mouse-face)
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1314 map))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1315
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1316 (defun gdb-breakpoints-mode ()
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1317 "Major mode for gdb breakpoints.
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1318
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1319 \\{gdb-breakpoints-mode-map}"
57661
b59713cd72a2 (gdb-get-create-buffer): Allow modes to run
Nick Roberts <nickrob@snap.net.nz>
parents: 57350
diff changeset
1320 (kill-all-local-variables)
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1321 (setq major-mode 'gdb-breakpoints-mode)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1322 (setq mode-name "Breakpoints")
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1323 (use-local-map gdb-breakpoints-mode-map)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1324 (setq buffer-read-only t)
57661
b59713cd72a2 (gdb-get-create-buffer): Allow modes to run
Nick Roberts <nickrob@snap.net.nz>
parents: 57350
diff changeset
1325 (run-mode-hooks 'gdb-breakpoints-mode-hook)
55762
e31413b06034 (gdb-breakpoints-mode, gdb-frames-mode)
Nick Roberts <nickrob@snap.net.nz>
parents: 55749
diff changeset
1326 (if (with-current-buffer gud-comint-buffer (eq gud-minor-mode 'gdba))
57661
b59713cd72a2 (gdb-get-create-buffer): Allow modes to run
Nick Roberts <nickrob@snap.net.nz>
parents: 57350
diff changeset
1327 'gdb-invalidate-breakpoints
b59713cd72a2 (gdb-get-create-buffer): Allow modes to run
Nick Roberts <nickrob@snap.net.nz>
parents: 57350
diff changeset
1328 'gdbmi-invalidate-breakpoints))
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1329
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1330 (defun gdb-toggle-breakpoint ()
59617
4988bdf5db77 (gdb-put-string): Copy/create strings so
Nick Roberts <nickrob@snap.net.nz>
parents: 58534
diff changeset
1331 "Enable/disable breakpoint at current line."
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1332 (interactive)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1333 (save-excursion
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1334 (beginning-of-line 1)
56330
a76e88488fd7 (gdb-goto-breakpoint): String match more
Nick Roberts <nickrob@snap.net.nz>
parents: 56285
diff changeset
1335 (if (if (with-current-buffer gud-comint-buffer (eq gud-minor-mode 'gdba))
a76e88488fd7 (gdb-goto-breakpoint): String match more
Nick Roberts <nickrob@snap.net.nz>
parents: 56285
diff changeset
1336 (looking-at "\\([0-9]+\\).*point\\s-*\\S-*\\s-*\\(.\\)")
a76e88488fd7 (gdb-goto-breakpoint): String match more
Nick Roberts <nickrob@snap.net.nz>
parents: 56285
diff changeset
1337 (looking-at
a76e88488fd7 (gdb-goto-breakpoint): String match more
Nick Roberts <nickrob@snap.net.nz>
parents: 56285
diff changeset
1338 "\\([0-9]+\\)\\s-*\\S-*\\s-*\\S-*\\s-*\\(.\\)\\s-*\\S-*\\s-*\\S-*:[0-9]+"))
a76e88488fd7 (gdb-goto-breakpoint): String match more
Nick Roberts <nickrob@snap.net.nz>
parents: 56285
diff changeset
1339 (gdb-enqueue-input
a76e88488fd7 (gdb-goto-breakpoint): String match more
Nick Roberts <nickrob@snap.net.nz>
parents: 56285
diff changeset
1340 (list
a76e88488fd7 (gdb-goto-breakpoint): String match more
Nick Roberts <nickrob@snap.net.nz>
parents: 56285
diff changeset
1341 (concat gdb-server-prefix
a76e88488fd7 (gdb-goto-breakpoint): String match more
Nick Roberts <nickrob@snap.net.nz>
parents: 56285
diff changeset
1342 (if (eq ?y (char-after (match-beginning 2)))
a76e88488fd7 (gdb-goto-breakpoint): String match more
Nick Roberts <nickrob@snap.net.nz>
parents: 56285
diff changeset
1343 "disable "
a76e88488fd7 (gdb-goto-breakpoint): String match more
Nick Roberts <nickrob@snap.net.nz>
parents: 56285
diff changeset
1344 "enable ")
a76e88488fd7 (gdb-goto-breakpoint): String match more
Nick Roberts <nickrob@snap.net.nz>
parents: 56285
diff changeset
1345 (match-string 1) "\n") 'ignore))
a76e88488fd7 (gdb-goto-breakpoint): String match more
Nick Roberts <nickrob@snap.net.nz>
parents: 56285
diff changeset
1346 (error "Not recognized as break/watchpoint line"))))
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1347
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1348 (defun gdb-delete-breakpoint ()
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1349 "Delete the breakpoint at current line."
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1350 (interactive)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1351 (beginning-of-line 1)
56330
a76e88488fd7 (gdb-goto-breakpoint): String match more
Nick Roberts <nickrob@snap.net.nz>
parents: 56285
diff changeset
1352 (if (if (with-current-buffer gud-comint-buffer (eq gud-minor-mode 'gdba))
a76e88488fd7 (gdb-goto-breakpoint): String match more
Nick Roberts <nickrob@snap.net.nz>
parents: 56285
diff changeset
1353 (looking-at "\\([0-9]+\\).*point\\s-*\\S-*\\s-*\\(.\\)")
a76e88488fd7 (gdb-goto-breakpoint): String match more
Nick Roberts <nickrob@snap.net.nz>
parents: 56285
diff changeset
1354 (looking-at
a76e88488fd7 (gdb-goto-breakpoint): String match more
Nick Roberts <nickrob@snap.net.nz>
parents: 56285
diff changeset
1355 "\\([0-9]+\\)\\s-*\\S-*\\s-*\\S-*\\s-*.\\s-*\\S-*\\s-*\\S-*:[0-9]+"))
a76e88488fd7 (gdb-goto-breakpoint): String match more
Nick Roberts <nickrob@snap.net.nz>
parents: 56285
diff changeset
1356 (gdb-enqueue-input
a76e88488fd7 (gdb-goto-breakpoint): String match more
Nick Roberts <nickrob@snap.net.nz>
parents: 56285
diff changeset
1357 (list
a76e88488fd7 (gdb-goto-breakpoint): String match more
Nick Roberts <nickrob@snap.net.nz>
parents: 56285
diff changeset
1358 (concat gdb-server-prefix "delete " (match-string 1) "\n") 'ignore))
a76e88488fd7 (gdb-goto-breakpoint): String match more
Nick Roberts <nickrob@snap.net.nz>
parents: 56285
diff changeset
1359 (error "Not recognized as break/watchpoint line")))
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1360
59708
9ce7d8f69f2c (gdb-goto-breakpoint, gdb-frames-select)
Nick Roberts <nickrob@snap.net.nz>
parents: 59635
diff changeset
1361 (defun gdb-goto-breakpoint (&optional event)
55400
1aaa031e318c Improve/extend documentation strings.
Nick Roberts <nickrob@snap.net.nz>
parents: 55330
diff changeset
1362 "Display the breakpoint location specified at current line."
59708
9ce7d8f69f2c (gdb-goto-breakpoint, gdb-frames-select)
Nick Roberts <nickrob@snap.net.nz>
parents: 59635
diff changeset
1363 (interactive (list last-input-event))
9ce7d8f69f2c (gdb-goto-breakpoint, gdb-frames-select)
Nick Roberts <nickrob@snap.net.nz>
parents: 59635
diff changeset
1364 (if event (mouse-set-point event))
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1365 (save-excursion
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1366 (beginning-of-line 1)
56330
a76e88488fd7 (gdb-goto-breakpoint): String match more
Nick Roberts <nickrob@snap.net.nz>
parents: 56285
diff changeset
1367 (if (if (with-current-buffer gud-comint-buffer (eq gud-minor-mode 'gdba))
59988
fb52ec059049 (gdb-location-list): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 59922
diff changeset
1368 (looking-at "\\([0-9]+\\) .* in .* at\\s-+\\(\\S-*\\):\\([0-9]+\\)")
56330
a76e88488fd7 (gdb-goto-breakpoint): String match more
Nick Roberts <nickrob@snap.net.nz>
parents: 56285
diff changeset
1369 (looking-at
59988
fb52ec059049 (gdb-location-list): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 59922
diff changeset
1370 "\\([0-9]+\\)\\s-*\\S-*\\s-*\\S-*\\s-*.\\s-*\\S-*\\s-*\\(\\S-*\\):\\([0-9]+\\)"))
fb52ec059049 (gdb-location-list): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 59922
diff changeset
1371 (let ((bptno (match-string 1))
fb52ec059049 (gdb-location-list): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 59922
diff changeset
1372 (file (match-string 2))
fb52ec059049 (gdb-location-list): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 59922
diff changeset
1373 (line (match-string 3)))
56330
a76e88488fd7 (gdb-goto-breakpoint): String match more
Nick Roberts <nickrob@snap.net.nz>
parents: 56285
diff changeset
1374 (save-selected-window
a76e88488fd7 (gdb-goto-breakpoint): String match more
Nick Roberts <nickrob@snap.net.nz>
parents: 56285
diff changeset
1375 (let* ((buf (find-file-noselect (if (file-exists-p file)
a76e88488fd7 (gdb-goto-breakpoint): String match more
Nick Roberts <nickrob@snap.net.nz>
parents: 56285
diff changeset
1376 file
59988
fb52ec059049 (gdb-location-list): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 59922
diff changeset
1377 (cdr (assoc bptno gdb-location-list)))))
58534
c655bc81dfc0 (gdb-view-source, gdb-selected-view):
Nick Roberts <nickrob@snap.net.nz>
parents: 58521
diff changeset
1378 (window (display-buffer buf)))
56330
a76e88488fd7 (gdb-goto-breakpoint): String match more
Nick Roberts <nickrob@snap.net.nz>
parents: 56285
diff changeset
1379 (with-current-buffer buf
a76e88488fd7 (gdb-goto-breakpoint): String match more
Nick Roberts <nickrob@snap.net.nz>
parents: 56285
diff changeset
1380 (goto-line (string-to-number line))
a76e88488fd7 (gdb-goto-breakpoint): String match more
Nick Roberts <nickrob@snap.net.nz>
parents: 56285
diff changeset
1381 (set-window-point window (point))))))
a76e88488fd7 (gdb-goto-breakpoint): String match more
Nick Roberts <nickrob@snap.net.nz>
parents: 56285
diff changeset
1382 (error "Not recognized as break/watchpoint line"))))
59708
9ce7d8f69f2c (gdb-goto-breakpoint, gdb-frames-select)
Nick Roberts <nickrob@snap.net.nz>
parents: 59635
diff changeset
1383
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1384
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1385 ;; Frames buffer. This displays a perpetually correct bactracktrace
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1386 ;; (from the command `where').
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1387 ;;
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1388 ;; Alas, if your stack is deep, it is costly.
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1389 ;;
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1390 (gdb-set-buffer-rules 'gdb-stack-buffer
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1391 'gdb-stack-buffer-name
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1392 'gdb-frames-mode)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1393
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1394 (def-gdb-auto-updated-buffer gdb-stack-buffer
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1395 gdb-invalidate-frames
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1396 "server where\n"
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1397 gdb-info-frames-handler
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1398 gdb-info-frames-custom)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1399
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1400 (defun gdb-info-frames-custom ()
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1401 (with-current-buffer (gdb-get-buffer 'gdb-stack-buffer)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1402 (save-excursion
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1403 (let ((buffer-read-only nil))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1404 (goto-char (point-min))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1405 (while (< (point) (point-max))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1406 (add-text-properties (point-at-bol) (point-at-eol)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1407 '(mouse-face highlight
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1408 help-echo "mouse-2, RET: Select frame"))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1409 (beginning-of-line)
58049
fd0093bd412a (gdb-current-stack-level): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 57982
diff changeset
1410 (when (and (looking-at "^#\\([0-9]+\\)")
fd0093bd412a (gdb-current-stack-level): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 57982
diff changeset
1411 (equal (match-string 1) gdb-current-stack-level))
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1412 (put-text-property (point-at-bol) (point-at-eol)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1413 'face '(:inverse-video t)))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1414 (forward-line 1))))))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1415
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1416 (defun gdb-stack-buffer-name ()
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1417 (with-current-buffer gud-comint-buffer
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1418 (concat "*stack frames of " (gdb-get-target-string) "*")))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1419
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1420 (defun gdb-display-stack-buffer ()
55400
1aaa031e318c Improve/extend documentation strings.
Nick Roberts <nickrob@snap.net.nz>
parents: 55330
diff changeset
1421 "Display backtrace of current stack."
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1422 (interactive)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1423 (gdb-display-buffer
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1424 (gdb-get-create-buffer 'gdb-stack-buffer)))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1425
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1426 (defun gdb-frame-stack-buffer ()
55400
1aaa031e318c Improve/extend documentation strings.
Nick Roberts <nickrob@snap.net.nz>
parents: 55330
diff changeset
1427 "Display backtrace of current stack in a new frame."
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1428 (interactive)
58521
54bb21951d18 (gdb-frame-parameters): Match height and
Nick Roberts <nickrob@snap.net.nz>
parents: 58485
diff changeset
1429 (let ((special-display-regexps (append special-display-regexps '(".*")))
54bb21951d18 (gdb-frame-parameters): Match height and
Nick Roberts <nickrob@snap.net.nz>
parents: 58485
diff changeset
1430 (special-display-frame-alist gdb-frame-parameters))
54bb21951d18 (gdb-frame-parameters): Match height and
Nick Roberts <nickrob@snap.net.nz>
parents: 58485
diff changeset
1431 (display-buffer (gdb-get-create-buffer 'gdb-stack-buffer))))
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1432
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1433 (defvar gdb-frames-mode-map
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1434 (let ((map (make-sparse-keymap)))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1435 (suppress-keymap map)
58485
31d7630f91d4 (gdb-breakpoints-mode-map)
Nick Roberts <nickrob@snap.net.nz>
parents: 58470
diff changeset
1436 (define-key map "q" 'kill-this-buffer)
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1437 (define-key map "\r" 'gdb-frames-select)
59708
9ce7d8f69f2c (gdb-goto-breakpoint, gdb-frames-select)
Nick Roberts <nickrob@snap.net.nz>
parents: 59635
diff changeset
1438 (define-key map [mouse-2] 'gdb-frames-select)
60946
a44ce059d2d1 (gdb-breakpoints-mode-map)
Nick Roberts <nickrob@snap.net.nz>
parents: 60869
diff changeset
1439 (define-key map [follow-link] 'mouse-face)
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1440 map))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1441
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1442 (defun gdb-frames-mode ()
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1443 "Major mode for gdb frames.
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1444
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1445 \\{gdb-frames-mode-map}"
57661
b59713cd72a2 (gdb-get-create-buffer): Allow modes to run
Nick Roberts <nickrob@snap.net.nz>
parents: 57350
diff changeset
1446 (kill-all-local-variables)
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1447 (setq major-mode 'gdb-frames-mode)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1448 (setq mode-name "Frames")
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1449 (setq buffer-read-only t)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1450 (use-local-map gdb-frames-mode-map)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1451 (font-lock-mode -1)
57661
b59713cd72a2 (gdb-get-create-buffer): Allow modes to run
Nick Roberts <nickrob@snap.net.nz>
parents: 57350
diff changeset
1452 (run-mode-hooks 'gdb-frames-mode-hook)
55762
e31413b06034 (gdb-breakpoints-mode, gdb-frames-mode)
Nick Roberts <nickrob@snap.net.nz>
parents: 55749
diff changeset
1453 (if (with-current-buffer gud-comint-buffer (eq gud-minor-mode 'gdba))
57661
b59713cd72a2 (gdb-get-create-buffer): Allow modes to run
Nick Roberts <nickrob@snap.net.nz>
parents: 57350
diff changeset
1454 'gdb-invalidate-frames
b59713cd72a2 (gdb-get-create-buffer): Allow modes to run
Nick Roberts <nickrob@snap.net.nz>
parents: 57350
diff changeset
1455 'gdbmi-invalidate-frames))
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1456
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1457 (defun gdb-get-frame-number ()
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1458 (save-excursion
55850
63ca25eb73a1 (gdb-current-frame, gud-watch)
Nick Roberts <nickrob@snap.net.nz>
parents: 55764
diff changeset
1459 (let* ((pos (re-search-backward "^#*\\([0-9]*\\)" nil t))
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1460 (n (or (and pos (match-string-no-properties 1)) "0")))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1461 n)))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1462
59708
9ce7d8f69f2c (gdb-goto-breakpoint, gdb-frames-select)
Nick Roberts <nickrob@snap.net.nz>
parents: 59635
diff changeset
1463 (defun gdb-frames-select (&optional event)
55400
1aaa031e318c Improve/extend documentation strings.
Nick Roberts <nickrob@snap.net.nz>
parents: 55330
diff changeset
1464 "Select the frame and display the relevant source."
59708
9ce7d8f69f2c (gdb-goto-breakpoint, gdb-frames-select)
Nick Roberts <nickrob@snap.net.nz>
parents: 59635
diff changeset
1465 (interactive (list last-input-event))
9ce7d8f69f2c (gdb-goto-breakpoint, gdb-frames-select)
Nick Roberts <nickrob@snap.net.nz>
parents: 59635
diff changeset
1466 (if event (mouse-set-point event))
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1467 (gdb-enqueue-input
55749
230865f1c59d (gdb-server-prefix): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 55696
diff changeset
1468 (list (concat gdb-server-prefix "frame " (gdb-get-frame-number) "\n") 'ignore))
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1469 (gud-display-frame))
59708
9ce7d8f69f2c (gdb-goto-breakpoint, gdb-frames-select)
Nick Roberts <nickrob@snap.net.nz>
parents: 59635
diff changeset
1470
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1471
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1472 ;; Threads buffer. This displays a selectable thread list.
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1473 ;;
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1474 (gdb-set-buffer-rules 'gdb-threads-buffer
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1475 'gdb-threads-buffer-name
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1476 'gdb-threads-mode)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1477
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1478 (def-gdb-auto-updated-buffer gdb-threads-buffer
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1479 gdb-invalidate-threads
55749
230865f1c59d (gdb-server-prefix): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 55696
diff changeset
1480 (concat gdb-server-prefix "info threads\n")
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1481 gdb-info-threads-handler
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1482 gdb-info-threads-custom)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1483
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1484 (defun gdb-info-threads-custom ()
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1485 (with-current-buffer (gdb-get-buffer 'gdb-threads-buffer)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1486 (let ((buffer-read-only nil))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1487 (goto-char (point-min))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1488 (while (< (point) (point-max))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1489 (add-text-properties (point-at-bol) (point-at-eol)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1490 '(mouse-face highlight
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1491 help-echo "mouse-2, RET: select thread"))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1492 (forward-line 1)))))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1493
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1494 (defun gdb-threads-buffer-name ()
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1495 (with-current-buffer gud-comint-buffer
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1496 (concat "*threads of " (gdb-get-target-string) "*")))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1497
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1498 (defun gdb-display-threads-buffer ()
55400
1aaa031e318c Improve/extend documentation strings.
Nick Roberts <nickrob@snap.net.nz>
parents: 55330
diff changeset
1499 "Display IDs of currently known threads."
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1500 (interactive)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1501 (gdb-display-buffer
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1502 (gdb-get-create-buffer 'gdb-threads-buffer)))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1503
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1504 (defun gdb-frame-threads-buffer ()
55400
1aaa031e318c Improve/extend documentation strings.
Nick Roberts <nickrob@snap.net.nz>
parents: 55330
diff changeset
1505 "Display IDs of currently known threads in a new frame."
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1506 (interactive)
58521
54bb21951d18 (gdb-frame-parameters): Match height and
Nick Roberts <nickrob@snap.net.nz>
parents: 58485
diff changeset
1507 (let ((special-display-regexps (append special-display-regexps '(".*")))
54bb21951d18 (gdb-frame-parameters): Match height and
Nick Roberts <nickrob@snap.net.nz>
parents: 58485
diff changeset
1508 (special-display-frame-alist gdb-frame-parameters))
54bb21951d18 (gdb-frame-parameters): Match height and
Nick Roberts <nickrob@snap.net.nz>
parents: 58485
diff changeset
1509 (display-buffer (gdb-get-create-buffer 'gdb-threads-buffer))))
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1510
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1511 (defvar gdb-threads-mode-map
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1512 (let ((map (make-sparse-keymap)))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1513 (suppress-keymap map)
58485
31d7630f91d4 (gdb-breakpoints-mode-map)
Nick Roberts <nickrob@snap.net.nz>
parents: 58470
diff changeset
1514 (define-key map "q" 'kill-this-buffer)
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1515 (define-key map "\r" 'gdb-threads-select)
59708
9ce7d8f69f2c (gdb-goto-breakpoint, gdb-frames-select)
Nick Roberts <nickrob@snap.net.nz>
parents: 59635
diff changeset
1516 (define-key map [mouse-2] 'gdb-threads-select)
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1517 map))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1518
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1519 (defun gdb-threads-mode ()
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1520 "Major mode for gdb frames.
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1521
55749
230865f1c59d (gdb-server-prefix): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 55696
diff changeset
1522 \\{gdb-threads-mode-map}"
57661
b59713cd72a2 (gdb-get-create-buffer): Allow modes to run
Nick Roberts <nickrob@snap.net.nz>
parents: 57350
diff changeset
1523 (kill-all-local-variables)
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1524 (setq major-mode 'gdb-threads-mode)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1525 (setq mode-name "Threads")
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1526 (setq buffer-read-only t)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1527 (use-local-map gdb-threads-mode-map)
57661
b59713cd72a2 (gdb-get-create-buffer): Allow modes to run
Nick Roberts <nickrob@snap.net.nz>
parents: 57350
diff changeset
1528 (run-mode-hooks 'gdb-threads-mode-hook)
b59713cd72a2 (gdb-get-create-buffer): Allow modes to run
Nick Roberts <nickrob@snap.net.nz>
parents: 57350
diff changeset
1529 'gdb-invalidate-threads)
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1530
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1531 (defun gdb-get-thread-number ()
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1532 (save-excursion
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1533 (re-search-backward "^\\s-*\\([0-9]*\\)" nil t)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1534 (match-string-no-properties 1)))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1535
59708
9ce7d8f69f2c (gdb-goto-breakpoint, gdb-frames-select)
Nick Roberts <nickrob@snap.net.nz>
parents: 59635
diff changeset
1536 (defun gdb-threads-select (&optional event)
55400
1aaa031e318c Improve/extend documentation strings.
Nick Roberts <nickrob@snap.net.nz>
parents: 55330
diff changeset
1537 "Select the thread and display the relevant source."
59708
9ce7d8f69f2c (gdb-goto-breakpoint, gdb-frames-select)
Nick Roberts <nickrob@snap.net.nz>
parents: 59635
diff changeset
1538 (interactive (list last-input-event))
9ce7d8f69f2c (gdb-goto-breakpoint, gdb-frames-select)
Nick Roberts <nickrob@snap.net.nz>
parents: 59635
diff changeset
1539 (if event (mouse-set-point event))
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1540 (gdb-enqueue-input
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1541 (list (concat "thread " (gdb-get-thread-number) "\n") 'ignore))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1542 (gud-display-frame))
59708
9ce7d8f69f2c (gdb-goto-breakpoint, gdb-frames-select)
Nick Roberts <nickrob@snap.net.nz>
parents: 59635
diff changeset
1543
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1544
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1545 ;; Registers buffer.
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1546 ;;
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1547 (gdb-set-buffer-rules 'gdb-registers-buffer
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1548 'gdb-registers-buffer-name
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1549 'gdb-registers-mode)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1550
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1551 (def-gdb-auto-updated-buffer gdb-registers-buffer
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1552 gdb-invalidate-registers
55749
230865f1c59d (gdb-server-prefix): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 55696
diff changeset
1553 (concat gdb-server-prefix "info registers\n")
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1554 gdb-info-registers-handler
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1555 gdb-info-registers-custom)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1556
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1557 (defun gdb-info-registers-custom ())
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1558
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1559 (defvar gdb-registers-mode-map
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1560 (let ((map (make-sparse-keymap)))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1561 (suppress-keymap map)
58485
31d7630f91d4 (gdb-breakpoints-mode-map)
Nick Roberts <nickrob@snap.net.nz>
parents: 58470
diff changeset
1562 (define-key map "q" 'kill-this-buffer)
31d7630f91d4 (gdb-breakpoints-mode-map)
Nick Roberts <nickrob@snap.net.nz>
parents: 58470
diff changeset
1563 map))
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1564
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1565 (defun gdb-registers-mode ()
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1566 "Major mode for gdb registers.
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1567
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1568 \\{gdb-registers-mode-map}"
57661
b59713cd72a2 (gdb-get-create-buffer): Allow modes to run
Nick Roberts <nickrob@snap.net.nz>
parents: 57350
diff changeset
1569 (kill-all-local-variables)
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1570 (setq major-mode 'gdb-registers-mode)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1571 (setq mode-name "Registers")
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1572 (setq buffer-read-only t)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1573 (use-local-map gdb-registers-mode-map)
57661
b59713cd72a2 (gdb-get-create-buffer): Allow modes to run
Nick Roberts <nickrob@snap.net.nz>
parents: 57350
diff changeset
1574 (run-mode-hooks 'gdb-registers-mode-hook)
b59713cd72a2 (gdb-get-create-buffer): Allow modes to run
Nick Roberts <nickrob@snap.net.nz>
parents: 57350
diff changeset
1575 'gdb-invalidate-registers)
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1576
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1577 (defun gdb-registers-buffer-name ()
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1578 (with-current-buffer gud-comint-buffer
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1579 (concat "*registers of " (gdb-get-target-string) "*")))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1580
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1581 (defun gdb-display-registers-buffer ()
55400
1aaa031e318c Improve/extend documentation strings.
Nick Roberts <nickrob@snap.net.nz>
parents: 55330
diff changeset
1582 "Display integer register contents."
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1583 (interactive)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1584 (gdb-display-buffer
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1585 (gdb-get-create-buffer 'gdb-registers-buffer)))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1586
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1587 (defun gdb-frame-registers-buffer ()
55400
1aaa031e318c Improve/extend documentation strings.
Nick Roberts <nickrob@snap.net.nz>
parents: 55330
diff changeset
1588 "Display integer register contents in a new frame."
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1589 (interactive)
58521
54bb21951d18 (gdb-frame-parameters): Match height and
Nick Roberts <nickrob@snap.net.nz>
parents: 58485
diff changeset
1590 (let ((special-display-regexps (append special-display-regexps '(".*")))
54bb21951d18 (gdb-frame-parameters): Match height and
Nick Roberts <nickrob@snap.net.nz>
parents: 58485
diff changeset
1591 (special-display-frame-alist gdb-frame-parameters))
54bb21951d18 (gdb-frame-parameters): Match height and
Nick Roberts <nickrob@snap.net.nz>
parents: 58485
diff changeset
1592 (display-buffer (gdb-get-create-buffer 'gdb-registers-buffer))))
59808
37a65df00ab2 (gdb-memory-address)
Nick Roberts <nickrob@snap.net.nz>
parents: 59766
diff changeset
1593
37a65df00ab2 (gdb-memory-address)
Nick Roberts <nickrob@snap.net.nz>
parents: 59766
diff changeset
1594 ;; Memory buffer.
37a65df00ab2 (gdb-memory-address)
Nick Roberts <nickrob@snap.net.nz>
parents: 59766
diff changeset
1595 ;;
37a65df00ab2 (gdb-memory-address)
Nick Roberts <nickrob@snap.net.nz>
parents: 59766
diff changeset
1596 (defcustom gdb-memory-repeat-count 32
37a65df00ab2 (gdb-memory-address)
Nick Roberts <nickrob@snap.net.nz>
parents: 59766
diff changeset
1597 "Number of data items in memory window."
37a65df00ab2 (gdb-memory-address)
Nick Roberts <nickrob@snap.net.nz>
parents: 59766
diff changeset
1598 :type 'integer
37a65df00ab2 (gdb-memory-address)
Nick Roberts <nickrob@snap.net.nz>
parents: 59766
diff changeset
1599 :group 'gud
59996
aac0a33f5772 Change release version from 21.4 to 22.1 throughout.
Kim F. Storm <storm@cua.dk>
parents: 59988
diff changeset
1600 :version "22.1")
59808
37a65df00ab2 (gdb-memory-address)
Nick Roberts <nickrob@snap.net.nz>
parents: 59766
diff changeset
1601
37a65df00ab2 (gdb-memory-address)
Nick Roberts <nickrob@snap.net.nz>
parents: 59766
diff changeset
1602 (defcustom gdb-memory-format "x"
37a65df00ab2 (gdb-memory-address)
Nick Roberts <nickrob@snap.net.nz>
parents: 59766
diff changeset
1603 "Display format of data items in memory window."
37a65df00ab2 (gdb-memory-address)
Nick Roberts <nickrob@snap.net.nz>
parents: 59766
diff changeset
1604 :type '(choice (const :tag "Hexadecimal" "x")
37a65df00ab2 (gdb-memory-address)
Nick Roberts <nickrob@snap.net.nz>
parents: 59766
diff changeset
1605 (const :tag "Signed decimal" "d")
37a65df00ab2 (gdb-memory-address)
Nick Roberts <nickrob@snap.net.nz>
parents: 59766
diff changeset
1606 (const :tag "Unsigned decimal" "u")
37a65df00ab2 (gdb-memory-address)
Nick Roberts <nickrob@snap.net.nz>
parents: 59766
diff changeset
1607 (const :tag "Octal" "o")
37a65df00ab2 (gdb-memory-address)
Nick Roberts <nickrob@snap.net.nz>
parents: 59766
diff changeset
1608 (const :tag "Binary" "t"))
37a65df00ab2 (gdb-memory-address)
Nick Roberts <nickrob@snap.net.nz>
parents: 59766
diff changeset
1609 :group 'gud
59996
aac0a33f5772 Change release version from 21.4 to 22.1 throughout.
Kim F. Storm <storm@cua.dk>
parents: 59988
diff changeset
1610 :version "22.1")
59808
37a65df00ab2 (gdb-memory-address)
Nick Roberts <nickrob@snap.net.nz>
parents: 59766
diff changeset
1611
37a65df00ab2 (gdb-memory-address)
Nick Roberts <nickrob@snap.net.nz>
parents: 59766
diff changeset
1612 (defcustom gdb-memory-unit "w"
37a65df00ab2 (gdb-memory-address)
Nick Roberts <nickrob@snap.net.nz>
parents: 59766
diff changeset
1613 "Unit size of data items in memory window."
37a65df00ab2 (gdb-memory-address)
Nick Roberts <nickrob@snap.net.nz>
parents: 59766
diff changeset
1614 :type '(choice (const :tag "Byte" "b")
37a65df00ab2 (gdb-memory-address)
Nick Roberts <nickrob@snap.net.nz>
parents: 59766
diff changeset
1615 (const :tag "Halfword" "h")
37a65df00ab2 (gdb-memory-address)
Nick Roberts <nickrob@snap.net.nz>
parents: 59766
diff changeset
1616 (const :tag "Word" "w")
37a65df00ab2 (gdb-memory-address)
Nick Roberts <nickrob@snap.net.nz>
parents: 59766
diff changeset
1617 (const :tag "Giant word" "g"))
37a65df00ab2 (gdb-memory-address)
Nick Roberts <nickrob@snap.net.nz>
parents: 59766
diff changeset
1618 :group 'gud
59996
aac0a33f5772 Change release version from 21.4 to 22.1 throughout.
Kim F. Storm <storm@cua.dk>
parents: 59988
diff changeset
1619 :version "22.1")
59808
37a65df00ab2 (gdb-memory-address)
Nick Roberts <nickrob@snap.net.nz>
parents: 59766
diff changeset
1620
37a65df00ab2 (gdb-memory-address)
Nick Roberts <nickrob@snap.net.nz>
parents: 59766
diff changeset
1621 (gdb-set-buffer-rules 'gdb-memory-buffer
37a65df00ab2 (gdb-memory-address)
Nick Roberts <nickrob@snap.net.nz>
parents: 59766
diff changeset
1622 'gdb-memory-buffer-name
37a65df00ab2 (gdb-memory-address)
Nick Roberts <nickrob@snap.net.nz>
parents: 59766
diff changeset
1623 'gdb-memory-mode)
37a65df00ab2 (gdb-memory-address)
Nick Roberts <nickrob@snap.net.nz>
parents: 59766
diff changeset
1624
37a65df00ab2 (gdb-memory-address)
Nick Roberts <nickrob@snap.net.nz>
parents: 59766
diff changeset
1625 (def-gdb-auto-updated-buffer gdb-memory-buffer
37a65df00ab2 (gdb-memory-address)
Nick Roberts <nickrob@snap.net.nz>
parents: 59766
diff changeset
1626 gdb-invalidate-memory
37a65df00ab2 (gdb-memory-address)
Nick Roberts <nickrob@snap.net.nz>
parents: 59766
diff changeset
1627 (concat gdb-server-prefix "x/" (number-to-string gdb-memory-repeat-count)
37a65df00ab2 (gdb-memory-address)
Nick Roberts <nickrob@snap.net.nz>
parents: 59766
diff changeset
1628 gdb-memory-format gdb-memory-unit " " gdb-memory-address "\n")
37a65df00ab2 (gdb-memory-address)
Nick Roberts <nickrob@snap.net.nz>
parents: 59766
diff changeset
1629 gdb-read-memory-handler
37a65df00ab2 (gdb-memory-address)
Nick Roberts <nickrob@snap.net.nz>
parents: 59766
diff changeset
1630 gdb-read-memory-custom)
37a65df00ab2 (gdb-memory-address)
Nick Roberts <nickrob@snap.net.nz>
parents: 59766
diff changeset
1631
37a65df00ab2 (gdb-memory-address)
Nick Roberts <nickrob@snap.net.nz>
parents: 59766
diff changeset
1632 (defun gdb-read-memory-custom ())
37a65df00ab2 (gdb-memory-address)
Nick Roberts <nickrob@snap.net.nz>
parents: 59766
diff changeset
1633
37a65df00ab2 (gdb-memory-address)
Nick Roberts <nickrob@snap.net.nz>
parents: 59766
diff changeset
1634 (defvar gdb-memory-mode-map
37a65df00ab2 (gdb-memory-address)
Nick Roberts <nickrob@snap.net.nz>
parents: 59766
diff changeset
1635 (let ((map (make-sparse-keymap)))
37a65df00ab2 (gdb-memory-address)
Nick Roberts <nickrob@snap.net.nz>
parents: 59766
diff changeset
1636 (suppress-keymap map)
37a65df00ab2 (gdb-memory-address)
Nick Roberts <nickrob@snap.net.nz>
parents: 59766
diff changeset
1637 (define-key map "q" 'kill-this-buffer)
37a65df00ab2 (gdb-memory-address)
Nick Roberts <nickrob@snap.net.nz>
parents: 59766
diff changeset
1638 map))
37a65df00ab2 (gdb-memory-address)
Nick Roberts <nickrob@snap.net.nz>
parents: 59766
diff changeset
1639
37a65df00ab2 (gdb-memory-address)
Nick Roberts <nickrob@snap.net.nz>
parents: 59766
diff changeset
1640 (defun gdb-memory-set-address (event)
37a65df00ab2 (gdb-memory-address)
Nick Roberts <nickrob@snap.net.nz>
parents: 59766
diff changeset
1641 "Set the start memory address."
37a65df00ab2 (gdb-memory-address)
Nick Roberts <nickrob@snap.net.nz>
parents: 59766
diff changeset
1642 (interactive "e")
37a65df00ab2 (gdb-memory-address)
Nick Roberts <nickrob@snap.net.nz>
parents: 59766
diff changeset
1643 (save-selected-window
37a65df00ab2 (gdb-memory-address)
Nick Roberts <nickrob@snap.net.nz>
parents: 59766
diff changeset
1644 (select-window (posn-window (event-start event)))
37a65df00ab2 (gdb-memory-address)
Nick Roberts <nickrob@snap.net.nz>
parents: 59766
diff changeset
1645 (let ((arg (read-from-minibuffer "Memory address: ")))
37a65df00ab2 (gdb-memory-address)
Nick Roberts <nickrob@snap.net.nz>
parents: 59766
diff changeset
1646 (setq gdb-memory-address arg))
37a65df00ab2 (gdb-memory-address)
Nick Roberts <nickrob@snap.net.nz>
parents: 59766
diff changeset
1647 (gdb-invalidate-memory)))
37a65df00ab2 (gdb-memory-address)
Nick Roberts <nickrob@snap.net.nz>
parents: 59766
diff changeset
1648
37a65df00ab2 (gdb-memory-address)
Nick Roberts <nickrob@snap.net.nz>
parents: 59766
diff changeset
1649 (defun gdb-memory-set-repeat-count (event)
37a65df00ab2 (gdb-memory-address)
Nick Roberts <nickrob@snap.net.nz>
parents: 59766
diff changeset
1650 "Set the number of data items in memory window."
37a65df00ab2 (gdb-memory-address)
Nick Roberts <nickrob@snap.net.nz>
parents: 59766
diff changeset
1651 (interactive "e")
37a65df00ab2 (gdb-memory-address)
Nick Roberts <nickrob@snap.net.nz>
parents: 59766
diff changeset
1652 (save-selected-window
37a65df00ab2 (gdb-memory-address)
Nick Roberts <nickrob@snap.net.nz>
parents: 59766
diff changeset
1653 (select-window (posn-window (event-start event)))
37a65df00ab2 (gdb-memory-address)
Nick Roberts <nickrob@snap.net.nz>
parents: 59766
diff changeset
1654 (let* ((arg (read-from-minibuffer "Repeat count: "))
37a65df00ab2 (gdb-memory-address)
Nick Roberts <nickrob@snap.net.nz>
parents: 59766
diff changeset
1655 (count (string-to-int arg)))
37a65df00ab2 (gdb-memory-address)
Nick Roberts <nickrob@snap.net.nz>
parents: 59766
diff changeset
1656 (if (< count 0)
37a65df00ab2 (gdb-memory-address)
Nick Roberts <nickrob@snap.net.nz>
parents: 59766
diff changeset
1657 (error "Non-negative numbers only")
37a65df00ab2 (gdb-memory-address)
Nick Roberts <nickrob@snap.net.nz>
parents: 59766
diff changeset
1658 (customize-set-variable 'gdb-memory-repeat-count count)
37a65df00ab2 (gdb-memory-address)
Nick Roberts <nickrob@snap.net.nz>
parents: 59766
diff changeset
1659 (gdb-invalidate-memory)))))
37a65df00ab2 (gdb-memory-address)
Nick Roberts <nickrob@snap.net.nz>
parents: 59766
diff changeset
1660
37a65df00ab2 (gdb-memory-address)
Nick Roberts <nickrob@snap.net.nz>
parents: 59766
diff changeset
1661 (defun gdb-memory-format-binary ()
37a65df00ab2 (gdb-memory-address)
Nick Roberts <nickrob@snap.net.nz>
parents: 59766
diff changeset
1662 "Set the display format to binary."
37a65df00ab2 (gdb-memory-address)
Nick Roberts <nickrob@snap.net.nz>
parents: 59766
diff changeset
1663 (interactive)
37a65df00ab2 (gdb-memory-address)
Nick Roberts <nickrob@snap.net.nz>
parents: 59766
diff changeset
1664 (customize-set-variable 'gdb-memory-format "t")
37a65df00ab2 (gdb-memory-address)
Nick Roberts <nickrob@snap.net.nz>
parents: 59766
diff changeset
1665 (gdb-invalidate-memory))
37a65df00ab2 (gdb-memory-address)
Nick Roberts <nickrob@snap.net.nz>
parents: 59766
diff changeset
1666
37a65df00ab2 (gdb-memory-address)
Nick Roberts <nickrob@snap.net.nz>
parents: 59766
diff changeset
1667 (defun gdb-memory-format-octal ()
37a65df00ab2 (gdb-memory-address)
Nick Roberts <nickrob@snap.net.nz>
parents: 59766
diff changeset
1668 "Set the display format to octal."
37a65df00ab2 (gdb-memory-address)
Nick Roberts <nickrob@snap.net.nz>
parents: 59766
diff changeset
1669 (interactive)
37a65df00ab2 (gdb-memory-address)
Nick Roberts <nickrob@snap.net.nz>
parents: 59766
diff changeset
1670 (customize-set-variable 'gdb-memory-format "o")
37a65df00ab2 (gdb-memory-address)
Nick Roberts <nickrob@snap.net.nz>
parents: 59766
diff changeset
1671 (gdb-invalidate-memory))
37a65df00ab2 (gdb-memory-address)
Nick Roberts <nickrob@snap.net.nz>
parents: 59766
diff changeset
1672
37a65df00ab2 (gdb-memory-address)
Nick Roberts <nickrob@snap.net.nz>
parents: 59766
diff changeset
1673 (defun gdb-memory-format-unsigned ()
37a65df00ab2 (gdb-memory-address)
Nick Roberts <nickrob@snap.net.nz>
parents: 59766
diff changeset
1674 "Set the display format to unsigned decimal."
37a65df00ab2 (gdb-memory-address)
Nick Roberts <nickrob@snap.net.nz>
parents: 59766
diff changeset
1675 (interactive)
37a65df00ab2 (gdb-memory-address)
Nick Roberts <nickrob@snap.net.nz>
parents: 59766
diff changeset
1676 (customize-set-variable 'gdb-memory-format "u")
37a65df00ab2 (gdb-memory-address)
Nick Roberts <nickrob@snap.net.nz>
parents: 59766
diff changeset
1677 (gdb-invalidate-memory))
37a65df00ab2 (gdb-memory-address)
Nick Roberts <nickrob@snap.net.nz>
parents: 59766
diff changeset
1678
37a65df00ab2 (gdb-memory-address)
Nick Roberts <nickrob@snap.net.nz>
parents: 59766
diff changeset
1679 (defun gdb-memory-format-signed ()
37a65df00ab2 (gdb-memory-address)
Nick Roberts <nickrob@snap.net.nz>
parents: 59766
diff changeset
1680 "Set the display format to decimal."
37a65df00ab2 (gdb-memory-address)
Nick Roberts <nickrob@snap.net.nz>
parents: 59766
diff changeset
1681 (interactive)
37a65df00ab2 (gdb-memory-address)
Nick Roberts <nickrob@snap.net.nz>
parents: 59766
diff changeset
1682 (customize-set-variable 'gdb-memory-format "d")
37a65df00ab2 (gdb-memory-address)
Nick Roberts <nickrob@snap.net.nz>
parents: 59766
diff changeset
1683 (gdb-invalidate-memory))
37a65df00ab2 (gdb-memory-address)
Nick Roberts <nickrob@snap.net.nz>
parents: 59766
diff changeset
1684
37a65df00ab2 (gdb-memory-address)
Nick Roberts <nickrob@snap.net.nz>
parents: 59766
diff changeset
1685 (defun gdb-memory-format-hexadecimal ()
37a65df00ab2 (gdb-memory-address)
Nick Roberts <nickrob@snap.net.nz>
parents: 59766
diff changeset
1686 "Set the display format to hexadecimal."
37a65df00ab2 (gdb-memory-address)
Nick Roberts <nickrob@snap.net.nz>
parents: 59766
diff changeset
1687 (interactive)
37a65df00ab2 (gdb-memory-address)
Nick Roberts <nickrob@snap.net.nz>
parents: 59766
diff changeset
1688 (customize-set-variable 'gdb-memory-format "x")
37a65df00ab2 (gdb-memory-address)
Nick Roberts <nickrob@snap.net.nz>
parents: 59766
diff changeset
1689 (gdb-invalidate-memory))
37a65df00ab2 (gdb-memory-address)
Nick Roberts <nickrob@snap.net.nz>
parents: 59766
diff changeset
1690
37a65df00ab2 (gdb-memory-address)
Nick Roberts <nickrob@snap.net.nz>
parents: 59766
diff changeset
1691 (defvar gdb-memory-format-keymap
37a65df00ab2 (gdb-memory-address)
Nick Roberts <nickrob@snap.net.nz>
parents: 59766
diff changeset
1692 (let ((map (make-sparse-keymap)))
37a65df00ab2 (gdb-memory-address)
Nick Roberts <nickrob@snap.net.nz>
parents: 59766
diff changeset
1693 (define-key map [header-line down-mouse-3] 'gdb-memory-format-menu-1)
37a65df00ab2 (gdb-memory-address)
Nick Roberts <nickrob@snap.net.nz>
parents: 59766
diff changeset
1694 map)
37a65df00ab2 (gdb-memory-address)
Nick Roberts <nickrob@snap.net.nz>
parents: 59766
diff changeset
1695 "Keymap to select format in the header line.")
37a65df00ab2 (gdb-memory-address)
Nick Roberts <nickrob@snap.net.nz>
parents: 59766
diff changeset
1696
37a65df00ab2 (gdb-memory-address)
Nick Roberts <nickrob@snap.net.nz>
parents: 59766
diff changeset
1697 (defvar gdb-memory-format-menu (make-sparse-keymap "Format")
37a65df00ab2 (gdb-memory-address)
Nick Roberts <nickrob@snap.net.nz>
parents: 59766
diff changeset
1698 "Menu of display formats in the header line.")
37a65df00ab2 (gdb-memory-address)
Nick Roberts <nickrob@snap.net.nz>
parents: 59766
diff changeset
1699
37a65df00ab2 (gdb-memory-address)
Nick Roberts <nickrob@snap.net.nz>
parents: 59766
diff changeset
1700 (define-key gdb-memory-format-menu [binary]
37a65df00ab2 (gdb-memory-address)
Nick Roberts <nickrob@snap.net.nz>
parents: 59766
diff changeset
1701 '(menu-item "Binary" gdb-memory-format-binary
37a65df00ab2 (gdb-memory-address)
Nick Roberts <nickrob@snap.net.nz>
parents: 59766
diff changeset
1702 :button (:radio . (equal gdb-memory-format "t"))))
37a65df00ab2 (gdb-memory-address)
Nick Roberts <nickrob@snap.net.nz>
parents: 59766
diff changeset
1703 (define-key gdb-memory-format-menu [octal]
37a65df00ab2 (gdb-memory-address)
Nick Roberts <nickrob@snap.net.nz>
parents: 59766
diff changeset
1704 '(menu-item "Octal" gdb-memory-format-octal
37a65df00ab2 (gdb-memory-address)
Nick Roberts <nickrob@snap.net.nz>
parents: 59766
diff changeset
1705 :button (:radio . (equal gdb-memory-format "o"))))
37a65df00ab2 (gdb-memory-address)
Nick Roberts <nickrob@snap.net.nz>
parents: 59766
diff changeset
1706 (define-key gdb-memory-format-menu [unsigned]
37a65df00ab2 (gdb-memory-address)
Nick Roberts <nickrob@snap.net.nz>
parents: 59766
diff changeset
1707 '(menu-item "Unsigned Decimal" gdb-memory-format-unsigned
37a65df00ab2 (gdb-memory-address)
Nick Roberts <nickrob@snap.net.nz>
parents: 59766
diff changeset
1708 :button (:radio . (equal gdb-memory-format "u"))))
37a65df00ab2 (gdb-memory-address)
Nick Roberts <nickrob@snap.net.nz>
parents: 59766
diff changeset
1709 (define-key gdb-memory-format-menu [signed]
37a65df00ab2 (gdb-memory-address)
Nick Roberts <nickrob@snap.net.nz>
parents: 59766
diff changeset
1710 '(menu-item "Signed Decimal" gdb-memory-format-signed
37a65df00ab2 (gdb-memory-address)
Nick Roberts <nickrob@snap.net.nz>
parents: 59766
diff changeset
1711 :button (:radio . (equal gdb-memory-format "d"))))
37a65df00ab2 (gdb-memory-address)
Nick Roberts <nickrob@snap.net.nz>
parents: 59766
diff changeset
1712 (define-key gdb-memory-format-menu [hexadecimal]
37a65df00ab2 (gdb-memory-address)
Nick Roberts <nickrob@snap.net.nz>
parents: 59766
diff changeset
1713 '(menu-item "Hexadecimal" gdb-memory-format-hexadecimal
37a65df00ab2 (gdb-memory-address)
Nick Roberts <nickrob@snap.net.nz>
parents: 59766
diff changeset
1714 :button (:radio . (equal gdb-memory-format "x"))))
37a65df00ab2 (gdb-memory-address)
Nick Roberts <nickrob@snap.net.nz>
parents: 59766
diff changeset
1715
37a65df00ab2 (gdb-memory-address)
Nick Roberts <nickrob@snap.net.nz>
parents: 59766
diff changeset
1716 (defun gdb-memory-format-menu (event)
37a65df00ab2 (gdb-memory-address)
Nick Roberts <nickrob@snap.net.nz>
parents: 59766
diff changeset
1717 (interactive "@e")
37a65df00ab2 (gdb-memory-address)
Nick Roberts <nickrob@snap.net.nz>
parents: 59766
diff changeset
1718 (x-popup-menu event gdb-memory-format-menu))
37a65df00ab2 (gdb-memory-address)
Nick Roberts <nickrob@snap.net.nz>
parents: 59766
diff changeset
1719
37a65df00ab2 (gdb-memory-address)
Nick Roberts <nickrob@snap.net.nz>
parents: 59766
diff changeset
1720 (defun gdb-memory-format-menu-1 (event)
37a65df00ab2 (gdb-memory-address)
Nick Roberts <nickrob@snap.net.nz>
parents: 59766
diff changeset
1721 (interactive "e")
37a65df00ab2 (gdb-memory-address)
Nick Roberts <nickrob@snap.net.nz>
parents: 59766
diff changeset
1722 (save-selected-window
37a65df00ab2 (gdb-memory-address)
Nick Roberts <nickrob@snap.net.nz>
parents: 59766
diff changeset
1723 (select-window (posn-window (event-start event)))
37a65df00ab2 (gdb-memory-address)
Nick Roberts <nickrob@snap.net.nz>
parents: 59766
diff changeset
1724 (let* ((selection (gdb-memory-format-menu event))
37a65df00ab2 (gdb-memory-address)
Nick Roberts <nickrob@snap.net.nz>
parents: 59766
diff changeset
1725 (binding (and selection (lookup-key gdb-memory-format-menu
37a65df00ab2 (gdb-memory-address)
Nick Roberts <nickrob@snap.net.nz>
parents: 59766
diff changeset
1726 (vector (car selection))))))
37a65df00ab2 (gdb-memory-address)
Nick Roberts <nickrob@snap.net.nz>
parents: 59766
diff changeset
1727 (if binding (call-interactively binding)))))
37a65df00ab2 (gdb-memory-address)
Nick Roberts <nickrob@snap.net.nz>
parents: 59766
diff changeset
1728
37a65df00ab2 (gdb-memory-address)
Nick Roberts <nickrob@snap.net.nz>
parents: 59766
diff changeset
1729 (defun gdb-memory-unit-giant ()
37a65df00ab2 (gdb-memory-address)
Nick Roberts <nickrob@snap.net.nz>
parents: 59766
diff changeset
1730 "Set the unit size to giant words (eight bytes)."
37a65df00ab2 (gdb-memory-address)
Nick Roberts <nickrob@snap.net.nz>
parents: 59766
diff changeset
1731 (interactive)
37a65df00ab2 (gdb-memory-address)
Nick Roberts <nickrob@snap.net.nz>
parents: 59766
diff changeset
1732 (customize-set-variable 'gdb-memory-unit "g")
37a65df00ab2 (gdb-memory-address)
Nick Roberts <nickrob@snap.net.nz>
parents: 59766
diff changeset
1733 (gdb-invalidate-memory))
37a65df00ab2 (gdb-memory-address)
Nick Roberts <nickrob@snap.net.nz>
parents: 59766
diff changeset
1734
37a65df00ab2 (gdb-memory-address)
Nick Roberts <nickrob@snap.net.nz>
parents: 59766
diff changeset
1735 (defun gdb-memory-unit-word ()
37a65df00ab2 (gdb-memory-address)
Nick Roberts <nickrob@snap.net.nz>
parents: 59766
diff changeset
1736 "Set the unit size to words (four bytes)."
37a65df00ab2 (gdb-memory-address)
Nick Roberts <nickrob@snap.net.nz>
parents: 59766
diff changeset
1737 (interactive)
37a65df00ab2 (gdb-memory-address)
Nick Roberts <nickrob@snap.net.nz>
parents: 59766
diff changeset
1738 (customize-set-variable 'gdb-memory-unit "w")
37a65df00ab2 (gdb-memory-address)
Nick Roberts <nickrob@snap.net.nz>
parents: 59766
diff changeset
1739 (gdb-invalidate-memory))
37a65df00ab2 (gdb-memory-address)
Nick Roberts <nickrob@snap.net.nz>
parents: 59766
diff changeset
1740
37a65df00ab2 (gdb-memory-address)
Nick Roberts <nickrob@snap.net.nz>
parents: 59766
diff changeset
1741 (defun gdb-memory-unit-halfword ()
37a65df00ab2 (gdb-memory-address)
Nick Roberts <nickrob@snap.net.nz>
parents: 59766
diff changeset
1742 "Set the unit size to halfwords (two bytes)."
37a65df00ab2 (gdb-memory-address)
Nick Roberts <nickrob@snap.net.nz>
parents: 59766
diff changeset
1743 (interactive)
37a65df00ab2 (gdb-memory-address)
Nick Roberts <nickrob@snap.net.nz>
parents: 59766
diff changeset
1744 (customize-set-variable 'gdb-memory-unit "h")
37a65df00ab2 (gdb-memory-address)
Nick Roberts <nickrob@snap.net.nz>
parents: 59766
diff changeset
1745 (gdb-invalidate-memory))
37a65df00ab2 (gdb-memory-address)
Nick Roberts <nickrob@snap.net.nz>
parents: 59766
diff changeset
1746
37a65df00ab2 (gdb-memory-address)
Nick Roberts <nickrob@snap.net.nz>
parents: 59766
diff changeset
1747 (defun gdb-memory-unit-byte ()
37a65df00ab2 (gdb-memory-address)
Nick Roberts <nickrob@snap.net.nz>
parents: 59766
diff changeset
1748 "Set the unit size to bytes."
37a65df00ab2 (gdb-memory-address)
Nick Roberts <nickrob@snap.net.nz>
parents: 59766
diff changeset
1749 (interactive)
37a65df00ab2 (gdb-memory-address)
Nick Roberts <nickrob@snap.net.nz>
parents: 59766
diff changeset
1750 (customize-set-variable 'gdb-memory-unit "b")
37a65df00ab2 (gdb-memory-address)
Nick Roberts <nickrob@snap.net.nz>
parents: 59766
diff changeset
1751 (gdb-invalidate-memory))
37a65df00ab2 (gdb-memory-address)
Nick Roberts <nickrob@snap.net.nz>
parents: 59766
diff changeset
1752
37a65df00ab2 (gdb-memory-address)
Nick Roberts <nickrob@snap.net.nz>
parents: 59766
diff changeset
1753 (defvar gdb-memory-unit-keymap
37a65df00ab2 (gdb-memory-address)
Nick Roberts <nickrob@snap.net.nz>
parents: 59766
diff changeset
1754 (let ((map (make-sparse-keymap)))
37a65df00ab2 (gdb-memory-address)
Nick Roberts <nickrob@snap.net.nz>
parents: 59766
diff changeset
1755 (define-key map [header-line down-mouse-3] 'gdb-memory-unit-menu-1)
37a65df00ab2 (gdb-memory-address)
Nick Roberts <nickrob@snap.net.nz>
parents: 59766
diff changeset
1756 map)
37a65df00ab2 (gdb-memory-address)
Nick Roberts <nickrob@snap.net.nz>
parents: 59766
diff changeset
1757 "Keymap to select units in the header line.")
37a65df00ab2 (gdb-memory-address)
Nick Roberts <nickrob@snap.net.nz>
parents: 59766
diff changeset
1758
37a65df00ab2 (gdb-memory-address)
Nick Roberts <nickrob@snap.net.nz>
parents: 59766
diff changeset
1759 (defvar gdb-memory-unit-menu (make-sparse-keymap "Unit")
37a65df00ab2 (gdb-memory-address)
Nick Roberts <nickrob@snap.net.nz>
parents: 59766
diff changeset
1760 "Menu of units in the header line.")
37a65df00ab2 (gdb-memory-address)
Nick Roberts <nickrob@snap.net.nz>
parents: 59766
diff changeset
1761
37a65df00ab2 (gdb-memory-address)
Nick Roberts <nickrob@snap.net.nz>
parents: 59766
diff changeset
1762 (define-key gdb-memory-unit-menu [giantwords]
37a65df00ab2 (gdb-memory-address)
Nick Roberts <nickrob@snap.net.nz>
parents: 59766
diff changeset
1763 '(menu-item "Giant words" gdb-memory-unit-giant
37a65df00ab2 (gdb-memory-address)
Nick Roberts <nickrob@snap.net.nz>
parents: 59766
diff changeset
1764 :button (:radio . (equal gdb-memory-unit "g"))))
37a65df00ab2 (gdb-memory-address)
Nick Roberts <nickrob@snap.net.nz>
parents: 59766
diff changeset
1765 (define-key gdb-memory-unit-menu [words]
37a65df00ab2 (gdb-memory-address)
Nick Roberts <nickrob@snap.net.nz>
parents: 59766
diff changeset
1766 '(menu-item "Words" gdb-memory-unit-word
37a65df00ab2 (gdb-memory-address)
Nick Roberts <nickrob@snap.net.nz>
parents: 59766
diff changeset
1767 :button (:radio . (equal gdb-memory-unit "w"))))
37a65df00ab2 (gdb-memory-address)
Nick Roberts <nickrob@snap.net.nz>
parents: 59766
diff changeset
1768 (define-key gdb-memory-unit-menu [halfwords]
37a65df00ab2 (gdb-memory-address)
Nick Roberts <nickrob@snap.net.nz>
parents: 59766
diff changeset
1769 '(menu-item "Halfwords" gdb-memory-unit-halfword
37a65df00ab2 (gdb-memory-address)
Nick Roberts <nickrob@snap.net.nz>
parents: 59766
diff changeset
1770 :button (:radio . (equal gdb-memory-unit "h"))))
37a65df00ab2 (gdb-memory-address)
Nick Roberts <nickrob@snap.net.nz>
parents: 59766
diff changeset
1771 (define-key gdb-memory-unit-menu [bytes]
37a65df00ab2 (gdb-memory-address)
Nick Roberts <nickrob@snap.net.nz>
parents: 59766
diff changeset
1772 '(menu-item "Bytes" gdb-memory-unit-byte
37a65df00ab2 (gdb-memory-address)
Nick Roberts <nickrob@snap.net.nz>
parents: 59766
diff changeset
1773 :button (:radio . (equal gdb-memory-unit "b"))))
37a65df00ab2 (gdb-memory-address)
Nick Roberts <nickrob@snap.net.nz>
parents: 59766
diff changeset
1774
37a65df00ab2 (gdb-memory-address)
Nick Roberts <nickrob@snap.net.nz>
parents: 59766
diff changeset
1775 (defun gdb-memory-unit-menu (event)
37a65df00ab2 (gdb-memory-address)
Nick Roberts <nickrob@snap.net.nz>
parents: 59766
diff changeset
1776 (interactive "@e")
37a65df00ab2 (gdb-memory-address)
Nick Roberts <nickrob@snap.net.nz>
parents: 59766
diff changeset
1777 (x-popup-menu event gdb-memory-unit-menu))
37a65df00ab2 (gdb-memory-address)
Nick Roberts <nickrob@snap.net.nz>
parents: 59766
diff changeset
1778
37a65df00ab2 (gdb-memory-address)
Nick Roberts <nickrob@snap.net.nz>
parents: 59766
diff changeset
1779 (defun gdb-memory-unit-menu-1 (event)
37a65df00ab2 (gdb-memory-address)
Nick Roberts <nickrob@snap.net.nz>
parents: 59766
diff changeset
1780 (interactive "e")
37a65df00ab2 (gdb-memory-address)
Nick Roberts <nickrob@snap.net.nz>
parents: 59766
diff changeset
1781 (save-selected-window
37a65df00ab2 (gdb-memory-address)
Nick Roberts <nickrob@snap.net.nz>
parents: 59766
diff changeset
1782 (select-window (posn-window (event-start event)))
37a65df00ab2 (gdb-memory-address)
Nick Roberts <nickrob@snap.net.nz>
parents: 59766
diff changeset
1783 (let* ((selection (gdb-memory-unit-menu event))
37a65df00ab2 (gdb-memory-address)
Nick Roberts <nickrob@snap.net.nz>
parents: 59766
diff changeset
1784 (binding (and selection (lookup-key gdb-memory-unit-menu
37a65df00ab2 (gdb-memory-address)
Nick Roberts <nickrob@snap.net.nz>
parents: 59766
diff changeset
1785 (vector (car selection))))))
37a65df00ab2 (gdb-memory-address)
Nick Roberts <nickrob@snap.net.nz>
parents: 59766
diff changeset
1786 (if binding (call-interactively binding)))))
37a65df00ab2 (gdb-memory-address)
Nick Roberts <nickrob@snap.net.nz>
parents: 59766
diff changeset
1787
37a65df00ab2 (gdb-memory-address)
Nick Roberts <nickrob@snap.net.nz>
parents: 59766
diff changeset
1788 ;;from make-mode-line-mouse-map
37a65df00ab2 (gdb-memory-address)
Nick Roberts <nickrob@snap.net.nz>
parents: 59766
diff changeset
1789 (defun gdb-make-header-line-mouse-map (mouse function) "\
37a65df00ab2 (gdb-memory-address)
Nick Roberts <nickrob@snap.net.nz>
parents: 59766
diff changeset
1790 Return a keymap with single entry for mouse key MOUSE on the header line.
37a65df00ab2 (gdb-memory-address)
Nick Roberts <nickrob@snap.net.nz>
parents: 59766
diff changeset
1791 MOUSE is defined to run function FUNCTION with no args in the buffer
37a65df00ab2 (gdb-memory-address)
Nick Roberts <nickrob@snap.net.nz>
parents: 59766
diff changeset
1792 corresponding to the mode line clicked."
37a65df00ab2 (gdb-memory-address)
Nick Roberts <nickrob@snap.net.nz>
parents: 59766
diff changeset
1793 (let ((map (make-sparse-keymap)))
37a65df00ab2 (gdb-memory-address)
Nick Roberts <nickrob@snap.net.nz>
parents: 59766
diff changeset
1794 (define-key map (vector 'header-line mouse) function)
37a65df00ab2 (gdb-memory-address)
Nick Roberts <nickrob@snap.net.nz>
parents: 59766
diff changeset
1795 (define-key map (vector 'header-line 'down-mouse-1) 'ignore)
37a65df00ab2 (gdb-memory-address)
Nick Roberts <nickrob@snap.net.nz>
parents: 59766
diff changeset
1796 map))
37a65df00ab2 (gdb-memory-address)
Nick Roberts <nickrob@snap.net.nz>
parents: 59766
diff changeset
1797
37a65df00ab2 (gdb-memory-address)
Nick Roberts <nickrob@snap.net.nz>
parents: 59766
diff changeset
1798 (defun gdb-memory-mode ()
37a65df00ab2 (gdb-memory-address)
Nick Roberts <nickrob@snap.net.nz>
parents: 59766
diff changeset
1799 "Major mode for examining memory.
37a65df00ab2 (gdb-memory-address)
Nick Roberts <nickrob@snap.net.nz>
parents: 59766
diff changeset
1800
37a65df00ab2 (gdb-memory-address)
Nick Roberts <nickrob@snap.net.nz>
parents: 59766
diff changeset
1801 \\{gdb-memory-mode-map}"
37a65df00ab2 (gdb-memory-address)
Nick Roberts <nickrob@snap.net.nz>
parents: 59766
diff changeset
1802 (kill-all-local-variables)
37a65df00ab2 (gdb-memory-address)
Nick Roberts <nickrob@snap.net.nz>
parents: 59766
diff changeset
1803 (setq major-mode 'gdb-memory-mode)
37a65df00ab2 (gdb-memory-address)
Nick Roberts <nickrob@snap.net.nz>
parents: 59766
diff changeset
1804 (setq mode-name "Memory")
37a65df00ab2 (gdb-memory-address)
Nick Roberts <nickrob@snap.net.nz>
parents: 59766
diff changeset
1805 (setq buffer-read-only t)
37a65df00ab2 (gdb-memory-address)
Nick Roberts <nickrob@snap.net.nz>
parents: 59766
diff changeset
1806 (use-local-map gdb-memory-mode-map)
37a65df00ab2 (gdb-memory-address)
Nick Roberts <nickrob@snap.net.nz>
parents: 59766
diff changeset
1807 (setq header-line-format
37a65df00ab2 (gdb-memory-address)
Nick Roberts <nickrob@snap.net.nz>
parents: 59766
diff changeset
1808 '(:eval
59996
aac0a33f5772 Change release version from 21.4 to 22.1 throughout.
Kim F. Storm <storm@cua.dk>
parents: 59988
diff changeset
1809 (concat
59808
37a65df00ab2 (gdb-memory-address)
Nick Roberts <nickrob@snap.net.nz>
parents: 59766
diff changeset
1810 "Read address: "
37a65df00ab2 (gdb-memory-address)
Nick Roberts <nickrob@snap.net.nz>
parents: 59766
diff changeset
1811 (propertize gdb-memory-address
37a65df00ab2 (gdb-memory-address)
Nick Roberts <nickrob@snap.net.nz>
parents: 59766
diff changeset
1812 'face font-lock-warning-face
37a65df00ab2 (gdb-memory-address)
Nick Roberts <nickrob@snap.net.nz>
parents: 59766
diff changeset
1813 'help-echo (purecopy "mouse-1: Set memory address")
37a65df00ab2 (gdb-memory-address)
Nick Roberts <nickrob@snap.net.nz>
parents: 59766
diff changeset
1814 'local-map (purecopy (gdb-make-header-line-mouse-map
37a65df00ab2 (gdb-memory-address)
Nick Roberts <nickrob@snap.net.nz>
parents: 59766
diff changeset
1815 'mouse-1
37a65df00ab2 (gdb-memory-address)
Nick Roberts <nickrob@snap.net.nz>
parents: 59766
diff changeset
1816 #'gdb-memory-set-address)))
37a65df00ab2 (gdb-memory-address)
Nick Roberts <nickrob@snap.net.nz>
parents: 59766
diff changeset
1817 " Repeat Count: "
37a65df00ab2 (gdb-memory-address)
Nick Roberts <nickrob@snap.net.nz>
parents: 59766
diff changeset
1818 (propertize (number-to-string gdb-memory-repeat-count)
37a65df00ab2 (gdb-memory-address)
Nick Roberts <nickrob@snap.net.nz>
parents: 59766
diff changeset
1819 'face font-lock-warning-face
37a65df00ab2 (gdb-memory-address)
Nick Roberts <nickrob@snap.net.nz>
parents: 59766
diff changeset
1820 'help-echo (purecopy "mouse-1: Set repeat count")
37a65df00ab2 (gdb-memory-address)
Nick Roberts <nickrob@snap.net.nz>
parents: 59766
diff changeset
1821 'local-map (purecopy (gdb-make-header-line-mouse-map
37a65df00ab2 (gdb-memory-address)
Nick Roberts <nickrob@snap.net.nz>
parents: 59766
diff changeset
1822 'mouse-1
37a65df00ab2 (gdb-memory-address)
Nick Roberts <nickrob@snap.net.nz>
parents: 59766
diff changeset
1823 #'gdb-memory-set-repeat-count)))
37a65df00ab2 (gdb-memory-address)
Nick Roberts <nickrob@snap.net.nz>
parents: 59766
diff changeset
1824 " Display Format: "
37a65df00ab2 (gdb-memory-address)
Nick Roberts <nickrob@snap.net.nz>
parents: 59766
diff changeset
1825 (propertize gdb-memory-format
37a65df00ab2 (gdb-memory-address)
Nick Roberts <nickrob@snap.net.nz>
parents: 59766
diff changeset
1826 'face font-lock-warning-face
37a65df00ab2 (gdb-memory-address)
Nick Roberts <nickrob@snap.net.nz>
parents: 59766
diff changeset
1827 'help-echo (purecopy "mouse-3: Select display format")
37a65df00ab2 (gdb-memory-address)
Nick Roberts <nickrob@snap.net.nz>
parents: 59766
diff changeset
1828 'local-map gdb-memory-format-keymap)
37a65df00ab2 (gdb-memory-address)
Nick Roberts <nickrob@snap.net.nz>
parents: 59766
diff changeset
1829 " Unit Size: "
37a65df00ab2 (gdb-memory-address)
Nick Roberts <nickrob@snap.net.nz>
parents: 59766
diff changeset
1830 (propertize gdb-memory-unit
37a65df00ab2 (gdb-memory-address)
Nick Roberts <nickrob@snap.net.nz>
parents: 59766
diff changeset
1831 'face font-lock-warning-face
37a65df00ab2 (gdb-memory-address)
Nick Roberts <nickrob@snap.net.nz>
parents: 59766
diff changeset
1832 'help-echo (purecopy "mouse-3: Select unit size")
37a65df00ab2 (gdb-memory-address)
Nick Roberts <nickrob@snap.net.nz>
parents: 59766
diff changeset
1833 'local-map gdb-memory-unit-keymap))))
37a65df00ab2 (gdb-memory-address)
Nick Roberts <nickrob@snap.net.nz>
parents: 59766
diff changeset
1834 (run-mode-hooks 'gdb-memory-mode-hook)
37a65df00ab2 (gdb-memory-address)
Nick Roberts <nickrob@snap.net.nz>
parents: 59766
diff changeset
1835 'gdb-invalidate-memory)
37a65df00ab2 (gdb-memory-address)
Nick Roberts <nickrob@snap.net.nz>
parents: 59766
diff changeset
1836
37a65df00ab2 (gdb-memory-address)
Nick Roberts <nickrob@snap.net.nz>
parents: 59766
diff changeset
1837 (defun gdb-memory-buffer-name ()
37a65df00ab2 (gdb-memory-address)
Nick Roberts <nickrob@snap.net.nz>
parents: 59766
diff changeset
1838 (with-current-buffer gud-comint-buffer
37a65df00ab2 (gdb-memory-address)
Nick Roberts <nickrob@snap.net.nz>
parents: 59766
diff changeset
1839 (concat "*memory of " (gdb-get-target-string) "*")))
37a65df00ab2 (gdb-memory-address)
Nick Roberts <nickrob@snap.net.nz>
parents: 59766
diff changeset
1840
37a65df00ab2 (gdb-memory-address)
Nick Roberts <nickrob@snap.net.nz>
parents: 59766
diff changeset
1841 (defun gdb-display-memory-buffer ()
37a65df00ab2 (gdb-memory-address)
Nick Roberts <nickrob@snap.net.nz>
parents: 59766
diff changeset
1842 "Display memory contents."
37a65df00ab2 (gdb-memory-address)
Nick Roberts <nickrob@snap.net.nz>
parents: 59766
diff changeset
1843 (interactive)
37a65df00ab2 (gdb-memory-address)
Nick Roberts <nickrob@snap.net.nz>
parents: 59766
diff changeset
1844 (gdb-display-buffer
37a65df00ab2 (gdb-memory-address)
Nick Roberts <nickrob@snap.net.nz>
parents: 59766
diff changeset
1845 (gdb-get-create-buffer 'gdb-memory-buffer)))
37a65df00ab2 (gdb-memory-address)
Nick Roberts <nickrob@snap.net.nz>
parents: 59766
diff changeset
1846
37a65df00ab2 (gdb-memory-address)
Nick Roberts <nickrob@snap.net.nz>
parents: 59766
diff changeset
1847 (defun gdb-frame-memory-buffer ()
37a65df00ab2 (gdb-memory-address)
Nick Roberts <nickrob@snap.net.nz>
parents: 59766
diff changeset
1848 "Display memory contents in a new frame."
37a65df00ab2 (gdb-memory-address)
Nick Roberts <nickrob@snap.net.nz>
parents: 59766
diff changeset
1849 (interactive)
37a65df00ab2 (gdb-memory-address)
Nick Roberts <nickrob@snap.net.nz>
parents: 59766
diff changeset
1850 (let ((special-display-regexps (append special-display-regexps '(".*")))
37a65df00ab2 (gdb-memory-address)
Nick Roberts <nickrob@snap.net.nz>
parents: 59766
diff changeset
1851 (special-display-frame-alist gdb-frame-parameters))
37a65df00ab2 (gdb-memory-address)
Nick Roberts <nickrob@snap.net.nz>
parents: 59766
diff changeset
1852 (display-buffer (gdb-get-create-buffer 'gdb-memory-buffer))))
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1853
59808
37a65df00ab2 (gdb-memory-address)
Nick Roberts <nickrob@snap.net.nz>
parents: 59766
diff changeset
1854
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1855 ;; Locals buffer.
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1856 ;;
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1857 (gdb-set-buffer-rules 'gdb-locals-buffer
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1858 'gdb-locals-buffer-name
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1859 'gdb-locals-mode)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1860
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1861 (def-gdb-auto-updated-buffer gdb-locals-buffer
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1862 gdb-invalidate-locals
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1863 "server info locals\n"
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1864 gdb-info-locals-handler
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1865 gdb-info-locals-custom)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1866
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1867 ;; Abbreviate for arrays and structures.
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1868 ;; These can be expanded using gud-display.
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1869 (defun gdb-info-locals-handler nil
55749
230865f1c59d (gdb-server-prefix): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 55696
diff changeset
1870 (setq gdb-pending-triggers (delq 'gdb-invalidate-locals
230865f1c59d (gdb-server-prefix): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 55696
diff changeset
1871 gdb-pending-triggers))
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1872 (let ((buf (gdb-get-buffer 'gdb-partial-output-buffer)))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1873 (with-current-buffer buf
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1874 (goto-char (point-min))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1875 (while (re-search-forward "^ .*\n" nil t)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1876 (replace-match "" nil nil))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1877 (goto-char (point-min))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1878 (while (re-search-forward "{[-0-9, {}\]*\n" nil t)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1879 (replace-match "(array);\n" nil nil))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1880 (goto-char (point-min))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1881 (while (re-search-forward "{.*=.*\n" nil t)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1882 (replace-match "(structure);\n" nil nil))))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1883 (let ((buf (gdb-get-buffer 'gdb-locals-buffer)))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1884 (and buf (with-current-buffer buf
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1885 (let ((p (point))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1886 (buffer-read-only nil))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1887 (delete-region (point-min) (point-max))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1888 (insert-buffer-substring (gdb-get-create-buffer
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1889 'gdb-partial-output-buffer))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1890 (goto-char p)))))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1891 (run-hooks 'gdb-info-locals-hook))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1892
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1893 (defun gdb-info-locals-custom ()
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1894 nil)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1895
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1896 (defvar gdb-locals-mode-map
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1897 (let ((map (make-sparse-keymap)))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1898 (suppress-keymap map)
58485
31d7630f91d4 (gdb-breakpoints-mode-map)
Nick Roberts <nickrob@snap.net.nz>
parents: 58470
diff changeset
1899 (define-key map "q" 'kill-this-buffer)
31d7630f91d4 (gdb-breakpoints-mode-map)
Nick Roberts <nickrob@snap.net.nz>
parents: 58470
diff changeset
1900 map))
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1901
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1902 (defun gdb-locals-mode ()
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1903 "Major mode for gdb locals.
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1904
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1905 \\{gdb-locals-mode-map}"
57661
b59713cd72a2 (gdb-get-create-buffer): Allow modes to run
Nick Roberts <nickrob@snap.net.nz>
parents: 57350
diff changeset
1906 (kill-all-local-variables)
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1907 (setq major-mode 'gdb-locals-mode)
55850
63ca25eb73a1 (gdb-current-frame, gud-watch)
Nick Roberts <nickrob@snap.net.nz>
parents: 55764
diff changeset
1908 (setq mode-name (concat "Locals:" gdb-current-frame))
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1909 (setq buffer-read-only t)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1910 (use-local-map gdb-locals-mode-map)
57661
b59713cd72a2 (gdb-get-create-buffer): Allow modes to run
Nick Roberts <nickrob@snap.net.nz>
parents: 57350
diff changeset
1911 (run-mode-hooks 'gdb-locals-mode-hook)
55762
e31413b06034 (gdb-breakpoints-mode, gdb-frames-mode)
Nick Roberts <nickrob@snap.net.nz>
parents: 55749
diff changeset
1912 (if (with-current-buffer gud-comint-buffer (eq gud-minor-mode 'gdba))
57661
b59713cd72a2 (gdb-get-create-buffer): Allow modes to run
Nick Roberts <nickrob@snap.net.nz>
parents: 57350
diff changeset
1913 'gdb-invalidate-locals
b59713cd72a2 (gdb-get-create-buffer): Allow modes to run
Nick Roberts <nickrob@snap.net.nz>
parents: 57350
diff changeset
1914 'gdbmi-invalidate-locals))
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1915
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1916 (defun gdb-locals-buffer-name ()
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1917 (with-current-buffer gud-comint-buffer
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1918 (concat "*locals of " (gdb-get-target-string) "*")))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1919
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1920 (defun gdb-display-locals-buffer ()
55400
1aaa031e318c Improve/extend documentation strings.
Nick Roberts <nickrob@snap.net.nz>
parents: 55330
diff changeset
1921 "Display local variables of current stack and their values."
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1922 (interactive)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1923 (gdb-display-buffer
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1924 (gdb-get-create-buffer 'gdb-locals-buffer)))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1925
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1926 (defun gdb-frame-locals-buffer ()
55400
1aaa031e318c Improve/extend documentation strings.
Nick Roberts <nickrob@snap.net.nz>
parents: 55330
diff changeset
1927 "Display local variables of current stack and their values in a new frame."
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1928 (interactive)
58521
54bb21951d18 (gdb-frame-parameters): Match height and
Nick Roberts <nickrob@snap.net.nz>
parents: 58485
diff changeset
1929 (let ((special-display-regexps (append special-display-regexps '(".*")))
54bb21951d18 (gdb-frame-parameters): Match height and
Nick Roberts <nickrob@snap.net.nz>
parents: 58485
diff changeset
1930 (special-display-frame-alist gdb-frame-parameters))
54bb21951d18 (gdb-frame-parameters): Match height and
Nick Roberts <nickrob@snap.net.nz>
parents: 58485
diff changeset
1931 (display-buffer (gdb-get-create-buffer 'gdb-locals-buffer))))
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1932
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1933
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1934 ;;;; Window management
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1935 (defun gdb-display-buffer (buf &optional size)
58485
31d7630f91d4 (gdb-breakpoints-mode-map)
Nick Roberts <nickrob@snap.net.nz>
parents: 58470
diff changeset
1936 (let ((answer (get-buffer-window buf 0))
31d7630f91d4 (gdb-breakpoints-mode-map)
Nick Roberts <nickrob@snap.net.nz>
parents: 58470
diff changeset
1937 (must-split nil))
31d7630f91d4 (gdb-breakpoints-mode-map)
Nick Roberts <nickrob@snap.net.nz>
parents: 58470
diff changeset
1938 (if answer
58534
c655bc81dfc0 (gdb-view-source, gdb-selected-view):
Nick Roberts <nickrob@snap.net.nz>
parents: 58521
diff changeset
1939 (display-buffer buf) ;Raise the frame if necessary.
58485
31d7630f91d4 (gdb-breakpoints-mode-map)
Nick Roberts <nickrob@snap.net.nz>
parents: 58470
diff changeset
1940 ;; The buffer is not yet displayed.
31d7630f91d4 (gdb-breakpoints-mode-map)
Nick Roberts <nickrob@snap.net.nz>
parents: 58470
diff changeset
1941 (pop-to-buffer gud-comint-buffer) ;Select the right frame.
58534
c655bc81dfc0 (gdb-view-source, gdb-selected-view):
Nick Roberts <nickrob@snap.net.nz>
parents: 58521
diff changeset
1942 (let ((window (get-lru-window)))
c655bc81dfc0 (gdb-view-source, gdb-selected-view):
Nick Roberts <nickrob@snap.net.nz>
parents: 58521
diff changeset
1943 (if window
c655bc81dfc0 (gdb-view-source, gdb-selected-view):
Nick Roberts <nickrob@snap.net.nz>
parents: 58521
diff changeset
1944 (progn
c655bc81dfc0 (gdb-view-source, gdb-selected-view):
Nick Roberts <nickrob@snap.net.nz>
parents: 58521
diff changeset
1945 (set-window-buffer window buf)
c655bc81dfc0 (gdb-view-source, gdb-selected-view):
Nick Roberts <nickrob@snap.net.nz>
parents: 58521
diff changeset
1946 (setq answer window))
58485
31d7630f91d4 (gdb-breakpoints-mode-map)
Nick Roberts <nickrob@snap.net.nz>
parents: 58470
diff changeset
1947 (setq must-split t)))
58534
c655bc81dfc0 (gdb-view-source, gdb-selected-view):
Nick Roberts <nickrob@snap.net.nz>
parents: 58521
diff changeset
1948 (if must-split
c655bc81dfc0 (gdb-view-source, gdb-selected-view):
Nick Roberts <nickrob@snap.net.nz>
parents: 58521
diff changeset
1949 (let* ((largest (get-largest-window))
c655bc81dfc0 (gdb-view-source, gdb-selected-view):
Nick Roberts <nickrob@snap.net.nz>
parents: 58521
diff changeset
1950 (cur-size (window-height largest))
c655bc81dfc0 (gdb-view-source, gdb-selected-view):
Nick Roberts <nickrob@snap.net.nz>
parents: 58521
diff changeset
1951 (new-size (and size (< size cur-size) (- cur-size size))))
c655bc81dfc0 (gdb-view-source, gdb-selected-view):
Nick Roberts <nickrob@snap.net.nz>
parents: 58521
diff changeset
1952 (setq answer (split-window largest new-size))
c655bc81dfc0 (gdb-view-source, gdb-selected-view):
Nick Roberts <nickrob@snap.net.nz>
parents: 58521
diff changeset
1953 (set-window-buffer answer buf)
c655bc81dfc0 (gdb-view-source, gdb-selected-view):
Nick Roberts <nickrob@snap.net.nz>
parents: 58521
diff changeset
1954 (set-window-dedicated-p answer t)))
58485
31d7630f91d4 (gdb-breakpoints-mode-map)
Nick Roberts <nickrob@snap.net.nz>
parents: 58470
diff changeset
1955 answer)))
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1956
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1957
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1958 ;;; Shared keymap initialization:
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1959
59922
79e9767b47c8 Update copyright. Put GDB-Frames before
Nick Roberts <nickrob@snap.net.nz>
parents: 59852
diff changeset
1960 (let ((menu (make-sparse-keymap "GDB-Windows")))
79e9767b47c8 Update copyright. Put GDB-Frames before
Nick Roberts <nickrob@snap.net.nz>
parents: 59852
diff changeset
1961 (define-key gud-menu-map [displays]
79e9767b47c8 Update copyright. Put GDB-Frames before
Nick Roberts <nickrob@snap.net.nz>
parents: 59852
diff changeset
1962 `(menu-item "GDB-Windows" ,menu :visible (eq gud-minor-mode 'gdba)))
79e9767b47c8 Update copyright. Put GDB-Frames before
Nick Roberts <nickrob@snap.net.nz>
parents: 59852
diff changeset
1963 (define-key menu [gdb] '("Gdb" . gdb-display-gdb-buffer))
79e9767b47c8 Update copyright. Put GDB-Frames before
Nick Roberts <nickrob@snap.net.nz>
parents: 59852
diff changeset
1964 (define-key menu [threads] '("Threads" . gdb-display-threads-buffer))
79e9767b47c8 Update copyright. Put GDB-Frames before
Nick Roberts <nickrob@snap.net.nz>
parents: 59852
diff changeset
1965 (define-key menu [memory] '("Memory" . gdb-display-memory-buffer))
79e9767b47c8 Update copyright. Put GDB-Frames before
Nick Roberts <nickrob@snap.net.nz>
parents: 59852
diff changeset
1966 (define-key menu [assembler] '("Machine" . gdb-display-assembler-buffer))
79e9767b47c8 Update copyright. Put GDB-Frames before
Nick Roberts <nickrob@snap.net.nz>
parents: 59852
diff changeset
1967 (define-key menu [registers] '("Registers" . gdb-display-registers-buffer))
79e9767b47c8 Update copyright. Put GDB-Frames before
Nick Roberts <nickrob@snap.net.nz>
parents: 59852
diff changeset
1968 (define-key menu [locals] '("Locals" . gdb-display-locals-buffer))
79e9767b47c8 Update copyright. Put GDB-Frames before
Nick Roberts <nickrob@snap.net.nz>
parents: 59852
diff changeset
1969 (define-key menu [frames] '("Stack" . gdb-display-stack-buffer))
79e9767b47c8 Update copyright. Put GDB-Frames before
Nick Roberts <nickrob@snap.net.nz>
parents: 59852
diff changeset
1970 (define-key menu [breakpoints] '("Breakpoints" . gdb-display-breakpoints-buffer)))
79e9767b47c8 Update copyright. Put GDB-Frames before
Nick Roberts <nickrob@snap.net.nz>
parents: 59852
diff changeset
1971
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1972 (let ((menu (make-sparse-keymap "GDB-Frames")))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1973 (define-key gud-menu-map [frames]
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1974 `(menu-item "GDB-Frames" ,menu :visible (eq gud-minor-mode 'gdba)))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1975 (define-key menu [gdb] '("Gdb" . gdb-frame-gdb-buffer))
55328
4440fe0e7dc6 (gud-watch, gdb-display-buffer)
Nick Roberts <nickrob@snap.net.nz>
parents: 55217
diff changeset
1976 (define-key menu [threads] '("Threads" . gdb-frame-threads-buffer))
59808
37a65df00ab2 (gdb-memory-address)
Nick Roberts <nickrob@snap.net.nz>
parents: 59766
diff changeset
1977 (define-key menu [memory] '("Memory" . gdb-frame-memory-buffer))
55749
230865f1c59d (gdb-server-prefix): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 55696
diff changeset
1978 (define-key menu [assembler] '("Machine" . gdb-frame-assembler-buffer))
55328
4440fe0e7dc6 (gud-watch, gdb-display-buffer)
Nick Roberts <nickrob@snap.net.nz>
parents: 55217
diff changeset
1979 (define-key menu [registers] '("Registers" . gdb-frame-registers-buffer))
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1980 (define-key menu [locals] '("Locals" . gdb-frame-locals-buffer))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1981 (define-key menu [frames] '("Stack" . gdb-frame-stack-buffer))
55749
230865f1c59d (gdb-server-prefix): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 55696
diff changeset
1982 (define-key menu [breakpoints] '("Breakpoints" . gdb-frame-breakpoints-buffer)))
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1983
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1984 (let ((menu (make-sparse-keymap "GDB-UI")))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1985 (define-key gud-menu-map [ui]
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1986 `(menu-item "GDB-UI" ,menu :visible (eq gud-minor-mode 'gdba)))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1987 (define-key menu [gdb-restore-windows]
59922
79e9767b47c8 Update copyright. Put GDB-Frames before
Nick Roberts <nickrob@snap.net.nz>
parents: 59852
diff changeset
1988 '("Restore Window Layout" . gdb-restore-windows))
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1989 (define-key menu [gdb-many-windows]
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1990 (menu-bar-make-toggle gdb-many-windows gdb-many-windows
59922
79e9767b47c8 Update copyright. Put GDB-Frames before
Nick Roberts <nickrob@snap.net.nz>
parents: 59852
diff changeset
1991 "Display Other Windows" "Many windows %s"
79e9767b47c8 Update copyright. Put GDB-Frames before
Nick Roberts <nickrob@snap.net.nz>
parents: 59852
diff changeset
1992 "Toggle display of locals, stack and breakpoint information")))
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1993
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1994 (defun gdb-frame-gdb-buffer ()
55400
1aaa031e318c Improve/extend documentation strings.
Nick Roberts <nickrob@snap.net.nz>
parents: 55330
diff changeset
1995 "Display GUD buffer in a new frame."
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1996 (interactive)
54993
08b0ee9a9b35 (gdb-frame-parameters): New constant.
Nick Roberts <nickrob@snap.net.nz>
parents: 54962
diff changeset
1997 (select-frame (make-frame gdb-frame-parameters))
08b0ee9a9b35 (gdb-frame-parameters): New constant.
Nick Roberts <nickrob@snap.net.nz>
parents: 54962
diff changeset
1998 (switch-to-buffer (gdb-get-create-buffer 'gdba))
55217
97d0e3a1174f (gdb-frame-breakpoints-buffer)
Nick Roberts <nickrob@snap.net.nz>
parents: 54993
diff changeset
1999 (set-window-dedicated-p (selected-window) t))
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2000
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2001 (defun gdb-display-gdb-buffer ()
55400
1aaa031e318c Improve/extend documentation strings.
Nick Roberts <nickrob@snap.net.nz>
parents: 55330
diff changeset
2002 "Display GUD buffer."
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2003 (interactive)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2004 (gdb-display-buffer
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2005 (gdb-get-create-buffer 'gdba)))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2006
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2007 (defvar gdb-main-file nil "Source file from which program execution begins.")
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2008
54668
69a699e79a0d (gdb-view-source-function, gdb-view-assembler)
Nick Roberts <nickrob@snap.net.nz>
parents: 54617
diff changeset
2009 (defcustom gdb-show-main nil
69a699e79a0d (gdb-view-source-function, gdb-view-assembler)
Nick Roberts <nickrob@snap.net.nz>
parents: 54617
diff changeset
2010 "Nil means don't display source file containing the main routine."
69a699e79a0d (gdb-view-source-function, gdb-view-assembler)
Nick Roberts <nickrob@snap.net.nz>
parents: 54617
diff changeset
2011 :type 'boolean
57851
67b88e92a24d (gdb-enable-debug-log)
Nick Roberts <nickrob@snap.net.nz>
parents: 57791
diff changeset
2012 :group 'gud
59996
aac0a33f5772 Change release version from 21.4 to 22.1 throughout.
Kim F. Storm <storm@cua.dk>
parents: 59988
diff changeset
2013 :version "22.1")
54668
69a699e79a0d (gdb-view-source-function, gdb-view-assembler)
Nick Roberts <nickrob@snap.net.nz>
parents: 54617
diff changeset
2014
58485
31d7630f91d4 (gdb-breakpoints-mode-map)
Nick Roberts <nickrob@snap.net.nz>
parents: 58470
diff changeset
2015 (defun gdb-set-window-buffer (name)
31d7630f91d4 (gdb-breakpoints-mode-map)
Nick Roberts <nickrob@snap.net.nz>
parents: 58470
diff changeset
2016 (set-window-buffer (selected-window) (get-buffer name))
31d7630f91d4 (gdb-breakpoints-mode-map)
Nick Roberts <nickrob@snap.net.nz>
parents: 58470
diff changeset
2017 (set-window-dedicated-p (selected-window) t))
58470
7858de1f2bdf (dedicated-switch-to-buffer): New function.
Nick Roberts <nickrob@snap.net.nz>
parents: 58431
diff changeset
2018
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2019 (defun gdb-setup-windows ()
54668
69a699e79a0d (gdb-view-source-function, gdb-view-assembler)
Nick Roberts <nickrob@snap.net.nz>
parents: 54617
diff changeset
2020 "Layout the window pattern for gdb-many-windows."
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2021 (gdb-display-locals-buffer)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2022 (gdb-display-stack-buffer)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2023 (delete-other-windows)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2024 (gdb-display-breakpoints-buffer)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2025 (delete-other-windows)
58534
c655bc81dfc0 (gdb-view-source, gdb-selected-view):
Nick Roberts <nickrob@snap.net.nz>
parents: 58521
diff changeset
2026 ; Don't dedicate.
c655bc81dfc0 (gdb-view-source, gdb-selected-view):
Nick Roberts <nickrob@snap.net.nz>
parents: 58521
diff changeset
2027 (pop-to-buffer gud-comint-buffer)
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2028 (split-window nil ( / ( * (window-height) 3) 4))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2029 (split-window nil ( / (window-height) 3))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2030 (split-window-horizontally)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2031 (other-window 1)
58485
31d7630f91d4 (gdb-breakpoints-mode-map)
Nick Roberts <nickrob@snap.net.nz>
parents: 58470
diff changeset
2032 (gdb-set-window-buffer (gdb-locals-buffer-name))
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2033 (other-window 1)
58534
c655bc81dfc0 (gdb-view-source, gdb-selected-view):
Nick Roberts <nickrob@snap.net.nz>
parents: 58521
diff changeset
2034 (switch-to-buffer
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2035 (if gud-last-last-frame
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2036 (gud-find-file (car gud-last-last-frame))
58534
c655bc81dfc0 (gdb-view-source, gdb-selected-view):
Nick Roberts <nickrob@snap.net.nz>
parents: 58521
diff changeset
2037 (gud-find-file gdb-main-file)))
54729
7bfccd78beed (gdb-use-inferior-io-buffer): New option.
Nick Roberts <nickrob@snap.net.nz>
parents: 54668
diff changeset
2038 (when gdb-use-inferior-io-buffer
7bfccd78beed (gdb-use-inferior-io-buffer): New option.
Nick Roberts <nickrob@snap.net.nz>
parents: 54668
diff changeset
2039 (split-window-horizontally)
7bfccd78beed (gdb-use-inferior-io-buffer): New option.
Nick Roberts <nickrob@snap.net.nz>
parents: 54668
diff changeset
2040 (other-window 1)
58485
31d7630f91d4 (gdb-breakpoints-mode-map)
Nick Roberts <nickrob@snap.net.nz>
parents: 58470
diff changeset
2041 (gdb-set-window-buffer (gdb-inferior-io-name)))
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2042 (other-window 1)
58485
31d7630f91d4 (gdb-breakpoints-mode-map)
Nick Roberts <nickrob@snap.net.nz>
parents: 58470
diff changeset
2043 (gdb-set-window-buffer (gdb-stack-buffer-name))
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2044 (split-window-horizontally)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2045 (other-window 1)
58485
31d7630f91d4 (gdb-breakpoints-mode-map)
Nick Roberts <nickrob@snap.net.nz>
parents: 58470
diff changeset
2046 (gdb-set-window-buffer (gdb-breakpoints-buffer-name))
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2047 (other-window 1))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2048
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2049 (defcustom gdb-many-windows nil
57791
d1b93fc4ce47 Docstring fixes.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57664
diff changeset
2050 "Nil means just pop up the GUD buffer unless `gdb-show-main' is t.
d1b93fc4ce47 Docstring fixes.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57664
diff changeset
2051 In this case it starts with two windows: one displaying the GUD
d1b93fc4ce47 Docstring fixes.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57664
diff changeset
2052 buffer and the other with the source file with the main routine
d1b93fc4ce47 Docstring fixes.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57664
diff changeset
2053 of the inferior. Non-nil means display the layout shown for
d1b93fc4ce47 Docstring fixes.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57664
diff changeset
2054 `gdba'."
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2055 :type 'boolean
57851
67b88e92a24d (gdb-enable-debug-log)
Nick Roberts <nickrob@snap.net.nz>
parents: 57791
diff changeset
2056 :group 'gud
59996
aac0a33f5772 Change release version from 21.4 to 22.1 throughout.
Kim F. Storm <storm@cua.dk>
parents: 59988
diff changeset
2057 :version "22.1")
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2058
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2059 (defun gdb-many-windows (arg)
59617
4988bdf5db77 (gdb-put-string): Copy/create strings so
Nick Roberts <nickrob@snap.net.nz>
parents: 58534
diff changeset
2060 "Toggle the number of windows in the basic arrangement."
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2061 (interactive "P")
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2062 (setq gdb-many-windows
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2063 (if (null arg)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2064 (not gdb-many-windows)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2065 (> (prefix-numeric-value arg) 0)))
54760
c6ccb7a82f9f (gdb-source-window): Remove variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 54729
diff changeset
2066 (condition-case nil
c6ccb7a82f9f (gdb-source-window): Remove variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 54729
diff changeset
2067 (gdb-restore-windows)
c6ccb7a82f9f (gdb-source-window): Remove variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 54729
diff changeset
2068 (error nil)))
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2069
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2070 (defun gdb-restore-windows ()
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2071 "Restore the basic arrangement of windows used by gdba.
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2072 This arrangement depends on the value of `gdb-many-windows'."
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2073 (interactive)
58485
31d7630f91d4 (gdb-breakpoints-mode-map)
Nick Roberts <nickrob@snap.net.nz>
parents: 58470
diff changeset
2074 (pop-to-buffer gud-comint-buffer) ;Select the right window and frame.
31d7630f91d4 (gdb-breakpoints-mode-map)
Nick Roberts <nickrob@snap.net.nz>
parents: 58470
diff changeset
2075 (delete-other-windows)
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2076 (if gdb-many-windows
58485
31d7630f91d4 (gdb-breakpoints-mode-map)
Nick Roberts <nickrob@snap.net.nz>
parents: 58470
diff changeset
2077 (gdb-setup-windows)
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2078 (split-window)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2079 (other-window 1)
58534
c655bc81dfc0 (gdb-view-source, gdb-selected-view):
Nick Roberts <nickrob@snap.net.nz>
parents: 58521
diff changeset
2080 (switch-to-buffer
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2081 (if gud-last-last-frame
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2082 (gud-find-file (car gud-last-last-frame))
58534
c655bc81dfc0 (gdb-view-source, gdb-selected-view):
Nick Roberts <nickrob@snap.net.nz>
parents: 58521
diff changeset
2083 (gud-find-file gdb-main-file)))
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2084 (other-window 1)))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2085
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2086 (defun gdb-reset ()
57791
d1b93fc4ce47 Docstring fixes.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57664
diff changeset
2087 "Exit a debugging session cleanly.
d1b93fc4ce47 Docstring fixes.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57664
diff changeset
2088 Kills the gdb buffers and resets the source buffers."
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2089 (dolist (buffer (buffer-list))
55696
ed6e91c53c82 (gdb-reset): Use unless. Fix regexp.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55507
diff changeset
2090 (unless (eq buffer gud-comint-buffer)
ed6e91c53c82 (gdb-reset): Use unless. Fix regexp.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55507
diff changeset
2091 (with-current-buffer buffer
55749
230865f1c59d (gdb-server-prefix): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 55696
diff changeset
2092 (if (memq gud-minor-mode '(gdbmi gdba))
55696
ed6e91c53c82 (gdb-reset): Use unless. Fix regexp.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55507
diff changeset
2093 (if (string-match "\\`\\*.+\\*\\'" (buffer-name))
ed6e91c53c82 (gdb-reset): Use unless. Fix regexp.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55507
diff changeset
2094 (kill-buffer nil)
ed6e91c53c82 (gdb-reset): Use unless. Fix regexp.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55507
diff changeset
2095 (gdb-remove-breakpoint-icons (point-min) (point-max) t)
ed6e91c53c82 (gdb-reset): Use unless. Fix regexp.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55507
diff changeset
2096 (setq gud-minor-mode nil)
ed6e91c53c82 (gdb-reset): Use unless. Fix regexp.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55507
diff changeset
2097 (kill-local-variable 'tool-bar-map)
ed6e91c53c82 (gdb-reset): Use unless. Fix regexp.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55507
diff changeset
2098 (setq gud-running nil))))))
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2099 (when (markerp gdb-overlay-arrow-position)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2100 (move-marker gdb-overlay-arrow-position nil)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2101 (setq gdb-overlay-arrow-position nil))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2102 (setq overlay-arrow-variable-list
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2103 (delq 'gdb-overlay-arrow-position overlay-arrow-variable-list)))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2104
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2105 (defun gdb-source-info ()
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2106 "Find the source file where the program starts and displays it with related
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2107 buffers."
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2108 (goto-char (point-min))
60073
6fba1da8f37e (gdb-find-file-unhook): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 59998
diff changeset
2109 (if (and (search-forward "Located in " nil t)
6fba1da8f37e (gdb-find-file-unhook): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 59998
diff changeset
2110 (looking-at "\\S-*"))
6fba1da8f37e (gdb-find-file-unhook): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 59998
diff changeset
2111 (setq gdb-main-file (match-string 0)))
58534
c655bc81dfc0 (gdb-view-source, gdb-selected-view):
Nick Roberts <nickrob@snap.net.nz>
parents: 58521
diff changeset
2112 (if gdb-many-windows
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2113 (gdb-setup-windows)
59988
fb52ec059049 (gdb-location-list): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 59922
diff changeset
2114 (gdb-get-create-buffer 'gdb-breakpoints-buffer)
60073
6fba1da8f37e (gdb-find-file-unhook): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 59998
diff changeset
2115 (if gdb-show-main
6fba1da8f37e (gdb-find-file-unhook): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 59998
diff changeset
2116 (let ((pop-up-windows t))
6fba1da8f37e (gdb-find-file-unhook): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 59998
diff changeset
2117 (display-buffer (gud-find-file gdb-main-file))))))
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2118
59988
fb52ec059049 (gdb-location-list): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 59922
diff changeset
2119 (defun gdb-get-location (bptno line flag)
fb52ec059049 (gdb-location-list): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 59922
diff changeset
2120 "Find the directory containing the relevant source file.
fb52ec059049 (gdb-location-list): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 59922
diff changeset
2121 Put in buffer and place breakpoint icon."
fb52ec059049 (gdb-location-list): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 59922
diff changeset
2122 (goto-char (point-min))
60326
47c96976e43d (gdb-get-location): Use a warning instead
Nick Roberts <nickrob@snap.net.nz>
parents: 60153
diff changeset
2123 (catch 'file-not-found
47c96976e43d (gdb-get-location): Use a warning instead
Nick Roberts <nickrob@snap.net.nz>
parents: 60153
diff changeset
2124 (if (search-forward "Located in " nil t)
47c96976e43d (gdb-get-location): Use a warning instead
Nick Roberts <nickrob@snap.net.nz>
parents: 60153
diff changeset
2125 (if (looking-at "\\S-*")
47c96976e43d (gdb-get-location): Use a warning instead
Nick Roberts <nickrob@snap.net.nz>
parents: 60153
diff changeset
2126 (push (cons bptno (match-string 0)) gdb-location-list))
47c96976e43d (gdb-get-location): Use a warning instead
Nick Roberts <nickrob@snap.net.nz>
parents: 60153
diff changeset
2127 (gdb-resync)
47c96976e43d (gdb-get-location): Use a warning instead
Nick Roberts <nickrob@snap.net.nz>
parents: 60153
diff changeset
2128 (push (cons bptno "File not found") gdb-location-list)
60541
fbf903562871 (gdb-var-create-handler, gdb-get-location):
Nick Roberts <nickrob@snap.net.nz>
parents: 60477
diff changeset
2129 (message-box "Cannot find source file for breakpoint location.\n\
fbf903562871 (gdb-var-create-handler, gdb-get-location):
Nick Roberts <nickrob@snap.net.nz>
parents: 60477
diff changeset
2130 Add directory to search path for source files using the GDB command, dir.")
60326
47c96976e43d (gdb-get-location): Use a warning instead
Nick Roberts <nickrob@snap.net.nz>
parents: 60153
diff changeset
2131 (throw 'file-not-found nil))
47c96976e43d (gdb-get-location): Use a warning instead
Nick Roberts <nickrob@snap.net.nz>
parents: 60153
diff changeset
2132 (with-current-buffer
47c96976e43d (gdb-get-location): Use a warning instead
Nick Roberts <nickrob@snap.net.nz>
parents: 60153
diff changeset
2133 (find-file-noselect (match-string 0))
47c96976e43d (gdb-get-location): Use a warning instead
Nick Roberts <nickrob@snap.net.nz>
parents: 60153
diff changeset
2134 (save-current-buffer
47c96976e43d (gdb-get-location): Use a warning instead
Nick Roberts <nickrob@snap.net.nz>
parents: 60153
diff changeset
2135 (set (make-local-variable 'gud-minor-mode) 'gdba)
47c96976e43d (gdb-get-location): Use a warning instead
Nick Roberts <nickrob@snap.net.nz>
parents: 60153
diff changeset
2136 (set (make-local-variable 'tool-bar-map) gud-tool-bar-map))
47c96976e43d (gdb-get-location): Use a warning instead
Nick Roberts <nickrob@snap.net.nz>
parents: 60153
diff changeset
2137 ;; only want one breakpoint icon at each location
47c96976e43d (gdb-get-location): Use a warning instead
Nick Roberts <nickrob@snap.net.nz>
parents: 60153
diff changeset
2138 (save-excursion
47c96976e43d (gdb-get-location): Use a warning instead
Nick Roberts <nickrob@snap.net.nz>
parents: 60153
diff changeset
2139 (goto-line (string-to-number line))
47c96976e43d (gdb-get-location): Use a warning instead
Nick Roberts <nickrob@snap.net.nz>
parents: 60153
diff changeset
2140 (gdb-put-breakpoint-icon (eq flag ?y) bptno)))))
59988
fb52ec059049 (gdb-location-list): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 59922
diff changeset
2141
60073
6fba1da8f37e (gdb-find-file-unhook): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 59998
diff changeset
2142 (add-hook 'find-file-hook 'gdb-find-file-hook)
6fba1da8f37e (gdb-find-file-unhook): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 59998
diff changeset
2143
6fba1da8f37e (gdb-find-file-unhook): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 59998
diff changeset
2144 (defun gdb-find-file-hook ()
6fba1da8f37e (gdb-find-file-unhook): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 59998
diff changeset
2145 (if (and (not gdb-find-file-unhook)
6fba1da8f37e (gdb-find-file-unhook): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 59998
diff changeset
2146 ;; in case gud or gdb-ui is just loaded
6fba1da8f37e (gdb-find-file-unhook): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 59998
diff changeset
2147 gud-comint-buffer
6fba1da8f37e (gdb-find-file-unhook): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 59998
diff changeset
2148 (buffer-name gud-comint-buffer)
6fba1da8f37e (gdb-find-file-unhook): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 59998
diff changeset
2149 (with-current-buffer gud-comint-buffer
6fba1da8f37e (gdb-find-file-unhook): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 59998
diff changeset
2150 (eq gud-minor-mode 'gdba)))
6fba1da8f37e (gdb-find-file-unhook): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 59998
diff changeset
2151 (condition-case nil
6fba1da8f37e (gdb-find-file-unhook): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 59998
diff changeset
2152 (gdb-enqueue-input
60124
106946a8423d (gdb-set-gud-minor-mode-existing-buffers)
Nick Roberts <nickrob@snap.net.nz>
parents: 60073
diff changeset
2153 (list (concat gdb-server-prefix "list "
106946a8423d (gdb-set-gud-minor-mode-existing-buffers)
Nick Roberts <nickrob@snap.net.nz>
parents: 60073
diff changeset
2154 (file-name-nondirectory buffer-file-name)
60073
6fba1da8f37e (gdb-find-file-unhook): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 59998
diff changeset
2155 ":1\n")
6fba1da8f37e (gdb-find-file-unhook): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 59998
diff changeset
2156 `(lambda () (gdb-set-gud-minor-mode ,(current-buffer)))))
6fba1da8f37e (gdb-find-file-unhook): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 59998
diff changeset
2157 (error (setq gdb-find-file-unhook t)))))
6fba1da8f37e (gdb-find-file-unhook): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 59998
diff changeset
2158
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2159 ;;from put-image
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2160 (defun gdb-put-string (putstring pos &optional dprop)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2161 "Put string PUTSTRING in front of POS in the current buffer.
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2162 PUTSTRING is displayed by putting an overlay into the current buffer with a
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2163 `before-string' STRING that has a `display' property whose value is
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2164 PUTSTRING."
59617
4988bdf5db77 (gdb-put-string): Copy/create strings so
Nick Roberts <nickrob@snap.net.nz>
parents: 58534
diff changeset
2165 (let ((string (make-string 1 ?x))
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2166 (buffer (current-buffer)))
59617
4988bdf5db77 (gdb-put-string): Copy/create strings so
Nick Roberts <nickrob@snap.net.nz>
parents: 58534
diff changeset
2167 (setq putstring (copy-sequence putstring))
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2168 (let ((overlay (make-overlay pos pos buffer))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2169 (prop (or dprop
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2170 (list (list 'margin 'left-margin) putstring))))
59617
4988bdf5db77 (gdb-put-string): Copy/create strings so
Nick Roberts <nickrob@snap.net.nz>
parents: 58534
diff changeset
2171 (put-text-property 0 (length string) 'display prop string)
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2172 (overlay-put overlay 'put-break t)
59617
4988bdf5db77 (gdb-put-string): Copy/create strings so
Nick Roberts <nickrob@snap.net.nz>
parents: 58534
diff changeset
2173 (overlay-put overlay 'before-string string))))
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2174
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2175 ;;from remove-images
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2176 (defun gdb-remove-strings (start end &optional buffer)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2177 "Remove strings between START and END in BUFFER.
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2178 Remove only strings that were put in BUFFER with calls to `gdb-put-string'.
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2179 BUFFER nil or omitted means use the current buffer."
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2180 (unless buffer
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2181 (setq buffer (current-buffer)))
59617
4988bdf5db77 (gdb-put-string): Copy/create strings so
Nick Roberts <nickrob@snap.net.nz>
parents: 58534
diff changeset
2182 (dolist (overlay (overlays-in start end))
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2183 (when (overlay-get overlay 'put-break)
59617
4988bdf5db77 (gdb-put-string): Copy/create strings so
Nick Roberts <nickrob@snap.net.nz>
parents: 58534
diff changeset
2184 (delete-overlay overlay))))
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2185
59617
4988bdf5db77 (gdb-put-string): Copy/create strings so
Nick Roberts <nickrob@snap.net.nz>
parents: 58534
diff changeset
2186 (defun gdb-put-breakpoint-icon (enabled bptno)
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2187 (let ((start (progn (beginning-of-line) (- (point) 1)))
59617
4988bdf5db77 (gdb-put-string): Copy/create strings so
Nick Roberts <nickrob@snap.net.nz>
parents: 58534
diff changeset
2188 (end (progn (end-of-line) (+ (point) 1)))
4988bdf5db77 (gdb-put-string): Copy/create strings so
Nick Roberts <nickrob@snap.net.nz>
parents: 58534
diff changeset
2189 (putstring (if enabled "B" "b")))
59635
4d7bfec0bb4a (gdb-put-breakpoint-icon): Add help-echo for
Nick Roberts <nickrob@snap.net.nz>
parents: 59617
diff changeset
2190 (add-text-properties
4d7bfec0bb4a (gdb-put-breakpoint-icon): Add help-echo for
Nick Roberts <nickrob@snap.net.nz>
parents: 59617
diff changeset
2191 0 1 '(help-echo "mouse-1: set/clear bkpt, mouse-3: enable/disable bkpt")
4d7bfec0bb4a (gdb-put-breakpoint-icon): Add help-echo for
Nick Roberts <nickrob@snap.net.nz>
parents: 59617
diff changeset
2192 putstring)
59617
4988bdf5db77 (gdb-put-string): Copy/create strings so
Nick Roberts <nickrob@snap.net.nz>
parents: 58534
diff changeset
2193 (if enabled (add-text-properties
4988bdf5db77 (gdb-put-string): Copy/create strings so
Nick Roberts <nickrob@snap.net.nz>
parents: 58534
diff changeset
2194 0 1 `(gdb-bptno ,bptno gdb-enabled t) putstring)
4988bdf5db77 (gdb-put-string): Copy/create strings so
Nick Roberts <nickrob@snap.net.nz>
parents: 58534
diff changeset
2195 (add-text-properties
4988bdf5db77 (gdb-put-string): Copy/create strings so
Nick Roberts <nickrob@snap.net.nz>
parents: 58534
diff changeset
2196 0 1 `(gdb-bptno ,bptno gdb-enabled nil) putstring))
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2197 (gdb-remove-breakpoint-icons start end)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2198 (if (display-images-p)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2199 (if (>= (car (window-fringes)) 8)
54668
69a699e79a0d (gdb-view-source-function, gdb-view-assembler)
Nick Roberts <nickrob@snap.net.nz>
parents: 54617
diff changeset
2200 (gdb-put-string
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2201 nil (1+ start)
57262
df4b0ff293d8 (breakpoint): Define as fringe bitmap.
Kim F. Storm <storm@cua.dk>
parents: 56330
diff changeset
2202 `(left-fringe breakpoint
59617
4988bdf5db77 (gdb-put-string): Copy/create strings so
Nick Roberts <nickrob@snap.net.nz>
parents: 58534
diff changeset
2203 ,(if enabled
60760
a706fe4203bc Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-193
Miles Bader <miles@gnu.org>
parents: 60541
diff changeset
2204 'breakpoint-enabled
a706fe4203bc Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-193
Miles Bader <miles@gnu.org>
parents: 60541
diff changeset
2205 'breakpoint-disabled)))
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2206 (when (< left-margin-width 2)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2207 (save-current-buffer
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2208 (setq left-margin-width 2)
58534
c655bc81dfc0 (gdb-view-source, gdb-selected-view):
Nick Roberts <nickrob@snap.net.nz>
parents: 58521
diff changeset
2209 (if (get-buffer-window (current-buffer) 0)
56285
313e3a9f34ca (breakpoint-enabled-bitmap-face)
Kim F. Storm <storm@cua.dk>
parents: 56258
diff changeset
2210 (set-window-margins
58534
c655bc81dfc0 (gdb-view-source, gdb-selected-view):
Nick Roberts <nickrob@snap.net.nz>
parents: 58521
diff changeset
2211 (get-buffer-window (current-buffer) 0)
55328
4440fe0e7dc6 (gud-watch, gdb-display-buffer)
Nick Roberts <nickrob@snap.net.nz>
parents: 55217
diff changeset
2212 left-margin-width right-margin-width))))
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2213 (put-image
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2214 (if enabled
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2215 (or breakpoint-enabled-icon
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2216 (setq breakpoint-enabled-icon
54668
69a699e79a0d (gdb-view-source-function, gdb-view-assembler)
Nick Roberts <nickrob@snap.net.nz>
parents: 54617
diff changeset
2217 (find-image `((:type xpm :data
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2218 ,breakpoint-xpm-data
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2219 :ascent 100 :pointer hand)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2220 (:type pbm :data
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2221 ,breakpoint-enabled-pbm-data
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2222 :ascent 100 :pointer hand)))))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2223 (or breakpoint-disabled-icon
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2224 (setq breakpoint-disabled-icon
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2225 (find-image `((:type xpm :data
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2226 ,breakpoint-xpm-data
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2227 :conversion disabled
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2228 :ascent 100)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2229 (:type pbm :data
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2230 ,breakpoint-disabled-pbm-data
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2231 :ascent 100))))))
59617
4988bdf5db77 (gdb-put-string): Copy/create strings so
Nick Roberts <nickrob@snap.net.nz>
parents: 58534
diff changeset
2232 (+ start 1)
4988bdf5db77 (gdb-put-string): Copy/create strings so
Nick Roberts <nickrob@snap.net.nz>
parents: 58534
diff changeset
2233 putstring
4988bdf5db77 (gdb-put-string): Copy/create strings so
Nick Roberts <nickrob@snap.net.nz>
parents: 58534
diff changeset
2234 'left-margin))
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2235 (when (< left-margin-width 2)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2236 (save-current-buffer
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2237 (setq left-margin-width 2)
58534
c655bc81dfc0 (gdb-view-source, gdb-selected-view):
Nick Roberts <nickrob@snap.net.nz>
parents: 58521
diff changeset
2238 (if (get-buffer-window (current-buffer) 0)
56285
313e3a9f34ca (breakpoint-enabled-bitmap-face)
Kim F. Storm <storm@cua.dk>
parents: 56258
diff changeset
2239 (set-window-margins
58534
c655bc81dfc0 (gdb-view-source, gdb-selected-view):
Nick Roberts <nickrob@snap.net.nz>
parents: 58521
diff changeset
2240 (get-buffer-window (current-buffer) 0)
55328
4440fe0e7dc6 (gud-watch, gdb-display-buffer)
Nick Roberts <nickrob@snap.net.nz>
parents: 55217
diff changeset
2241 left-margin-width right-margin-width))))
60760
a706fe4203bc Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-193
Miles Bader <miles@gnu.org>
parents: 60541
diff changeset
2242 (gdb-put-string
a706fe4203bc Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-193
Miles Bader <miles@gnu.org>
parents: 60541
diff changeset
2243 (propertize putstring
a706fe4203bc Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-193
Miles Bader <miles@gnu.org>
parents: 60541
diff changeset
2244 'face (if enabled 'breakpoint-enabled 'breakpoint-disabled))
a706fe4203bc Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-193
Miles Bader <miles@gnu.org>
parents: 60541
diff changeset
2245 (1+ start)))))
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2246
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2247 (defun gdb-remove-breakpoint-icons (start end &optional remove-margin)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2248 (gdb-remove-strings start end)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2249 (if (display-images-p)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2250 (remove-images start end))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2251 (when remove-margin
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2252 (setq left-margin-width 0)
58534
c655bc81dfc0 (gdb-view-source, gdb-selected-view):
Nick Roberts <nickrob@snap.net.nz>
parents: 58521
diff changeset
2253 (if (get-buffer-window (current-buffer) 0)
56285
313e3a9f34ca (breakpoint-enabled-bitmap-face)
Kim F. Storm <storm@cua.dk>
parents: 56258
diff changeset
2254 (set-window-margins
58534
c655bc81dfc0 (gdb-view-source, gdb-selected-view):
Nick Roberts <nickrob@snap.net.nz>
parents: 58521
diff changeset
2255 (get-buffer-window (current-buffer) 0)
55328
4440fe0e7dc6 (gud-watch, gdb-display-buffer)
Nick Roberts <nickrob@snap.net.nz>
parents: 55217
diff changeset
2256 left-margin-width right-margin-width))))
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2257
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2258
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2259 ;;
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2260 ;; Assembler buffer.
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2261 ;;
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2262 (gdb-set-buffer-rules 'gdb-assembler-buffer
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2263 'gdb-assembler-buffer-name
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2264 'gdb-assembler-mode)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2265
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2266 (def-gdb-auto-updated-buffer gdb-assembler-buffer
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2267 gdb-invalidate-assembler
55749
230865f1c59d (gdb-server-prefix): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 55696
diff changeset
2268 (concat gdb-server-prefix "disassemble " gdb-current-address "\n")
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2269 gdb-assembler-handler
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2270 gdb-assembler-custom)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2271
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2272 (defun gdb-assembler-custom ()
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2273 (let ((buffer (gdb-get-buffer 'gdb-assembler-buffer))
59766
8d2464efeb2e (gdb-info-breakpoints-custom)
Nick Roberts <nickrob@snap.net.nz>
parents: 59763
diff changeset
2274 (pos 1) (address) (flag) (bptno))
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2275 (with-current-buffer buffer
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2276 (if (not (equal gdb-current-address "main"))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2277 (progn
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2278 (goto-char (point-min))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2279 (if (re-search-forward gdb-current-address nil t)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2280 (progn
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2281 (setq pos (point))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2282 (beginning-of-line)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2283 (or gdb-overlay-arrow-position
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2284 (setq gdb-overlay-arrow-position (make-marker)))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2285 (set-marker gdb-overlay-arrow-position
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2286 (point) (current-buffer))))))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2287 ;; remove all breakpoint-icons in assembler buffer before updating.
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2288 (gdb-remove-breakpoint-icons (point-min) (point-max)))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2289 (with-current-buffer (gdb-get-buffer 'gdb-breakpoints-buffer)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2290 (goto-char (point-min))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2291 (while (< (point) (- (point-max) 1))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2292 (forward-line 1)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2293 (if (looking-at "[^\t].*breakpoint")
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2294 (progn
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2295 (looking-at
59766
8d2464efeb2e (gdb-info-breakpoints-custom)
Nick Roberts <nickrob@snap.net.nz>
parents: 59763
diff changeset
2296 "\\([0-9]+\\)\\s-+\\S-+\\s-+\\S-+\\s-+\\(.\\)\\s-+0x\\(\\S-+\\)")
8d2464efeb2e (gdb-info-breakpoints-custom)
Nick Roberts <nickrob@snap.net.nz>
parents: 59763
diff changeset
2297 (setq bptno (match-string 1))
8d2464efeb2e (gdb-info-breakpoints-custom)
Nick Roberts <nickrob@snap.net.nz>
parents: 59763
diff changeset
2298 (setq flag (char-after (match-beginning 2)))
8d2464efeb2e (gdb-info-breakpoints-custom)
Nick Roberts <nickrob@snap.net.nz>
parents: 59763
diff changeset
2299 (setq address (match-string 3))
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2300 ;; remove leading 0s from output of info break.
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2301 (if (string-match "^0+\\(.*\\)" address)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2302 (setq address (match-string 1 address)))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2303 (with-current-buffer buffer
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2304 (goto-char (point-min))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2305 (if (re-search-forward address nil t)
59766
8d2464efeb2e (gdb-info-breakpoints-custom)
Nick Roberts <nickrob@snap.net.nz>
parents: 59763
diff changeset
2306 (gdb-put-breakpoint-icon (eq flag ?y) bptno)))))))
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2307 (if (not (equal gdb-current-address "main"))
58534
c655bc81dfc0 (gdb-view-source, gdb-selected-view):
Nick Roberts <nickrob@snap.net.nz>
parents: 58521
diff changeset
2308 (set-window-point (get-buffer-window buffer 0) pos))))
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2309
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2310 (defvar gdb-assembler-mode-map
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2311 (let ((map (make-sparse-keymap)))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2312 (suppress-keymap map)
58485
31d7630f91d4 (gdb-breakpoints-mode-map)
Nick Roberts <nickrob@snap.net.nz>
parents: 58470
diff changeset
2313 (define-key map "q" 'kill-this-buffer)
31d7630f91d4 (gdb-breakpoints-mode-map)
Nick Roberts <nickrob@snap.net.nz>
parents: 58470
diff changeset
2314 map))
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2315
57661
b59713cd72a2 (gdb-get-create-buffer): Allow modes to run
Nick Roberts <nickrob@snap.net.nz>
parents: 57350
diff changeset
2316 (defvar gdb-assembler-font-lock-keywords
57664
4d6eec4c1ef8 * progmodes/gdb-ui.el (gdb-assembler-font-lock-keywords): Handle
Masatake YAMATO <jet@gyve.org>
parents: 57661
diff changeset
2317 '(;; <__function.name+n>
4d6eec4c1ef8 * progmodes/gdb-ui.el (gdb-assembler-font-lock-keywords): Handle
Masatake YAMATO <jet@gyve.org>
parents: 57661
diff changeset
2318 ("<\\(\\(\\sw\\|[_.]\\)+\\)\\(\\+[0-9]+\\)?>"
4d6eec4c1ef8 * progmodes/gdb-ui.el (gdb-assembler-font-lock-keywords): Handle
Masatake YAMATO <jet@gyve.org>
parents: 57661
diff changeset
2319 (1 font-lock-function-name-face))
4d6eec4c1ef8 * progmodes/gdb-ui.el (gdb-assembler-font-lock-keywords): Handle
Masatake YAMATO <jet@gyve.org>
parents: 57661
diff changeset
2320 ;; 0xNNNNNNNN <__function.name+n>: opcode
4d6eec4c1ef8 * progmodes/gdb-ui.el (gdb-assembler-font-lock-keywords): Handle
Masatake YAMATO <jet@gyve.org>
parents: 57661
diff changeset
2321 ("^0x[0-9a-f]+ \\(<\\(\\(\\sw\\|[_.]\\)+\\)\\+[0-9]+>\\)?:[ \t]+\\(\\sw+\\)"
57661
b59713cd72a2 (gdb-get-create-buffer): Allow modes to run
Nick Roberts <nickrob@snap.net.nz>
parents: 57350
diff changeset
2322 (4 font-lock-keyword-face))
57664
4d6eec4c1ef8 * progmodes/gdb-ui.el (gdb-assembler-font-lock-keywords): Handle
Masatake YAMATO <jet@gyve.org>
parents: 57661
diff changeset
2323 ;; %register(at least i386)
57661
b59713cd72a2 (gdb-get-create-buffer): Allow modes to run
Nick Roberts <nickrob@snap.net.nz>
parents: 57350
diff changeset
2324 ("%\\sw+" . font-lock-variable-name-face)
57664
4d6eec4c1ef8 * progmodes/gdb-ui.el (gdb-assembler-font-lock-keywords): Handle
Masatake YAMATO <jet@gyve.org>
parents: 57661
diff changeset
2325 ("^\\(Dump of assembler code for function\\) \\(.+\\):"
57661
b59713cd72a2 (gdb-get-create-buffer): Allow modes to run
Nick Roberts <nickrob@snap.net.nz>
parents: 57350
diff changeset
2326 (1 font-lock-comment-face)
b59713cd72a2 (gdb-get-create-buffer): Allow modes to run
Nick Roberts <nickrob@snap.net.nz>
parents: 57350
diff changeset
2327 (2 font-lock-function-name-face))
b59713cd72a2 (gdb-get-create-buffer): Allow modes to run
Nick Roberts <nickrob@snap.net.nz>
parents: 57350
diff changeset
2328 ("^\\(End of assembler dump\\.\\)" . font-lock-comment-face))
b59713cd72a2 (gdb-get-create-buffer): Allow modes to run
Nick Roberts <nickrob@snap.net.nz>
parents: 57350
diff changeset
2329 "Font lock keywords used in `gdb-assembler-mode'.")
b59713cd72a2 (gdb-get-create-buffer): Allow modes to run
Nick Roberts <nickrob@snap.net.nz>
parents: 57350
diff changeset
2330
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2331 (defun gdb-assembler-mode ()
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2332 "Major mode for viewing code assembler.
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2333
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2334 \\{gdb-assembler-mode-map}"
57661
b59713cd72a2 (gdb-get-create-buffer): Allow modes to run
Nick Roberts <nickrob@snap.net.nz>
parents: 57350
diff changeset
2335 (kill-all-local-variables)
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2336 (setq major-mode 'gdb-assembler-mode)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2337 (setq mode-name "Machine")
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2338 (setq gdb-overlay-arrow-position nil)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2339 (add-to-list 'overlay-arrow-variable-list 'gdb-overlay-arrow-position)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2340 (put 'gdb-overlay-arrow-position 'overlay-arrow-string "=>")
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2341 (setq fringes-outside-margins t)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2342 (setq buffer-read-only t)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2343 (use-local-map gdb-assembler-mode-map)
57661
b59713cd72a2 (gdb-get-create-buffer): Allow modes to run
Nick Roberts <nickrob@snap.net.nz>
parents: 57350
diff changeset
2344 (gdb-invalidate-assembler)
b59713cd72a2 (gdb-get-create-buffer): Allow modes to run
Nick Roberts <nickrob@snap.net.nz>
parents: 57350
diff changeset
2345 (set (make-local-variable 'font-lock-defaults)
b59713cd72a2 (gdb-get-create-buffer): Allow modes to run
Nick Roberts <nickrob@snap.net.nz>
parents: 57350
diff changeset
2346 '(gdb-assembler-font-lock-keywords))
b59713cd72a2 (gdb-get-create-buffer): Allow modes to run
Nick Roberts <nickrob@snap.net.nz>
parents: 57350
diff changeset
2347 (run-mode-hooks 'gdb-assembler-mode-hook)
b59713cd72a2 (gdb-get-create-buffer): Allow modes to run
Nick Roberts <nickrob@snap.net.nz>
parents: 57350
diff changeset
2348 'gdb-invalidate-assembler)
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2349
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2350 (defun gdb-assembler-buffer-name ()
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2351 (with-current-buffer gud-comint-buffer
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2352 (concat "*Machine Code " (gdb-get-target-string) "*")))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2353
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2354 (defun gdb-display-assembler-buffer ()
55400
1aaa031e318c Improve/extend documentation strings.
Nick Roberts <nickrob@snap.net.nz>
parents: 55330
diff changeset
2355 "Display disassembly view."
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2356 (interactive)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2357 (gdb-display-buffer
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2358 (gdb-get-create-buffer 'gdb-assembler-buffer)))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2359
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2360 (defun gdb-frame-assembler-buffer ()
55400
1aaa031e318c Improve/extend documentation strings.
Nick Roberts <nickrob@snap.net.nz>
parents: 55330
diff changeset
2361 "Display disassembly view in a new frame."
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2362 (interactive)
58521
54bb21951d18 (gdb-frame-parameters): Match height and
Nick Roberts <nickrob@snap.net.nz>
parents: 58485
diff changeset
2363 (let ((special-display-regexps (append special-display-regexps '(".*")))
54bb21951d18 (gdb-frame-parameters): Match height and
Nick Roberts <nickrob@snap.net.nz>
parents: 58485
diff changeset
2364 (special-display-frame-alist gdb-frame-parameters))
54bb21951d18 (gdb-frame-parameters): Match height and
Nick Roberts <nickrob@snap.net.nz>
parents: 58485
diff changeset
2365 (display-buffer (gdb-get-create-buffer 'gdb-assembler-buffer))))
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2366
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2367 ;; modified because if gdb-current-address has changed value a new command
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2368 ;; must be enqueued to update the buffer with the new output
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2369 (defun gdb-invalidate-assembler (&optional ignored)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2370 (if (gdb-get-buffer 'gdb-assembler-buffer)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2371 (progn
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2372 (unless (string-equal gdb-current-frame gdb-previous-frame)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2373 (if (or (not (member 'gdb-invalidate-assembler
55749
230865f1c59d (gdb-server-prefix): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 55696
diff changeset
2374 gdb-pending-triggers))
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2375 (not (string-equal gdb-current-address
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2376 gdb-previous-address)))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2377 (progn
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2378 ;; take previous disassemble command off the queue
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2379 (with-current-buffer gud-comint-buffer
58485
31d7630f91d4 (gdb-breakpoints-mode-map)
Nick Roberts <nickrob@snap.net.nz>
parents: 58470
diff changeset
2380 (let ((queue gdb-input-queue))
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2381 (dolist (item queue)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2382 (if (equal (cdr item) '(gdb-assembler-handler))
55749
230865f1c59d (gdb-server-prefix): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 55696
diff changeset
2383 (setq gdb-input-queue
230865f1c59d (gdb-server-prefix): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 55696
diff changeset
2384 (delete item gdb-input-queue))))))
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2385 (gdb-enqueue-input
55749
230865f1c59d (gdb-server-prefix): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 55696
diff changeset
2386 (list (concat gdb-server-prefix "disassemble " gdb-current-address "\n")
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2387 'gdb-assembler-handler))
55749
230865f1c59d (gdb-server-prefix): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 55696
diff changeset
2388 (push 'gdb-invalidate-assembler gdb-pending-triggers)
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2389 (setq gdb-previous-address gdb-current-address)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2390 (setq gdb-previous-frame gdb-current-frame)))))))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2391
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2392 (defun gdb-get-current-frame ()
55749
230865f1c59d (gdb-server-prefix): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 55696
diff changeset
2393 (if (not (member 'gdb-get-current-frame gdb-pending-triggers))
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2394 (progn
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2395 (gdb-enqueue-input
55749
230865f1c59d (gdb-server-prefix): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 55696
diff changeset
2396 (list (concat gdb-server-prefix "info frame\n") 'gdb-frame-handler))
230865f1c59d (gdb-server-prefix): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 55696
diff changeset
2397 (push 'gdb-get-current-frame
230865f1c59d (gdb-server-prefix): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 55696
diff changeset
2398 gdb-pending-triggers))))
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2399
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2400 (defun gdb-frame-handler ()
55749
230865f1c59d (gdb-server-prefix): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 55696
diff changeset
2401 (setq gdb-pending-triggers
230865f1c59d (gdb-server-prefix): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 55696
diff changeset
2402 (delq 'gdb-get-current-frame gdb-pending-triggers))
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2403 (with-current-buffer (gdb-get-create-buffer 'gdb-partial-output-buffer)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2404 (goto-char (point-min))
58049
fd0093bd412a (gdb-current-stack-level): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 57982
diff changeset
2405 (if (looking-at "Stack level \\([0-9]+\\)")
fd0093bd412a (gdb-current-stack-level): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 57982
diff changeset
2406 (setq gdb-current-stack-level (match-string 1)))
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2407 (forward-line)
54962
c3272c09f927 (gdb-goto-info): Require 'info.
Nick Roberts <nickrob@snap.net.nz>
parents: 54901
diff changeset
2408 (if (looking-at ".*=\\s-+0x\\(\\S-*\\)\\s-+in\\s-+\\(\\S-*?\\);? ")
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2409 (progn
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2410 (setq gdb-current-frame (match-string 2))
55850
63ca25eb73a1 (gdb-current-frame, gud-watch)
Nick Roberts <nickrob@snap.net.nz>
parents: 55764
diff changeset
2411 (if (gdb-get-buffer 'gdb-locals-buffer)
63ca25eb73a1 (gdb-current-frame, gud-watch)
Nick Roberts <nickrob@snap.net.nz>
parents: 55764
diff changeset
2412 (with-current-buffer (gdb-get-buffer 'gdb-locals-buffer)
63ca25eb73a1 (gdb-current-frame, gud-watch)
Nick Roberts <nickrob@snap.net.nz>
parents: 55764
diff changeset
2413 (setq mode-name (concat "Locals:" gdb-current-frame))))
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2414 (let ((address (match-string 1)))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2415 ;; remove leading 0s from output of info frame command.
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2416 (if (string-match "^0+\\(.*\\)" address)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2417 (setq gdb-current-address
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2418 (concat "0x" (match-string 1 address)))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2419 (setq gdb-current-address (concat "0x" address))))
58534
c655bc81dfc0 (gdb-view-source, gdb-selected-view):
Nick Roberts <nickrob@snap.net.nz>
parents: 58521
diff changeset
2420 (if (not (re-search-forward "(\\S-*:[0-9]*);" nil t))
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2421 ;;update with new frame for machine code if necessary
58534
c655bc81dfc0 (gdb-view-source, gdb-selected-view):
Nick Roberts <nickrob@snap.net.nz>
parents: 58521
diff changeset
2422 (gdb-invalidate-assembler)))))
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2423 (if (re-search-forward " source language \\(\\S-*\\)\." nil t)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2424 (setq gdb-current-language (match-string 1))))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2425
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2426 (provide 'gdb-ui)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2427
55696
ed6e91c53c82 (gdb-reset): Use unless. Fix regexp.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55507
diff changeset
2428 ;; arch-tag: e9fb00c5-74ef-469f-a088-37384caae352
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2429 ;;; gdb-ui.el ends here