annotate lisp/progmodes/gdb-ui.el @ 66119:bc2d2dc9f534

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