annotate lisp/gdb-ui.el @ 48715:1e0c7ad65f05

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