annotate lisp/gdb-ui.el @ 48662:d29870d63092

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