annotate lisp/progmodes/gdb-ui.el @ 57822:7cda0787d8cd

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