annotate lisp/gdb-ui.el @ 49576:873d790b25eb

*** empty log message ***
author Juanma Barranquero <lekktu@gmail.com>
date Mon, 03 Feb 2003 16:31:35 +0000
parents 7c4bc41333d1
children 37645a051842
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1 ;;; gdb-ui.el --- User Interface for running GDB
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
3 ;; Author: Nick Roberts <nick@nick.uklinux.net>
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
4 ;; Maintainer: FSF
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
5 ;; Keywords: unix, tools
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
6
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
7 ;; Copyright (C) 2002 Free Software Foundation, Inc.
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
8
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
9 ;; This file is part of GNU Emacs.
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
10
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
11 ;; GNU Emacs is free software; you can redistribute it and/or modify
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
12 ;; it under the terms of the GNU General Public License as published by
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
13 ;; the Free Software Foundation; either version 2, or (at your option)
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
14 ;; any later version.
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
15
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
16 ;; GNU Emacs is distributed in the hope that it will be useful,
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
19 ;; GNU General Public License for more details.
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
20
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
21 ;; You should have received a copy of the GNU General Public License
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
22 ;; along with GNU Emacs; see the file COPYING. If not, write to the
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
23 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
24 ;; Boston, MA 02111-1307, USA.
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
25
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
26 ;;; Commentary:
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
27
49249
7c4bc41333d1 Improve commentary.
Nick Roberts <nickrob@snap.net.nz>
parents: 49147
diff changeset
28 ;; This mode acts as a graphical user interface to GDB. You can interact with
7c4bc41333d1 Improve commentary.
Nick Roberts <nickrob@snap.net.nz>
parents: 49147
diff changeset
29 ;; GDB through the GUD buffer in the usual way, but there are also further
7c4bc41333d1 Improve commentary.
Nick Roberts <nickrob@snap.net.nz>
parents: 49147
diff changeset
30 ;; buffers which control the execution and describe the state of your program.
7c4bc41333d1 Improve commentary.
Nick Roberts <nickrob@snap.net.nz>
parents: 49147
diff changeset
31 ;; It separates the input/output of your program from that of GDB and displays
7c4bc41333d1 Improve commentary.
Nick Roberts <nickrob@snap.net.nz>
parents: 49147
diff changeset
32 ;; expressions and their current values in their own buffers. It also uses
7c4bc41333d1 Improve commentary.
Nick Roberts <nickrob@snap.net.nz>
parents: 49147
diff changeset
33 ;; features of Emacs 21 such as the display margin for breakpoints, and the
7c4bc41333d1 Improve commentary.
Nick Roberts <nickrob@snap.net.nz>
parents: 49147
diff changeset
34 ;; toolbar (see the GDB User Interface section in the Emacs info manual).
48963
1bb53161a4b9 (gdb-info-display-custom): Ensure that frames/buffers
Nick Roberts <nickrob@snap.net.nz>
parents: 48955
diff changeset
35
49249
7c4bc41333d1 Improve commentary.
Nick Roberts <nickrob@snap.net.nz>
parents: 49147
diff changeset
36 ;; Start the debugger with M-x gdba.
7c4bc41333d1 Improve commentary.
Nick Roberts <nickrob@snap.net.nz>
parents: 49147
diff changeset
37
7c4bc41333d1 Improve commentary.
Nick Roberts <nickrob@snap.net.nz>
parents: 49147
diff changeset
38 ;; This file is based on gdba.el from GDB 5.0 written by Tom Lord and Jim
7c4bc41333d1 Improve commentary.
Nick Roberts <nickrob@snap.net.nz>
parents: 49147
diff changeset
39 ;; Kingdon and uses GDB's annotation interface. You don't need to know about
7c4bc41333d1 Improve commentary.
Nick Roberts <nickrob@snap.net.nz>
parents: 49147
diff changeset
40 ;; annotations to use this mode as a debugger, but if you are interested
7c4bc41333d1 Improve commentary.
Nick Roberts <nickrob@snap.net.nz>
parents: 49147
diff changeset
41 ;; developing the mode itself, then see the Annotations section in the GDB
7c4bc41333d1 Improve commentary.
Nick Roberts <nickrob@snap.net.nz>
parents: 49147
diff changeset
42 ;; info manual.
48921
3aa5ba679145 Remove the concept of an instance. This means that a lot of functions have
Nick Roberts <nickrob@snap.net.nz>
parents: 48884
diff changeset
43 ;;
3aa5ba679145 Remove the concept of an instance. This means that a lot of functions have
Nick Roberts <nickrob@snap.net.nz>
parents: 48884
diff changeset
44 ;; Known Bugs: Does not auto-display arrays of structures or structures
48963
1bb53161a4b9 (gdb-info-display-custom): Ensure that frames/buffers
Nick Roberts <nickrob@snap.net.nz>
parents: 48955
diff changeset
45 ;; containing arrays.
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
46
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
47 ;;; Code:
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
48
48300
69646014abb3 Fix feature name in `require'.
Juanma Barranquero <lekktu@gmail.com>
parents: 48292
diff changeset
49 (require 'gud)
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
50
49249
7c4bc41333d1 Improve commentary.
Nick Roberts <nickrob@snap.net.nz>
parents: 49147
diff changeset
51 (defcustom gdb-window-height 20
7c4bc41333d1 Improve commentary.
Nick Roberts <nickrob@snap.net.nz>
parents: 49147
diff changeset
52 "*Number of lines in a frame for a displayed expression in GDB-UI."
7c4bc41333d1 Improve commentary.
Nick Roberts <nickrob@snap.net.nz>
parents: 49147
diff changeset
53 :type 'integer
7c4bc41333d1 Improve commentary.
Nick Roberts <nickrob@snap.net.nz>
parents: 49147
diff changeset
54 :group 'gud)
7c4bc41333d1 Improve commentary.
Nick Roberts <nickrob@snap.net.nz>
parents: 49147
diff changeset
55
7c4bc41333d1 Improve commentary.
Nick Roberts <nickrob@snap.net.nz>
parents: 49147
diff changeset
56 (defcustom gdb-window-width 30
7c4bc41333d1 Improve commentary.
Nick Roberts <nickrob@snap.net.nz>
parents: 49147
diff changeset
57 "Width of a frame for a displayed expression in GDB-UI."
7c4bc41333d1 Improve commentary.
Nick Roberts <nickrob@snap.net.nz>
parents: 49147
diff changeset
58 :type 'integer
7c4bc41333d1 Improve commentary.
Nick Roberts <nickrob@snap.net.nz>
parents: 49147
diff changeset
59 :group 'gud)
7c4bc41333d1 Improve commentary.
Nick Roberts <nickrob@snap.net.nz>
parents: 49147
diff changeset
60
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
61 (defvar gdb-main-or-pc nil "Initialisation for Assembler buffer.")
48498
8fdedd7dca85 General tidying. Patches from Stefan Monnier.
Nick Roberts <nickrob@snap.net.nz>
parents: 48300
diff changeset
62 (defvar gdb-current-address nil)
8fdedd7dca85 General tidying. Patches from Stefan Monnier.
Nick Roberts <nickrob@snap.net.nz>
parents: 48300
diff changeset
63 (defvar gdb-display-in-progress nil)
8fdedd7dca85 General tidying. Patches from Stefan Monnier.
Nick Roberts <nickrob@snap.net.nz>
parents: 48300
diff changeset
64 (defvar gdb-dive nil)
49000
f3c5848184cb (gdb-delete-display): Rename (gdb-delete-expression).
Nick Roberts <nickrob@snap.net.nz>
parents: 48963
diff changeset
65 (defvar gdb-buffer-type nil)
f3c5848184cb (gdb-delete-display): Rename (gdb-delete-expression).
Nick Roberts <nickrob@snap.net.nz>
parents: 48963
diff changeset
66 (defvar gdb-variables '()
f3c5848184cb (gdb-delete-display): Rename (gdb-delete-expression).
Nick Roberts <nickrob@snap.net.nz>
parents: 48963
diff changeset
67 "A list of variables that are local to the GUD buffer.")
f3c5848184cb (gdb-delete-display): Rename (gdb-delete-expression).
Nick Roberts <nickrob@snap.net.nz>
parents: 48963
diff changeset
68
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
69
48515
3216cd45d6d2 Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents: 48498
diff changeset
70 ;;;###autoload
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
71 (defun gdba (command-line)
48827
dc51e4b2d5c1 Improve documentation strings.
Nick Roberts <nickrob@snap.net.nz>
parents: 48738
diff changeset
72 "Run gdb on program FILE in buffer *gud-FILE*.
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
73 The directory containing FILE becomes the initial working directory
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
74 and source-file directory for your debugger.
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
75
48827
dc51e4b2d5c1 Improve documentation strings.
Nick Roberts <nickrob@snap.net.nz>
parents: 48738
diff changeset
76 If `gdb-many-windows' is nil (the default value) then gdb starts with
dc51e4b2d5c1 Improve documentation strings.
Nick Roberts <nickrob@snap.net.nz>
parents: 48738
diff changeset
77 just two windows : the GUD and the source buffer. If it is t the
dc51e4b2d5c1 Improve documentation strings.
Nick Roberts <nickrob@snap.net.nz>
parents: 48738
diff changeset
78 following layout will appear (keybindings given in relevant buffer) :
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
79
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
80 ---------------------------------------------------------------------
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
81 GDB Toolbar
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
82 ---------------------------------------------------------------------
48827
dc51e4b2d5c1 Improve documentation strings.
Nick Roberts <nickrob@snap.net.nz>
parents: 48738
diff changeset
83 GUD buffer (I/O of GDB) | Locals buffer
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
84 |
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
85 |
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
86 |
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
87 ---------------------------------------------------------------------
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
88 Source buffer | Input/Output (of debuggee) buffer
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
89 | (comint-mode)
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
90 |
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
91 |
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
92 |
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
93 |
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
94 |
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
95 |
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
96 ---------------------------------------------------------------------
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
97 Stack buffer | Breakpoints buffer
49000
f3c5848184cb (gdb-delete-display): Rename (gdb-delete-expression).
Nick Roberts <nickrob@snap.net.nz>
parents: 48963
diff changeset
98 RET gdb-frames-select | SPC gdb-toggle-breakpoint
f3c5848184cb (gdb-delete-display): Rename (gdb-delete-expression).
Nick Roberts <nickrob@snap.net.nz>
parents: 48963
diff changeset
99 | RET gdb-goto-breakpoint
f3c5848184cb (gdb-delete-display): Rename (gdb-delete-expression).
Nick Roberts <nickrob@snap.net.nz>
parents: 48963
diff changeset
100 | d gdb-delete-breakpoint
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
101 ---------------------------------------------------------------------
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
102
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
103 All the buffers share the toolbar and source should always display in the same
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
104 window e.g after typing g on a breakpoint in the breakpoints buffer. Breakpoint
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
105 icons are displayed both by setting a break with gud-break and by typing break
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
106 in the GUD buffer.
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
107
48827
dc51e4b2d5c1 Improve documentation strings.
Nick Roberts <nickrob@snap.net.nz>
parents: 48738
diff changeset
108 This works best (depending on the size of your monitor) using most of the
dc51e4b2d5c1 Improve documentation strings.
Nick Roberts <nickrob@snap.net.nz>
parents: 48738
diff changeset
109 screen.
dc51e4b2d5c1 Improve documentation strings.
Nick Roberts <nickrob@snap.net.nz>
parents: 48738
diff changeset
110
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
111 Displayed expressions appear in separate frames. Arrays may be displayed
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
112 as slices and visualised using the graph program from plotutils if installed.
48827
dc51e4b2d5c1 Improve documentation strings.
Nick Roberts <nickrob@snap.net.nz>
parents: 48738
diff changeset
113 Pointers in structures may be followed in a tree-like fashion.
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
114
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
115 The following interactive lisp functions help control operation :
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
116
48827
dc51e4b2d5c1 Improve documentation strings.
Nick Roberts <nickrob@snap.net.nz>
parents: 48738
diff changeset
117 `gdb-many-windows' - Toggle the number of windows gdb uses.
dc51e4b2d5c1 Improve documentation strings.
Nick Roberts <nickrob@snap.net.nz>
parents: 48738
diff changeset
118 `gdb-restore-windows' - To restore the window layout.
dc51e4b2d5c1 Improve documentation strings.
Nick Roberts <nickrob@snap.net.nz>
parents: 48738
diff changeset
119 `gdb-quit' - To delete (most) of the buffers used by GDB-UI and
dc51e4b2d5c1 Improve documentation strings.
Nick Roberts <nickrob@snap.net.nz>
parents: 48738
diff changeset
120 reset variables."
48963
1bb53161a4b9 (gdb-info-display-custom): Ensure that frames/buffers
Nick Roberts <nickrob@snap.net.nz>
parents: 48955
diff changeset
121 ;;
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
122 (interactive (list (gud-query-cmdline 'gdba)))
48963
1bb53161a4b9 (gdb-info-display-custom): Ensure that frames/buffers
Nick Roberts <nickrob@snap.net.nz>
parents: 48955
diff changeset
123 ;;
48682
a74dd42cf01d (gud-gdb-complete-string, gud-gdb-complete-break)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48662
diff changeset
124 ;; Let's start with a basic gud-gdb buffer and then modify it a bit.
a74dd42cf01d (gud-gdb-complete-string, gud-gdb-complete-break)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48662
diff changeset
125 (gdb command-line)
48963
1bb53161a4b9 (gdb-info-display-custom): Ensure that frames/buffers
Nick Roberts <nickrob@snap.net.nz>
parents: 48955
diff changeset
126 ;;
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
127 (set (make-local-variable 'gud-minor-mode) 'gdba)
48884
f774c94b3b5e (gdba-marker-filter, gdb-output-burst): Merge and
Nick Roberts <nickrob@snap.net.nz>
parents: 48827
diff changeset
128 (set (make-local-variable 'gud-marker-filter) 'gud-gdba-marker-filter)
48963
1bb53161a4b9 (gdb-info-display-custom): Ensure that frames/buffers
Nick Roberts <nickrob@snap.net.nz>
parents: 48955
diff changeset
129 ;;
48682
a74dd42cf01d (gud-gdb-complete-string, gud-gdb-complete-break)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48662
diff changeset
130 (gud-def gud-break (if (not (string-equal mode-name "Assembler"))
a74dd42cf01d (gud-gdb-complete-string, gud-gdb-complete-break)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48662
diff changeset
131 (gud-call "break %f:%l" arg)
a74dd42cf01d (gud-gdb-complete-string, gud-gdb-complete-break)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48662
diff changeset
132 (save-excursion
a74dd42cf01d (gud-gdb-complete-string, gud-gdb-complete-break)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48662
diff changeset
133 (beginning-of-line)
a74dd42cf01d (gud-gdb-complete-string, gud-gdb-complete-break)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48662
diff changeset
134 (forward-char 2)
a74dd42cf01d (gud-gdb-complete-string, gud-gdb-complete-break)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48662
diff changeset
135 (gud-call "break *%a" arg)))
a74dd42cf01d (gud-gdb-complete-string, gud-gdb-complete-break)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48662
diff changeset
136 "\C-b" "Set breakpoint at current line or address.")
48963
1bb53161a4b9 (gdb-info-display-custom): Ensure that frames/buffers
Nick Roberts <nickrob@snap.net.nz>
parents: 48955
diff changeset
137 ;;
48682
a74dd42cf01d (gud-gdb-complete-string, gud-gdb-complete-break)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48662
diff changeset
138 (gud-def gud-remove (if (not (string-equal mode-name "Assembler"))
a74dd42cf01d (gud-gdb-complete-string, gud-gdb-complete-break)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48662
diff changeset
139 (gud-call "clear %f:%l" arg)
a74dd42cf01d (gud-gdb-complete-string, gud-gdb-complete-break)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48662
diff changeset
140 (save-excursion
a74dd42cf01d (gud-gdb-complete-string, gud-gdb-complete-break)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48662
diff changeset
141 (beginning-of-line)
a74dd42cf01d (gud-gdb-complete-string, gud-gdb-complete-break)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48662
diff changeset
142 (forward-char 2)
a74dd42cf01d (gud-gdb-complete-string, gud-gdb-complete-break)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48662
diff changeset
143 (gud-call "clear *%a" arg)))
a74dd42cf01d (gud-gdb-complete-string, gud-gdb-complete-break)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48662
diff changeset
144 "\C-d" "Remove breakpoint at current line or address.")
48963
1bb53161a4b9 (gdb-info-display-custom): Ensure that frames/buffers
Nick Roberts <nickrob@snap.net.nz>
parents: 48955
diff changeset
145 ;;
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
146 (setq comint-input-sender 'gdb-send)
48963
1bb53161a4b9 (gdb-info-display-custom): Ensure that frames/buffers
Nick Roberts <nickrob@snap.net.nz>
parents: 48955
diff changeset
147 ;;
48662
d29870d63092 Fix up comment markers.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48661
diff changeset
148 ;; (re-)initialise
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
149 (setq gdb-main-or-pc "main")
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
150 (setq gdb-current-address nil)
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
151 (setq gdb-display-in-progress nil)
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
152 (setq gdb-dive nil)
48963
1bb53161a4b9 (gdb-info-display-custom): Ensure that frames/buffers
Nick Roberts <nickrob@snap.net.nz>
parents: 48955
diff changeset
153 ;;
48921
3aa5ba679145 Remove the concept of an instance. This means that a lot of functions have
Nick Roberts <nickrob@snap.net.nz>
parents: 48884
diff changeset
154 (mapc 'make-local-variable gdb-variables)
48884
f774c94b3b5e (gdba-marker-filter, gdb-output-burst): Merge and
Nick Roberts <nickrob@snap.net.nz>
parents: 48827
diff changeset
155 (setq gdb-buffer-type 'gdba)
48963
1bb53161a4b9 (gdb-info-display-custom): Ensure that frames/buffers
Nick Roberts <nickrob@snap.net.nz>
parents: 48955
diff changeset
156 ;;
48682
a74dd42cf01d (gud-gdb-complete-string, gud-gdb-complete-break)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48662
diff changeset
157 (gdb-clear-inferior-io)
48963
1bb53161a4b9 (gdb-info-display-custom): Ensure that frames/buffers
Nick Roberts <nickrob@snap.net.nz>
parents: 48955
diff changeset
158 ;;
49039
6c5f45b01d2e Acknowledge Tom Lord as author of gdba.el.
Nick Roberts <nickrob@snap.net.nz>
parents: 49000
diff changeset
159 (gdb-enqueue-input (list "set height 0\n" 'ignore))
48662
d29870d63092 Fix up comment markers.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48661
diff changeset
160 ;; find source file and compilation directory here
48921
3aa5ba679145 Remove the concept of an instance. This means that a lot of functions have
Nick Roberts <nickrob@snap.net.nz>
parents: 48884
diff changeset
161 (gdb-enqueue-input (list "server list\n" 'ignore))
3aa5ba679145 Remove the concept of an instance. This means that a lot of functions have
Nick Roberts <nickrob@snap.net.nz>
parents: 48884
diff changeset
162 (gdb-enqueue-input (list "server info source\n"
3aa5ba679145 Remove the concept of an instance. This means that a lot of functions have
Nick Roberts <nickrob@snap.net.nz>
parents: 48884
diff changeset
163 'gdb-source-info))
48963
1bb53161a4b9 (gdb-info-display-custom): Ensure that frames/buffers
Nick Roberts <nickrob@snap.net.nz>
parents: 48955
diff changeset
164 ;;
48682
a74dd42cf01d (gud-gdb-complete-string, gud-gdb-complete-break)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48662
diff changeset
165 (run-hooks 'gdba-mode-hook))
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
166
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
167 (defun gud-display ()
49039
6c5f45b01d2e Acknowledge Tom Lord as author of gdba.el.
Nick Roberts <nickrob@snap.net.nz>
parents: 49000
diff changeset
168 "Auto-display (possibly dereferenced) C expression at point."
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
169 (interactive)
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
170 (save-excursion
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
171 (let ((expr (gud-find-c-expr)))
48921
3aa5ba679145 Remove the concept of an instance. This means that a lot of functions have
Nick Roberts <nickrob@snap.net.nz>
parents: 48884
diff changeset
172 (gdb-enqueue-input
49147
8a40184e2f0e (gud-display): Use GDB command ptype instead of whatis
Nick Roberts <nickrob@snap.net.nz>
parents: 49039
diff changeset
173 (list (concat "server ptype " expr "\n")
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
174 `(lambda () (gud-display1 ,expr)))))))
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
175
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
176 (defun gud-display1 (expr)
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
177 (goto-char (point-min))
49147
8a40184e2f0e (gud-display): Use GDB command ptype instead of whatis
Nick Roberts <nickrob@snap.net.nz>
parents: 49039
diff changeset
178 (if (looking-at "No symbol")
8a40184e2f0e (gud-display): Use GDB command ptype instead of whatis
Nick Roberts <nickrob@snap.net.nz>
parents: 49039
diff changeset
179 (progn
8a40184e2f0e (gud-display): Use GDB command ptype instead of whatis
Nick Roberts <nickrob@snap.net.nz>
parents: 49039
diff changeset
180 (gdb-set-output-sink 'user)
8a40184e2f0e (gud-display): Use GDB command ptype instead of whatis
Nick Roberts <nickrob@snap.net.nz>
parents: 49039
diff changeset
181 (gud-call (concat "server ptype " expr)))
8a40184e2f0e (gud-display): Use GDB command ptype instead of whatis
Nick Roberts <nickrob@snap.net.nz>
parents: 49039
diff changeset
182 (goto-char (- (point-max) 1))
8a40184e2f0e (gud-display): Use GDB command ptype instead of whatis
Nick Roberts <nickrob@snap.net.nz>
parents: 49039
diff changeset
183 (if (equal (char-before) (string-to-char "\*"))
8a40184e2f0e (gud-display): Use GDB command ptype instead of whatis
Nick Roberts <nickrob@snap.net.nz>
parents: 49039
diff changeset
184 (gdb-enqueue-input
8a40184e2f0e (gud-display): Use GDB command ptype instead of whatis
Nick Roberts <nickrob@snap.net.nz>
parents: 49039
diff changeset
185 (list (concat "server display* " expr "\n") 'ignore))
48921
3aa5ba679145 Remove the concept of an instance. This means that a lot of functions have
Nick Roberts <nickrob@snap.net.nz>
parents: 48884
diff changeset
186 (gdb-enqueue-input
49147
8a40184e2f0e (gud-display): Use GDB command ptype instead of whatis
Nick Roberts <nickrob@snap.net.nz>
parents: 49039
diff changeset
187 (list (concat "server display " expr "\n") 'ignore)))))
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
188
49039
6c5f45b01d2e Acknowledge Tom Lord as author of gdba.el.
Nick Roberts <nickrob@snap.net.nz>
parents: 49000
diff changeset
189 ; this would messy because these bindings don't work with M-x gdb
6c5f45b01d2e Acknowledge Tom Lord as author of gdba.el.
Nick Roberts <nickrob@snap.net.nz>
parents: 49000
diff changeset
190 ; (define-key global-map "\C-x\C-a\C-a" 'gud-display)
6c5f45b01d2e Acknowledge Tom Lord as author of gdba.el.
Nick Roberts <nickrob@snap.net.nz>
parents: 49000
diff changeset
191 ; (define-key gud-minor-mode-map "\C-c\C-a" 'gud-display)
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
192
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
193
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
194
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
195 ;; ======================================================================
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
196 ;;
48921
3aa5ba679145 Remove the concept of an instance. This means that a lot of functions have
Nick Roberts <nickrob@snap.net.nz>
parents: 48884
diff changeset
197 ;; In this world, there are gdb variables (of unspecified
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
198 ;; representation) and buffers associated with those objects.
48921
3aa5ba679145 Remove the concept of an instance. This means that a lot of functions have
Nick Roberts <nickrob@snap.net.nz>
parents: 48884
diff changeset
199 ;; The list of variables is built up by the expansions of
3aa5ba679145 Remove the concept of an instance. This means that a lot of functions have
Nick Roberts <nickrob@snap.net.nz>
parents: 48884
diff changeset
200 ;; def-gdb-variable
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
201
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
202 (defmacro def-gdb-var (root-symbol &optional default doc)
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
203 (let* ((root (symbol-name root-symbol))
48921
3aa5ba679145 Remove the concept of an instance. This means that a lot of functions have
Nick Roberts <nickrob@snap.net.nz>
parents: 48884
diff changeset
204 (accessor (intern (concat "gdb-get-" root)))
3aa5ba679145 Remove the concept of an instance. This means that a lot of functions have
Nick Roberts <nickrob@snap.net.nz>
parents: 48884
diff changeset
205 (setter (intern (concat "gdb-set-" root)))
48640
7bc8b0b65a02 (gdba): Use the default for gud-find-file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48639
diff changeset
206 (name (intern (concat "gdb-" root))))
7bc8b0b65a02 (gdba): Use the default for gud-find-file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48639
diff changeset
207 `(progn
7bc8b0b65a02 (gdba): Use the default for gud-find-file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48639
diff changeset
208 (defvar ,name ,default ,doc)
48921
3aa5ba679145 Remove the concept of an instance. This means that a lot of functions have
Nick Roberts <nickrob@snap.net.nz>
parents: 48884
diff changeset
209 (if (not (memq ',name gdb-variables))
3aa5ba679145 Remove the concept of an instance. This means that a lot of functions have
Nick Roberts <nickrob@snap.net.nz>
parents: 48884
diff changeset
210 (push ',name gdb-variables))
48685
19bf840bede8 Replace uses of (gdb-get-instance-buffer 'gdba) and
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48682
diff changeset
211 (defun ,accessor ()
19bf840bede8 Replace uses of (gdb-get-instance-buffer 'gdba) and
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48682
diff changeset
212 (buffer-local-value ',name gud-comint-buffer))
19bf840bede8 Replace uses of (gdb-get-instance-buffer 'gdba) and
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48682
diff changeset
213 (defun ,setter (val)
19bf840bede8 Replace uses of (gdb-get-instance-buffer 'gdba) and
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48682
diff changeset
214 (with-current-buffer gud-comint-buffer
19bf840bede8 Replace uses of (gdb-get-instance-buffer 'gdba) and
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48682
diff changeset
215 (setq ,name val))))))
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
216
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
217 (def-gdb-var buffer-type nil
48921
3aa5ba679145 Remove the concept of an instance. This means that a lot of functions have
Nick Roberts <nickrob@snap.net.nz>
parents: 48884
diff changeset
218 "One of the symbols bound in gdb-buffer-rules")
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
219
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
220 (def-gdb-var burst ""
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
221 "A string of characters from gdb that have not yet been processed.")
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
222
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
223 (def-gdb-var input-queue ()
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
224 "A list of high priority gdb command objects.")
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
225
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
226 (def-gdb-var idle-input-queue ()
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
227 "A list of low priority gdb command objects.")
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
228
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
229 (def-gdb-var prompting nil
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
230 "True when gdb is idle with no pending input.")
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
231
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
232 (def-gdb-var output-sink 'user
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
233 "The disposition of the output of the current gdb command.
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
234 Possible values are these symbols:
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
235
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
236 user -- gdb output should be copied to the GUD buffer
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
237 for the user to see.
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
238
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
239 inferior -- gdb output should be copied to the inferior-io buffer
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
240
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
241 pre-emacs -- output should be ignored util the post-prompt
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
242 annotation is received. Then the output-sink
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
243 becomes:...
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
244 emacs -- output should be collected in the partial-output-buffer
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
245 for subsequent processing by a command. This is the
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
246 disposition of output generated by commands that
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
247 gdb mode sends to gdb on its own behalf.
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
248 post-emacs -- ignore input until the prompt annotation is
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
249 received, then go to USER disposition.
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
250 ")
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
251
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
252 (def-gdb-var current-item nil
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
253 "The most recent command item sent to gdb.")
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
254
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
255 (def-gdb-var pending-triggers '()
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
256 "A list of trigger functions that have run later than their output
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
257 handlers.")
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
258
48921
3aa5ba679145 Remove the concept of an instance. This means that a lot of functions have
Nick Roberts <nickrob@snap.net.nz>
parents: 48884
diff changeset
259 ;; end of gdb variables
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
260
48921
3aa5ba679145 Remove the concept of an instance. This means that a lot of functions have
Nick Roberts <nickrob@snap.net.nz>
parents: 48884
diff changeset
261 (defun gdb-get-target-string ()
48884
f774c94b3b5e (gdba-marker-filter, gdb-output-burst): Merge and
Nick Roberts <nickrob@snap.net.nz>
parents: 48827
diff changeset
262 (with-current-buffer gud-comint-buffer
f774c94b3b5e (gdba-marker-filter, gdb-output-burst): Merge and
Nick Roberts <nickrob@snap.net.nz>
parents: 48827
diff changeset
263 gud-target-name))
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
264
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
265
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
266 ;;
48921
3aa5ba679145 Remove the concept of an instance. This means that a lot of functions have
Nick Roberts <nickrob@snap.net.nz>
parents: 48884
diff changeset
267 ;; gdb buffers.
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
268 ;;
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
269 ;; Each buffer has a TYPE -- a symbol that identifies the function
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
270 ;; of that particular buffer.
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
271 ;;
48738
81dc78298a54 Remove inappropriate key-bindings.
Nick Roberts <nickrob@snap.net.nz>
parents: 48685
diff changeset
272 ;; The usual gdb interaction buffer is given the type `gdba' and
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
273 ;; is constructed specially.
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
274 ;;
48921
3aa5ba679145 Remove the concept of an instance. This means that a lot of functions have
Nick Roberts <nickrob@snap.net.nz>
parents: 48884
diff changeset
275 ;; Others are constructed by gdb-get-create-buffer and
3aa5ba679145 Remove the concept of an instance. This means that a lot of functions have
Nick Roberts <nickrob@snap.net.nz>
parents: 48884
diff changeset
276 ;; named according to the rules set forth in the gdb-buffer-rules-assoc
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
277
48921
3aa5ba679145 Remove the concept of an instance. This means that a lot of functions have
Nick Roberts <nickrob@snap.net.nz>
parents: 48884
diff changeset
278 (defvar gdb-buffer-rules-assoc '())
48515
3216cd45d6d2 Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents: 48498
diff changeset
279
48921
3aa5ba679145 Remove the concept of an instance. This means that a lot of functions have
Nick Roberts <nickrob@snap.net.nz>
parents: 48884
diff changeset
280 (defun gdb-get-buffer (key)
3aa5ba679145 Remove the concept of an instance. This means that a lot of functions have
Nick Roberts <nickrob@snap.net.nz>
parents: 48884
diff changeset
281 "Return the gdb buffer tagged with type KEY.
3aa5ba679145 Remove the concept of an instance. This means that a lot of functions have
Nick Roberts <nickrob@snap.net.nz>
parents: 48884
diff changeset
282 The key should be one of the cars in `gdb-buffer-rules-assoc'."
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
283 (save-excursion
48515
3216cd45d6d2 Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents: 48498
diff changeset
284 (gdb-look-for-tagged-buffer key (buffer-list))))
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
285
48921
3aa5ba679145 Remove the concept of an instance. This means that a lot of functions have
Nick Roberts <nickrob@snap.net.nz>
parents: 48884
diff changeset
286 (defun gdb-get-create-buffer (key)
3aa5ba679145 Remove the concept of an instance. This means that a lot of functions have
Nick Roberts <nickrob@snap.net.nz>
parents: 48884
diff changeset
287 "Create a new gdb buffer of the type specified by KEY.
3aa5ba679145 Remove the concept of an instance. This means that a lot of functions have
Nick Roberts <nickrob@snap.net.nz>
parents: 48884
diff changeset
288 The key should be one of the cars in `gdb-buffer-rules-assoc'."
3aa5ba679145 Remove the concept of an instance. This means that a lot of functions have
Nick Roberts <nickrob@snap.net.nz>
parents: 48884
diff changeset
289 (or (gdb-get-buffer key)
3aa5ba679145 Remove the concept of an instance. This means that a lot of functions have
Nick Roberts <nickrob@snap.net.nz>
parents: 48884
diff changeset
290 (let* ((rules (assoc key gdb-buffer-rules-assoc))
48515
3216cd45d6d2 Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents: 48498
diff changeset
291 (name (funcall (gdb-rules-name-maker rules)))
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
292 (new (get-buffer-create name)))
48685
19bf840bede8 Replace uses of (gdb-get-instance-buffer 'gdba) and
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48682
diff changeset
293 (with-current-buffer new
19bf840bede8 Replace uses of (gdb-get-instance-buffer 'gdba) and
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48682
diff changeset
294 ;; FIXME: This should be set after calling the function, since the
19bf840bede8 Replace uses of (gdb-get-instance-buffer 'gdba) and
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48682
diff changeset
295 ;; function should run kill-all-local-variables.
19bf840bede8 Replace uses of (gdb-get-instance-buffer 'gdba) and
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48682
diff changeset
296 (set (make-local-variable 'gdb-buffer-type) key)
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
297 (if (cdr (cdr rules))
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
298 (funcall (car (cdr (cdr rules)))))
48685
19bf840bede8 Replace uses of (gdb-get-instance-buffer 'gdba) and
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48682
diff changeset
299 (set (make-local-variable 'gud-comint-buffer) gud-comint-buffer)
19bf840bede8 Replace uses of (gdb-get-instance-buffer 'gdba) and
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48682
diff changeset
300 (set (make-local-variable 'gud-minor-mode) 'gdba)
19bf840bede8 Replace uses of (gdb-get-instance-buffer 'gdba) and
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48682
diff changeset
301 (set (make-local-variable 'tool-bar-map) gud-tool-bar-map)
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
302 new))))
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
303
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
304 (defun gdb-rules-name-maker (rules) (car (cdr rules)))
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
305
48515
3216cd45d6d2 Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents: 48498
diff changeset
306 (defun gdb-look-for-tagged-buffer (key bufs)
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
307 (let ((retval nil))
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
308 (while (and (not retval) bufs)
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
309 (set-buffer (car bufs))
48515
3216cd45d6d2 Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents: 48498
diff changeset
310 (if (eq gdb-buffer-type key)
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
311 (setq retval (car bufs)))
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
312 (setq bufs (cdr bufs)))
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
313 retval))
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
314
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
315 ;;
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
316 ;; This assoc maps buffer type symbols to rules. Each rule is a list of
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
317 ;; at least one and possible more functions. The functions have these
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
318 ;; roles in defining a buffer type:
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
319 ;;
48921
3aa5ba679145 Remove the concept of an instance. This means that a lot of functions have
Nick Roberts <nickrob@snap.net.nz>
parents: 48884
diff changeset
320 ;; NAME - Return a name for this buffer type.
3aa5ba679145 Remove the concept of an instance. This means that a lot of functions have
Nick Roberts <nickrob@snap.net.nz>
parents: 48884
diff changeset
321 ;;
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
322 ;; The remaining function(s) are optional:
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
323 ;;
48921
3aa5ba679145 Remove the concept of an instance. This means that a lot of functions have
Nick Roberts <nickrob@snap.net.nz>
parents: 48884
diff changeset
324 ;; MODE - called in a new buffer with no arguments, should establish
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
325 ;; the proper mode for the buffer.
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
326 ;;
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
327
48921
3aa5ba679145 Remove the concept of an instance. This means that a lot of functions have
Nick Roberts <nickrob@snap.net.nz>
parents: 48884
diff changeset
328 (defun gdb-set-buffer-rules (buffer-type &rest rules)
3aa5ba679145 Remove the concept of an instance. This means that a lot of functions have
Nick Roberts <nickrob@snap.net.nz>
parents: 48884
diff changeset
329 (let ((binding (assoc buffer-type gdb-buffer-rules-assoc)))
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
330 (if binding
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
331 (setcdr binding rules)
48685
19bf840bede8 Replace uses of (gdb-get-instance-buffer 'gdba) and
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48682
diff changeset
332 (push (cons buffer-type rules)
48921
3aa5ba679145 Remove the concept of an instance. This means that a lot of functions have
Nick Roberts <nickrob@snap.net.nz>
parents: 48884
diff changeset
333 gdb-buffer-rules-assoc))))
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
334
48662
d29870d63092 Fix up comment markers.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48661
diff changeset
335 ;; GUD buffers are an exception to the rules
48921
3aa5ba679145 Remove the concept of an instance. This means that a lot of functions have
Nick Roberts <nickrob@snap.net.nz>
parents: 48884
diff changeset
336 (gdb-set-buffer-rules 'gdba 'error)
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
337
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
338 ;;
48955
1abfa35a3a5a (gdb-display-number-end): Make auto-display of
Nick Roberts <nickrob@snap.net.nz>
parents: 48921
diff changeset
339 ;; Partial-output buffer : This accumulates output from a command executed on
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
340 ;; behalf of emacs (rather than the user).
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
341 ;;
48921
3aa5ba679145 Remove the concept of an instance. This means that a lot of functions have
Nick Roberts <nickrob@snap.net.nz>
parents: 48884
diff changeset
342 (gdb-set-buffer-rules 'gdb-partial-output-buffer
3aa5ba679145 Remove the concept of an instance. This means that a lot of functions have
Nick Roberts <nickrob@snap.net.nz>
parents: 48884
diff changeset
343 'gdb-partial-output-name)
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
344
48515
3216cd45d6d2 Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents: 48498
diff changeset
345 (defun gdb-partial-output-name ()
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
346 (concat "*partial-output-"
48921
3aa5ba679145 Remove the concept of an instance. This means that a lot of functions have
Nick Roberts <nickrob@snap.net.nz>
parents: 48884
diff changeset
347 (gdb-get-target-string)
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
348 "*"))
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
349
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
350
48921
3aa5ba679145 Remove the concept of an instance. This means that a lot of functions have
Nick Roberts <nickrob@snap.net.nz>
parents: 48884
diff changeset
351 (gdb-set-buffer-rules 'gdb-inferior-io
3aa5ba679145 Remove the concept of an instance. This means that a lot of functions have
Nick Roberts <nickrob@snap.net.nz>
parents: 48884
diff changeset
352 'gdb-inferior-io-name
3aa5ba679145 Remove the concept of an instance. This means that a lot of functions have
Nick Roberts <nickrob@snap.net.nz>
parents: 48884
diff changeset
353 'gdb-inferior-io-mode)
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
354
48515
3216cd45d6d2 Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents: 48498
diff changeset
355 (defun gdb-inferior-io-name ()
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
356 (concat "*input/output of "
48921
3aa5ba679145 Remove the concept of an instance. This means that a lot of functions have
Nick Roberts <nickrob@snap.net.nz>
parents: 48884
diff changeset
357 (gdb-get-target-string)
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
358 "*"))
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
359
48661
b092bff770ec Fold top-level `setq's and `define-key's into their corresponding defvar.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48659
diff changeset
360 (defvar gdb-inferior-io-mode-map
b092bff770ec Fold top-level `setq's and `define-key's into their corresponding defvar.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48659
diff changeset
361 (let ((map (make-sparse-keymap)))
b092bff770ec Fold top-level `setq's and `define-key's into their corresponding defvar.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48659
diff changeset
362 (define-key map "\C-c\C-c" 'gdb-inferior-io-interrupt)
b092bff770ec Fold top-level `setq's and `define-key's into their corresponding defvar.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48659
diff changeset
363 (define-key map "\C-c\C-z" 'gdb-inferior-io-stop)
b092bff770ec Fold top-level `setq's and `define-key's into their corresponding defvar.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48659
diff changeset
364 (define-key map "\C-c\C-\\" 'gdb-inferior-io-quit)
b092bff770ec Fold top-level `setq's and `define-key's into their corresponding defvar.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48659
diff changeset
365 (define-key map "\C-c\C-d" 'gdb-inferior-io-eof)
b092bff770ec Fold top-level `setq's and `define-key's into their corresponding defvar.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48659
diff changeset
366 map))
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
367
48659
4d69c0f01cc0 (gdb-inferior-io-mode-map): Remove (unused).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48641
diff changeset
368 (define-derived-mode gdb-inferior-io-mode comint-mode "Debuggee I/O"
4d69c0f01cc0 (gdb-inferior-io-mode-map): Remove (unused).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48641
diff changeset
369 "Major mode for gdb inferior-io."
4d69c0f01cc0 (gdb-inferior-io-mode-map): Remove (unused).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48641
diff changeset
370 :syntax-table nil :abbrev-table nil
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
371 ;; We want to use comint because it has various nifty and familiar
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
372 ;; features. We don't need a process, but comint wants one, so create
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
373 ;; a dummy one.
48659
4d69c0f01cc0 (gdb-inferior-io-mode-map): Remove (unused).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48641
diff changeset
374 (make-comint-in-buffer
4d69c0f01cc0 (gdb-inferior-io-mode-map): Remove (unused).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48641
diff changeset
375 (substring (buffer-name) 1 (- (length (buffer-name)) 1))
4d69c0f01cc0 (gdb-inferior-io-mode-map): Remove (unused).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48641
diff changeset
376 (current-buffer) "/bin/cat")
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
377 (setq comint-input-sender 'gdb-inferior-io-sender))
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
378
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
379 (defun gdb-inferior-io-sender (proc string)
48685
19bf840bede8 Replace uses of (gdb-get-instance-buffer 'gdba) and
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48682
diff changeset
380 ;; PROC is the pseudo-process created to satisfy comint.
19bf840bede8 Replace uses of (gdb-get-instance-buffer 'gdba) and
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48682
diff changeset
381 (with-current-buffer (process-buffer proc)
19bf840bede8 Replace uses of (gdb-get-instance-buffer 'gdba) and
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48682
diff changeset
382 (setq proc (get-buffer-process gud-comint-buffer))
19bf840bede8 Replace uses of (gdb-get-instance-buffer 'gdba) and
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48682
diff changeset
383 (process-send-string proc string)
19bf840bede8 Replace uses of (gdb-get-instance-buffer 'gdba) and
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48682
diff changeset
384 (process-send-string proc "\n")))
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
385
48515
3216cd45d6d2 Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents: 48498
diff changeset
386 (defun gdb-inferior-io-interrupt ()
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
387 "Interrupt the program being debugged."
48659
4d69c0f01cc0 (gdb-inferior-io-mode-map): Remove (unused).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48641
diff changeset
388 (interactive)
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
389 (interrupt-process
48685
19bf840bede8 Replace uses of (gdb-get-instance-buffer 'gdba) and
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48682
diff changeset
390 (get-buffer-process gud-comint-buffer) comint-ptyp))
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
391
48515
3216cd45d6d2 Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents: 48498
diff changeset
392 (defun gdb-inferior-io-quit ()
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
393 "Send quit signal to the program being debugged."
48659
4d69c0f01cc0 (gdb-inferior-io-mode-map): Remove (unused).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48641
diff changeset
394 (interactive)
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
395 (quit-process
48685
19bf840bede8 Replace uses of (gdb-get-instance-buffer 'gdba) and
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48682
diff changeset
396 (get-buffer-process gud-comint-buffer) comint-ptyp))
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
397
48515
3216cd45d6d2 Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents: 48498
diff changeset
398 (defun gdb-inferior-io-stop ()
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
399 "Stop the program being debugged."
48659
4d69c0f01cc0 (gdb-inferior-io-mode-map): Remove (unused).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48641
diff changeset
400 (interactive)
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
401 (stop-process
48685
19bf840bede8 Replace uses of (gdb-get-instance-buffer 'gdba) and
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48682
diff changeset
402 (get-buffer-process gud-comint-buffer) comint-ptyp))
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
403
48515
3216cd45d6d2 Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents: 48498
diff changeset
404 (defun gdb-inferior-io-eof ()
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
405 "Send end-of-file to the program being debugged."
48659
4d69c0f01cc0 (gdb-inferior-io-mode-map): Remove (unused).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48641
diff changeset
406 (interactive)
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
407 (process-send-eof
48685
19bf840bede8 Replace uses of (gdb-get-instance-buffer 'gdba) and
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48682
diff changeset
408 (get-buffer-process gud-comint-buffer)))
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
409
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
410
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
411 ;;
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
412 ;; gdb communications
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
413 ;;
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
414
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
415 ;; INPUT: things sent to gdb
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
416 ;;
48921
3aa5ba679145 Remove the concept of an instance. This means that a lot of functions have
Nick Roberts <nickrob@snap.net.nz>
parents: 48884
diff changeset
417 ;; There is a high and low priority input queue. Low priority input is sent
3aa5ba679145 Remove the concept of an instance. This means that a lot of functions have
Nick Roberts <nickrob@snap.net.nz>
parents: 48884
diff changeset
418 ;; only when the high priority queue is idle.
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
419 ;;
48921
3aa5ba679145 Remove the concept of an instance. This means that a lot of functions have
Nick Roberts <nickrob@snap.net.nz>
parents: 48884
diff changeset
420 ;; The queues are lists. Each element is either a string (indicating user or
3aa5ba679145 Remove the concept of an instance. This means that a lot of functions have
Nick Roberts <nickrob@snap.net.nz>
parents: 48884
diff changeset
421 ;; user-like input) or a list of the form:
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
422 ;;
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
423 ;; (INPUT-STRING HANDLER-FN)
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
424 ;;
48921
3aa5ba679145 Remove the concept of an instance. This means that a lot of functions have
Nick Roberts <nickrob@snap.net.nz>
parents: 48884
diff changeset
425 ;; The handler function will be called from the partial-output buffer when the
3aa5ba679145 Remove the concept of an instance. This means that a lot of functions have
Nick Roberts <nickrob@snap.net.nz>
parents: 48884
diff changeset
426 ;; command completes. This is the way to write commands which invoke gdb
3aa5ba679145 Remove the concept of an instance. This means that a lot of functions have
Nick Roberts <nickrob@snap.net.nz>
parents: 48884
diff changeset
427 ;; commands autonomously.
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
428 ;;
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
429 ;; These lists are consumed tail first.
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
430 ;;
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
431
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
432 (defun gdb-send (proc string)
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
433 "A comint send filter for gdb.
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
434 This filter may simply queue output for a later time."
48921
3aa5ba679145 Remove the concept of an instance. This means that a lot of functions have
Nick Roberts <nickrob@snap.net.nz>
parents: 48884
diff changeset
435 (gdb-enqueue-input (concat string "\n")))
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
436
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
437 ;; Note: Stuff enqueued here will be sent to the next prompt, even if it
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
438 ;; is a query, or other non-top-level prompt. To guarantee stuff will get
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
439 ;; sent to the top-level prompt, currently it must be put in the idle queue.
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
440 ;; ^^^^^^^^^
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
441 ;; [This should encourage gdb extensions that invoke gdb commands to let
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
442 ;; the user go first; it is not a bug. -t]
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
443 ;;
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
444
48921
3aa5ba679145 Remove the concept of an instance. This means that a lot of functions have
Nick Roberts <nickrob@snap.net.nz>
parents: 48884
diff changeset
445 (defun gdb-enqueue-input (item)
3aa5ba679145 Remove the concept of an instance. This means that a lot of functions have
Nick Roberts <nickrob@snap.net.nz>
parents: 48884
diff changeset
446 (if (gdb-get-prompting)
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
447 (progn
48515
3216cd45d6d2 Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents: 48498
diff changeset
448 (gdb-send-item item)
48921
3aa5ba679145 Remove the concept of an instance. This means that a lot of functions have
Nick Roberts <nickrob@snap.net.nz>
parents: 48884
diff changeset
449 (gdb-set-prompting nil))
3aa5ba679145 Remove the concept of an instance. This means that a lot of functions have
Nick Roberts <nickrob@snap.net.nz>
parents: 48884
diff changeset
450 (gdb-set-input-queue
3aa5ba679145 Remove the concept of an instance. This means that a lot of functions have
Nick Roberts <nickrob@snap.net.nz>
parents: 48884
diff changeset
451 (cons item (gdb-get-input-queue)))))
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
452
48921
3aa5ba679145 Remove the concept of an instance. This means that a lot of functions have
Nick Roberts <nickrob@snap.net.nz>
parents: 48884
diff changeset
453 (defun gdb-dequeue-input ()
3aa5ba679145 Remove the concept of an instance. This means that a lot of functions have
Nick Roberts <nickrob@snap.net.nz>
parents: 48884
diff changeset
454 (let ((queue (gdb-get-input-queue)))
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
455 (and queue
48921
3aa5ba679145 Remove the concept of an instance. This means that a lot of functions have
Nick Roberts <nickrob@snap.net.nz>
parents: 48884
diff changeset
456 (if (not (cdr queue))
3aa5ba679145 Remove the concept of an instance. This means that a lot of functions have
Nick Roberts <nickrob@snap.net.nz>
parents: 48884
diff changeset
457 (let ((answer (car queue)))
3aa5ba679145 Remove the concept of an instance. This means that a lot of functions have
Nick Roberts <nickrob@snap.net.nz>
parents: 48884
diff changeset
458 (gdb-set-input-queue '())
3aa5ba679145 Remove the concept of an instance. This means that a lot of functions have
Nick Roberts <nickrob@snap.net.nz>
parents: 48884
diff changeset
459 answer)
3aa5ba679145 Remove the concept of an instance. This means that a lot of functions have
Nick Roberts <nickrob@snap.net.nz>
parents: 48884
diff changeset
460 (gdb-take-last-elt queue)))))
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
461
48921
3aa5ba679145 Remove the concept of an instance. This means that a lot of functions have
Nick Roberts <nickrob@snap.net.nz>
parents: 48884
diff changeset
462 (defun gdb-enqueue-idle-input (item)
3aa5ba679145 Remove the concept of an instance. This means that a lot of functions have
Nick Roberts <nickrob@snap.net.nz>
parents: 48884
diff changeset
463 (if (and (gdb-get-prompting)
3aa5ba679145 Remove the concept of an instance. This means that a lot of functions have
Nick Roberts <nickrob@snap.net.nz>
parents: 48884
diff changeset
464 (not (gdb-get-input-queue)))
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
465 (progn
48515
3216cd45d6d2 Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents: 48498
diff changeset
466 (gdb-send-item item)
48921
3aa5ba679145 Remove the concept of an instance. This means that a lot of functions have
Nick Roberts <nickrob@snap.net.nz>
parents: 48884
diff changeset
467 (gdb-set-prompting nil))
3aa5ba679145 Remove the concept of an instance. This means that a lot of functions have
Nick Roberts <nickrob@snap.net.nz>
parents: 48884
diff changeset
468 (gdb-set-idle-input-queue
3aa5ba679145 Remove the concept of an instance. This means that a lot of functions have
Nick Roberts <nickrob@snap.net.nz>
parents: 48884
diff changeset
469 (cons item (gdb-get-idle-input-queue)))))
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
470
48921
3aa5ba679145 Remove the concept of an instance. This means that a lot of functions have
Nick Roberts <nickrob@snap.net.nz>
parents: 48884
diff changeset
471 (defun gdb-dequeue-idle-input ()
3aa5ba679145 Remove the concept of an instance. This means that a lot of functions have
Nick Roberts <nickrob@snap.net.nz>
parents: 48884
diff changeset
472 (let ((queue (gdb-get-idle-input-queue)))
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
473 (and queue
48921
3aa5ba679145 Remove the concept of an instance. This means that a lot of functions have
Nick Roberts <nickrob@snap.net.nz>
parents: 48884
diff changeset
474 (if (not (cdr queue))
3aa5ba679145 Remove the concept of an instance. This means that a lot of functions have
Nick Roberts <nickrob@snap.net.nz>
parents: 48884
diff changeset
475 (let ((answer (car queue)))
3aa5ba679145 Remove the concept of an instance. This means that a lot of functions have
Nick Roberts <nickrob@snap.net.nz>
parents: 48884
diff changeset
476 (gdb-set-idle-input-queue '())
3aa5ba679145 Remove the concept of an instance. This means that a lot of functions have
Nick Roberts <nickrob@snap.net.nz>
parents: 48884
diff changeset
477 answer)
3aa5ba679145 Remove the concept of an instance. This means that a lot of functions have
Nick Roberts <nickrob@snap.net.nz>
parents: 48884
diff changeset
478 (gdb-take-last-elt queue)))))
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
479
48662
d29870d63092 Fix up comment markers.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48661
diff changeset
480 ;; Don't use this in general.
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
481 (defun gdb-take-last-elt (l)
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
482 (if (cdr (cdr l))
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
483 (gdb-take-last-elt (cdr l))
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
484 (let ((answer (car (cdr l))))
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
485 (setcdr l '())
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
486 answer)))
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
487
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
488
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
489 ;;
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
490 ;; output -- things gdb prints to emacs
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
491 ;;
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
492 ;; GDB output is a stream interrupted by annotations.
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
493 ;; Annotations can be recognized by their beginning
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
494 ;; with \C-j\C-z\C-z<tag><opt>\C-j
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
495 ;;
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
496 ;; The tag is a string obeying symbol syntax.
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
497 ;;
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
498 ;; The optional part `<opt>' can be either the empty string
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
499 ;; or a space followed by more data relating to the annotation.
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
500 ;; For example, the SOURCE annotation is followed by a filename,
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
501 ;; line number and various useless goo. This data must not include
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
502 ;; any newlines.
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
503 ;;
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
504
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
505 (defcustom gud-gdba-command-name "gdb -annotate=2"
48682
a74dd42cf01d (gud-gdb-complete-string, gud-gdb-complete-break)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48662
diff changeset
506 "Default command to execute an executable under the GDB-UI debugger."
48921
3aa5ba679145 Remove the concept of an instance. This means that a lot of functions have
Nick Roberts <nickrob@snap.net.nz>
parents: 48884
diff changeset
507 :type 'string
3aa5ba679145 Remove the concept of an instance. This means that a lot of functions have
Nick Roberts <nickrob@snap.net.nz>
parents: 48884
diff changeset
508 :group 'gud)
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
509
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
510 (defvar gdb-annotation-rules
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
511 '(("frames-invalid" gdb-invalidate-frame-and-assembler)
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
512 ("breakpoints-invalid" gdb-invalidate-breakpoints-and-assembler)
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
513 ("pre-prompt" gdb-pre-prompt)
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
514 ("prompt" gdb-prompt)
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
515 ("commands" gdb-subprompt)
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
516 ("overload-choice" gdb-subprompt)
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
517 ("query" gdb-subprompt)
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
518 ("prompt-for-continue" gdb-subprompt)
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
519 ("post-prompt" gdb-post-prompt)
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
520 ("source" gdb-source)
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
521 ("starting" gdb-starting)
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
522 ("exited" gdb-stopping)
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
523 ("signalled" gdb-stopping)
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
524 ("signal" gdb-stopping)
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
525 ("breakpoint" gdb-stopping)
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
526 ("watchpoint" gdb-stopping)
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
527 ("frame-begin" gdb-frame-begin)
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
528 ("stopped" gdb-stopped)
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
529 ("display-begin" gdb-display-begin)
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
530 ("display-end" gdb-display-end)
49147
8a40184e2f0e (gud-display): Use GDB command ptype instead of whatis
Nick Roberts <nickrob@snap.net.nz>
parents: 49039
diff changeset
531 ; GDB commands info stack, info locals and frame generate an error-begin
8a40184e2f0e (gud-display): Use GDB command ptype instead of whatis
Nick Roberts <nickrob@snap.net.nz>
parents: 49039
diff changeset
532 ; annotation at start when there is no stack but this is a quirk/bug in
8a40184e2f0e (gud-display): Use GDB command ptype instead of whatis
Nick Roberts <nickrob@snap.net.nz>
parents: 49039
diff changeset
533 ; annotations.
8a40184e2f0e (gud-display): Use GDB command ptype instead of whatis
Nick Roberts <nickrob@snap.net.nz>
parents: 49039
diff changeset
534 ; ("error-begin" gdb-error-begin)
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
535 ("display-number-end" gdb-display-number-end)
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
536 ("array-section-begin" gdb-array-section-begin)
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
537 ("array-section-end" gdb-array-section-end)
48662
d29870d63092 Fix up comment markers.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48661
diff changeset
538 ;; ("elt" gdb-elt)
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
539 ("field-begin" gdb-field-begin)
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
540 ("field-end" gdb-field-end)
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
541 ) "An assoc mapping annotation tags to functions which process them.")
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
542
48515
3216cd45d6d2 Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents: 48498
diff changeset
543 (defun gdb-ignore-annotation (args)
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
544 nil)
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
545
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
546 (defconst gdb-source-spec-regexp
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
547 "\\(.*\\):\\([0-9]*\\):[0-9]*:[a-z]*:\\(0x[a-f0-9]*\\)")
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
548
48570
4934b8352621 (gdb-starting): Set gdb-running to t.
Nick Roberts <nickrob@snap.net.nz>
parents: 48515
diff changeset
549 ;; Do not use this except as an annotation handler.
48515
3216cd45d6d2 Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents: 48498
diff changeset
550 (defun gdb-source (args)
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
551 (string-match gdb-source-spec-regexp args)
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
552 ;; Extract the frame position from the marker.
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
553 (setq gud-last-frame
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
554 (cons
48641
da382393fb77 Get rid of (quote ..); use match-string and ignore.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48640
diff changeset
555 (match-string 1 args)
da382393fb77 Get rid of (quote ..); use match-string and ignore.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48640
diff changeset
556 (string-to-int (match-string 2 args))))
da382393fb77 Get rid of (quote ..); use match-string and ignore.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48640
diff changeset
557 (setq gdb-current-address (match-string 3 args))
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
558 (setq gdb-main-or-pc gdb-current-address)
48662
d29870d63092 Fix up comment markers.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48661
diff changeset
559 ;;update with new frame for machine code if necessary
48515
3216cd45d6d2 Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents: 48498
diff changeset
560 (gdb-invalidate-assembler))
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
561
48515
3216cd45d6d2 Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents: 48498
diff changeset
562 (defun gdb-send-item (item)
48921
3aa5ba679145 Remove the concept of an instance. This means that a lot of functions have
Nick Roberts <nickrob@snap.net.nz>
parents: 48884
diff changeset
563 (gdb-set-current-item item)
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
564 (if (stringp item)
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
565 (progn
48921
3aa5ba679145 Remove the concept of an instance. This means that a lot of functions have
Nick Roberts <nickrob@snap.net.nz>
parents: 48884
diff changeset
566 (gdb-set-output-sink 'user)
48685
19bf840bede8 Replace uses of (gdb-get-instance-buffer 'gdba) and
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48682
diff changeset
567 (process-send-string (get-buffer-process gud-comint-buffer) item))
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
568 (progn
48515
3216cd45d6d2 Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents: 48498
diff changeset
569 (gdb-clear-partial-output)
48921
3aa5ba679145 Remove the concept of an instance. This means that a lot of functions have
Nick Roberts <nickrob@snap.net.nz>
parents: 48884
diff changeset
570 (gdb-set-output-sink 'pre-emacs)
48685
19bf840bede8 Replace uses of (gdb-get-instance-buffer 'gdba) and
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48682
diff changeset
571 (process-send-string (get-buffer-process gud-comint-buffer)
19bf840bede8 Replace uses of (gdb-get-instance-buffer 'gdba) and
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48682
diff changeset
572 (car item)))))
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
573
48515
3216cd45d6d2 Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents: 48498
diff changeset
574 (defun gdb-pre-prompt (ignored)
48570
4934b8352621 (gdb-starting): Set gdb-running to t.
Nick Roberts <nickrob@snap.net.nz>
parents: 48515
diff changeset
575 "An annotation handler for `pre-prompt'. This terminates the collection of
4934b8352621 (gdb-starting): Set gdb-running to t.
Nick Roberts <nickrob@snap.net.nz>
parents: 48515
diff changeset
576 output from a previous command if that happens to be in effect."
48921
3aa5ba679145 Remove the concept of an instance. This means that a lot of functions have
Nick Roberts <nickrob@snap.net.nz>
parents: 48884
diff changeset
577 (let ((sink (gdb-get-output-sink)))
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
578 (cond
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
579 ((eq sink 'user) t)
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
580 ((eq sink 'emacs)
48921
3aa5ba679145 Remove the concept of an instance. This means that a lot of functions have
Nick Roberts <nickrob@snap.net.nz>
parents: 48884
diff changeset
581 (gdb-set-output-sink 'post-emacs)
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
582 (let ((handler
48921
3aa5ba679145 Remove the concept of an instance. This means that a lot of functions have
Nick Roberts <nickrob@snap.net.nz>
parents: 48884
diff changeset
583 (car (cdr (gdb-get-current-item)))))
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
584 (save-excursion
48921
3aa5ba679145 Remove the concept of an instance. This means that a lot of functions have
Nick Roberts <nickrob@snap.net.nz>
parents: 48884
diff changeset
585 (set-buffer (gdb-get-create-buffer
48515
3216cd45d6d2 Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents: 48498
diff changeset
586 'gdb-partial-output-buffer))
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
587 (funcall handler))))
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
588 (t
48921
3aa5ba679145 Remove the concept of an instance. This means that a lot of functions have
Nick Roberts <nickrob@snap.net.nz>
parents: 48884
diff changeset
589 (gdb-set-output-sink 'user)
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
590 (error "Output sink phase error 1")))))
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
591
48955
1abfa35a3a5a (gdb-display-number-end): Make auto-display of
Nick Roberts <nickrob@snap.net.nz>
parents: 48921
diff changeset
592 (defun gdb-prompt (ignored)
1abfa35a3a5a (gdb-display-number-end): Make auto-display of
Nick Roberts <nickrob@snap.net.nz>
parents: 48921
diff changeset
593 "An annotation handler for `prompt'.
1abfa35a3a5a (gdb-display-number-end): Make auto-display of
Nick Roberts <nickrob@snap.net.nz>
parents: 48921
diff changeset
594 This sends the next command (if any) to gdb."
1abfa35a3a5a (gdb-display-number-end): Make auto-display of
Nick Roberts <nickrob@snap.net.nz>
parents: 48921
diff changeset
595 (let ((sink (gdb-get-output-sink)))
1abfa35a3a5a (gdb-display-number-end): Make auto-display of
Nick Roberts <nickrob@snap.net.nz>
parents: 48921
diff changeset
596 (cond
1abfa35a3a5a (gdb-display-number-end): Make auto-display of
Nick Roberts <nickrob@snap.net.nz>
parents: 48921
diff changeset
597 ((eq sink 'user) t)
1abfa35a3a5a (gdb-display-number-end): Make auto-display of
Nick Roberts <nickrob@snap.net.nz>
parents: 48921
diff changeset
598 ((eq sink 'post-emacs)
1abfa35a3a5a (gdb-display-number-end): Make auto-display of
Nick Roberts <nickrob@snap.net.nz>
parents: 48921
diff changeset
599 (gdb-set-output-sink 'user))
1abfa35a3a5a (gdb-display-number-end): Make auto-display of
Nick Roberts <nickrob@snap.net.nz>
parents: 48921
diff changeset
600 (t
1abfa35a3a5a (gdb-display-number-end): Make auto-display of
Nick Roberts <nickrob@snap.net.nz>
parents: 48921
diff changeset
601 (gdb-set-output-sink 'user)
1abfa35a3a5a (gdb-display-number-end): Make auto-display of
Nick Roberts <nickrob@snap.net.nz>
parents: 48921
diff changeset
602 (error "Phase error in gdb-prompt (got %s)" sink))))
1abfa35a3a5a (gdb-display-number-end): Make auto-display of
Nick Roberts <nickrob@snap.net.nz>
parents: 48921
diff changeset
603 (let ((highest (gdb-dequeue-input)))
1abfa35a3a5a (gdb-display-number-end): Make auto-display of
Nick Roberts <nickrob@snap.net.nz>
parents: 48921
diff changeset
604 (if highest
1abfa35a3a5a (gdb-display-number-end): Make auto-display of
Nick Roberts <nickrob@snap.net.nz>
parents: 48921
diff changeset
605 (gdb-send-item highest)
1abfa35a3a5a (gdb-display-number-end): Make auto-display of
Nick Roberts <nickrob@snap.net.nz>
parents: 48921
diff changeset
606 (let ((lowest (gdb-dequeue-idle-input)))
1abfa35a3a5a (gdb-display-number-end): Make auto-display of
Nick Roberts <nickrob@snap.net.nz>
parents: 48921
diff changeset
607 (if lowest
1abfa35a3a5a (gdb-display-number-end): Make auto-display of
Nick Roberts <nickrob@snap.net.nz>
parents: 48921
diff changeset
608 (gdb-send-item lowest)
1abfa35a3a5a (gdb-display-number-end): Make auto-display of
Nick Roberts <nickrob@snap.net.nz>
parents: 48921
diff changeset
609 (progn
1abfa35a3a5a (gdb-display-number-end): Make auto-display of
Nick Roberts <nickrob@snap.net.nz>
parents: 48921
diff changeset
610 (gdb-set-prompting t)
1abfa35a3a5a (gdb-display-number-end): Make auto-display of
Nick Roberts <nickrob@snap.net.nz>
parents: 48921
diff changeset
611 (gud-display-frame)))))))
1abfa35a3a5a (gdb-display-number-end): Make auto-display of
Nick Roberts <nickrob@snap.net.nz>
parents: 48921
diff changeset
612
1abfa35a3a5a (gdb-display-number-end): Make auto-display of
Nick Roberts <nickrob@snap.net.nz>
parents: 48921
diff changeset
613 (defun gdb-subprompt (ignored)
1abfa35a3a5a (gdb-display-number-end): Make auto-display of
Nick Roberts <nickrob@snap.net.nz>
parents: 48921
diff changeset
614 "An annotation handler for non-top-level prompts."
1abfa35a3a5a (gdb-display-number-end): Make auto-display of
Nick Roberts <nickrob@snap.net.nz>
parents: 48921
diff changeset
615 (let ((highest (gdb-dequeue-input)))
1abfa35a3a5a (gdb-display-number-end): Make auto-display of
Nick Roberts <nickrob@snap.net.nz>
parents: 48921
diff changeset
616 (if highest
1abfa35a3a5a (gdb-display-number-end): Make auto-display of
Nick Roberts <nickrob@snap.net.nz>
parents: 48921
diff changeset
617 (gdb-send-item highest)
1abfa35a3a5a (gdb-display-number-end): Make auto-display of
Nick Roberts <nickrob@snap.net.nz>
parents: 48921
diff changeset
618 (gdb-set-prompting t))))
1abfa35a3a5a (gdb-display-number-end): Make auto-display of
Nick Roberts <nickrob@snap.net.nz>
parents: 48921
diff changeset
619
48515
3216cd45d6d2 Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents: 48498
diff changeset
620 (defun gdb-starting (ignored)
48570
4934b8352621 (gdb-starting): Set gdb-running to t.
Nick Roberts <nickrob@snap.net.nz>
parents: 48515
diff changeset
621 "An annotation handler for `starting'. This says that I/O for the
4934b8352621 (gdb-starting): Set gdb-running to t.
Nick Roberts <nickrob@snap.net.nz>
parents: 48515
diff changeset
622 subprocess is now the program being debugged, not GDB."
48921
3aa5ba679145 Remove the concept of an instance. This means that a lot of functions have
Nick Roberts <nickrob@snap.net.nz>
parents: 48884
diff changeset
623 (let ((sink (gdb-get-output-sink)))
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
624 (cond
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
625 ((eq sink 'user)
48570
4934b8352621 (gdb-starting): Set gdb-running to t.
Nick Roberts <nickrob@snap.net.nz>
parents: 48515
diff changeset
626 (progn
48639
00993d9b9cb7 (gdba, gdb-starting, gdb-stopped, gdb-quit): Update gdb-running -> gud-running.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48600
diff changeset
627 (setq gud-running t)
48921
3aa5ba679145 Remove the concept of an instance. This means that a lot of functions have
Nick Roberts <nickrob@snap.net.nz>
parents: 48884
diff changeset
628 (gdb-set-output-sink 'inferior)))
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
629 (t (error "Unexpected `starting' annotation")))))
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
630
48515
3216cd45d6d2 Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents: 48498
diff changeset
631 (defun gdb-stopping (ignored)
48570
4934b8352621 (gdb-starting): Set gdb-running to t.
Nick Roberts <nickrob@snap.net.nz>
parents: 48515
diff changeset
632 "An annotation handler for `exited' and other annotations which say that I/O
4934b8352621 (gdb-starting): Set gdb-running to t.
Nick Roberts <nickrob@snap.net.nz>
parents: 48515
diff changeset
633 for the subprocess is now GDB, not the program being debugged."
48921
3aa5ba679145 Remove the concept of an instance. This means that a lot of functions have
Nick Roberts <nickrob@snap.net.nz>
parents: 48884
diff changeset
634 (let ((sink (gdb-get-output-sink)))
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
635 (cond
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
636 ((eq sink 'inferior)
48921
3aa5ba679145 Remove the concept of an instance. This means that a lot of functions have
Nick Roberts <nickrob@snap.net.nz>
parents: 48884
diff changeset
637 (gdb-set-output-sink 'user))
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
638 (t (error "Unexpected stopping annotation")))))
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
639
48955
1abfa35a3a5a (gdb-display-number-end): Make auto-display of
Nick Roberts <nickrob@snap.net.nz>
parents: 48921
diff changeset
640 (defun gdb-frame-begin (ignored)
1abfa35a3a5a (gdb-display-number-end): Make auto-display of
Nick Roberts <nickrob@snap.net.nz>
parents: 48921
diff changeset
641 (let ((sink (gdb-get-output-sink)))
1abfa35a3a5a (gdb-display-number-end): Make auto-display of
Nick Roberts <nickrob@snap.net.nz>
parents: 48921
diff changeset
642 (cond
1abfa35a3a5a (gdb-display-number-end): Make auto-display of
Nick Roberts <nickrob@snap.net.nz>
parents: 48921
diff changeset
643 ((eq sink 'inferior)
1abfa35a3a5a (gdb-display-number-end): Make auto-display of
Nick Roberts <nickrob@snap.net.nz>
parents: 48921
diff changeset
644 (gdb-set-output-sink 'user))
1abfa35a3a5a (gdb-display-number-end): Make auto-display of
Nick Roberts <nickrob@snap.net.nz>
parents: 48921
diff changeset
645 ((eq sink 'user) t)
1abfa35a3a5a (gdb-display-number-end): Make auto-display of
Nick Roberts <nickrob@snap.net.nz>
parents: 48921
diff changeset
646 ((eq sink 'emacs) t)
1abfa35a3a5a (gdb-display-number-end): Make auto-display of
Nick Roberts <nickrob@snap.net.nz>
parents: 48921
diff changeset
647 (t (error "Unexpected frame-begin annotation (%S)" sink)))))
1abfa35a3a5a (gdb-display-number-end): Make auto-display of
Nick Roberts <nickrob@snap.net.nz>
parents: 48921
diff changeset
648
48515
3216cd45d6d2 Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents: 48498
diff changeset
649 (defun gdb-stopped (ignored)
48570
4934b8352621 (gdb-starting): Set gdb-running to t.
Nick Roberts <nickrob@snap.net.nz>
parents: 48515
diff changeset
650 "An annotation handler for `stopped'. It is just like gdb-stopping, except
4934b8352621 (gdb-starting): Set gdb-running to t.
Nick Roberts <nickrob@snap.net.nz>
parents: 48515
diff changeset
651 that if we already set the output sink to 'user in gdb-stopping, that is fine."
48639
00993d9b9cb7 (gdba, gdb-starting, gdb-stopped, gdb-quit): Update gdb-running -> gud-running.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48600
diff changeset
652 (setq gud-running nil)
48921
3aa5ba679145 Remove the concept of an instance. This means that a lot of functions have
Nick Roberts <nickrob@snap.net.nz>
parents: 48884
diff changeset
653 (let ((sink (gdb-get-output-sink)))
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
654 (cond
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
655 ((eq sink 'inferior)
48921
3aa5ba679145 Remove the concept of an instance. This means that a lot of functions have
Nick Roberts <nickrob@snap.net.nz>
parents: 48884
diff changeset
656 (gdb-set-output-sink 'user))
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
657 ((eq sink 'user) t)
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
658 (t (error "Unexpected stopped annotation")))))
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
659
48515
3216cd45d6d2 Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents: 48498
diff changeset
660 (defun gdb-post-prompt (ignored)
48570
4934b8352621 (gdb-starting): Set gdb-running to t.
Nick Roberts <nickrob@snap.net.nz>
parents: 48515
diff changeset
661 "An annotation handler for `post-prompt'. This begins the collection of
4934b8352621 (gdb-starting): Set gdb-running to t.
Nick Roberts <nickrob@snap.net.nz>
parents: 48515
diff changeset
662 output from the current command if that happens to be appropriate."
48921
3aa5ba679145 Remove the concept of an instance. This means that a lot of functions have
Nick Roberts <nickrob@snap.net.nz>
parents: 48884
diff changeset
663 (if (not (gdb-get-pending-triggers))
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
664 (progn
48955
1abfa35a3a5a (gdb-display-number-end): Make auto-display of
Nick Roberts <nickrob@snap.net.nz>
parents: 48921
diff changeset
665 (gdb-get-current-frame)
48515
3216cd45d6d2 Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents: 48498
diff changeset
666 (gdb-invalidate-registers ignored)
3216cd45d6d2 Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents: 48498
diff changeset
667 (gdb-invalidate-locals ignored)
3216cd45d6d2 Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents: 48498
diff changeset
668 (gdb-invalidate-display ignored)))
48921
3aa5ba679145 Remove the concept of an instance. This means that a lot of functions have
Nick Roberts <nickrob@snap.net.nz>
parents: 48884
diff changeset
669 (let ((sink (gdb-get-output-sink)))
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
670 (cond
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
671 ((eq sink 'user) t)
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
672 ((eq sink 'pre-emacs)
48921
3aa5ba679145 Remove the concept of an instance. This means that a lot of functions have
Nick Roberts <nickrob@snap.net.nz>
parents: 48884
diff changeset
673 (gdb-set-output-sink 'emacs))
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
674 (t
48921
3aa5ba679145 Remove the concept of an instance. This means that a lot of functions have
Nick Roberts <nickrob@snap.net.nz>
parents: 48884
diff changeset
675 (gdb-set-output-sink 'user)
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
676 (error "Output sink phase error 3")))))
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
677
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
678 ;; If we get an error whilst evaluating one of the expressions
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
679 ;; we won't get the display-end annotation. Set the sink back to
49249
7c4bc41333d1 Improve commentary.
Nick Roberts <nickrob@snap.net.nz>
parents: 49147
diff changeset
680 ;; user to make sure that the error message is seen.
7c4bc41333d1 Improve commentary.
Nick Roberts <nickrob@snap.net.nz>
parents: 49147
diff changeset
681 ;; NOT USED: see annotation-rules for reason.
7c4bc41333d1 Improve commentary.
Nick Roberts <nickrob@snap.net.nz>
parents: 49147
diff changeset
682 ;(defun gdb-error-begin (ignored)
7c4bc41333d1 Improve commentary.
Nick Roberts <nickrob@snap.net.nz>
parents: 49147
diff changeset
683 ; (gdb-set-output-sink 'user))
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
684
48515
3216cd45d6d2 Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents: 48498
diff changeset
685 (defun gdb-display-begin (ignored)
48921
3aa5ba679145 Remove the concept of an instance. This means that a lot of functions have
Nick Roberts <nickrob@snap.net.nz>
parents: 48884
diff changeset
686 (gdb-set-output-sink 'emacs)
3aa5ba679145 Remove the concept of an instance. This means that a lot of functions have
Nick Roberts <nickrob@snap.net.nz>
parents: 48884
diff changeset
687 (gdb-clear-partial-output)
3aa5ba679145 Remove the concept of an instance. This means that a lot of functions have
Nick Roberts <nickrob@snap.net.nz>
parents: 48884
diff changeset
688 (setq gdb-display-in-progress t))
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
689
48515
3216cd45d6d2 Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents: 48498
diff changeset
690 (defvar gdb-expression-buffer-name)
3216cd45d6d2 Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents: 48498
diff changeset
691 (defvar gdb-display-number)
3216cd45d6d2 Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents: 48498
diff changeset
692 (defvar gdb-dive-display-number)
3216cd45d6d2 Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents: 48498
diff changeset
693
3216cd45d6d2 Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents: 48498
diff changeset
694 (defun gdb-display-number-end (ignored)
48921
3aa5ba679145 Remove the concept of an instance. This means that a lot of functions have
Nick Roberts <nickrob@snap.net.nz>
parents: 48884
diff changeset
695 (set-buffer (gdb-get-buffer 'gdb-partial-output-buffer))
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
696 (setq gdb-display-number (buffer-string))
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
697 (setq gdb-expression-buffer-name
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
698 (concat "*display " gdb-display-number "*"))
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
699 (save-excursion
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
700 (if (progn
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
701 (set-buffer (window-buffer))
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
702 gdb-dive)
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
703 (progn
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
704 (let ((number gdb-display-number))
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
705 (switch-to-buffer
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
706 (set-buffer (get-buffer-create gdb-expression-buffer-name)))
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
707 (gdb-expressions-mode)
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
708 (setq gdb-dive-display-number number)))
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
709 (set-buffer (get-buffer-create gdb-expression-buffer-name))
48955
1abfa35a3a5a (gdb-display-number-end): Make auto-display of
Nick Roberts <nickrob@snap.net.nz>
parents: 48921
diff changeset
710 (gdb-expressions-mode)
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
711 (if (and (display-graphic-p) (not gdb-dive))
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
712 (catch 'frame-exists
48661
b092bff770ec Fold top-level `setq's and `define-key's into their corresponding defvar.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48659
diff changeset
713 (dolist (frame (frame-list))
b092bff770ec Fold top-level `setq's and `define-key's into their corresponding defvar.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48659
diff changeset
714 (if (string-equal (frame-parameter frame 'name)
b092bff770ec Fold top-level `setq's and `define-key's into their corresponding defvar.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48659
diff changeset
715 gdb-expression-buffer-name)
b092bff770ec Fold top-level `setq's and `define-key's into their corresponding defvar.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48659
diff changeset
716 (throw 'frame-exists nil)))
49249
7c4bc41333d1 Improve commentary.
Nick Roberts <nickrob@snap.net.nz>
parents: 49147
diff changeset
717 (make-frame `((height . ,gdb-window-height)
7c4bc41333d1 Improve commentary.
Nick Roberts <nickrob@snap.net.nz>
parents: 49147
diff changeset
718 (width . ,gdb-window-width)
48661
b092bff770ec Fold top-level `setq's and `define-key's into their corresponding defvar.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48659
diff changeset
719 (tool-bar-lines . nil)
b092bff770ec Fold top-level `setq's and `define-key's into their corresponding defvar.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48659
diff changeset
720 (menu-bar-lines . nil)
48955
1abfa35a3a5a (gdb-display-number-end): Make auto-display of
Nick Roberts <nickrob@snap.net.nz>
parents: 48921
diff changeset
721 (minibuffer . nil))))
1abfa35a3a5a (gdb-display-number-end): Make auto-display of
Nick Roberts <nickrob@snap.net.nz>
parents: 48921
diff changeset
722 (gdb-display-buffer (get-buffer gdb-expression-buffer-name)))))
48921
3aa5ba679145 Remove the concept of an instance. This means that a lot of functions have
Nick Roberts <nickrob@snap.net.nz>
parents: 48884
diff changeset
723 (set-buffer (gdb-get-buffer 'gdb-partial-output-buffer))
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
724 (setq gdb-dive nil))
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
725
48515
3216cd45d6d2 Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents: 48498
diff changeset
726 (defvar gdb-current-frame nil)
3216cd45d6d2 Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents: 48498
diff changeset
727 (defvar gdb-nesting-level)
3216cd45d6d2 Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents: 48498
diff changeset
728 (defvar gdb-expression)
3216cd45d6d2 Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents: 48498
diff changeset
729 (defvar gdb-point)
3216cd45d6d2 Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents: 48498
diff changeset
730 (defvar gdb-annotation-arg)
3216cd45d6d2 Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents: 48498
diff changeset
731
48661
b092bff770ec Fold top-level `setq's and `define-key's into their corresponding defvar.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48659
diff changeset
732 (defun gdb-delete-line ()
b092bff770ec Fold top-level `setq's and `define-key's into their corresponding defvar.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48659
diff changeset
733 "Delete the current line."
b092bff770ec Fold top-level `setq's and `define-key's into their corresponding defvar.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48659
diff changeset
734 (delete-region (line-beginning-position) (line-beginning-position 2)))
b092bff770ec Fold top-level `setq's and `define-key's into their corresponding defvar.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48659
diff changeset
735
48515
3216cd45d6d2 Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents: 48498
diff changeset
736 (defun gdb-display-end (ignored)
48921
3aa5ba679145 Remove the concept of an instance. This means that a lot of functions have
Nick Roberts <nickrob@snap.net.nz>
parents: 48884
diff changeset
737 (set-buffer (gdb-get-buffer 'gdb-partial-output-buffer))
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
738 (goto-char (point-min))
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
739 (search-forward ": ")
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
740 (looking-at "\\(.*?\\) =")
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
741 (let ((char "")
48641
da382393fb77 Get rid of (quote ..); use match-string and ignore.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48640
diff changeset
742 (gdb-temp-value (match-string 1)))
48662
d29870d63092 Fix up comment markers.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48661
diff changeset
743 ;;move * to front of expression if necessary
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
744 (if (looking-at ".*\\*")
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
745 (progn
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
746 (setq char "*")
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
747 (setq gdb-temp-value (substring gdb-temp-value 1 nil))))
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
748 (save-excursion
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
749 (set-buffer gdb-expression-buffer-name)
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
750 (setq gdb-expression gdb-temp-value)
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
751 (if (not (string-match "::" gdb-expression))
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
752 (setq gdb-expression (concat char gdb-current-frame
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
753 "::" gdb-expression))
48662
d29870d63092 Fix up comment markers.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48661
diff changeset
754 ;;else put * back on if necessary
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
755 (setq gdb-expression (concat char gdb-expression)))
49039
6c5f45b01d2e Acknowledge Tom Lord as author of gdba.el.
Nick Roberts <nickrob@snap.net.nz>
parents: 49000
diff changeset
756 (if (not header-line-format)
6c5f45b01d2e Acknowledge Tom Lord as author of gdba.el.
Nick Roberts <nickrob@snap.net.nz>
parents: 49000
diff changeset
757 (setq header-line-format (concat "-- " gdb-expression " %-")))))
48963
1bb53161a4b9 (gdb-info-display-custom): Ensure that frames/buffers
Nick Roberts <nickrob@snap.net.nz>
parents: 48955
diff changeset
758 ;;
48662
d29870d63092 Fix up comment markers.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48661
diff changeset
759 ;;-if scalar/string
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
760 (if (not (re-search-forward "##" nil t))
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
761 (progn
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
762 (save-excursion
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
763 (set-buffer gdb-expression-buffer-name)
49039
6c5f45b01d2e Acknowledge Tom Lord as author of gdba.el.
Nick Roberts <nickrob@snap.net.nz>
parents: 49000
diff changeset
764 (let ((buffer-read-only nil))
6c5f45b01d2e Acknowledge Tom Lord as author of gdba.el.
Nick Roberts <nickrob@snap.net.nz>
parents: 49000
diff changeset
765 (delete-region (point-min) (point-max))
6c5f45b01d2e Acknowledge Tom Lord as author of gdba.el.
Nick Roberts <nickrob@snap.net.nz>
parents: 49000
diff changeset
766 (insert-buffer-substring
6c5f45b01d2e Acknowledge Tom Lord as author of gdba.el.
Nick Roberts <nickrob@snap.net.nz>
parents: 49000
diff changeset
767 (gdb-get-buffer 'gdb-partial-output-buffer)))))
48662
d29870d63092 Fix up comment markers.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48661
diff changeset
768 ;; display expression name...
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
769 (goto-char (point-min))
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
770 (let ((start (progn (point)))
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
771 (end (progn (end-of-line) (point))))
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
772 (save-excursion
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
773 (set-buffer gdb-expression-buffer-name)
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
774 (setq buffer-read-only nil)
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
775 (delete-region (point-min) (point-max))
48921
3aa5ba679145 Remove the concept of an instance. This means that a lot of functions have
Nick Roberts <nickrob@snap.net.nz>
parents: 48884
diff changeset
776 (insert-buffer-substring (gdb-get-buffer
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
777 'gdb-partial-output-buffer)
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
778 start end)
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
779 (insert "\n")))
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
780 (goto-char (point-min))
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
781 (re-search-forward "##" nil t)
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
782 (setq gdb-nesting-level 0)
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
783 (if (looking-at "array-section-begin")
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
784 (progn
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
785 (gdb-delete-line)
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
786 (setq gdb-point (point))
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
787 (gdb-array-format)))
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
788 (if (looking-at "field-begin \\(.\\)")
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
789 (progn
48641
da382393fb77 Get rid of (quote ..); use match-string and ignore.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48640
diff changeset
790 (setq gdb-annotation-arg (match-string 1))
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
791 (gdb-field-format-begin))))
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
792 (save-excursion
48921
3aa5ba679145 Remove the concept of an instance. This means that a lot of functions have
Nick Roberts <nickrob@snap.net.nz>
parents: 48884
diff changeset
793 (set-buffer gdb-expression-buffer-name)
3aa5ba679145 Remove the concept of an instance. This means that a lot of functions have
Nick Roberts <nickrob@snap.net.nz>
parents: 48884
diff changeset
794 (if gdb-dive-display-number
3aa5ba679145 Remove the concept of an instance. This means that a lot of functions have
Nick Roberts <nickrob@snap.net.nz>
parents: 48884
diff changeset
795 (progn
49039
6c5f45b01d2e Acknowledge Tom Lord as author of gdba.el.
Nick Roberts <nickrob@snap.net.nz>
parents: 49000
diff changeset
796 (let ((buffer-read-only nil))
6c5f45b01d2e Acknowledge Tom Lord as author of gdba.el.
Nick Roberts <nickrob@snap.net.nz>
parents: 49000
diff changeset
797 (goto-char (point-max))
6c5f45b01d2e Acknowledge Tom Lord as author of gdba.el.
Nick Roberts <nickrob@snap.net.nz>
parents: 49000
diff changeset
798 (insert "\n")
6c5f45b01d2e Acknowledge Tom Lord as author of gdba.el.
Nick Roberts <nickrob@snap.net.nz>
parents: 49000
diff changeset
799 (insert-text-button "[back]" 'type 'gdb-display-back)))))
48515
3216cd45d6d2 Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents: 48498
diff changeset
800 (gdb-clear-partial-output)
48921
3aa5ba679145 Remove the concept of an instance. This means that a lot of functions have
Nick Roberts <nickrob@snap.net.nz>
parents: 48884
diff changeset
801 (gdb-set-output-sink 'user)
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
802 (setq gdb-display-in-progress nil))
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
803
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
804 (define-button-type 'gdb-display-back
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
805 'help-echo (purecopy "mouse-2, RET: go back to previous display buffer")
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
806 'action (lambda (button) (gdb-display-go-back)))
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
807
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
808 (defun gdb-display-go-back ()
48662
d29870d63092 Fix up comment markers.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48661
diff changeset
809 ;; delete display so they don't accumulate and delete buffer
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
810 (let ((number gdb-display-number))
48921
3aa5ba679145 Remove the concept of an instance. This means that a lot of functions have
Nick Roberts <nickrob@snap.net.nz>
parents: 48884
diff changeset
811 (gdb-enqueue-input
48641
da382393fb77 Get rid of (quote ..); use match-string and ignore.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48640
diff changeset
812 (list (concat "server delete display " number "\n") 'ignore))
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
813 (switch-to-buffer (concat "*display " gdb-dive-display-number "*"))
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
814 (kill-buffer (get-buffer (concat "*display " number "*")))))
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
815
48662
d29870d63092 Fix up comment markers.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48661
diff changeset
816 ;; prefix annotations with ## and process whole output in one chunk
d29870d63092 Fix up comment markers.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48661
diff changeset
817 ;; in gdb-partial-output-buffer (to allow recursion).
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
818
48662
d29870d63092 Fix up comment markers.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48661
diff changeset
819 ;; array-section flags are just removed again but after counting. They
d29870d63092 Fix up comment markers.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48661
diff changeset
820 ;; might also be useful for arrays of structures and structures with arrays.
48515
3216cd45d6d2 Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents: 48498
diff changeset
821 (defun gdb-array-section-begin (args)
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
822 (if gdb-display-in-progress
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
823 (progn
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
824 (save-excursion
48921
3aa5ba679145 Remove the concept of an instance. This means that a lot of functions have
Nick Roberts <nickrob@snap.net.nz>
parents: 48884
diff changeset
825 (set-buffer (gdb-get-buffer 'gdb-partial-output-buffer))
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
826 (goto-char (point-max))
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
827 (insert (concat "\n##array-section-begin " args "\n"))))))
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
828
48515
3216cd45d6d2 Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents: 48498
diff changeset
829 (defun gdb-array-section-end (ignored)
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
830 (if gdb-display-in-progress
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
831 (progn
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
832 (save-excursion
48921
3aa5ba679145 Remove the concept of an instance. This means that a lot of functions have
Nick Roberts <nickrob@snap.net.nz>
parents: 48884
diff changeset
833 (set-buffer (gdb-get-buffer 'gdb-partial-output-buffer))
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
834 (goto-char (point-max))
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
835 (insert "\n##array-section-end\n")))))
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
836
48515
3216cd45d6d2 Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents: 48498
diff changeset
837 (defun gdb-field-begin (args)
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
838 (if gdb-display-in-progress
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
839 (progn
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
840 (save-excursion
48921
3aa5ba679145 Remove the concept of an instance. This means that a lot of functions have
Nick Roberts <nickrob@snap.net.nz>
parents: 48884
diff changeset
841 (set-buffer (gdb-get-buffer 'gdb-partial-output-buffer))
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
842 (goto-char (point-max))
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
843 (insert (concat "\n##field-begin " args "\n"))))))
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
844
48515
3216cd45d6d2 Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents: 48498
diff changeset
845 (defun gdb-field-end (ignored)
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
846 (if gdb-display-in-progress
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
847 (progn
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
848 (save-excursion
48921
3aa5ba679145 Remove the concept of an instance. This means that a lot of functions have
Nick Roberts <nickrob@snap.net.nz>
parents: 48884
diff changeset
849 (set-buffer (gdb-get-buffer 'gdb-partial-output-buffer))
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
850 (goto-char (point-max))
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
851 (insert "\n##field-end\n")))))
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
852
48515
3216cd45d6d2 Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents: 48498
diff changeset
853 (defun gdb-elt (ignored)
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
854 (if gdb-display-in-progress
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
855 (progn
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
856 (goto-char (point-max))
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
857 (insert "\n##elt\n"))))
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
858
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
859 (defun gdb-field-format-begin ()
48662
d29870d63092 Fix up comment markers.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48661
diff changeset
860 ;; get rid of ##field-begin
d29870d63092 Fix up comment markers.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48661
diff changeset
861 (gdb-delete-line)
d29870d63092 Fix up comment markers.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48661
diff changeset
862 (gdb-insert-field)
d29870d63092 Fix up comment markers.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48661
diff changeset
863 (setq gdb-nesting-level (+ gdb-nesting-level 1))
d29870d63092 Fix up comment markers.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48661
diff changeset
864 (while (re-search-forward "##" nil t)
d29870d63092 Fix up comment markers.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48661
diff changeset
865 ;; keep making recursive calls...
d29870d63092 Fix up comment markers.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48661
diff changeset
866 (if (looking-at "field-begin \\(.\\)")
d29870d63092 Fix up comment markers.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48661
diff changeset
867 (progn
d29870d63092 Fix up comment markers.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48661
diff changeset
868 (setq gdb-annotation-arg (match-string 1))
d29870d63092 Fix up comment markers.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48661
diff changeset
869 (gdb-field-format-begin)))
d29870d63092 Fix up comment markers.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48661
diff changeset
870 ;; until field-end.
d29870d63092 Fix up comment markers.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48661
diff changeset
871 (if (looking-at "field-end") (gdb-field-format-end))))
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
872
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
873 (defun gdb-field-format-end ()
48662
d29870d63092 Fix up comment markers.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48661
diff changeset
874 ;; get rid of ##field-end and `,' or `}'
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
875 (gdb-delete-line)
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
876 (gdb-delete-line)
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
877 (setq gdb-nesting-level (- gdb-nesting-level 1)))
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
878
48661
b092bff770ec Fold top-level `setq's and `define-key's into their corresponding defvar.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48659
diff changeset
879 (defvar gdb-dive-map
b092bff770ec Fold top-level `setq's and `define-key's into their corresponding defvar.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48659
diff changeset
880 (let ((map (make-sparse-keymap)))
b092bff770ec Fold top-level `setq's and `define-key's into their corresponding defvar.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48659
diff changeset
881 (define-key map [mouse-2] 'gdb-dive)
b092bff770ec Fold top-level `setq's and `define-key's into their corresponding defvar.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48659
diff changeset
882 (define-key map [S-mouse-2] 'gdb-dive-new-frame)
b092bff770ec Fold top-level `setq's and `define-key's into their corresponding defvar.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48659
diff changeset
883 map))
48515
3216cd45d6d2 Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents: 48498
diff changeset
884
3216cd45d6d2 Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents: 48498
diff changeset
885 (defun gdb-dive (event)
3216cd45d6d2 Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents: 48498
diff changeset
886 "Dive into structure."
3216cd45d6d2 Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents: 48498
diff changeset
887 (interactive "e")
3216cd45d6d2 Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents: 48498
diff changeset
888 (setq gdb-dive t)
3216cd45d6d2 Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents: 48498
diff changeset
889 (gdb-dive-new-frame event))
3216cd45d6d2 Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents: 48498
diff changeset
890
3216cd45d6d2 Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents: 48498
diff changeset
891 (defun gdb-dive-new-frame (event)
3216cd45d6d2 Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents: 48498
diff changeset
892 "Dive into structure and display in a new frame."
3216cd45d6d2 Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents: 48498
diff changeset
893 (interactive "e")
3216cd45d6d2 Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents: 48498
diff changeset
894 (save-excursion
3216cd45d6d2 Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents: 48498
diff changeset
895 (mouse-set-point event)
3216cd45d6d2 Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents: 48498
diff changeset
896 (let ((point (point)) (gdb-full-expression gdb-expression)
3216cd45d6d2 Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents: 48498
diff changeset
897 (end (progn (end-of-line) (point)))
3216cd45d6d2 Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents: 48498
diff changeset
898 (gdb-part-expression "") (gdb-last-field nil) (gdb-display-char nil))
3216cd45d6d2 Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents: 48498
diff changeset
899 (beginning-of-line)
3216cd45d6d2 Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents: 48498
diff changeset
900 (if (looking-at "\*") (setq gdb-display-char "*"))
3216cd45d6d2 Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents: 48498
diff changeset
901 (re-search-forward "\\(\\S-+\\) = " end t)
48641
da382393fb77 Get rid of (quote ..); use match-string and ignore.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48640
diff changeset
902 (setq gdb-last-field (match-string-no-properties 1))
48515
3216cd45d6d2 Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents: 48498
diff changeset
903 (goto-char (match-beginning 1))
3216cd45d6d2 Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents: 48498
diff changeset
904 (let ((last-column (current-column)))
3216cd45d6d2 Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents: 48498
diff changeset
905 (while (re-search-backward "\\s-\\(\\S-+\\) = {" nil t)
3216cd45d6d2 Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents: 48498
diff changeset
906 (goto-char (match-beginning 1))
3216cd45d6d2 Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents: 48498
diff changeset
907 (if (and (< (current-column) last-column)
3216cd45d6d2 Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents: 48498
diff changeset
908 (> (count-lines 1 (point)) 1))
3216cd45d6d2 Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents: 48498
diff changeset
909 (progn
3216cd45d6d2 Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents: 48498
diff changeset
910 (setq gdb-part-expression
48641
da382393fb77 Get rid of (quote ..); use match-string and ignore.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48640
diff changeset
911 (concat "." (match-string-no-properties 1)
da382393fb77 Get rid of (quote ..); use match-string and ignore.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48640
diff changeset
912 gdb-part-expression))
48515
3216cd45d6d2 Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents: 48498
diff changeset
913 (setq last-column (current-column))))))
48641
da382393fb77 Get rid of (quote ..); use match-string and ignore.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48640
diff changeset
914 ;; * not needed for components of a pointer to a structure in gdb
48515
3216cd45d6d2 Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents: 48498
diff changeset
915 (if (string-equal "*" (substring gdb-full-expression 0 1))
3216cd45d6d2 Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents: 48498
diff changeset
916 (setq gdb-full-expression (substring gdb-full-expression 1 nil)))
3216cd45d6d2 Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents: 48498
diff changeset
917 (setq gdb-full-expression
3216cd45d6d2 Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents: 48498
diff changeset
918 (concat gdb-full-expression gdb-part-expression "." gdb-last-field))
48921
3aa5ba679145 Remove the concept of an instance. This means that a lot of functions have
Nick Roberts <nickrob@snap.net.nz>
parents: 48884
diff changeset
919 (gdb-enqueue-input
48641
da382393fb77 Get rid of (quote ..); use match-string and ignore.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48640
diff changeset
920 (list (concat "server display" gdb-display-char
da382393fb77 Get rid of (quote ..); use match-string and ignore.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48640
diff changeset
921 " " gdb-full-expression "\n")
da382393fb77 Get rid of (quote ..); use match-string and ignore.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48640
diff changeset
922 'ignore)))))
48515
3216cd45d6d2 Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents: 48498
diff changeset
923
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
924 (defun gdb-insert-field ()
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
925 (let ((start (progn (point)))
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
926 (end (progn (next-line) (point)))
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
927 (num 0))
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
928 (save-excursion
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
929 (set-buffer gdb-expression-buffer-name)
49039
6c5f45b01d2e Acknowledge Tom Lord as author of gdba.el.
Nick Roberts <nickrob@snap.net.nz>
parents: 49000
diff changeset
930 (let ((buffer-read-only nil))
6c5f45b01d2e Acknowledge Tom Lord as author of gdba.el.
Nick Roberts <nickrob@snap.net.nz>
parents: 49000
diff changeset
931 (if (string-equal gdb-annotation-arg "\*") (insert "\*"))
6c5f45b01d2e Acknowledge Tom Lord as author of gdba.el.
Nick Roberts <nickrob@snap.net.nz>
parents: 49000
diff changeset
932 (while (<= num gdb-nesting-level)
6c5f45b01d2e Acknowledge Tom Lord as author of gdba.el.
Nick Roberts <nickrob@snap.net.nz>
parents: 49000
diff changeset
933 (insert "\t")
6c5f45b01d2e Acknowledge Tom Lord as author of gdba.el.
Nick Roberts <nickrob@snap.net.nz>
parents: 49000
diff changeset
934 (setq num (+ num 1)))
6c5f45b01d2e Acknowledge Tom Lord as author of gdba.el.
Nick Roberts <nickrob@snap.net.nz>
parents: 49000
diff changeset
935 (insert-buffer-substring (gdb-get-buffer
6c5f45b01d2e Acknowledge Tom Lord as author of gdba.el.
Nick Roberts <nickrob@snap.net.nz>
parents: 49000
diff changeset
936 'gdb-partial-output-buffer)
6c5f45b01d2e Acknowledge Tom Lord as author of gdba.el.
Nick Roberts <nickrob@snap.net.nz>
parents: 49000
diff changeset
937 start end)
6c5f45b01d2e Acknowledge Tom Lord as author of gdba.el.
Nick Roberts <nickrob@snap.net.nz>
parents: 49000
diff changeset
938 (put-text-property (- (point) (- end start)) (- (point) 1)
6c5f45b01d2e Acknowledge Tom Lord as author of gdba.el.
Nick Roberts <nickrob@snap.net.nz>
parents: 49000
diff changeset
939 'mouse-face 'highlight)
6c5f45b01d2e Acknowledge Tom Lord as author of gdba.el.
Nick Roberts <nickrob@snap.net.nz>
parents: 49000
diff changeset
940 (put-text-property (- (point) (- end start)) (- (point) 1)
6c5f45b01d2e Acknowledge Tom Lord as author of gdba.el.
Nick Roberts <nickrob@snap.net.nz>
parents: 49000
diff changeset
941 'local-map gdb-dive-map)))
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
942 (delete-region start end)))
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
943
48515
3216cd45d6d2 Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents: 48498
diff changeset
944 (defvar gdb-values)
3216cd45d6d2 Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents: 48498
diff changeset
945
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
946 (defun gdb-array-format ()
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
947 (while (re-search-forward "##" nil t)
48662
d29870d63092 Fix up comment markers.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48661
diff changeset
948 ;; keep making recursive calls...
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
949 (if (looking-at "array-section-begin")
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
950 (progn
48662
d29870d63092 Fix up comment markers.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48661
diff changeset
951 ;;get rid of ##array-section-begin
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
952 (gdb-delete-line)
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
953 (setq gdb-nesting-level (+ gdb-nesting-level 1))
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
954 (gdb-array-format)))
48662
d29870d63092 Fix up comment markers.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48661
diff changeset
955 ;;until *matching* array-section-end is found
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
956 (if (looking-at "array-section-end")
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
957 (if (eq gdb-nesting-level 0)
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
958 (progn
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
959 (let ((values (buffer-substring gdb-point (- (point) 2))))
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
960 (save-excursion
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
961 (set-buffer gdb-expression-buffer-name)
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
962 (setq gdb-values
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
963 (concat "{" (replace-regexp-in-string "\n" "" values)
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
964 "}"))
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
965 (gdb-array-format1))))
48662
d29870d63092 Fix up comment markers.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48661
diff changeset
966 ;;else get rid of ##array-section-end etc
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
967 (gdb-delete-line)
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
968 (setq gdb-nesting-level (- gdb-nesting-level 1))
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
969 (gdb-array-format)))))
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
970
48515
3216cd45d6d2 Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents: 48498
diff changeset
971 (defvar gdb-array-start)
3216cd45d6d2 Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents: 48498
diff changeset
972 (defvar gdb-array-stop)
3216cd45d6d2 Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents: 48498
diff changeset
973
48661
b092bff770ec Fold top-level `setq's and `define-key's into their corresponding defvar.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48659
diff changeset
974 (defvar gdb-array-slice-map
b092bff770ec Fold top-level `setq's and `define-key's into their corresponding defvar.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48659
diff changeset
975 (let ((map (make-sparse-keymap)))
b092bff770ec Fold top-level `setq's and `define-key's into their corresponding defvar.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48659
diff changeset
976 (define-key map [mouse-2] 'gdb-array-slice)
b092bff770ec Fold top-level `setq's and `define-key's into their corresponding defvar.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48659
diff changeset
977 map))
48515
3216cd45d6d2 Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents: 48498
diff changeset
978
3216cd45d6d2 Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents: 48498
diff changeset
979 (defun gdb-array-slice (event)
3216cd45d6d2 Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents: 48498
diff changeset
980 "Select an array slice to display."
3216cd45d6d2 Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents: 48498
diff changeset
981 (interactive "e")
3216cd45d6d2 Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents: 48498
diff changeset
982 (mouse-set-point event)
3216cd45d6d2 Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents: 48498
diff changeset
983 (save-excursion
3216cd45d6d2 Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents: 48498
diff changeset
984 (let ((n -1) (stop 0) (start 0) (point (point)))
3216cd45d6d2 Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents: 48498
diff changeset
985 (beginning-of-line)
3216cd45d6d2 Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents: 48498
diff changeset
986 (while (search-forward "[" point t)
3216cd45d6d2 Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents: 48498
diff changeset
987 (setq n (+ n 1)))
3216cd45d6d2 Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents: 48498
diff changeset
988 (setq start (string-to-int (read-string "Start index: ")))
3216cd45d6d2 Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents: 48498
diff changeset
989 (aset gdb-array-start n start)
3216cd45d6d2 Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents: 48498
diff changeset
990 (setq stop (string-to-int (read-string "Stop index: ")))
3216cd45d6d2 Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents: 48498
diff changeset
991 (aset gdb-array-stop n stop)))
3216cd45d6d2 Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents: 48498
diff changeset
992 (gdb-array-format1))
3216cd45d6d2 Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents: 48498
diff changeset
993
3216cd45d6d2 Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents: 48498
diff changeset
994 (defvar gdb-display-string)
3216cd45d6d2 Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents: 48498
diff changeset
995 (defvar gdb-array-size)
3216cd45d6d2 Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents: 48498
diff changeset
996
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
997 (defun gdb-array-format1 ()
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
998 (setq gdb-display-string "")
49039
6c5f45b01d2e Acknowledge Tom Lord as author of gdba.el.
Nick Roberts <nickrob@snap.net.nz>
parents: 49000
diff changeset
999 (let ((buffer-read-only nil))
6c5f45b01d2e Acknowledge Tom Lord as author of gdba.el.
Nick Roberts <nickrob@snap.net.nz>
parents: 49000
diff changeset
1000 (delete-region (point-min) (point-max))
6c5f45b01d2e Acknowledge Tom Lord as author of gdba.el.
Nick Roberts <nickrob@snap.net.nz>
parents: 49000
diff changeset
1001 (let ((gdb-value-list (split-string gdb-values ", ")))
6c5f45b01d2e Acknowledge Tom Lord as author of gdba.el.
Nick Roberts <nickrob@snap.net.nz>
parents: 49000
diff changeset
1002 (string-match "\\({+\\)" (car gdb-value-list))
6c5f45b01d2e Acknowledge Tom Lord as author of gdba.el.
Nick Roberts <nickrob@snap.net.nz>
parents: 49000
diff changeset
1003 (let* ((depth (- (match-end 1) (match-beginning 1)))
6c5f45b01d2e Acknowledge Tom Lord as author of gdba.el.
Nick Roberts <nickrob@snap.net.nz>
parents: 49000
diff changeset
1004 (indices (make-vector depth '0))
6c5f45b01d2e Acknowledge Tom Lord as author of gdba.el.
Nick Roberts <nickrob@snap.net.nz>
parents: 49000
diff changeset
1005 (index 0) (num 0) (array-start "")
6c5f45b01d2e Acknowledge Tom Lord as author of gdba.el.
Nick Roberts <nickrob@snap.net.nz>
parents: 49000
diff changeset
1006 (array-stop "") (array-slice "") (array-range nil)
6c5f45b01d2e Acknowledge Tom Lord as author of gdba.el.
Nick Roberts <nickrob@snap.net.nz>
parents: 49000
diff changeset
1007 (flag t) (indices-string ""))
6c5f45b01d2e Acknowledge Tom Lord as author of gdba.el.
Nick Roberts <nickrob@snap.net.nz>
parents: 49000
diff changeset
1008 (dolist (gdb-value gdb-value-list)
6c5f45b01d2e Acknowledge Tom Lord as author of gdba.el.
Nick Roberts <nickrob@snap.net.nz>
parents: 49000
diff changeset
1009 (string-match "{*\\([^}]*\\)\\(}*\\)" gdb-value)
6c5f45b01d2e Acknowledge Tom Lord as author of gdba.el.
Nick Roberts <nickrob@snap.net.nz>
parents: 49000
diff changeset
1010 (setq num 0)
6c5f45b01d2e Acknowledge Tom Lord as author of gdba.el.
Nick Roberts <nickrob@snap.net.nz>
parents: 49000
diff changeset
1011 (while (< num depth)
6c5f45b01d2e Acknowledge Tom Lord as author of gdba.el.
Nick Roberts <nickrob@snap.net.nz>
parents: 49000
diff changeset
1012 (setq indices-string
6c5f45b01d2e Acknowledge Tom Lord as author of gdba.el.
Nick Roberts <nickrob@snap.net.nz>
parents: 49000
diff changeset
1013 (concat indices-string
6c5f45b01d2e Acknowledge Tom Lord as author of gdba.el.
Nick Roberts <nickrob@snap.net.nz>
parents: 49000
diff changeset
1014 "[" (int-to-string (aref indices num)) "]"))
6c5f45b01d2e Acknowledge Tom Lord as author of gdba.el.
Nick Roberts <nickrob@snap.net.nz>
parents: 49000
diff changeset
1015 (if (not (= (aref gdb-array-start num) -1))
6c5f45b01d2e Acknowledge Tom Lord as author of gdba.el.
Nick Roberts <nickrob@snap.net.nz>
parents: 49000
diff changeset
1016 (if (or (< (aref indices num) (aref gdb-array-start num))
6c5f45b01d2e Acknowledge Tom Lord as author of gdba.el.
Nick Roberts <nickrob@snap.net.nz>
parents: 49000
diff changeset
1017 (> (aref indices num) (aref gdb-array-stop num)))
6c5f45b01d2e Acknowledge Tom Lord as author of gdba.el.
Nick Roberts <nickrob@snap.net.nz>
parents: 49000
diff changeset
1018 (setq flag nil))
6c5f45b01d2e Acknowledge Tom Lord as author of gdba.el.
Nick Roberts <nickrob@snap.net.nz>
parents: 49000
diff changeset
1019 (aset gdb-array-size num (aref indices num)))
6c5f45b01d2e Acknowledge Tom Lord as author of gdba.el.
Nick Roberts <nickrob@snap.net.nz>
parents: 49000
diff changeset
1020 (setq num (+ num 1)))
6c5f45b01d2e Acknowledge Tom Lord as author of gdba.el.
Nick Roberts <nickrob@snap.net.nz>
parents: 49000
diff changeset
1021 (if flag
6c5f45b01d2e Acknowledge Tom Lord as author of gdba.el.
Nick Roberts <nickrob@snap.net.nz>
parents: 49000
diff changeset
1022 (let ((gdb-display-value (match-string 1 gdb-value)))
6c5f45b01d2e Acknowledge Tom Lord as author of gdba.el.
Nick Roberts <nickrob@snap.net.nz>
parents: 49000
diff changeset
1023 (setq gdb-display-string (concat gdb-display-string " "
6c5f45b01d2e Acknowledge Tom Lord as author of gdba.el.
Nick Roberts <nickrob@snap.net.nz>
parents: 49000
diff changeset
1024 gdb-display-value))
6c5f45b01d2e Acknowledge Tom Lord as author of gdba.el.
Nick Roberts <nickrob@snap.net.nz>
parents: 49000
diff changeset
1025 (insert
6c5f45b01d2e Acknowledge Tom Lord as author of gdba.el.
Nick Roberts <nickrob@snap.net.nz>
parents: 49000
diff changeset
1026 (concat indices-string "\t" gdb-display-value "\n"))))
6c5f45b01d2e Acknowledge Tom Lord as author of gdba.el.
Nick Roberts <nickrob@snap.net.nz>
parents: 49000
diff changeset
1027 (setq indices-string "")
6c5f45b01d2e Acknowledge Tom Lord as author of gdba.el.
Nick Roberts <nickrob@snap.net.nz>
parents: 49000
diff changeset
1028 (setq flag t)
6c5f45b01d2e Acknowledge Tom Lord as author of gdba.el.
Nick Roberts <nickrob@snap.net.nz>
parents: 49000
diff changeset
1029 ;; 0<= index < depth, start at right : (- depth 1)
6c5f45b01d2e Acknowledge Tom Lord as author of gdba.el.
Nick Roberts <nickrob@snap.net.nz>
parents: 49000
diff changeset
1030 (setq index (- (- depth 1)
6c5f45b01d2e Acknowledge Tom Lord as author of gdba.el.
Nick Roberts <nickrob@snap.net.nz>
parents: 49000
diff changeset
1031 (- (match-end 2) (match-beginning 2))))
6c5f45b01d2e Acknowledge Tom Lord as author of gdba.el.
Nick Roberts <nickrob@snap.net.nz>
parents: 49000
diff changeset
1032 ;;don't set for very last brackets
6c5f45b01d2e Acknowledge Tom Lord as author of gdba.el.
Nick Roberts <nickrob@snap.net.nz>
parents: 49000
diff changeset
1033 (when (>= index 0)
6c5f45b01d2e Acknowledge Tom Lord as author of gdba.el.
Nick Roberts <nickrob@snap.net.nz>
parents: 49000
diff changeset
1034 (aset indices index (+ 1 (aref indices index)))
6c5f45b01d2e Acknowledge Tom Lord as author of gdba.el.
Nick Roberts <nickrob@snap.net.nz>
parents: 49000
diff changeset
1035 (setq num (+ 1 index))
6c5f45b01d2e Acknowledge Tom Lord as author of gdba.el.
Nick Roberts <nickrob@snap.net.nz>
parents: 49000
diff changeset
1036 (while (< num depth)
6c5f45b01d2e Acknowledge Tom Lord as author of gdba.el.
Nick Roberts <nickrob@snap.net.nz>
parents: 49000
diff changeset
1037 (aset indices num 0)
6c5f45b01d2e Acknowledge Tom Lord as author of gdba.el.
Nick Roberts <nickrob@snap.net.nz>
parents: 49000
diff changeset
1038 (setq num (+ num 1)))))
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1039 (setq num 0)
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1040 (while (< num depth)
49039
6c5f45b01d2e Acknowledge Tom Lord as author of gdba.el.
Nick Roberts <nickrob@snap.net.nz>
parents: 49000
diff changeset
1041 (if (= (aref gdb-array-start num) -1)
6c5f45b01d2e Acknowledge Tom Lord as author of gdba.el.
Nick Roberts <nickrob@snap.net.nz>
parents: 49000
diff changeset
1042 (progn
6c5f45b01d2e Acknowledge Tom Lord as author of gdba.el.
Nick Roberts <nickrob@snap.net.nz>
parents: 49000
diff changeset
1043 (aset gdb-array-start num 0)
6c5f45b01d2e Acknowledge Tom Lord as author of gdba.el.
Nick Roberts <nickrob@snap.net.nz>
parents: 49000
diff changeset
1044 (aset gdb-array-stop num (aref indices num))))
6c5f45b01d2e Acknowledge Tom Lord as author of gdba.el.
Nick Roberts <nickrob@snap.net.nz>
parents: 49000
diff changeset
1045 (setq array-start (int-to-string (aref gdb-array-start num)))
6c5f45b01d2e Acknowledge Tom Lord as author of gdba.el.
Nick Roberts <nickrob@snap.net.nz>
parents: 49000
diff changeset
1046 (setq array-stop (int-to-string (aref gdb-array-stop num)))
6c5f45b01d2e Acknowledge Tom Lord as author of gdba.el.
Nick Roberts <nickrob@snap.net.nz>
parents: 49000
diff changeset
1047 (setq array-range (concat "[" array-start
6c5f45b01d2e Acknowledge Tom Lord as author of gdba.el.
Nick Roberts <nickrob@snap.net.nz>
parents: 49000
diff changeset
1048 ":" array-stop "]"))
6c5f45b01d2e Acknowledge Tom Lord as author of gdba.el.
Nick Roberts <nickrob@snap.net.nz>
parents: 49000
diff changeset
1049 (put-text-property 1 (+ (length array-start)
6c5f45b01d2e Acknowledge Tom Lord as author of gdba.el.
Nick Roberts <nickrob@snap.net.nz>
parents: 49000
diff changeset
1050 (length array-stop) 2)
6c5f45b01d2e Acknowledge Tom Lord as author of gdba.el.
Nick Roberts <nickrob@snap.net.nz>
parents: 49000
diff changeset
1051 'mouse-face 'highlight array-range)
6c5f45b01d2e Acknowledge Tom Lord as author of gdba.el.
Nick Roberts <nickrob@snap.net.nz>
parents: 49000
diff changeset
1052 (put-text-property 1 (+ (length array-start)
6c5f45b01d2e Acknowledge Tom Lord as author of gdba.el.
Nick Roberts <nickrob@snap.net.nz>
parents: 49000
diff changeset
1053 (length array-stop) 2)
6c5f45b01d2e Acknowledge Tom Lord as author of gdba.el.
Nick Roberts <nickrob@snap.net.nz>
parents: 49000
diff changeset
1054 'local-map gdb-array-slice-map array-range)
6c5f45b01d2e Acknowledge Tom Lord as author of gdba.el.
Nick Roberts <nickrob@snap.net.nz>
parents: 49000
diff changeset
1055 (goto-char (point-min))
6c5f45b01d2e Acknowledge Tom Lord as author of gdba.el.
Nick Roberts <nickrob@snap.net.nz>
parents: 49000
diff changeset
1056 (setq array-slice (concat array-slice array-range))
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1057 (setq num (+ num 1)))
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1058 (goto-char (point-min))
49039
6c5f45b01d2e Acknowledge Tom Lord as author of gdba.el.
Nick Roberts <nickrob@snap.net.nz>
parents: 49000
diff changeset
1059 (insert "Array Size : ")
6c5f45b01d2e Acknowledge Tom Lord as author of gdba.el.
Nick Roberts <nickrob@snap.net.nz>
parents: 49000
diff changeset
1060 (setq num 0)
6c5f45b01d2e Acknowledge Tom Lord as author of gdba.el.
Nick Roberts <nickrob@snap.net.nz>
parents: 49000
diff changeset
1061 (while (< num depth)
6c5f45b01d2e Acknowledge Tom Lord as author of gdba.el.
Nick Roberts <nickrob@snap.net.nz>
parents: 49000
diff changeset
1062 (insert
6c5f45b01d2e Acknowledge Tom Lord as author of gdba.el.
Nick Roberts <nickrob@snap.net.nz>
parents: 49000
diff changeset
1063 (concat "["
6c5f45b01d2e Acknowledge Tom Lord as author of gdba.el.
Nick Roberts <nickrob@snap.net.nz>
parents: 49000
diff changeset
1064 (int-to-string (+ (aref gdb-array-size num) 1)) "]"))
6c5f45b01d2e Acknowledge Tom Lord as author of gdba.el.
Nick Roberts <nickrob@snap.net.nz>
parents: 49000
diff changeset
1065 (setq num (+ num 1)))
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1066 (insert
49039
6c5f45b01d2e Acknowledge Tom Lord as author of gdba.el.
Nick Roberts <nickrob@snap.net.nz>
parents: 49000
diff changeset
1067 (concat "\n Slice : " array-slice "\n\nIndex\tValues\n\n"))))))
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1068
48884
f774c94b3b5e (gdba-marker-filter, gdb-output-burst): Merge and
Nick Roberts <nickrob@snap.net.nz>
parents: 48827
diff changeset
1069 (defun gud-gdba-marker-filter (string)
48921
3aa5ba679145 Remove the concept of an instance. This means that a lot of functions have
Nick Roberts <nickrob@snap.net.nz>
parents: 48884
diff changeset
1070 "A gud marker filter for gdb. Handle a burst of output from GDB."
49000
f3c5848184cb (gdb-delete-display): Rename (gdb-delete-expression).
Nick Roberts <nickrob@snap.net.nz>
parents: 48963
diff changeset
1071 (let (
f3c5848184cb (gdb-delete-display): Rename (gdb-delete-expression).
Nick Roberts <nickrob@snap.net.nz>
parents: 48963
diff changeset
1072 ;; Recall the left over burst from last time
f3c5848184cb (gdb-delete-display): Rename (gdb-delete-expression).
Nick Roberts <nickrob@snap.net.nz>
parents: 48963
diff changeset
1073 (burst (concat (gdb-get-burst) string))
f3c5848184cb (gdb-delete-display): Rename (gdb-delete-expression).
Nick Roberts <nickrob@snap.net.nz>
parents: 48963
diff changeset
1074 ;; Start accumulating output for the GUD buffer
f3c5848184cb (gdb-delete-display): Rename (gdb-delete-expression).
Nick Roberts <nickrob@snap.net.nz>
parents: 48963
diff changeset
1075 (output ""))
f3c5848184cb (gdb-delete-display): Rename (gdb-delete-expression).
Nick Roberts <nickrob@snap.net.nz>
parents: 48963
diff changeset
1076 ;;
f3c5848184cb (gdb-delete-display): Rename (gdb-delete-expression).
Nick Roberts <nickrob@snap.net.nz>
parents: 48963
diff changeset
1077 ;; Process all the complete markers in this chunk.
f3c5848184cb (gdb-delete-display): Rename (gdb-delete-expression).
Nick Roberts <nickrob@snap.net.nz>
parents: 48963
diff changeset
1078 (while (string-match "\n\032\032\\(.*\\)\n" burst)
f3c5848184cb (gdb-delete-display): Rename (gdb-delete-expression).
Nick Roberts <nickrob@snap.net.nz>
parents: 48963
diff changeset
1079 (let ((annotation (match-string 1 burst)))
f3c5848184cb (gdb-delete-display): Rename (gdb-delete-expression).
Nick Roberts <nickrob@snap.net.nz>
parents: 48963
diff changeset
1080 ;;
f3c5848184cb (gdb-delete-display): Rename (gdb-delete-expression).
Nick Roberts <nickrob@snap.net.nz>
parents: 48963
diff changeset
1081 ;; Stuff prior to the match is just ordinary output.
f3c5848184cb (gdb-delete-display): Rename (gdb-delete-expression).
Nick Roberts <nickrob@snap.net.nz>
parents: 48963
diff changeset
1082 ;; It is either concatenated to OUTPUT or directed
f3c5848184cb (gdb-delete-display): Rename (gdb-delete-expression).
Nick Roberts <nickrob@snap.net.nz>
parents: 48963
diff changeset
1083 ;; elsewhere.
f3c5848184cb (gdb-delete-display): Rename (gdb-delete-expression).
Nick Roberts <nickrob@snap.net.nz>
parents: 48963
diff changeset
1084 (setq output
f3c5848184cb (gdb-delete-display): Rename (gdb-delete-expression).
Nick Roberts <nickrob@snap.net.nz>
parents: 48963
diff changeset
1085 (gdb-concat-output
f3c5848184cb (gdb-delete-display): Rename (gdb-delete-expression).
Nick Roberts <nickrob@snap.net.nz>
parents: 48963
diff changeset
1086 output
f3c5848184cb (gdb-delete-display): Rename (gdb-delete-expression).
Nick Roberts <nickrob@snap.net.nz>
parents: 48963
diff changeset
1087 (substring burst 0 (match-beginning 0))))
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1088
49000
f3c5848184cb (gdb-delete-display): Rename (gdb-delete-expression).
Nick Roberts <nickrob@snap.net.nz>
parents: 48963
diff changeset
1089 ;; Take that stuff off the burst.
f3c5848184cb (gdb-delete-display): Rename (gdb-delete-expression).
Nick Roberts <nickrob@snap.net.nz>
parents: 48963
diff changeset
1090 (setq burst (substring burst (match-end 0)))
48300
69646014abb3 Fix feature name in `require'.
Juanma Barranquero <lekktu@gmail.com>
parents: 48292
diff changeset
1091
49000
f3c5848184cb (gdb-delete-display): Rename (gdb-delete-expression).
Nick Roberts <nickrob@snap.net.nz>
parents: 48963
diff changeset
1092 ;; Parse the tag from the annotation, and maybe its arguments.
f3c5848184cb (gdb-delete-display): Rename (gdb-delete-expression).
Nick Roberts <nickrob@snap.net.nz>
parents: 48963
diff changeset
1093 (string-match "\\(\\S-*\\) ?\\(.*\\)" annotation)
f3c5848184cb (gdb-delete-display): Rename (gdb-delete-expression).
Nick Roberts <nickrob@snap.net.nz>
parents: 48963
diff changeset
1094 (let* ((annotation-type (match-string 1 annotation))
f3c5848184cb (gdb-delete-display): Rename (gdb-delete-expression).
Nick Roberts <nickrob@snap.net.nz>
parents: 48963
diff changeset
1095 (annotation-arguments (match-string 2 annotation))
f3c5848184cb (gdb-delete-display): Rename (gdb-delete-expression).
Nick Roberts <nickrob@snap.net.nz>
parents: 48963
diff changeset
1096 (annotation-rule (assoc annotation-type
f3c5848184cb (gdb-delete-display): Rename (gdb-delete-expression).
Nick Roberts <nickrob@snap.net.nz>
parents: 48963
diff changeset
1097 gdb-annotation-rules)))
f3c5848184cb (gdb-delete-display): Rename (gdb-delete-expression).
Nick Roberts <nickrob@snap.net.nz>
parents: 48963
diff changeset
1098 ;; Call the handler for this annotation.
f3c5848184cb (gdb-delete-display): Rename (gdb-delete-expression).
Nick Roberts <nickrob@snap.net.nz>
parents: 48963
diff changeset
1099 (if annotation-rule
f3c5848184cb (gdb-delete-display): Rename (gdb-delete-expression).
Nick Roberts <nickrob@snap.net.nz>
parents: 48963
diff changeset
1100 (funcall (car (cdr annotation-rule))
f3c5848184cb (gdb-delete-display): Rename (gdb-delete-expression).
Nick Roberts <nickrob@snap.net.nz>
parents: 48963
diff changeset
1101 annotation-arguments)
f3c5848184cb (gdb-delete-display): Rename (gdb-delete-expression).
Nick Roberts <nickrob@snap.net.nz>
parents: 48963
diff changeset
1102 ;; Else the annotation is not recognized. Ignore it silently,
f3c5848184cb (gdb-delete-display): Rename (gdb-delete-expression).
Nick Roberts <nickrob@snap.net.nz>
parents: 48963
diff changeset
1103 ;; so that GDB can add new annotations without causing
f3c5848184cb (gdb-delete-display): Rename (gdb-delete-expression).
Nick Roberts <nickrob@snap.net.nz>
parents: 48963
diff changeset
1104 ;; us to blow up.
f3c5848184cb (gdb-delete-display): Rename (gdb-delete-expression).
Nick Roberts <nickrob@snap.net.nz>
parents: 48963
diff changeset
1105 ))))
f3c5848184cb (gdb-delete-display): Rename (gdb-delete-expression).
Nick Roberts <nickrob@snap.net.nz>
parents: 48963
diff changeset
1106 ;;
f3c5848184cb (gdb-delete-display): Rename (gdb-delete-expression).
Nick Roberts <nickrob@snap.net.nz>
parents: 48963
diff changeset
1107 ;; Does the remaining text end in a partial line?
f3c5848184cb (gdb-delete-display): Rename (gdb-delete-expression).
Nick Roberts <nickrob@snap.net.nz>
parents: 48963
diff changeset
1108 ;; If it does, then keep part of the burst until we get more.
f3c5848184cb (gdb-delete-display): Rename (gdb-delete-expression).
Nick Roberts <nickrob@snap.net.nz>
parents: 48963
diff changeset
1109 (if (string-match "\n\\'\\|\n\032\\'\\|\n\032\032.*\\'"
f3c5848184cb (gdb-delete-display): Rename (gdb-delete-expression).
Nick Roberts <nickrob@snap.net.nz>
parents: 48963
diff changeset
1110 burst)
f3c5848184cb (gdb-delete-display): Rename (gdb-delete-expression).
Nick Roberts <nickrob@snap.net.nz>
parents: 48963
diff changeset
1111 (progn
f3c5848184cb (gdb-delete-display): Rename (gdb-delete-expression).
Nick Roberts <nickrob@snap.net.nz>
parents: 48963
diff changeset
1112 ;; Everything before the potential marker start can be output.
f3c5848184cb (gdb-delete-display): Rename (gdb-delete-expression).
Nick Roberts <nickrob@snap.net.nz>
parents: 48963
diff changeset
1113 (setq output
f3c5848184cb (gdb-delete-display): Rename (gdb-delete-expression).
Nick Roberts <nickrob@snap.net.nz>
parents: 48963
diff changeset
1114 (gdb-concat-output output
f3c5848184cb (gdb-delete-display): Rename (gdb-delete-expression).
Nick Roberts <nickrob@snap.net.nz>
parents: 48963
diff changeset
1115 (substring burst 0 (match-beginning 0))))
f3c5848184cb (gdb-delete-display): Rename (gdb-delete-expression).
Nick Roberts <nickrob@snap.net.nz>
parents: 48963
diff changeset
1116 ;;
f3c5848184cb (gdb-delete-display): Rename (gdb-delete-expression).
Nick Roberts <nickrob@snap.net.nz>
parents: 48963
diff changeset
1117 ;; Everything after, we save, to combine with later input.
f3c5848184cb (gdb-delete-display): Rename (gdb-delete-expression).
Nick Roberts <nickrob@snap.net.nz>
parents: 48963
diff changeset
1118 (setq burst (substring burst (match-beginning 0))))
48963
1bb53161a4b9 (gdb-info-display-custom): Ensure that frames/buffers
Nick Roberts <nickrob@snap.net.nz>
parents: 48955
diff changeset
1119 ;;
49000
f3c5848184cb (gdb-delete-display): Rename (gdb-delete-expression).
Nick Roberts <nickrob@snap.net.nz>
parents: 48963
diff changeset
1120 ;; In case we know the burst contains no partial annotations:
f3c5848184cb (gdb-delete-display): Rename (gdb-delete-expression).
Nick Roberts <nickrob@snap.net.nz>
parents: 48963
diff changeset
1121 (progn
f3c5848184cb (gdb-delete-display): Rename (gdb-delete-expression).
Nick Roberts <nickrob@snap.net.nz>
parents: 48963
diff changeset
1122 (setq output (gdb-concat-output output burst))
f3c5848184cb (gdb-delete-display): Rename (gdb-delete-expression).
Nick Roberts <nickrob@snap.net.nz>
parents: 48963
diff changeset
1123 (setq burst "")))
f3c5848184cb (gdb-delete-display): Rename (gdb-delete-expression).
Nick Roberts <nickrob@snap.net.nz>
parents: 48963
diff changeset
1124 ;;
f3c5848184cb (gdb-delete-display): Rename (gdb-delete-expression).
Nick Roberts <nickrob@snap.net.nz>
parents: 48963
diff changeset
1125 ;; Save the remaining burst for the next call to this function.
f3c5848184cb (gdb-delete-display): Rename (gdb-delete-expression).
Nick Roberts <nickrob@snap.net.nz>
parents: 48963
diff changeset
1126 (gdb-set-burst burst)
f3c5848184cb (gdb-delete-display): Rename (gdb-delete-expression).
Nick Roberts <nickrob@snap.net.nz>
parents: 48963
diff changeset
1127 output))
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1128
48515
3216cd45d6d2 Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents: 48498
diff changeset
1129 (defun gdb-concat-output (so-far new)
48921
3aa5ba679145 Remove the concept of an instance. This means that a lot of functions have
Nick Roberts <nickrob@snap.net.nz>
parents: 48884
diff changeset
1130 (let ((sink (gdb-get-output-sink )))
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1131 (cond
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1132 ((eq sink 'user) (concat so-far new))
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1133 ((or (eq sink 'pre-emacs) (eq sink 'post-emacs)) so-far)
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1134 ((eq sink 'emacs)
48515
3216cd45d6d2 Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents: 48498
diff changeset
1135 (gdb-append-to-partial-output new)
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1136 so-far)
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1137 ((eq sink 'inferior)
48515
3216cd45d6d2 Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents: 48498
diff changeset
1138 (gdb-append-to-inferior-io new)
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1139 so-far)
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1140 (t (error "Bogon output sink %S" sink)))))
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1141
48515
3216cd45d6d2 Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents: 48498
diff changeset
1142 (defun gdb-append-to-partial-output (string)
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1143 (save-excursion
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1144 (set-buffer
48921
3aa5ba679145 Remove the concept of an instance. This means that a lot of functions have
Nick Roberts <nickrob@snap.net.nz>
parents: 48884
diff changeset
1145 (gdb-get-create-buffer 'gdb-partial-output-buffer))
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1146 (goto-char (point-max))
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1147 (insert string)))
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1148
48515
3216cd45d6d2 Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents: 48498
diff changeset
1149 (defun gdb-clear-partial-output ()
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1150 (save-excursion
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1151 (set-buffer
48921
3aa5ba679145 Remove the concept of an instance. This means that a lot of functions have
Nick Roberts <nickrob@snap.net.nz>
parents: 48884
diff changeset
1152 (gdb-get-create-buffer 'gdb-partial-output-buffer))
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1153 (delete-region (point-min) (point-max))))
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1154
48515
3216cd45d6d2 Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents: 48498
diff changeset
1155 (defun gdb-append-to-inferior-io (string)
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1156 (save-excursion
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1157 (set-buffer
48921
3aa5ba679145 Remove the concept of an instance. This means that a lot of functions have
Nick Roberts <nickrob@snap.net.nz>
parents: 48884
diff changeset
1158 (gdb-get-create-buffer 'gdb-inferior-io))
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1159 (goto-char (point-max))
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1160 (insert-before-markers string))
48884
f774c94b3b5e (gdba-marker-filter, gdb-output-burst): Merge and
Nick Roberts <nickrob@snap.net.nz>
parents: 48827
diff changeset
1161 (if (not (string-equal string ""))
f774c94b3b5e (gdba-marker-filter, gdb-output-burst): Merge and
Nick Roberts <nickrob@snap.net.nz>
parents: 48827
diff changeset
1162 (gdb-display-buffer
48921
3aa5ba679145 Remove the concept of an instance. This means that a lot of functions have
Nick Roberts <nickrob@snap.net.nz>
parents: 48884
diff changeset
1163 (gdb-get-create-buffer 'gdb-inferior-io))))
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1164
48515
3216cd45d6d2 Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents: 48498
diff changeset
1165 (defun gdb-clear-inferior-io ()
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1166 (save-excursion
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1167 (set-buffer
48921
3aa5ba679145 Remove the concept of an instance. This means that a lot of functions have
Nick Roberts <nickrob@snap.net.nz>
parents: 48884
diff changeset
1168 (gdb-get-create-buffer 'gdb-inferior-io))
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1169 (delete-region (point-min) (point-max))))
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1170
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1171
48921
3aa5ba679145 Remove the concept of an instance. This means that a lot of functions have
Nick Roberts <nickrob@snap.net.nz>
parents: 48884
diff changeset
1172 ;; One trick is to have a command who's output is always available in a buffer
3aa5ba679145 Remove the concept of an instance. This means that a lot of functions have
Nick Roberts <nickrob@snap.net.nz>
parents: 48884
diff changeset
1173 ;; of it's own, and is always up to date. We build several buffers of this
3aa5ba679145 Remove the concept of an instance. This means that a lot of functions have
Nick Roberts <nickrob@snap.net.nz>
parents: 48884
diff changeset
1174 ;; type.
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1175 ;;
48921
3aa5ba679145 Remove the concept of an instance. This means that a lot of functions have
Nick Roberts <nickrob@snap.net.nz>
parents: 48884
diff changeset
1176 ;; There are two aspects to this: gdb has to tell us when the output for that
3aa5ba679145 Remove the concept of an instance. This means that a lot of functions have
Nick Roberts <nickrob@snap.net.nz>
parents: 48884
diff changeset
1177 ;; command might have changed, and we have to be able to run the command
3aa5ba679145 Remove the concept of an instance. This means that a lot of functions have
Nick Roberts <nickrob@snap.net.nz>
parents: 48884
diff changeset
1178 ;; behind the user's back.
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1179 ;;
48921
3aa5ba679145 Remove the concept of an instance. This means that a lot of functions have
Nick Roberts <nickrob@snap.net.nz>
parents: 48884
diff changeset
1180 ;; The idle input queue and the output phasing associated with the variable
3aa5ba679145 Remove the concept of an instance. This means that a lot of functions have
Nick Roberts <nickrob@snap.net.nz>
parents: 48884
diff changeset
1181 ;; gdb-output-sink help us to run commands behind the user's back.
48300
69646014abb3 Fix feature name in `require'.
Juanma Barranquero <lekktu@gmail.com>
parents: 48292
diff changeset
1182 ;;
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1183 ;; Below is the code for specificly managing buffers of output from one
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1184 ;; command.
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1185 ;;
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1186
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1187 ;; The trigger function is suitable for use in the assoc GDB-ANNOTATION-RULES
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1188 ;; It adds an idle input for the command we are tracking. It should be the
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1189 ;; annotation rule binding of whatever gdb sends to tell us this command
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1190 ;; might have changed it's output.
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1191 ;;
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1192 ;; NAME is the function name. DEMAND-PREDICATE tests if output is really needed.
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1193 ;; GDB-COMMAND is a string of such. OUTPUT-HANDLER is the function bound to the
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1194 ;; input in the input queue (see comment about ``gdb communications'' above).
48570
4934b8352621 (gdb-starting): Set gdb-running to t.
Nick Roberts <nickrob@snap.net.nz>
parents: 48515
diff changeset
1195
4934b8352621 (gdb-starting): Set gdb-running to t.
Nick Roberts <nickrob@snap.net.nz>
parents: 48515
diff changeset
1196 (defmacro def-gdb-auto-update-trigger (name demand-predicate gdb-command
4934b8352621 (gdb-starting): Set gdb-running to t.
Nick Roberts <nickrob@snap.net.nz>
parents: 48515
diff changeset
1197 output-handler)
48515
3216cd45d6d2 Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents: 48498
diff changeset
1198 `(defun ,name (&optional ignored)
3216cd45d6d2 Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents: 48498
diff changeset
1199 (if (and (,demand-predicate)
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1200 (not (member ',name
48921
3aa5ba679145 Remove the concept of an instance. This means that a lot of functions have
Nick Roberts <nickrob@snap.net.nz>
parents: 48884
diff changeset
1201 (gdb-get-pending-triggers))))
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1202 (progn
48921
3aa5ba679145 Remove the concept of an instance. This means that a lot of functions have
Nick Roberts <nickrob@snap.net.nz>
parents: 48884
diff changeset
1203 (gdb-enqueue-idle-input
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1204 (list ,gdb-command ',output-handler))
48921
3aa5ba679145 Remove the concept of an instance. This means that a lot of functions have
Nick Roberts <nickrob@snap.net.nz>
parents: 48884
diff changeset
1205 (gdb-set-pending-triggers
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1206 (cons ',name
48921
3aa5ba679145 Remove the concept of an instance. This means that a lot of functions have
Nick Roberts <nickrob@snap.net.nz>
parents: 48884
diff changeset
1207 (gdb-get-pending-triggers)))))))
48300
69646014abb3 Fix feature name in `require'.
Juanma Barranquero <lekktu@gmail.com>
parents: 48292
diff changeset
1208
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1209 (defmacro def-gdb-auto-update-handler (name trigger buf-key custom-defun)
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1210 `(defun ,name ()
48921
3aa5ba679145 Remove the concept of an instance. This means that a lot of functions have
Nick Roberts <nickrob@snap.net.nz>
parents: 48884
diff changeset
1211 (gdb-set-pending-triggers
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1212 (delq ',trigger
48921
3aa5ba679145 Remove the concept of an instance. This means that a lot of functions have
Nick Roberts <nickrob@snap.net.nz>
parents: 48884
diff changeset
1213 (gdb-get-pending-triggers)))
3aa5ba679145 Remove the concept of an instance. This means that a lot of functions have
Nick Roberts <nickrob@snap.net.nz>
parents: 48884
diff changeset
1214 (let ((buf (gdb-get-buffer ',buf-key)))
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1215 (and buf
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1216 (save-excursion
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1217 (set-buffer buf)
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1218 (let ((p (point))
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1219 (buffer-read-only nil))
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1220 (delete-region (point-min) (point-max))
48921
3aa5ba679145 Remove the concept of an instance. This means that a lot of functions have
Nick Roberts <nickrob@snap.net.nz>
parents: 48884
diff changeset
1221 (insert-buffer-substring (gdb-get-create-buffer
3aa5ba679145 Remove the concept of an instance. This means that a lot of functions have
Nick Roberts <nickrob@snap.net.nz>
parents: 48884
diff changeset
1222 'gdb-partial-output-buffer))
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1223 (goto-char p)))))
48641
da382393fb77 Get rid of (quote ..); use match-string and ignore.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48640
diff changeset
1224 ;; put customisation here
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1225 (,custom-defun)))
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1226
48641
da382393fb77 Get rid of (quote ..); use match-string and ignore.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48640
diff changeset
1227 (defmacro def-gdb-auto-updated-buffer (buffer-key trigger-name gdb-command
48921
3aa5ba679145 Remove the concept of an instance. This means that a lot of functions have
Nick Roberts <nickrob@snap.net.nz>
parents: 48884
diff changeset
1228 output-handler-name custom-defun)
3aa5ba679145 Remove the concept of an instance. This means that a lot of functions have
Nick Roberts <nickrob@snap.net.nz>
parents: 48884
diff changeset
1229 `(progn
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1230 (def-gdb-auto-update-trigger ,trigger-name
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1231 ;; The demand predicate:
48921
3aa5ba679145 Remove the concept of an instance. This means that a lot of functions have
Nick Roberts <nickrob@snap.net.nz>
parents: 48884
diff changeset
1232 (lambda () (gdb-get-buffer ',buffer-key))
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1233 ,gdb-command
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1234 ,output-handler-name)
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1235 (def-gdb-auto-update-handler ,output-handler-name
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1236 ,trigger-name ,buffer-key ,custom-defun)))
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1237
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1238
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1239 ;;
48955
1abfa35a3a5a (gdb-display-number-end): Make auto-display of
Nick Roberts <nickrob@snap.net.nz>
parents: 48921
diff changeset
1240 ;; Breakpoint buffer : This displays the output of `info breakpoints'.
48300
69646014abb3 Fix feature name in `require'.
Juanma Barranquero <lekktu@gmail.com>
parents: 48292
diff changeset
1241 ;;
48921
3aa5ba679145 Remove the concept of an instance. This means that a lot of functions have
Nick Roberts <nickrob@snap.net.nz>
parents: 48884
diff changeset
1242 (gdb-set-buffer-rules 'gdb-breakpoints-buffer
3aa5ba679145 Remove the concept of an instance. This means that a lot of functions have
Nick Roberts <nickrob@snap.net.nz>
parents: 48884
diff changeset
1243 'gdb-breakpoints-buffer-name
3aa5ba679145 Remove the concept of an instance. This means that a lot of functions have
Nick Roberts <nickrob@snap.net.nz>
parents: 48884
diff changeset
1244 'gdb-breakpoints-mode)
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1245
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1246 (def-gdb-auto-updated-buffer gdb-breakpoints-buffer
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1247 ;; This defines the auto update rule for buffers of type
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1248 ;; `gdb-breakpoints-buffer'.
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1249 ;;
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1250 ;; It defines a function to serve as the annotation handler that
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1251 ;; handles the `foo-invalidated' message. That function is called:
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1252 gdb-invalidate-breakpoints
48963
1bb53161a4b9 (gdb-info-display-custom): Ensure that frames/buffers
Nick Roberts <nickrob@snap.net.nz>
parents: 48955
diff changeset
1253 ;;
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1254 ;; To update the buffer, this command is sent to gdb.
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1255 "server info breakpoints\n"
48963
1bb53161a4b9 (gdb-info-display-custom): Ensure that frames/buffers
Nick Roberts <nickrob@snap.net.nz>
parents: 48955
diff changeset
1256 ;;
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1257 ;; This also defines a function to be the handler for the output
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1258 ;; from the command above. That function will copy the output into
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1259 ;; the appropriately typed buffer. That function will be called:
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1260 gdb-info-breakpoints-handler
48921
3aa5ba679145 Remove the concept of an instance. This means that a lot of functions have
Nick Roberts <nickrob@snap.net.nz>
parents: 48884
diff changeset
1261 ;; buffer specific functions
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1262 gdb-info-breakpoints-custom)
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1263
48515
3216cd45d6d2 Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents: 48498
diff changeset
1264 (defvar gdb-cdir nil "Compilation directory.")
48661
b092bff770ec Fold top-level `setq's and `define-key's into their corresponding defvar.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48659
diff changeset
1265 (defvar breakpoint-enabled-icon)
b092bff770ec Fold top-level `setq's and `define-key's into their corresponding defvar.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48659
diff changeset
1266 (defvar breakpoint-disabled-icon)
48515
3216cd45d6d2 Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents: 48498
diff changeset
1267
48662
d29870d63092 Fix up comment markers.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48661
diff changeset
1268 ;;-put breakpoint icons in relevant margins (even those set in the GUD buffer)
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1269 (defun gdb-info-breakpoints-custom ()
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1270 (let ((flag)(address))
48963
1bb53161a4b9 (gdb-info-display-custom): Ensure that frames/buffers
Nick Roberts <nickrob@snap.net.nz>
parents: 48955
diff changeset
1271 ;;
48659
4d69c0f01cc0 (gdb-inferior-io-mode-map): Remove (unused).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48641
diff changeset
1272 ;; remove all breakpoint-icons in source buffers but not assembler buffer
48955
1abfa35a3a5a (gdb-display-number-end): Make auto-display of
Nick Roberts <nickrob@snap.net.nz>
parents: 48921
diff changeset
1273 (dolist (buffer (buffer-list))
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1274 (save-excursion
48955
1abfa35a3a5a (gdb-display-number-end): Make auto-display of
Nick Roberts <nickrob@snap.net.nz>
parents: 48921
diff changeset
1275 (set-buffer buffer)
1abfa35a3a5a (gdb-display-number-end): Make auto-display of
Nick Roberts <nickrob@snap.net.nz>
parents: 48921
diff changeset
1276 (if (and (eq gud-minor-mode 'gdba)
1abfa35a3a5a (gdb-display-number-end): Make auto-display of
Nick Roberts <nickrob@snap.net.nz>
parents: 48921
diff changeset
1277 (not (string-match "^\*" (buffer-name))))
1abfa35a3a5a (gdb-display-number-end): Make auto-display of
Nick Roberts <nickrob@snap.net.nz>
parents: 48921
diff changeset
1278 (if (display-graphic-p)
1abfa35a3a5a (gdb-display-number-end): Make auto-display of
Nick Roberts <nickrob@snap.net.nz>
parents: 48921
diff changeset
1279 (remove-images (point-min) (point-max))
1abfa35a3a5a (gdb-display-number-end): Make auto-display of
Nick Roberts <nickrob@snap.net.nz>
parents: 48921
diff changeset
1280 (remove-strings (point-min) (point-max))))))
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1281 (save-excursion
48921
3aa5ba679145 Remove the concept of an instance. This means that a lot of functions have
Nick Roberts <nickrob@snap.net.nz>
parents: 48884
diff changeset
1282 (set-buffer (gdb-get-buffer 'gdb-breakpoints-buffer))
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1283 (save-excursion
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1284 (goto-char (point-min))
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1285 (while (< (point) (- (point-max) 1))
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1286 (forward-line 1)
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1287 (if (looking-at "[^\t].*breakpoint")
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1288 (progn
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1289 (looking-at "\\([0-9]*\\)\\s-*\\S-*\\s-*\\S-*\\s-*\\(.\\)")
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1290 (setq flag (char-after (match-beginning 2)))
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1291 (beginning-of-line)
48738
81dc78298a54 Remove inappropriate key-bindings.
Nick Roberts <nickrob@snap.net.nz>
parents: 48685
diff changeset
1292 (if (re-search-forward "in\\s-+\\S-+\\s-+at\\s-+" nil t)
81dc78298a54 Remove inappropriate key-bindings.
Nick Roberts <nickrob@snap.net.nz>
parents: 48685
diff changeset
1293 (progn
81dc78298a54 Remove inappropriate key-bindings.
Nick Roberts <nickrob@snap.net.nz>
parents: 48685
diff changeset
1294 (looking-at "\\(\\S-*\\):\\([0-9]+\\)")
49039
6c5f45b01d2e Acknowledge Tom Lord as author of gdba.el.
Nick Roberts <nickrob@snap.net.nz>
parents: 49000
diff changeset
1295 (let ((line (match-string 2)) (buffer-read-only nil)
48738
81dc78298a54 Remove inappropriate key-bindings.
Nick Roberts <nickrob@snap.net.nz>
parents: 48685
diff changeset
1296 (file (match-string 1)))
49039
6c5f45b01d2e Acknowledge Tom Lord as author of gdba.el.
Nick Roberts <nickrob@snap.net.nz>
parents: 49000
diff changeset
1297 (put-text-property (progn (beginning-of-line) (point))
6c5f45b01d2e Acknowledge Tom Lord as author of gdba.el.
Nick Roberts <nickrob@snap.net.nz>
parents: 49000
diff changeset
1298 (progn (end-of-line) (point))
6c5f45b01d2e Acknowledge Tom Lord as author of gdba.el.
Nick Roberts <nickrob@snap.net.nz>
parents: 49000
diff changeset
1299 'mouse-face 'highlight)
48738
81dc78298a54 Remove inappropriate key-bindings.
Nick Roberts <nickrob@snap.net.nz>
parents: 48685
diff changeset
1300 (save-excursion
81dc78298a54 Remove inappropriate key-bindings.
Nick Roberts <nickrob@snap.net.nz>
parents: 48685
diff changeset
1301 (set-buffer
81dc78298a54 Remove inappropriate key-bindings.
Nick Roberts <nickrob@snap.net.nz>
parents: 48685
diff changeset
1302 (find-file-noselect
81dc78298a54 Remove inappropriate key-bindings.
Nick Roberts <nickrob@snap.net.nz>
parents: 48685
diff changeset
1303 (if (file-exists-p file) file
81dc78298a54 Remove inappropriate key-bindings.
Nick Roberts <nickrob@snap.net.nz>
parents: 48685
diff changeset
1304 (expand-file-name file gdb-cdir))))
81dc78298a54 Remove inappropriate key-bindings.
Nick Roberts <nickrob@snap.net.nz>
parents: 48685
diff changeset
1305 (save-current-buffer
81dc78298a54 Remove inappropriate key-bindings.
Nick Roberts <nickrob@snap.net.nz>
parents: 48685
diff changeset
1306 (set (make-local-variable 'gud-minor-mode) 'gdba)
81dc78298a54 Remove inappropriate key-bindings.
Nick Roberts <nickrob@snap.net.nz>
parents: 48685
diff changeset
1307 (set (make-local-variable 'tool-bar-map)
81dc78298a54 Remove inappropriate key-bindings.
Nick Roberts <nickrob@snap.net.nz>
parents: 48685
diff changeset
1308 gud-tool-bar-map)
81dc78298a54 Remove inappropriate key-bindings.
Nick Roberts <nickrob@snap.net.nz>
parents: 48685
diff changeset
1309 (setq left-margin-width 2)
81dc78298a54 Remove inappropriate key-bindings.
Nick Roberts <nickrob@snap.net.nz>
parents: 48685
diff changeset
1310 (if (get-buffer-window (current-buffer))
81dc78298a54 Remove inappropriate key-bindings.
Nick Roberts <nickrob@snap.net.nz>
parents: 48685
diff changeset
1311 (set-window-margins (get-buffer-window
81dc78298a54 Remove inappropriate key-bindings.
Nick Roberts <nickrob@snap.net.nz>
parents: 48685
diff changeset
1312 (current-buffer))
81dc78298a54 Remove inappropriate key-bindings.
Nick Roberts <nickrob@snap.net.nz>
parents: 48685
diff changeset
1313 left-margin-width
81dc78298a54 Remove inappropriate key-bindings.
Nick Roberts <nickrob@snap.net.nz>
parents: 48685
diff changeset
1314 right-margin-width)))
81dc78298a54 Remove inappropriate key-bindings.
Nick Roberts <nickrob@snap.net.nz>
parents: 48685
diff changeset
1315 ;; only want one breakpoint icon at each location
81dc78298a54 Remove inappropriate key-bindings.
Nick Roberts <nickrob@snap.net.nz>
parents: 48685
diff changeset
1316 (save-excursion
81dc78298a54 Remove inappropriate key-bindings.
Nick Roberts <nickrob@snap.net.nz>
parents: 48685
diff changeset
1317 (goto-line (string-to-number line))
81dc78298a54 Remove inappropriate key-bindings.
Nick Roberts <nickrob@snap.net.nz>
parents: 48685
diff changeset
1318 (let ((start (progn (beginning-of-line)
81dc78298a54 Remove inappropriate key-bindings.
Nick Roberts <nickrob@snap.net.nz>
parents: 48685
diff changeset
1319 (- (point) 1)))
81dc78298a54 Remove inappropriate key-bindings.
Nick Roberts <nickrob@snap.net.nz>
parents: 48685
diff changeset
1320 (end (progn (end-of-line) (+ (point) 1))))
81dc78298a54 Remove inappropriate key-bindings.
Nick Roberts <nickrob@snap.net.nz>
parents: 48685
diff changeset
1321 (if (display-graphic-p)
81dc78298a54 Remove inappropriate key-bindings.
Nick Roberts <nickrob@snap.net.nz>
parents: 48685
diff changeset
1322 (progn
81dc78298a54 Remove inappropriate key-bindings.
Nick Roberts <nickrob@snap.net.nz>
parents: 48685
diff changeset
1323 (remove-images start end)
81dc78298a54 Remove inappropriate key-bindings.
Nick Roberts <nickrob@snap.net.nz>
parents: 48685
diff changeset
1324 (if (eq ?y flag)
81dc78298a54 Remove inappropriate key-bindings.
Nick Roberts <nickrob@snap.net.nz>
parents: 48685
diff changeset
1325 (put-image breakpoint-enabled-icon
81dc78298a54 Remove inappropriate key-bindings.
Nick Roberts <nickrob@snap.net.nz>
parents: 48685
diff changeset
1326 (point)
81dc78298a54 Remove inappropriate key-bindings.
Nick Roberts <nickrob@snap.net.nz>
parents: 48685
diff changeset
1327 "breakpoint icon enabled"
81dc78298a54 Remove inappropriate key-bindings.
Nick Roberts <nickrob@snap.net.nz>
parents: 48685
diff changeset
1328 'left-margin)
81dc78298a54 Remove inappropriate key-bindings.
Nick Roberts <nickrob@snap.net.nz>
parents: 48685
diff changeset
1329 (put-image breakpoint-disabled-icon (point)
81dc78298a54 Remove inappropriate key-bindings.
Nick Roberts <nickrob@snap.net.nz>
parents: 48685
diff changeset
1330 "breakpoint icon disabled"
81dc78298a54 Remove inappropriate key-bindings.
Nick Roberts <nickrob@snap.net.nz>
parents: 48685
diff changeset
1331 'left-margin)))
81dc78298a54 Remove inappropriate key-bindings.
Nick Roberts <nickrob@snap.net.nz>
parents: 48685
diff changeset
1332 (remove-strings start end)
81dc78298a54 Remove inappropriate key-bindings.
Nick Roberts <nickrob@snap.net.nz>
parents: 48685
diff changeset
1333 (if (eq ?y flag)
81dc78298a54 Remove inappropriate key-bindings.
Nick Roberts <nickrob@snap.net.nz>
parents: 48685
diff changeset
1334 (put-string "B" (point) "enabled"
81dc78298a54 Remove inappropriate key-bindings.
Nick Roberts <nickrob@snap.net.nz>
parents: 48685
diff changeset
1335 'left-margin)
81dc78298a54 Remove inappropriate key-bindings.
Nick Roberts <nickrob@snap.net.nz>
parents: 48685
diff changeset
1336 (put-string "b" (point) "disabled"
81dc78298a54 Remove inappropriate key-bindings.
Nick Roberts <nickrob@snap.net.nz>
parents: 48685
diff changeset
1337 'left-margin)))))))))))
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1338 (end-of-line))))))
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1339
48515
3216cd45d6d2 Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents: 48498
diff changeset
1340 (defun gdb-breakpoints-buffer-name ()
48685
19bf840bede8 Replace uses of (gdb-get-instance-buffer 'gdba) and
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48682
diff changeset
1341 (with-current-buffer gud-comint-buffer
48921
3aa5ba679145 Remove the concept of an instance. This means that a lot of functions have
Nick Roberts <nickrob@snap.net.nz>
parents: 48884
diff changeset
1342 (concat "*breakpoints of " (gdb-get-target-string) "*")))
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1343
48515
3216cd45d6d2 Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents: 48498
diff changeset
1344 (defun gdb-display-breakpoints-buffer ()
48659
4d69c0f01cc0 (gdb-inferior-io-mode-map): Remove (unused).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48641
diff changeset
1345 (interactive)
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1346 (gdb-display-buffer
48921
3aa5ba679145 Remove the concept of an instance. This means that a lot of functions have
Nick Roberts <nickrob@snap.net.nz>
parents: 48884
diff changeset
1347 (gdb-get-create-buffer 'gdb-breakpoints-buffer)))
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1348
48515
3216cd45d6d2 Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents: 48498
diff changeset
1349 (defun gdb-frame-breakpoints-buffer ()
48659
4d69c0f01cc0 (gdb-inferior-io-mode-map): Remove (unused).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48641
diff changeset
1350 (interactive)
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1351 (switch-to-buffer-other-frame
48921
3aa5ba679145 Remove the concept of an instance. This means that a lot of functions have
Nick Roberts <nickrob@snap.net.nz>
parents: 48884
diff changeset
1352 (gdb-get-create-buffer 'gdb-breakpoints-buffer)))
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1353
48661
b092bff770ec Fold top-level `setq's and `define-key's into their corresponding defvar.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48659
diff changeset
1354 (defvar gdb-breakpoints-mode-map
b092bff770ec Fold top-level `setq's and `define-key's into their corresponding defvar.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48659
diff changeset
1355 (let ((map (make-sparse-keymap))
b092bff770ec Fold top-level `setq's and `define-key's into their corresponding defvar.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48659
diff changeset
1356 (menu (make-sparse-keymap "Breakpoints")))
49000
f3c5848184cb (gdb-delete-display): Rename (gdb-delete-expression).
Nick Roberts <nickrob@snap.net.nz>
parents: 48963
diff changeset
1357 (define-key menu [toggle] '("Toggle" . gdb-toggle-breakpoint))
f3c5848184cb (gdb-delete-display): Rename (gdb-delete-expression).
Nick Roberts <nickrob@snap.net.nz>
parents: 48963
diff changeset
1358 (define-key menu [delete] '("Delete" . gdb-delete-breakpoint))
f3c5848184cb (gdb-delete-display): Rename (gdb-delete-expression).
Nick Roberts <nickrob@snap.net.nz>
parents: 48963
diff changeset
1359 (define-key menu [goto] '("Goto" . gdb-goto-breakpoint))
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1360
48661
b092bff770ec Fold top-level `setq's and `define-key's into their corresponding defvar.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48659
diff changeset
1361 (suppress-keymap map)
b092bff770ec Fold top-level `setq's and `define-key's into their corresponding defvar.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48659
diff changeset
1362 (define-key map [menu-bar breakpoints] (cons "Breakpoints" menu))
49000
f3c5848184cb (gdb-delete-display): Rename (gdb-delete-expression).
Nick Roberts <nickrob@snap.net.nz>
parents: 48963
diff changeset
1363 (define-key map " " 'gdb-toggle-breakpoint)
f3c5848184cb (gdb-delete-display): Rename (gdb-delete-expression).
Nick Roberts <nickrob@snap.net.nz>
parents: 48963
diff changeset
1364 (define-key map "d" 'gdb-delete-breakpoint)
f3c5848184cb (gdb-delete-display): Rename (gdb-delete-expression).
Nick Roberts <nickrob@snap.net.nz>
parents: 48963
diff changeset
1365 (define-key map "\r" 'gdb-goto-breakpoint)
f3c5848184cb (gdb-delete-display): Rename (gdb-delete-expression).
Nick Roberts <nickrob@snap.net.nz>
parents: 48963
diff changeset
1366 (define-key map [mouse-2] 'gdb-mouse-goto-breakpoint)
48661
b092bff770ec Fold top-level `setq's and `define-key's into their corresponding defvar.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48659
diff changeset
1367 map))
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1368
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1369 (defun gdb-breakpoints-mode ()
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1370 "Major mode for gdb breakpoints.
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1371
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1372 \\{gdb-breakpoints-mode-map}"
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1373 (setq major-mode 'gdb-breakpoints-mode)
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1374 (setq mode-name "Breakpoints")
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1375 (use-local-map gdb-breakpoints-mode-map)
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1376 (setq buffer-read-only t)
48515
3216cd45d6d2 Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents: 48498
diff changeset
1377 (gdb-invalidate-breakpoints))
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1378
49000
f3c5848184cb (gdb-delete-display): Rename (gdb-delete-expression).
Nick Roberts <nickrob@snap.net.nz>
parents: 48963
diff changeset
1379 (defun gdb-toggle-breakpoint ()
f3c5848184cb (gdb-delete-display): Rename (gdb-delete-expression).
Nick Roberts <nickrob@snap.net.nz>
parents: 48963
diff changeset
1380 "Enable/disable the breakpoint at current line."
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1381 (interactive)
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1382 (save-excursion
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1383 (beginning-of-line 1)
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1384 (if (not (looking-at "\\([0-9]+\\).*point\\s-*\\S-*\\s-*\\(.\\)"))
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1385 (error "Not recognized as break/watchpoint line")
48921
3aa5ba679145 Remove the concept of an instance. This means that a lot of functions have
Nick Roberts <nickrob@snap.net.nz>
parents: 48884
diff changeset
1386 (gdb-enqueue-input
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1387 (list
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1388 (concat
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1389 (if (eq ?y (char-after (match-beginning 2)))
48963
1bb53161a4b9 (gdb-info-display-custom): Ensure that frames/buffers
Nick Roberts <nickrob@snap.net.nz>
parents: 48955
diff changeset
1390 "server disable "
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1391 "server enable ")
48963
1bb53161a4b9 (gdb-info-display-custom): Ensure that frames/buffers
Nick Roberts <nickrob@snap.net.nz>
parents: 48955
diff changeset
1392 (match-string 1) "\n")
48641
da382393fb77 Get rid of (quote ..); use match-string and ignore.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48640
diff changeset
1393 'ignore)))))
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1394
49000
f3c5848184cb (gdb-delete-display): Rename (gdb-delete-expression).
Nick Roberts <nickrob@snap.net.nz>
parents: 48963
diff changeset
1395 (defun gdb-delete-breakpoint ()
f3c5848184cb (gdb-delete-display): Rename (gdb-delete-expression).
Nick Roberts <nickrob@snap.net.nz>
parents: 48963
diff changeset
1396 "Delete the breakpoint at current line."
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1397 (interactive)
48921
3aa5ba679145 Remove the concept of an instance. This means that a lot of functions have
Nick Roberts <nickrob@snap.net.nz>
parents: 48884
diff changeset
1398 (beginning-of-line 1)
3aa5ba679145 Remove the concept of an instance. This means that a lot of functions have
Nick Roberts <nickrob@snap.net.nz>
parents: 48884
diff changeset
1399 (if (not (looking-at "\\([0-9]+\\).*point\\s-*\\S-*\\s-*\\(.\\)"))
3aa5ba679145 Remove the concept of an instance. This means that a lot of functions have
Nick Roberts <nickrob@snap.net.nz>
parents: 48884
diff changeset
1400 (error "Not recognized as break/watchpoint line")
3aa5ba679145 Remove the concept of an instance. This means that a lot of functions have
Nick Roberts <nickrob@snap.net.nz>
parents: 48884
diff changeset
1401 (gdb-enqueue-input
3aa5ba679145 Remove the concept of an instance. This means that a lot of functions have
Nick Roberts <nickrob@snap.net.nz>
parents: 48884
diff changeset
1402 (list (concat "server delete " (match-string 1) "\n") 'ignore))))
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1403
48515
3216cd45d6d2 Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents: 48498
diff changeset
1404 (defvar gdb-source-window nil)
3216cd45d6d2 Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents: 48498
diff changeset
1405
49000
f3c5848184cb (gdb-delete-display): Rename (gdb-delete-expression).
Nick Roberts <nickrob@snap.net.nz>
parents: 48963
diff changeset
1406 (defun gdb-goto-breakpoint ()
f3c5848184cb (gdb-delete-display): Rename (gdb-delete-expression).
Nick Roberts <nickrob@snap.net.nz>
parents: 48963
diff changeset
1407 "Display the file in the source buffer at the breakpoint specified on the
f3c5848184cb (gdb-delete-display): Rename (gdb-delete-expression).
Nick Roberts <nickrob@snap.net.nz>
parents: 48963
diff changeset
1408 current line."
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1409 (interactive)
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1410 (save-excursion
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1411 (beginning-of-line 1)
48738
81dc78298a54 Remove inappropriate key-bindings.
Nick Roberts <nickrob@snap.net.nz>
parents: 48685
diff changeset
1412 (re-search-forward "in\\s-+\\S-+\\s-+at\\s-+" nil t)
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1413 (looking-at "\\(\\S-*\\):\\([0-9]+\\)"))
48738
81dc78298a54 Remove inappropriate key-bindings.
Nick Roberts <nickrob@snap.net.nz>
parents: 48685
diff changeset
1414 (if (match-string 2)
81dc78298a54 Remove inappropriate key-bindings.
Nick Roberts <nickrob@snap.net.nz>
parents: 48685
diff changeset
1415 (let ((line (match-string 2))
81dc78298a54 Remove inappropriate key-bindings.
Nick Roberts <nickrob@snap.net.nz>
parents: 48685
diff changeset
1416 (file (match-string 1)))
81dc78298a54 Remove inappropriate key-bindings.
Nick Roberts <nickrob@snap.net.nz>
parents: 48685
diff changeset
1417 (save-selected-window
81dc78298a54 Remove inappropriate key-bindings.
Nick Roberts <nickrob@snap.net.nz>
parents: 48685
diff changeset
1418 (select-window gdb-source-window)
81dc78298a54 Remove inappropriate key-bindings.
Nick Roberts <nickrob@snap.net.nz>
parents: 48685
diff changeset
1419 (switch-to-buffer (find-file-noselect
81dc78298a54 Remove inappropriate key-bindings.
Nick Roberts <nickrob@snap.net.nz>
parents: 48685
diff changeset
1420 (if (file-exists-p file)
81dc78298a54 Remove inappropriate key-bindings.
Nick Roberts <nickrob@snap.net.nz>
parents: 48685
diff changeset
1421 file
81dc78298a54 Remove inappropriate key-bindings.
Nick Roberts <nickrob@snap.net.nz>
parents: 48685
diff changeset
1422 (expand-file-name file gdb-cdir))))
81dc78298a54 Remove inappropriate key-bindings.
Nick Roberts <nickrob@snap.net.nz>
parents: 48685
diff changeset
1423 (goto-line (string-to-number line))))))
49000
f3c5848184cb (gdb-delete-display): Rename (gdb-delete-expression).
Nick Roberts <nickrob@snap.net.nz>
parents: 48963
diff changeset
1424
f3c5848184cb (gdb-delete-display): Rename (gdb-delete-expression).
Nick Roberts <nickrob@snap.net.nz>
parents: 48963
diff changeset
1425 (defun gdb-mouse-goto-breakpoint (event)
f3c5848184cb (gdb-delete-display): Rename (gdb-delete-expression).
Nick Roberts <nickrob@snap.net.nz>
parents: 48963
diff changeset
1426 "Display the file in the source buffer at the selected breakpoint."
f3c5848184cb (gdb-delete-display): Rename (gdb-delete-expression).
Nick Roberts <nickrob@snap.net.nz>
parents: 48963
diff changeset
1427 (interactive "e")
f3c5848184cb (gdb-delete-display): Rename (gdb-delete-expression).
Nick Roberts <nickrob@snap.net.nz>
parents: 48963
diff changeset
1428 (mouse-set-point event)
f3c5848184cb (gdb-delete-display): Rename (gdb-delete-expression).
Nick Roberts <nickrob@snap.net.nz>
parents: 48963
diff changeset
1429 (gdb-goto-breakpoint))
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1430
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1431 ;;
48955
1abfa35a3a5a (gdb-display-number-end): Make auto-display of
Nick Roberts <nickrob@snap.net.nz>
parents: 48921
diff changeset
1432 ;; Frames buffer. This displays a perpetually correct bactracktrace
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1433 ;; (from the command `where').
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1434 ;;
48955
1abfa35a3a5a (gdb-display-number-end): Make auto-display of
Nick Roberts <nickrob@snap.net.nz>
parents: 48921
diff changeset
1435 ;; Alas, if your stack is deep, it is costly.
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1436 ;;
48921
3aa5ba679145 Remove the concept of an instance. This means that a lot of functions have
Nick Roberts <nickrob@snap.net.nz>
parents: 48884
diff changeset
1437 (gdb-set-buffer-rules 'gdb-stack-buffer
3aa5ba679145 Remove the concept of an instance. This means that a lot of functions have
Nick Roberts <nickrob@snap.net.nz>
parents: 48884
diff changeset
1438 'gdb-stack-buffer-name
3aa5ba679145 Remove the concept of an instance. This means that a lot of functions have
Nick Roberts <nickrob@snap.net.nz>
parents: 48884
diff changeset
1439 'gdb-frames-mode)
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1440
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1441 (def-gdb-auto-updated-buffer gdb-stack-buffer
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1442 gdb-invalidate-frames
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1443 "server where\n"
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1444 gdb-info-frames-handler
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1445 gdb-info-frames-custom)
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1446
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1447 (defun gdb-info-frames-custom ()
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1448 (save-excursion
48921
3aa5ba679145 Remove the concept of an instance. This means that a lot of functions have
Nick Roberts <nickrob@snap.net.nz>
parents: 48884
diff changeset
1449 (set-buffer (gdb-get-buffer 'gdb-stack-buffer))
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1450 (let ((buffer-read-only nil))
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1451 (goto-char (point-min))
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1452 (while (< (point) (point-max))
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1453 (put-text-property (progn (beginning-of-line) (point))
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1454 (progn (end-of-line) (point))
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1455 'mouse-face 'highlight)
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1456 (forward-line 1)))))
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1457
48515
3216cd45d6d2 Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents: 48498
diff changeset
1458 (defun gdb-stack-buffer-name ()
48685
19bf840bede8 Replace uses of (gdb-get-instance-buffer 'gdba) and
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48682
diff changeset
1459 (with-current-buffer gud-comint-buffer
48963
1bb53161a4b9 (gdb-info-display-custom): Ensure that frames/buffers
Nick Roberts <nickrob@snap.net.nz>
parents: 48955
diff changeset
1460 (concat "*stack frames of " (gdb-get-target-string) "*")))
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1461
48515
3216cd45d6d2 Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents: 48498
diff changeset
1462 (defun gdb-display-stack-buffer ()
48659
4d69c0f01cc0 (gdb-inferior-io-mode-map): Remove (unused).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48641
diff changeset
1463 (interactive)
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1464 (gdb-display-buffer
48921
3aa5ba679145 Remove the concept of an instance. This means that a lot of functions have
Nick Roberts <nickrob@snap.net.nz>
parents: 48884
diff changeset
1465 (gdb-get-create-buffer 'gdb-stack-buffer)))
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1466
48515
3216cd45d6d2 Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents: 48498
diff changeset
1467 (defun gdb-frame-stack-buffer ()
48659
4d69c0f01cc0 (gdb-inferior-io-mode-map): Remove (unused).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48641
diff changeset
1468 (interactive)
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1469 (switch-to-buffer-other-frame
48921
3aa5ba679145 Remove the concept of an instance. This means that a lot of functions have
Nick Roberts <nickrob@snap.net.nz>
parents: 48884
diff changeset
1470 (gdb-get-create-buffer 'gdb-stack-buffer)))
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1471
48661
b092bff770ec Fold top-level `setq's and `define-key's into their corresponding defvar.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48659
diff changeset
1472 (defvar gdb-frames-mode-map
b092bff770ec Fold top-level `setq's and `define-key's into their corresponding defvar.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48659
diff changeset
1473 (let ((map (make-sparse-keymap)))
b092bff770ec Fold top-level `setq's and `define-key's into their corresponding defvar.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48659
diff changeset
1474 (suppress-keymap map)
49000
f3c5848184cb (gdb-delete-display): Rename (gdb-delete-expression).
Nick Roberts <nickrob@snap.net.nz>
parents: 48963
diff changeset
1475 (define-key map "\r" 'gdb-frames-select)
48738
81dc78298a54 Remove inappropriate key-bindings.
Nick Roberts <nickrob@snap.net.nz>
parents: 48685
diff changeset
1476 (define-key map [mouse-2] 'gdb-frames-mouse-select)
48661
b092bff770ec Fold top-level `setq's and `define-key's into their corresponding defvar.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48659
diff changeset
1477 map))
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1478
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1479 (defun gdb-frames-mode ()
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1480 "Major mode for gdb frames.
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1481
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1482 \\{gdb-frames-mode-map}"
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1483 (setq major-mode 'gdb-frames-mode)
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1484 (setq mode-name "Frames")
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1485 (setq buffer-read-only t)
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1486 (use-local-map gdb-frames-mode-map)
48515
3216cd45d6d2 Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents: 48498
diff changeset
1487 (gdb-invalidate-frames))
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1488
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1489 (defun gdb-get-frame-number ()
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1490 (save-excursion
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1491 (let* ((pos (re-search-backward "^#\\([0-9]*\\)" nil t))
49000
f3c5848184cb (gdb-delete-display): Rename (gdb-delete-expression).
Nick Roberts <nickrob@snap.net.nz>
parents: 48963
diff changeset
1492 (n (or (and pos (match-string-no-properties 1)) "0")))
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1493 n)))
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1494
49000
f3c5848184cb (gdb-delete-display): Rename (gdb-delete-expression).
Nick Roberts <nickrob@snap.net.nz>
parents: 48963
diff changeset
1495 (defun gdb-frames-select ()
f3c5848184cb (gdb-delete-display): Rename (gdb-delete-expression).
Nick Roberts <nickrob@snap.net.nz>
parents: 48963
diff changeset
1496 "Make the frame on the current line become the current frame and display the
f3c5848184cb (gdb-delete-display): Rename (gdb-delete-expression).
Nick Roberts <nickrob@snap.net.nz>
parents: 48963
diff changeset
1497 source in the source buffer."
f3c5848184cb (gdb-delete-display): Rename (gdb-delete-expression).
Nick Roberts <nickrob@snap.net.nz>
parents: 48963
diff changeset
1498 (interactive)
f3c5848184cb (gdb-delete-display): Rename (gdb-delete-expression).
Nick Roberts <nickrob@snap.net.nz>
parents: 48963
diff changeset
1499 (gdb-enqueue-input
f3c5848184cb (gdb-delete-display): Rename (gdb-delete-expression).
Nick Roberts <nickrob@snap.net.nz>
parents: 48963
diff changeset
1500 (list (concat "server frame " (gdb-get-frame-number) "\n") 'ignore))
f3c5848184cb (gdb-delete-display): Rename (gdb-delete-expression).
Nick Roberts <nickrob@snap.net.nz>
parents: 48963
diff changeset
1501 (gud-display-frame))
f3c5848184cb (gdb-delete-display): Rename (gdb-delete-expression).
Nick Roberts <nickrob@snap.net.nz>
parents: 48963
diff changeset
1502
f3c5848184cb (gdb-delete-display): Rename (gdb-delete-expression).
Nick Roberts <nickrob@snap.net.nz>
parents: 48963
diff changeset
1503 (defun gdb-frames-mouse-select (event)
f3c5848184cb (gdb-delete-display): Rename (gdb-delete-expression).
Nick Roberts <nickrob@snap.net.nz>
parents: 48963
diff changeset
1504 "Make the selected frame become the current frame and display the source in
f3c5848184cb (gdb-delete-display): Rename (gdb-delete-expression).
Nick Roberts <nickrob@snap.net.nz>
parents: 48963
diff changeset
1505 the source buffer."
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1506 (interactive "e")
49000
f3c5848184cb (gdb-delete-display): Rename (gdb-delete-expression).
Nick Roberts <nickrob@snap.net.nz>
parents: 48963
diff changeset
1507 (mouse-set-point event)
f3c5848184cb (gdb-delete-display): Rename (gdb-delete-expression).
Nick Roberts <nickrob@snap.net.nz>
parents: 48963
diff changeset
1508 (gdb-frames-select))
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1509
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1510 ;;
48955
1abfa35a3a5a (gdb-display-number-end): Make auto-display of
Nick Roberts <nickrob@snap.net.nz>
parents: 48921
diff changeset
1511 ;; Registers buffer.
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1512 ;;
48955
1abfa35a3a5a (gdb-display-number-end): Make auto-display of
Nick Roberts <nickrob@snap.net.nz>
parents: 48921
diff changeset
1513 (gdb-set-buffer-rules 'gdb-registers-buffer
1abfa35a3a5a (gdb-display-number-end): Make auto-display of
Nick Roberts <nickrob@snap.net.nz>
parents: 48921
diff changeset
1514 'gdb-registers-buffer-name
1abfa35a3a5a (gdb-display-number-end): Make auto-display of
Nick Roberts <nickrob@snap.net.nz>
parents: 48921
diff changeset
1515 'gdb-registers-mode)
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1516
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1517 (def-gdb-auto-updated-buffer gdb-registers-buffer
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1518 gdb-invalidate-registers
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1519 "server info registers\n"
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1520 gdb-info-registers-handler
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1521 gdb-info-registers-custom)
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1522
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1523 (defun gdb-info-registers-custom ())
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1524
48661
b092bff770ec Fold top-level `setq's and `define-key's into their corresponding defvar.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48659
diff changeset
1525 (defvar gdb-registers-mode-map
b092bff770ec Fold top-level `setq's and `define-key's into their corresponding defvar.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48659
diff changeset
1526 (let ((map (make-sparse-keymap)))
b092bff770ec Fold top-level `setq's and `define-key's into their corresponding defvar.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48659
diff changeset
1527 (suppress-keymap map)
b092bff770ec Fold top-level `setq's and `define-key's into their corresponding defvar.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48659
diff changeset
1528 map))
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1529
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1530 (defun gdb-registers-mode ()
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1531 "Major mode for gdb registers.
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1532
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1533 \\{gdb-registers-mode-map}"
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1534 (setq major-mode 'gdb-registers-mode)
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1535 (setq mode-name "Registers")
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1536 (setq buffer-read-only t)
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1537 (use-local-map gdb-registers-mode-map)
48515
3216cd45d6d2 Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents: 48498
diff changeset
1538 (gdb-invalidate-registers))
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1539
48515
3216cd45d6d2 Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents: 48498
diff changeset
1540 (defun gdb-registers-buffer-name ()
48685
19bf840bede8 Replace uses of (gdb-get-instance-buffer 'gdba) and
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48682
diff changeset
1541 (with-current-buffer gud-comint-buffer
48921
3aa5ba679145 Remove the concept of an instance. This means that a lot of functions have
Nick Roberts <nickrob@snap.net.nz>
parents: 48884
diff changeset
1542 (concat "*registers of " (gdb-get-target-string) "*")))
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1543
48515
3216cd45d6d2 Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents: 48498
diff changeset
1544 (defun gdb-display-registers-buffer ()
48659
4d69c0f01cc0 (gdb-inferior-io-mode-map): Remove (unused).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48641
diff changeset
1545 (interactive)
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1546 (gdb-display-buffer
48921
3aa5ba679145 Remove the concept of an instance. This means that a lot of functions have
Nick Roberts <nickrob@snap.net.nz>
parents: 48884
diff changeset
1547 (gdb-get-create-buffer 'gdb-registers-buffer)))
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1548
48515
3216cd45d6d2 Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents: 48498
diff changeset
1549 (defun gdb-frame-registers-buffer ()
48659
4d69c0f01cc0 (gdb-inferior-io-mode-map): Remove (unused).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48641
diff changeset
1550 (interactive)
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1551 (switch-to-buffer-other-frame
48921
3aa5ba679145 Remove the concept of an instance. This means that a lot of functions have
Nick Roberts <nickrob@snap.net.nz>
parents: 48884
diff changeset
1552 (gdb-get-create-buffer 'gdb-registers-buffer)))
48955
1abfa35a3a5a (gdb-display-number-end): Make auto-display of
Nick Roberts <nickrob@snap.net.nz>
parents: 48921
diff changeset
1553
1abfa35a3a5a (gdb-display-number-end): Make auto-display of
Nick Roberts <nickrob@snap.net.nz>
parents: 48921
diff changeset
1554 ;;
1abfa35a3a5a (gdb-display-number-end): Make auto-display of
Nick Roberts <nickrob@snap.net.nz>
parents: 48921
diff changeset
1555 ;; Locals buffer.
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1556 ;;
48955
1abfa35a3a5a (gdb-display-number-end): Make auto-display of
Nick Roberts <nickrob@snap.net.nz>
parents: 48921
diff changeset
1557 (gdb-set-buffer-rules 'gdb-locals-buffer
1abfa35a3a5a (gdb-display-number-end): Make auto-display of
Nick Roberts <nickrob@snap.net.nz>
parents: 48921
diff changeset
1558 'gdb-locals-buffer-name
1abfa35a3a5a (gdb-display-number-end): Make auto-display of
Nick Roberts <nickrob@snap.net.nz>
parents: 48921
diff changeset
1559 'gdb-locals-mode)
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1560
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1561 (def-gdb-auto-updated-buffer gdb-locals-buffer
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1562 gdb-invalidate-locals
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1563 "server info locals\n"
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1564 gdb-info-locals-handler
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1565 gdb-info-locals-custom)
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1566
48963
1bb53161a4b9 (gdb-info-display-custom): Ensure that frames/buffers
Nick Roberts <nickrob@snap.net.nz>
parents: 48955
diff changeset
1567 ;; Abbreviate for arrays and structures.
1bb53161a4b9 (gdb-info-display-custom): Ensure that frames/buffers
Nick Roberts <nickrob@snap.net.nz>
parents: 48955
diff changeset
1568 ;; These can be expanded using gud-display.
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1569 (defun gdb-info-locals-handler nil
48921
3aa5ba679145 Remove the concept of an instance. This means that a lot of functions have
Nick Roberts <nickrob@snap.net.nz>
parents: 48884
diff changeset
1570 (gdb-set-pending-triggers (delq 'gdb-invalidate-locals
3aa5ba679145 Remove the concept of an instance. This means that a lot of functions have
Nick Roberts <nickrob@snap.net.nz>
parents: 48884
diff changeset
1571 (gdb-get-pending-triggers)))
3aa5ba679145 Remove the concept of an instance. This means that a lot of functions have
Nick Roberts <nickrob@snap.net.nz>
parents: 48884
diff changeset
1572 (let ((buf (gdb-get-buffer 'gdb-partial-output-buffer)))
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1573 (save-excursion
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1574 (set-buffer buf)
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1575 (goto-char (point-min))
48685
19bf840bede8 Replace uses of (gdb-get-instance-buffer 'gdba) and
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48682
diff changeset
1576 (while (re-search-forward "^ .*\n" nil t)
19bf840bede8 Replace uses of (gdb-get-instance-buffer 'gdba) and
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48682
diff changeset
1577 (replace-match "" nil nil))
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1578 (goto-char (point-min))
48685
19bf840bede8 Replace uses of (gdb-get-instance-buffer 'gdba) and
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48682
diff changeset
1579 (while (re-search-forward "{[-0-9, {}\]*\n" nil t)
19bf840bede8 Replace uses of (gdb-get-instance-buffer 'gdba) and
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48682
diff changeset
1580 (replace-match "(array);\n" nil nil))
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1581 (goto-char (point-min))
48685
19bf840bede8 Replace uses of (gdb-get-instance-buffer 'gdba) and
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48682
diff changeset
1582 (while (re-search-forward "{.*=.*\n" nil t)
19bf840bede8 Replace uses of (gdb-get-instance-buffer 'gdba) and
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48682
diff changeset
1583 (replace-match "(structure);\n" nil nil))))
48921
3aa5ba679145 Remove the concept of an instance. This means that a lot of functions have
Nick Roberts <nickrob@snap.net.nz>
parents: 48884
diff changeset
1584 (let ((buf (gdb-get-buffer 'gdb-locals-buffer)))
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1585 (and buf (save-excursion
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1586 (set-buffer buf)
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1587 (let ((p (point))
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1588 (buffer-read-only nil))
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1589 (delete-region (point-min) (point-max))
48921
3aa5ba679145 Remove the concept of an instance. This means that a lot of functions have
Nick Roberts <nickrob@snap.net.nz>
parents: 48884
diff changeset
1590 (insert-buffer-substring (gdb-get-create-buffer
3aa5ba679145 Remove the concept of an instance. This means that a lot of functions have
Nick Roberts <nickrob@snap.net.nz>
parents: 48884
diff changeset
1591 'gdb-partial-output-buffer))
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1592 (goto-char p)))))
48641
da382393fb77 Get rid of (quote ..); use match-string and ignore.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48640
diff changeset
1593 (run-hooks 'gdb-info-locals-hook))
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1594
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1595 (defun gdb-info-locals-custom ()
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1596 nil)
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1597
48661
b092bff770ec Fold top-level `setq's and `define-key's into their corresponding defvar.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48659
diff changeset
1598 (defvar gdb-locals-mode-map
b092bff770ec Fold top-level `setq's and `define-key's into their corresponding defvar.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48659
diff changeset
1599 (let ((map (make-sparse-keymap)))
b092bff770ec Fold top-level `setq's and `define-key's into their corresponding defvar.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48659
diff changeset
1600 (suppress-keymap map)
b092bff770ec Fold top-level `setq's and `define-key's into their corresponding defvar.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48659
diff changeset
1601 map))
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1602
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1603 (defun gdb-locals-mode ()
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1604 "Major mode for gdb locals.
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1605
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1606 \\{gdb-locals-mode-map}"
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1607 (setq major-mode 'gdb-locals-mode)
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1608 (setq mode-name "Locals")
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1609 (setq buffer-read-only t)
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1610 (use-local-map gdb-locals-mode-map)
48515
3216cd45d6d2 Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents: 48498
diff changeset
1611 (gdb-invalidate-locals))
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1612
48515
3216cd45d6d2 Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents: 48498
diff changeset
1613 (defun gdb-locals-buffer-name ()
48685
19bf840bede8 Replace uses of (gdb-get-instance-buffer 'gdba) and
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48682
diff changeset
1614 (with-current-buffer gud-comint-buffer
48921
3aa5ba679145 Remove the concept of an instance. This means that a lot of functions have
Nick Roberts <nickrob@snap.net.nz>
parents: 48884
diff changeset
1615 (concat "*locals of " (gdb-get-target-string) "*")))
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1616
48515
3216cd45d6d2 Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents: 48498
diff changeset
1617 (defun gdb-display-locals-buffer ()
48659
4d69c0f01cc0 (gdb-inferior-io-mode-map): Remove (unused).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48641
diff changeset
1618 (interactive)
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1619 (gdb-display-buffer
48921
3aa5ba679145 Remove the concept of an instance. This means that a lot of functions have
Nick Roberts <nickrob@snap.net.nz>
parents: 48884
diff changeset
1620 (gdb-get-create-buffer 'gdb-locals-buffer)))
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1621
48515
3216cd45d6d2 Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents: 48498
diff changeset
1622 (defun gdb-frame-locals-buffer ()
48659
4d69c0f01cc0 (gdb-inferior-io-mode-map): Remove (unused).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48641
diff changeset
1623 (interactive)
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1624 (switch-to-buffer-other-frame
48921
3aa5ba679145 Remove the concept of an instance. This means that a lot of functions have
Nick Roberts <nickrob@snap.net.nz>
parents: 48884
diff changeset
1625 (gdb-get-create-buffer 'gdb-locals-buffer)))
48955
1abfa35a3a5a (gdb-display-number-end): Make auto-display of
Nick Roberts <nickrob@snap.net.nz>
parents: 48921
diff changeset
1626
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1627 ;;
48955
1abfa35a3a5a (gdb-display-number-end): Make auto-display of
Nick Roberts <nickrob@snap.net.nz>
parents: 48921
diff changeset
1628 ;; Display expression buffer.
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1629 ;;
48921
3aa5ba679145 Remove the concept of an instance. This means that a lot of functions have
Nick Roberts <nickrob@snap.net.nz>
parents: 48884
diff changeset
1630 (gdb-set-buffer-rules 'gdb-display-buffer
3aa5ba679145 Remove the concept of an instance. This means that a lot of functions have
Nick Roberts <nickrob@snap.net.nz>
parents: 48884
diff changeset
1631 'gdb-display-buffer-name
3aa5ba679145 Remove the concept of an instance. This means that a lot of functions have
Nick Roberts <nickrob@snap.net.nz>
parents: 48884
diff changeset
1632 'gdb-display-mode)
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1633
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1634 (def-gdb-auto-updated-buffer gdb-display-buffer
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1635 ;; `gdb-display-buffer'.
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1636 gdb-invalidate-display
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1637 "server info display\n"
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1638 gdb-info-display-handler
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1639 gdb-info-display-custom)
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1640
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1641 (defun gdb-info-display-custom ()
48963
1bb53161a4b9 (gdb-info-display-custom): Ensure that frames/buffers
Nick Roberts <nickrob@snap.net.nz>
parents: 48955
diff changeset
1642 (let ((display-list nil))
1bb53161a4b9 (gdb-info-display-custom): Ensure that frames/buffers
Nick Roberts <nickrob@snap.net.nz>
parents: 48955
diff changeset
1643 (save-excursion
1bb53161a4b9 (gdb-info-display-custom): Ensure that frames/buffers
Nick Roberts <nickrob@snap.net.nz>
parents: 48955
diff changeset
1644 (set-buffer (gdb-get-buffer 'gdb-display-buffer))
1bb53161a4b9 (gdb-info-display-custom): Ensure that frames/buffers
Nick Roberts <nickrob@snap.net.nz>
parents: 48955
diff changeset
1645 (goto-char (point-min))
1bb53161a4b9 (gdb-info-display-custom): Ensure that frames/buffers
Nick Roberts <nickrob@snap.net.nz>
parents: 48955
diff changeset
1646 (while (< (point) (- (point-max) 1))
1bb53161a4b9 (gdb-info-display-custom): Ensure that frames/buffers
Nick Roberts <nickrob@snap.net.nz>
parents: 48955
diff changeset
1647 (forward-line 1)
1bb53161a4b9 (gdb-info-display-custom): Ensure that frames/buffers
Nick Roberts <nickrob@snap.net.nz>
parents: 48955
diff changeset
1648 (if (looking-at "\\([0-9]+\\): \\([ny]\\)")
1bb53161a4b9 (gdb-info-display-custom): Ensure that frames/buffers
Nick Roberts <nickrob@snap.net.nz>
parents: 48955
diff changeset
1649 (setq display-list
1bb53161a4b9 (gdb-info-display-custom): Ensure that frames/buffers
Nick Roberts <nickrob@snap.net.nz>
parents: 48955
diff changeset
1650 (cons (string-to-int (match-string 1)) display-list)))
1bb53161a4b9 (gdb-info-display-custom): Ensure that frames/buffers
Nick Roberts <nickrob@snap.net.nz>
parents: 48955
diff changeset
1651 (end-of-line)))
1bb53161a4b9 (gdb-info-display-custom): Ensure that frames/buffers
Nick Roberts <nickrob@snap.net.nz>
parents: 48955
diff changeset
1652 (if (not (display-graphic-p))
1bb53161a4b9 (gdb-info-display-custom): Ensure that frames/buffers
Nick Roberts <nickrob@snap.net.nz>
parents: 48955
diff changeset
1653 (progn
1bb53161a4b9 (gdb-info-display-custom): Ensure that frames/buffers
Nick Roberts <nickrob@snap.net.nz>
parents: 48955
diff changeset
1654 (dolist (buffer (buffer-list))
1bb53161a4b9 (gdb-info-display-custom): Ensure that frames/buffers
Nick Roberts <nickrob@snap.net.nz>
parents: 48955
diff changeset
1655 (if (string-match "\\*display \\([0-9]+\\)\\*" (buffer-name buffer))
1bb53161a4b9 (gdb-info-display-custom): Ensure that frames/buffers
Nick Roberts <nickrob@snap.net.nz>
parents: 48955
diff changeset
1656 (progn
1bb53161a4b9 (gdb-info-display-custom): Ensure that frames/buffers
Nick Roberts <nickrob@snap.net.nz>
parents: 48955
diff changeset
1657 (let ((number
1bb53161a4b9 (gdb-info-display-custom): Ensure that frames/buffers
Nick Roberts <nickrob@snap.net.nz>
parents: 48955
diff changeset
1658 (match-string 1 (buffer-name buffer))))
1bb53161a4b9 (gdb-info-display-custom): Ensure that frames/buffers
Nick Roberts <nickrob@snap.net.nz>
parents: 48955
diff changeset
1659 (if (not (memq (string-to-int number) display-list))
1bb53161a4b9 (gdb-info-display-custom): Ensure that frames/buffers
Nick Roberts <nickrob@snap.net.nz>
parents: 48955
diff changeset
1660 (kill-buffer
1bb53161a4b9 (gdb-info-display-custom): Ensure that frames/buffers
Nick Roberts <nickrob@snap.net.nz>
parents: 48955
diff changeset
1661 (get-buffer (concat "*display " number "*")))))))))
49039
6c5f45b01d2e Acknowledge Tom Lord as author of gdba.el.
Nick Roberts <nickrob@snap.net.nz>
parents: 49000
diff changeset
1662 (gdb-delete-frames display-list))))
6c5f45b01d2e Acknowledge Tom Lord as author of gdba.el.
Nick Roberts <nickrob@snap.net.nz>
parents: 49000
diff changeset
1663
6c5f45b01d2e Acknowledge Tom Lord as author of gdba.el.
Nick Roberts <nickrob@snap.net.nz>
parents: 49000
diff changeset
1664 (defun gdb-delete-frames (display-list)
6c5f45b01d2e Acknowledge Tom Lord as author of gdba.el.
Nick Roberts <nickrob@snap.net.nz>
parents: 49000
diff changeset
1665 (dolist (frame (frame-list))
6c5f45b01d2e Acknowledge Tom Lord as author of gdba.el.
Nick Roberts <nickrob@snap.net.nz>
parents: 49000
diff changeset
1666 (let ((frame-name (frame-parameter frame 'name)))
6c5f45b01d2e Acknowledge Tom Lord as author of gdba.el.
Nick Roberts <nickrob@snap.net.nz>
parents: 49000
diff changeset
1667 (if (string-match "\\*display \\([0-9]+\\)\\*" frame-name)
6c5f45b01d2e Acknowledge Tom Lord as author of gdba.el.
Nick Roberts <nickrob@snap.net.nz>
parents: 49000
diff changeset
1668 (progn
6c5f45b01d2e Acknowledge Tom Lord as author of gdba.el.
Nick Roberts <nickrob@snap.net.nz>
parents: 49000
diff changeset
1669 (let ((number (match-string 1 frame-name)))
6c5f45b01d2e Acknowledge Tom Lord as author of gdba.el.
Nick Roberts <nickrob@snap.net.nz>
parents: 49000
diff changeset
1670 (if (not (memq (string-to-int number) display-list))
6c5f45b01d2e Acknowledge Tom Lord as author of gdba.el.
Nick Roberts <nickrob@snap.net.nz>
parents: 49000
diff changeset
1671 (progn (kill-buffer
6c5f45b01d2e Acknowledge Tom Lord as author of gdba.el.
Nick Roberts <nickrob@snap.net.nz>
parents: 49000
diff changeset
1672 (get-buffer (concat "*display " number "*")))
6c5f45b01d2e Acknowledge Tom Lord as author of gdba.el.
Nick Roberts <nickrob@snap.net.nz>
parents: 49000
diff changeset
1673 (delete-frame frame)))))))))
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1674
48661
b092bff770ec Fold top-level `setq's and `define-key's into their corresponding defvar.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48659
diff changeset
1675 (defvar gdb-display-mode-map
b092bff770ec Fold top-level `setq's and `define-key's into their corresponding defvar.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48659
diff changeset
1676 (let ((map (make-sparse-keymap))
b092bff770ec Fold top-level `setq's and `define-key's into their corresponding defvar.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48659
diff changeset
1677 (menu (make-sparse-keymap "Display")))
49000
f3c5848184cb (gdb-delete-display): Rename (gdb-delete-expression).
Nick Roberts <nickrob@snap.net.nz>
parents: 48963
diff changeset
1678 (define-key menu [toggle] '("Toggle" . gdb-toggle-display))
f3c5848184cb (gdb-delete-display): Rename (gdb-delete-expression).
Nick Roberts <nickrob@snap.net.nz>
parents: 48963
diff changeset
1679 (define-key menu [delete] '("Delete" . gdb-delete-display))
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1680
48661
b092bff770ec Fold top-level `setq's and `define-key's into their corresponding defvar.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48659
diff changeset
1681 (suppress-keymap map)
b092bff770ec Fold top-level `setq's and `define-key's into their corresponding defvar.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48659
diff changeset
1682 (define-key map [menu-bar display] (cons "Display" menu))
49000
f3c5848184cb (gdb-delete-display): Rename (gdb-delete-expression).
Nick Roberts <nickrob@snap.net.nz>
parents: 48963
diff changeset
1683 (define-key map " " 'gdb-toggle-display)
f3c5848184cb (gdb-delete-display): Rename (gdb-delete-expression).
Nick Roberts <nickrob@snap.net.nz>
parents: 48963
diff changeset
1684 (define-key map "d" 'gdb-delete-display)
48661
b092bff770ec Fold top-level `setq's and `define-key's into their corresponding defvar.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48659
diff changeset
1685 map))
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1686
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1687 (defun gdb-display-mode ()
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1688 "Major mode for gdb display.
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1689
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1690 \\{gdb-display-mode-map}"
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1691 (setq major-mode 'gdb-display-mode)
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1692 (setq mode-name "Display")
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1693 (setq buffer-read-only t)
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1694 (use-local-map gdb-display-mode-map)
48515
3216cd45d6d2 Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents: 48498
diff changeset
1695 (gdb-invalidate-display))
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1696
48515
3216cd45d6d2 Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents: 48498
diff changeset
1697 (defun gdb-display-buffer-name ()
48685
19bf840bede8 Replace uses of (gdb-get-instance-buffer 'gdba) and
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48682
diff changeset
1698 (with-current-buffer gud-comint-buffer
48921
3aa5ba679145 Remove the concept of an instance. This means that a lot of functions have
Nick Roberts <nickrob@snap.net.nz>
parents: 48884
diff changeset
1699 (concat "*Displayed expressions of " (gdb-get-target-string) "*")))
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1700
48515
3216cd45d6d2 Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents: 48498
diff changeset
1701 (defun gdb-display-display-buffer ()
48659
4d69c0f01cc0 (gdb-inferior-io-mode-map): Remove (unused).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48641
diff changeset
1702 (interactive)
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1703 (gdb-display-buffer
48921
3aa5ba679145 Remove the concept of an instance. This means that a lot of functions have
Nick Roberts <nickrob@snap.net.nz>
parents: 48884
diff changeset
1704 (gdb-get-create-buffer 'gdb-display-buffer)))
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1705
48515
3216cd45d6d2 Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents: 48498
diff changeset
1706 (defun gdb-frame-display-buffer ()
48659
4d69c0f01cc0 (gdb-inferior-io-mode-map): Remove (unused).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48641
diff changeset
1707 (interactive)
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1708 (switch-to-buffer-other-frame
48921
3aa5ba679145 Remove the concept of an instance. This means that a lot of functions have
Nick Roberts <nickrob@snap.net.nz>
parents: 48884
diff changeset
1709 (gdb-get-create-buffer 'gdb-display-buffer)))
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1710
49000
f3c5848184cb (gdb-delete-display): Rename (gdb-delete-expression).
Nick Roberts <nickrob@snap.net.nz>
parents: 48963
diff changeset
1711 (defun gdb-toggle-display ()
f3c5848184cb (gdb-delete-display): Rename (gdb-delete-expression).
Nick Roberts <nickrob@snap.net.nz>
parents: 48963
diff changeset
1712 "Enable/disable the displayed expression at current line."
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1713 (interactive)
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1714 (save-excursion
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1715 (beginning-of-line 1)
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1716 (if (not (looking-at "\\([0-9]+\\): \\([ny]\\)"))
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1717 (error "No expression on this line")
48921
3aa5ba679145 Remove the concept of an instance. This means that a lot of functions have
Nick Roberts <nickrob@snap.net.nz>
parents: 48884
diff changeset
1718 (gdb-enqueue-input
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1719 (list
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1720 (concat
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1721 (if (eq ?y (char-after (match-beginning 2)))
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1722 "server disable display "
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1723 "server enable display ")
48963
1bb53161a4b9 (gdb-info-display-custom): Ensure that frames/buffers
Nick Roberts <nickrob@snap.net.nz>
parents: 48955
diff changeset
1724 (match-string 1) "\n")
48641
da382393fb77 Get rid of (quote ..); use match-string and ignore.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48640
diff changeset
1725 'ignore)))))
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1726
49000
f3c5848184cb (gdb-delete-display): Rename (gdb-delete-expression).
Nick Roberts <nickrob@snap.net.nz>
parents: 48963
diff changeset
1727 (defun gdb-delete-display ()
f3c5848184cb (gdb-delete-display): Rename (gdb-delete-expression).
Nick Roberts <nickrob@snap.net.nz>
parents: 48963
diff changeset
1728 "Delete the displayed expression at current line."
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1729 (interactive)
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1730 (save-excursion
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1731 (set-buffer
48921
3aa5ba679145 Remove the concept of an instance. This means that a lot of functions have
Nick Roberts <nickrob@snap.net.nz>
parents: 48884
diff changeset
1732 (gdb-get-buffer 'gdb-display-buffer))
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1733 (beginning-of-line 1)
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1734 (if (not (looking-at "\\([0-9]+\\): \\([ny]\\)"))
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1735 (error "No expression on this line")
48641
da382393fb77 Get rid of (quote ..); use match-string and ignore.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48640
diff changeset
1736 (let ((number (match-string 1)))
48921
3aa5ba679145 Remove the concept of an instance. This means that a lot of functions have
Nick Roberts <nickrob@snap.net.nz>
parents: 48884
diff changeset
1737 (gdb-enqueue-input
48963
1bb53161a4b9 (gdb-info-display-custom): Ensure that frames/buffers
Nick Roberts <nickrob@snap.net.nz>
parents: 48955
diff changeset
1738 (list (concat "server delete display " number "\n") 'ignore))))))
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1739
48661
b092bff770ec Fold top-level `setq's and `define-key's into their corresponding defvar.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48659
diff changeset
1740 (defvar gdb-expressions-mode-map
b092bff770ec Fold top-level `setq's and `define-key's into their corresponding defvar.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48659
diff changeset
1741 (let ((map (make-sparse-keymap)))
b092bff770ec Fold top-level `setq's and `define-key's into their corresponding defvar.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48659
diff changeset
1742 (suppress-keymap map)
b092bff770ec Fold top-level `setq's and `define-key's into their corresponding defvar.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48659
diff changeset
1743 (define-key map "v" 'gdb-array-visualise)
49147
8a40184e2f0e (gud-display): Use GDB command ptype instead of whatis
Nick Roberts <nickrob@snap.net.nz>
parents: 49039
diff changeset
1744 (define-key map "q" 'gdb-delete-expression)
48661
b092bff770ec Fold top-level `setq's and `define-key's into their corresponding defvar.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48659
diff changeset
1745 (define-key map [mouse-3] 'gdb-expressions-popup-menu)
b092bff770ec Fold top-level `setq's and `define-key's into their corresponding defvar.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48659
diff changeset
1746 map))
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1747
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1748 (defvar gdb-expressions-mode-menu
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1749 '("GDB Expressions Commands"
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1750 "----"
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1751 ["Visualise" gdb-array-visualise t]
49000
f3c5848184cb (gdb-delete-display): Rename (gdb-delete-expression).
Nick Roberts <nickrob@snap.net.nz>
parents: 48963
diff changeset
1752 ["Delete" gdb-delete-expression t])
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1753 "Menu for `gdb-expressions-mode'.")
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1754
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1755 (defun gdb-expressions-popup-menu (event)
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1756 "Explicit Popup menu as this buffer doesn't have a menubar."
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1757 (interactive "@e")
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1758 (mouse-set-point event)
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1759 (popup-menu gdb-expressions-mode-menu))
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1760
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1761 (defun gdb-expressions-mode ()
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1762 "Major mode for display expressions.
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1763
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1764 \\{gdb-expressions-mode-map}"
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1765 (setq major-mode 'gdb-expressions-mode)
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1766 (setq mode-name "Expressions")
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1767 (use-local-map gdb-expressions-mode-map)
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1768 (make-local-variable 'gdb-display-number)
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1769 (make-local-variable 'gdb-values)
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1770 (make-local-variable 'gdb-expression)
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1771 (set (make-local-variable 'gdb-display-string) nil)
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1772 (set (make-local-variable 'gdb-dive-display-number) nil)
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1773 (set (make-local-variable 'gud-minor-mode) 'gdba)
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1774 (set (make-local-variable 'gdb-array-start) (make-vector 16 '-1))
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1775 (set (make-local-variable 'gdb-array-stop) (make-vector 16 '-1))
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1776 (set (make-local-variable 'gdb-array-size) (make-vector 16 '-1))
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1777 (setq buffer-read-only t))
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1778
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1779
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1780 ;;;; Window management
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1781
48515
3216cd45d6d2 Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents: 48498
diff changeset
1782 ;;; FIXME: This should only return true for buffers in the current gdb-proc
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1783 (defun gdb-protected-buffer-p (buffer)
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1784 "Is BUFFER a buffer which we want to leave displayed?"
48682
a74dd42cf01d (gud-gdb-complete-string, gud-gdb-complete-break)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48662
diff changeset
1785 (with-current-buffer buffer
a74dd42cf01d (gud-gdb-complete-string, gud-gdb-complete-break)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48662
diff changeset
1786 (or gdb-buffer-type overlay-arrow-position)))
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1787
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1788 ;;; The way we abuse the dedicated-p flag is pretty gross, but seems
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1789 ;;; to do the right thing. Seeing as there is no way for Lisp code to
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1790 ;;; get at the use_time field of a window, I'm not sure there exists a
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1791 ;;; more elegant solution without writing C code.
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1792
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1793 (defun gdb-display-buffer (buf &optional size)
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1794 (let ((must-split nil)
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1795 (answer nil))
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1796 (unwind-protect
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1797 (progn
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1798 (walk-windows
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1799 '(lambda (win)
48921
3aa5ba679145 Remove the concept of an instance. This means that a lot of functions have
Nick Roberts <nickrob@snap.net.nz>
parents: 48884
diff changeset
1800 (if (or (eq gud-comint-buffer (window-buffer win))
3aa5ba679145 Remove the concept of an instance. This means that a lot of functions have
Nick Roberts <nickrob@snap.net.nz>
parents: 48884
diff changeset
1801 (eq gdb-source-window win))
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1802 (set-window-dedicated-p win t))))
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1803 (setq answer (get-buffer-window buf))
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1804 (if (not answer)
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1805 (let ((window (get-lru-window)))
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1806 (if window
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1807 (progn
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1808 (set-window-buffer window buf)
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1809 (setq answer window))
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1810 (setq must-split t)))))
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1811 (walk-windows
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1812 '(lambda (win)
48921
3aa5ba679145 Remove the concept of an instance. This means that a lot of functions have
Nick Roberts <nickrob@snap.net.nz>
parents: 48884
diff changeset
1813 (if (or (eq gud-comint-buffer (window-buffer win))
3aa5ba679145 Remove the concept of an instance. This means that a lot of functions have
Nick Roberts <nickrob@snap.net.nz>
parents: 48884
diff changeset
1814 (eq gdb-source-window win))
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1815 (set-window-dedicated-p win nil)))))
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1816 (if must-split
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1817 (let* ((largest (get-largest-window))
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1818 (cur-size (window-height largest))
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1819 (new-size (and size (< size cur-size) (- cur-size size))))
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1820 (setq answer (split-window largest new-size))
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1821 (set-window-buffer answer buf)))
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1822 answer))
48300
69646014abb3 Fix feature name in `require'.
Juanma Barranquero <lekktu@gmail.com>
parents: 48292
diff changeset
1823
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1824 (defun gdb-display-source-buffer (buffer)
49000
f3c5848184cb (gdb-delete-display): Rename (gdb-delete-expression).
Nick Roberts <nickrob@snap.net.nz>
parents: 48963
diff changeset
1825 (set-window-buffer gdb-source-window buffer)
f3c5848184cb (gdb-delete-display): Rename (gdb-delete-expression).
Nick Roberts <nickrob@snap.net.nz>
parents: 48963
diff changeset
1826 gdb-source-window)
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1827
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1828
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1829 ;;; Shared keymap initialization:
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1830
48515
3216cd45d6d2 Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents: 48498
diff changeset
1831 (defun gdb-display-gdb-buffer ()
48659
4d69c0f01cc0 (gdb-inferior-io-mode-map): Remove (unused).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48641
diff changeset
1832 (interactive)
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1833 (gdb-display-buffer
48921
3aa5ba679145 Remove the concept of an instance. This means that a lot of functions have
Nick Roberts <nickrob@snap.net.nz>
parents: 48884
diff changeset
1834 (gdb-get-create-buffer 'gdba)))
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1835
48661
b092bff770ec Fold top-level `setq's and `define-key's into their corresponding defvar.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48659
diff changeset
1836 (let ((menu (make-sparse-keymap "GDB-Windows")))
48682
a74dd42cf01d (gud-gdb-complete-string, gud-gdb-complete-break)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48662
diff changeset
1837 (define-key gud-menu-map [displays]
48738
81dc78298a54 Remove inappropriate key-bindings.
Nick Roberts <nickrob@snap.net.nz>
parents: 48685
diff changeset
1838 `(menu-item "GDB-Windows" ,menu :visible (eq gud-minor-mode 'gdba)))
48661
b092bff770ec Fold top-level `setq's and `define-key's into their corresponding defvar.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48659
diff changeset
1839 (define-key menu [gdb] '("Gdb" . gdb-display-gdb-buffer))
b092bff770ec Fold top-level `setq's and `define-key's into their corresponding defvar.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48659
diff changeset
1840 (define-key menu [locals] '("Locals" . gdb-display-locals-buffer))
b092bff770ec Fold top-level `setq's and `define-key's into their corresponding defvar.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48659
diff changeset
1841 (define-key menu [registers] '("Registers" . gdb-display-registers-buffer))
b092bff770ec Fold top-level `setq's and `define-key's into their corresponding defvar.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48659
diff changeset
1842 (define-key menu [frames] '("Stack" . gdb-display-stack-buffer))
b092bff770ec Fold top-level `setq's and `define-key's into their corresponding defvar.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48659
diff changeset
1843 (define-key menu [breakpoints] '("Breakpoints" . gdb-display-breakpoints-buffer))
b092bff770ec Fold top-level `setq's and `define-key's into their corresponding defvar.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48659
diff changeset
1844 (define-key menu [display] '("Display" . gdb-display-display-buffer))
b092bff770ec Fold top-level `setq's and `define-key's into their corresponding defvar.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48659
diff changeset
1845 (define-key menu [assembler] '("Assembler" . gdb-display-assembler-buffer)))
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1846
48515
3216cd45d6d2 Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents: 48498
diff changeset
1847 (defun gdb-frame-gdb-buffer ()
48659
4d69c0f01cc0 (gdb-inferior-io-mode-map): Remove (unused).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48641
diff changeset
1848 (interactive)
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1849 (switch-to-buffer-other-frame
48921
3aa5ba679145 Remove the concept of an instance. This means that a lot of functions have
Nick Roberts <nickrob@snap.net.nz>
parents: 48884
diff changeset
1850 (gdb-get-create-buffer 'gdba)))
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1851
48661
b092bff770ec Fold top-level `setq's and `define-key's into their corresponding defvar.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48659
diff changeset
1852 (let ((menu (make-sparse-keymap "GDB-Frames")))
48682
a74dd42cf01d (gud-gdb-complete-string, gud-gdb-complete-break)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48662
diff changeset
1853 (define-key gud-menu-map [frames]
48738
81dc78298a54 Remove inappropriate key-bindings.
Nick Roberts <nickrob@snap.net.nz>
parents: 48685
diff changeset
1854 `(menu-item "GDB-Frames" ,menu :visible (eq gud-minor-mode 'gdba)))
48661
b092bff770ec Fold top-level `setq's and `define-key's into their corresponding defvar.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48659
diff changeset
1855 (define-key menu [gdb] '("Gdb" . gdb-frame-gdb-buffer))
b092bff770ec Fold top-level `setq's and `define-key's into their corresponding defvar.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48659
diff changeset
1856 (define-key menu [locals] '("Locals" . gdb-frame-locals-buffer))
b092bff770ec Fold top-level `setq's and `define-key's into their corresponding defvar.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48659
diff changeset
1857 (define-key menu [registers] '("Registers" . gdb-frame-registers-buffer))
b092bff770ec Fold top-level `setq's and `define-key's into their corresponding defvar.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48659
diff changeset
1858 (define-key menu [frames] '("Stack" . gdb-frame-stack-buffer))
b092bff770ec Fold top-level `setq's and `define-key's into their corresponding defvar.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48659
diff changeset
1859 (define-key menu [breakpoints] '("Breakpoints" . gdb-frame-breakpoints-buffer))
b092bff770ec Fold top-level `setq's and `define-key's into their corresponding defvar.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48659
diff changeset
1860 (define-key menu [display] '("Display" . gdb-frame-display-buffer))
b092bff770ec Fold top-level `setq's and `define-key's into their corresponding defvar.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48659
diff changeset
1861 (define-key menu [assembler] '("Assembler" . gdb-frame-assembler-buffer)))
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1862
48515
3216cd45d6d2 Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents: 48498
diff changeset
1863 (defvar gdb-main-file nil "Source file from which program execution begins.")
3216cd45d6d2 Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents: 48498
diff changeset
1864
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1865 ;; layout for all the windows
48515
3216cd45d6d2 Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents: 48498
diff changeset
1866 (defun gdb-setup-windows ()
3216cd45d6d2 Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents: 48498
diff changeset
1867 (gdb-display-locals-buffer)
3216cd45d6d2 Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents: 48498
diff changeset
1868 (gdb-display-stack-buffer)
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1869 (delete-other-windows)
48515
3216cd45d6d2 Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents: 48498
diff changeset
1870 (gdb-display-breakpoints-buffer)
3216cd45d6d2 Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents: 48498
diff changeset
1871 (gdb-display-display-buffer)
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1872 (delete-other-windows)
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1873 (split-window nil ( / ( * (window-height) 3) 4))
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1874 (split-window nil ( / (window-height) 3))
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1875 (split-window-horizontally)
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1876 (other-window 1)
48515
3216cd45d6d2 Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents: 48498
diff changeset
1877 (switch-to-buffer (gdb-locals-buffer-name))
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1878 (other-window 1)
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1879 (switch-to-buffer
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1880 (if gud-last-last-frame
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1881 (gud-find-file (car gud-last-last-frame))
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1882 (gud-find-file gdb-main-file)))
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1883 (setq gdb-source-window (get-buffer-window (current-buffer)))
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1884 (split-window-horizontally)
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1885 (other-window 1)
48515
3216cd45d6d2 Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents: 48498
diff changeset
1886 (switch-to-buffer (gdb-inferior-io-name))
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1887 (other-window 1)
48515
3216cd45d6d2 Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents: 48498
diff changeset
1888 (switch-to-buffer (gdb-stack-buffer-name))
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1889 (split-window-horizontally)
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1890 (other-window 1)
48515
3216cd45d6d2 Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents: 48498
diff changeset
1891 (switch-to-buffer (gdb-breakpoints-buffer-name))
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1892 (other-window 1))
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1893
48600
88be03de9df4 (gdb-many-windows): Define as a minor mode.
Nick Roberts <nickrob@snap.net.nz>
parents: 48570
diff changeset
1894 (define-minor-mode gdb-many-windows
88be03de9df4 (gdb-many-windows): Define as a minor mode.
Nick Roberts <nickrob@snap.net.nz>
parents: 48570
diff changeset
1895 "Toggle the number of windows in the basic arrangement."
88be03de9df4 (gdb-many-windows): Define as a minor mode.
Nick Roberts <nickrob@snap.net.nz>
parents: 48570
diff changeset
1896 :group 'gud
48827
dc51e4b2d5c1 Improve documentation strings.
Nick Roberts <nickrob@snap.net.nz>
parents: 48738
diff changeset
1897 :init-value nil
48600
88be03de9df4 (gdb-many-windows): Define as a minor mode.
Nick Roberts <nickrob@snap.net.nz>
parents: 48570
diff changeset
1898 (gdb-restore-windows))
88be03de9df4 (gdb-many-windows): Define as a minor mode.
Nick Roberts <nickrob@snap.net.nz>
parents: 48570
diff changeset
1899
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1900 (defun gdb-restore-windows ()
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1901 "Restore the basic arrangement of windows used by gdba.
48498
8fdedd7dca85 General tidying. Patches from Stefan Monnier.
Nick Roberts <nickrob@snap.net.nz>
parents: 48300
diff changeset
1902 This arrangement depends on the value of `gdb-many-windows'."
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1903 (interactive)
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1904 (if gdb-many-windows
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1905 (progn
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1906 (switch-to-buffer gud-comint-buffer)
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1907 (delete-other-windows)
48515
3216cd45d6d2 Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents: 48498
diff changeset
1908 (gdb-setup-windows))
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1909 (switch-to-buffer gud-comint-buffer)
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1910 (delete-other-windows)
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1911 (split-window)
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1912 (other-window 1)
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1913 (switch-to-buffer
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1914 (if gud-last-last-frame
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1915 (gud-find-file (car gud-last-last-frame))
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1916 (gud-find-file gdb-main-file)))
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1917 (other-window 1)))
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1918
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1919 (defconst breakpoint-xpm-data "/* XPM */
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1920 static char *magick[] = {
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1921 /* columns rows colors chars-per-pixel */
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1922 \"12 12 2 1\",
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1923 \" c red\",
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1924 \"+ c None\",
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1925 /* pixels */
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1926 \"+++++ +++++\",
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1927 \"+++ +++\",
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1928 \"++ ++\",
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1929 \"+ +\",
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1930 \"+ +\",
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1931 \" \",
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1932 \" \",
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1933 \"+ +\",
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1934 \"+ +\",
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1935 \"++ ++\",
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1936 \"+++ +++\",
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1937 \"+++++ +++++\"
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1938 };"
48921
3aa5ba679145 Remove the concept of an instance. This means that a lot of functions have
Nick Roberts <nickrob@snap.net.nz>
parents: 48884
diff changeset
1939 "XPM file used for breakpoint icon.")
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1940
48661
b092bff770ec Fold top-level `setq's and `define-key's into their corresponding defvar.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48659
diff changeset
1941 (defvar breakpoint-enabled-icon
b092bff770ec Fold top-level `setq's and `define-key's into their corresponding defvar.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48659
diff changeset
1942 (find-image `((:type xpm :data ,breakpoint-xpm-data)))
b092bff770ec Fold top-level `setq's and `define-key's into their corresponding defvar.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48659
diff changeset
1943 "Icon for enabled breakpoint in display margin")
b092bff770ec Fold top-level `setq's and `define-key's into their corresponding defvar.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48659
diff changeset
1944 (defvar breakpoint-disabled-icon
b092bff770ec Fold top-level `setq's and `define-key's into their corresponding defvar.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48659
diff changeset
1945 (find-image `((:type xpm :data ,breakpoint-xpm-data
b092bff770ec Fold top-level `setq's and `define-key's into their corresponding defvar.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48659
diff changeset
1946 :conversion laplace)))
b092bff770ec Fold top-level `setq's and `define-key's into their corresponding defvar.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48659
diff changeset
1947 "Icon for disabled breakpoint in display margin")
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1948
49147
8a40184e2f0e (gud-display): Use GDB command ptype instead of whatis
Nick Roberts <nickrob@snap.net.nz>
parents: 49039
diff changeset
1949 (defun gdb-reset ()
8a40184e2f0e (gud-display): Use GDB command ptype instead of whatis
Nick Roberts <nickrob@snap.net.nz>
parents: 49039
diff changeset
1950 "Exit a debugging session cleanly by killing the gdb buffers and resetting
8a40184e2f0e (gud-display): Use GDB command ptype instead of whatis
Nick Roberts <nickrob@snap.net.nz>
parents: 49039
diff changeset
1951 the source buffers."
49039
6c5f45b01d2e Acknowledge Tom Lord as author of gdba.el.
Nick Roberts <nickrob@snap.net.nz>
parents: 49000
diff changeset
1952 (gdb-delete-frames '())
48955
1abfa35a3a5a (gdb-display-number-end): Make auto-display of
Nick Roberts <nickrob@snap.net.nz>
parents: 48921
diff changeset
1953 (dolist (buffer (buffer-list))
49147
8a40184e2f0e (gud-display): Use GDB command ptype instead of whatis
Nick Roberts <nickrob@snap.net.nz>
parents: 49039
diff changeset
1954 (if (not (eq buffer gud-comint-buffer))
49249
7c4bc41333d1 Improve commentary.
Nick Roberts <nickrob@snap.net.nz>
parents: 49147
diff changeset
1955 (with-current-buffer buffer
49147
8a40184e2f0e (gud-display): Use GDB command ptype instead of whatis
Nick Roberts <nickrob@snap.net.nz>
parents: 49039
diff changeset
1956 (if (eq gud-minor-mode 'gdba)
8a40184e2f0e (gud-display): Use GDB command ptype instead of whatis
Nick Roberts <nickrob@snap.net.nz>
parents: 49039
diff changeset
1957 (if (string-match "^\*.+*$" (buffer-name))
8a40184e2f0e (gud-display): Use GDB command ptype instead of whatis
Nick Roberts <nickrob@snap.net.nz>
parents: 49039
diff changeset
1958 (kill-buffer nil)
8a40184e2f0e (gud-display): Use GDB command ptype instead of whatis
Nick Roberts <nickrob@snap.net.nz>
parents: 49039
diff changeset
1959 (if (display-graphic-p)
8a40184e2f0e (gud-display): Use GDB command ptype instead of whatis
Nick Roberts <nickrob@snap.net.nz>
parents: 49039
diff changeset
1960 (remove-images (point-min) (point-max))
8a40184e2f0e (gud-display): Use GDB command ptype instead of whatis
Nick Roberts <nickrob@snap.net.nz>
parents: 49039
diff changeset
1961 (remove-strings (point-min) (point-max)))
8a40184e2f0e (gud-display): Use GDB command ptype instead of whatis
Nick Roberts <nickrob@snap.net.nz>
parents: 49039
diff changeset
1962 (setq left-margin-width 0)
8a40184e2f0e (gud-display): Use GDB command ptype instead of whatis
Nick Roberts <nickrob@snap.net.nz>
parents: 49039
diff changeset
1963 (setq gud-minor-mode nil)
8a40184e2f0e (gud-display): Use GDB command ptype instead of whatis
Nick Roberts <nickrob@snap.net.nz>
parents: 49039
diff changeset
1964 (kill-local-variable 'tool-bar-map)
8a40184e2f0e (gud-display): Use GDB command ptype instead of whatis
Nick Roberts <nickrob@snap.net.nz>
parents: 49039
diff changeset
1965 (setq gud-running nil)
8a40184e2f0e (gud-display): Use GDB command ptype instead of whatis
Nick Roberts <nickrob@snap.net.nz>
parents: 49039
diff changeset
1966 (if (get-buffer-window (current-buffer))
8a40184e2f0e (gud-display): Use GDB command ptype instead of whatis
Nick Roberts <nickrob@snap.net.nz>
parents: 49039
diff changeset
1967 (set-window-margins (get-buffer-window
8a40184e2f0e (gud-display): Use GDB command ptype instead of whatis
Nick Roberts <nickrob@snap.net.nz>
parents: 49039
diff changeset
1968 (current-buffer))
8a40184e2f0e (gud-display): Use GDB command ptype instead of whatis
Nick Roberts <nickrob@snap.net.nz>
parents: 49039
diff changeset
1969 left-margin-width
8a40184e2f0e (gud-display): Use GDB command ptype instead of whatis
Nick Roberts <nickrob@snap.net.nz>
parents: 49039
diff changeset
1970 right-margin-width))))))))
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1971
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1972 (defun gdb-source-info ()
48641
da382393fb77 Get rid of (quote ..); use match-string and ignore.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48640
diff changeset
1973 "Find the source file where the program starts and displays it with related
48570
4934b8352621 (gdb-starting): Set gdb-running to t.
Nick Roberts <nickrob@snap.net.nz>
parents: 48515
diff changeset
1974 buffers."
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1975 (goto-char (point-min))
48659
4d69c0f01cc0 (gdb-inferior-io-mode-map): Remove (unused).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48641
diff changeset
1976 (when (search-forward "directory is " nil t)
4d69c0f01cc0 (gdb-inferior-io-mode-map): Remove (unused).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48641
diff changeset
1977 (looking-at "\\S-*")
4d69c0f01cc0 (gdb-inferior-io-mode-map): Remove (unused).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48641
diff changeset
1978 (setq gdb-cdir (match-string 0))
4d69c0f01cc0 (gdb-inferior-io-mode-map): Remove (unused).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48641
diff changeset
1979 (search-forward "Located in ")
4d69c0f01cc0 (gdb-inferior-io-mode-map): Remove (unused).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48641
diff changeset
1980 (looking-at "\\S-*")
4d69c0f01cc0 (gdb-inferior-io-mode-map): Remove (unused).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48641
diff changeset
1981 (setq gdb-main-file (match-string 0))
4d69c0f01cc0 (gdb-inferior-io-mode-map): Remove (unused).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48641
diff changeset
1982 ;; Make sure we are not in the minibuffer window when we try to delete
4d69c0f01cc0 (gdb-inferior-io-mode-map): Remove (unused).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48641
diff changeset
1983 ;; all other windows.
4d69c0f01cc0 (gdb-inferior-io-mode-map): Remove (unused).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48641
diff changeset
1984 (if (window-minibuffer-p (selected-window))
4d69c0f01cc0 (gdb-inferior-io-mode-map): Remove (unused).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48641
diff changeset
1985 (other-window 1))
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1986 (delete-other-windows)
48659
4d69c0f01cc0 (gdb-inferior-io-mode-map): Remove (unused).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48641
diff changeset
1987 (if gdb-many-windows
4d69c0f01cc0 (gdb-inferior-io-mode-map): Remove (unused).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48641
diff changeset
1988 (gdb-setup-windows)
4d69c0f01cc0 (gdb-inferior-io-mode-map): Remove (unused).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48641
diff changeset
1989 (gdb-display-breakpoints-buffer)
48963
1bb53161a4b9 (gdb-info-display-custom): Ensure that frames/buffers
Nick Roberts <nickrob@snap.net.nz>
parents: 48955
diff changeset
1990 (gdb-display-display-buffer)
48659
4d69c0f01cc0 (gdb-inferior-io-mode-map): Remove (unused).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48641
diff changeset
1991 (delete-other-windows)
4d69c0f01cc0 (gdb-inferior-io-mode-map): Remove (unused).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48641
diff changeset
1992 (split-window)
4d69c0f01cc0 (gdb-inferior-io-mode-map): Remove (unused).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48641
diff changeset
1993 (other-window 1)
4d69c0f01cc0 (gdb-inferior-io-mode-map): Remove (unused).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48641
diff changeset
1994 (switch-to-buffer (gud-find-file gdb-main-file))
48955
1abfa35a3a5a (gdb-display-number-end): Make auto-display of
Nick Roberts <nickrob@snap.net.nz>
parents: 48921
diff changeset
1995 (setq gdb-source-window (get-buffer-window (current-buffer)))
1abfa35a3a5a (gdb-display-number-end): Make auto-display of
Nick Roberts <nickrob@snap.net.nz>
parents: 48921
diff changeset
1996 (other-window 1))))
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1997
48662
d29870d63092 Fix up comment markers.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48661
diff changeset
1998 ;;from put-image
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
1999 (defun put-string (putstring pos &optional string area)
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2000 "Put string PUTSTRING in front of POS in the current buffer.
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2001 PUTSTRING is displayed by putting an overlay into the current buffer with a
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2002 `before-string' STRING that has a `display' property whose value is
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2003 PUTSTRING. STRING is defaulted if you omit it.
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2004 POS may be an integer or marker.
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2005 AREA is where to display the string. AREA nil or omitted means
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2006 display it in the text area, a value of `left-margin' means
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2007 display it in the left marginal area, a value of `right-margin'
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2008 means display it in the right marginal area."
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2009 (unless string (setq string "x"))
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2010 (let ((buffer (current-buffer)))
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2011 (unless (or (null area) (memq area '(left-margin right-margin)))
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2012 (error "Invalid area %s" area))
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2013 (setq string (copy-sequence string))
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2014 (let ((overlay (make-overlay pos pos buffer))
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2015 (prop (if (null area) putstring (list (list 'margin area) putstring))))
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2016 (put-text-property 0 (length string) 'display prop string)
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2017 (overlay-put overlay 'put-text t)
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2018 (overlay-put overlay 'before-string string))))
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2019
48662
d29870d63092 Fix up comment markers.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48661
diff changeset
2020 ;;from remove-images
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2021 (defun remove-strings (start end &optional buffer)
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2022 "Remove strings between START and END in BUFFER.
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2023 Remove only images that were put in BUFFER with calls to `put-string'.
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2024 BUFFER nil or omitted means use the current buffer."
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2025 (unless buffer
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2026 (setq buffer (current-buffer)))
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2027 (let ((overlays (overlays-in start end)))
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2028 (while overlays
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2029 (let ((overlay (car overlays)))
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2030 (when (overlay-get overlay 'put-text)
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2031 (delete-overlay overlay)))
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2032 (setq overlays (cdr overlays)))))
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2033
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2034 (defun put-arrow (putstring pos &optional string area)
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2035 "Put arrow string PUTSTRING in front of POS in the current buffer.
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2036 PUTSTRING is displayed by putting an overlay into the current buffer with a
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2037 `before-string' \"gdb-arrow\" that has a `display' property whose value is
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2038 PUTSTRING. STRING is defaulted if you omit it.
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2039 POS may be an integer or marker.
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2040 AREA is where to display the string. AREA nil or omitted means
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2041 display it in the text area, a value of `left-margin' means
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2042 display it in the left marginal area, a value of `right-margin'
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2043 means display it in the right marginal area."
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2044 (setq string "gdb-arrow")
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2045 (let ((buffer (current-buffer)))
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2046 (unless (or (null area) (memq area '(left-margin right-margin)))
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2047 (error "Invalid area %s" area))
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2048 (setq string (copy-sequence string))
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2049 (let ((overlay (make-overlay pos pos buffer))
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2050 (prop (if (null area) putstring (list (list 'margin area) putstring))))
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2051 (put-text-property 0 (length string) 'display prop string)
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2052 (overlay-put overlay 'put-text t)
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2053 (overlay-put overlay 'before-string string))))
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2054
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2055 (defun remove-arrow (&optional buffer)
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2056 "Remove arrow in BUFFER.
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2057 Remove only images that were put in BUFFER with calls to `put-arrow'.
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2058 BUFFER nil or omitted means use the current buffer."
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2059 (unless buffer
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2060 (setq buffer (current-buffer)))
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2061 (let ((overlays (overlays-in (point-min) (point-max))))
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2062 (while overlays
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2063 (let ((overlay (car overlays)))
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2064 (when (string-equal (overlay-get overlay 'before-string) "gdb-arrow")
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2065 (delete-overlay overlay)))
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2066 (setq overlays (cdr overlays)))))
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2067
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2068 (defun gdb-array-visualise ()
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2069 "Visualise arrays and slices using graph program from plotutils."
48498
8fdedd7dca85 General tidying. Patches from Stefan Monnier.
Nick Roberts <nickrob@snap.net.nz>
parents: 48300
diff changeset
2070 (interactive)
48661
b092bff770ec Fold top-level `setq's and `define-key's into their corresponding defvar.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48659
diff changeset
2071 (when (and (display-graphic-p) gdb-display-string)
b092bff770ec Fold top-level `setq's and `define-key's into their corresponding defvar.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48659
diff changeset
2072 (let ((n 0) m)
b092bff770ec Fold top-level `setq's and `define-key's into their corresponding defvar.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48659
diff changeset
2073 (catch 'multi-dimensional
b092bff770ec Fold top-level `setq's and `define-key's into their corresponding defvar.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48659
diff changeset
2074 (while (eq (aref gdb-array-start n) (aref gdb-array-stop n))
b092bff770ec Fold top-level `setq's and `define-key's into their corresponding defvar.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48659
diff changeset
2075 (setq n (+ n 1)))
b092bff770ec Fold top-level `setq's and `define-key's into their corresponding defvar.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48659
diff changeset
2076 (setq m (+ n 1))
b092bff770ec Fold top-level `setq's and `define-key's into their corresponding defvar.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48659
diff changeset
2077 (while (< m (length gdb-array-start))
b092bff770ec Fold top-level `setq's and `define-key's into their corresponding defvar.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48659
diff changeset
2078 (if (not (eq (aref gdb-array-start m) (aref gdb-array-stop m)))
b092bff770ec Fold top-level `setq's and `define-key's into their corresponding defvar.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48659
diff changeset
2079 (progn
b092bff770ec Fold top-level `setq's and `define-key's into their corresponding defvar.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48659
diff changeset
2080 (x-popup-dialog
b092bff770ec Fold top-level `setq's and `define-key's into their corresponding defvar.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48659
diff changeset
2081 t `(,(concat "Only one dimensional data can be visualised.\n"
b092bff770ec Fold top-level `setq's and `define-key's into their corresponding defvar.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48659
diff changeset
2082 "Use an array slice to reduce the number of\n"
b092bff770ec Fold top-level `setq's and `define-key's into their corresponding defvar.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48659
diff changeset
2083 "dimensions") ("OK" t)))
b092bff770ec Fold top-level `setq's and `define-key's into their corresponding defvar.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48659
diff changeset
2084 (throw 'multi-dimensional nil))
b092bff770ec Fold top-level `setq's and `define-key's into their corresponding defvar.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48659
diff changeset
2085 (setq m (+ m 1))))
b092bff770ec Fold top-level `setq's and `define-key's into their corresponding defvar.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48659
diff changeset
2086 (shell-command (concat "echo" gdb-display-string " | graph -a 1 "
b092bff770ec Fold top-level `setq's and `define-key's into their corresponding defvar.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48659
diff changeset
2087 (int-to-string (aref gdb-array-start n))
b092bff770ec Fold top-level `setq's and `define-key's into their corresponding defvar.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48659
diff changeset
2088 " -x "
b092bff770ec Fold top-level `setq's and `define-key's into their corresponding defvar.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48659
diff changeset
2089 (int-to-string (aref gdb-array-start n))
b092bff770ec Fold top-level `setq's and `define-key's into their corresponding defvar.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48659
diff changeset
2090 " "
b092bff770ec Fold top-level `setq's and `define-key's into their corresponding defvar.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48659
diff changeset
2091 (int-to-string (aref gdb-array-stop n))
b092bff770ec Fold top-level `setq's and `define-key's into their corresponding defvar.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48659
diff changeset
2092 " 1 -T X"))))))
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2093
49000
f3c5848184cb (gdb-delete-display): Rename (gdb-delete-expression).
Nick Roberts <nickrob@snap.net.nz>
parents: 48963
diff changeset
2094 (defun gdb-delete-expression ()
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2095 "Delete displayed expression and its frame."
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2096 (interactive)
48921
3aa5ba679145 Remove the concept of an instance. This means that a lot of functions have
Nick Roberts <nickrob@snap.net.nz>
parents: 48884
diff changeset
2097 (gdb-enqueue-input
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2098 (list (concat "server delete display " gdb-display-number "\n")
48963
1bb53161a4b9 (gdb-info-display-custom): Ensure that frames/buffers
Nick Roberts <nickrob@snap.net.nz>
parents: 48955
diff changeset
2099 'ignore)))
48955
1abfa35a3a5a (gdb-display-number-end): Make auto-display of
Nick Roberts <nickrob@snap.net.nz>
parents: 48921
diff changeset
2100
1abfa35a3a5a (gdb-display-number-end): Make auto-display of
Nick Roberts <nickrob@snap.net.nz>
parents: 48921
diff changeset
2101 ;;
1abfa35a3a5a (gdb-display-number-end): Make auto-display of
Nick Roberts <nickrob@snap.net.nz>
parents: 48921
diff changeset
2102 ;; Assembler buffer.
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2103 ;;
48955
1abfa35a3a5a (gdb-display-number-end): Make auto-display of
Nick Roberts <nickrob@snap.net.nz>
parents: 48921
diff changeset
2104 (gdb-set-buffer-rules 'gdb-assembler-buffer
1abfa35a3a5a (gdb-display-number-end): Make auto-display of
Nick Roberts <nickrob@snap.net.nz>
parents: 48921
diff changeset
2105 'gdb-assembler-buffer-name
1abfa35a3a5a (gdb-display-number-end): Make auto-display of
Nick Roberts <nickrob@snap.net.nz>
parents: 48921
diff changeset
2106 'gdb-assembler-mode)
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2107
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2108 (def-gdb-auto-updated-buffer gdb-assembler-buffer
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2109 gdb-invalidate-assembler
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2110 (concat "server disassemble " gdb-main-or-pc "\n")
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2111 gdb-assembler-handler
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2112 gdb-assembler-custom)
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2113
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2114 (defun gdb-assembler-custom ()
48921
3aa5ba679145 Remove the concept of an instance. This means that a lot of functions have
Nick Roberts <nickrob@snap.net.nz>
parents: 48884
diff changeset
2115 (let ((buffer (gdb-get-buffer 'gdb-assembler-buffer))
48498
8fdedd7dca85 General tidying. Patches from Stefan Monnier.
Nick Roberts <nickrob@snap.net.nz>
parents: 48300
diff changeset
2116 (gdb-arrow-position) (address) (flag))
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2117 (if gdb-current-address
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2118 (progn
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2119 (save-excursion
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2120 (set-buffer buffer)
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2121 (remove-arrow)
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2122 (goto-char (point-min))
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2123 (re-search-forward gdb-current-address)
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2124 (setq gdb-arrow-position (point))
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2125 (put-arrow "=>" gdb-arrow-position nil 'left-margin))))
48662
d29870d63092 Fix up comment markers.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48661
diff changeset
2126 ;; remove all breakpoint-icons in assembler buffer before updating.
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2127 (save-excursion
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2128 (set-buffer buffer)
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2129 (if (display-graphic-p)
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2130 (remove-images (point-min) (point-max))
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2131 (remove-strings (point-min) (point-max))))
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2132 (save-excursion
48921
3aa5ba679145 Remove the concept of an instance. This means that a lot of functions have
Nick Roberts <nickrob@snap.net.nz>
parents: 48884
diff changeset
2133 (set-buffer (gdb-get-buffer 'gdb-breakpoints-buffer))
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2134 (goto-char (point-min))
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2135 (while (< (point) (- (point-max) 1))
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2136 (forward-line 1)
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2137 (if (looking-at "[^\t].*breakpoint")
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2138 (progn
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2139 (looking-at
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2140 "\\([0-9]*\\)\\s-*\\S-*\\s-*\\S-*\\s-*\\(.\\)\\s-*0x0\\(\\S-*\\)")
48662
d29870d63092 Fix up comment markers.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48661
diff changeset
2141 ;; info break gives '0x0' (8 digit) while dump gives '0x' (7 digit)
48641
da382393fb77 Get rid of (quote ..); use match-string and ignore.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48640
diff changeset
2142 (setq address (concat "0x" (match-string 3)))
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2143 (setq flag (char-after (match-beginning 2)))
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2144 (save-excursion
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2145 (set-buffer buffer)
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2146 (goto-char (point-min))
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2147 (if (re-search-forward address nil t)
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2148 (let ((start (progn (beginning-of-line) (- (point) 1)))
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2149 (end (progn (end-of-line) (+ (point) 1))))
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2150 (if (display-graphic-p)
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2151 (progn
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2152 (remove-images start end)
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2153 (if (eq ?y flag)
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2154 (put-image breakpoint-enabled-icon (point)
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2155 "breakpoint icon enabled"
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2156 'left-margin)
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2157 (put-image breakpoint-disabled-icon (point)
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2158 "breakpoint icon disabled"
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2159 'left-margin)))
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2160 (remove-strings start end)
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2161 (if (eq ?y flag)
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2162 (put-string "B" (point) "enabled" 'left-margin)
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2163 (put-string "b" (point) "disabled"
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2164 'left-margin))))))))))
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2165 (if gdb-current-address
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2166 (set-window-point (get-buffer-window buffer) gdb-arrow-position))))
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2167
48661
b092bff770ec Fold top-level `setq's and `define-key's into their corresponding defvar.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48659
diff changeset
2168 (defvar gdb-assembler-mode-map
b092bff770ec Fold top-level `setq's and `define-key's into their corresponding defvar.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48659
diff changeset
2169 (let ((map (make-sparse-keymap)))
b092bff770ec Fold top-level `setq's and `define-key's into their corresponding defvar.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48659
diff changeset
2170 (suppress-keymap map)
b092bff770ec Fold top-level `setq's and `define-key's into their corresponding defvar.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48659
diff changeset
2171 map))
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2172
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2173 (defun gdb-assembler-mode ()
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2174 "Major mode for viewing code assembler.
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2175
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2176 \\{gdb-assembler-mode-map}"
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2177 (setq major-mode 'gdb-assembler-mode)
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2178 (setq mode-name "Assembler")
48515
3216cd45d6d2 Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents: 48498
diff changeset
2179 (setq left-margin-width 2)
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2180 (setq buffer-read-only t)
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2181 (use-local-map gdb-assembler-mode-map)
48515
3216cd45d6d2 Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents: 48498
diff changeset
2182 (gdb-invalidate-assembler)
3216cd45d6d2 Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents: 48498
diff changeset
2183 (gdb-invalidate-breakpoints))
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2184
48515
3216cd45d6d2 Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents: 48498
diff changeset
2185 (defun gdb-assembler-buffer-name ()
48685
19bf840bede8 Replace uses of (gdb-get-instance-buffer 'gdba) and
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48682
diff changeset
2186 (with-current-buffer gud-comint-buffer
48921
3aa5ba679145 Remove the concept of an instance. This means that a lot of functions have
Nick Roberts <nickrob@snap.net.nz>
parents: 48884
diff changeset
2187 (concat "*Machine Code " (gdb-get-target-string) "*")))
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2188
48515
3216cd45d6d2 Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents: 48498
diff changeset
2189 (defun gdb-display-assembler-buffer ()
48659
4d69c0f01cc0 (gdb-inferior-io-mode-map): Remove (unused).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48641
diff changeset
2190 (interactive)
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2191 (gdb-display-buffer
48921
3aa5ba679145 Remove the concept of an instance. This means that a lot of functions have
Nick Roberts <nickrob@snap.net.nz>
parents: 48884
diff changeset
2192 (gdb-get-create-buffer 'gdb-assembler-buffer)))
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2193
48515
3216cd45d6d2 Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents: 48498
diff changeset
2194 (defun gdb-frame-assembler-buffer ()
48659
4d69c0f01cc0 (gdb-inferior-io-mode-map): Remove (unused).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48641
diff changeset
2195 (interactive)
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2196 (switch-to-buffer-other-frame
48921
3aa5ba679145 Remove the concept of an instance. This means that a lot of functions have
Nick Roberts <nickrob@snap.net.nz>
parents: 48884
diff changeset
2197 (gdb-get-create-buffer 'gdb-assembler-buffer)))
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2198
48515
3216cd45d6d2 Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents: 48498
diff changeset
2199 (defun gdb-invalidate-frame-and-assembler (&optional ignored)
3216cd45d6d2 Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents: 48498
diff changeset
2200 (gdb-invalidate-frames)
3216cd45d6d2 Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents: 48498
diff changeset
2201 (gdb-invalidate-assembler))
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2202
48515
3216cd45d6d2 Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents: 48498
diff changeset
2203 (defun gdb-invalidate-breakpoints-and-assembler (&optional ignored)
3216cd45d6d2 Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents: 48498
diff changeset
2204 (gdb-invalidate-breakpoints)
3216cd45d6d2 Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents: 48498
diff changeset
2205 (gdb-invalidate-assembler))
3216cd45d6d2 Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents: 48498
diff changeset
2206
3216cd45d6d2 Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents: 48498
diff changeset
2207 (defvar gdb-prev-main-or-pc nil)
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2208
48662
d29870d63092 Fix up comment markers.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48661
diff changeset
2209 ;; modified because if gdb-main-or-pc has changed value a new command
d29870d63092 Fix up comment markers.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48661
diff changeset
2210 ;; must be enqueued to update the buffer with the new output
48515
3216cd45d6d2 Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents: 48498
diff changeset
2211 (defun gdb-invalidate-assembler (&optional ignored)
48921
3aa5ba679145 Remove the concept of an instance. This means that a lot of functions have
Nick Roberts <nickrob@snap.net.nz>
parents: 48884
diff changeset
2212 (if (and (gdb-get-buffer 'gdb-assembler-buffer)
48641
da382393fb77 Get rid of (quote ..); use match-string and ignore.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48640
diff changeset
2213 (or (not (member 'gdb-invalidate-assembler
48921
3aa5ba679145 Remove the concept of an instance. This means that a lot of functions have
Nick Roberts <nickrob@snap.net.nz>
parents: 48884
diff changeset
2214 (gdb-get-pending-triggers)))
48641
da382393fb77 Get rid of (quote ..); use match-string and ignore.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48640
diff changeset
2215 (not (string-equal gdb-main-or-pc gdb-prev-main-or-pc))))
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2216 (progn
48641
da382393fb77 Get rid of (quote ..); use match-string and ignore.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48640
diff changeset
2217 ;; take previous disassemble command off the queue
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2218 (save-excursion
48685
19bf840bede8 Replace uses of (gdb-get-instance-buffer 'gdba) and
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48682
diff changeset
2219 (set-buffer gud-comint-buffer)
48641
da382393fb77 Get rid of (quote ..); use match-string and ignore.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48640
diff changeset
2220 (let ((queue gdb-idle-input-queue) (item))
da382393fb77 Get rid of (quote ..); use match-string and ignore.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48640
diff changeset
2221 (while queue
da382393fb77 Get rid of (quote ..); use match-string and ignore.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48640
diff changeset
2222 (setq item (car queue))
da382393fb77 Get rid of (quote ..); use match-string and ignore.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48640
diff changeset
2223 (if (equal (cdr item) '(gdb-assembler-handler))
da382393fb77 Get rid of (quote ..); use match-string and ignore.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48640
diff changeset
2224 (delete item gdb-idle-input-queue))
da382393fb77 Get rid of (quote ..); use match-string and ignore.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48640
diff changeset
2225 (setq queue (cdr queue)))))
48921
3aa5ba679145 Remove the concept of an instance. This means that a lot of functions have
Nick Roberts <nickrob@snap.net.nz>
parents: 48884
diff changeset
2226 (gdb-enqueue-idle-input
48515
3216cd45d6d2 Major re-organisation. Simplify legacy gdba code to allow only one gdb process.
Nick Roberts <nickrob@snap.net.nz>
parents: 48498
diff changeset
2227 (list (concat "server disassemble " gdb-main-or-pc "\n")
48641
da382393fb77 Get rid of (quote ..); use match-string and ignore.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48640
diff changeset
2228 'gdb-assembler-handler))
48921
3aa5ba679145 Remove the concept of an instance. This means that a lot of functions have
Nick Roberts <nickrob@snap.net.nz>
parents: 48884
diff changeset
2229 (gdb-set-pending-triggers
48641
da382393fb77 Get rid of (quote ..); use match-string and ignore.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48640
diff changeset
2230 (cons 'gdb-invalidate-assembler
48921
3aa5ba679145 Remove the concept of an instance. This means that a lot of functions have
Nick Roberts <nickrob@snap.net.nz>
parents: 48884
diff changeset
2231 (gdb-get-pending-triggers)))
48641
da382393fb77 Get rid of (quote ..); use match-string and ignore.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48640
diff changeset
2232 (setq gdb-prev-main-or-pc gdb-main-or-pc))))
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2233
48955
1abfa35a3a5a (gdb-display-number-end): Make auto-display of
Nick Roberts <nickrob@snap.net.nz>
parents: 48921
diff changeset
2234 (defun gdb-get-current-frame ()
1abfa35a3a5a (gdb-display-number-end): Make auto-display of
Nick Roberts <nickrob@snap.net.nz>
parents: 48921
diff changeset
2235 (if (not (member 'gdb-get-current-frame (gdb-get-pending-triggers)))
1abfa35a3a5a (gdb-display-number-end): Make auto-display of
Nick Roberts <nickrob@snap.net.nz>
parents: 48921
diff changeset
2236 (progn
1abfa35a3a5a (gdb-display-number-end): Make auto-display of
Nick Roberts <nickrob@snap.net.nz>
parents: 48921
diff changeset
2237 (gdb-enqueue-idle-input
1abfa35a3a5a (gdb-display-number-end): Make auto-display of
Nick Roberts <nickrob@snap.net.nz>
parents: 48921
diff changeset
2238 (list (concat "server frame\n") 'gdb-frame-handler))
1abfa35a3a5a (gdb-display-number-end): Make auto-display of
Nick Roberts <nickrob@snap.net.nz>
parents: 48921
diff changeset
2239 (gdb-set-pending-triggers
1abfa35a3a5a (gdb-display-number-end): Make auto-display of
Nick Roberts <nickrob@snap.net.nz>
parents: 48921
diff changeset
2240 (cons 'gdb-get-current-frame
1abfa35a3a5a (gdb-display-number-end): Make auto-display of
Nick Roberts <nickrob@snap.net.nz>
parents: 48921
diff changeset
2241 (gdb-get-pending-triggers))))))
1abfa35a3a5a (gdb-display-number-end): Make auto-display of
Nick Roberts <nickrob@snap.net.nz>
parents: 48921
diff changeset
2242
1abfa35a3a5a (gdb-display-number-end): Make auto-display of
Nick Roberts <nickrob@snap.net.nz>
parents: 48921
diff changeset
2243 (defun gdb-frame-handler ()
1abfa35a3a5a (gdb-display-number-end): Make auto-display of
Nick Roberts <nickrob@snap.net.nz>
parents: 48921
diff changeset
2244 (gdb-set-pending-triggers
1abfa35a3a5a (gdb-display-number-end): Make auto-display of
Nick Roberts <nickrob@snap.net.nz>
parents: 48921
diff changeset
2245 (delq 'gdb-get-current-frame (gdb-get-pending-triggers)))
1abfa35a3a5a (gdb-display-number-end): Make auto-display of
Nick Roberts <nickrob@snap.net.nz>
parents: 48921
diff changeset
2246 (save-excursion
1abfa35a3a5a (gdb-display-number-end): Make auto-display of
Nick Roberts <nickrob@snap.net.nz>
parents: 48921
diff changeset
2247 (set-buffer (gdb-get-create-buffer 'gdb-partial-output-buffer))
1abfa35a3a5a (gdb-display-number-end): Make auto-display of
Nick Roberts <nickrob@snap.net.nz>
parents: 48921
diff changeset
2248 (goto-char (point-min))
49039
6c5f45b01d2e Acknowledge Tom Lord as author of gdba.el.
Nick Roberts <nickrob@snap.net.nz>
parents: 49000
diff changeset
2249 (if (looking-at "^#[0-9]*\\s-*0x\\S-* in \\(\\S-*\\)")
6c5f45b01d2e Acknowledge Tom Lord as author of gdba.el.
Nick Roberts <nickrob@snap.net.nz>
parents: 49000
diff changeset
2250 (setq gdb-current-frame (match-string 1))
6c5f45b01d2e Acknowledge Tom Lord as author of gdba.el.
Nick Roberts <nickrob@snap.net.nz>
parents: 49000
diff changeset
2251 (if (looking-at "^#[0-9]*\\s-*\\(\\S-*\\)")
6c5f45b01d2e Acknowledge Tom Lord as author of gdba.el.
Nick Roberts <nickrob@snap.net.nz>
parents: 49000
diff changeset
2252 (setq gdb-current-frame (match-string 1))))))
48955
1abfa35a3a5a (gdb-display-number-end): Make auto-display of
Nick Roberts <nickrob@snap.net.nz>
parents: 48921
diff changeset
2253
48292
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2254 (provide 'gdb-ui)
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2255
27d9e4538750 New file.
Nick Roberts <nickrob@snap.net.nz>
parents:
diff changeset
2256 ;;; gdb-ui.el ends here