annotate lisp/gdb-ui.el @ 48440:7aad36bad1cc

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