annotate lisp/progmodes/gdb-ui.el @ 59144:8d9ea622c741

* term/mac-win.el: Sync with x-win.el. Rearrange the contents. Call mac-clear-font-name-table if invoked on Mac OS 8/9. Call x-open-connection on Mac OS X.
author Steven Tamm <steventamm@mac.com>
date Mon, 27 Dec 2004 17:23:02 +0000
parents c655bc81dfc0
children 4988bdf5db77 549734260e34 f2ebccfa87d4
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
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
7 ;; Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc.
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
8
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
9 ;; This file is part of GNU Emacs.
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
10
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
11 ;; GNU Emacs is free software; you can redistribute it and/or modify
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
12 ;; it under the terms of the GNU General Public License as published by
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
13 ;; the Free Software Foundation; either version 2, or (at your option)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
14 ;; any later version.
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
15
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
16 ;; GNU Emacs is distributed in the hope that it will be useful,
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
19 ;; GNU General Public License for more details.
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
20
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
21 ;; You should have received a copy of the GNU General Public License
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
22 ;; along with GNU Emacs; see the file COPYING. If not, write to the
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
23 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
24 ;; Boston, MA 02111-1307, USA.
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
25
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
26 ;;; Commentary:
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
27
57791
d1b93fc4ce47 Docstring fixes.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57664
diff changeset
28 ;; This mode acts as a graphical user interface to GDB. You can interact with
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
29 ;; GDB through the GUD buffer in the usual way, but there are also further
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
30 ;; buffers which control the execution and describe the state of your program.
54729
7bfccd78beed (gdb-use-inferior-io-buffer): New option.
Nick Roberts <nickrob@snap.net.nz>
parents: 54668
diff changeset
31 ;; It separates the input/output of your program from that of GDB, if
57791
d1b93fc4ce47 Docstring fixes.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57664
diff changeset
32 ;; required, and watches expressions in the speedbar. It also uses features of
56258
3b1880995ace (gdb-toggle-breakpoint)
Nick Roberts <nickrob@snap.net.nz>
parents: 55850
diff changeset
33 ;; Emacs 21 such as the fringe/display margin for breakpoints, and the toolbar
3b1880995ace (gdb-toggle-breakpoint)
Nick Roberts <nickrob@snap.net.nz>
parents: 55850
diff changeset
34 ;; (see the GDB Graphical Interface section in the Emacs info manual).
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
35
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
36 ;; Start the debugger with M-x gdba.
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
37
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
38 ;; This file has evolved from gdba.el from GDB 5.0 written by Tom Lord and Jim
57791
d1b93fc4ce47 Docstring fixes.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57664
diff changeset
39 ;; Kingdon and uses GDB's annotation interface. You don't need to know about
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
40 ;; annotations to use this mode as a debugger, but if you are interested
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
41 ;; developing the mode itself, then see the Annotations section in the GDB
56285
313e3a9f34ca (breakpoint-enabled-bitmap-face)
Kim F. Storm <storm@cua.dk>
parents: 56258
diff changeset
42 ;; info manual.
55850
63ca25eb73a1 (gdb-current-frame, gud-watch)
Nick Roberts <nickrob@snap.net.nz>
parents: 55764
diff changeset
43 ;;
57791
d1b93fc4ce47 Docstring fixes.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57664
diff changeset
44 ;; 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
45 ;; 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
46 ;; it. Some GDB/MI commands are used in this file through the CLI command
d1b93fc4ce47 Docstring fixes.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57664
diff changeset
47 ;; 'interpreter mi <mi-command>'. A file called gdb-mi.el is included in the
55850
63ca25eb73a1 (gdb-current-frame, gud-watch)
Nick Roberts <nickrob@snap.net.nz>
parents: 55764
diff changeset
48 ;; GDB repository for future releases (6.2 onwards) that uses GDB/MI as the
57791
d1b93fc4ce47 Docstring fixes.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57664
diff changeset
49 ;; primary interface to GDB. It is still under development and is part of a
55850
63ca25eb73a1 (gdb-current-frame, gud-watch)
Nick Roberts <nickrob@snap.net.nz>
parents: 55764
diff changeset
50 ;; process to migrate Emacs from annotations to GDB/MI.
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
51 ;;
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
52 ;; Known Bugs:
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
53 ;;
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
54
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
55 ;;; Code:
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
56
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
57 (require 'gud)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
58
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
59 (defvar gdb-current-address "main" "Initialisation for Assembler buffer.")
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
60 (defvar gdb-previous-address nil)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
61 (defvar gdb-previous-frame nil)
55850
63ca25eb73a1 (gdb-current-frame, gud-watch)
Nick Roberts <nickrob@snap.net.nz>
parents: 55764
diff changeset
62 (defvar gdb-current-frame nil)
58049
fd0093bd412a (gdb-current-stack-level): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 57982
diff changeset
63 (defvar gdb-current-stack-level nil)
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
64 (defvar gdb-current-language nil)
57791
d1b93fc4ce47 Docstring fixes.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57664
diff changeset
65 (defvar gdb-var-list nil "List of variables in watch window.")
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
66 (defvar gdb-var-changed nil "Non-nil means that gdb-var-list has changed.")
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
67 (defvar gdb-buffer-type nil)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
68 (defvar gdb-overlay-arrow-position nil)
55749
230865f1c59d (gdb-server-prefix): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 55696
diff changeset
69 (defvar gdb-server-prefix nil)
58431
da65edef151e (gdb-flush-pending-output): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 58420
diff changeset
70 (defvar gdb-flush-pending-output nil)
56285
313e3a9f34ca (breakpoint-enabled-bitmap-face)
Kim F. Storm <storm@cua.dk>
parents: 56258
diff changeset
71
58420
97e4fc5c7297 (gdb-resync): New function.
Nick Roberts <nickrob@snap.net.nz>
parents: 58049
diff changeset
72 (defvar gdb-buffer-type nil
97e4fc5c7297 (gdb-resync): New function.
Nick Roberts <nickrob@snap.net.nz>
parents: 58049
diff changeset
73 "One of the symbols bound in `gdb-buffer-rules'.")
97e4fc5c7297 (gdb-resync): New function.
Nick Roberts <nickrob@snap.net.nz>
parents: 58049
diff changeset
74
97e4fc5c7297 (gdb-resync): New function.
Nick Roberts <nickrob@snap.net.nz>
parents: 58049
diff changeset
75 (defvar gdb-input-queue ()
97e4fc5c7297 (gdb-resync): New function.
Nick Roberts <nickrob@snap.net.nz>
parents: 58049
diff changeset
76 "A list of gdb command objects.")
97e4fc5c7297 (gdb-resync): New function.
Nick Roberts <nickrob@snap.net.nz>
parents: 58049
diff changeset
77
97e4fc5c7297 (gdb-resync): New function.
Nick Roberts <nickrob@snap.net.nz>
parents: 58049
diff changeset
78 (defvar gdb-prompting nil
97e4fc5c7297 (gdb-resync): New function.
Nick Roberts <nickrob@snap.net.nz>
parents: 58049
diff changeset
79 "True when gdb is idle with no pending input.")
97e4fc5c7297 (gdb-resync): New function.
Nick Roberts <nickrob@snap.net.nz>
parents: 58049
diff changeset
80
97e4fc5c7297 (gdb-resync): New function.
Nick Roberts <nickrob@snap.net.nz>
parents: 58049
diff changeset
81 (defvar gdb-output-sink 'user
97e4fc5c7297 (gdb-resync): New function.
Nick Roberts <nickrob@snap.net.nz>
parents: 58049
diff changeset
82 "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
83 Possible values are these symbols:
97e4fc5c7297 (gdb-resync): New function.
Nick Roberts <nickrob@snap.net.nz>
parents: 58049
diff changeset
84
97e4fc5c7297 (gdb-resync): New function.
Nick Roberts <nickrob@snap.net.nz>
parents: 58049
diff changeset
85 `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
86 for the user to see.
97e4fc5c7297 (gdb-resync): New function.
Nick Roberts <nickrob@snap.net.nz>
parents: 58049
diff changeset
87
97e4fc5c7297 (gdb-resync): New function.
Nick Roberts <nickrob@snap.net.nz>
parents: 58049
diff changeset
88 `inferior' -- gdb output should be copied to the inferior-io buffer
97e4fc5c7297 (gdb-resync): New function.
Nick Roberts <nickrob@snap.net.nz>
parents: 58049
diff changeset
89
97e4fc5c7297 (gdb-resync): New function.
Nick Roberts <nickrob@snap.net.nz>
parents: 58049
diff changeset
90 `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
91 annotation is received. Then the output-sink
97e4fc5c7297 (gdb-resync): New function.
Nick Roberts <nickrob@snap.net.nz>
parents: 58049
diff changeset
92 becomes:...
97e4fc5c7297 (gdb-resync): New function.
Nick Roberts <nickrob@snap.net.nz>
parents: 58049
diff changeset
93 `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
94 for subsequent processing by a command. This is the
97e4fc5c7297 (gdb-resync): New function.
Nick Roberts <nickrob@snap.net.nz>
parents: 58049
diff changeset
95 disposition of output generated by commands that
97e4fc5c7297 (gdb-resync): New function.
Nick Roberts <nickrob@snap.net.nz>
parents: 58049
diff changeset
96 gdb mode sends to gdb on its own behalf.
97e4fc5c7297 (gdb-resync): New function.
Nick Roberts <nickrob@snap.net.nz>
parents: 58049
diff changeset
97 `post-emacs' -- ignore output until the prompt annotation is
97e4fc5c7297 (gdb-resync): New function.
Nick Roberts <nickrob@snap.net.nz>
parents: 58049
diff changeset
98 received, then go to USER disposition.
97e4fc5c7297 (gdb-resync): New function.
Nick Roberts <nickrob@snap.net.nz>
parents: 58049
diff changeset
99
97e4fc5c7297 (gdb-resync): New function.
Nick Roberts <nickrob@snap.net.nz>
parents: 58049
diff changeset
100 gdba (gdb-ui.el) uses all five values, gdbmi (gdb-mi.el) only two
97e4fc5c7297 (gdb-resync): New function.
Nick Roberts <nickrob@snap.net.nz>
parents: 58049
diff changeset
101 \(`user' and `emacs').")
97e4fc5c7297 (gdb-resync): New function.
Nick Roberts <nickrob@snap.net.nz>
parents: 58049
diff changeset
102
97e4fc5c7297 (gdb-resync): New function.
Nick Roberts <nickrob@snap.net.nz>
parents: 58049
diff changeset
103 (defvar gdb-current-item nil
97e4fc5c7297 (gdb-resync): New function.
Nick Roberts <nickrob@snap.net.nz>
parents: 58049
diff changeset
104 "The most recent command item sent to gdb.")
97e4fc5c7297 (gdb-resync): New function.
Nick Roberts <nickrob@snap.net.nz>
parents: 58049
diff changeset
105
97e4fc5c7297 (gdb-resync): New function.
Nick Roberts <nickrob@snap.net.nz>
parents: 58049
diff changeset
106 (defvar gdb-pending-triggers '()
97e4fc5c7297 (gdb-resync): New function.
Nick Roberts <nickrob@snap.net.nz>
parents: 58049
diff changeset
107 "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
108 handlers.")
97e4fc5c7297 (gdb-resync): New function.
Nick Roberts <nickrob@snap.net.nz>
parents: 58049
diff changeset
109
97e4fc5c7297 (gdb-resync): New function.
Nick Roberts <nickrob@snap.net.nz>
parents: 58049
diff changeset
110 ;; end of gdb variables
97e4fc5c7297 (gdb-resync): New function.
Nick Roberts <nickrob@snap.net.nz>
parents: 58049
diff changeset
111
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
112 ;;;###autoload
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
113 (defun gdba (command-line)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
114 "Run gdb on program FILE in buffer *gud-FILE*.
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
115 The directory containing FILE becomes the initial working directory
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
116 and source-file directory for your debugger.
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
117
54668
69a699e79a0d (gdb-view-source-function, gdb-view-assembler)
Nick Roberts <nickrob@snap.net.nz>
parents: 54617
diff changeset
118 If `gdb-many-windows' is nil (the default value) then gdb just
69a699e79a0d (gdb-view-source-function, gdb-view-assembler)
Nick Roberts <nickrob@snap.net.nz>
parents: 54617
diff changeset
119 pops up the GUD buffer unless `gdb-show-main' is t. In this case
69a699e79a0d (gdb-view-source-function, gdb-view-assembler)
Nick Roberts <nickrob@snap.net.nz>
parents: 54617
diff changeset
120 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
121 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
122
54901
fa4feb8b3c34 (gdb-goto-info): New function.
Nick Roberts <nickrob@snap.net.nz>
parents: 54760
diff changeset
123 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
124 `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
125 `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
126 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
127 relevant buffer.
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
128
54901
fa4feb8b3c34 (gdb-goto-info): New function.
Nick Roberts <nickrob@snap.net.nz>
parents: 54760
diff changeset
129 Watch expressions appear in the speedbar/slowbar.
fa4feb8b3c34 (gdb-goto-info): New function.
Nick Roberts <nickrob@snap.net.nz>
parents: 54760
diff changeset
130
57791
d1b93fc4ce47 Docstring fixes.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57664
diff changeset
131 The following commands help control operation :
54901
fa4feb8b3c34 (gdb-goto-info): New function.
Nick Roberts <nickrob@snap.net.nz>
parents: 54760
diff changeset
132
fa4feb8b3c34 (gdb-goto-info): New function.
Nick Roberts <nickrob@snap.net.nz>
parents: 54760
diff changeset
133 `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
134 `gdb-restore-windows' - To restore the window layout.
fa4feb8b3c34 (gdb-goto-info): New function.
Nick Roberts <nickrob@snap.net.nz>
parents: 54760
diff changeset
135
fa4feb8b3c34 (gdb-goto-info): New function.
Nick Roberts <nickrob@snap.net.nz>
parents: 54760
diff changeset
136 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
137 detailed description of this mode.
fa4feb8b3c34 (gdb-goto-info): New function.
Nick Roberts <nickrob@snap.net.nz>
parents: 54760
diff changeset
138
fa4feb8b3c34 (gdb-goto-info): New function.
Nick Roberts <nickrob@snap.net.nz>
parents: 54760
diff changeset
139
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
140 ---------------------------------------------------------------------
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
141 GDB Toolbar
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
142 ---------------------------------------------------------------------
54901
fa4feb8b3c34 (gdb-goto-info): New function.
Nick Roberts <nickrob@snap.net.nz>
parents: 54760
diff changeset
143 GUD buffer (I/O of GDB) | Locals buffer
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
144 |
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
145 |
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
146 |
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
147 ---------------------------------------------------------------------
55749
230865f1c59d (gdb-server-prefix): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 55696
diff changeset
148 Source buffer | Input/Output (of inferior) buffer
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
149 | (comint-mode)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
150 |
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
151 |
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
152 |
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
153 |
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
154 |
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
155 |
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
156 ---------------------------------------------------------------------
54901
fa4feb8b3c34 (gdb-goto-info): New function.
Nick Roberts <nickrob@snap.net.nz>
parents: 54760
diff changeset
157 Stack buffer | Breakpoints buffer
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
158 RET gdb-frames-select | SPC gdb-toggle-breakpoint
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
159 | RET gdb-goto-breakpoint
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
160 | d gdb-delete-breakpoint
57791
d1b93fc4ce47 Docstring fixes.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57664
diff changeset
161 ---------------------------------------------------------------------"
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
162 ;;
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
163 (interactive (list (gud-query-cmdline 'gdba)))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
164 ;;
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
165 ;; 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
166 (gdb command-line)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
167 (gdb-ann3))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
168
54616
47c4cb867a84 (gdb-ann3, gdb-send-item)
Nick Roberts <nickrob@snap.net.nz>
parents: 54538
diff changeset
169 (defvar gdb-debug-log nil)
47c4cb867a84 (gdb-ann3, gdb-send-item)
Nick Roberts <nickrob@snap.net.nz>
parents: 54538
diff changeset
170
47c4cb867a84 (gdb-ann3, gdb-send-item)
Nick Roberts <nickrob@snap.net.nz>
parents: 54538
diff changeset
171 (defcustom gdb-enable-debug-log nil
47c4cb867a84 (gdb-ann3, gdb-send-item)
Nick Roberts <nickrob@snap.net.nz>
parents: 54538
diff changeset
172 "Non-nil means record the process input and output in `gdb-debug-log'."
47c4cb867a84 (gdb-ann3, gdb-send-item)
Nick Roberts <nickrob@snap.net.nz>
parents: 54538
diff changeset
173 :type 'boolean
57851
67b88e92a24d (gdb-enable-debug-log)
Nick Roberts <nickrob@snap.net.nz>
parents: 57791
diff changeset
174 :group 'gud
67b88e92a24d (gdb-enable-debug-log)
Nick Roberts <nickrob@snap.net.nz>
parents: 57791
diff changeset
175 :version "21.4")
54616
47c4cb867a84 (gdb-ann3, gdb-send-item)
Nick Roberts <nickrob@snap.net.nz>
parents: 54538
diff changeset
176
54729
7bfccd78beed (gdb-use-inferior-io-buffer): New option.
Nick Roberts <nickrob@snap.net.nz>
parents: 54668
diff changeset
177 (defcustom gdb-use-inferior-io-buffer nil
7bfccd78beed (gdb-use-inferior-io-buffer): New option.
Nick Roberts <nickrob@snap.net.nz>
parents: 54668
diff changeset
178 "Non-nil means display output from the inferior in a separate buffer."
7bfccd78beed (gdb-use-inferior-io-buffer): New option.
Nick Roberts <nickrob@snap.net.nz>
parents: 54668
diff changeset
179 :type 'boolean
57851
67b88e92a24d (gdb-enable-debug-log)
Nick Roberts <nickrob@snap.net.nz>
parents: 57791
diff changeset
180 :group 'gud
67b88e92a24d (gdb-enable-debug-log)
Nick Roberts <nickrob@snap.net.nz>
parents: 57791
diff changeset
181 :version "21.4")
54729
7bfccd78beed (gdb-use-inferior-io-buffer): New option.
Nick Roberts <nickrob@snap.net.nz>
parents: 54668
diff changeset
182
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
183 (defun gdb-ann3 ()
54616
47c4cb867a84 (gdb-ann3, gdb-send-item)
Nick Roberts <nickrob@snap.net.nz>
parents: 54538
diff changeset
184 (setq gdb-debug-log nil)
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
185 (set (make-local-variable 'gud-minor-mode) 'gdba)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
186 (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
187 ;;
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
188 (gud-def gud-break (if (not (string-equal mode-name "Machine"))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
189 (gud-call "break %f:%l" arg)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
190 (save-excursion
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
191 (beginning-of-line)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
192 (forward-char 2)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
193 (gud-call "break *%a" arg)))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
194 "\C-b" "Set breakpoint at current line or address.")
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
195 ;;
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
196 (gud-def gud-remove (if (not (string-equal mode-name "Machine"))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
197 (gud-call "clear %f:%l" arg)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
198 (save-excursion
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
199 (beginning-of-line)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
200 (forward-char 2)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
201 (gud-call "clear *%a" arg)))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
202 "\C-d" "Remove breakpoint at current line or address.")
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
203 ;;
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
204 (gud-def gud-until (if (not (string-equal mode-name "Machine"))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
205 (gud-call "until %f:%l" arg)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
206 (save-excursion
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
207 (beginning-of-line)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
208 (forward-char 2)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
209 (gud-call "until *%a" arg)))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
210 "\C-u" "Continue to current line or address.")
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
211
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
212 (define-key gud-minor-mode-map [left-margin mouse-1]
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
213 'gdb-mouse-toggle-breakpoint)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
214 (define-key gud-minor-mode-map [left-fringe mouse-1]
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
215 'gdb-mouse-toggle-breakpoint)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
216
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
217 (setq comint-input-sender 'gdb-send)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
218 ;;
57664
4d6eec4c1ef8 * progmodes/gdb-ui.el (gdb-assembler-font-lock-keywords): Handle
Masatake YAMATO <jet@gyve.org>
parents: 57661
diff changeset
219 ;; (re-)initialize
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
220 (setq gdb-current-address "main")
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
221 (setq gdb-previous-address nil)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
222 (setq gdb-previous-frame nil)
55850
63ca25eb73a1 (gdb-current-frame, gud-watch)
Nick Roberts <nickrob@snap.net.nz>
parents: 55764
diff changeset
223 (setq gdb-current-frame nil)
58049
fd0093bd412a (gdb-current-stack-level): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 57982
diff changeset
224 (setq gdb-current-stack-level nil)
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
225 (setq gdb-var-list nil)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
226 (setq gdb-var-changed nil)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
227 (setq gdb-first-prompt nil)
55749
230865f1c59d (gdb-server-prefix): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 55696
diff changeset
228 (setq gdb-prompting nil)
57350
11b8de2051f3 (gdb-ann3): (Re-)initialise gdb-input-queue.
Nick Roberts <nickrob@snap.net.nz>
parents: 57262
diff changeset
229 (setq gdb-input-queue nil)
55749
230865f1c59d (gdb-server-prefix): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 55696
diff changeset
230 (setq gdb-current-item nil)
230865f1c59d (gdb-server-prefix): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 55696
diff changeset
231 (setq gdb-pending-triggers nil)
230865f1c59d (gdb-server-prefix): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 55696
diff changeset
232 (setq gdb-output-sink 'user)
230865f1c59d (gdb-server-prefix): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 55696
diff changeset
233 (setq gdb-server-prefix "server ")
58431
da65edef151e (gdb-flush-pending-output): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 58420
diff changeset
234 (setq gdb-flush-pending-output nil)
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
235 ;;
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
236 (setq gdb-buffer-type 'gdba)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
237 ;;
54729
7bfccd78beed (gdb-use-inferior-io-buffer): New option.
Nick Roberts <nickrob@snap.net.nz>
parents: 54668
diff changeset
238 (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
239 ;;
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
240 (if (eq window-system 'w32)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
241 (gdb-enqueue-input (list "set new-console off\n" 'ignore)))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
242 (gdb-enqueue-input (list "set height 0\n" 'ignore))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
243 ;; find source file and compilation directory here
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
244 (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
245 (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
246 (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
247 ;;
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
248 (run-hooks 'gdba-mode-hook))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
249
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
250 (defcustom gdb-use-colon-colon-notation nil
57791
d1b93fc4ce47 Docstring fixes.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57664
diff changeset
251 "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
252 :type 'boolean
57851
67b88e92a24d (gdb-enable-debug-log)
Nick Roberts <nickrob@snap.net.nz>
parents: 57791
diff changeset
253 :group 'gud
67b88e92a24d (gdb-enable-debug-log)
Nick Roberts <nickrob@snap.net.nz>
parents: 57791
diff changeset
254 :version "21.4")
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
255
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
256 (defun gud-watch ()
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
257 "Watch expression at point."
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
258 (interactive)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
259 (require 'tooltip)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
260 (let ((expr (tooltip-identifier-from-point (point))))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
261 (if (and (string-equal gdb-current-language "c")
55850
63ca25eb73a1 (gdb-current-frame, gud-watch)
Nick Roberts <nickrob@snap.net.nz>
parents: 55764
diff changeset
262 gdb-use-colon-colon-notation gdb-current-frame)
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
263 (setq expr (concat gdb-current-frame "::" expr)))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
264 (catch 'already-watched
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
265 (dolist (var gdb-var-list)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
266 (if (string-equal expr (car var)) (throw 'already-watched nil)))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
267 (set-text-properties 0 (length expr) nil expr)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
268 (gdb-enqueue-input
56285
313e3a9f34ca (breakpoint-enabled-bitmap-face)
Kim F. Storm <storm@cua.dk>
parents: 56258
diff changeset
269 (list
55749
230865f1c59d (gdb-server-prefix): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 55696
diff changeset
270 (if (eq gud-minor-mode 'gdba)
230865f1c59d (gdb-server-prefix): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 55696
diff changeset
271 (concat "server interpreter mi \"-var-create - * " expr "\"\n")
230865f1c59d (gdb-server-prefix): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 55696
diff changeset
272 (concat"-var-create - * " expr "\n"))
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
273 `(lambda () (gdb-var-create-handler ,expr))))))
58534
c655bc81dfc0 (gdb-view-source, gdb-selected-view):
Nick Roberts <nickrob@snap.net.nz>
parents: 58521
diff changeset
274 (select-window (get-buffer-window gud-comint-buffer 0)))
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
275
54901
fa4feb8b3c34 (gdb-goto-info): New function.
Nick Roberts <nickrob@snap.net.nz>
parents: 54760
diff changeset
276 (defun gdb-goto-info ()
55400
1aaa031e318c Improve/extend documentation strings.
Nick Roberts <nickrob@snap.net.nz>
parents: 55330
diff changeset
277 "Go to Emacs info node: GDB Graphical Interface."
54901
fa4feb8b3c34 (gdb-goto-info): New function.
Nick Roberts <nickrob@snap.net.nz>
parents: 54760
diff changeset
278 (interactive)
fa4feb8b3c34 (gdb-goto-info): New function.
Nick Roberts <nickrob@snap.net.nz>
parents: 54760
diff changeset
279 (select-frame (make-frame))
54962
c3272c09f927 (gdb-goto-info): Require 'info.
Nick Roberts <nickrob@snap.net.nz>
parents: 54901
diff changeset
280 (require 'info)
54901
fa4feb8b3c34 (gdb-goto-info): New function.
Nick Roberts <nickrob@snap.net.nz>
parents: 54760
diff changeset
281 (Info-goto-node "(emacs)GDB Graphical Interface"))
fa4feb8b3c34 (gdb-goto-info): New function.
Nick Roberts <nickrob@snap.net.nz>
parents: 54760
diff changeset
282
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
283 (defconst gdb-var-create-regexp
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
284 "name=\"\\(.*?\\)\",numchild=\"\\(.*?\\)\",type=\"\\(.*?\\)\"")
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
285
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
286 (defun gdb-var-create-handler (expr)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
287 (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
288 (goto-char (point-min))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
289 (if (re-search-forward gdb-var-create-regexp nil t)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
290 (let ((var (list expr
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
291 (match-string 1)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
292 (match-string 2)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
293 (match-string 3)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
294 nil nil)))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
295 (push var gdb-var-list)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
296 (setq speedbar-update-flag t)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
297 (speedbar 1)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
298 (if (equal (nth 2 var) "0")
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
299 (gdb-enqueue-input
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
300 (list (concat "server interpreter mi \"-var-evaluate-expression "
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
301 (nth 1 var) "\"\n")
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
302 `(lambda () (gdb-var-evaluate-expression-handler
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
303 ,(nth 1 var) nil))))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
304 (setq gdb-var-changed t)))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
305 (if (re-search-forward "Undefined command" nil t)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
306 (message "Watching expressions requires gdb 6.0 onwards")
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
307 (message "No symbol %s in current context." expr)))))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
308
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
309 (defun gdb-var-evaluate-expression-handler (varnum changed)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
310 (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
311 (goto-char (point-min))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
312 (re-search-forward ".*value=\"\\(.*?\\)\"" nil t)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
313 (catch 'var-found
58485
31d7630f91d4 (gdb-breakpoints-mode-map)
Nick Roberts <nickrob@snap.net.nz>
parents: 58470
diff changeset
314 (let ((num 0))
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
315 (dolist (var gdb-var-list)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
316 (if (string-equal varnum (cadr var))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
317 (progn
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
318 (if changed (setcar (nthcdr 5 var) t))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
319 (setcar (nthcdr 4 var) (match-string 1))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
320 (setcar (nthcdr num gdb-var-list) var)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
321 (throw 'var-found nil)))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
322 (setq num (+ num 1))))))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
323 (setq gdb-var-changed t))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
324
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
325 (defun gdb-var-list-children (varnum)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
326 (gdb-enqueue-input
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
327 (list (concat "server interpreter mi \"-var-list-children " varnum "\"\n")
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
328 `(lambda () (gdb-var-list-children-handler ,varnum)))))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
329
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
330 (defconst gdb-var-list-children-regexp
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
331 "name=\"\\(.*?\\)\",exp=\"\\(.*?\\)\",numchild=\"\\(.*?\\)\"")
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
332
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
333 (defun gdb-var-list-children-handler (varnum)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
334 (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
335 (goto-char (point-min))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
336 (let ((var-list nil))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
337 (catch 'child-already-watched
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
338 (dolist (var gdb-var-list)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
339 (if (string-equal varnum (cadr var))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
340 (progn
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
341 (push var var-list)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
342 (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
343 (let ((varchild (list (match-string 2)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
344 (match-string 1)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
345 (match-string 3)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
346 nil nil nil)))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
347 (if (looking-at ",type=\"\\(.*?\\)\"")
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
348 (setcar (nthcdr 3 varchild) (match-string 1)))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
349 (dolist (var1 gdb-var-list)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
350 (if (string-equal (cadr var1) (cadr varchild))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
351 (throw 'child-already-watched nil)))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
352 (push varchild var-list)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
353 (if (equal (nth 2 varchild) "0")
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
354 (gdb-enqueue-input
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
355 (list
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
356 (concat
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
357 "server interpreter mi \"-var-evaluate-expression "
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
358 (nth 1 varchild) "\"\n")
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
359 `(lambda () (gdb-var-evaluate-expression-handler
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
360 ,(nth 1 varchild) nil))))))))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
361 (push var var-list)))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
362 (setq gdb-var-list (nreverse var-list))))))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
363
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
364 (defun gdb-var-update ()
55749
230865f1c59d (gdb-server-prefix): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 55696
diff changeset
365 (if (not (member 'gdb-var-update gdb-pending-triggers))
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
366 (progn
55764
25f133a490aa (gdb-var-update, gdb-var-update-handler, gdb-var-delete)
Nick Roberts <nickrob@snap.net.nz>
parents: 55762
diff changeset
367 (gdb-enqueue-input
56285
313e3a9f34ca (breakpoint-enabled-bitmap-face)
Kim F. Storm <storm@cua.dk>
parents: 56258
diff changeset
368 (list
55764
25f133a490aa (gdb-var-update, gdb-var-update-handler, gdb-var-delete)
Nick Roberts <nickrob@snap.net.nz>
parents: 55762
diff changeset
369 (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
370 "server interpreter mi \"-var-update *\"\n"
25f133a490aa (gdb-var-update, gdb-var-update-handler, gdb-var-delete)
Nick Roberts <nickrob@snap.net.nz>
parents: 55762
diff changeset
371 "-var-update *\n")
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
372 'gdb-var-update-handler))
55749
230865f1c59d (gdb-server-prefix): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 55696
diff changeset
373 (push 'gdb-var-update gdb-pending-triggers))))
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
374
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
375 (defconst gdb-var-update-regexp "name=\"\\(.*?\\)\"")
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
376
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
377 (defun gdb-var-update-handler ()
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
378 (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
379 (goto-char (point-min))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
380 (while (re-search-forward gdb-var-update-regexp nil t)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
381 (let ((varnum (match-string 1)))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
382 (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
383 (list
25f133a490aa (gdb-var-update, gdb-var-update-handler, gdb-var-delete)
Nick Roberts <nickrob@snap.net.nz>
parents: 55762
diff changeset
384 (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
385 (concat "server interpreter mi \"-var-evaluate-expression "
25f133a490aa (gdb-var-update, gdb-var-update-handler, gdb-var-delete)
Nick Roberts <nickrob@snap.net.nz>
parents: 55762
diff changeset
386 varnum "\"\n")
25f133a490aa (gdb-var-update, gdb-var-update-handler, gdb-var-delete)
Nick Roberts <nickrob@snap.net.nz>
parents: 55762
diff changeset
387 (concat "-var-evaluate-expression " varnum "\n"))
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
388 `(lambda () (gdb-var-evaluate-expression-handler
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
389 ,varnum t)))))))
55749
230865f1c59d (gdb-server-prefix): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 55696
diff changeset
390 (setq gdb-pending-triggers
230865f1c59d (gdb-server-prefix): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 55696
diff changeset
391 (delq 'gdb-var-update gdb-pending-triggers)))
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
392
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
393 (defun gdb-var-delete ()
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
394 "Delete watched expression from the speedbar."
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
395 (interactive)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
396 (if (with-current-buffer gud-comint-buffer (eq gud-minor-mode 'gdba))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
397 (let ((text (speedbar-line-text)))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
398 (string-match "\\(\\S-+\\)" text)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
399 (let* ((expr (match-string 1 text))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
400 (var (assoc expr gdb-var-list))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
401 (varnum (cadr var)))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
402 (unless (string-match "\\." varnum)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
403 (gdb-enqueue-input
56285
313e3a9f34ca (breakpoint-enabled-bitmap-face)
Kim F. Storm <storm@cua.dk>
parents: 56258
diff changeset
404 (list
55764
25f133a490aa (gdb-var-update, gdb-var-update-handler, gdb-var-delete)
Nick Roberts <nickrob@snap.net.nz>
parents: 55762
diff changeset
405 (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
406 (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
407 (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
408 (concat "-var-delete " varnum "\n"))
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
409 'ignore))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
410 (setq gdb-var-list (delq var gdb-var-list))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
411 (dolist (varchild gdb-var-list)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
412 (if (string-match (concat (nth 1 var) "\\.") (nth 1 varchild))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
413 (setq gdb-var-list (delq varchild gdb-var-list))))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
414 (setq gdb-var-changed t))))))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
415
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
416 (defun gdb-edit-value (text token indent)
57791
d1b93fc4ce47 Docstring fixes.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57664
diff changeset
417 "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
418 (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
419 (varnum (cadr var)) (value))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
420 (setq value (read-string "New value: "))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
421 (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
422 (list
25f133a490aa (gdb-var-update, gdb-var-update-handler, gdb-var-delete)
Nick Roberts <nickrob@snap.net.nz>
parents: 55762
diff changeset
423 (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
424 (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
425 (concat "server interpreter mi \"-var-assign " varnum " " value "\"\n")
25f133a490aa (gdb-var-update, gdb-var-update-handler, gdb-var-delete)
Nick Roberts <nickrob@snap.net.nz>
parents: 55762
diff changeset
426 (concat "-var-assign " varnum " " value "\n"))
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
427 'ignore))))
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 (defcustom gdb-show-changed-values t
57791
d1b93fc4ce47 Docstring fixes.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57664
diff changeset
430 "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
431 The highlighting is done with `font-lock-warning-face'."
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
432 :type 'boolean
58049
fd0093bd412a (gdb-current-stack-level): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 57982
diff changeset
433 :group 'gud
fd0093bd412a (gdb-current-stack-level): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 57982
diff changeset
434 :version "21.4")
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
435
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
436 (defun gdb-speedbar-expand-node (text token indent)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
437 "Expand the node the user clicked on.
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
438 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
439 TOKEN is data related to this node.
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
440 INDENT is the current indentation depth."
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
441 (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
442 (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
443 (gdb-var-list-children token)
25f133a490aa (gdb-var-update, gdb-var-update-handler, gdb-var-delete)
Nick Roberts <nickrob@snap.net.nz>
parents: 55762
diff changeset
444 (gdbmi-var-list-children token)))
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
445 ((string-match "-" text) ;contract this node
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
446 (dolist (var gdb-var-list)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
447 (if (string-match (concat token "\\.") (nth 1 var))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
448 (setq gdb-var-list (delq var gdb-var-list))))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
449 (setq gdb-var-changed t))))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
450
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
451 (defun gdb-get-target-string ()
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
452 (with-current-buffer gud-comint-buffer
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
453 gud-target-name))
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
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
456 ;;
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
457 ;; gdb buffers.
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
458 ;;
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
459 ;; 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
460 ;; of that particular buffer.
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
461 ;;
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
462 ;; 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
463 ;; is constructed specially.
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
464 ;;
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
465 ;; Others are constructed by gdb-get-create-buffer and
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
466 ;; 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
467
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
468 (defvar gdb-buffer-rules-assoc '())
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
469
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
470 (defun gdb-get-buffer (key)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
471 "Return the gdb buffer tagged with type KEY.
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
472 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
473 (save-excursion
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
474 (gdb-look-for-tagged-buffer key (buffer-list))))
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 (defun gdb-get-create-buffer (key)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
477 "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
478 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
479 (or (gdb-get-buffer key)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
480 (let* ((rules (assoc key gdb-buffer-rules-assoc))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
481 (name (funcall (gdb-rules-name-maker rules)))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
482 (new (get-buffer-create name)))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
483 (with-current-buffer new
57661
b59713cd72a2 (gdb-get-create-buffer): Allow modes to run
Nick Roberts <nickrob@snap.net.nz>
parents: 57350
diff changeset
484 (let ((trigger))
b59713cd72a2 (gdb-get-create-buffer): Allow modes to run
Nick Roberts <nickrob@snap.net.nz>
parents: 57350
diff changeset
485 (if (cdr (cdr rules))
b59713cd72a2 (gdb-get-create-buffer): Allow modes to run
Nick Roberts <nickrob@snap.net.nz>
parents: 57350
diff changeset
486 (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
487 (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
488 (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
489 (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
490 (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
491 (if trigger (funcall trigger)))
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
492 new))))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
493
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
494 (defun gdb-rules-name-maker (rules) (car (cdr rules)))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
495
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
496 (defun gdb-look-for-tagged-buffer (key bufs)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
497 (let ((retval nil))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
498 (while (and (not retval) bufs)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
499 (set-buffer (car bufs))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
500 (if (eq gdb-buffer-type key)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
501 (setq retval (car bufs)))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
502 (setq bufs (cdr bufs)))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
503 retval))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
504
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
505 ;;
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
506 ;; 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
507 ;; 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
508 ;; roles in defining a buffer type:
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 ;; NAME - Return a name for this buffer type.
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
511 ;;
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
512 ;; The remaining function(s) are optional:
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
513 ;;
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
514 ;; 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
515 ;; the proper mode for the buffer.
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
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
518 (defun gdb-set-buffer-rules (buffer-type &rest rules)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
519 (let ((binding (assoc buffer-type gdb-buffer-rules-assoc)))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
520 (if binding
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
521 (setcdr binding rules)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
522 (push (cons buffer-type rules)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
523 gdb-buffer-rules-assoc))))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
524
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
525 ;; GUD buffers are an exception to the rules
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
526 (gdb-set-buffer-rules 'gdba 'error)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
527
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
528 ;;
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
529 ;; 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
530 ;; behalf of emacs (rather than the user).
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
531 ;;
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
532 (gdb-set-buffer-rules 'gdb-partial-output-buffer
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
533 'gdb-partial-output-name)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
534
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
535 (defun gdb-partial-output-name ()
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
536 (concat "*partial-output-"
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
537 (gdb-get-target-string)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
538 "*"))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
539
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
540
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
541 (gdb-set-buffer-rules 'gdb-inferior-io
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
542 'gdb-inferior-io-name
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
543 'gdb-inferior-io-mode)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
544
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
545 (defun gdb-inferior-io-name ()
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
546 (concat "*input/output of "
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
547 (gdb-get-target-string)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
548 "*"))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
549
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
550 (defvar gdb-inferior-io-mode-map
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
551 (let ((map (make-sparse-keymap)))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
552 (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
553 (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
554 (define-key map "\C-c\C-\\" 'gdb-inferior-io-quit)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
555 (define-key map "\C-c\C-d" 'gdb-inferior-io-eof)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
556 map))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
557
55749
230865f1c59d (gdb-server-prefix): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 55696
diff changeset
558 (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
559 "Major mode for gdb inferior-io."
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
560 :syntax-table nil :abbrev-table nil
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
561 ;; 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
562 ;; 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
563 ;; a dummy one.
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
564 (make-comint-in-buffer
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
565 (substring (buffer-name) 1 (- (length (buffer-name)) 1))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
566 (current-buffer) "hexl")
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
567 (setq comint-input-sender 'gdb-inferior-io-sender))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
568
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
569 (defun gdb-inferior-io-sender (proc string)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
570 ;; PROC is the pseudo-process created to satisfy comint.
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
571 (with-current-buffer (process-buffer proc)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
572 (setq proc (get-buffer-process gud-comint-buffer))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
573 (process-send-string proc string)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
574 (process-send-string proc "\n")))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
575
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
576 (defun gdb-inferior-io-interrupt ()
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
577 "Interrupt the program being debugged."
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
578 (interactive)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
579 (interrupt-process
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
580 (get-buffer-process gud-comint-buffer) comint-ptyp))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
581
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
582 (defun gdb-inferior-io-quit ()
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
583 "Send quit signal to the program being debugged."
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
584 (interactive)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
585 (quit-process
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
586 (get-buffer-process gud-comint-buffer) comint-ptyp))
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-inferior-io-stop ()
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
589 "Stop the program being debugged."
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
590 (interactive)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
591 (stop-process
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
592 (get-buffer-process gud-comint-buffer) comint-ptyp))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
593
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
594 (defun gdb-inferior-io-eof ()
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
595 "Send end-of-file to the program being debugged."
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
596 (interactive)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
597 (process-send-eof
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
598 (get-buffer-process gud-comint-buffer)))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
599
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
600
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
601 ;;
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
602 ;; gdb communications
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
603 ;;
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
604
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
605 ;; INPUT: things sent to gdb
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
606 ;;
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
607 ;; 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
608 ;; user-like input) or a list of the form:
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 ;; (INPUT-STRING HANDLER-FN)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
611 ;;
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
612 ;; 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
613 ;; 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
614 ;; commands autonomously.
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 ;; These lists are consumed tail first.
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
617 ;;
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 (defun gdb-send (proc string)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
620 "A comint send filter for gdb.
57791
d1b93fc4ce47 Docstring fixes.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57664
diff changeset
621 This filter may simply queue input for a later time."
54729
7bfccd78beed (gdb-use-inferior-io-buffer): New option.
Nick Roberts <nickrob@snap.net.nz>
parents: 54668
diff changeset
622 (if gud-running
7bfccd78beed (gdb-use-inferior-io-buffer): New option.
Nick Roberts <nickrob@snap.net.nz>
parents: 54668
diff changeset
623 (process-send-string proc (concat string "\n"))
7bfccd78beed (gdb-use-inferior-io-buffer): New option.
Nick Roberts <nickrob@snap.net.nz>
parents: 54668
diff changeset
624 (gdb-enqueue-input (concat string "\n"))))
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
625
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
626 ;; 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
627 ;; is a query, or other non-top-level prompt.
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
628
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
629 (defun gdb-enqueue-input (item)
55749
230865f1c59d (gdb-server-prefix): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 55696
diff changeset
630 (if gdb-prompting
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
631 (progn
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
632 (gdb-send-item item)
55749
230865f1c59d (gdb-server-prefix): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 55696
diff changeset
633 (setq gdb-prompting nil))
230865f1c59d (gdb-server-prefix): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 55696
diff changeset
634 (push item gdb-input-queue)))
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
635
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
636 (defun gdb-dequeue-input ()
55749
230865f1c59d (gdb-server-prefix): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 55696
diff changeset
637 (let ((queue gdb-input-queue))
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
638 (and queue
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
639 (let ((last (car (last queue))))
55749
230865f1c59d (gdb-server-prefix): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 55696
diff changeset
640 (unless (nbutlast queue) (setq gdb-input-queue '()))
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
641 last))))
58420
97e4fc5c7297 (gdb-resync): New function.
Nick Roberts <nickrob@snap.net.nz>
parents: 58049
diff changeset
642
97e4fc5c7297 (gdb-resync): New function.
Nick Roberts <nickrob@snap.net.nz>
parents: 58049
diff changeset
643 (defun gdb-send-item (item)
58431
da65edef151e (gdb-flush-pending-output): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 58420
diff changeset
644 (setq gdb-flush-pending-output nil)
58420
97e4fc5c7297 (gdb-resync): New function.
Nick Roberts <nickrob@snap.net.nz>
parents: 58049
diff changeset
645 (if gdb-enable-debug-log (push (cons 'send item) gdb-debug-log))
97e4fc5c7297 (gdb-resync): New function.
Nick Roberts <nickrob@snap.net.nz>
parents: 58049
diff changeset
646 (setq gdb-current-item item)
97e4fc5c7297 (gdb-resync): New function.
Nick Roberts <nickrob@snap.net.nz>
parents: 58049
diff changeset
647 (with-current-buffer gud-comint-buffer
97e4fc5c7297 (gdb-resync): New function.
Nick Roberts <nickrob@snap.net.nz>
parents: 58049
diff changeset
648 (if (eq gud-minor-mode 'gdba)
97e4fc5c7297 (gdb-resync): New function.
Nick Roberts <nickrob@snap.net.nz>
parents: 58049
diff changeset
649 (if (stringp item)
97e4fc5c7297 (gdb-resync): New function.
Nick Roberts <nickrob@snap.net.nz>
parents: 58049
diff changeset
650 (progn
97e4fc5c7297 (gdb-resync): New function.
Nick Roberts <nickrob@snap.net.nz>
parents: 58049
diff changeset
651 (setq gdb-output-sink 'user)
97e4fc5c7297 (gdb-resync): New function.
Nick Roberts <nickrob@snap.net.nz>
parents: 58049
diff changeset
652 (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
653 (progn
97e4fc5c7297 (gdb-resync): New function.
Nick Roberts <nickrob@snap.net.nz>
parents: 58049
diff changeset
654 (gdb-clear-partial-output)
97e4fc5c7297 (gdb-resync): New function.
Nick Roberts <nickrob@snap.net.nz>
parents: 58049
diff changeset
655 (setq gdb-output-sink 'pre-emacs)
97e4fc5c7297 (gdb-resync): New function.
Nick Roberts <nickrob@snap.net.nz>
parents: 58049
diff changeset
656 (process-send-string (get-buffer-process gud-comint-buffer)
97e4fc5c7297 (gdb-resync): New function.
Nick Roberts <nickrob@snap.net.nz>
parents: 58049
diff changeset
657 (car item))))
97e4fc5c7297 (gdb-resync): New function.
Nick Roberts <nickrob@snap.net.nz>
parents: 58049
diff changeset
658 ;; case: eq gud-minor-mode 'gdbmi
97e4fc5c7297 (gdb-resync): New function.
Nick Roberts <nickrob@snap.net.nz>
parents: 58049
diff changeset
659 (gdb-clear-partial-output)
97e4fc5c7297 (gdb-resync): New function.
Nick Roberts <nickrob@snap.net.nz>
parents: 58049
diff changeset
660 (setq gdb-output-sink 'emacs)
97e4fc5c7297 (gdb-resync): New function.
Nick Roberts <nickrob@snap.net.nz>
parents: 58049
diff changeset
661 (process-send-string (get-buffer-process gud-comint-buffer)
97e4fc5c7297 (gdb-resync): New function.
Nick Roberts <nickrob@snap.net.nz>
parents: 58049
diff changeset
662 (car item)))))
54538
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 ;;
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
665 ;; output -- things gdb prints to emacs
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
666 ;;
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
667 ;; GDB output is a stream interrupted by annotations.
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
668 ;; Annotations can be recognized by their beginning
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
669 ;; 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
670 ;;
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
671 ;; The tag is a string obeying symbol syntax.
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
672 ;;
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
673 ;; The optional part `<opt>' can be either the empty string
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
674 ;; 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
675 ;; For example, the SOURCE annotation is followed by a filename,
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
676 ;; 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
677 ;; any newlines.
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
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
680 (defcustom gud-gdba-command-name "gdb -annotate=3"
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
681 "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
682 :type 'string
57851
67b88e92a24d (gdb-enable-debug-log)
Nick Roberts <nickrob@snap.net.nz>
parents: 57791
diff changeset
683 :group 'gud
67b88e92a24d (gdb-enable-debug-log)
Nick Roberts <nickrob@snap.net.nz>
parents: 57791
diff changeset
684 :version "21.4")
54538
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 (defvar gdb-annotation-rules
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
687 '(("pre-prompt" gdb-pre-prompt)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
688 ("prompt" gdb-prompt)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
689 ("commands" gdb-subprompt)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
690 ("overload-choice" gdb-subprompt)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
691 ("query" gdb-subprompt)
55749
230865f1c59d (gdb-server-prefix): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 55696
diff changeset
692 ;; 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
693 ("nquery" gdb-subprompt)
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
694 ("prompt-for-continue" gdb-subprompt)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
695 ("post-prompt" gdb-post-prompt)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
696 ("source" gdb-source)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
697 ("starting" gdb-starting)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
698 ("exited" gdb-stopping)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
699 ("signalled" gdb-stopping)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
700 ("signal" gdb-stopping)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
701 ("breakpoint" gdb-stopping)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
702 ("watchpoint" gdb-stopping)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
703 ("frame-begin" gdb-frame-begin)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
704 ("stopped" gdb-stopped)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
705 ) "An assoc mapping annotation tags to functions which process them.")
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
706
58420
97e4fc5c7297 (gdb-resync): New function.
Nick Roberts <nickrob@snap.net.nz>
parents: 58049
diff changeset
707 (defun gdb-resync()
58431
da65edef151e (gdb-flush-pending-output): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 58420
diff changeset
708 (setq gdb-flush-pending-output t)
58420
97e4fc5c7297 (gdb-resync): New function.
Nick Roberts <nickrob@snap.net.nz>
parents: 58049
diff changeset
709 (setq gud-running nil)
97e4fc5c7297 (gdb-resync): New function.
Nick Roberts <nickrob@snap.net.nz>
parents: 58049
diff changeset
710 (setq gdb-output-sink 'user)
97e4fc5c7297 (gdb-resync): New function.
Nick Roberts <nickrob@snap.net.nz>
parents: 58049
diff changeset
711 (setq gdb-input-queue nil)
97e4fc5c7297 (gdb-resync): New function.
Nick Roberts <nickrob@snap.net.nz>
parents: 58049
diff changeset
712 (setq gdb-pending-triggers nil)
97e4fc5c7297 (gdb-resync): New function.
Nick Roberts <nickrob@snap.net.nz>
parents: 58049
diff changeset
713 (setq gdb-prompting t))
97e4fc5c7297 (gdb-resync): New function.
Nick Roberts <nickrob@snap.net.nz>
parents: 58049
diff changeset
714
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
715 (defconst gdb-source-spec-regexp
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
716 "\\(.*\\):\\([0-9]*\\):[0-9]*:[a-z]*:\\(0x[a-f0-9]*\\)")
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
717
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
718 ;; Do not use this except as an annotation handler.
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
719 (defun gdb-source (args)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
720 (string-match gdb-source-spec-regexp args)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
721 ;; Extract the frame position from the marker.
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
722 (setq gud-last-frame
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
723 (cons
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
724 (match-string 1 args)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
725 (string-to-int (match-string 2 args))))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
726 (setq gdb-current-address (match-string 3 args))
54962
c3272c09f927 (gdb-goto-info): Require 'info.
Nick Roberts <nickrob@snap.net.nz>
parents: 54901
diff changeset
727 ;; cover for auto-display output which comes *before*
c3272c09f927 (gdb-goto-info): Require 'info.
Nick Roberts <nickrob@snap.net.nz>
parents: 54901
diff changeset
728 ;; stopped annotation
55749
230865f1c59d (gdb-server-prefix): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 55696
diff changeset
729 (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
730
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
731 (defun gdb-pre-prompt (ignored)
57791
d1b93fc4ce47 Docstring fixes.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57664
diff changeset
732 "An annotation handler for `pre-prompt'.
d1b93fc4ce47 Docstring fixes.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57664
diff changeset
733 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
734 happens to be in effect."
55749
230865f1c59d (gdb-server-prefix): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 55696
diff changeset
735 (let ((sink gdb-output-sink))
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
736 (cond
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
737 ((eq sink 'user) t)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
738 ((eq sink 'emacs)
55749
230865f1c59d (gdb-server-prefix): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 55696
diff changeset
739 (setq gdb-output-sink 'post-emacs))
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
740 (t
58420
97e4fc5c7297 (gdb-resync): New function.
Nick Roberts <nickrob@snap.net.nz>
parents: 58049
diff changeset
741 (gdb-resync)
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
742 (error "Phase error in gdb-pre-prompt (got %s)" sink)))))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
743
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
744 (defun gdb-prompt (ignored)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
745 "An annotation handler for `prompt'.
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
746 This sends the next command (if any) to gdb."
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
747 (when gdb-first-prompt (gdb-ann3))
55749
230865f1c59d (gdb-server-prefix): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 55696
diff changeset
748 (let ((sink gdb-output-sink))
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
749 (cond
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
750 ((eq sink 'user) t)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
751 ((eq sink 'post-emacs)
55749
230865f1c59d (gdb-server-prefix): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 55696
diff changeset
752 (setq gdb-output-sink 'user)
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
753 (let ((handler
55749
230865f1c59d (gdb-server-prefix): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 55696
diff changeset
754 (car (cdr gdb-current-item))))
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
755 (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
756 (funcall handler))))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
757 (t
58420
97e4fc5c7297 (gdb-resync): New function.
Nick Roberts <nickrob@snap.net.nz>
parents: 58049
diff changeset
758 (gdb-resync)
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
759 (error "Phase error in gdb-prompt (got %s)" sink))))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
760 (let ((input (gdb-dequeue-input)))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
761 (if input
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
762 (gdb-send-item input)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
763 (progn
55749
230865f1c59d (gdb-server-prefix): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 55696
diff changeset
764 (setq gdb-prompting t)
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
765 (gud-display-frame)))))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
766
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
767 (defun gdb-subprompt (ignored)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
768 "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
769 (setq gdb-prompting t))
54538
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-starting (ignored)
57791
d1b93fc4ce47 Docstring fixes.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57664
diff changeset
772 "An annotation handler for `starting'.
d1b93fc4ce47 Docstring fixes.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57664
diff changeset
773 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
774 not GDB."
55749
230865f1c59d (gdb-server-prefix): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 55696
diff changeset
775 (let ((sink gdb-output-sink))
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
776 (cond
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
777 ((eq sink 'user)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
778 (progn
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
779 (setq gud-running t)
54729
7bfccd78beed (gdb-use-inferior-io-buffer): New option.
Nick Roberts <nickrob@snap.net.nz>
parents: 54668
diff changeset
780 (if gdb-use-inferior-io-buffer
55749
230865f1c59d (gdb-server-prefix): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 55696
diff changeset
781 (setq gdb-output-sink 'inferior))))
58420
97e4fc5c7297 (gdb-resync): New function.
Nick Roberts <nickrob@snap.net.nz>
parents: 58049
diff changeset
782 (t
97e4fc5c7297 (gdb-resync): New function.
Nick Roberts <nickrob@snap.net.nz>
parents: 58049
diff changeset
783 (gdb-resync)
97e4fc5c7297 (gdb-resync): New function.
Nick Roberts <nickrob@snap.net.nz>
parents: 58049
diff changeset
784 (error "Unexpected `starting' annotation")))))
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
785
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
786 (defun gdb-stopping (ignored)
57791
d1b93fc4ce47 Docstring fixes.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57664
diff changeset
787 "An annotation handler for `exited' and other annotations.
d1b93fc4ce47 Docstring fixes.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57664
diff changeset
788 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
789 being debugged."
54729
7bfccd78beed (gdb-use-inferior-io-buffer): New option.
Nick Roberts <nickrob@snap.net.nz>
parents: 54668
diff changeset
790 (if gdb-use-inferior-io-buffer
55749
230865f1c59d (gdb-server-prefix): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 55696
diff changeset
791 (let ((sink gdb-output-sink))
54729
7bfccd78beed (gdb-use-inferior-io-buffer): New option.
Nick Roberts <nickrob@snap.net.nz>
parents: 54668
diff changeset
792 (cond
7bfccd78beed (gdb-use-inferior-io-buffer): New option.
Nick Roberts <nickrob@snap.net.nz>
parents: 54668
diff changeset
793 ((eq sink 'inferior)
55749
230865f1c59d (gdb-server-prefix): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 55696
diff changeset
794 (setq gdb-output-sink 'user))
58420
97e4fc5c7297 (gdb-resync): New function.
Nick Roberts <nickrob@snap.net.nz>
parents: 58049
diff changeset
795 (t
97e4fc5c7297 (gdb-resync): New function.
Nick Roberts <nickrob@snap.net.nz>
parents: 58049
diff changeset
796 (gdb-resync)
97e4fc5c7297 (gdb-resync): New function.
Nick Roberts <nickrob@snap.net.nz>
parents: 58049
diff changeset
797 (error "Unexpected stopping annotation"))))))
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
798
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
799 (defun gdb-frame-begin (ignored)
55749
230865f1c59d (gdb-server-prefix): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 55696
diff changeset
800 (let ((sink gdb-output-sink))
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
801 (cond
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
802 ((eq sink 'inferior)
55749
230865f1c59d (gdb-server-prefix): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 55696
diff changeset
803 (setq gdb-output-sink 'user))
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
804 ((eq sink 'user) t)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
805 ((eq sink 'emacs) t)
58420
97e4fc5c7297 (gdb-resync): New function.
Nick Roberts <nickrob@snap.net.nz>
parents: 58049
diff changeset
806 (t
97e4fc5c7297 (gdb-resync): New function.
Nick Roberts <nickrob@snap.net.nz>
parents: 58049
diff changeset
807 (gdb-resync)
97e4fc5c7297 (gdb-resync): New function.
Nick Roberts <nickrob@snap.net.nz>
parents: 58049
diff changeset
808 (error "Unexpected frame-begin annotation (%S)" sink)))))
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
809
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
810 (defun gdb-stopped (ignored)
57791
d1b93fc4ce47 Docstring fixes.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57664
diff changeset
811 "An annotation handler for `stopped'.
d1b93fc4ce47 Docstring fixes.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57664
diff changeset
812 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
813 sink to `user' in `gdb-stopping', that is fine."
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
814 (setq gud-running nil)
55749
230865f1c59d (gdb-server-prefix): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 55696
diff changeset
815 (let ((sink gdb-output-sink))
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
816 (cond
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
817 ((eq sink 'inferior)
55749
230865f1c59d (gdb-server-prefix): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 55696
diff changeset
818 (setq gdb-output-sink 'user))
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
819 ((eq sink 'user) t)
58420
97e4fc5c7297 (gdb-resync): New function.
Nick Roberts <nickrob@snap.net.nz>
parents: 58049
diff changeset
820 (t
97e4fc5c7297 (gdb-resync): New function.
Nick Roberts <nickrob@snap.net.nz>
parents: 58049
diff changeset
821 (gdb-resync)
97e4fc5c7297 (gdb-resync): New function.
Nick Roberts <nickrob@snap.net.nz>
parents: 58049
diff changeset
822 (error "Unexpected stopped annotation")))))
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
823
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
824 (defun gdb-post-prompt (ignored)
57791
d1b93fc4ce47 Docstring fixes.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57664
diff changeset
825 "An annotation handler for `post-prompt'.
d1b93fc4ce47 Docstring fixes.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57664
diff changeset
826 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
827 happens to be appropriate."
55749
230865f1c59d (gdb-server-prefix): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 55696
diff changeset
828 (if (not gdb-pending-triggers)
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
829 (progn
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
830 (gdb-get-current-frame)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
831 (gdb-invalidate-frames)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
832 (gdb-invalidate-breakpoints)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
833 (gdb-invalidate-assembler)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
834 (gdb-invalidate-registers)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
835 (gdb-invalidate-locals)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
836 (gdb-invalidate-threads)
54617
9049edac1117 (gdb-post-prompt): Fix test.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 54616
diff changeset
837 (unless (eq system-type 'darwin) ;Breaks on Darwin's GDB-5.3.
9049edac1117 (gdb-post-prompt): Fix test.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 54616
diff changeset
838 ;; FIXME: with GDB-6 on Darwin, this might very well work.
54616
47c4cb867a84 (gdb-ann3, gdb-send-item)
Nick Roberts <nickrob@snap.net.nz>
parents: 54538
diff changeset
839 (dolist (frame (frame-list))
47c4cb867a84 (gdb-ann3, gdb-send-item)
Nick Roberts <nickrob@snap.net.nz>
parents: 54538
diff changeset
840 (when (string-equal (frame-parameter frame 'name) "Speedbar")
47c4cb867a84 (gdb-ann3, gdb-send-item)
Nick Roberts <nickrob@snap.net.nz>
parents: 54538
diff changeset
841 (setq gdb-var-changed t) ; force update
47c4cb867a84 (gdb-ann3, gdb-send-item)
Nick Roberts <nickrob@snap.net.nz>
parents: 54538
diff changeset
842 (dolist (var gdb-var-list)
47c4cb867a84 (gdb-ann3, gdb-send-item)
Nick Roberts <nickrob@snap.net.nz>
parents: 54538
diff changeset
843 (setcar (nthcdr 5 var) nil))))
47c4cb867a84 (gdb-ann3, gdb-send-item)
Nick Roberts <nickrob@snap.net.nz>
parents: 54538
diff changeset
844 (gdb-var-update))))
55749
230865f1c59d (gdb-server-prefix): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 55696
diff changeset
845 (let ((sink gdb-output-sink))
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
846 (cond
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
847 ((eq sink 'user) t)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
848 ((eq sink 'pre-emacs)
55749
230865f1c59d (gdb-server-prefix): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 55696
diff changeset
849 (setq gdb-output-sink 'emacs))
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
850 (t
58420
97e4fc5c7297 (gdb-resync): New function.
Nick Roberts <nickrob@snap.net.nz>
parents: 58049
diff changeset
851 (gdb-resync)
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
852 (error "Phase error in gdb-post-prompt (got %s)" sink)))))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
853
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
854 (defun gud-gdba-marker-filter (string)
57791
d1b93fc4ce47 Docstring fixes.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57664
diff changeset
855 "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
856 (if gdb-flush-pending-output
da65edef151e (gdb-flush-pending-output): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 58420
diff changeset
857 nil
da65edef151e (gdb-flush-pending-output): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 58420
diff changeset
858 (if gdb-enable-debug-log (push (cons 'recv string) gdb-debug-log))
da65edef151e (gdb-flush-pending-output): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 58420
diff changeset
859 ;; Recall the left over gud-marker-acc from last time
da65edef151e (gdb-flush-pending-output): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 58420
diff changeset
860 (setq gud-marker-acc (concat gud-marker-acc string))
da65edef151e (gdb-flush-pending-output): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 58420
diff changeset
861 ;; Start accumulating output for the GUD buffer
da65edef151e (gdb-flush-pending-output): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 58420
diff changeset
862 (let ((output ""))
da65edef151e (gdb-flush-pending-output): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 58420
diff changeset
863 ;;
da65edef151e (gdb-flush-pending-output): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 58420
diff changeset
864 ;; 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
865 (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
866 (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
867 ;;
da65edef151e (gdb-flush-pending-output): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 58420
diff changeset
868 ;; 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
869 ;; 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
870 ;; elsewhere.
da65edef151e (gdb-flush-pending-output): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 58420
diff changeset
871 (setq output
da65edef151e (gdb-flush-pending-output): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 58420
diff changeset
872 (gdb-concat-output
da65edef151e (gdb-flush-pending-output): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 58420
diff changeset
873 output
da65edef151e (gdb-flush-pending-output): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 58420
diff changeset
874 (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
875 ;;
da65edef151e (gdb-flush-pending-output): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 58420
diff changeset
876 ;; 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
877 (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
878 ;;
da65edef151e (gdb-flush-pending-output): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 58420
diff changeset
879 ;; 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
880 (string-match "\\(\\S-*\\) ?\\(.*\\)" annotation)
da65edef151e (gdb-flush-pending-output): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 58420
diff changeset
881 (let* ((annotation-type (match-string 1 annotation))
da65edef151e (gdb-flush-pending-output): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 58420
diff changeset
882 (annotation-arguments (match-string 2 annotation))
da65edef151e (gdb-flush-pending-output): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 58420
diff changeset
883 (annotation-rule (assoc annotation-type
da65edef151e (gdb-flush-pending-output): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 58420
diff changeset
884 gdb-annotation-rules)))
da65edef151e (gdb-flush-pending-output): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 58420
diff changeset
885 ;; Call the handler for this annotation.
da65edef151e (gdb-flush-pending-output): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 58420
diff changeset
886 (if annotation-rule
da65edef151e (gdb-flush-pending-output): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 58420
diff changeset
887 (funcall (car (cdr annotation-rule))
da65edef151e (gdb-flush-pending-output): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 58420
diff changeset
888 annotation-arguments)
da65edef151e (gdb-flush-pending-output): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 58420
diff changeset
889 ;; 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
890 ;; 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
891 ;; us to blow up.
da65edef151e (gdb-flush-pending-output): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 58420
diff changeset
892 ))))
da65edef151e (gdb-flush-pending-output): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 58420
diff changeset
893 ;;
da65edef151e (gdb-flush-pending-output): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 58420
diff changeset
894 ;; 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
895 ;; 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
896 (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
897 gud-marker-acc)
da65edef151e (gdb-flush-pending-output): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 58420
diff changeset
898 (progn
da65edef151e (gdb-flush-pending-output): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 58420
diff changeset
899 ;; 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
900 (setq output
da65edef151e (gdb-flush-pending-output): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 58420
diff changeset
901 (gdb-concat-output output
da65edef151e (gdb-flush-pending-output): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 58420
diff changeset
902 (substring gud-marker-acc 0
da65edef151e (gdb-flush-pending-output): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 58420
diff changeset
903 (match-beginning 0))))
da65edef151e (gdb-flush-pending-output): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 58420
diff changeset
904 ;;
da65edef151e (gdb-flush-pending-output): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 58420
diff changeset
905 ;; Everything after, we save, to combine with later input.
da65edef151e (gdb-flush-pending-output): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 58420
diff changeset
906 (setq gud-marker-acc (substring gud-marker-acc (match-beginning 0))))
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
907 ;;
58431
da65edef151e (gdb-flush-pending-output): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 58420
diff changeset
908 ;; 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
909 (progn
58431
da65edef151e (gdb-flush-pending-output): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 58420
diff changeset
910 (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
911 (setq gud-marker-acc "")))
da65edef151e (gdb-flush-pending-output): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 58420
diff changeset
912 output)))
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
913
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
914 (defun gdb-concat-output (so-far new)
55749
230865f1c59d (gdb-server-prefix): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 55696
diff changeset
915 (let ((sink gdb-output-sink))
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
916 (cond
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
917 ((eq sink 'user) (concat so-far new))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
918 ((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
919 ((eq sink 'emacs)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
920 (gdb-append-to-partial-output new)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
921 so-far)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
922 ((eq sink 'inferior)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
923 (gdb-append-to-inferior-io new)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
924 so-far)
58420
97e4fc5c7297 (gdb-resync): New function.
Nick Roberts <nickrob@snap.net.nz>
parents: 58049
diff changeset
925 (t
97e4fc5c7297 (gdb-resync): New function.
Nick Roberts <nickrob@snap.net.nz>
parents: 58049
diff changeset
926 (gdb-resync)
97e4fc5c7297 (gdb-resync): New function.
Nick Roberts <nickrob@snap.net.nz>
parents: 58049
diff changeset
927 (error "Bogon output sink %S" sink)))))
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
928
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
929 (defun gdb-append-to-partial-output (string)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
930 (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
931 (goto-char (point-max))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
932 (insert string)))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
933
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
934 (defun gdb-clear-partial-output ()
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
935 (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
936 (erase-buffer)))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
937
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
938 (defun gdb-append-to-inferior-io (string)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
939 (with-current-buffer (gdb-get-create-buffer 'gdb-inferior-io)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
940 (goto-char (point-max))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
941 (insert-before-markers string))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
942 (if (not (string-equal string ""))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
943 (gdb-display-buffer (gdb-get-create-buffer 'gdb-inferior-io))))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
944
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
945 (defun gdb-clear-inferior-io ()
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
946 (with-current-buffer (gdb-get-create-buffer 'gdb-inferior-io)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
947 (erase-buffer)))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
948
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
949
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
950 ;; 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
951 ;; 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
952 ;; type.
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
953 ;;
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
954 ;; 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
955 ;; 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
956 ;; behind the user's back.
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
957 ;;
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
958 ;; The output phasing associated with the variable gdb-output-sink
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
959 ;; help us to run commands behind the user's back.
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
960 ;;
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
961 ;; 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
962 ;; command.
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
963 ;;
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
964
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
965 ;; 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
966 ;; 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
967 ;; 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
968 ;; might have changed it's output.
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
969 ;;
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
970 ;; NAME is the function name. DEMAND-PREDICATE tests if output is really needed.
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
971 ;; 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
972 ;; 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
973
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
974 (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
975 output-handler)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
976 `(defun ,name (&optional ignored)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
977 (if (and (,demand-predicate)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
978 (not (member ',name
55749
230865f1c59d (gdb-server-prefix): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 55696
diff changeset
979 gdb-pending-triggers)))
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
980 (progn
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
981 (gdb-enqueue-input
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
982 (list ,gdb-command ',output-handler))
55749
230865f1c59d (gdb-server-prefix): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 55696
diff changeset
983 (push ',name gdb-pending-triggers)))))
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
984
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
985 (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
986 `(defun ,name ()
55749
230865f1c59d (gdb-server-prefix): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 55696
diff changeset
987 (setq gdb-pending-triggers
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
988 (delq ',trigger
55749
230865f1c59d (gdb-server-prefix): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 55696
diff changeset
989 gdb-pending-triggers))
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
990 (let ((buf (gdb-get-buffer ',buf-key)))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
991 (and buf
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
992 (with-current-buffer buf
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
993 (let ((p (point))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
994 (buffer-read-only nil))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
995 (erase-buffer)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
996 (insert-buffer-substring (gdb-get-create-buffer
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
997 'gdb-partial-output-buffer))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
998 (goto-char p)))))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
999 ;; put customisation here
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1000 (,custom-defun)))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1001
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1002 (defmacro def-gdb-auto-updated-buffer (buffer-key trigger-name gdb-command
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1003 output-handler-name custom-defun)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1004 `(progn
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1005 (def-gdb-auto-update-trigger ,trigger-name
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1006 ;; The demand predicate:
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1007 (lambda () (gdb-get-buffer ',buffer-key))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1008 ,gdb-command
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1009 ,output-handler-name)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1010 (def-gdb-auto-update-handler ,output-handler-name
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1011 ,trigger-name ,buffer-key ,custom-defun)))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1012
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1013
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1014 ;;
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1015 ;; Breakpoint buffer : This displays the output of `info breakpoints'.
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1016 ;;
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1017 (gdb-set-buffer-rules 'gdb-breakpoints-buffer
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1018 'gdb-breakpoints-buffer-name
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1019 'gdb-breakpoints-mode)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1020
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1021 (def-gdb-auto-updated-buffer gdb-breakpoints-buffer
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1022 ;; This defines the auto update rule for buffers of type
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1023 ;; `gdb-breakpoints-buffer'.
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1024 ;;
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1025 ;; 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
1026 ;; handles the `foo-invalidated' message. That function is called:
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1027 gdb-invalidate-breakpoints
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1028 ;;
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1029 ;; To update the buffer, this command is sent to gdb.
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1030 "server info breakpoints\n"
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1031 ;;
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1032 ;; 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
1033 ;; 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
1034 ;; the appropriately typed buffer. That function will be called:
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1035 gdb-info-breakpoints-handler
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1036 ;; buffer specific functions
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1037 gdb-info-breakpoints-custom)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1038
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1039 (defvar gdb-cdir nil "Compilation directory.")
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1040
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1041 (defconst breakpoint-xpm-data "/* XPM */
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1042 static char *magick[] = {
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1043 /* columns rows colors chars-per-pixel */
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1044 \"10 10 2 1\",
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1045 \" c red\",
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1046 \"+ c None\",
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1047 /* pixels */
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1048 \"+++ +++\",
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1049 \"++ ++\",
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1050 \"+ +\",
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1051 \" \",
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 \" \",
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1054 \" \",
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1055 \"+ +\",
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1056 \"++ ++\",
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1057 \"+++ +++\",
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1058 };"
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1059 "XPM data used for breakpoint icon.")
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1060
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1061 (defconst breakpoint-enabled-pbm-data
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1062 "P1
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1063 10 10\",
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1064 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
1065 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
1066 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
1067 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
1068 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
1069 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
1070 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
1071 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
1072 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
1073 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
1074 "PBM data used for enabled breakpoint icon.")
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1075
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1076 (defconst breakpoint-disabled-pbm-data
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1077 "P1
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1078 10 10\",
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1079 0 0 1 0 1 0 1 0 0 0
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1080 0 1 0 1 0 1 0 1 0 0
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1081 1 0 1 0 1 0 1 0 1 0
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1082 0 1 0 1 0 1 0 1 0 1
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1083 1 0 1 0 1 0 1 0 1 0
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1084 0 1 0 1 0 1 0 1 0 1
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1085 1 0 1 0 1 0 1 0 1 0
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1086 0 1 0 1 0 1 0 1 0 1
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1087 0 0 1 0 1 0 1 0 1 0
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1088 0 0 0 1 0 1 0 1 0 0"
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1089 "PBM data used for disabled breakpoint icon.")
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1090
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1091 (defvar breakpoint-enabled-icon nil
57791
d1b93fc4ce47 Docstring fixes.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57664
diff changeset
1092 "Icon for enabled breakpoint in display margin.")
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1093
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1094 (defvar breakpoint-disabled-icon nil
57791
d1b93fc4ce47 Docstring fixes.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57664
diff changeset
1095 "Icon for disabled breakpoint in display margin.")
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1096
57262
df4b0ff293d8 (breakpoint): Define as fringe bitmap.
Kim F. Storm <storm@cua.dk>
parents: 56330
diff changeset
1097 ;; 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
1098 (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
1099 (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
1100 "\x3c\x7e\xff\xff\xff\xff\x7e\x3c"))
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1101
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1102 (defface breakpoint-enabled-bitmap-face
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1103 '((t
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1104 :inherit fringe
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1105 :foreground "red"))
56285
313e3a9f34ca (breakpoint-enabled-bitmap-face)
Kim F. Storm <storm@cua.dk>
parents: 56258
diff changeset
1106 "Face for enabled breakpoint icon in fringe."
313e3a9f34ca (breakpoint-enabled-bitmap-face)
Kim F. Storm <storm@cua.dk>
parents: 56258
diff changeset
1107 :group 'gud)
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1108
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1109 (defface breakpoint-disabled-bitmap-face
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1110 '((t
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1111 :inherit fringe
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1112 :foreground "grey60"))
56285
313e3a9f34ca (breakpoint-enabled-bitmap-face)
Kim F. Storm <storm@cua.dk>
parents: 56258
diff changeset
1113 "Face for disabled breakpoint icon in fringe."
313e3a9f34ca (breakpoint-enabled-bitmap-face)
Kim F. Storm <storm@cua.dk>
parents: 56258
diff changeset
1114 :group 'gud)
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1115
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1116
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1117 ;;-put breakpoint icons in relevant margins (even those set in the GUD buffer)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1118 (defun gdb-info-breakpoints-custom ()
58485
31d7630f91d4 (gdb-breakpoints-mode-map)
Nick Roberts <nickrob@snap.net.nz>
parents: 58470
diff changeset
1119 (let ((flag))
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1120 ;;
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1121 ;; remove all breakpoint-icons in source buffers but not assembler buffer
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1122 (dolist (buffer (buffer-list))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1123 (with-current-buffer buffer
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1124 (if (and (eq gud-minor-mode 'gdba)
55749
230865f1c59d (gdb-server-prefix): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 55696
diff changeset
1125 (not (string-match "\\`\\*.+\\*\\'" (buffer-name))))
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1126 (gdb-remove-breakpoint-icons (point-min) (point-max)))))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1127 (with-current-buffer (gdb-get-buffer 'gdb-breakpoints-buffer)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1128 (save-excursion
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1129 (goto-char (point-min))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1130 (while (< (point) (- (point-max) 1))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1131 (forward-line 1)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1132 (if (looking-at "[^\t].*breakpoint")
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1133 (progn
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1134 (looking-at "[0-9]*\\s-*\\S-*\\s-*\\S-*\\s-*\\(.\\)")
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1135 (setq flag (char-after (match-beginning 1)))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1136 (beginning-of-line)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1137 (if (re-search-forward "in\\s-+\\S-+\\s-+at\\s-+" nil t)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1138 (progn
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1139 (looking-at "\\(\\S-*\\):\\([0-9]+\\)")
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1140 (let ((line (match-string 2)) (buffer-read-only nil)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1141 (file (match-string 1)))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1142 (add-text-properties (point-at-bol) (point-at-eol)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1143 '(mouse-face highlight
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1144 help-echo "mouse-2, RET: visit breakpoint"))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1145 (with-current-buffer
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1146 (find-file-noselect
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1147 (if (file-exists-p file) file
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1148 (expand-file-name file gdb-cdir)))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1149 (save-current-buffer
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1150 (set (make-local-variable 'gud-minor-mode) 'gdba)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1151 (set (make-local-variable 'tool-bar-map)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1152 gud-tool-bar-map))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1153 ;; only want one breakpoint icon at each location
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1154 (save-excursion
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1155 (goto-line (string-to-number line))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1156 (gdb-put-breakpoint-icon (eq flag ?y)))))))))
54962
c3272c09f927 (gdb-goto-info): Require 'info.
Nick Roberts <nickrob@snap.net.nz>
parents: 54901
diff changeset
1157 (end-of-line)))))
c3272c09f927 (gdb-goto-info): Require 'info.
Nick Roberts <nickrob@snap.net.nz>
parents: 54901
diff changeset
1158 (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
1159
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1160 (defun gdb-mouse-toggle-breakpoint (event)
57791
d1b93fc4ce47 Docstring fixes.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57664
diff changeset
1161 "Toggle breakpoint in left fringe/margin with mouse click."
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1162 (interactive "e")
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1163 (mouse-minibuffer-check event)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1164 (let ((posn (event-end event)))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1165 (if (numberp (posn-point posn))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1166 (with-selected-window (posn-window posn)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1167 (save-excursion
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1168 (goto-char (posn-point posn))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1169 (if (or (posn-object posn)
57262
df4b0ff293d8 (breakpoint): Define as fringe bitmap.
Kim F. Storm <storm@cua.dk>
parents: 56330
diff changeset
1170 (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
1171 'breakpoint))
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1172 (gud-remove nil)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1173 (gud-break nil)))))))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1174
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1175 (defun gdb-breakpoints-buffer-name ()
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1176 (with-current-buffer gud-comint-buffer
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1177 (concat "*breakpoints of " (gdb-get-target-string) "*")))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1178
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1179 (defun gdb-display-breakpoints-buffer ()
55400
1aaa031e318c Improve/extend documentation strings.
Nick Roberts <nickrob@snap.net.nz>
parents: 55330
diff changeset
1180 "Display status of user-settable breakpoints."
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1181 (interactive)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1182 (gdb-display-buffer
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1183 (gdb-get-create-buffer 'gdb-breakpoints-buffer)))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1184
54993
08b0ee9a9b35 (gdb-frame-parameters): New constant.
Nick Roberts <nickrob@snap.net.nz>
parents: 54962
diff changeset
1185 (defconst gdb-frame-parameters
58521
54bb21951d18 (gdb-frame-parameters): Match height and
Nick Roberts <nickrob@snap.net.nz>
parents: 58485
diff changeset
1186 '((height . 14) (width . 80)
54993
08b0ee9a9b35 (gdb-frame-parameters): New constant.
Nick Roberts <nickrob@snap.net.nz>
parents: 54962
diff changeset
1187 (unsplittable . t)
08b0ee9a9b35 (gdb-frame-parameters): New constant.
Nick Roberts <nickrob@snap.net.nz>
parents: 54962
diff changeset
1188 (tool-bar-lines . nil)
08b0ee9a9b35 (gdb-frame-parameters): New constant.
Nick Roberts <nickrob@snap.net.nz>
parents: 54962
diff changeset
1189 (menu-bar-lines . nil)
08b0ee9a9b35 (gdb-frame-parameters): New constant.
Nick Roberts <nickrob@snap.net.nz>
parents: 54962
diff changeset
1190 (minibuffer . nil)))
08b0ee9a9b35 (gdb-frame-parameters): New constant.
Nick Roberts <nickrob@snap.net.nz>
parents: 54962
diff changeset
1191
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1192 (defun gdb-frame-breakpoints-buffer ()
55400
1aaa031e318c Improve/extend documentation strings.
Nick Roberts <nickrob@snap.net.nz>
parents: 55330
diff changeset
1193 "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
1194 (interactive)
58521
54bb21951d18 (gdb-frame-parameters): Match height and
Nick Roberts <nickrob@snap.net.nz>
parents: 58485
diff changeset
1195 (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
1196 (special-display-frame-alist gdb-frame-parameters))
54bb21951d18 (gdb-frame-parameters): Match height and
Nick Roberts <nickrob@snap.net.nz>
parents: 58485
diff changeset
1197 (display-buffer (gdb-get-create-buffer 'gdb-breakpoints-buffer))))
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1198
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1199 (defvar gdb-breakpoints-mode-map
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1200 (let ((map (make-sparse-keymap))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1201 (menu (make-sparse-keymap "Breakpoints")))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1202 (define-key menu [toggle] '("Toggle" . gdb-toggle-breakpoint))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1203 (define-key menu [delete] '("Delete" . gdb-delete-breakpoint))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1204 (define-key menu [goto] '("Goto" . gdb-goto-breakpoint))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1205
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1206 (suppress-keymap map)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1207 (define-key map [menu-bar breakpoints] (cons "Breakpoints" menu))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1208 (define-key map " " 'gdb-toggle-breakpoint)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1209 (define-key map "d" 'gdb-delete-breakpoint)
58485
31d7630f91d4 (gdb-breakpoints-mode-map)
Nick Roberts <nickrob@snap.net.nz>
parents: 58470
diff changeset
1210 (define-key map "q" 'kill-this-buffer)
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1211 (define-key map "\r" 'gdb-goto-breakpoint)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1212 (define-key map [mouse-2] 'gdb-mouse-goto-breakpoint)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1213 map))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1214
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1215 (defun gdb-breakpoints-mode ()
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1216 "Major mode for gdb breakpoints.
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 \\{gdb-breakpoints-mode-map}"
57661
b59713cd72a2 (gdb-get-create-buffer): Allow modes to run
Nick Roberts <nickrob@snap.net.nz>
parents: 57350
diff changeset
1219 (kill-all-local-variables)
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1220 (setq major-mode 'gdb-breakpoints-mode)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1221 (setq mode-name "Breakpoints")
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1222 (use-local-map gdb-breakpoints-mode-map)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1223 (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
1224 (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
1225 (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
1226 'gdb-invalidate-breakpoints
b59713cd72a2 (gdb-get-create-buffer): Allow modes to run
Nick Roberts <nickrob@snap.net.nz>
parents: 57350
diff changeset
1227 'gdbmi-invalidate-breakpoints))
54538
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 (defun gdb-toggle-breakpoint ()
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1230 "Enable/disable the breakpoint at current line."
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1231 (interactive)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1232 (save-excursion
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1233 (beginning-of-line 1)
56330
a76e88488fd7 (gdb-goto-breakpoint): String match more
Nick Roberts <nickrob@snap.net.nz>
parents: 56285
diff changeset
1234 (if (if (with-current-buffer gud-comint-buffer (eq gud-minor-mode 'gdba))
a76e88488fd7 (gdb-goto-breakpoint): String match more
Nick Roberts <nickrob@snap.net.nz>
parents: 56285
diff changeset
1235 (looking-at "\\([0-9]+\\).*point\\s-*\\S-*\\s-*\\(.\\)")
a76e88488fd7 (gdb-goto-breakpoint): String match more
Nick Roberts <nickrob@snap.net.nz>
parents: 56285
diff changeset
1236 (looking-at
a76e88488fd7 (gdb-goto-breakpoint): String match more
Nick Roberts <nickrob@snap.net.nz>
parents: 56285
diff changeset
1237 "\\([0-9]+\\)\\s-*\\S-*\\s-*\\S-*\\s-*\\(.\\)\\s-*\\S-*\\s-*\\S-*:[0-9]+"))
a76e88488fd7 (gdb-goto-breakpoint): String match more
Nick Roberts <nickrob@snap.net.nz>
parents: 56285
diff changeset
1238 (gdb-enqueue-input
a76e88488fd7 (gdb-goto-breakpoint): String match more
Nick Roberts <nickrob@snap.net.nz>
parents: 56285
diff changeset
1239 (list
a76e88488fd7 (gdb-goto-breakpoint): String match more
Nick Roberts <nickrob@snap.net.nz>
parents: 56285
diff changeset
1240 (concat gdb-server-prefix
a76e88488fd7 (gdb-goto-breakpoint): String match more
Nick Roberts <nickrob@snap.net.nz>
parents: 56285
diff changeset
1241 (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
1242 "disable "
a76e88488fd7 (gdb-goto-breakpoint): String match more
Nick Roberts <nickrob@snap.net.nz>
parents: 56285
diff changeset
1243 "enable ")
a76e88488fd7 (gdb-goto-breakpoint): String match more
Nick Roberts <nickrob@snap.net.nz>
parents: 56285
diff changeset
1244 (match-string 1) "\n") 'ignore))
a76e88488fd7 (gdb-goto-breakpoint): String match more
Nick Roberts <nickrob@snap.net.nz>
parents: 56285
diff changeset
1245 (error "Not recognized as break/watchpoint line"))))
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1246
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1247 (defun gdb-delete-breakpoint ()
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1248 "Delete the breakpoint at current line."
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1249 (interactive)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1250 (beginning-of-line 1)
56330
a76e88488fd7 (gdb-goto-breakpoint): String match more
Nick Roberts <nickrob@snap.net.nz>
parents: 56285
diff changeset
1251 (if (if (with-current-buffer gud-comint-buffer (eq gud-minor-mode 'gdba))
a76e88488fd7 (gdb-goto-breakpoint): String match more
Nick Roberts <nickrob@snap.net.nz>
parents: 56285
diff changeset
1252 (looking-at "\\([0-9]+\\).*point\\s-*\\S-*\\s-*\\(.\\)")
a76e88488fd7 (gdb-goto-breakpoint): String match more
Nick Roberts <nickrob@snap.net.nz>
parents: 56285
diff changeset
1253 (looking-at
a76e88488fd7 (gdb-goto-breakpoint): String match more
Nick Roberts <nickrob@snap.net.nz>
parents: 56285
diff changeset
1254 "\\([0-9]+\\)\\s-*\\S-*\\s-*\\S-*\\s-*.\\s-*\\S-*\\s-*\\S-*:[0-9]+"))
a76e88488fd7 (gdb-goto-breakpoint): String match more
Nick Roberts <nickrob@snap.net.nz>
parents: 56285
diff changeset
1255 (gdb-enqueue-input
a76e88488fd7 (gdb-goto-breakpoint): String match more
Nick Roberts <nickrob@snap.net.nz>
parents: 56285
diff changeset
1256 (list
a76e88488fd7 (gdb-goto-breakpoint): String match more
Nick Roberts <nickrob@snap.net.nz>
parents: 56285
diff changeset
1257 (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
1258 (error "Not recognized as break/watchpoint line")))
54538
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 (defun gdb-goto-breakpoint ()
55400
1aaa031e318c Improve/extend documentation strings.
Nick Roberts <nickrob@snap.net.nz>
parents: 55330
diff changeset
1261 "Display the breakpoint location specified at current line."
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1262 (interactive)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1263 (save-excursion
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1264 (beginning-of-line 1)
56330
a76e88488fd7 (gdb-goto-breakpoint): String match more
Nick Roberts <nickrob@snap.net.nz>
parents: 56285
diff changeset
1265 (if (if (with-current-buffer gud-comint-buffer (eq gud-minor-mode 'gdba))
a76e88488fd7 (gdb-goto-breakpoint): String match more
Nick Roberts <nickrob@snap.net.nz>
parents: 56285
diff changeset
1266 (looking-at ".*in\\s-+\\S-+\\s-+at\\s-+\\(\\S-*\\):\\([0-9]+\\)")
a76e88488fd7 (gdb-goto-breakpoint): String match more
Nick Roberts <nickrob@snap.net.nz>
parents: 56285
diff changeset
1267 (looking-at
a76e88488fd7 (gdb-goto-breakpoint): String match more
Nick Roberts <nickrob@snap.net.nz>
parents: 56285
diff changeset
1268 "[0-9]+\\s-*\\S-*\\s-*\\S-*\\s-*.\\s-*\\S-*\\s-*\\(\\S-*\\):\\([0-9]+\\)"))
a76e88488fd7 (gdb-goto-breakpoint): String match more
Nick Roberts <nickrob@snap.net.nz>
parents: 56285
diff changeset
1269 (let ((line (match-string 2))
a76e88488fd7 (gdb-goto-breakpoint): String match more
Nick Roberts <nickrob@snap.net.nz>
parents: 56285
diff changeset
1270 (file (match-string 1)))
a76e88488fd7 (gdb-goto-breakpoint): String match more
Nick Roberts <nickrob@snap.net.nz>
parents: 56285
diff changeset
1271 (save-selected-window
a76e88488fd7 (gdb-goto-breakpoint): String match more
Nick Roberts <nickrob@snap.net.nz>
parents: 56285
diff changeset
1272 (let* ((buf (find-file-noselect (if (file-exists-p file)
a76e88488fd7 (gdb-goto-breakpoint): String match more
Nick Roberts <nickrob@snap.net.nz>
parents: 56285
diff changeset
1273 file
a76e88488fd7 (gdb-goto-breakpoint): String match more
Nick Roberts <nickrob@snap.net.nz>
parents: 56285
diff changeset
1274 (expand-file-name file gdb-cdir))))
58534
c655bc81dfc0 (gdb-view-source, gdb-selected-view):
Nick Roberts <nickrob@snap.net.nz>
parents: 58521
diff changeset
1275 (window (display-buffer buf)))
56330
a76e88488fd7 (gdb-goto-breakpoint): String match more
Nick Roberts <nickrob@snap.net.nz>
parents: 56285
diff changeset
1276 (with-current-buffer buf
a76e88488fd7 (gdb-goto-breakpoint): String match more
Nick Roberts <nickrob@snap.net.nz>
parents: 56285
diff changeset
1277 (goto-line (string-to-number line))
a76e88488fd7 (gdb-goto-breakpoint): String match more
Nick Roberts <nickrob@snap.net.nz>
parents: 56285
diff changeset
1278 (set-window-point window (point))))))
a76e88488fd7 (gdb-goto-breakpoint): String match more
Nick Roberts <nickrob@snap.net.nz>
parents: 56285
diff changeset
1279 (error "Not recognized as break/watchpoint line"))))
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1280
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1281 (defun gdb-mouse-goto-breakpoint (event)
55400
1aaa031e318c Improve/extend documentation strings.
Nick Roberts <nickrob@snap.net.nz>
parents: 55330
diff changeset
1282 "Display the breakpoint location that you click on."
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1283 (interactive "e")
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1284 (mouse-set-point event)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1285 (gdb-goto-breakpoint))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1286
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1287 ;;
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1288 ;; Frames buffer. This displays a perpetually correct bactracktrace
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1289 ;; (from the command `where').
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1290 ;;
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1291 ;; Alas, if your stack is deep, it is costly.
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1292 ;;
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1293 (gdb-set-buffer-rules 'gdb-stack-buffer
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1294 'gdb-stack-buffer-name
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1295 'gdb-frames-mode)
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 (def-gdb-auto-updated-buffer gdb-stack-buffer
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1298 gdb-invalidate-frames
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1299 "server where\n"
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1300 gdb-info-frames-handler
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1301 gdb-info-frames-custom)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1302
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1303 (defun gdb-info-frames-custom ()
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1304 (with-current-buffer (gdb-get-buffer 'gdb-stack-buffer)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1305 (save-excursion
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1306 (let ((buffer-read-only nil))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1307 (goto-char (point-min))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1308 (while (< (point) (point-max))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1309 (add-text-properties (point-at-bol) (point-at-eol)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1310 '(mouse-face highlight
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1311 help-echo "mouse-2, RET: Select frame"))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1312 (beginning-of-line)
58049
fd0093bd412a (gdb-current-stack-level): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 57982
diff changeset
1313 (when (and (looking-at "^#\\([0-9]+\\)")
fd0093bd412a (gdb-current-stack-level): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 57982
diff changeset
1314 (equal (match-string 1) gdb-current-stack-level))
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1315 (put-text-property (point-at-bol) (point-at-eol)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1316 'face '(:inverse-video t)))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1317 (forward-line 1))))))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1318
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1319 (defun gdb-stack-buffer-name ()
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1320 (with-current-buffer gud-comint-buffer
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1321 (concat "*stack frames of " (gdb-get-target-string) "*")))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1322
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1323 (defun gdb-display-stack-buffer ()
55400
1aaa031e318c Improve/extend documentation strings.
Nick Roberts <nickrob@snap.net.nz>
parents: 55330
diff changeset
1324 "Display backtrace of current stack."
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1325 (interactive)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1326 (gdb-display-buffer
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1327 (gdb-get-create-buffer 'gdb-stack-buffer)))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1328
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1329 (defun gdb-frame-stack-buffer ()
55400
1aaa031e318c Improve/extend documentation strings.
Nick Roberts <nickrob@snap.net.nz>
parents: 55330
diff changeset
1330 "Display backtrace of current stack in a new frame."
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1331 (interactive)
58521
54bb21951d18 (gdb-frame-parameters): Match height and
Nick Roberts <nickrob@snap.net.nz>
parents: 58485
diff changeset
1332 (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
1333 (special-display-frame-alist gdb-frame-parameters))
54bb21951d18 (gdb-frame-parameters): Match height and
Nick Roberts <nickrob@snap.net.nz>
parents: 58485
diff changeset
1334 (display-buffer (gdb-get-create-buffer 'gdb-stack-buffer))))
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1335
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1336 (defvar gdb-frames-mode-map
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1337 (let ((map (make-sparse-keymap)))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1338 (suppress-keymap map)
58485
31d7630f91d4 (gdb-breakpoints-mode-map)
Nick Roberts <nickrob@snap.net.nz>
parents: 58470
diff changeset
1339 (define-key map "q" 'kill-this-buffer)
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1340 (define-key map "\r" 'gdb-frames-select)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1341 (define-key map [mouse-2] 'gdb-frames-mouse-select)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1342 map))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1343
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1344 (defun gdb-frames-mode ()
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1345 "Major mode for gdb frames.
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1346
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1347 \\{gdb-frames-mode-map}"
57661
b59713cd72a2 (gdb-get-create-buffer): Allow modes to run
Nick Roberts <nickrob@snap.net.nz>
parents: 57350
diff changeset
1348 (kill-all-local-variables)
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1349 (setq major-mode 'gdb-frames-mode)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1350 (setq mode-name "Frames")
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1351 (setq buffer-read-only t)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1352 (use-local-map gdb-frames-mode-map)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1353 (font-lock-mode -1)
57661
b59713cd72a2 (gdb-get-create-buffer): Allow modes to run
Nick Roberts <nickrob@snap.net.nz>
parents: 57350
diff changeset
1354 (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
1355 (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
1356 'gdb-invalidate-frames
b59713cd72a2 (gdb-get-create-buffer): Allow modes to run
Nick Roberts <nickrob@snap.net.nz>
parents: 57350
diff changeset
1357 'gdbmi-invalidate-frames))
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1358
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1359 (defun gdb-get-frame-number ()
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1360 (save-excursion
55850
63ca25eb73a1 (gdb-current-frame, gud-watch)
Nick Roberts <nickrob@snap.net.nz>
parents: 55764
diff changeset
1361 (let* ((pos (re-search-backward "^#*\\([0-9]*\\)" nil t))
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1362 (n (or (and pos (match-string-no-properties 1)) "0")))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1363 n)))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1364
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1365 (defun gdb-frames-select ()
55400
1aaa031e318c Improve/extend documentation strings.
Nick Roberts <nickrob@snap.net.nz>
parents: 55330
diff changeset
1366 "Select the frame and display the relevant source."
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1367 (interactive)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1368 (gdb-enqueue-input
55749
230865f1c59d (gdb-server-prefix): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 55696
diff changeset
1369 (list (concat gdb-server-prefix "frame " (gdb-get-frame-number) "\n") 'ignore))
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1370 (gud-display-frame))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1371
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1372 (defun gdb-frames-mouse-select (event)
55400
1aaa031e318c Improve/extend documentation strings.
Nick Roberts <nickrob@snap.net.nz>
parents: 55330
diff changeset
1373 "Select the frame you click on and display the relevant source."
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1374 (interactive "e")
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1375 (mouse-set-point event)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1376 (gdb-frames-select))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1377
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1378 ;;
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1379 ;; Threads buffer. This displays a selectable thread list.
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1380 ;;
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1381 (gdb-set-buffer-rules 'gdb-threads-buffer
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1382 'gdb-threads-buffer-name
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1383 'gdb-threads-mode)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1384
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1385 (def-gdb-auto-updated-buffer gdb-threads-buffer
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1386 gdb-invalidate-threads
55749
230865f1c59d (gdb-server-prefix): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 55696
diff changeset
1387 (concat gdb-server-prefix "info threads\n")
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1388 gdb-info-threads-handler
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1389 gdb-info-threads-custom)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1390
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1391 (defun gdb-info-threads-custom ()
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1392 (with-current-buffer (gdb-get-buffer 'gdb-threads-buffer)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1393 (let ((buffer-read-only nil))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1394 (goto-char (point-min))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1395 (while (< (point) (point-max))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1396 (add-text-properties (point-at-bol) (point-at-eol)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1397 '(mouse-face highlight
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1398 help-echo "mouse-2, RET: select thread"))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1399 (forward-line 1)))))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1400
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1401 (defun gdb-threads-buffer-name ()
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1402 (with-current-buffer gud-comint-buffer
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1403 (concat "*threads of " (gdb-get-target-string) "*")))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1404
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1405 (defun gdb-display-threads-buffer ()
55400
1aaa031e318c Improve/extend documentation strings.
Nick Roberts <nickrob@snap.net.nz>
parents: 55330
diff changeset
1406 "Display IDs of currently known threads."
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1407 (interactive)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1408 (gdb-display-buffer
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1409 (gdb-get-create-buffer 'gdb-threads-buffer)))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1410
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1411 (defun gdb-frame-threads-buffer ()
55400
1aaa031e318c Improve/extend documentation strings.
Nick Roberts <nickrob@snap.net.nz>
parents: 55330
diff changeset
1412 "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
1413 (interactive)
58521
54bb21951d18 (gdb-frame-parameters): Match height and
Nick Roberts <nickrob@snap.net.nz>
parents: 58485
diff changeset
1414 (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
1415 (special-display-frame-alist gdb-frame-parameters))
54bb21951d18 (gdb-frame-parameters): Match height and
Nick Roberts <nickrob@snap.net.nz>
parents: 58485
diff changeset
1416 (display-buffer (gdb-get-create-buffer 'gdb-threads-buffer))))
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1417
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1418 (defvar gdb-threads-mode-map
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1419 (let ((map (make-sparse-keymap)))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1420 (suppress-keymap map)
58485
31d7630f91d4 (gdb-breakpoints-mode-map)
Nick Roberts <nickrob@snap.net.nz>
parents: 58470
diff changeset
1421 (define-key map "q" 'kill-this-buffer)
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1422 (define-key map "\r" 'gdb-threads-select)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1423 (define-key map [mouse-2] 'gdb-threads-mouse-select)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1424 map))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1425
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1426 (defun gdb-threads-mode ()
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1427 "Major mode for gdb frames.
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1428
55749
230865f1c59d (gdb-server-prefix): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 55696
diff changeset
1429 \\{gdb-threads-mode-map}"
57661
b59713cd72a2 (gdb-get-create-buffer): Allow modes to run
Nick Roberts <nickrob@snap.net.nz>
parents: 57350
diff changeset
1430 (kill-all-local-variables)
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1431 (setq major-mode 'gdb-threads-mode)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1432 (setq mode-name "Threads")
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1433 (setq buffer-read-only t)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1434 (use-local-map gdb-threads-mode-map)
57661
b59713cd72a2 (gdb-get-create-buffer): Allow modes to run
Nick Roberts <nickrob@snap.net.nz>
parents: 57350
diff changeset
1435 (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
1436 'gdb-invalidate-threads)
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1437
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1438 (defun gdb-get-thread-number ()
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1439 (save-excursion
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1440 (re-search-backward "^\\s-*\\([0-9]*\\)" nil t)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1441 (match-string-no-properties 1)))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1442
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1443 (defun gdb-threads-select ()
55400
1aaa031e318c Improve/extend documentation strings.
Nick Roberts <nickrob@snap.net.nz>
parents: 55330
diff changeset
1444 "Select the thread and display the relevant source."
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1445 (interactive)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1446 (gdb-enqueue-input
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1447 (list (concat "thread " (gdb-get-thread-number) "\n") 'ignore))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1448 (gud-display-frame))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1449
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1450 (defun gdb-threads-mouse-select (event)
55400
1aaa031e318c Improve/extend documentation strings.
Nick Roberts <nickrob@snap.net.nz>
parents: 55330
diff changeset
1451 "Select the thread you click on and display the relevant source."
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1452 (interactive "e")
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1453 (mouse-set-point event)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1454 (gdb-threads-select))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1455
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1456 ;;
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1457 ;; Registers buffer.
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1458 ;;
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1459 (gdb-set-buffer-rules 'gdb-registers-buffer
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1460 'gdb-registers-buffer-name
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1461 'gdb-registers-mode)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1462
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1463 (def-gdb-auto-updated-buffer gdb-registers-buffer
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1464 gdb-invalidate-registers
55749
230865f1c59d (gdb-server-prefix): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 55696
diff changeset
1465 (concat gdb-server-prefix "info registers\n")
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1466 gdb-info-registers-handler
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1467 gdb-info-registers-custom)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1468
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1469 (defun gdb-info-registers-custom ())
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1470
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1471 (defvar gdb-registers-mode-map
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1472 (let ((map (make-sparse-keymap)))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1473 (suppress-keymap map)
58485
31d7630f91d4 (gdb-breakpoints-mode-map)
Nick Roberts <nickrob@snap.net.nz>
parents: 58470
diff changeset
1474 (define-key map "q" 'kill-this-buffer)
31d7630f91d4 (gdb-breakpoints-mode-map)
Nick Roberts <nickrob@snap.net.nz>
parents: 58470
diff changeset
1475 map))
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1476
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1477 (defun gdb-registers-mode ()
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1478 "Major mode for gdb registers.
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1479
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1480 \\{gdb-registers-mode-map}"
57661
b59713cd72a2 (gdb-get-create-buffer): Allow modes to run
Nick Roberts <nickrob@snap.net.nz>
parents: 57350
diff changeset
1481 (kill-all-local-variables)
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1482 (setq major-mode 'gdb-registers-mode)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1483 (setq mode-name "Registers")
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1484 (setq buffer-read-only t)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1485 (use-local-map gdb-registers-mode-map)
57661
b59713cd72a2 (gdb-get-create-buffer): Allow modes to run
Nick Roberts <nickrob@snap.net.nz>
parents: 57350
diff changeset
1486 (run-mode-hooks 'gdb-registers-mode-hook)
b59713cd72a2 (gdb-get-create-buffer): Allow modes to run
Nick Roberts <nickrob@snap.net.nz>
parents: 57350
diff changeset
1487 'gdb-invalidate-registers)
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1488
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1489 (defun gdb-registers-buffer-name ()
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1490 (with-current-buffer gud-comint-buffer
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1491 (concat "*registers of " (gdb-get-target-string) "*")))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1492
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1493 (defun gdb-display-registers-buffer ()
55400
1aaa031e318c Improve/extend documentation strings.
Nick Roberts <nickrob@snap.net.nz>
parents: 55330
diff changeset
1494 "Display integer register contents."
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1495 (interactive)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1496 (gdb-display-buffer
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1497 (gdb-get-create-buffer 'gdb-registers-buffer)))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1498
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1499 (defun gdb-frame-registers-buffer ()
55400
1aaa031e318c Improve/extend documentation strings.
Nick Roberts <nickrob@snap.net.nz>
parents: 55330
diff changeset
1500 "Display integer register contents in a new frame."
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1501 (interactive)
58521
54bb21951d18 (gdb-frame-parameters): Match height and
Nick Roberts <nickrob@snap.net.nz>
parents: 58485
diff changeset
1502 (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
1503 (special-display-frame-alist gdb-frame-parameters))
54bb21951d18 (gdb-frame-parameters): Match height and
Nick Roberts <nickrob@snap.net.nz>
parents: 58485
diff changeset
1504 (display-buffer (gdb-get-create-buffer 'gdb-registers-buffer))))
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1505
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1506 ;;
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1507 ;; Locals buffer.
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1508 ;;
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1509 (gdb-set-buffer-rules 'gdb-locals-buffer
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1510 'gdb-locals-buffer-name
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1511 'gdb-locals-mode)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1512
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1513 (def-gdb-auto-updated-buffer gdb-locals-buffer
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1514 gdb-invalidate-locals
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1515 "server info locals\n"
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1516 gdb-info-locals-handler
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1517 gdb-info-locals-custom)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1518
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1519 ;; Abbreviate for arrays and structures.
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1520 ;; These can be expanded using gud-display.
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1521 (defun gdb-info-locals-handler nil
55749
230865f1c59d (gdb-server-prefix): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 55696
diff changeset
1522 (setq gdb-pending-triggers (delq 'gdb-invalidate-locals
230865f1c59d (gdb-server-prefix): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 55696
diff changeset
1523 gdb-pending-triggers))
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1524 (let ((buf (gdb-get-buffer 'gdb-partial-output-buffer)))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1525 (with-current-buffer buf
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1526 (goto-char (point-min))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1527 (while (re-search-forward "^ .*\n" nil t)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1528 (replace-match "" nil nil))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1529 (goto-char (point-min))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1530 (while (re-search-forward "{[-0-9, {}\]*\n" nil t)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1531 (replace-match "(array);\n" nil nil))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1532 (goto-char (point-min))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1533 (while (re-search-forward "{.*=.*\n" nil t)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1534 (replace-match "(structure);\n" nil nil))))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1535 (let ((buf (gdb-get-buffer 'gdb-locals-buffer)))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1536 (and buf (with-current-buffer buf
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1537 (let ((p (point))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1538 (buffer-read-only nil))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1539 (delete-region (point-min) (point-max))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1540 (insert-buffer-substring (gdb-get-create-buffer
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1541 'gdb-partial-output-buffer))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1542 (goto-char p)))))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1543 (run-hooks 'gdb-info-locals-hook))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1544
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1545 (defun gdb-info-locals-custom ()
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1546 nil)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1547
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1548 (defvar gdb-locals-mode-map
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1549 (let ((map (make-sparse-keymap)))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1550 (suppress-keymap map)
58485
31d7630f91d4 (gdb-breakpoints-mode-map)
Nick Roberts <nickrob@snap.net.nz>
parents: 58470
diff changeset
1551 (define-key map "q" 'kill-this-buffer)
31d7630f91d4 (gdb-breakpoints-mode-map)
Nick Roberts <nickrob@snap.net.nz>
parents: 58470
diff changeset
1552 map))
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1553
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1554 (defun gdb-locals-mode ()
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1555 "Major mode for gdb locals.
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1556
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1557 \\{gdb-locals-mode-map}"
57661
b59713cd72a2 (gdb-get-create-buffer): Allow modes to run
Nick Roberts <nickrob@snap.net.nz>
parents: 57350
diff changeset
1558 (kill-all-local-variables)
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1559 (setq major-mode 'gdb-locals-mode)
55850
63ca25eb73a1 (gdb-current-frame, gud-watch)
Nick Roberts <nickrob@snap.net.nz>
parents: 55764
diff changeset
1560 (setq mode-name (concat "Locals:" gdb-current-frame))
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1561 (setq buffer-read-only t)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1562 (use-local-map gdb-locals-mode-map)
57661
b59713cd72a2 (gdb-get-create-buffer): Allow modes to run
Nick Roberts <nickrob@snap.net.nz>
parents: 57350
diff changeset
1563 (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
1564 (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
1565 'gdb-invalidate-locals
b59713cd72a2 (gdb-get-create-buffer): Allow modes to run
Nick Roberts <nickrob@snap.net.nz>
parents: 57350
diff changeset
1566 'gdbmi-invalidate-locals))
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1567
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1568 (defun gdb-locals-buffer-name ()
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1569 (with-current-buffer gud-comint-buffer
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1570 (concat "*locals of " (gdb-get-target-string) "*")))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1571
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1572 (defun gdb-display-locals-buffer ()
55400
1aaa031e318c Improve/extend documentation strings.
Nick Roberts <nickrob@snap.net.nz>
parents: 55330
diff changeset
1573 "Display local variables of current stack and their values."
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1574 (interactive)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1575 (gdb-display-buffer
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1576 (gdb-get-create-buffer 'gdb-locals-buffer)))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1577
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1578 (defun gdb-frame-locals-buffer ()
55400
1aaa031e318c Improve/extend documentation strings.
Nick Roberts <nickrob@snap.net.nz>
parents: 55330
diff changeset
1579 "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
1580 (interactive)
58521
54bb21951d18 (gdb-frame-parameters): Match height and
Nick Roberts <nickrob@snap.net.nz>
parents: 58485
diff changeset
1581 (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
1582 (special-display-frame-alist gdb-frame-parameters))
54bb21951d18 (gdb-frame-parameters): Match height and
Nick Roberts <nickrob@snap.net.nz>
parents: 58485
diff changeset
1583 (display-buffer (gdb-get-create-buffer 'gdb-locals-buffer))))
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1584
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1585
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1586 ;;;; Window management
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1587 (defun gdb-display-buffer (buf &optional size)
58485
31d7630f91d4 (gdb-breakpoints-mode-map)
Nick Roberts <nickrob@snap.net.nz>
parents: 58470
diff changeset
1588 (let ((answer (get-buffer-window buf 0))
31d7630f91d4 (gdb-breakpoints-mode-map)
Nick Roberts <nickrob@snap.net.nz>
parents: 58470
diff changeset
1589 (must-split nil))
31d7630f91d4 (gdb-breakpoints-mode-map)
Nick Roberts <nickrob@snap.net.nz>
parents: 58470
diff changeset
1590 (if answer
58534
c655bc81dfc0 (gdb-view-source, gdb-selected-view):
Nick Roberts <nickrob@snap.net.nz>
parents: 58521
diff changeset
1591 (display-buffer buf) ;Raise the frame if necessary.
58485
31d7630f91d4 (gdb-breakpoints-mode-map)
Nick Roberts <nickrob@snap.net.nz>
parents: 58470
diff changeset
1592 ;; The buffer is not yet displayed.
31d7630f91d4 (gdb-breakpoints-mode-map)
Nick Roberts <nickrob@snap.net.nz>
parents: 58470
diff changeset
1593 (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
1594 (let ((window (get-lru-window)))
c655bc81dfc0 (gdb-view-source, gdb-selected-view):
Nick Roberts <nickrob@snap.net.nz>
parents: 58521
diff changeset
1595 (if window
c655bc81dfc0 (gdb-view-source, gdb-selected-view):
Nick Roberts <nickrob@snap.net.nz>
parents: 58521
diff changeset
1596 (progn
c655bc81dfc0 (gdb-view-source, gdb-selected-view):
Nick Roberts <nickrob@snap.net.nz>
parents: 58521
diff changeset
1597 (set-window-buffer window buf)
c655bc81dfc0 (gdb-view-source, gdb-selected-view):
Nick Roberts <nickrob@snap.net.nz>
parents: 58521
diff changeset
1598 (setq answer window))
58485
31d7630f91d4 (gdb-breakpoints-mode-map)
Nick Roberts <nickrob@snap.net.nz>
parents: 58470
diff changeset
1599 (setq must-split t)))
58534
c655bc81dfc0 (gdb-view-source, gdb-selected-view):
Nick Roberts <nickrob@snap.net.nz>
parents: 58521
diff changeset
1600 (if must-split
c655bc81dfc0 (gdb-view-source, gdb-selected-view):
Nick Roberts <nickrob@snap.net.nz>
parents: 58521
diff changeset
1601 (let* ((largest (get-largest-window))
c655bc81dfc0 (gdb-view-source, gdb-selected-view):
Nick Roberts <nickrob@snap.net.nz>
parents: 58521
diff changeset
1602 (cur-size (window-height largest))
c655bc81dfc0 (gdb-view-source, gdb-selected-view):
Nick Roberts <nickrob@snap.net.nz>
parents: 58521
diff changeset
1603 (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
1604 (setq answer (split-window largest new-size))
c655bc81dfc0 (gdb-view-source, gdb-selected-view):
Nick Roberts <nickrob@snap.net.nz>
parents: 58521
diff changeset
1605 (set-window-buffer answer buf)
c655bc81dfc0 (gdb-view-source, gdb-selected-view):
Nick Roberts <nickrob@snap.net.nz>
parents: 58521
diff changeset
1606 (set-window-dedicated-p answer t)))
58485
31d7630f91d4 (gdb-breakpoints-mode-map)
Nick Roberts <nickrob@snap.net.nz>
parents: 58470
diff changeset
1607 answer)))
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1608
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1609
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1610 ;;; Shared keymap initialization:
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1611
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1612 (let ((menu (make-sparse-keymap "GDB-Frames")))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1613 (define-key gud-menu-map [frames]
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1614 `(menu-item "GDB-Frames" ,menu :visible (eq gud-minor-mode 'gdba)))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1615 (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
1616 (define-key menu [threads] '("Threads" . gdb-frame-threads-buffer))
55749
230865f1c59d (gdb-server-prefix): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 55696
diff changeset
1617 (define-key menu [assembler] '("Machine" . gdb-frame-assembler-buffer))
55328
4440fe0e7dc6 (gud-watch, gdb-display-buffer)
Nick Roberts <nickrob@snap.net.nz>
parents: 55217
diff changeset
1618 (define-key menu [registers] '("Registers" . gdb-frame-registers-buffer))
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1619 (define-key menu [locals] '("Locals" . gdb-frame-locals-buffer))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1620 (define-key menu [frames] '("Stack" . gdb-frame-stack-buffer))
55749
230865f1c59d (gdb-server-prefix): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 55696
diff changeset
1621 (define-key menu [breakpoints] '("Breakpoints" . gdb-frame-breakpoints-buffer)))
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1622
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1623 (let ((menu (make-sparse-keymap "GDB-Windows")))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1624 (define-key gud-menu-map [displays]
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1625 `(menu-item "GDB-Windows" ,menu :visible (eq gud-minor-mode 'gdba)))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1626 (define-key menu [gdb] '("Gdb" . gdb-display-gdb-buffer))
55749
230865f1c59d (gdb-server-prefix): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 55696
diff changeset
1627 (define-key menu [assembler] '("Machine" . gdb-display-assembler-buffer))
55328
4440fe0e7dc6 (gud-watch, gdb-display-buffer)
Nick Roberts <nickrob@snap.net.nz>
parents: 55217
diff changeset
1628 (define-key menu [threads] '("Threads" . gdb-display-threads-buffer))
4440fe0e7dc6 (gud-watch, gdb-display-buffer)
Nick Roberts <nickrob@snap.net.nz>
parents: 55217
diff changeset
1629 (define-key menu [registers] '("Registers" . gdb-display-registers-buffer))
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1630 (define-key menu [locals] '("Locals" . gdb-display-locals-buffer))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1631 (define-key menu [frames] '("Stack" . gdb-display-stack-buffer))
55749
230865f1c59d (gdb-server-prefix): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 55696
diff changeset
1632 (define-key menu [breakpoints] '("Breakpoints" . gdb-display-breakpoints-buffer)))
54538
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 (let ((menu (make-sparse-keymap "GDB-UI")))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1635 (define-key gud-menu-map [ui]
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1636 `(menu-item "GDB-UI" ,menu :visible (eq gud-minor-mode 'gdba)))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1637 (define-key menu [gdb-restore-windows]
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1638 '("Restore window layout" . gdb-restore-windows))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1639 (define-key menu [gdb-many-windows]
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1640 (menu-bar-make-toggle gdb-many-windows gdb-many-windows
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1641 "Display other windows" "Many Windows %s"
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1642 "Display locals, stack and breakpoint information")))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1643
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1644 (defun gdb-frame-gdb-buffer ()
55400
1aaa031e318c Improve/extend documentation strings.
Nick Roberts <nickrob@snap.net.nz>
parents: 55330
diff changeset
1645 "Display GUD buffer in a new frame."
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1646 (interactive)
54993
08b0ee9a9b35 (gdb-frame-parameters): New constant.
Nick Roberts <nickrob@snap.net.nz>
parents: 54962
diff changeset
1647 (select-frame (make-frame gdb-frame-parameters))
08b0ee9a9b35 (gdb-frame-parameters): New constant.
Nick Roberts <nickrob@snap.net.nz>
parents: 54962
diff changeset
1648 (switch-to-buffer (gdb-get-create-buffer 'gdba))
55217
97d0e3a1174f (gdb-frame-breakpoints-buffer)
Nick Roberts <nickrob@snap.net.nz>
parents: 54993
diff changeset
1649 (set-window-dedicated-p (selected-window) t))
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1650
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1651 (defun gdb-display-gdb-buffer ()
55400
1aaa031e318c Improve/extend documentation strings.
Nick Roberts <nickrob@snap.net.nz>
parents: 55330
diff changeset
1652 "Display GUD buffer."
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1653 (interactive)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1654 (gdb-display-buffer
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1655 (gdb-get-create-buffer 'gdba)))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1656
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1657 (defvar gdb-main-file nil "Source file from which program execution begins.")
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1658
54668
69a699e79a0d (gdb-view-source-function, gdb-view-assembler)
Nick Roberts <nickrob@snap.net.nz>
parents: 54617
diff changeset
1659 (defcustom gdb-show-main nil
69a699e79a0d (gdb-view-source-function, gdb-view-assembler)
Nick Roberts <nickrob@snap.net.nz>
parents: 54617
diff changeset
1660 "Nil means don't display source file containing the main routine."
69a699e79a0d (gdb-view-source-function, gdb-view-assembler)
Nick Roberts <nickrob@snap.net.nz>
parents: 54617
diff changeset
1661 :type 'boolean
57851
67b88e92a24d (gdb-enable-debug-log)
Nick Roberts <nickrob@snap.net.nz>
parents: 57791
diff changeset
1662 :group 'gud
67b88e92a24d (gdb-enable-debug-log)
Nick Roberts <nickrob@snap.net.nz>
parents: 57791
diff changeset
1663 :version "21.4")
54668
69a699e79a0d (gdb-view-source-function, gdb-view-assembler)
Nick Roberts <nickrob@snap.net.nz>
parents: 54617
diff changeset
1664
58485
31d7630f91d4 (gdb-breakpoints-mode-map)
Nick Roberts <nickrob@snap.net.nz>
parents: 58470
diff changeset
1665 (defun gdb-set-window-buffer (name)
31d7630f91d4 (gdb-breakpoints-mode-map)
Nick Roberts <nickrob@snap.net.nz>
parents: 58470
diff changeset
1666 (set-window-buffer (selected-window) (get-buffer name))
31d7630f91d4 (gdb-breakpoints-mode-map)
Nick Roberts <nickrob@snap.net.nz>
parents: 58470
diff changeset
1667 (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
1668
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1669 (defun gdb-setup-windows ()
54668
69a699e79a0d (gdb-view-source-function, gdb-view-assembler)
Nick Roberts <nickrob@snap.net.nz>
parents: 54617
diff changeset
1670 "Layout the window pattern for gdb-many-windows."
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1671 (gdb-display-locals-buffer)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1672 (gdb-display-stack-buffer)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1673 (delete-other-windows)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1674 (gdb-display-breakpoints-buffer)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1675 (delete-other-windows)
58534
c655bc81dfc0 (gdb-view-source, gdb-selected-view):
Nick Roberts <nickrob@snap.net.nz>
parents: 58521
diff changeset
1676 ; Don't dedicate.
c655bc81dfc0 (gdb-view-source, gdb-selected-view):
Nick Roberts <nickrob@snap.net.nz>
parents: 58521
diff changeset
1677 (pop-to-buffer gud-comint-buffer)
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1678 (split-window nil ( / ( * (window-height) 3) 4))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1679 (split-window nil ( / (window-height) 3))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1680 (split-window-horizontally)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1681 (other-window 1)
58485
31d7630f91d4 (gdb-breakpoints-mode-map)
Nick Roberts <nickrob@snap.net.nz>
parents: 58470
diff changeset
1682 (gdb-set-window-buffer (gdb-locals-buffer-name))
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1683 (other-window 1)
58534
c655bc81dfc0 (gdb-view-source, gdb-selected-view):
Nick Roberts <nickrob@snap.net.nz>
parents: 58521
diff changeset
1684 (switch-to-buffer
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1685 (if gud-last-last-frame
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1686 (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
1687 (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
1688 (when gdb-use-inferior-io-buffer
7bfccd78beed (gdb-use-inferior-io-buffer): New option.
Nick Roberts <nickrob@snap.net.nz>
parents: 54668
diff changeset
1689 (split-window-horizontally)
7bfccd78beed (gdb-use-inferior-io-buffer): New option.
Nick Roberts <nickrob@snap.net.nz>
parents: 54668
diff changeset
1690 (other-window 1)
58485
31d7630f91d4 (gdb-breakpoints-mode-map)
Nick Roberts <nickrob@snap.net.nz>
parents: 58470
diff changeset
1691 (gdb-set-window-buffer (gdb-inferior-io-name)))
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1692 (other-window 1)
58485
31d7630f91d4 (gdb-breakpoints-mode-map)
Nick Roberts <nickrob@snap.net.nz>
parents: 58470
diff changeset
1693 (gdb-set-window-buffer (gdb-stack-buffer-name))
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1694 (split-window-horizontally)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1695 (other-window 1)
58485
31d7630f91d4 (gdb-breakpoints-mode-map)
Nick Roberts <nickrob@snap.net.nz>
parents: 58470
diff changeset
1696 (gdb-set-window-buffer (gdb-breakpoints-buffer-name))
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1697 (other-window 1))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1698
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1699 (defcustom gdb-many-windows nil
57791
d1b93fc4ce47 Docstring fixes.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57664
diff changeset
1700 "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
1701 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
1702 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
1703 of the inferior. Non-nil means display the layout shown for
d1b93fc4ce47 Docstring fixes.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57664
diff changeset
1704 `gdba'."
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1705 :type 'boolean
57851
67b88e92a24d (gdb-enable-debug-log)
Nick Roberts <nickrob@snap.net.nz>
parents: 57791
diff changeset
1706 :group 'gud
67b88e92a24d (gdb-enable-debug-log)
Nick Roberts <nickrob@snap.net.nz>
parents: 57791
diff changeset
1707 :version "21.4")
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1708
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1709 (defun gdb-many-windows (arg)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1710 "Toggle the number of windows in the basic arrangement."
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1711 (interactive "P")
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1712 (setq gdb-many-windows
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1713 (if (null arg)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1714 (not gdb-many-windows)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1715 (> (prefix-numeric-value arg) 0)))
54760
c6ccb7a82f9f (gdb-source-window): Remove variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 54729
diff changeset
1716 (condition-case nil
c6ccb7a82f9f (gdb-source-window): Remove variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 54729
diff changeset
1717 (gdb-restore-windows)
c6ccb7a82f9f (gdb-source-window): Remove variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 54729
diff changeset
1718 (error nil)))
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1719
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1720 (defun gdb-restore-windows ()
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1721 "Restore the basic arrangement of windows used by gdba.
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1722 This arrangement depends on the value of `gdb-many-windows'."
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1723 (interactive)
58485
31d7630f91d4 (gdb-breakpoints-mode-map)
Nick Roberts <nickrob@snap.net.nz>
parents: 58470
diff changeset
1724 (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
1725 (delete-other-windows)
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1726 (if gdb-many-windows
58485
31d7630f91d4 (gdb-breakpoints-mode-map)
Nick Roberts <nickrob@snap.net.nz>
parents: 58470
diff changeset
1727 (gdb-setup-windows)
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1728 (split-window)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1729 (other-window 1)
58534
c655bc81dfc0 (gdb-view-source, gdb-selected-view):
Nick Roberts <nickrob@snap.net.nz>
parents: 58521
diff changeset
1730 (switch-to-buffer
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1731 (if gud-last-last-frame
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1732 (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
1733 (gud-find-file gdb-main-file)))
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1734 (other-window 1)))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1735
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1736 (defun gdb-reset ()
57791
d1b93fc4ce47 Docstring fixes.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57664
diff changeset
1737 "Exit a debugging session cleanly.
d1b93fc4ce47 Docstring fixes.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57664
diff changeset
1738 Kills the gdb buffers and resets the source buffers."
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1739 (dolist (buffer (buffer-list))
55696
ed6e91c53c82 (gdb-reset): Use unless. Fix regexp.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55507
diff changeset
1740 (unless (eq buffer gud-comint-buffer)
ed6e91c53c82 (gdb-reset): Use unless. Fix regexp.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55507
diff changeset
1741 (with-current-buffer buffer
55749
230865f1c59d (gdb-server-prefix): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 55696
diff changeset
1742 (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
1743 (if (string-match "\\`\\*.+\\*\\'" (buffer-name))
ed6e91c53c82 (gdb-reset): Use unless. Fix regexp.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55507
diff changeset
1744 (kill-buffer nil)
ed6e91c53c82 (gdb-reset): Use unless. Fix regexp.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55507
diff changeset
1745 (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
1746 (setq gud-minor-mode nil)
ed6e91c53c82 (gdb-reset): Use unless. Fix regexp.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55507
diff changeset
1747 (kill-local-variable 'tool-bar-map)
ed6e91c53c82 (gdb-reset): Use unless. Fix regexp.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55507
diff changeset
1748 (setq gud-running nil))))))
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1749 (when (markerp gdb-overlay-arrow-position)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1750 (move-marker gdb-overlay-arrow-position nil)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1751 (setq gdb-overlay-arrow-position nil))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1752 (setq overlay-arrow-variable-list
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1753 (delq 'gdb-overlay-arrow-position overlay-arrow-variable-list)))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1754
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1755 (defun gdb-source-info ()
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1756 "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
1757 buffers."
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1758 (goto-char (point-min))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1759 (if (search-forward "directory is " nil t)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1760 (if (looking-at "\\S-*:\\(\\S-*\\)")
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1761 (setq gdb-cdir (match-string 1))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1762 (looking-at "\\S-*")
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1763 (setq gdb-cdir (match-string 0))))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1764 (if (search-forward "Located in " nil t)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1765 (if (looking-at "\\S-*")
58534
c655bc81dfc0 (gdb-view-source, gdb-selected-view):
Nick Roberts <nickrob@snap.net.nz>
parents: 58521
diff changeset
1766 (setq gdb-main-file (match-string 0))))
c655bc81dfc0 (gdb-view-source, gdb-selected-view):
Nick Roberts <nickrob@snap.net.nz>
parents: 58521
diff changeset
1767 (if gdb-many-windows
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1768 (gdb-setup-windows)
54668
69a699e79a0d (gdb-view-source-function, gdb-view-assembler)
Nick Roberts <nickrob@snap.net.nz>
parents: 54617
diff changeset
1769 (gdb-get-create-buffer 'gdb-breakpoints-buffer)
58534
c655bc81dfc0 (gdb-view-source, gdb-selected-view):
Nick Roberts <nickrob@snap.net.nz>
parents: 58521
diff changeset
1770 (if gdb-show-main
58485
31d7630f91d4 (gdb-breakpoints-mode-map)
Nick Roberts <nickrob@snap.net.nz>
parents: 58470
diff changeset
1771 (let ((pop-up-windows t))
58534
c655bc81dfc0 (gdb-view-source, gdb-selected-view):
Nick Roberts <nickrob@snap.net.nz>
parents: 58521
diff changeset
1772 (display-buffer (gud-find-file gdb-main-file))))))
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1773
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1774 ;;from put-image
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1775 (defun gdb-put-string (putstring pos &optional dprop)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1776 "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
1777 PUTSTRING is displayed by putting an overlay into the current buffer with a
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1778 `before-string' STRING that has a `display' property whose value is
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1779 PUTSTRING."
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1780 (let ((gdb-string "x")
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1781 (buffer (current-buffer)))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1782 (let ((overlay (make-overlay pos pos buffer))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1783 (prop (or dprop
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1784 (list (list 'margin 'left-margin) putstring))))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1785 (put-text-property 0 (length gdb-string) 'display prop gdb-string)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1786 (overlay-put overlay 'put-break t)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1787 (overlay-put overlay 'before-string gdb-string))))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1788
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1789 ;;from remove-images
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1790 (defun gdb-remove-strings (start end &optional buffer)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1791 "Remove strings between START and END in BUFFER.
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1792 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
1793 BUFFER nil or omitted means use the current buffer."
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1794 (unless buffer
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1795 (setq buffer (current-buffer)))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1796 (let ((overlays (overlays-in start end)))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1797 (while overlays
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1798 (let ((overlay (car overlays)))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1799 (when (overlay-get overlay 'put-break)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1800 (delete-overlay overlay)))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1801 (setq overlays (cdr overlays)))))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1802
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1803 (defun gdb-put-breakpoint-icon (enabled)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1804 (let ((start (progn (beginning-of-line) (- (point) 1)))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1805 (end (progn (end-of-line) (+ (point) 1))))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1806 (gdb-remove-breakpoint-icons start end)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1807 (if (display-images-p)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1808 (if (>= (car (window-fringes)) 8)
54668
69a699e79a0d (gdb-view-source-function, gdb-view-assembler)
Nick Roberts <nickrob@snap.net.nz>
parents: 54617
diff changeset
1809 (gdb-put-string
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1810 nil (1+ start)
57262
df4b0ff293d8 (breakpoint): Define as fringe bitmap.
Kim F. Storm <storm@cua.dk>
parents: 56330
diff changeset
1811 `(left-fringe breakpoint
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1812 ,(if enabled
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1813 'breakpoint-enabled-bitmap-face
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1814 'breakpoint-disabled-bitmap-face)))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1815 (when (< left-margin-width 2)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1816 (save-current-buffer
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1817 (setq left-margin-width 2)
58534
c655bc81dfc0 (gdb-view-source, gdb-selected-view):
Nick Roberts <nickrob@snap.net.nz>
parents: 58521
diff changeset
1818 (if (get-buffer-window (current-buffer) 0)
56285
313e3a9f34ca (breakpoint-enabled-bitmap-face)
Kim F. Storm <storm@cua.dk>
parents: 56258
diff changeset
1819 (set-window-margins
58534
c655bc81dfc0 (gdb-view-source, gdb-selected-view):
Nick Roberts <nickrob@snap.net.nz>
parents: 58521
diff changeset
1820 (get-buffer-window (current-buffer) 0)
55328
4440fe0e7dc6 (gud-watch, gdb-display-buffer)
Nick Roberts <nickrob@snap.net.nz>
parents: 55217
diff changeset
1821 left-margin-width right-margin-width))))
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1822 (put-image
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1823 (if enabled
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1824 (or breakpoint-enabled-icon
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1825 (setq breakpoint-enabled-icon
54668
69a699e79a0d (gdb-view-source-function, gdb-view-assembler)
Nick Roberts <nickrob@snap.net.nz>
parents: 54617
diff changeset
1826 (find-image `((:type xpm :data
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1827 ,breakpoint-xpm-data
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1828 :ascent 100 :pointer hand)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1829 (:type pbm :data
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1830 ,breakpoint-enabled-pbm-data
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1831 :ascent 100 :pointer hand)))))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1832 (or breakpoint-disabled-icon
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1833 (setq breakpoint-disabled-icon
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1834 (find-image `((:type xpm :data
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1835 ,breakpoint-xpm-data
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1836 :conversion disabled
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1837 :ascent 100)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1838 (:type pbm :data
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1839 ,breakpoint-disabled-pbm-data
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1840 :ascent 100))))))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1841 (+ start 1) nil 'left-margin))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1842 (when (< left-margin-width 2)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1843 (save-current-buffer
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1844 (setq left-margin-width 2)
58534
c655bc81dfc0 (gdb-view-source, gdb-selected-view):
Nick Roberts <nickrob@snap.net.nz>
parents: 58521
diff changeset
1845 (if (get-buffer-window (current-buffer) 0)
56285
313e3a9f34ca (breakpoint-enabled-bitmap-face)
Kim F. Storm <storm@cua.dk>
parents: 56258
diff changeset
1846 (set-window-margins
58534
c655bc81dfc0 (gdb-view-source, gdb-selected-view):
Nick Roberts <nickrob@snap.net.nz>
parents: 58521
diff changeset
1847 (get-buffer-window (current-buffer) 0)
55328
4440fe0e7dc6 (gud-watch, gdb-display-buffer)
Nick Roberts <nickrob@snap.net.nz>
parents: 55217
diff changeset
1848 left-margin-width right-margin-width))))
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1849 (gdb-put-string (if enabled "B" "b") (1+ start)))))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1850
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1851 (defun gdb-remove-breakpoint-icons (start end &optional remove-margin)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1852 (gdb-remove-strings start end)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1853 (if (display-images-p)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1854 (remove-images start end))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1855 (when remove-margin
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1856 (setq left-margin-width 0)
58534
c655bc81dfc0 (gdb-view-source, gdb-selected-view):
Nick Roberts <nickrob@snap.net.nz>
parents: 58521
diff changeset
1857 (if (get-buffer-window (current-buffer) 0)
56285
313e3a9f34ca (breakpoint-enabled-bitmap-face)
Kim F. Storm <storm@cua.dk>
parents: 56258
diff changeset
1858 (set-window-margins
58534
c655bc81dfc0 (gdb-view-source, gdb-selected-view):
Nick Roberts <nickrob@snap.net.nz>
parents: 58521
diff changeset
1859 (get-buffer-window (current-buffer) 0)
55328
4440fe0e7dc6 (gud-watch, gdb-display-buffer)
Nick Roberts <nickrob@snap.net.nz>
parents: 55217
diff changeset
1860 left-margin-width right-margin-width))))
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1861
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1862
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1863 ;;
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1864 ;; Assembler buffer.
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1865 ;;
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1866 (gdb-set-buffer-rules 'gdb-assembler-buffer
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1867 'gdb-assembler-buffer-name
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1868 'gdb-assembler-mode)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1869
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1870 (def-gdb-auto-updated-buffer gdb-assembler-buffer
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1871 gdb-invalidate-assembler
55749
230865f1c59d (gdb-server-prefix): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 55696
diff changeset
1872 (concat gdb-server-prefix "disassemble " gdb-current-address "\n")
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1873 gdb-assembler-handler
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1874 gdb-assembler-custom)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1875
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1876 (defun gdb-assembler-custom ()
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1877 (let ((buffer (gdb-get-buffer 'gdb-assembler-buffer))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1878 (pos 1) (address) (flag))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1879 (with-current-buffer buffer
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1880 (if (not (equal gdb-current-address "main"))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1881 (progn
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1882 (goto-char (point-min))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1883 (if (re-search-forward gdb-current-address nil t)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1884 (progn
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1885 (setq pos (point))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1886 (beginning-of-line)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1887 (or gdb-overlay-arrow-position
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1888 (setq gdb-overlay-arrow-position (make-marker)))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1889 (set-marker gdb-overlay-arrow-position
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1890 (point) (current-buffer))))))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1891 ;; remove all breakpoint-icons in assembler buffer before updating.
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1892 (gdb-remove-breakpoint-icons (point-min) (point-max)))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1893 (with-current-buffer (gdb-get-buffer 'gdb-breakpoints-buffer)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1894 (goto-char (point-min))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1895 (while (< (point) (- (point-max) 1))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1896 (forward-line 1)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1897 (if (looking-at "[^\t].*breakpoint")
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1898 (progn
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1899 (looking-at
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1900 "[0-9]*\\s-*\\S-*\\s-*\\S-*\\s-*\\(.\\)\\s-*0x\\(\\S-*\\)")
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1901 (setq flag (char-after (match-beginning 1)))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1902 (setq address (match-string 2))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1903 ;; remove leading 0s from output of info break.
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1904 (if (string-match "^0+\\(.*\\)" address)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1905 (setq address (match-string 1 address)))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1906 (with-current-buffer buffer
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1907 (goto-char (point-min))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1908 (if (re-search-forward address nil t)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1909 (gdb-put-breakpoint-icon (eq flag ?y))))))))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1910 (if (not (equal gdb-current-address "main"))
58534
c655bc81dfc0 (gdb-view-source, gdb-selected-view):
Nick Roberts <nickrob@snap.net.nz>
parents: 58521
diff changeset
1911 (set-window-point (get-buffer-window buffer 0) pos))))
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1912
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1913 (defvar gdb-assembler-mode-map
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1914 (let ((map (make-sparse-keymap)))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1915 (suppress-keymap map)
58485
31d7630f91d4 (gdb-breakpoints-mode-map)
Nick Roberts <nickrob@snap.net.nz>
parents: 58470
diff changeset
1916 (define-key map "q" 'kill-this-buffer)
31d7630f91d4 (gdb-breakpoints-mode-map)
Nick Roberts <nickrob@snap.net.nz>
parents: 58470
diff changeset
1917 map))
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1918
57661
b59713cd72a2 (gdb-get-create-buffer): Allow modes to run
Nick Roberts <nickrob@snap.net.nz>
parents: 57350
diff changeset
1919 (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
1920 '(;; <__function.name+n>
4d6eec4c1ef8 * progmodes/gdb-ui.el (gdb-assembler-font-lock-keywords): Handle
Masatake YAMATO <jet@gyve.org>
parents: 57661
diff changeset
1921 ("<\\(\\(\\sw\\|[_.]\\)+\\)\\(\\+[0-9]+\\)?>"
4d6eec4c1ef8 * progmodes/gdb-ui.el (gdb-assembler-font-lock-keywords): Handle
Masatake YAMATO <jet@gyve.org>
parents: 57661
diff changeset
1922 (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
1923 ;; 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
1924 ("^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
1925 (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
1926 ;; %register(at least i386)
57661
b59713cd72a2 (gdb-get-create-buffer): Allow modes to run
Nick Roberts <nickrob@snap.net.nz>
parents: 57350
diff changeset
1927 ("%\\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
1928 ("^\\(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
1929 (1 font-lock-comment-face)
b59713cd72a2 (gdb-get-create-buffer): Allow modes to run
Nick Roberts <nickrob@snap.net.nz>
parents: 57350
diff changeset
1930 (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
1931 ("^\\(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
1932 "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
1933
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1934 (defun gdb-assembler-mode ()
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1935 "Major mode for viewing code assembler.
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1936
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1937 \\{gdb-assembler-mode-map}"
57661
b59713cd72a2 (gdb-get-create-buffer): Allow modes to run
Nick Roberts <nickrob@snap.net.nz>
parents: 57350
diff changeset
1938 (kill-all-local-variables)
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1939 (setq major-mode 'gdb-assembler-mode)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1940 (setq mode-name "Machine")
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1941 (setq gdb-overlay-arrow-position nil)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1942 (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
1943 (put 'gdb-overlay-arrow-position 'overlay-arrow-string "=>")
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1944 (setq fringes-outside-margins t)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1945 (setq buffer-read-only t)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1946 (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
1947 (gdb-invalidate-assembler)
b59713cd72a2 (gdb-get-create-buffer): Allow modes to run
Nick Roberts <nickrob@snap.net.nz>
parents: 57350
diff changeset
1948 (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
1949 '(gdb-assembler-font-lock-keywords))
b59713cd72a2 (gdb-get-create-buffer): Allow modes to run
Nick Roberts <nickrob@snap.net.nz>
parents: 57350
diff changeset
1950 (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
1951 'gdb-invalidate-assembler)
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1952
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1953 (defun gdb-assembler-buffer-name ()
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1954 (with-current-buffer gud-comint-buffer
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1955 (concat "*Machine Code " (gdb-get-target-string) "*")))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1956
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1957 (defun gdb-display-assembler-buffer ()
55400
1aaa031e318c Improve/extend documentation strings.
Nick Roberts <nickrob@snap.net.nz>
parents: 55330
diff changeset
1958 "Display disassembly view."
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1959 (interactive)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1960 (gdb-display-buffer
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1961 (gdb-get-create-buffer 'gdb-assembler-buffer)))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1962
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1963 (defun gdb-frame-assembler-buffer ()
55400
1aaa031e318c Improve/extend documentation strings.
Nick Roberts <nickrob@snap.net.nz>
parents: 55330
diff changeset
1964 "Display disassembly view in a new frame."
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1965 (interactive)
58521
54bb21951d18 (gdb-frame-parameters): Match height and
Nick Roberts <nickrob@snap.net.nz>
parents: 58485
diff changeset
1966 (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
1967 (special-display-frame-alist gdb-frame-parameters))
54bb21951d18 (gdb-frame-parameters): Match height and
Nick Roberts <nickrob@snap.net.nz>
parents: 58485
diff changeset
1968 (display-buffer (gdb-get-create-buffer 'gdb-assembler-buffer))))
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1969
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1970 ;; modified because if gdb-current-address has changed value a new command
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1971 ;; 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
1972 (defun gdb-invalidate-assembler (&optional ignored)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1973 (if (gdb-get-buffer 'gdb-assembler-buffer)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1974 (progn
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1975 (unless (string-equal gdb-current-frame gdb-previous-frame)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1976 (if (or (not (member 'gdb-invalidate-assembler
55749
230865f1c59d (gdb-server-prefix): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 55696
diff changeset
1977 gdb-pending-triggers))
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1978 (not (string-equal gdb-current-address
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1979 gdb-previous-address)))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1980 (progn
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1981 ;; take previous disassemble command off the queue
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1982 (with-current-buffer gud-comint-buffer
58485
31d7630f91d4 (gdb-breakpoints-mode-map)
Nick Roberts <nickrob@snap.net.nz>
parents: 58470
diff changeset
1983 (let ((queue gdb-input-queue))
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1984 (dolist (item queue)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1985 (if (equal (cdr item) '(gdb-assembler-handler))
55749
230865f1c59d (gdb-server-prefix): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 55696
diff changeset
1986 (setq gdb-input-queue
230865f1c59d (gdb-server-prefix): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 55696
diff changeset
1987 (delete item gdb-input-queue))))))
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1988 (gdb-enqueue-input
55749
230865f1c59d (gdb-server-prefix): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 55696
diff changeset
1989 (list (concat gdb-server-prefix "disassemble " gdb-current-address "\n")
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1990 'gdb-assembler-handler))
55749
230865f1c59d (gdb-server-prefix): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 55696
diff changeset
1991 (push 'gdb-invalidate-assembler gdb-pending-triggers)
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1992 (setq gdb-previous-address gdb-current-address)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1993 (setq gdb-previous-frame gdb-current-frame)))))))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1994
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1995 (defun gdb-get-current-frame ()
55749
230865f1c59d (gdb-server-prefix): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 55696
diff changeset
1996 (if (not (member 'gdb-get-current-frame gdb-pending-triggers))
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1997 (progn
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1998 (gdb-enqueue-input
55749
230865f1c59d (gdb-server-prefix): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 55696
diff changeset
1999 (list (concat gdb-server-prefix "info frame\n") 'gdb-frame-handler))
230865f1c59d (gdb-server-prefix): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 55696
diff changeset
2000 (push 'gdb-get-current-frame
230865f1c59d (gdb-server-prefix): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 55696
diff changeset
2001 gdb-pending-triggers))))
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2002
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2003 (defun gdb-frame-handler ()
55749
230865f1c59d (gdb-server-prefix): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 55696
diff changeset
2004 (setq gdb-pending-triggers
230865f1c59d (gdb-server-prefix): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 55696
diff changeset
2005 (delq 'gdb-get-current-frame gdb-pending-triggers))
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2006 (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
2007 (goto-char (point-min))
58049
fd0093bd412a (gdb-current-stack-level): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 57982
diff changeset
2008 (if (looking-at "Stack level \\([0-9]+\\)")
fd0093bd412a (gdb-current-stack-level): New variable.
Nick Roberts <nickrob@snap.net.nz>
parents: 57982
diff changeset
2009 (setq gdb-current-stack-level (match-string 1)))
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2010 (forward-line)
54962
c3272c09f927 (gdb-goto-info): Require 'info.
Nick Roberts <nickrob@snap.net.nz>
parents: 54901
diff changeset
2011 (if (looking-at ".*=\\s-+0x\\(\\S-*\\)\\s-+in\\s-+\\(\\S-*?\\);? ")
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2012 (progn
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2013 (setq gdb-current-frame (match-string 2))
55850
63ca25eb73a1 (gdb-current-frame, gud-watch)
Nick Roberts <nickrob@snap.net.nz>
parents: 55764
diff changeset
2014 (if (gdb-get-buffer 'gdb-locals-buffer)
63ca25eb73a1 (gdb-current-frame, gud-watch)
Nick Roberts <nickrob@snap.net.nz>
parents: 55764
diff changeset
2015 (with-current-buffer (gdb-get-buffer 'gdb-locals-buffer)
63ca25eb73a1 (gdb-current-frame, gud-watch)
Nick Roberts <nickrob@snap.net.nz>
parents: 55764
diff changeset
2016 (setq mode-name (concat "Locals:" gdb-current-frame))))
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2017 (let ((address (match-string 1)))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2018 ;; remove leading 0s from output of info frame command.
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2019 (if (string-match "^0+\\(.*\\)" address)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2020 (setq gdb-current-address
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2021 (concat "0x" (match-string 1 address)))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2022 (setq gdb-current-address (concat "0x" address))))
58534
c655bc81dfc0 (gdb-view-source, gdb-selected-view):
Nick Roberts <nickrob@snap.net.nz>
parents: 58521
diff changeset
2023 (if (not (re-search-forward "(\\S-*:[0-9]*);" nil t))
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2024 ;;update with new frame for machine code if necessary
58534
c655bc81dfc0 (gdb-view-source, gdb-selected-view):
Nick Roberts <nickrob@snap.net.nz>
parents: 58521
diff changeset
2025 (gdb-invalidate-assembler)))))
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2026 (if (re-search-forward " source language \\(\\S-*\\)\." nil t)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2027 (setq gdb-current-language (match-string 1))))
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2028
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2029 (provide 'gdb-ui)
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2030
55696
ed6e91c53c82 (gdb-reset): Use unless. Fix regexp.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55507
diff changeset
2031 ;; arch-tag: e9fb00c5-74ef-469f-a088-37384caae352
54538
35328b5dc91b Moved from lisp directory
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2032 ;;; gdb-ui.el ends here