annotate lisp/progmodes/gdb-ui.el @ 56687:fb266772e0e7

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