]> code.delx.au - gnu-emacs/blob - lisp/progmodes/gdb-ui.el
(gdb-ann3): Move definition of gud-pp to here.
[gnu-emacs] / lisp / progmodes / gdb-ui.el
1 ;;; gdb-ui.el --- User Interface for running GDB
2
3 ;; Author: Nick Roberts <nickrob@gnu.org>
4 ;; Maintainer: FSF
5 ;; Keywords: unix, tools
6
7 ;; Copyright (C) 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
8
9 ;; This file is part of GNU Emacs.
10
11 ;; GNU Emacs is free software; you can redistribute it and/or modify
12 ;; it under the terms of the GNU General Public License as published by
13 ;; the Free Software Foundation; either version 2, or (at your option)
14 ;; any later version.
15
16 ;; GNU Emacs is distributed in the hope that it will be useful,
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 ;; GNU General Public License for more details.
20
21 ;; You should have received a copy of the GNU General Public License
22 ;; along with GNU Emacs; see the file COPYING. If not, write to the
23 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
24 ;; Boston, MA 02110-1301, USA.
25
26 ;;; Commentary:
27
28 ;; This mode acts as a graphical user interface to GDB. You can interact with
29 ;; GDB through the GUD buffer in the usual way, but there are also further
30 ;; buffers which control the execution and describe the state of your program.
31 ;; It separates the input/output of your program from that of GDB, if
32 ;; required, and watches expressions in the speedbar. It also uses features of
33 ;; Emacs 21 such as the fringe/display margin for breakpoints, and the toolbar
34 ;; (see the GDB Graphical Interface section in the Emacs info manual).
35
36 ;; By default, M-x gdb will start the debugger. However, if you have customised
37 ;; gud-gdb-command-name, then start it with M-x gdba.
38
39 ;; This file has evolved from gdba.el that was included with GDB 5.0 and
40 ;; written by Tom Lord and Jim Kingdon. It uses GDB's annotation interface.
41 ;; You don't need to know about annotations to use this mode as a debugger,
42 ;; but if you are interested developing the mode itself, then see the
43 ;; Annotations section in the GDB info manual.
44 ;;
45 ;; GDB developers plan to make the annotation interface obsolete. A new
46 ;; interface called GDB/MI (machine interface) has been designed to replace
47 ;; it. Some GDB/MI commands are used in this file through the CLI command
48 ;; 'interpreter mi <mi-command>'. A file called gdb-mi.el is included with
49 ;; GDB (6.2 onwards) that uses GDB/MI as the primary interface to GDB. It is
50 ;; still under development and is part of a process to migrate Emacs from
51 ;; annotations to GDB/MI.
52 ;;
53 ;; This mode SHOULD WORK WITH GDB 5.0 ONWARDS but you will NEED GDB 6.0
54 ;; ONWARDS TO USE WATCH EXPRESSIONS.
55 ;;
56 ;; Windows Platforms:
57 ;;
58 ;; If you are using Emacs and GDB on Windows you will need to flush the buffer
59 ;; explicitly in your program if you want timely display of I/O in Emacs.
60 ;; Alternatively you can make the output stream unbuffered, for example, by
61 ;; using a macro:
62 ;;
63 ;; #ifdef UNBUFFERED
64 ;; setvbuf (stdout, (char *) NULL, _IONBF, 0);
65 ;; #endif
66 ;;
67 ;; and compiling with -DUNBUFFERED while debugging.
68 ;;
69 ;; Known Bugs:
70 ;;
71 ;; TODO:
72 ;; 1) Use MI command -data-read-memory for memory window.
73 ;; 2) Highlight changed register values (use MI commands
74 ;; -data-list-register-values and -data-list-changed-registers instead
75 ;; of 'info registers'.
76 ;; 3) Use tree-widget.el instead of the speedbar for watch-expressions?
77 ;; 4) Mark breakpoint locations on scroll-bar of source buffer?
78 ;; 5) After release of 22.1 use '-var-list-children --all-values'
79 ;; and '-stack-list-locals 2' which need GDB 6.1 onwards.
80 ;; 6) With gud-print and gud-pstar, print the variable name in the GUD
81 ;; buffer instead of the value's history number.
82
83 ;;; Code:
84
85 (require 'gud)
86
87 (defvar tool-bar-map)
88
89 (defvar gdb-frame-address "main" "Initialization for Assembler buffer.")
90 (defvar gdb-previous-frame-address nil)
91 (defvar gdb-memory-address "main")
92 (defvar gdb-previous-frame nil)
93 (defvar gdb-selected-frame nil)
94 (defvar gdb-frame-number nil)
95 (defvar gdb-current-language nil)
96 (defvar gdb-var-list nil "List of variables in watch window.")
97 (defvar gdb-var-changed nil "Non-nil means that `gdb-var-list' has changed.")
98 (defvar gdb-main-file nil "Source file from which program execution begins.")
99 (defvar gdb-overlay-arrow-position nil)
100 (defvar gdb-server-prefix nil)
101 (defvar gdb-flush-pending-output nil)
102 (defvar gdb-location-alist nil
103 "Alist of breakpoint numbers and full filenames.")
104 (defvar gdb-find-file-unhook nil)
105 (defvar gdb-active-process nil "GUD tooltips display variable values when t, \
106 and #define directives otherwise.")
107 (defvar gdb-error "Non-nil when GDB is reporting an error.")
108 (defvar gdb-macro-info nil
109 "Non-nil if GDB knows that the inferior includes preprocessor macro info.")
110 (defvar gdb-buffer-fringe-width nil)
111
112 (defvar gdb-buffer-type nil
113 "One of the symbols bound in `gdb-buffer-rules'.")
114 (make-variable-buffer-local 'gdb-buffer-type)
115
116 (defvar gdb-input-queue ()
117 "A list of gdb command objects.")
118
119 (defvar gdb-prompting nil
120 "True when gdb is idle with no pending input.")
121
122 (defvar gdb-output-sink 'user
123 "The disposition of the output of the current gdb command.
124 Possible values are these symbols:
125
126 `user' -- gdb output should be copied to the GUD buffer
127 for the user to see.
128
129 `inferior' -- gdb output should be copied to the inferior-io buffer.
130
131 `pre-emacs' -- output should be ignored util the post-prompt
132 annotation is received. Then the output-sink
133 becomes:...
134 `emacs' -- output should be collected in the partial-output-buffer
135 for subsequent processing by a command. This is the
136 disposition of output generated by commands that
137 gdb mode sends to gdb on its own behalf.
138 `post-emacs' -- ignore output until the prompt annotation is
139 received, then go to USER disposition.
140
141 gdba (gdb-ui.el) uses all five values, gdbmi (gdb-mi.el) only two
142 \(`user' and `emacs').")
143
144 (defvar gdb-current-item nil
145 "The most recent command item sent to gdb.")
146
147 (defvar gdb-pending-triggers '()
148 "A list of trigger functions that have run later than their output
149 handlers.")
150
151 ;; end of gdb variables
152
153 ;;;###autoload
154 (defun gdba (command-line)
155 "Run gdb on program FILE in buffer *gud-FILE*.
156 The directory containing FILE becomes the initial working directory
157 and source-file directory for your debugger.
158
159 If `gdb-many-windows' is nil (the default value) then gdb just
160 pops up the GUD buffer unless `gdb-show-main' is t. In this case
161 it starts with two windows: one displaying the GUD buffer and the
162 other with the source file with the main routine of the inferior.
163
164 If `gdb-many-windows' is t, regardless of the value of
165 `gdb-show-main', the layout below will appear unless
166 `gdb-use-inferior-io-buffer' is nil when the source buffer
167 occupies the full width of the frame. Keybindings are given in
168 relevant buffer.
169
170 Watch expressions appear in the speedbar/slowbar.
171
172 The following commands help control operation :
173
174 `gdb-many-windows' - Toggle the number of windows gdb uses.
175 `gdb-restore-windows' - To restore the window layout.
176
177 See Info node `(emacs)GDB Graphical Interface' for a more
178 detailed description of this mode.
179
180
181 +--------------------------------------------------------------+
182 | GDB Toolbar |
183 +-------------------------------+------------------------------+
184 | GUD buffer (I/O of GDB) | Locals buffer |
185 | | |
186 | | |
187 | | |
188 +-------------------------------+------------------------------+
189 | Source buffer | I/O buffer (of inferior) |
190 | | (comint-mode) |
191 | | |
192 | | |
193 | | |
194 | | |
195 | | |
196 | | |
197 +-------------------------------+------------------------------+
198 | Stack buffer | Breakpoints buffer |
199 | RET gdb-frames-select | SPC gdb-toggle-breakpoint |
200 | | RET gdb-goto-breakpoint |
201 | | d gdb-delete-breakpoint |
202 +-------------------------------+------------------------------+"
203 ;;
204 (interactive (list (gud-query-cmdline 'gdba)))
205 ;;
206 ;; Let's start with a basic gud-gdb buffer and then modify it a bit.
207 (gdb command-line)
208 (gdb-ann3))
209
210 (defvar gdb-debug-log nil)
211
212 ;;;###autoload
213 (defcustom gdb-enable-debug-log nil
214 "Non-nil means record the process input and output in `gdb-debug-log'."
215 :type 'boolean
216 :group 'gud
217 :version "22.1")
218
219 (defcustom gdb-cpp-define-alist-program "gcc -E -dM -"
220 "Shell command for generating a list of defined macros in a source file.
221 This list is used to display the #define directive associated
222 with an identifier as a tooltip. It works in a debug session with
223 GDB, when gud-tooltip-mode is t.
224
225 Set `gdb-cpp-define-alist-flags' for any include paths or
226 predefined macros."
227 :type 'string
228 :group 'gud
229 :version "22.1")
230
231 (defcustom gdb-cpp-define-alist-flags ""
232 "Preprocessor flags for `gdb-cpp-define-alist-program'."
233 :type 'string
234 :group 'gud
235 :version "22.1")
236
237 (defcustom gdb-show-main nil
238 "Non-nil means display source file containing the main routine at startup.
239 Also display the main routine in the disassembly buffer if present."
240 :type 'boolean
241 :group 'gud
242 :version "22.1")
243
244 (defcustom gdb-use-inferior-io-buffer nil
245 "Non-nil means display output from the inferior in a separate buffer."
246 :type 'boolean
247 :group 'gud
248 :version "22.1")
249
250 (defun gdb-use-inferior-io-buffer (arg)
251 "Toggle separate IO for inferior.
252 With arg, use separate IO iff arg is positive."
253 (interactive "P")
254 (setq gdb-use-inferior-io-buffer
255 (if (null arg)
256 (not gdb-use-inferior-io-buffer)
257 (> (prefix-numeric-value arg) 0)))
258 (if (and gud-comint-buffer
259 (buffer-name gud-comint-buffer))
260 (condition-case nil
261 (if gdb-use-inferior-io-buffer
262 (gdb-restore-windows)
263 (kill-buffer (gdb-inferior-io-name)))
264 (error nil))))
265
266 (defvar gdb-define-alist nil "Alist of #define directives for GUD tooltips.")
267
268 (defun gdb-create-define-alist ()
269 "Create an alist of #define directives for GUD tooltips."
270 (let* ((file (buffer-file-name))
271 (output
272 (with-output-to-string
273 (with-current-buffer standard-output
274 (call-process shell-file-name
275 (if (file-exists-p file) file nil)
276 (list t nil) nil "-c"
277 (concat gdb-cpp-define-alist-program " "
278 gdb-cpp-define-alist-flags)))))
279 (define-list (split-string output "\n" t))
280 (name))
281 (setq gdb-define-alist nil)
282 (dolist (define define-list)
283 (setq name (nth 1 (split-string define "[( ]")))
284 (push (cons name define) gdb-define-alist))))
285
286 (defun gdb-tooltip-print ()
287 (tooltip-show
288 (with-current-buffer (gdb-get-buffer 'gdb-partial-output-buffer)
289 (let ((string (buffer-string)))
290 ;; remove newline for gud-tooltip-echo-area
291 (substring string 0 (- (length string) 1))))
292 (or gud-tooltip-echo-area tooltip-use-echo-area)))
293
294 ;; If expr is a macro for a function don't print because of possible dangerous
295 ;; side-effects. Also printing a function within a tooltip generates an
296 ;; unexpected starting annotation (phase error).
297 (defun gdb-tooltip-print-1 (expr)
298 (with-current-buffer (gdb-get-buffer 'gdb-partial-output-buffer)
299 (goto-char (point-min))
300 (if (search-forward "expands to: " nil t)
301 (unless (looking-at "\\S-+.*(.*).*")
302 (gdb-enqueue-input
303 (list (concat gdb-server-prefix "print " expr "\n")
304 'gdb-tooltip-print))))))
305
306 (defun gdb-set-gud-minor-mode (buffer)
307 "Set `gud-minor-mode' from find-file if appropriate."
308 (goto-char (point-min))
309 (unless (search-forward "No source file named " nil t)
310 (condition-case nil
311 (gdb-enqueue-input
312 (list (concat gdb-server-prefix "info source\n")
313 `(lambda () (gdb-set-gud-minor-mode-1 ,buffer))))
314 (error (setq gdb-find-file-unhook t)))))
315
316 (defun gdb-set-gud-minor-mode-1 (buffer)
317 (goto-char (point-min))
318 (when (and (search-forward "Located in " nil t)
319 (looking-at "\\S-+")
320 (string-equal (buffer-file-name buffer)
321 (match-string 0)))
322 (with-current-buffer buffer
323 (set (make-local-variable 'gud-minor-mode) 'gdba)
324 (set (make-local-variable 'tool-bar-map) gud-tool-bar-map)
325 (when gud-tooltip-mode
326 (make-local-variable 'gdb-define-alist)
327 (gdb-create-define-alist)
328 (add-hook 'after-save-hook 'gdb-create-define-alist nil t)))))
329
330 (defun gdb-set-gud-minor-mode-existing-buffers ()
331 (dolist (buffer (buffer-list))
332 (let ((file (buffer-file-name buffer)))
333 (if file
334 (progn
335 (gdb-enqueue-input
336 (list (concat gdb-server-prefix "list "
337 (file-name-nondirectory file) ":1\n")
338 `(lambda () (gdb-set-gud-minor-mode ,buffer)))))))))
339
340 (defun gdb-find-watch-expression ()
341 (let* ((var (nth (- (line-number-at-pos (point)) 2) gdb-var-list))
342 (varno (nth 1 var)) (expr))
343 (string-match "\\(var[0-9]+\\)\\.\\(.*\\)" varno)
344 (dolist (var1 gdb-var-list)
345 (if (string-equal (nth 1 var1) (match-string 1 varno))
346 (setq expr (concat (car var1) "." (match-string 2 varno)))))
347 expr))
348
349 (defun gdb-ann3 ()
350 (setq gdb-debug-log nil)
351 (set (make-local-variable 'gud-minor-mode) 'gdba)
352 (set (make-local-variable 'gud-marker-filter) 'gud-gdba-marker-filter)
353 ;;
354 (gud-def gud-break (if (not (string-match "Machine" mode-name))
355 (gud-call "break %f:%l" arg)
356 (save-excursion
357 (beginning-of-line)
358 (forward-char 2)
359 (gud-call "break *%a" arg)))
360 "\C-b" "Set breakpoint at current line or address.")
361 ;;
362 (gud-def gud-remove (if (not (string-match "Machine" mode-name))
363 (gud-call "clear %f:%l" arg)
364 (save-excursion
365 (beginning-of-line)
366 (forward-char 2)
367 (gud-call "clear *%a" arg)))
368 "\C-d" "Remove breakpoint at current line or address.")
369 ;;
370 (gud-def gud-until (if (not (string-match "Machine" mode-name))
371 (gud-call "until %f:%l" arg)
372 (save-excursion
373 (beginning-of-line)
374 (forward-char 2)
375 (gud-call "until *%a" arg)))
376 "\C-u" "Continue to current line or address.")
377 ;;
378 (gud-def gud-go (gud-call (if gdb-active-process "continue" "run") arg)
379 nil "Start or continue execution.")
380
381 ;; For debugging Emacs only.
382 (gud-def gud-pp
383 (gud-call
384 (concat
385 "pp1 " (if (eq (buffer-local-value
386 'major-mode (window-buffer)) 'speedbar-mode)
387 (gdb-find-watch-expression) "%e")) arg)
388 nil "Print the emacs s-expression.")
389
390 (define-key gud-minor-mode-map [left-margin mouse-1]
391 'gdb-mouse-set-clear-breakpoint)
392 (define-key gud-minor-mode-map [left-fringe mouse-1]
393 'gdb-mouse-set-clear-breakpoint)
394 (define-key gud-minor-mode-map [left-fringe mouse-2]
395 'gdb-mouse-until)
396 (define-key gud-minor-mode-map [left-fringe drag-mouse-1]
397 'gdb-mouse-until)
398 (define-key gud-minor-mode-map [left-margin mouse-3]
399 'gdb-mouse-toggle-breakpoint-margin)
400 (define-key gud-minor-mode-map [left-fringe mouse-3]
401 'gdb-mouse-toggle-breakpoint-fringe)
402
403 (setq comint-input-sender 'gdb-send)
404 ;;
405 ;; (re-)initialize
406 (setq gdb-frame-address (if gdb-show-main "main" nil))
407 (setq gdb-previous-frame-address nil
408 gdb-memory-address "main"
409 gdb-previous-frame nil
410 gdb-selected-frame nil
411 gdb-current-language nil
412 gdb-frame-number nil
413 gdb-var-list nil
414 gdb-var-changed nil
415 gdb-first-prompt nil
416 gdb-prompting nil
417 gdb-input-queue nil
418 gdb-current-item nil
419 gdb-pending-triggers nil
420 gdb-output-sink 'user
421 gdb-server-prefix "server "
422 gdb-flush-pending-output nil
423 gdb-location-alist nil
424 gdb-find-file-unhook nil
425 gdb-error nil
426 gdb-macro-info nil
427 gdb-buffer-fringe-width (car (window-fringes)))
428 ;;
429 (setq gdb-buffer-type 'gdba)
430 ;;
431 (if gdb-use-inferior-io-buffer (gdb-clear-inferior-io))
432 ;;
433 (if (eq window-system 'w32)
434 (gdb-enqueue-input (list "set new-console off\n" 'ignore)))
435 (gdb-enqueue-input (list "set height 0\n" 'ignore))
436 (gdb-enqueue-input (list "set width 0\n" 'ignore))
437 ;; find source file and compilation directory here
438 (gdb-enqueue-input (list "server list main\n" 'ignore)) ; C program
439 (gdb-enqueue-input (list "server list MAIN__\n" 'ignore)) ; Fortran program
440 (gdb-enqueue-input (list "server info source\n" 'gdb-source-info))
441 ;;
442 (gdb-set-gud-minor-mode-existing-buffers)
443 (run-hooks 'gdba-mode-hook))
444
445 (defun gdb-mouse-until (event)
446 "Execute source lines by dragging the overlay arrow (fringe) with the mouse."
447 (interactive "e")
448 (if gud-overlay-arrow-position
449 (let ((start (event-start event))
450 (end (event-end event))
451 (buffer (marker-buffer gud-overlay-arrow-position)) (line))
452 (if (not (string-match "Machine" mode-name))
453 (if (equal buffer (window-buffer (posn-window end)))
454 (with-current-buffer buffer
455 (when (or (equal start end)
456 (equal (posn-point start)
457 (marker-position
458 gud-overlay-arrow-position)))
459 (setq line (line-number-at-pos (posn-point end)))
460 (gud-call (concat "until " (number-to-string line))))))
461 (if (equal (marker-buffer gdb-overlay-arrow-position)
462 (window-buffer (posn-window end)))
463 (when (or (equal start end)
464 (equal (posn-point start)
465 (marker-position
466 gdb-overlay-arrow-position)))
467 (save-excursion
468 (goto-line (line-number-at-pos (posn-point end)))
469 (forward-char 2)
470 (gud-call (concat "until *%a")))))))))
471
472 (defcustom gdb-use-colon-colon-notation nil
473 "If non-nil use FUN::VAR format to display variables in the speedbar."
474 :type 'boolean
475 :group 'gud
476 :version "22.1")
477
478 (defun gud-watch ()
479 "Watch expression at point."
480 (interactive)
481 (require 'tooltip)
482 (save-selected-window
483 (let ((expr (tooltip-identifier-from-point (point))))
484 (if (and (string-equal gdb-current-language "c")
485 gdb-use-colon-colon-notation gdb-selected-frame)
486 (setq expr (concat gdb-selected-frame "::" expr)))
487 (catch 'already-watched
488 (dolist (var gdb-var-list)
489 (if (string-equal expr (car var)) (throw 'already-watched nil)))
490 (set-text-properties 0 (length expr) nil expr)
491 (gdb-enqueue-input
492 (list
493 (if (eq gud-minor-mode 'gdba)
494 (concat "server interpreter mi \"-var-create - * " expr "\"\n")
495 (concat"-var-create - * " expr "\n"))
496 `(lambda () (gdb-var-create-handler ,expr))))))))
497
498 (defconst gdb-var-create-regexp
499 "name=\"\\(.*?\\)\",numchild=\"\\(.*?\\)\",type=\"\\(.*?\\)\"")
500
501 (defun gdb-var-create-handler (expr)
502 (with-current-buffer (gdb-get-create-buffer 'gdb-partial-output-buffer)
503 (goto-char (point-min))
504 (if (re-search-forward gdb-var-create-regexp nil t)
505 (let ((var (list expr
506 (match-string 1)
507 (match-string 2)
508 (match-string 3)
509 nil nil)))
510 (push var gdb-var-list)
511 (speedbar 1)
512 (unless (string-equal
513 speedbar-initial-expansion-list-name "GUD")
514 (speedbar-change-initial-expansion-list "GUD"))
515 (if (or (equal (nth 2 var) "0")
516 (and (equal (nth 2 var) "1")
517 (string-match "char \\*" (nth 3 var))))
518 (gdb-enqueue-input
519 (list
520 (if (eq (buffer-local-value 'gud-minor-mode gud-comint-buffer)
521 'gdba)
522 (concat "server interpreter mi \"-var-evaluate-expression "
523 (nth 1 var) "\"\n")
524 (concat "-var-evaluate-expression " (nth 1 var) "\n"))
525 `(lambda () (gdb-var-evaluate-expression-handler
526 ,(nth 1 var) nil))))
527 (setq gdb-var-changed t)))
528 (if (re-search-forward "Undefined command" nil t)
529 (message-box "Watching expressions requires gdb 6.0 onwards")
530 (message "No symbol \"%s\" in current context." expr)))))
531
532 (defun gdb-var-evaluate-expression-handler (varnum changed)
533 (with-current-buffer (gdb-get-create-buffer 'gdb-partial-output-buffer)
534 (goto-char (point-min))
535 (re-search-forward ".*value=\\(\".*\"\\)" nil t)
536 (catch 'var-found
537 (let ((num 0))
538 (dolist (var gdb-var-list)
539 (if (string-equal varnum (cadr var))
540 (progn
541 (if changed (setcar (nthcdr 5 var) t))
542 (setcar (nthcdr 4 var) (read (match-string 1)))
543 (setcar (nthcdr num gdb-var-list) var)
544 (throw 'var-found nil)))
545 (setq num (+ num 1))))))
546 (setq gdb-var-changed t))
547
548 (defun gdb-var-list-children (varnum)
549 (gdb-enqueue-input
550 (list (concat "server interpreter mi \"-var-list-children " varnum "\"\n")
551 `(lambda () (gdb-var-list-children-handler ,varnum)))))
552
553 (defconst gdb-var-list-children-regexp
554 "name=\"\\(.*?\\)\",exp=\"\\(.*?\\)\",numchild=\"\\(.*?\\)\",\
555 type=\"\\(.*?\\)\"")
556
557 (defun gdb-var-list-children-handler (varnum)
558 (with-current-buffer (gdb-get-create-buffer 'gdb-partial-output-buffer)
559 (goto-char (point-min))
560 (let ((var-list nil))
561 (catch 'child-already-watched
562 (dolist (var gdb-var-list)
563 (if (string-equal varnum (cadr var))
564 (progn
565 (push var var-list)
566 (while (re-search-forward gdb-var-list-children-regexp nil t)
567 (let ((varchild (list (match-string 2)
568 (match-string 1)
569 (match-string 3)
570 (match-string 4)
571 nil nil)))
572 (dolist (var1 gdb-var-list)
573 (if (string-equal (cadr var1) (cadr varchild))
574 (throw 'child-already-watched nil)))
575 (push varchild var-list)
576 (if (or (equal (nth 2 varchild) "0")
577 (and (equal (nth 2 varchild) "1")
578 (string-match "char \\*" (nth 3 varchild))))
579 (gdb-enqueue-input
580 (list
581 (concat
582 "server interpreter mi \"-var-evaluate-expression "
583 (nth 1 varchild) "\"\n")
584 `(lambda () (gdb-var-evaluate-expression-handler
585 ,(nth 1 varchild) nil))))))))
586 (push var var-list)))
587 (setq gdb-var-list (nreverse var-list))))))
588
589 (defun gdb-var-update ()
590 (when (not (member 'gdb-var-update gdb-pending-triggers))
591 (gdb-enqueue-input
592 (list "server interpreter mi \"-var-update *\"\n"
593 'gdb-var-update-handler))
594 (push 'gdb-var-update gdb-pending-triggers)))
595
596 (defconst gdb-var-update-regexp "name=\"\\(.*?\\)\"")
597
598 (defun gdb-var-update-handler ()
599 (with-current-buffer (gdb-get-create-buffer 'gdb-partial-output-buffer)
600 (goto-char (point-min))
601 (while (re-search-forward gdb-var-update-regexp nil t)
602 (catch 'var-found-1
603 (let ((varnum (match-string 1)))
604 (dolist (var gdb-var-list)
605 (when (and (string-equal varnum (cadr var))
606 (or (equal (nth 2 var) "0")
607 (and (equal (nth 2 var) "1")
608 (string-match "char \\*" (nth 3 var)))))
609 (gdb-enqueue-input
610 (list
611 (concat "server interpreter mi \"-var-evaluate-expression "
612 varnum "\"\n")
613 `(lambda () (gdb-var-evaluate-expression-handler ,varnum t))))
614 (throw 'var-found-1 nil)))))))
615 (setq gdb-pending-triggers
616 (delq 'gdb-var-update gdb-pending-triggers))
617 (when (and (boundp 'speedbar-frame) (frame-live-p speedbar-frame))
618 ;; Dummy command to update speedbar at right time.
619 (gdb-enqueue-input (list "server pwd\n" 'gdb-speedbar-timer-fn))
620 ;; Keep gdb-pending-triggers non-nil till end.
621 (push 'gdb-speedbar-timer gdb-pending-triggers)))
622
623 (defun gdb-speedbar-timer-fn ()
624 (setq gdb-pending-triggers
625 (delq 'gdb-speedbar-timer gdb-pending-triggers))
626 (with-current-buffer gud-comint-buffer
627 (speedbar-timer-fn)))
628
629 (defun gdb-var-delete ()
630 "Delete watch expression at point from the speedbar."
631 (interactive)
632 (if (memq (buffer-local-value 'gud-minor-mode gud-comint-buffer)
633 '(gdbmi gdba))
634 (let ((text (speedbar-line-text)))
635 (string-match "\\(\\S-+\\)" text)
636 (let* ((expr (match-string 1 text))
637 (var (assoc expr gdb-var-list))
638 (varnum (cadr var)))
639 (unless (string-match "\\." varnum)
640 (gdb-enqueue-input
641 (list
642 (if (eq (buffer-local-value 'gud-minor-mode gud-comint-buffer)
643 'gdba)
644 (concat "server interpreter mi \"-var-delete " varnum "\"\n")
645 (concat "-var-delete " varnum "\n"))
646 'ignore))
647 (setq gdb-var-list (delq var gdb-var-list))
648 (dolist (varchild gdb-var-list)
649 (if (string-match (concat (nth 1 var) "\\.") (nth 1 varchild))
650 (setq gdb-var-list (delq varchild gdb-var-list))))
651 (setq gdb-var-changed t))))))
652
653 (defun gdb-edit-value (text token indent)
654 "Assign a value to a variable displayed in the speedbar."
655 (let* ((var (nth (- (count-lines (point-min) (point)) 2) gdb-var-list))
656 (varnum (cadr var)) (value))
657 (setq value (read-string "New value: "))
658 (gdb-enqueue-input
659 (list
660 (if (eq (buffer-local-value 'gud-minor-mode gud-comint-buffer) 'gdba)
661 (concat "server interpreter mi \"-var-assign "
662 varnum " " value "\"\n")
663 (concat "-var-assign " varnum " " value "\n"))
664 'ignore))))
665
666 (defcustom gdb-show-changed-values t
667 "If non-nil highlight values that have recently changed in the speedbar.
668 The highlighting is done with `font-lock-warning-face'."
669 :type 'boolean
670 :group 'gud
671 :version "22.1")
672
673 (defun gdb-speedbar-expand-node (text token indent)
674 "Expand the node the user clicked on.
675 TEXT is the text of the button we clicked on, a + or - item.
676 TOKEN is data related to this node.
677 INDENT is the current indentation depth."
678 (cond ((string-match "+" text) ;expand this node
679 (if (eq (buffer-local-value 'gud-minor-mode gud-comint-buffer) 'gdba)
680 (gdb-var-list-children token)
681 (progn
682 (gdbmi-var-update)
683 (gdbmi-var-list-children token))))
684 ((string-match "-" text) ;contract this node
685 (dolist (var gdb-var-list)
686 (if (string-match (concat token "\\.") (nth 1 var))
687 (setq gdb-var-list (delq var gdb-var-list))))
688 (setq gdb-var-changed t)
689 (with-current-buffer gud-comint-buffer
690 (speedbar-timer-fn)))))
691
692 (defun gdb-get-target-string ()
693 (with-current-buffer gud-comint-buffer
694 gud-target-name))
695 \f
696
697 ;;
698 ;; gdb buffers.
699 ;;
700 ;; Each buffer has a TYPE -- a symbol that identifies the function
701 ;; of that particular buffer.
702 ;;
703 ;; The usual gdb interaction buffer is given the type `gdba' and
704 ;; is constructed specially.
705 ;;
706 ;; Others are constructed by gdb-get-create-buffer and
707 ;; named according to the rules set forth in the gdb-buffer-rules-assoc
708
709 (defvar gdb-buffer-rules-assoc '())
710
711 (defun gdb-get-buffer (key)
712 "Return the gdb buffer tagged with type KEY.
713 The key should be one of the cars in `gdb-buffer-rules-assoc'."
714 (save-excursion
715 (gdb-look-for-tagged-buffer key (buffer-list))))
716
717 (defun gdb-get-create-buffer (key)
718 "Create a new gdb buffer of the type specified by KEY.
719 The key should be one of the cars in `gdb-buffer-rules-assoc'."
720 (or (gdb-get-buffer key)
721 (let* ((rules (assoc key gdb-buffer-rules-assoc))
722 (name (funcall (gdb-rules-name-maker rules)))
723 (new (get-buffer-create name)))
724 (with-current-buffer new
725 (let ((trigger))
726 (if (cdr (cdr rules))
727 (setq trigger (funcall (car (cdr (cdr rules))))))
728 (setq gdb-buffer-type key)
729 (set (make-local-variable 'gud-minor-mode)
730 (buffer-local-value 'gud-minor-mode gud-comint-buffer))
731 (set (make-local-variable 'tool-bar-map) gud-tool-bar-map)
732 (if trigger (funcall trigger)))
733 new))))
734
735 (defun gdb-rules-name-maker (rules) (car (cdr rules)))
736
737 (defun gdb-look-for-tagged-buffer (key bufs)
738 (let ((retval nil))
739 (while (and (not retval) bufs)
740 (set-buffer (car bufs))
741 (if (eq gdb-buffer-type key)
742 (setq retval (car bufs)))
743 (setq bufs (cdr bufs)))
744 retval))
745
746 ;;
747 ;; This assoc maps buffer type symbols to rules. Each rule is a list of
748 ;; at least one and possible more functions. The functions have these
749 ;; roles in defining a buffer type:
750 ;;
751 ;; NAME - Return a name for this buffer type.
752 ;;
753 ;; The remaining function(s) are optional:
754 ;;
755 ;; MODE - called in a new buffer with no arguments, should establish
756 ;; the proper mode for the buffer.
757 ;;
758
759 (defun gdb-set-buffer-rules (buffer-type &rest rules)
760 (let ((binding (assoc buffer-type gdb-buffer-rules-assoc)))
761 (if binding
762 (setcdr binding rules)
763 (push (cons buffer-type rules)
764 gdb-buffer-rules-assoc))))
765
766 ;; GUD buffers are an exception to the rules
767 (gdb-set-buffer-rules 'gdba 'error)
768
769 ;;
770 ;; Partial-output buffer : This accumulates output from a command executed on
771 ;; behalf of emacs (rather than the user).
772 ;;
773 (gdb-set-buffer-rules 'gdb-partial-output-buffer
774 'gdb-partial-output-name)
775
776 (defun gdb-partial-output-name ()
777 (concat "*partial-output-"
778 (gdb-get-target-string)
779 "*"))
780
781 \f
782 (gdb-set-buffer-rules 'gdb-inferior-io
783 'gdb-inferior-io-name
784 'gdb-inferior-io-mode)
785
786 (defun gdb-inferior-io-name ()
787 (concat "*input/output of "
788 (gdb-get-target-string)
789 "*"))
790
791 (defun gdb-display-inferior-io-buffer ()
792 "Display IO of inferior in a separate window."
793 (interactive)
794 (if gdb-use-inferior-io-buffer
795 (gdb-display-buffer
796 (gdb-get-create-buffer 'gdb-inferior-io))))
797
798 (defconst gdb-frame-parameters
799 '((height . 14) (width . 80)
800 (unsplittable . t)
801 (tool-bar-lines . nil)
802 (menu-bar-lines . nil)
803 (minibuffer . nil)))
804
805 (defun gdb-frame-inferior-io-buffer ()
806 "Display IO of inferior in a new frame."
807 (interactive)
808 (if gdb-use-inferior-io-buffer
809 (let ((special-display-regexps (append special-display-regexps '(".*")))
810 (special-display-frame-alist gdb-frame-parameters))
811 (display-buffer (gdb-get-create-buffer 'gdb-inferior-io)))))
812
813 (defvar gdb-inferior-io-mode-map
814 (let ((map (make-sparse-keymap)))
815 (define-key map "\C-c\C-c" 'gdb-inferior-io-interrupt)
816 (define-key map "\C-c\C-z" 'gdb-inferior-io-stop)
817 (define-key map "\C-c\C-\\" 'gdb-inferior-io-quit)
818 (define-key map "\C-c\C-d" 'gdb-inferior-io-eof)
819 (define-key map "\C-d" 'gdb-inferior-io-eof)
820 map))
821
822 (define-derived-mode gdb-inferior-io-mode comint-mode "Inferior I/O"
823 "Major mode for gdb inferior-io."
824 :syntax-table nil :abbrev-table nil
825 ;; We want to use comint because it has various nifty and familiar
826 ;; features. We don't need a process, but comint wants one, so create
827 ;; a dummy one.
828 (make-comint-in-buffer
829 (substring (buffer-name) 1 (- (length (buffer-name)) 1))
830 (current-buffer) "hexl")
831 (setq comint-input-sender 'gdb-inferior-io-sender))
832
833 (defun gdb-inferior-io-sender (proc string)
834 ;; PROC is the pseudo-process created to satisfy comint.
835 (with-current-buffer (process-buffer proc)
836 (setq proc (get-buffer-process gud-comint-buffer))
837 (process-send-string proc string)
838 (process-send-string proc "\n")))
839
840 (defun gdb-inferior-io-interrupt ()
841 "Interrupt the program being debugged."
842 (interactive)
843 (interrupt-process
844 (get-buffer-process gud-comint-buffer) comint-ptyp))
845
846 (defun gdb-inferior-io-quit ()
847 "Send quit signal to the program being debugged."
848 (interactive)
849 (quit-process
850 (get-buffer-process gud-comint-buffer) comint-ptyp))
851
852 (defun gdb-inferior-io-stop ()
853 "Stop the program being debugged."
854 (interactive)
855 (stop-process
856 (get-buffer-process gud-comint-buffer) comint-ptyp))
857
858 (defun gdb-inferior-io-eof ()
859 "Send end-of-file to the program being debugged."
860 (interactive)
861 (process-send-eof
862 (get-buffer-process gud-comint-buffer)))
863 \f
864
865 ;;
866 ;; gdb communications
867 ;;
868
869 ;; INPUT: things sent to gdb
870 ;;
871 ;; The queues are lists. Each element is either a string (indicating user or
872 ;; user-like input) or a list of the form:
873 ;;
874 ;; (INPUT-STRING HANDLER-FN)
875 ;;
876 ;; The handler function will be called from the partial-output buffer when the
877 ;; command completes. This is the way to write commands which invoke gdb
878 ;; commands autonomously.
879 ;;
880 ;; These lists are consumed tail first.
881 ;;
882
883 (defun gdb-send (proc string)
884 "A comint send filter for gdb.
885 This filter may simply queue input for a later time."
886 (with-current-buffer gud-comint-buffer
887 (let ((inhibit-read-only t))
888 (remove-text-properties (point-min) (point-max) '(face))))
889 (let ((item (concat string "\n")))
890 (if gud-running
891 (progn
892 (if gdb-enable-debug-log (push (cons 'send item) gdb-debug-log))
893 (process-send-string proc item))
894 (gdb-enqueue-input item))))
895
896 ;; Note: Stuff enqueued here will be sent to the next prompt, even if it
897 ;; is a query, or other non-top-level prompt.
898
899 (defun gdb-enqueue-input (item)
900 (if gdb-prompting
901 (progn
902 (gdb-send-item item)
903 (setq gdb-prompting nil))
904 (push item gdb-input-queue)))
905
906 (defun gdb-dequeue-input ()
907 (let ((queue gdb-input-queue))
908 (and queue
909 (let ((last (car (last queue))))
910 (unless (nbutlast queue) (setq gdb-input-queue '()))
911 last))))
912
913 (defun gdb-send-item (item)
914 (setq gdb-flush-pending-output nil)
915 (if gdb-enable-debug-log (push (cons 'send-item item) gdb-debug-log))
916 (setq gdb-current-item item)
917 (let ((process (get-buffer-process gud-comint-buffer)))
918 (if (eq (buffer-local-value 'gud-minor-mode gud-comint-buffer) 'gdba)
919 (if (stringp item)
920 (progn
921 (setq gdb-output-sink 'user)
922 (process-send-string process item))
923 (progn
924 (gdb-clear-partial-output)
925 (setq gdb-output-sink 'pre-emacs)
926 (process-send-string process
927 (car item))))
928 ;; case: eq gud-minor-mode 'gdbmi
929 (gdb-clear-partial-output)
930 (setq gdb-output-sink 'emacs)
931 (process-send-string process (car item)))))
932 \f
933 ;;
934 ;; output -- things gdb prints to emacs
935 ;;
936 ;; GDB output is a stream interrupted by annotations.
937 ;; Annotations can be recognized by their beginning
938 ;; with \C-j\C-z\C-z<tag><opt>\C-j
939 ;;
940 ;; The tag is a string obeying symbol syntax.
941 ;;
942 ;; The optional part `<opt>' can be either the empty string
943 ;; or a space followed by more data relating to the annotation.
944 ;; For example, the SOURCE annotation is followed by a filename,
945 ;; line number and various useless goo. This data must not include
946 ;; any newlines.
947 ;;
948
949 (defcustom gud-gdba-command-name "gdb -annotate=3"
950 "Default command to execute an executable under the GDB-UI debugger."
951 :type 'string
952 :group 'gud
953 :version "22.1")
954
955 (defvar gdb-annotation-rules
956 '(("pre-prompt" gdb-pre-prompt)
957 ("prompt" gdb-prompt)
958 ("commands" gdb-subprompt)
959 ("overload-choice" gdb-subprompt)
960 ("query" gdb-subprompt)
961 ;; Need this prompt for GDB 6.1
962 ("nquery" gdb-subprompt)
963 ("prompt-for-continue" gdb-subprompt)
964 ("post-prompt" gdb-post-prompt)
965 ("source" gdb-source)
966 ("starting" gdb-starting)
967 ("exited" gdb-exited)
968 ("signalled" gdb-exited)
969 ("signal" gdb-stopping)
970 ("breakpoint" gdb-stopping)
971 ("watchpoint" gdb-stopping)
972 ("frame-begin" gdb-frame-begin)
973 ("stopped" gdb-stopped)
974 ("error-begin" gdb-error)
975 ("error" gdb-error)
976 ) "An assoc mapping annotation tags to functions which process them.")
977
978 (defun gdb-resync()
979 (setq gdb-flush-pending-output t)
980 (setq gud-running nil)
981 (setq gdb-output-sink 'user)
982 (setq gdb-input-queue nil)
983 (setq gdb-pending-triggers nil)
984 (setq gdb-prompting t))
985
986 (defconst gdb-source-spec-regexp
987 "\\(.*\\):\\([0-9]*\\):[0-9]*:[a-z]*:0x0*\\([a-f0-9]*\\)")
988
989 ;; Do not use this except as an annotation handler.
990 (defun gdb-source (args)
991 (string-match gdb-source-spec-regexp args)
992 ;; Extract the frame position from the marker.
993 (setq gud-last-frame
994 (cons
995 (match-string 1 args)
996 (string-to-number (match-string 2 args))))
997 (setq gdb-frame-address (match-string 3 args))
998 ;; cover for auto-display output which comes *before*
999 ;; stopped annotation
1000 (if (eq gdb-output-sink 'inferior) (setq gdb-output-sink 'user)))
1001
1002 (defun gdb-pre-prompt (ignored)
1003 "An annotation handler for `pre-prompt'.
1004 This terminates the collection of output from a previous command if that
1005 happens to be in effect."
1006 (let ((sink gdb-output-sink))
1007 (cond
1008 ((eq sink 'user) t)
1009 ((eq sink 'emacs)
1010 (setq gdb-output-sink 'post-emacs))
1011 (t
1012 (gdb-resync)
1013 (error "Phase error in gdb-pre-prompt (got %s)" sink)))))
1014
1015 (defun gdb-prompt (ignored)
1016 "An annotation handler for `prompt'.
1017 This sends the next command (if any) to gdb."
1018 (when gdb-first-prompt (gdb-ann3))
1019 (let ((sink gdb-output-sink))
1020 (cond
1021 ((eq sink 'user) t)
1022 ((eq sink 'post-emacs)
1023 (setq gdb-output-sink 'user)
1024 (let ((handler
1025 (car (cdr gdb-current-item))))
1026 (with-current-buffer (gdb-get-create-buffer 'gdb-partial-output-buffer)
1027 (funcall handler))))
1028 (t
1029 (gdb-resync)
1030 (error "Phase error in gdb-prompt (got %s)" sink))))
1031 (let ((input (gdb-dequeue-input)))
1032 (if input
1033 (gdb-send-item input)
1034 (progn
1035 (setq gdb-prompting t)
1036 (gud-display-frame)))))
1037
1038 (defun gdb-subprompt (ignored)
1039 "An annotation handler for non-top-level prompts."
1040 (setq gdb-prompting t))
1041
1042 (defun gdb-starting (ignored)
1043 "An annotation handler for `starting'.
1044 This says that I/O for the subprocess is now the program being debugged,
1045 not GDB."
1046 (setq gdb-active-process t)
1047 (let ((sink gdb-output-sink))
1048 (cond
1049 ((eq sink 'user)
1050 (progn
1051 (setq gud-running t)
1052 (if gdb-use-inferior-io-buffer
1053 (setq gdb-output-sink 'inferior))))
1054 (t
1055 (gdb-resync)
1056 (error "Unexpected `starting' annotation")))))
1057
1058 (defun gdb-stopping (ignored)
1059 "An annotation handler for `breakpoint' and other annotations.
1060 They say that I/O for the subprocess is now GDB, not the program
1061 being debugged."
1062 (if gdb-use-inferior-io-buffer
1063 (let ((sink gdb-output-sink))
1064 (cond
1065 ((eq sink 'inferior)
1066 (setq gdb-output-sink 'user))
1067 (t
1068 (gdb-resync)
1069 (error "Unexpected stopping annotation"))))))
1070
1071 (defun gdb-exited (ignored)
1072 "An annotation handler for `exited' and `signalled'.
1073 They say that I/O for the subprocess is now GDB, not the program
1074 being debugged and that the program is no longer running. This
1075 function is used to change the focus of GUD tooltips to #define
1076 directives."
1077 (setq gdb-active-process nil)
1078 (setq gud-overlay-arrow-position nil)
1079 (setq gdb-overlay-arrow-position nil)
1080 (gdb-stopping ignored))
1081
1082 (defun gdb-frame-begin (ignored)
1083 (let ((sink gdb-output-sink))
1084 (cond
1085 ((eq sink 'inferior)
1086 (setq gdb-output-sink 'user))
1087 ((eq sink 'user) t)
1088 ((eq sink 'emacs) t)
1089 (t
1090 (gdb-resync)
1091 (error "Unexpected frame-begin annotation (%S)" sink)))))
1092
1093 (defun gdb-stopped (ignored)
1094 "An annotation handler for `stopped'.
1095 It is just like `gdb-stopping', except that if we already set the output
1096 sink to `user' in `gdb-stopping', that is fine."
1097 (setq gud-running nil)
1098 (let ((sink gdb-output-sink))
1099 (cond
1100 ((eq sink 'inferior)
1101 (setq gdb-output-sink 'user))
1102 ((eq sink 'user) t)
1103 (t
1104 (gdb-resync)
1105 (error "Unexpected stopped annotation")))))
1106
1107 (defun gdb-error (ignored)
1108 (setq gdb-error (not gdb-error)))
1109
1110 (defun gdb-post-prompt (ignored)
1111 "An annotation handler for `post-prompt'.
1112 This begins the collection of output from the current command if that
1113 happens to be appropriate."
1114 (unless gdb-pending-triggers
1115 (gdb-get-selected-frame)
1116 (gdb-invalidate-frames)
1117 (gdb-invalidate-breakpoints)
1118 ;; Do this through gdb-get-selected-frame -> gdb-frame-handler
1119 ;; so gdb-frame-address is updated.
1120 ;; (gdb-invalidate-assembler)
1121 (gdb-invalidate-registers)
1122 (gdb-invalidate-memory)
1123 (gdb-invalidate-locals)
1124 (gdb-invalidate-threads)
1125 (unless (eq system-type 'darwin) ;Breaks on Darwin's GDB-5.3.
1126 ;; FIXME: with GDB-6 on Darwin, this might very well work.
1127 ;; Only needed/used with speedbar/watch expressions.
1128 (when (and (boundp 'speedbar-frame) (frame-live-p speedbar-frame))
1129 (setq gdb-var-changed t) ; force update
1130 (dolist (var gdb-var-list)
1131 (setcar (nthcdr 5 var) nil))
1132 (gdb-var-update))))
1133 (let ((sink gdb-output-sink))
1134 (cond
1135 ((eq sink 'user) t)
1136 ((eq sink 'pre-emacs)
1137 (setq gdb-output-sink 'emacs))
1138 (t
1139 (gdb-resync)
1140 (error "Phase error in gdb-post-prompt (got %s)" sink)))))
1141
1142 (defun gud-gdba-marker-filter (string)
1143 "A gud marker filter for gdb. Handle a burst of output from GDB."
1144 (if gdb-flush-pending-output
1145 nil
1146 (if gdb-enable-debug-log (push (cons 'recv string) gdb-debug-log))
1147 ;; Recall the left over gud-marker-acc from last time.
1148 (setq gud-marker-acc (concat gud-marker-acc string))
1149 ;; Start accumulating output for the GUD buffer.
1150 (let ((output ""))
1151 ;;
1152 ;; Process all the complete markers in this chunk.
1153 (while (string-match "\n\032\032\\(.*\\)\n" gud-marker-acc)
1154 (let ((annotation (match-string 1 gud-marker-acc)))
1155 ;;
1156 ;; Stuff prior to the match is just ordinary output.
1157 ;; It is either concatenated to OUTPUT or directed
1158 ;; elsewhere.
1159 (setq output
1160 (gdb-concat-output
1161 output
1162 (substring gud-marker-acc 0 (match-beginning 0))))
1163 ;;
1164 ;; Take that stuff off the gud-marker-acc.
1165 (setq gud-marker-acc (substring gud-marker-acc (match-end 0)))
1166 ;;
1167 ;; Parse the tag from the annotation, and maybe its arguments.
1168 (string-match "\\(\\S-*\\) ?\\(.*\\)" annotation)
1169 (let* ((annotation-type (match-string 1 annotation))
1170 (annotation-arguments (match-string 2 annotation))
1171 (annotation-rule (assoc annotation-type
1172 gdb-annotation-rules)))
1173 ;; Call the handler for this annotation.
1174 (if annotation-rule
1175 (funcall (car (cdr annotation-rule))
1176 annotation-arguments)
1177 ;; Else the annotation is not recognized. Ignore it silently,
1178 ;; so that GDB can add new annotations without causing
1179 ;; us to blow up.
1180 ))))
1181 ;;
1182 ;; Does the remaining text end in a partial line?
1183 ;; If it does, then keep part of the gud-marker-acc until we get more.
1184 (if (string-match "\n\\'\\|\n\032\\'\\|\n\032\032.*\\'"
1185 gud-marker-acc)
1186 (progn
1187 ;; Everything before the potential marker start can be output.
1188 (setq output
1189 (gdb-concat-output output
1190 (substring gud-marker-acc 0
1191 (match-beginning 0))))
1192 ;;
1193 ;; Everything after, we save, to combine with later input.
1194 (setq gud-marker-acc (substring gud-marker-acc
1195 (match-beginning 0))))
1196 ;;
1197 ;; In case we know the gud-marker-acc contains no partial annotations:
1198 (progn
1199 (setq output (gdb-concat-output output gud-marker-acc))
1200 (setq gud-marker-acc "")))
1201 output)))
1202
1203 (defun gdb-concat-output (so-far new)
1204 (if gdb-error
1205 (put-text-property 0 (length new) 'face font-lock-warning-face new))
1206 (let ((sink gdb-output-sink))
1207 (cond
1208 ((eq sink 'user) (concat so-far new))
1209 ((or (eq sink 'pre-emacs) (eq sink 'post-emacs)) so-far)
1210 ((eq sink 'emacs)
1211 (gdb-append-to-partial-output new)
1212 so-far)
1213 ((eq sink 'inferior)
1214 (gdb-append-to-inferior-io new)
1215 so-far)
1216 (t
1217 (gdb-resync)
1218 (error "Bogon output sink %S" sink)))))
1219
1220 (defun gdb-append-to-partial-output (string)
1221 (with-current-buffer (gdb-get-create-buffer 'gdb-partial-output-buffer)
1222 (goto-char (point-max))
1223 (insert string)))
1224
1225 (defun gdb-clear-partial-output ()
1226 (with-current-buffer (gdb-get-create-buffer 'gdb-partial-output-buffer)
1227 (erase-buffer)))
1228
1229 (defun gdb-append-to-inferior-io (string)
1230 (with-current-buffer (gdb-get-create-buffer 'gdb-inferior-io)
1231 (goto-char (point-max))
1232 (insert-before-markers string))
1233 (if (not (string-equal string ""))
1234 (gdb-display-buffer (gdb-get-create-buffer 'gdb-inferior-io))))
1235
1236 (defun gdb-clear-inferior-io ()
1237 (with-current-buffer (gdb-get-create-buffer 'gdb-inferior-io)
1238 (erase-buffer)))
1239 \f
1240
1241 ;; One trick is to have a command who's output is always available in a buffer
1242 ;; of it's own, and is always up to date. We build several buffers of this
1243 ;; type.
1244 ;;
1245 ;; There are two aspects to this: gdb has to tell us when the output for that
1246 ;; command might have changed, and we have to be able to run the command
1247 ;; behind the user's back.
1248 ;;
1249 ;; The output phasing associated with the variable gdb-output-sink
1250 ;; help us to run commands behind the user's back.
1251 ;;
1252 ;; Below is the code for specificly managing buffers of output from one
1253 ;; command.
1254 ;;
1255
1256 ;; The trigger function is suitable for use in the assoc GDB-ANNOTATION-RULES
1257 ;; It adds an input for the command we are tracking. It should be the
1258 ;; annotation rule binding of whatever gdb sends to tell us this command
1259 ;; might have changed it's output.
1260 ;;
1261 ;; NAME is the function name. DEMAND-PREDICATE tests if output is really needed.
1262 ;; GDB-COMMAND is a string of such. OUTPUT-HANDLER is the function bound to the
1263 ;; input in the input queue (see comment about ``gdb communications'' above).
1264
1265 (defmacro def-gdb-auto-update-trigger (name demand-predicate gdb-command
1266 output-handler)
1267 `(defun ,name (&optional ignored)
1268 (if (and ,demand-predicate
1269 (not (member ',name
1270 gdb-pending-triggers)))
1271 (progn
1272 (gdb-enqueue-input
1273 (list ,gdb-command ',output-handler))
1274 (push ',name gdb-pending-triggers)))))
1275
1276 (defmacro def-gdb-auto-update-handler (name trigger buf-key custom-defun)
1277 `(defun ,name ()
1278 (setq gdb-pending-triggers
1279 (delq ',trigger
1280 gdb-pending-triggers))
1281 (let ((buf (gdb-get-buffer ',buf-key)))
1282 (and buf
1283 (with-current-buffer buf
1284 (let* ((window (get-buffer-window buf 0))
1285 (p (window-point window))
1286 (buffer-read-only nil))
1287 (erase-buffer)
1288 (insert-buffer-substring (gdb-get-create-buffer
1289 'gdb-partial-output-buffer))
1290 (set-window-point window p)))))
1291 ;; put customisation here
1292 (,custom-defun)))
1293
1294 (defmacro def-gdb-auto-updated-buffer (buffer-key
1295 trigger-name gdb-command
1296 output-handler-name custom-defun)
1297 `(progn
1298 (def-gdb-auto-update-trigger ,trigger-name
1299 ;; The demand predicate:
1300 (gdb-get-buffer ',buffer-key)
1301 ,gdb-command
1302 ,output-handler-name)
1303 (def-gdb-auto-update-handler ,output-handler-name
1304 ,trigger-name ,buffer-key ,custom-defun)))
1305
1306 \f
1307 ;;
1308 ;; Breakpoint buffer : This displays the output of `info breakpoints'.
1309 ;;
1310 (gdb-set-buffer-rules 'gdb-breakpoints-buffer
1311 'gdb-breakpoints-buffer-name
1312 'gdb-breakpoints-mode)
1313
1314 (def-gdb-auto-updated-buffer gdb-breakpoints-buffer
1315 ;; This defines the auto update rule for buffers of type
1316 ;; `gdb-breakpoints-buffer'.
1317 ;;
1318 ;; It defines a function to serve as the annotation handler that
1319 ;; handles the `foo-invalidated' message. That function is called:
1320 gdb-invalidate-breakpoints
1321 ;;
1322 ;; To update the buffer, this command is sent to gdb.
1323 "server info breakpoints\n"
1324 ;;
1325 ;; This also defines a function to be the handler for the output
1326 ;; from the command above. That function will copy the output into
1327 ;; the appropriately typed buffer. That function will be called:
1328 gdb-info-breakpoints-handler
1329 ;; buffer specific functions
1330 gdb-info-breakpoints-custom)
1331
1332 (defconst breakpoint-xpm-data
1333 "/* XPM */
1334 static char *magick[] = {
1335 /* columns rows colors chars-per-pixel */
1336 \"10 10 2 1\",
1337 \" c red\",
1338 \"+ c None\",
1339 /* pixels */
1340 \"+++ +++\",
1341 \"++ ++\",
1342 \"+ +\",
1343 \" \",
1344 \" \",
1345 \" \",
1346 \" \",
1347 \"+ +\",
1348 \"++ ++\",
1349 \"+++ +++\",
1350 };"
1351 "XPM data used for breakpoint icon.")
1352
1353 (defconst breakpoint-enabled-pbm-data
1354 "P1
1355 10 10\",
1356 0 0 0 0 1 1 1 1 0 0 0 0
1357 0 0 0 1 1 1 1 1 1 0 0 0
1358 0 0 1 1 1 1 1 1 1 1 0 0
1359 0 1 1 1 1 1 1 1 1 1 1 0
1360 0 1 1 1 1 1 1 1 1 1 1 0
1361 0 1 1 1 1 1 1 1 1 1 1 0
1362 0 1 1 1 1 1 1 1 1 1 1 0
1363 0 0 1 1 1 1 1 1 1 1 0 0
1364 0 0 0 1 1 1 1 1 1 0 0 0
1365 0 0 0 0 1 1 1 1 0 0 0 0"
1366 "PBM data used for enabled breakpoint icon.")
1367
1368 (defconst breakpoint-disabled-pbm-data
1369 "P1
1370 10 10\",
1371 0 0 1 0 1 0 1 0 0 0
1372 0 1 0 1 0 1 0 1 0 0
1373 1 0 1 0 1 0 1 0 1 0
1374 0 1 0 1 0 1 0 1 0 1
1375 1 0 1 0 1 0 1 0 1 0
1376 0 1 0 1 0 1 0 1 0 1
1377 1 0 1 0 1 0 1 0 1 0
1378 0 1 0 1 0 1 0 1 0 1
1379 0 0 1 0 1 0 1 0 1 0
1380 0 0 0 1 0 1 0 1 0 0"
1381 "PBM data used for disabled breakpoint icon.")
1382
1383 (defvar breakpoint-enabled-icon nil
1384 "Icon for enabled breakpoint in display margin.")
1385
1386 (defvar breakpoint-disabled-icon nil
1387 "Icon for disabled breakpoint in display margin.")
1388
1389 ;; Bitmap for breakpoint in fringe
1390 (and (display-images-p)
1391 (define-fringe-bitmap 'breakpoint
1392 "\x3c\x7e\xff\xff\xff\xff\x7e\x3c"))
1393
1394 (defface breakpoint-enabled
1395 '((t
1396 :foreground "red"
1397 :weight bold))
1398 "Face for enabled breakpoint icon in fringe."
1399 :group 'gud)
1400
1401 (defface breakpoint-disabled
1402 ;; We use different values of grey for different background types,
1403 ;; so that on low-color displays it will end up as something visible
1404 ;; if it has to be approximated.
1405 '((((background dark)) :foreground "grey60")
1406 (((background light)) :foreground "grey40"))
1407 "Face for disabled breakpoint icon in fringe."
1408 :group 'gud)
1409
1410 ;; Put breakpoint icons in relevant margins (even those set in the GUD buffer).
1411 (defun gdb-info-breakpoints-custom ()
1412 (let ((flag) (bptno))
1413 ;; Remove all breakpoint-icons in source buffers but not assembler buffer.
1414 (dolist (buffer (buffer-list))
1415 (with-current-buffer buffer
1416 (if (and (eq gud-minor-mode 'gdba)
1417 (not (string-match "\\`\\*.+\\*\\'" (buffer-name))))
1418 (gdb-remove-breakpoint-icons (point-min) (point-max)))))
1419 (with-current-buffer (gdb-get-buffer 'gdb-breakpoints-buffer)
1420 (save-excursion
1421 (goto-char (point-min))
1422 (while (< (point) (- (point-max) 1))
1423 (forward-line 1)
1424 (if (looking-at "[^\t].*?breakpoint")
1425 (progn
1426 (looking-at "\\([0-9]+\\)\\s-+\\S-+\\s-+\\S-+\\s-+\\(.\\)")
1427 (setq bptno (match-string 1))
1428 (setq flag (char-after (match-beginning 2)))
1429 (beginning-of-line)
1430 (if (re-search-forward " in \\(.*\\) at\\s-+" nil t)
1431 (progn
1432 (let ((buffer-read-only nil))
1433 (add-text-properties (match-beginning 1) (match-end 1)
1434 '(face font-lock-function-name-face)))
1435 (looking-at "\\(\\S-+\\):\\([0-9]+\\)")
1436 (let ((line (match-string 2)) (buffer-read-only nil)
1437 (file (match-string 1)))
1438 (add-text-properties (line-beginning-position)
1439 (line-end-position)
1440 '(mouse-face highlight
1441 help-echo "mouse-2, RET: visit breakpoint"))
1442 (unless (file-exists-p file)
1443 (setq file (cdr (assoc bptno gdb-location-alist))))
1444 (if (and file
1445 (not (string-equal file "File not found")))
1446 (with-current-buffer
1447 (find-file-noselect file 'nowarn)
1448 (set (make-local-variable 'gud-minor-mode)
1449 'gdba)
1450 (set (make-local-variable 'tool-bar-map)
1451 gud-tool-bar-map)
1452 ;; Only want one breakpoint icon at each
1453 ;; location.
1454 (save-excursion
1455 (goto-line (string-to-number line))
1456 (gdb-put-breakpoint-icon (eq flag ?y) bptno)))
1457 (gdb-enqueue-input
1458 (list
1459 (concat "list "
1460 (match-string-no-properties 1) ":1\n")
1461 'ignore))
1462 (gdb-enqueue-input
1463 (list "info source\n"
1464 `(lambda () (gdb-get-location
1465 ,bptno ,line ,flag))))))))))
1466 (end-of-line)))))
1467 (if (gdb-get-buffer 'gdb-assembler-buffer) (gdb-assembler-custom)))
1468
1469 (defun gdb-mouse-set-clear-breakpoint (event)
1470 "Set/clear breakpoint in left fringe/margin with mouse click."
1471 (interactive "e")
1472 (mouse-minibuffer-check event)
1473 (let ((posn (event-end event)))
1474 (if (numberp (posn-point posn))
1475 (with-selected-window (posn-window posn)
1476 (save-excursion
1477 (goto-char (posn-point posn))
1478 (if (or (posn-object posn)
1479 (eq (car (fringe-bitmaps-at-pos (posn-point posn)))
1480 'breakpoint))
1481 (gud-remove nil)
1482 (gud-break nil)))))))
1483
1484 (defun gdb-mouse-toggle-breakpoint-margin (event)
1485 "Enable/disable breakpoint in left margin with mouse click."
1486 (interactive "e")
1487 (mouse-minibuffer-check event)
1488 (let ((posn (event-end event)))
1489 (if (numberp (posn-point posn))
1490 (with-selected-window (posn-window posn)
1491 (save-excursion
1492 (goto-char (posn-point posn))
1493 (if (posn-object posn)
1494 (gdb-enqueue-input
1495 (list
1496 (let ((bptno (get-text-property
1497 0 'gdb-bptno (car (posn-string posn)))))
1498 (concat
1499 (if (get-text-property
1500 0 'gdb-enabled (car (posn-string posn)))
1501 "disable "
1502 "enable ")
1503 bptno "\n"))
1504 'ignore))))))))
1505
1506 (defun gdb-mouse-toggle-breakpoint-fringe (event)
1507 "Enable/disable breakpoint in left fringe with mouse click."
1508 (interactive "e")
1509 (mouse-minibuffer-check event)
1510 (let* ((posn (event-end event))
1511 (pos (posn-point posn))
1512 obj)
1513 (when (numberp pos)
1514 (with-selected-window (posn-window posn)
1515 (save-excursion
1516 (set-buffer (window-buffer (selected-window)))
1517 (goto-char pos)
1518 (dolist (overlay (overlays-in pos pos))
1519 (when (overlay-get overlay 'put-break)
1520 (setq obj (overlay-get overlay 'before-string))))
1521 (when (stringp obj)
1522 (gdb-enqueue-input
1523 (list
1524 (concat
1525 (if (get-text-property 0 'gdb-enabled obj)
1526 "disable "
1527 "enable ")
1528 (get-text-property 0 'gdb-bptno obj) "\n")
1529 'ignore))))))))
1530
1531 (defun gdb-breakpoints-buffer-name ()
1532 (with-current-buffer gud-comint-buffer
1533 (concat "*breakpoints of " (gdb-get-target-string) "*")))
1534
1535 (defun gdb-display-breakpoints-buffer ()
1536 "Display status of user-settable breakpoints."
1537 (interactive)
1538 (gdb-display-buffer
1539 (gdb-get-create-buffer 'gdb-breakpoints-buffer)))
1540
1541 (defun gdb-frame-breakpoints-buffer ()
1542 "Display status of user-settable breakpoints in a new frame."
1543 (interactive)
1544 (let ((special-display-regexps (append special-display-regexps '(".*")))
1545 (special-display-frame-alist gdb-frame-parameters))
1546 (display-buffer (gdb-get-create-buffer 'gdb-breakpoints-buffer))))
1547
1548 (defvar gdb-breakpoints-mode-map
1549 (let ((map (make-sparse-keymap))
1550 (menu (make-sparse-keymap "Breakpoints")))
1551 (define-key menu [quit] '("Quit" . kill-this-buffer))
1552 (define-key menu [goto] '("Goto" . gdb-goto-breakpoint))
1553 (define-key menu [delete] '("Delete" . gdb-delete-breakpoint))
1554 (define-key menu [toggle] '("Toggle" . gdb-toggle-breakpoint))
1555 (suppress-keymap map)
1556 (define-key map [menu-bar breakpoints] (cons "Breakpoints" menu))
1557 (define-key map " " 'gdb-toggle-breakpoint)
1558 (define-key map "d" 'gdb-delete-breakpoint)
1559 (define-key map "q" 'kill-this-buffer)
1560 (define-key map "\r" 'gdb-goto-breakpoint)
1561 (define-key map [mouse-2] 'gdb-goto-breakpoint)
1562 (define-key map [follow-link] 'mouse-face)
1563 map))
1564
1565 (defun gdb-breakpoints-mode ()
1566 "Major mode for gdb breakpoints.
1567
1568 \\{gdb-breakpoints-mode-map}"
1569 (kill-all-local-variables)
1570 (setq major-mode 'gdb-breakpoints-mode)
1571 (setq mode-name "Breakpoints")
1572 (use-local-map gdb-breakpoints-mode-map)
1573 (setq buffer-read-only t)
1574 (run-mode-hooks 'gdb-breakpoints-mode-hook)
1575 (if (eq (buffer-local-value 'gud-minor-mode gud-comint-buffer) 'gdba)
1576 'gdb-invalidate-breakpoints
1577 'gdbmi-invalidate-breakpoints))
1578
1579 (defun gdb-toggle-breakpoint ()
1580 "Enable/disable breakpoint at current line."
1581 (interactive)
1582 (save-excursion
1583 (beginning-of-line 1)
1584 (if (if (eq (buffer-local-value 'gud-minor-mode gud-comint-buffer) 'gdba)
1585 (looking-at "\\([0-9]+\\).*?point\\s-+\\S-+\\s-+\\(.\\)\\s-+")
1586 (looking-at
1587 "\\([0-9]+\\)\\s-+\\S-+\\s-+\\S-+\\s-+\\(.\\)\\s-+\\S-+\\s-+\\S-+:[0-9]+"))
1588 (gdb-enqueue-input
1589 (list
1590 (concat gdb-server-prefix
1591 (if (eq ?y (char-after (match-beginning 2)))
1592 "disable "
1593 "enable ")
1594 (match-string 1) "\n") 'ignore))
1595 (error "Not recognized as break/watchpoint line"))))
1596
1597 (defun gdb-delete-breakpoint ()
1598 "Delete the breakpoint at current line."
1599 (interactive)
1600 (beginning-of-line 1)
1601 (if (if (eq (buffer-local-value 'gud-minor-mode gud-comint-buffer) 'gdba)
1602 (looking-at "\\([0-9]+\\).*?point\\s-+\\S-+\\s-+\\(.\\)")
1603 (looking-at
1604 "\\([0-9]+\\)\\s-+\\S-+\\s-+\\S-+\\s-+\\s-+\\S-+\\s-+\\S-+:[0-9]+"))
1605 (gdb-enqueue-input
1606 (list
1607 (concat gdb-server-prefix "delete " (match-string 1) "\n") 'ignore))
1608 (error "Not recognized as break/watchpoint line")))
1609
1610 (defun gdb-goto-breakpoint (&optional event)
1611 "Display the breakpoint location specified at current line."
1612 (interactive (list last-input-event))
1613 (if event (mouse-set-point event))
1614 ;; Hack to stop gdb-goto-breakpoint displaying in GUD buffer.
1615 (let ((window (get-buffer-window gud-comint-buffer)))
1616 (if window (save-selected-window (select-window window))))
1617 (save-excursion
1618 (beginning-of-line 1)
1619 (if (if (eq (buffer-local-value 'gud-minor-mode gud-comint-buffer) 'gdba)
1620 (looking-at "\\([0-9]+\\) .+ in .+ at\\s-+\\(\\S-+\\):\\([0-9]+\\)")
1621 (looking-at
1622 "\\([0-9]+\\)\\s-+\\S-+\\s-+\\S-+\\s-+.\\s-+\\S-+\\s-+\
1623 \\(\\S-+\\):\\([0-9]+\\)"))
1624 (let ((bptno (match-string 1))
1625 (file (match-string 2))
1626 (line (match-string 3)))
1627 (save-selected-window
1628 (let* ((buf (find-file-noselect
1629 (if (file-exists-p file) file
1630 (cdr (assoc bptno gdb-location-alist)))))
1631 (window (display-buffer buf)))
1632 (with-current-buffer buf
1633 (goto-line (string-to-number line))
1634 (set-window-point window (point))))))
1635 (error "Not recognized as break/watchpoint line"))))
1636 \f
1637
1638 ;; Frames buffer. This displays a perpetually correct bactracktrace
1639 ;; (from the command `where').
1640 ;;
1641 ;; Alas, if your stack is deep, it is costly.
1642 ;;
1643 (gdb-set-buffer-rules 'gdb-stack-buffer
1644 'gdb-stack-buffer-name
1645 'gdb-frames-mode)
1646
1647 (def-gdb-auto-updated-buffer gdb-stack-buffer
1648 gdb-invalidate-frames
1649 "server where\n"
1650 gdb-info-frames-handler
1651 gdb-info-frames-custom)
1652
1653 (defun gdb-info-frames-custom ()
1654 (with-current-buffer (gdb-get-buffer 'gdb-stack-buffer)
1655 (save-excursion
1656 (let ((buffer-read-only nil)
1657 bl el)
1658 (goto-char (point-min))
1659 (while (< (point) (point-max))
1660 (setq bl (line-beginning-position)
1661 el (line-end-position))
1662 (unless (looking-at "No ")
1663 (add-text-properties bl el
1664 '(mouse-face highlight
1665 help-echo "mouse-2, RET: Select frame")))
1666 (goto-char bl)
1667 (when (looking-at "^#\\([0-9]+\\)")
1668 (when (string-equal (match-string 1) gdb-frame-number)
1669 (put-text-property bl (+ bl 4)
1670 'face '(:inverse-video t)))
1671 (when (re-search-forward
1672 (concat
1673 (if (string-equal (match-string 1) "0") "" " in ")
1674 "\\([^ ]+\\) (") el t)
1675 (put-text-property (match-beginning 1) (match-end 1)
1676 'face font-lock-function-name-face)
1677 (setq bl (match-end 0))
1678 (while (re-search-forward "<\\([^>]+\\)>" el t)
1679 (put-text-property (match-beginning 1) (match-end 1)
1680 'face font-lock-function-name-face))
1681 (goto-char bl)
1682 (while (re-search-forward "\\(\\(\\sw\\|[_.]\\)+\\)=" el t)
1683 (put-text-property (match-beginning 1) (match-end 1)
1684 'face font-lock-variable-name-face))))
1685 (forward-line 1))))))
1686
1687 (defun gdb-stack-buffer-name ()
1688 (with-current-buffer gud-comint-buffer
1689 (concat "*stack frames of " (gdb-get-target-string) "*")))
1690
1691 (defun gdb-display-stack-buffer ()
1692 "Display backtrace of current stack."
1693 (interactive)
1694 (gdb-display-buffer
1695 (gdb-get-create-buffer 'gdb-stack-buffer)))
1696
1697 (defun gdb-frame-stack-buffer ()
1698 "Display backtrace of current stack in a new frame."
1699 (interactive)
1700 (let ((special-display-regexps (append special-display-regexps '(".*")))
1701 (special-display-frame-alist gdb-frame-parameters))
1702 (display-buffer (gdb-get-create-buffer 'gdb-stack-buffer))))
1703
1704 (defvar gdb-frames-mode-map
1705 (let ((map (make-sparse-keymap)))
1706 (suppress-keymap map)
1707 (define-key map "q" 'kill-this-buffer)
1708 (define-key map "\r" 'gdb-frames-select)
1709 (define-key map [mouse-2] 'gdb-frames-select)
1710 (define-key map [follow-link] 'mouse-face)
1711 map))
1712
1713 (defun gdb-frames-mode ()
1714 "Major mode for gdb frames.
1715
1716 \\{gdb-frames-mode-map}"
1717 (kill-all-local-variables)
1718 (setq major-mode 'gdb-frames-mode)
1719 (setq mode-name "Frames")
1720 (setq buffer-read-only t)
1721 (use-local-map gdb-frames-mode-map)
1722 (font-lock-mode -1)
1723 (run-mode-hooks 'gdb-frames-mode-hook)
1724 (if (eq (buffer-local-value 'gud-minor-mode gud-comint-buffer) 'gdba)
1725 'gdb-invalidate-frames
1726 'gdbmi-invalidate-frames))
1727
1728 (defun gdb-get-frame-number ()
1729 (save-excursion
1730 (end-of-line)
1731 (let* ((pos (re-search-backward "^#*\\([0-9]*\\)" nil t))
1732 (n (or (and pos (match-string-no-properties 1)) "0")))
1733 n)))
1734
1735 (defun gdb-frames-select (&optional event)
1736 "Select the frame and display the relevant source."
1737 (interactive (list last-input-event))
1738 (if event (mouse-set-point event))
1739 (gdb-enqueue-input
1740 (list (concat gdb-server-prefix "frame "
1741 (gdb-get-frame-number) "\n") 'ignore))
1742 (gud-display-frame))
1743 \f
1744
1745 ;; Threads buffer. This displays a selectable thread list.
1746 ;;
1747 (gdb-set-buffer-rules 'gdb-threads-buffer
1748 'gdb-threads-buffer-name
1749 'gdb-threads-mode)
1750
1751 (def-gdb-auto-updated-buffer gdb-threads-buffer
1752 gdb-invalidate-threads
1753 (concat gdb-server-prefix "info threads\n")
1754 gdb-info-threads-handler
1755 gdb-info-threads-custom)
1756
1757 (defun gdb-info-threads-custom ()
1758 (with-current-buffer (gdb-get-buffer 'gdb-threads-buffer)
1759 (let ((buffer-read-only nil))
1760 (goto-char (point-min))
1761 (while (< (point) (point-max))
1762 (unless (looking-at "No ")
1763 (add-text-properties (line-beginning-position) (line-end-position)
1764 '(mouse-face highlight
1765 help-echo "mouse-2, RET: select thread")))
1766 (forward-line 1)))))
1767
1768 (defun gdb-threads-buffer-name ()
1769 (with-current-buffer gud-comint-buffer
1770 (concat "*threads of " (gdb-get-target-string) "*")))
1771
1772 (defun gdb-display-threads-buffer ()
1773 "Display IDs of currently known threads."
1774 (interactive)
1775 (gdb-display-buffer
1776 (gdb-get-create-buffer 'gdb-threads-buffer)))
1777
1778 (defun gdb-frame-threads-buffer ()
1779 "Display IDs of currently known threads in a new frame."
1780 (interactive)
1781 (let ((special-display-regexps (append special-display-regexps '(".*")))
1782 (special-display-frame-alist gdb-frame-parameters))
1783 (display-buffer (gdb-get-create-buffer 'gdb-threads-buffer))))
1784
1785 (defvar gdb-threads-mode-map
1786 (let ((map (make-sparse-keymap)))
1787 (suppress-keymap map)
1788 (define-key map "q" 'kill-this-buffer)
1789 (define-key map "\r" 'gdb-threads-select)
1790 (define-key map [mouse-2] 'gdb-threads-select)
1791 map))
1792
1793 (defvar gdb-threads-font-lock-keywords
1794 '(
1795 (") +\\([^ ]+\\) (" (1 font-lock-function-name-face))
1796 ("in \\([^ ]+\\) (" (1 font-lock-function-name-face))
1797 ("\\(\\(\\sw\\|[_.]\\)+\\)=" (1 font-lock-variable-name-face))
1798 )
1799 "Font lock keywords used in `gdb-threads-mode'.")
1800
1801 (defun gdb-threads-mode ()
1802 "Major mode for gdb frames.
1803
1804 \\{gdb-threads-mode-map}"
1805 (kill-all-local-variables)
1806 (setq major-mode 'gdb-threads-mode)
1807 (setq mode-name "Threads")
1808 (setq buffer-read-only t)
1809 (use-local-map gdb-threads-mode-map)
1810 (set (make-local-variable 'font-lock-defaults)
1811 '(gdb-threads-font-lock-keywords))
1812 (run-mode-hooks 'gdb-threads-mode-hook)
1813 'gdb-invalidate-threads)
1814
1815 (defun gdb-get-thread-number ()
1816 (save-excursion
1817 (re-search-backward "^\\s-*\\([0-9]*\\)" nil t)
1818 (match-string-no-properties 1)))
1819
1820 (defun gdb-threads-select (&optional event)
1821 "Select the thread and display the relevant source."
1822 (interactive (list last-input-event))
1823 (if event (mouse-set-point event))
1824 (gdb-enqueue-input
1825 (list (concat "thread " (gdb-get-thread-number) "\n") 'ignore))
1826 (gud-display-frame))
1827 \f
1828
1829 ;; Registers buffer.
1830 ;;
1831 (defcustom gdb-all-registers nil
1832 "Non-nil means include floating-point registers."
1833 :type 'boolean
1834 :group 'gud
1835 :version "22.1")
1836
1837 (gdb-set-buffer-rules 'gdb-registers-buffer
1838 'gdb-registers-buffer-name
1839 'gdb-registers-mode)
1840
1841 (def-gdb-auto-updated-buffer gdb-registers-buffer
1842 gdb-invalidate-registers
1843 (concat
1844 gdb-server-prefix "info " (if gdb-all-registers "all-") "registers\n")
1845 gdb-info-registers-handler
1846 gdb-info-registers-custom)
1847
1848 (defun gdb-info-registers-custom ()
1849 (with-current-buffer (gdb-get-buffer 'gdb-registers-buffer)
1850 (save-excursion
1851 (let ((buffer-read-only nil)
1852 bl)
1853 (goto-char (point-min))
1854 (while (< (point) (point-max))
1855 (setq bl (line-beginning-position))
1856 (when (looking-at "^[^ ]+")
1857 (unless (string-equal (match-string 0) "The")
1858 (put-text-property bl (match-end 0)
1859 'face font-lock-variable-name-face)))
1860 (forward-line 1))))))
1861
1862 (defvar gdb-registers-mode-map
1863 (let ((map (make-sparse-keymap)))
1864 (suppress-keymap map)
1865 (define-key map " " 'toggle-gdb-all-registers)
1866 (define-key map "q" 'kill-this-buffer)
1867 map))
1868
1869 (defun gdb-registers-mode ()
1870 "Major mode for gdb registers.
1871
1872 \\{gdb-registers-mode-map}"
1873 (kill-all-local-variables)
1874 (setq major-mode 'gdb-registers-mode)
1875 (setq mode-name "Registers:")
1876 (setq buffer-read-only t)
1877 (use-local-map gdb-registers-mode-map)
1878 (run-mode-hooks 'gdb-registers-mode-hook)
1879 (if (eq (buffer-local-value 'gud-minor-mode gud-comint-buffer) 'gdba)
1880 'gdb-invalidate-registers
1881 'gdbmi-invalidate-registers))
1882
1883 (defun gdb-registers-buffer-name ()
1884 (with-current-buffer gud-comint-buffer
1885 (concat "*registers of " (gdb-get-target-string) "*")))
1886
1887 (defun gdb-display-registers-buffer ()
1888 "Display integer register contents."
1889 (interactive)
1890 (gdb-display-buffer
1891 (gdb-get-create-buffer 'gdb-registers-buffer)))
1892
1893 (defun gdb-frame-registers-buffer ()
1894 "Display integer register contents in a new frame."
1895 (interactive)
1896 (let ((special-display-regexps (append special-display-regexps '(".*")))
1897 (special-display-frame-alist gdb-frame-parameters))
1898 (display-buffer (gdb-get-create-buffer 'gdb-registers-buffer))))
1899
1900 (defun toggle-gdb-all-registers ()
1901 "Toggle the display of floating-point registers."
1902 (interactive)
1903 (if gdb-all-registers
1904 (progn
1905 (setq gdb-all-registers nil)
1906 (with-current-buffer (gdb-get-buffer 'gdb-registers-buffer)
1907 (setq mode-name "Registers:")))
1908 (setq gdb-all-registers t)
1909 (with-current-buffer (gdb-get-buffer 'gdb-registers-buffer)
1910 (setq mode-name "Registers:All")))
1911 (gdb-invalidate-registers))
1912 \f
1913
1914 ;; Memory buffer.
1915 ;;
1916 (defcustom gdb-memory-repeat-count 32
1917 "Number of data items in memory window."
1918 :type 'integer
1919 :group 'gud
1920 :version "22.1")
1921
1922 (defcustom gdb-memory-format "x"
1923 "Display format of data items in memory window."
1924 :type '(choice (const :tag "Hexadecimal" "x")
1925 (const :tag "Signed decimal" "d")
1926 (const :tag "Unsigned decimal" "u")
1927 (const :tag "Octal" "o")
1928 (const :tag "Binary" "t"))
1929 :group 'gud
1930 :version "22.1")
1931
1932 (defcustom gdb-memory-unit "w"
1933 "Unit size of data items in memory window."
1934 :type '(choice (const :tag "Byte" "b")
1935 (const :tag "Halfword" "h")
1936 (const :tag "Word" "w")
1937 (const :tag "Giant word" "g"))
1938 :group 'gud
1939 :version "22.1")
1940
1941 (gdb-set-buffer-rules 'gdb-memory-buffer
1942 'gdb-memory-buffer-name
1943 'gdb-memory-mode)
1944
1945 (def-gdb-auto-updated-buffer gdb-memory-buffer
1946 gdb-invalidate-memory
1947 (concat gdb-server-prefix "x/" (number-to-string gdb-memory-repeat-count)
1948 gdb-memory-format gdb-memory-unit " " gdb-memory-address "\n")
1949 gdb-read-memory-handler
1950 gdb-read-memory-custom)
1951
1952 (defun gdb-read-memory-custom ()
1953 (save-excursion
1954 (goto-char (point-min))
1955 (if (looking-at "0x[[:xdigit:]]+")
1956 (setq gdb-memory-address (match-string 0)))))
1957
1958 (defvar gdb-memory-mode-map
1959 (let ((map (make-sparse-keymap)))
1960 (suppress-keymap map)
1961 (define-key map "q" 'kill-this-buffer)
1962 map))
1963
1964 (defun gdb-memory-set-address (event)
1965 "Set the start memory address."
1966 (interactive "e")
1967 (save-selected-window
1968 (select-window (posn-window (event-start event)))
1969 (let ((arg (read-from-minibuffer "Memory address: ")))
1970 (setq gdb-memory-address arg))
1971 (gdb-invalidate-memory)))
1972
1973 (defun gdb-memory-set-repeat-count (event)
1974 "Set the number of data items in memory window."
1975 (interactive "e")
1976 (save-selected-window
1977 (select-window (posn-window (event-start event)))
1978 (let* ((arg (read-from-minibuffer "Repeat count: "))
1979 (count (string-to-number arg)))
1980 (if (<= count 0)
1981 (error "Positive numbers only")
1982 (customize-set-variable 'gdb-memory-repeat-count count)
1983 (gdb-invalidate-memory)))))
1984
1985 (defun gdb-memory-format-binary ()
1986 "Set the display format to binary."
1987 (interactive)
1988 (customize-set-variable 'gdb-memory-format "t")
1989 (gdb-invalidate-memory))
1990
1991 (defun gdb-memory-format-octal ()
1992 "Set the display format to octal."
1993 (interactive)
1994 (customize-set-variable 'gdb-memory-format "o")
1995 (gdb-invalidate-memory))
1996
1997 (defun gdb-memory-format-unsigned ()
1998 "Set the display format to unsigned decimal."
1999 (interactive)
2000 (customize-set-variable 'gdb-memory-format "u")
2001 (gdb-invalidate-memory))
2002
2003 (defun gdb-memory-format-signed ()
2004 "Set the display format to decimal."
2005 (interactive)
2006 (customize-set-variable 'gdb-memory-format "d")
2007 (gdb-invalidate-memory))
2008
2009 (defun gdb-memory-format-hexadecimal ()
2010 "Set the display format to hexadecimal."
2011 (interactive)
2012 (customize-set-variable 'gdb-memory-format "x")
2013 (gdb-invalidate-memory))
2014
2015 (defvar gdb-memory-format-keymap
2016 (let ((map (make-sparse-keymap)))
2017 (define-key map [header-line down-mouse-3] 'gdb-memory-format-menu-1)
2018 map)
2019 "Keymap to select format in the header line.")
2020
2021 (defvar gdb-memory-format-menu (make-sparse-keymap "Format")
2022 "Menu of display formats in the header line.")
2023
2024 (define-key gdb-memory-format-menu [binary]
2025 '(menu-item "Binary" gdb-memory-format-binary
2026 :button (:radio . (equal gdb-memory-format "t"))))
2027 (define-key gdb-memory-format-menu [octal]
2028 '(menu-item "Octal" gdb-memory-format-octal
2029 :button (:radio . (equal gdb-memory-format "o"))))
2030 (define-key gdb-memory-format-menu [unsigned]
2031 '(menu-item "Unsigned Decimal" gdb-memory-format-unsigned
2032 :button (:radio . (equal gdb-memory-format "u"))))
2033 (define-key gdb-memory-format-menu [signed]
2034 '(menu-item "Signed Decimal" gdb-memory-format-signed
2035 :button (:radio . (equal gdb-memory-format "d"))))
2036 (define-key gdb-memory-format-menu [hexadecimal]
2037 '(menu-item "Hexadecimal" gdb-memory-format-hexadecimal
2038 :button (:radio . (equal gdb-memory-format "x"))))
2039
2040 (defun gdb-memory-format-menu (event)
2041 (interactive "@e")
2042 (x-popup-menu event gdb-memory-format-menu))
2043
2044 (defun gdb-memory-format-menu-1 (event)
2045 (interactive "e")
2046 (save-selected-window
2047 (select-window (posn-window (event-start event)))
2048 (let* ((selection (gdb-memory-format-menu event))
2049 (binding (and selection (lookup-key gdb-memory-format-menu
2050 (vector (car selection))))))
2051 (if binding (call-interactively binding)))))
2052
2053 (defun gdb-memory-unit-giant ()
2054 "Set the unit size to giant words (eight bytes)."
2055 (interactive)
2056 (customize-set-variable 'gdb-memory-unit "g")
2057 (gdb-invalidate-memory))
2058
2059 (defun gdb-memory-unit-word ()
2060 "Set the unit size to words (four bytes)."
2061 (interactive)
2062 (customize-set-variable 'gdb-memory-unit "w")
2063 (gdb-invalidate-memory))
2064
2065 (defun gdb-memory-unit-halfword ()
2066 "Set the unit size to halfwords (two bytes)."
2067 (interactive)
2068 (customize-set-variable 'gdb-memory-unit "h")
2069 (gdb-invalidate-memory))
2070
2071 (defun gdb-memory-unit-byte ()
2072 "Set the unit size to bytes."
2073 (interactive)
2074 (customize-set-variable 'gdb-memory-unit "b")
2075 (gdb-invalidate-memory))
2076
2077 (defvar gdb-memory-unit-keymap
2078 (let ((map (make-sparse-keymap)))
2079 (define-key map [header-line down-mouse-3] 'gdb-memory-unit-menu-1)
2080 map)
2081 "Keymap to select units in the header line.")
2082
2083 (defvar gdb-memory-unit-menu (make-sparse-keymap "Unit")
2084 "Menu of units in the header line.")
2085
2086 (define-key gdb-memory-unit-menu [giantwords]
2087 '(menu-item "Giant words" gdb-memory-unit-giant
2088 :button (:radio . (equal gdb-memory-unit "g"))))
2089 (define-key gdb-memory-unit-menu [words]
2090 '(menu-item "Words" gdb-memory-unit-word
2091 :button (:radio . (equal gdb-memory-unit "w"))))
2092 (define-key gdb-memory-unit-menu [halfwords]
2093 '(menu-item "Halfwords" gdb-memory-unit-halfword
2094 :button (:radio . (equal gdb-memory-unit "h"))))
2095 (define-key gdb-memory-unit-menu [bytes]
2096 '(menu-item "Bytes" gdb-memory-unit-byte
2097 :button (:radio . (equal gdb-memory-unit "b"))))
2098
2099 (defun gdb-memory-unit-menu (event)
2100 (interactive "@e")
2101 (x-popup-menu event gdb-memory-unit-menu))
2102
2103 (defun gdb-memory-unit-menu-1 (event)
2104 (interactive "e")
2105 (save-selected-window
2106 (select-window (posn-window (event-start event)))
2107 (let* ((selection (gdb-memory-unit-menu event))
2108 (binding (and selection (lookup-key gdb-memory-unit-menu
2109 (vector (car selection))))))
2110 (if binding (call-interactively binding)))))
2111
2112 ;;from make-mode-line-mouse-map
2113 (defun gdb-make-header-line-mouse-map (mouse function) "\
2114 Return a keymap with single entry for mouse key MOUSE on the header line.
2115 MOUSE is defined to run function FUNCTION with no args in the buffer
2116 corresponding to the mode line clicked."
2117 (let ((map (make-sparse-keymap)))
2118 (define-key map (vector 'header-line mouse) function)
2119 (define-key map (vector 'header-line 'down-mouse-1) 'ignore)
2120 map))
2121
2122 (defvar gdb-memory-font-lock-keywords
2123 '(;; <__function.name+n>
2124 ("<\\(\\(\\sw\\|[_.]\\)+\\)\\(\\+[0-9]+\\)?>" (1 font-lock-function-name-face))
2125 )
2126 "Font lock keywords used in `gdb-memory-mode'.")
2127
2128 (defun gdb-memory-mode ()
2129 "Major mode for examining memory.
2130
2131 \\{gdb-memory-mode-map}"
2132 (kill-all-local-variables)
2133 (setq major-mode 'gdb-memory-mode)
2134 (setq mode-name "Memory")
2135 (setq buffer-read-only t)
2136 (use-local-map gdb-memory-mode-map)
2137 (setq header-line-format
2138 '(:eval
2139 (concat
2140 "Read address["
2141 (propertize
2142 "-"
2143 'face font-lock-warning-face
2144 'help-echo "mouse-1: Decrement address"
2145 'mouse-face 'mode-line-highlight
2146 'local-map
2147 (gdb-make-header-line-mouse-map
2148 'mouse-1
2149 #'(lambda () (interactive)
2150 (let ((gdb-memory-address
2151 ;; Let GDB do the arithmetic.
2152 (concat
2153 gdb-memory-address " - "
2154 (number-to-string
2155 (* gdb-memory-repeat-count
2156 (cond ((string= gdb-memory-unit "b") 1)
2157 ((string= gdb-memory-unit "h") 2)
2158 ((string= gdb-memory-unit "w") 4)
2159 ((string= gdb-memory-unit "g") 8)))))))
2160 (gdb-invalidate-memory)))))
2161 "|"
2162 (propertize "+"
2163 'face font-lock-warning-face
2164 'help-echo "mouse-1: Increment address"
2165 'mouse-face 'mode-line-highlight
2166 'local-map (gdb-make-header-line-mouse-map
2167 'mouse-1
2168 #'(lambda () (interactive)
2169 (let ((gdb-memory-address nil))
2170 (gdb-invalidate-memory)))))
2171 "]: "
2172 (propertize gdb-memory-address
2173 'face font-lock-warning-face
2174 'help-echo "mouse-1: Set memory address"
2175 'mouse-face 'mode-line-highlight
2176 'local-map (gdb-make-header-line-mouse-map
2177 'mouse-1
2178 #'gdb-memory-set-address))
2179 " Repeat Count: "
2180 (propertize (number-to-string gdb-memory-repeat-count)
2181 'face font-lock-warning-face
2182 'help-echo "mouse-1: Set repeat count"
2183 'mouse-face 'mode-line-highlight
2184 'local-map (gdb-make-header-line-mouse-map
2185 'mouse-1
2186 #'gdb-memory-set-repeat-count))
2187 " Display Format: "
2188 (propertize gdb-memory-format
2189 'face font-lock-warning-face
2190 'help-echo "mouse-3: Select display format"
2191 'mouse-face 'mode-line-highlight
2192 'local-map gdb-memory-format-keymap)
2193 " Unit Size: "
2194 (propertize gdb-memory-unit
2195 'face font-lock-warning-face
2196 'help-echo "mouse-3: Select unit size"
2197 'mouse-face 'mode-line-highlight
2198 'local-map gdb-memory-unit-keymap))))
2199 (set (make-local-variable 'font-lock-defaults)
2200 '(gdb-memory-font-lock-keywords))
2201 (run-mode-hooks 'gdb-memory-mode-hook)
2202 'gdb-invalidate-memory)
2203
2204 (defun gdb-memory-buffer-name ()
2205 (with-current-buffer gud-comint-buffer
2206 (concat "*memory of " (gdb-get-target-string) "*")))
2207
2208 (defun gdb-display-memory-buffer ()
2209 "Display memory contents."
2210 (interactive)
2211 (gdb-display-buffer
2212 (gdb-get-create-buffer 'gdb-memory-buffer)))
2213
2214 (defun gdb-frame-memory-buffer ()
2215 "Display memory contents in a new frame."
2216 (interactive)
2217 (let ((special-display-regexps (append special-display-regexps '(".*")))
2218 (special-display-frame-alist gdb-frame-parameters))
2219 (display-buffer (gdb-get-create-buffer 'gdb-memory-buffer))))
2220 \f
2221
2222 ;; Locals buffer.
2223 ;;
2224 (gdb-set-buffer-rules 'gdb-locals-buffer
2225 'gdb-locals-buffer-name
2226 'gdb-locals-mode)
2227
2228 (def-gdb-auto-update-trigger gdb-invalidate-locals
2229 (gdb-get-buffer 'gdb-locals-buffer)
2230 "server info locals\n"
2231 gdb-info-locals-handler)
2232
2233 ;; Abbreviate for arrays and structures.
2234 ;; These can be expanded using gud-display.
2235 (defun gdb-info-locals-handler ()
2236 (setq gdb-pending-triggers (delq 'gdb-invalidate-locals
2237 gdb-pending-triggers))
2238 (let ((buf (gdb-get-buffer 'gdb-partial-output-buffer)))
2239 (with-current-buffer buf
2240 (goto-char (point-min))
2241 (while (re-search-forward "^[ }].*\n" nil t)
2242 (replace-match "" nil nil))
2243 (goto-char (point-min))
2244 (while (re-search-forward "{\\(.*=.*\n\\|\n\\)" nil t)
2245 (replace-match "(structure);\n" nil nil))
2246 (goto-char (point-min))
2247 (while (re-search-forward "\\s-*{.*\n" nil t)
2248 (replace-match " (array);\n" nil nil))))
2249 (let ((buf (gdb-get-buffer 'gdb-locals-buffer)))
2250 (and buf
2251 (with-current-buffer buf
2252 (let* ((window (get-buffer-window buf 0))
2253 (p (window-point window))
2254 (buffer-read-only nil))
2255 (erase-buffer)
2256 (insert-buffer-substring (gdb-get-create-buffer
2257 'gdb-partial-output-buffer))
2258 (set-window-point window p)))))
2259 (run-hooks 'gdb-info-locals-hook))
2260
2261 (defvar gdb-locals-mode-map
2262 (let ((map (make-sparse-keymap)))
2263 (suppress-keymap map)
2264 (define-key map "q" 'kill-this-buffer)
2265 map))
2266
2267 (defvar gdb-locals-font-lock-keywords
2268 '(
2269 ;; var = (struct struct_tag) value
2270 ( "\\(^\\(\\sw\\|[_.]\\)+\\) += +(\\(struct\\) \\(\\(\\sw\\|[_.]\\)+\\)"
2271 (1 font-lock-variable-name-face)
2272 (3 font-lock-keyword-face)
2273 (4 font-lock-type-face))
2274 ;; var = (type) value
2275 ( "\\(^\\(\\sw\\|[_.]\\)+\\) += +(\\(\\(\\sw\\|[_.]\\)+\\)"
2276 (1 font-lock-variable-name-face)
2277 (3 font-lock-type-face))
2278 ;; var = val
2279 ( "\\(^\\(\\sw\\|[_.]\\)+\\) += +[^(]"
2280 (1 font-lock-variable-name-face))
2281 )
2282 "Font lock keywords used in `gdb-local-mode'.")
2283
2284 (defun gdb-locals-mode ()
2285 "Major mode for gdb locals.
2286
2287 \\{gdb-locals-mode-map}"
2288 (kill-all-local-variables)
2289 (setq major-mode 'gdb-locals-mode)
2290 (setq mode-name (concat "Locals:" gdb-selected-frame))
2291 (setq buffer-read-only t)
2292 (use-local-map gdb-locals-mode-map)
2293 (set (make-local-variable 'font-lock-defaults)
2294 '(gdb-locals-font-lock-keywords))
2295 (run-mode-hooks 'gdb-locals-mode-hook)
2296 (if (eq (buffer-local-value 'gud-minor-mode gud-comint-buffer) 'gdba)
2297 'gdb-invalidate-locals
2298 'gdbmi-invalidate-locals))
2299
2300 (defun gdb-locals-buffer-name ()
2301 (with-current-buffer gud-comint-buffer
2302 (concat "*locals of " (gdb-get-target-string) "*")))
2303
2304 (defun gdb-display-locals-buffer ()
2305 "Display local variables of current stack and their values."
2306 (interactive)
2307 (gdb-display-buffer
2308 (gdb-get-create-buffer 'gdb-locals-buffer)))
2309
2310 (defun gdb-frame-locals-buffer ()
2311 "Display local variables of current stack and their values in a new frame."
2312 (interactive)
2313 (let ((special-display-regexps (append special-display-regexps '(".*")))
2314 (special-display-frame-alist gdb-frame-parameters))
2315 (display-buffer (gdb-get-create-buffer 'gdb-locals-buffer))))
2316 \f
2317
2318 ;;;; Window management
2319 (defun gdb-display-buffer (buf &optional size)
2320 (let ((answer (get-buffer-window buf 0))
2321 (must-split nil))
2322 (if answer
2323 (display-buffer buf nil 0) ;Raise the frame if necessary.
2324 ;; The buffer is not yet displayed.
2325 (pop-to-buffer gud-comint-buffer) ;Select the right frame.
2326 (let ((window (get-lru-window)))
2327 (if (and window
2328 (not (eq window (get-buffer-window gud-comint-buffer))))
2329 (progn
2330 (set-window-buffer window buf)
2331 (setq answer window))
2332 (setq must-split t)))
2333 (if must-split
2334 (let* ((largest (get-largest-window))
2335 (cur-size (window-height largest))
2336 (new-size (and size (< size cur-size) (- cur-size size))))
2337 (setq answer (split-window largest new-size))
2338 (set-window-buffer answer buf)
2339 (set-window-dedicated-p answer t)))
2340 answer)))
2341
2342 \f
2343 ;;; Shared keymap initialization:
2344
2345 (let ((menu (make-sparse-keymap "GDB-Windows")))
2346 (define-key gud-menu-map [displays]
2347 `(menu-item "GDB-Windows" ,menu
2348 :visible (memq gud-minor-mode '(gdbmi gdba))))
2349 (define-key menu [gdb] '("Gdb" . gdb-display-gdb-buffer))
2350 (define-key menu [threads] '("Threads" . gdb-display-threads-buffer))
2351 (define-key menu [memory] '("Memory" . gdb-display-memory-buffer))
2352 (define-key menu [disassembly]
2353 '("Disassembly" . gdb-display-assembler-buffer))
2354 (define-key menu [registers] '("Registers" . gdb-display-registers-buffer))
2355 (define-key menu [inferior]
2356 '(menu-item "Inferior IO" gdb-display-inferior-io-buffer
2357 :enable gdb-use-inferior-io-buffer))
2358 (define-key menu [locals] '("Locals" . gdb-display-locals-buffer))
2359 (define-key menu [frames] '("Stack" . gdb-display-stack-buffer))
2360 (define-key menu [breakpoints]
2361 '("Breakpoints" . gdb-display-breakpoints-buffer)))
2362
2363 (let ((menu (make-sparse-keymap "GDB-Frames")))
2364 (define-key gud-menu-map [frames]
2365 `(menu-item "GDB-Frames" ,menu
2366 :visible (memq gud-minor-mode '(gdbmi gdba))))
2367 (define-key menu [gdb] '("Gdb" . gdb-frame-gdb-buffer))
2368 (define-key menu [threads] '("Threads" . gdb-frame-threads-buffer))
2369 (define-key menu [memory] '("Memory" . gdb-frame-memory-buffer))
2370 (define-key menu [disassembly] '("Disassembiy" . gdb-frame-assembler-buffer))
2371 (define-key menu [registers] '("Registers" . gdb-frame-registers-buffer))
2372 (define-key menu [inferior]
2373 '(menu-item "Inferior IO" gdb-frame-inferior-io-buffer
2374 :enable gdb-use-inferior-io-buffer))
2375 (define-key menu [locals] '("Locals" . gdb-frame-locals-buffer))
2376 (define-key menu [frames] '("Stack" . gdb-frame-stack-buffer))
2377 (define-key menu [breakpoints]
2378 '("Breakpoints" . gdb-frame-breakpoints-buffer)))
2379
2380 (let ((menu (make-sparse-keymap "GDB-UI/MI")))
2381 (define-key gud-menu-map [ui]
2382 `(menu-item (if (eq gud-minor-mode 'gdba) "GDB-UI" "GDB-MI")
2383 ,menu :visible (memq gud-minor-mode '(gdbmi gdba))))
2384 (define-key menu [gdb-use-inferior-io]
2385 '(menu-item "Separate inferior IO" gdb-use-inferior-io-buffer
2386 :visible (eq gud-minor-mode 'gdba)
2387 :help "Toggle separate IO for inferior."
2388 :button (:toggle . gdb-use-inferior-io-buffer)))
2389 (define-key menu [gdb-many-windows]
2390 '(menu-item "Display Other Windows" gdb-many-windows
2391 :help "Toggle display of locals, stack and breakpoint information"
2392 :button (:toggle . gdb-many-windows)))
2393 (define-key menu [gdb-restore-windows]
2394 '(menu-item "Restore Window Layout" gdb-restore-windows
2395 :help "Restore standard layout for debug session.")))
2396
2397 (defun gdb-frame-gdb-buffer ()
2398 "Display GUD buffer in a new frame."
2399 (interactive)
2400 (let ((special-display-regexps (append special-display-regexps '(".*")))
2401 (special-display-frame-alist gdb-frame-parameters)
2402 (same-window-regexps nil))
2403 (display-buffer gud-comint-buffer)))
2404
2405 (defun gdb-display-gdb-buffer ()
2406 "Display GUD buffer."
2407 (interactive)
2408 (let ((same-window-regexps nil))
2409 (pop-to-buffer gud-comint-buffer)))
2410
2411 (defun gdb-set-window-buffer (name)
2412 (set-window-buffer (selected-window) (get-buffer name))
2413 (set-window-dedicated-p (selected-window) t))
2414
2415 (defun gdb-setup-windows ()
2416 "Layout the window pattern for `gdb-many-windows'."
2417 (gdb-display-locals-buffer)
2418 (gdb-display-stack-buffer)
2419 (delete-other-windows)
2420 (gdb-display-breakpoints-buffer)
2421 (delete-other-windows)
2422 ; Don't dedicate.
2423 (pop-to-buffer gud-comint-buffer)
2424 (split-window nil ( / ( * (window-height) 3) 4))
2425 (split-window nil ( / (window-height) 3))
2426 (split-window-horizontally)
2427 (other-window 1)
2428 (gdb-set-window-buffer (gdb-locals-buffer-name))
2429 (other-window 1)
2430 (switch-to-buffer
2431 (if gud-last-last-frame
2432 (gud-find-file (car gud-last-last-frame))
2433 (gud-find-file gdb-main-file)))
2434 (when gdb-use-inferior-io-buffer
2435 (split-window-horizontally)
2436 (other-window 1)
2437 (gdb-set-window-buffer
2438 (gdb-get-create-buffer 'gdb-inferior-io)))
2439 (other-window 1)
2440 (gdb-set-window-buffer (gdb-stack-buffer-name))
2441 (split-window-horizontally)
2442 (other-window 1)
2443 (gdb-set-window-buffer (gdb-breakpoints-buffer-name))
2444 (other-window 1))
2445
2446 (defcustom gdb-many-windows nil
2447 "Nil means just pop up the GUD buffer unless `gdb-show-main' is t.
2448 In this case it starts with two windows: one displaying the GUD
2449 buffer and the other with the source file with the main routine
2450 of the inferior. Non-nil means display the layout shown for
2451 `gdba'."
2452 :type 'boolean
2453 :group 'gud
2454 :version "22.1")
2455
2456 (defun gdb-many-windows (arg)
2457 "Toggle the number of windows in the basic arrangement.
2458 With arg, display additional buffers iff arg is positive."
2459 (interactive "P")
2460 (setq gdb-many-windows
2461 (if (null arg)
2462 (not gdb-many-windows)
2463 (> (prefix-numeric-value arg) 0)))
2464 (if (and gud-comint-buffer
2465 (buffer-name gud-comint-buffer))
2466 (condition-case nil
2467 (gdb-restore-windows)
2468 (error nil))))
2469
2470 (defun gdb-restore-windows ()
2471 "Restore the basic arrangement of windows used by gdba.
2472 This arrangement depends on the value of `gdb-many-windows'."
2473 (interactive)
2474 (pop-to-buffer gud-comint-buffer) ;Select the right window and frame.
2475 (delete-other-windows)
2476 (if gdb-many-windows
2477 (gdb-setup-windows)
2478 (when (or gud-last-last-frame gdb-show-main)
2479 (split-window)
2480 (other-window 1)
2481 (switch-to-buffer
2482 (if gud-last-last-frame
2483 (gud-find-file (car gud-last-last-frame))
2484 (gud-find-file gdb-main-file)))
2485 (other-window 1))))
2486
2487 (defun gdb-reset ()
2488 "Exit a debugging session cleanly.
2489 Kills the gdb buffers and resets the source buffers."
2490 (dolist (buffer (buffer-list))
2491 (unless (eq buffer gud-comint-buffer)
2492 (with-current-buffer buffer
2493 (if (memq gud-minor-mode '(gdbmi gdba))
2494 (if (string-match "\\`\\*.+\\*\\'" (buffer-name))
2495 (kill-buffer nil)
2496 (gdb-remove-breakpoint-icons (point-min) (point-max) t)
2497 (setq gud-minor-mode nil)
2498 (kill-local-variable 'tool-bar-map)
2499 (kill-local-variable 'gdb-define-alist))))))
2500 (when (markerp gdb-overlay-arrow-position)
2501 (move-marker gdb-overlay-arrow-position nil)
2502 (setq gdb-overlay-arrow-position nil))
2503 (setq overlay-arrow-variable-list
2504 (delq 'gdb-overlay-arrow-position overlay-arrow-variable-list))
2505 (setq gud-running nil)
2506 (setq gdb-active-process nil)
2507 (remove-hook 'after-save-hook 'gdb-create-define-alist t))
2508
2509 (defun gdb-source-info ()
2510 "Find the source file where the program starts and displays it with related
2511 buffers."
2512 (goto-char (point-min))
2513 (if (and (search-forward "Located in " nil t)
2514 (looking-at "\\S-+"))
2515 (setq gdb-main-file (match-string 0)))
2516 (goto-char (point-min))
2517 (if (search-forward "Includes preprocessor macro info." nil t)
2518 (setq gdb-macro-info t))
2519 (if gdb-many-windows
2520 (gdb-setup-windows)
2521 (gdb-get-create-buffer 'gdb-breakpoints-buffer)
2522 (if gdb-show-main
2523 (let ((pop-up-windows t))
2524 (display-buffer (gud-find-file gdb-main-file))))))
2525
2526 (defun gdb-get-location (bptno line flag)
2527 "Find the directory containing the relevant source file.
2528 Put in buffer and place breakpoint icon."
2529 (goto-char (point-min))
2530 (catch 'file-not-found
2531 (if (search-forward "Located in " nil t)
2532 (when (looking-at "\\S-+")
2533 (delete (cons bptno "File not found") gdb-location-alist)
2534 (push (cons bptno (match-string 0)) gdb-location-alist))
2535 (gdb-resync)
2536 (unless (assoc bptno gdb-location-alist)
2537 (push (cons bptno "File not found") gdb-location-alist)
2538 (message-box "Cannot find source file for breakpoint location.\n\
2539 Add directory to search path for source files using the GDB command, dir."))
2540 (throw 'file-not-found nil))
2541 (with-current-buffer
2542 (find-file-noselect (match-string 0))
2543 (save-current-buffer
2544 (set (make-local-variable 'gud-minor-mode) 'gdba)
2545 (set (make-local-variable 'tool-bar-map) gud-tool-bar-map))
2546 ;; only want one breakpoint icon at each location
2547 (save-excursion
2548 (goto-line (string-to-number line))
2549 (gdb-put-breakpoint-icon (eq flag ?y) bptno)))))
2550
2551 (add-hook 'find-file-hook 'gdb-find-file-hook)
2552
2553 (defun gdb-find-file-hook ()
2554 "Set up buffer for debugging if file is part of the source code
2555 of the current session."
2556 (if (and (not gdb-find-file-unhook)
2557 ;; in case gud or gdb-ui is just loaded
2558 gud-comint-buffer
2559 (buffer-name gud-comint-buffer)
2560 (eq (buffer-local-value 'gud-minor-mode gud-comint-buffer)
2561 'gdba))
2562 (condition-case nil
2563 (gdb-enqueue-input
2564 (list (concat gdb-server-prefix "list "
2565 (file-name-nondirectory buffer-file-name)
2566 ":1\n")
2567 `(lambda () (gdb-set-gud-minor-mode ,(current-buffer)))))
2568 (error (setq gdb-find-file-unhook t)))))
2569
2570 ;;from put-image
2571 (defun gdb-put-string (putstring pos &optional dprop &rest sprops)
2572 "Put string PUTSTRING in front of POS in the current buffer.
2573 PUTSTRING is displayed by putting an overlay into the current buffer with a
2574 `before-string' string that has a `display' property whose value is
2575 PUTSTRING."
2576 (let ((string (make-string 1 ?x))
2577 (buffer (current-buffer)))
2578 (setq putstring (copy-sequence putstring))
2579 (let ((overlay (make-overlay pos pos buffer))
2580 (prop (or dprop
2581 (list (list 'margin 'left-margin) putstring))))
2582 (put-text-property 0 1 'display prop string)
2583 (if sprops
2584 (add-text-properties 0 1 sprops string))
2585 (overlay-put overlay 'put-break t)
2586 (overlay-put overlay 'before-string string))))
2587
2588 ;;from remove-images
2589 (defun gdb-remove-strings (start end &optional buffer)
2590 "Remove strings between START and END in BUFFER.
2591 Remove only strings that were put in BUFFER with calls to `gdb-put-string'.
2592 BUFFER nil or omitted means use the current buffer."
2593 (unless buffer
2594 (setq buffer (current-buffer)))
2595 (dolist (overlay (overlays-in start end))
2596 (when (overlay-get overlay 'put-break)
2597 (delete-overlay overlay))))
2598
2599 (defun gdb-put-breakpoint-icon (enabled bptno)
2600 (let ((start (- (line-beginning-position) 1))
2601 (end (+ (line-end-position) 1))
2602 (putstring (if enabled "B" "b"))
2603 (source-window (get-buffer-window (current-buffer) 0)))
2604 (add-text-properties
2605 0 1 '(help-echo "mouse-1: clear bkpt, mouse-3: enable/disable bkpt")
2606 putstring)
2607 (if enabled
2608 (add-text-properties
2609 0 1 `(gdb-bptno ,bptno gdb-enabled t) putstring)
2610 (add-text-properties
2611 0 1 `(gdb-bptno ,bptno gdb-enabled nil) putstring))
2612 (gdb-remove-breakpoint-icons start end)
2613 (if (display-images-p)
2614 (if (>= (or left-fringe-width
2615 (if source-window (car (window-fringes source-window)))
2616 gdb-buffer-fringe-width) 8)
2617 (gdb-put-string
2618 nil (1+ start)
2619 `(left-fringe breakpoint
2620 ,(if enabled
2621 'breakpoint-enabled
2622 'breakpoint-disabled))
2623 'gdb-bptno bptno
2624 'gdb-enabled enabled)
2625 (when (< left-margin-width 2)
2626 (save-current-buffer
2627 (setq left-margin-width 2)
2628 (if source-window
2629 (set-window-margins
2630 source-window
2631 left-margin-width right-margin-width))))
2632 (put-image
2633 (if enabled
2634 (or breakpoint-enabled-icon
2635 (setq breakpoint-enabled-icon
2636 (find-image `((:type xpm :data
2637 ,breakpoint-xpm-data
2638 :ascent 100 :pointer hand)
2639 (:type pbm :data
2640 ,breakpoint-enabled-pbm-data
2641 :ascent 100 :pointer hand)))))
2642 (or breakpoint-disabled-icon
2643 (setq breakpoint-disabled-icon
2644 (find-image `((:type xpm :data
2645 ,breakpoint-xpm-data
2646 :conversion disabled
2647 :ascent 100 :pointer hand)
2648 (:type pbm :data
2649 ,breakpoint-disabled-pbm-data
2650 :ascent 100 :pointer hand))))))
2651 (+ start 1)
2652 putstring
2653 'left-margin))
2654 (when (< left-margin-width 2)
2655 (save-current-buffer
2656 (setq left-margin-width 2)
2657 (let ((window (get-buffer-window (current-buffer) 0)))
2658 (if window
2659 (set-window-margins
2660 window left-margin-width right-margin-width)))))
2661 (gdb-put-string
2662 (propertize putstring
2663 'face (if enabled 'breakpoint-enabled 'breakpoint-disabled))
2664 (1+ start)))))
2665
2666 (defun gdb-remove-breakpoint-icons (start end &optional remove-margin)
2667 (gdb-remove-strings start end)
2668 (if (display-images-p)
2669 (remove-images start end))
2670 (when remove-margin
2671 (setq left-margin-width 0)
2672 (let ((window (get-buffer-window (current-buffer) 0)))
2673 (if window
2674 (set-window-margins
2675 window left-margin-width right-margin-width)))))
2676
2677 \f
2678 ;;
2679 ;; Assembler buffer.
2680 ;;
2681 (gdb-set-buffer-rules 'gdb-assembler-buffer
2682 'gdb-assembler-buffer-name
2683 'gdb-assembler-mode)
2684
2685 (def-gdb-auto-update-handler gdb-assembler-handler
2686 gdb-invalidate-assembler
2687 gdb-assembler-buffer
2688 gdb-assembler-custom)
2689
2690 (defun gdb-assembler-custom ()
2691 (let ((buffer (gdb-get-buffer 'gdb-assembler-buffer))
2692 (pos 1) (address) (flag) (bptno))
2693 (with-current-buffer buffer
2694 (save-excursion
2695 (if (not (equal gdb-frame-address "main"))
2696 (progn
2697 (goto-char (point-min))
2698 (if (and gdb-frame-address
2699 (re-search-forward gdb-frame-address nil t))
2700 (progn
2701 (setq pos (point))
2702 (beginning-of-line)
2703 (or gdb-overlay-arrow-position
2704 (setq gdb-overlay-arrow-position (make-marker)))
2705 (set-marker gdb-overlay-arrow-position
2706 (point) (current-buffer))))))
2707 ;; remove all breakpoint-icons in assembler buffer before updating.
2708 (gdb-remove-breakpoint-icons (point-min) (point-max))))
2709 (with-current-buffer (gdb-get-buffer 'gdb-breakpoints-buffer)
2710 (goto-char (point-min))
2711 (while (< (point) (- (point-max) 1))
2712 (forward-line 1)
2713 (if (looking-at "[^\t].*?breakpoint")
2714 (progn
2715 (looking-at
2716 "\\([0-9]+\\)\\s-+\\S-+\\s-+\\S-+\\s-+\\(.\\)\\s-+0x0*\\(\\S-+\\)")
2717 (setq bptno (match-string 1))
2718 (setq flag (char-after (match-beginning 2)))
2719 (setq address (match-string 3))
2720 (with-current-buffer buffer
2721 (save-excursion
2722 (goto-char (point-min))
2723 (if (re-search-forward address nil t)
2724 (gdb-put-breakpoint-icon (eq flag ?y) bptno))))))))
2725 (if (not (equal gdb-frame-address "main"))
2726 (with-current-buffer buffer
2727 (set-window-point (get-buffer-window buffer 0) pos)))))
2728
2729 (defvar gdb-assembler-mode-map
2730 (let ((map (make-sparse-keymap)))
2731 (suppress-keymap map)
2732 (define-key map "q" 'kill-this-buffer)
2733 map))
2734
2735 (defvar gdb-assembler-font-lock-keywords
2736 '(;; <__function.name+n>
2737 ("<\\(\\(\\sw\\|[_.]\\)+\\)\\(\\+[0-9]+\\)?>"
2738 (1 font-lock-function-name-face))
2739 ;; 0xNNNNNNNN <__function.name+n>: opcode
2740 ("^0x[0-9a-f]+ \\(<\\(\\(\\sw\\|[_.]\\)+\\)\\+[0-9]+>\\)?:[ \t]+\\(\\sw+\\)"
2741 (4 font-lock-keyword-face))
2742 ;; %register(at least i386)
2743 ("%\\sw+" . font-lock-variable-name-face)
2744 ("^\\(Dump of assembler code for function\\) \\(.+\\):"
2745 (1 font-lock-comment-face)
2746 (2 font-lock-function-name-face))
2747 ("^\\(End of assembler dump\\.\\)" . font-lock-comment-face))
2748 "Font lock keywords used in `gdb-assembler-mode'.")
2749
2750 (defun gdb-assembler-mode ()
2751 "Major mode for viewing code assembler.
2752
2753 \\{gdb-assembler-mode-map}"
2754 (kill-all-local-variables)
2755 (setq major-mode 'gdb-assembler-mode)
2756 (setq mode-name (concat "Machine:" gdb-selected-frame))
2757 (setq gdb-overlay-arrow-position nil)
2758 (add-to-list 'overlay-arrow-variable-list 'gdb-overlay-arrow-position)
2759 (setq fringes-outside-margins t)
2760 (setq buffer-read-only t)
2761 (use-local-map gdb-assembler-mode-map)
2762 (gdb-invalidate-assembler)
2763 (set (make-local-variable 'font-lock-defaults)
2764 '(gdb-assembler-font-lock-keywords))
2765 (run-mode-hooks 'gdb-assembler-mode-hook)
2766 'gdb-invalidate-assembler)
2767
2768 (defun gdb-assembler-buffer-name ()
2769 (with-current-buffer gud-comint-buffer
2770 (concat "*disassembly of " (gdb-get-target-string) "*")))
2771
2772 (defun gdb-display-assembler-buffer ()
2773 "Display disassembly view."
2774 (interactive)
2775 (setq gdb-previous-frame nil)
2776 (gdb-display-buffer
2777 (gdb-get-create-buffer 'gdb-assembler-buffer)))
2778
2779 (defun gdb-frame-assembler-buffer ()
2780 "Display disassembly view in a new frame."
2781 (interactive)
2782 (setq gdb-previous-frame nil)
2783 (let ((special-display-regexps (append special-display-regexps '(".*")))
2784 (special-display-frame-alist gdb-frame-parameters))
2785 (display-buffer (gdb-get-create-buffer 'gdb-assembler-buffer))))
2786
2787 ;; modified because if gdb-frame-address has changed value a new command
2788 ;; must be enqueued to update the buffer with the new output
2789 (defun gdb-invalidate-assembler (&optional ignored)
2790 (if (gdb-get-buffer 'gdb-assembler-buffer)
2791 (progn
2792 (unless (and gdb-selected-frame
2793 (string-equal gdb-selected-frame gdb-previous-frame))
2794 (if (or (not (member 'gdb-invalidate-assembler
2795 gdb-pending-triggers))
2796 (not (string-equal gdb-frame-address
2797 gdb-previous-frame-address)))
2798 (progn
2799 ;; take previous disassemble command, if any, off the queue
2800 (with-current-buffer gud-comint-buffer
2801 (let ((queue gdb-input-queue))
2802 (dolist (item queue)
2803 (if (equal (cdr item) '(gdb-assembler-handler))
2804 (setq gdb-input-queue
2805 (delete item gdb-input-queue))))))
2806 (gdb-enqueue-input
2807 (list
2808 (concat gdb-server-prefix "disassemble "
2809 (if (member gdb-frame-address '(nil "main")) nil "0x")
2810 gdb-frame-address "\n")
2811 'gdb-assembler-handler))
2812 (push 'gdb-invalidate-assembler gdb-pending-triggers)
2813 (setq gdb-previous-frame-address gdb-frame-address)
2814 (setq gdb-previous-frame gdb-selected-frame)))))))
2815
2816 (defun gdb-get-selected-frame ()
2817 (if (not (member 'gdb-get-selected-frame gdb-pending-triggers))
2818 (progn
2819 (gdb-enqueue-input
2820 (list (concat gdb-server-prefix "info frame\n") 'gdb-frame-handler))
2821 (push 'gdb-get-selected-frame
2822 gdb-pending-triggers))))
2823
2824 (defun gdb-frame-handler ()
2825 (setq gdb-pending-triggers
2826 (delq 'gdb-get-selected-frame gdb-pending-triggers))
2827 (with-current-buffer (gdb-get-create-buffer 'gdb-partial-output-buffer)
2828 (goto-char (point-min))
2829 (if (re-search-forward "Stack level \\([0-9]+\\)" nil t)
2830 (setq gdb-frame-number (match-string 1)))
2831 (goto-char (point-min))
2832 (if (re-search-forward
2833 ".*=\\s-+0x0*\\(\\S-*\\)\\s-+in\\s-+\\(\\S-*?\\);? " nil t)
2834 (progn
2835 (setq gdb-selected-frame (match-string 2))
2836 (if (gdb-get-buffer 'gdb-locals-buffer)
2837 (with-current-buffer (gdb-get-buffer 'gdb-locals-buffer)
2838 (setq mode-name (concat "Locals:" gdb-selected-frame))))
2839 (if (gdb-get-buffer 'gdb-assembler-buffer)
2840 (with-current-buffer (gdb-get-buffer 'gdb-assembler-buffer)
2841 (setq mode-name (concat "Machine:" gdb-selected-frame))))
2842 (setq gdb-frame-address (match-string 1))))
2843 (goto-char (point-min))
2844 (if (re-search-forward " source language \\(\\S-*\\)\." nil t)
2845 (setq gdb-current-language (match-string 1))))
2846 (gdb-invalidate-assembler))
2847
2848 (provide 'gdb-ui)
2849
2850 ;; arch-tag: e9fb00c5-74ef-469f-a088-37384caae352
2851 ;;; gdb-ui.el ends here