1 ;;; gdb-ui.el --- User Interface for running GDB
3 ;; Author: Nick Roberts <nickrob@gnu.org>
5 ;; Keywords: unix, tools
7 ;; Copyright (C) 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
9 ;; This file is part of GNU Emacs.
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)
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.
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., 59 Temple Place - Suite 330,
24 ;; Boston, MA 02111-1307, USA.
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).
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.
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.
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.
56 ;; 1) Use MI command -data-read-memory for memory window.
57 ;; 2) Highlight changed register values (use MI commands
58 ;; -data-list-register-values and -data-list-changed-registers instead
59 ;; of 'info registers'.
60 ;; 3) Use tree-widget.el instead of the speedbar for watch-expressions?
61 ;; 4) Mark breakpoint locations on scroll-bar of source buffer?
62 ;; 5) After release of 22.1 use '-var-list-children --all-values'
63 ;; and '-stack-list-locals 2' which need GDB 6.1 onwards.
69 (defvar gdb-frame-address
"main" "Initialisation for Assembler buffer.")
70 (defvar gdb-previous-frame-address nil
)
71 (defvar gdb-memory-address
"main")
72 (defvar gdb-previous-frame nil
)
73 (defvar gdb-selected-frame nil
)
74 (defvar gdb-frame-number nil
)
75 (defvar gdb-current-language nil
)
76 (defvar gdb-var-list nil
"List of variables in watch window.")
77 (defvar gdb-var-changed nil
"Non-nil means that gdb-var-list has changed.")
78 (defvar gdb-main-file nil
"Source file from which program execution begins.")
79 (defvar gdb-buffer-type nil
)
80 (defvar gdb-overlay-arrow-position nil
)
81 (defvar gdb-server-prefix nil
)
82 (defvar gdb-flush-pending-output nil
)
83 (defvar gdb-location-alist nil
84 "Alist of breakpoint numbers and full filenames.")
85 (defvar gdb-find-file-unhook nil
)
86 (defvar gdb-active-process nil
"GUD tooltips display variable values when t, \
87 and #define directives otherwise.")
88 (defvar gdb-macro-info nil
89 "Non-nil if GDB knows that the inferior includes preprocessor macro info.")
91 (defvar gdb-buffer-type nil
92 "One of the symbols bound in `gdb-buffer-rules'.")
94 (defvar gdb-input-queue
()
95 "A list of gdb command objects.")
97 (defvar gdb-prompting nil
98 "True when gdb is idle with no pending input.")
100 (defvar gdb-output-sink
'user
101 "The disposition of the output of the current gdb command.
102 Possible values are these symbols:
104 `user' -- gdb output should be copied to the GUD buffer
107 `inferior' -- gdb output should be copied to the inferior-io buffer
109 `pre-emacs' -- output should be ignored util the post-prompt
110 annotation is received. Then the output-sink
112 `emacs' -- output should be collected in the partial-output-buffer
113 for subsequent processing by a command. This is the
114 disposition of output generated by commands that
115 gdb mode sends to gdb on its own behalf.
116 `post-emacs' -- ignore output until the prompt annotation is
117 received, then go to USER disposition.
119 gdba (gdb-ui.el) uses all five values, gdbmi (gdb-mi.el) only two
120 \(`user' and `emacs').")
122 (defvar gdb-current-item nil
123 "The most recent command item sent to gdb.")
125 (defvar gdb-pending-triggers
'()
126 "A list of trigger functions that have run later than their output
129 ;; end of gdb variables
132 (defun gdba (command-line)
133 "Run gdb on program FILE in buffer *gud-FILE*.
134 The directory containing FILE becomes the initial working directory
135 and source-file directory for your debugger.
137 If `gdb-many-windows' is nil (the default value) then gdb just
138 pops up the GUD buffer unless `gdb-show-main' is t. In this case
139 it starts with two windows: one displaying the GUD buffer and the
140 other with the source file with the main routine of the inferior.
142 If `gdb-many-windows' is t, regardless of the value of
143 `gdb-show-main', the layout below will appear unless
144 `gdb-use-inferior-io-buffer' is nil when the source buffer
145 occupies the full width of the frame. Keybindings are given in
148 Watch expressions appear in the speedbar/slowbar.
150 The following commands help control operation :
152 `gdb-many-windows' - Toggle the number of windows gdb uses.
153 `gdb-restore-windows' - To restore the window layout.
155 See Info node `(emacs)GDB Graphical Interface' for a more
156 detailed description of this mode.
159 ---------------------------------------------------------------------
161 ---------------------------------------------------------------------
162 GUD buffer (I/O of GDB) | Locals buffer
166 ---------------------------------------------------------------------
167 Source buffer | Input/Output (of inferior) buffer
175 ---------------------------------------------------------------------
176 Stack buffer | Breakpoints buffer
177 RET gdb-frames-select | SPC gdb-toggle-breakpoint
178 | RET gdb-goto-breakpoint
179 | d gdb-delete-breakpoint
180 ---------------------------------------------------------------------"
182 (interactive (list (gud-query-cmdline 'gdba
)))
184 ;; Let's start with a basic gud-gdb buffer and then modify it a bit.
188 (defvar gdb-debug-log nil
)
190 (defcustom gdb-enable-debug-log nil
191 "Non-nil means record the process input and output in `gdb-debug-log'."
196 (defcustom gdb-use-inferior-io-buffer nil
197 "Non-nil means display output from the inferior in a separate buffer."
202 (defcustom gdb-cpp-define-alist-program
"gcc -E -dM -"
203 "Shell command for generating a list of defined macros in a source file.
204 This list is used to display the #define directive associated
205 with an identifier as a tooltip. It works in a debug session with
206 GDB, when gud-tooltip-mode is t.
208 Set `gdb-cpp-define-alist-flags' for any include paths or
214 (defcustom gdb-cpp-define-alist-flags
""
215 "Preprocessor flags for `gdb-cpp-define-alist-program'."
220 (defcustom gdb-show-main nil
221 "Non-nil means display source file containing the main routine at startup.
222 Also display the main routine in the disassembly buffer if present."
227 (defvar gdb-define-alist nil
"Alist of #define directives for GUD tooltips.")
229 (defun gdb-create-define-alist ()
230 "Create an alist of #define directives for GUD tooltips."
231 (let* ((file (buffer-file-name))
233 (with-output-to-string
234 (with-current-buffer standard-output
235 (call-process shell-file-name
236 (if (file-exists-p file
) file nil
)
237 (list t nil
) nil
"-c"
238 (concat gdb-cpp-define-alist-program
" "
239 gdb-cpp-define-alist-flags
)))))
240 (define-list (split-string output
"\n" t
))
242 (setq gdb-define-alist nil
)
243 (dolist (define define-list
)
244 (setq name
(nth 1 (split-string define
"[( ]")))
245 (push (cons name define
) gdb-define-alist
))))
247 (defun gdb-tooltip-print ()
249 (with-current-buffer (gdb-get-buffer 'gdb-partial-output-buffer
)
250 (let ((string (buffer-string)))
251 ;; remove newline for gud-tooltip-echo-area
252 (substring string
0 (- (length string
) 1))))
253 gud-tooltip-echo-area
))
255 ;; If expr is a macro for a function don't print because of possible dangerous
256 ;; side-effects. Also printing a function within a tooltip generates an
257 ;; unexpected starting annotation (phase error).
258 (defun gdb-tooltip-print-1 (expr)
259 (with-current-buffer (gdb-get-buffer 'gdb-partial-output-buffer
)
260 (goto-char (point-min))
261 (if (search-forward "expands to: " nil t
)
262 (unless (looking-at "\\S+.*(.*).*")
264 (list (concat gdb-server-prefix
"print " expr
"\n")
265 'gdb-tooltip-print
))))))
267 (defun gdb-set-gud-minor-mode (buffer)
268 "Set gud-minor-mode from find-file if appropriate."
269 (goto-char (point-min))
270 (unless (search-forward "No source file named " nil t
)
273 (list (concat gdb-server-prefix
"info source\n")
274 `(lambda () (gdb-set-gud-minor-mode-1 ,buffer
))))
275 (error (setq gdb-find-file-unhook t
)))))
277 (defun gdb-set-gud-minor-mode-1 (buffer)
278 (goto-char (point-min))
279 (when (and (search-forward "Located in " nil t
)
281 (string-equal (buffer-file-name buffer
)
283 (with-current-buffer buffer
284 (set (make-local-variable 'gud-minor-mode
) 'gdba
)
285 (set (make-local-variable 'tool-bar-map
) gud-tool-bar-map
)
286 (when gud-tooltip-mode
287 (make-local-variable 'gdb-define-alist
)
288 (gdb-create-define-alist)
289 (add-hook 'after-save-hook
'gdb-create-define-alist nil t
)))))
291 (defun gdb-set-gud-minor-mode-existing-buffers ()
292 (dolist (buffer (buffer-list))
293 (let ((file (buffer-file-name buffer
)))
297 (list (concat gdb-server-prefix
"list "
298 (file-name-nondirectory file
) ":1\n")
299 `(lambda () (gdb-set-gud-minor-mode ,buffer
)))))))))
302 (setq gdb-debug-log nil
)
303 (set (make-local-variable 'gud-minor-mode
) 'gdba
)
304 (set (make-local-variable 'gud-marker-filter
) 'gud-gdba-marker-filter
)
306 (gud-def gud-break
(if (not (string-match "Machine" mode-name
))
307 (gud-call "break %f:%l" arg
)
311 (gud-call "break *%a" arg
)))
312 "\C-b" "Set breakpoint at current line or address.")
314 (gud-def gud-remove
(if (not (string-match "Machine" mode-name
))
315 (gud-call "clear %f:%l" arg
)
319 (gud-call "clear *%a" arg
)))
320 "\C-d" "Remove breakpoint at current line or address.")
322 (gud-def gud-until
(if (not (string-match "Machine" mode-name
))
323 (gud-call "until %f:%l" arg
)
327 (gud-call "until *%a" arg
)))
328 "\C-u" "Continue to current line or address.")
330 (define-key gud-minor-mode-map
[left-margin mouse-1
]
331 'gdb-mouse-set-clear-breakpoint
)
332 (define-key gud-minor-mode-map
[left-fringe mouse-1
]
333 'gdb-mouse-set-clear-breakpoint
)
334 (define-key gud-minor-mode-map
[left-margin mouse-3
]
335 'gdb-mouse-toggle-breakpoint
)
336 ; Currently only works in margin.
337 ; (define-key gud-minor-mode-map [left-fringe mouse-3]
338 ; 'gdb-mouse-toggle-breakpoint)
340 (setq comint-input-sender
'gdb-send
)
343 (setq gdb-frame-address
(if gdb-show-main
"main" nil
))
344 (setq gdb-previous-frame-address nil
345 gdb-memory-address
"main"
346 gdb-previous-frame nil
347 gdb-selected-frame nil
348 gdb-current-language nil
356 gdb-pending-triggers nil
357 gdb-output-sink
'user
358 gdb-server-prefix
"server "
359 gdb-flush-pending-output nil
360 gdb-location-alist nil
361 gdb-find-file-unhook nil
364 (setq gdb-buffer-type
'gdba
)
366 (if gdb-use-inferior-io-buffer
(gdb-clear-inferior-io))
368 (if (eq window-system
'w32
)
369 (gdb-enqueue-input (list "set new-console off\n" 'ignore
)))
370 (gdb-enqueue-input (list "set height 0\n" 'ignore
))
371 (gdb-enqueue-input (list "set width 0\n" 'ignore
))
372 ;; find source file and compilation directory here
373 (gdb-enqueue-input (list "server list main\n" 'ignore
)) ; C program
374 (gdb-enqueue-input (list "server list MAIN__\n" 'ignore
)) ; Fortran program
375 (gdb-enqueue-input (list "server info source\n" 'gdb-source-info
))
377 (gdb-set-gud-minor-mode-existing-buffers)
378 (run-hooks 'gdba-mode-hook
))
380 (defcustom gdb-use-colon-colon-notation nil
381 "If non-nil use FUN::VAR format to display variables in the speedbar."
387 "Watch expression at point."
390 (let ((expr (tooltip-identifier-from-point (point))))
391 (if (and (string-equal gdb-current-language
"c")
392 gdb-use-colon-colon-notation gdb-selected-frame
)
393 (setq expr
(concat gdb-selected-frame
"::" expr
)))
394 (catch 'already-watched
395 (dolist (var gdb-var-list
)
396 (if (string-equal expr
(car var
)) (throw 'already-watched nil
)))
397 (set-text-properties 0 (length expr
) nil expr
)
400 (if (eq gud-minor-mode
'gdba
)
401 (concat "server interpreter mi \"-var-create - * " expr
"\"\n")
402 (concat"-var-create - * " expr
"\n"))
403 `(lambda () (gdb-var-create-handler ,expr
))))))
404 (select-window (get-buffer-window gud-comint-buffer
0)))
406 (defconst gdb-var-create-regexp
407 "name=\"\\(.*?\\)\",numchild=\"\\(.*?\\)\",type=\"\\(.*?\\)\"")
409 (defun gdb-var-create-handler (expr)
410 (with-current-buffer (gdb-get-create-buffer 'gdb-partial-output-buffer
)
411 (goto-char (point-min))
412 (if (re-search-forward gdb-var-create-regexp nil t
)
413 (let ((var (list expr
418 (push var gdb-var-list
)
420 (if (equal (nth 2 var
) "0")
423 (if (with-current-buffer
424 gud-comint-buffer
(eq gud-minor-mode
'gdba
))
425 (concat "server interpreter mi \"-var-evaluate-expression "
427 (concat "-var-evaluate-expression " (nth 1 var
) "\n"))
428 `(lambda () (gdb-var-evaluate-expression-handler
430 (setq gdb-var-changed t
)))
431 (if (re-search-forward "Undefined command" nil t
)
432 (message-box "Watching expressions requires gdb 6.0 onwards")
433 (message "No symbol %s in current context." expr
)))))
435 (defun gdb-var-evaluate-expression-handler (varnum changed
)
436 (with-current-buffer (gdb-get-create-buffer 'gdb-partial-output-buffer
)
437 (goto-char (point-min))
438 (re-search-forward ".*value=\"\\(.*?\\)\"" nil t
)
441 (dolist (var gdb-var-list
)
442 (if (string-equal varnum
(cadr var
))
444 (if changed
(setcar (nthcdr 5 var
) t
))
445 (setcar (nthcdr 4 var
) (match-string 1))
446 (setcar (nthcdr num gdb-var-list
) var
)
447 (throw 'var-found nil
)))
448 (setq num
(+ num
1))))))
449 (setq gdb-var-changed t
))
451 (defun gdb-var-list-children (varnum)
453 (list (concat "server interpreter mi \"-var-list-children " varnum
"\"\n")
454 `(lambda () (gdb-var-list-children-handler ,varnum
)))))
456 (defconst gdb-var-list-children-regexp
457 "name=\"\\(.*?\\)\",exp=\"\\(.*?\\)\",numchild=\"\\(.*?\\)\"")
459 (defun gdb-var-list-children-handler (varnum)
460 (with-current-buffer (gdb-get-create-buffer 'gdb-partial-output-buffer
)
461 (goto-char (point-min))
462 (let ((var-list nil
))
463 (catch 'child-already-watched
464 (dolist (var gdb-var-list
)
465 (if (string-equal varnum
(cadr var
))
468 (while (re-search-forward gdb-var-list-children-regexp nil t
)
469 (let ((varchild (list (match-string 2)
473 (if (looking-at ",type=\"\\(.*?\\)\"")
474 (setcar (nthcdr 3 varchild
) (match-string 1)))
475 (dolist (var1 gdb-var-list
)
476 (if (string-equal (cadr var1
) (cadr varchild
))
477 (throw 'child-already-watched nil
)))
478 (push varchild var-list
)
479 (if (equal (nth 2 varchild
) "0")
483 "server interpreter mi \"-var-evaluate-expression "
484 (nth 1 varchild
) "\"\n")
485 `(lambda () (gdb-var-evaluate-expression-handler
486 ,(nth 1 varchild
) nil
))))))))
487 (push var var-list
)))
488 (setq gdb-var-list
(nreverse var-list
))))))
490 (defun gdb-var-update ()
491 (if (not (member 'gdb-var-update gdb-pending-triggers
))
495 (if (with-current-buffer gud-comint-buffer
(eq gud-minor-mode
'gdba
))
496 "server interpreter mi \"-var-update *\"\n"
498 'gdb-var-update-handler
))
499 (push 'gdb-var-update gdb-pending-triggers
))))
501 (defconst gdb-var-update-regexp
"name=\"\\(.*?\\)\"")
503 (defun gdb-var-update-handler ()
504 (with-current-buffer (gdb-get-create-buffer 'gdb-partial-output-buffer
)
505 (goto-char (point-min))
506 (while (re-search-forward gdb-var-update-regexp nil t
)
507 (let ((varnum (match-string 1)))
510 (if (with-current-buffer gud-comint-buffer
511 (eq gud-minor-mode
'gdba
))
512 (concat "server interpreter mi \"-var-evaluate-expression "
514 (concat "-var-evaluate-expression " varnum
"\n"))
515 `(lambda () (gdb-var-evaluate-expression-handler
517 (setq gdb-pending-triggers
518 (delq 'gdb-var-update gdb-pending-triggers
))
519 (when (and (boundp 'speedbar-frame
) (frame-live-p speedbar-frame
))
520 ;; dummy command to update speedbar at right time
521 (gdb-enqueue-input (list "server pwd\n" 'gdb-speedbar-timer-fn
))
522 ;; keep gdb-pending-triggers non-nil till end
523 (push 'gdb-speedbar-timer gdb-pending-triggers
)))
525 (defun gdb-speedbar-timer-fn ()
526 (setq gdb-pending-triggers
527 (delq 'gdb-speedbar-timer gdb-pending-triggers
))
528 (with-current-buffer gud-comint-buffer
529 (speedbar-timer-fn)))
531 (defun gdb-var-delete ()
532 "Delete watched expression from the speedbar."
534 (if (with-current-buffer gud-comint-buffer
(eq gud-minor-mode
'gdba
))
535 (let ((text (speedbar-line-text)))
536 (string-match "\\(\\S-+\\)" text
)
537 (let* ((expr (match-string 1 text
))
538 (var (assoc expr gdb-var-list
))
540 (unless (string-match "\\." varnum
)
543 (if (with-current-buffer gud-comint-buffer
544 (eq gud-minor-mode
'gdba
))
545 (concat "server interpreter mi \"-var-delete " varnum
"\"\n")
546 (concat "-var-delete " varnum
"\n"))
548 (setq gdb-var-list
(delq var gdb-var-list
))
549 (dolist (varchild gdb-var-list
)
550 (if (string-match (concat (nth 1 var
) "\\.") (nth 1 varchild
))
551 (setq gdb-var-list
(delq varchild gdb-var-list
))))
552 (setq gdb-var-changed t
))))))
554 (defun gdb-edit-value (text token indent
)
555 "Assign a value to a variable displayed in the speedbar."
556 (let* ((var (nth (- (count-lines (point-min) (point)) 2) gdb-var-list
))
557 (varnum (cadr var
)) (value))
558 (setq value
(read-string "New value: "))
561 (if (with-current-buffer gud-comint-buffer
562 (eq gud-minor-mode
'gdba
))
563 (concat "server interpreter mi \"-var-assign "
564 varnum
" " value
"\"\n")
565 (concat "-var-assign " varnum
" " value
"\n"))
568 (defcustom gdb-show-changed-values t
569 "If non-nil highlight values that have recently changed in the speedbar.
570 The highlighting is done with `font-lock-warning-face'."
575 (defun gdb-speedbar-expand-node (text token indent
)
576 "Expand the node the user clicked on.
577 TEXT is the text of the button we clicked on, a + or - item.
578 TOKEN is data related to this node.
579 INDENT is the current indentation depth."
580 (cond ((string-match "+" text
) ;expand this node
581 (if (with-current-buffer gud-comint-buffer
(eq gud-minor-mode
'gdba
))
582 (gdb-var-list-children token
)
583 (gdbmi-var-list-children token
)))
584 ((string-match "-" text
) ;contract this node
585 (dolist (var gdb-var-list
)
586 (if (string-match (concat token
"\\.") (nth 1 var
))
587 (setq gdb-var-list
(delq var gdb-var-list
))))
588 (setq gdb-var-changed t
))))
590 (defun gdb-get-target-string ()
591 (with-current-buffer gud-comint-buffer
598 ;; Each buffer has a TYPE -- a symbol that identifies the function
599 ;; of that particular buffer.
601 ;; The usual gdb interaction buffer is given the type `gdba' and
602 ;; is constructed specially.
604 ;; Others are constructed by gdb-get-create-buffer and
605 ;; named according to the rules set forth in the gdb-buffer-rules-assoc
607 (defvar gdb-buffer-rules-assoc
'())
609 (defun gdb-get-buffer (key)
610 "Return the gdb buffer tagged with type KEY.
611 The key should be one of the cars in `gdb-buffer-rules-assoc'."
613 (gdb-look-for-tagged-buffer key
(buffer-list))))
615 (defun gdb-get-create-buffer (key)
616 "Create a new gdb buffer of the type specified by KEY.
617 The key should be one of the cars in `gdb-buffer-rules-assoc'."
618 (or (gdb-get-buffer key
)
619 (let* ((rules (assoc key gdb-buffer-rules-assoc
))
620 (name (funcall (gdb-rules-name-maker rules
)))
621 (new (get-buffer-create name
)))
622 (with-current-buffer new
624 (if (cdr (cdr rules
))
625 (setq trigger
(funcall (car (cdr (cdr rules
))))))
626 (set (make-local-variable 'gdb-buffer-type
) key
)
627 (set (make-local-variable 'gud-minor-mode
)
628 (with-current-buffer gud-comint-buffer gud-minor-mode
))
629 (set (make-local-variable 'tool-bar-map
) gud-tool-bar-map
)
630 (if trigger
(funcall trigger
)))
633 (defun gdb-rules-name-maker (rules) (car (cdr rules
)))
635 (defun gdb-look-for-tagged-buffer (key bufs
)
637 (while (and (not retval
) bufs
)
638 (set-buffer (car bufs
))
639 (if (eq gdb-buffer-type key
)
640 (setq retval
(car bufs
)))
641 (setq bufs
(cdr bufs
)))
645 ;; This assoc maps buffer type symbols to rules. Each rule is a list of
646 ;; at least one and possible more functions. The functions have these
647 ;; roles in defining a buffer type:
649 ;; NAME - Return a name for this buffer type.
651 ;; The remaining function(s) are optional:
653 ;; MODE - called in a new buffer with no arguments, should establish
654 ;; the proper mode for the buffer.
657 (defun gdb-set-buffer-rules (buffer-type &rest rules
)
658 (let ((binding (assoc buffer-type gdb-buffer-rules-assoc
)))
660 (setcdr binding rules
)
661 (push (cons buffer-type rules
)
662 gdb-buffer-rules-assoc
))))
664 ;; GUD buffers are an exception to the rules
665 (gdb-set-buffer-rules 'gdba
'error
)
668 ;; Partial-output buffer : This accumulates output from a command executed on
669 ;; behalf of emacs (rather than the user).
671 (gdb-set-buffer-rules 'gdb-partial-output-buffer
672 'gdb-partial-output-name
)
674 (defun gdb-partial-output-name ()
675 (concat "*partial-output-"
676 (gdb-get-target-string)
680 (gdb-set-buffer-rules 'gdb-inferior-io
681 'gdb-inferior-io-name
682 'gdb-inferior-io-mode
)
684 (defun gdb-inferior-io-name ()
685 (concat "*input/output of "
686 (gdb-get-target-string)
689 (defun gdb-display-inferior-io-buffer ()
690 "Display IO of inferior in a separate window."
692 (if gdb-use-inferior-io-buffer
694 (gdb-get-create-buffer 'gdb-inferior-io
))))
696 (defun gdb-frame-inferior-io-buffer ()
697 "Display IO of inferior in a new frame."
699 (if gdb-use-inferior-io-buffer
700 (let ((special-display-regexps (append special-display-regexps
'(".*")))
701 (special-display-frame-alist gdb-frame-parameters
))
702 (display-buffer (gdb-get-create-buffer 'gdb-inferior-io
)))))
704 (defvar gdb-inferior-io-mode-map
705 (let ((map (make-sparse-keymap)))
706 (define-key map
"\C-c\C-c" 'gdb-inferior-io-interrupt
)
707 (define-key map
"\C-c\C-z" 'gdb-inferior-io-stop
)
708 (define-key map
"\C-c\C-\\" 'gdb-inferior-io-quit
)
709 (define-key map
"\C-c\C-d" 'gdb-inferior-io-eof
)
710 (define-key map
"\C-d" 'gdb-inferior-io-eof
)
713 (define-derived-mode gdb-inferior-io-mode comint-mode
"Inferior I/O"
714 "Major mode for gdb inferior-io."
715 :syntax-table nil
:abbrev-table nil
716 ;; We want to use comint because it has various nifty and familiar
717 ;; features. We don't need a process, but comint wants one, so create
719 (make-comint-in-buffer
720 (substring (buffer-name) 1 (- (length (buffer-name)) 1))
721 (current-buffer) "hexl")
722 (setq comint-input-sender
'gdb-inferior-io-sender
))
724 (defun gdb-inferior-io-sender (proc string
)
725 ;; PROC is the pseudo-process created to satisfy comint.
726 (with-current-buffer (process-buffer proc
)
727 (setq proc
(get-buffer-process gud-comint-buffer
))
728 (process-send-string proc string
)
729 (process-send-string proc
"\n")))
731 (defun gdb-inferior-io-interrupt ()
732 "Interrupt the program being debugged."
735 (get-buffer-process gud-comint-buffer
) comint-ptyp
))
737 (defun gdb-inferior-io-quit ()
738 "Send quit signal to the program being debugged."
741 (get-buffer-process gud-comint-buffer
) comint-ptyp
))
743 (defun gdb-inferior-io-stop ()
744 "Stop the program being debugged."
747 (get-buffer-process gud-comint-buffer
) comint-ptyp
))
749 (defun gdb-inferior-io-eof ()
750 "Send end-of-file to the program being debugged."
753 (get-buffer-process gud-comint-buffer
)))
757 ;; gdb communications
760 ;; INPUT: things sent to gdb
762 ;; The queues are lists. Each element is either a string (indicating user or
763 ;; user-like input) or a list of the form:
765 ;; (INPUT-STRING HANDLER-FN)
767 ;; The handler function will be called from the partial-output buffer when the
768 ;; command completes. This is the way to write commands which invoke gdb
769 ;; commands autonomously.
771 ;; These lists are consumed tail first.
774 (defun gdb-send (proc string
)
775 "A comint send filter for gdb.
776 This filter may simply queue input for a later time."
777 (let ((item (concat string
"\n")))
780 (if gdb-enable-debug-log
(push (cons 'send item
) gdb-debug-log
))
781 (process-send-string proc item
))
782 (gdb-enqueue-input item
))))
784 ;; Note: Stuff enqueued here will be sent to the next prompt, even if it
785 ;; is a query, or other non-top-level prompt.
787 (defun gdb-enqueue-input (item)
791 (setq gdb-prompting nil
))
792 (push item gdb-input-queue
)))
794 (defun gdb-dequeue-input ()
795 (let ((queue gdb-input-queue
))
797 (let ((last (car (last queue
))))
798 (unless (nbutlast queue
) (setq gdb-input-queue
'()))
801 (defun gdb-send-item (item)
802 (setq gdb-flush-pending-output nil
)
803 (if gdb-enable-debug-log
(push (cons 'send-item item
) gdb-debug-log
))
804 (setq gdb-current-item item
)
805 (with-current-buffer gud-comint-buffer
806 (if (eq gud-minor-mode
'gdba
)
809 (setq gdb-output-sink
'user
)
810 (process-send-string (get-buffer-process gud-comint-buffer
) item
))
812 (gdb-clear-partial-output)
813 (setq gdb-output-sink
'pre-emacs
)
814 (process-send-string (get-buffer-process gud-comint-buffer
)
816 ;; case: eq gud-minor-mode 'gdbmi
817 (gdb-clear-partial-output)
818 (setq gdb-output-sink
'emacs
)
819 (process-send-string (get-buffer-process gud-comint-buffer
)
823 ;; output -- things gdb prints to emacs
825 ;; GDB output is a stream interrupted by annotations.
826 ;; Annotations can be recognized by their beginning
827 ;; with \C-j\C-z\C-z<tag><opt>\C-j
829 ;; The tag is a string obeying symbol syntax.
831 ;; The optional part `<opt>' can be either the empty string
832 ;; or a space followed by more data relating to the annotation.
833 ;; For example, the SOURCE annotation is followed by a filename,
834 ;; line number and various useless goo. This data must not include
838 (defcustom gud-gdba-command-name
"gdb -annotate=3"
839 "Default command to execute an executable under the GDB-UI debugger."
844 (defvar gdb-annotation-rules
845 '(("pre-prompt" gdb-pre-prompt
)
846 ("prompt" gdb-prompt
)
847 ("commands" gdb-subprompt
)
848 ("overload-choice" gdb-subprompt
)
849 ("query" gdb-subprompt
)
850 ;; Need this prompt for GDB 6.1
851 ("nquery" gdb-subprompt
)
852 ("prompt-for-continue" gdb-subprompt
)
853 ("post-prompt" gdb-post-prompt
)
854 ("source" gdb-source
)
855 ("starting" gdb-starting
)
856 ("exited" gdb-exited
)
857 ("signalled" gdb-exited
)
858 ("signal" gdb-stopping
)
859 ("breakpoint" gdb-stopping
)
860 ("watchpoint" gdb-stopping
)
861 ("frame-begin" gdb-frame-begin
)
862 ("stopped" gdb-stopped
)
863 ) "An assoc mapping annotation tags to functions which process them.")
866 (setq gdb-flush-pending-output t
)
867 (setq gud-running nil
)
868 (setq gdb-output-sink
'user
)
869 (setq gdb-input-queue nil
)
870 (setq gdb-pending-triggers nil
)
871 (setq gdb-prompting t
))
873 (defconst gdb-source-spec-regexp
874 "\\(.*\\):\\([0-9]*\\):[0-9]*:[a-z]*:0x0*\\([a-f0-9]*\\)")
876 ;; Do not use this except as an annotation handler.
877 (defun gdb-source (args)
878 (string-match gdb-source-spec-regexp args
)
879 ;; Extract the frame position from the marker.
882 (match-string 1 args
)
883 (string-to-number (match-string 2 args
))))
884 (setq gdb-frame-address
(match-string 3 args
))
885 ;; cover for auto-display output which comes *before*
886 ;; stopped annotation
887 (if (eq gdb-output-sink
'inferior
) (setq gdb-output-sink
'user
)))
889 (defun gdb-pre-prompt (ignored)
890 "An annotation handler for `pre-prompt'.
891 This terminates the collection of output from a previous command if that
892 happens to be in effect."
893 (let ((sink gdb-output-sink
))
897 (setq gdb-output-sink
'post-emacs
))
900 (error "Phase error in gdb-pre-prompt (got %s)" sink
)))))
902 (defun gdb-prompt (ignored)
903 "An annotation handler for `prompt'.
904 This sends the next command (if any) to gdb."
905 (when gdb-first-prompt
(gdb-ann3))
906 (let ((sink gdb-output-sink
))
909 ((eq sink
'post-emacs
)
910 (setq gdb-output-sink
'user
)
912 (car (cdr gdb-current-item
))))
913 (with-current-buffer (gdb-get-create-buffer 'gdb-partial-output-buffer
)
917 (error "Phase error in gdb-prompt (got %s)" sink
))))
918 (let ((input (gdb-dequeue-input)))
920 (gdb-send-item input
)
922 (setq gdb-prompting t
)
923 (gud-display-frame)))))
925 (defun gdb-subprompt (ignored)
926 "An annotation handler for non-top-level prompts."
927 (setq gdb-prompting t
))
929 (defun gdb-starting (ignored)
930 "An annotation handler for `starting'.
931 This says that I/O for the subprocess is now the program being debugged,
933 (setq gdb-active-process t
)
934 (let ((sink gdb-output-sink
))
939 (if gdb-use-inferior-io-buffer
940 (setq gdb-output-sink
'inferior
))))
943 (error "Unexpected `starting' annotation")))))
945 (defun gdb-stopping (ignored)
946 "An annotation handler for `breakpoint' and other annotations.
947 They say that I/O for the subprocess is now GDB, not the program
949 (if gdb-use-inferior-io-buffer
950 (let ((sink gdb-output-sink
))
953 (setq gdb-output-sink
'user
))
956 (error "Unexpected stopping annotation"))))))
958 (defun gdb-exited (ignored)
959 "An annotation handler for `exited' and `signalled'.
960 They say that I/O for the subprocess is now GDB, not the program
961 being debugged and that the program is no longer running. This
962 function is used to change the focus of GUD tooltips to #define
964 (setq gdb-active-process nil
)
965 (gdb-stopping ignored
))
967 (defun gdb-frame-begin (ignored)
968 (let ((sink gdb-output-sink
))
971 (setq gdb-output-sink
'user
))
976 (error "Unexpected frame-begin annotation (%S)" sink
)))))
978 (defun gdb-stopped (ignored)
979 "An annotation handler for `stopped'.
980 It is just like `gdb-stopping', except that if we already set the output
981 sink to `user' in `gdb-stopping', that is fine."
982 (setq gud-running nil
)
983 (let ((sink gdb-output-sink
))
986 (setq gdb-output-sink
'user
))
990 (error "Unexpected stopped annotation")))))
992 (defun gdb-post-prompt (ignored)
993 "An annotation handler for `post-prompt'.
994 This begins the collection of output from the current command if that
995 happens to be appropriate."
996 (unless gdb-pending-triggers
997 (gdb-get-selected-frame)
998 (gdb-invalidate-frames)
999 (gdb-invalidate-breakpoints)
1000 ;; Do this through gdb-get-selected-frame -> gdb-frame-handler
1001 ;; so gdb-frame-address is updated.
1002 ;; (gdb-invalidate-assembler)
1003 (gdb-invalidate-registers)
1004 (gdb-invalidate-memory)
1005 (gdb-invalidate-locals)
1006 (gdb-invalidate-threads)
1007 (unless (eq system-type
'darwin
) ;Breaks on Darwin's GDB-5.3.
1008 ;; FIXME: with GDB-6 on Darwin, this might very well work.
1009 ;; only needed/used with speedbar/watch expressions
1010 (when (and (boundp 'speedbar-frame
) (frame-live-p speedbar-frame
))
1011 (setq gdb-var-changed t
) ; force update
1012 (dolist (var gdb-var-list
)
1013 (setcar (nthcdr 5 var
) nil
))
1015 (let ((sink gdb-output-sink
))
1018 ((eq sink
'pre-emacs
)
1019 (setq gdb-output-sink
'emacs
))
1022 (error "Phase error in gdb-post-prompt (got %s)" sink
)))))
1024 (defun gud-gdba-marker-filter (string)
1025 "A gud marker filter for gdb. Handle a burst of output from GDB."
1026 (if gdb-flush-pending-output
1028 (if gdb-enable-debug-log
(push (cons 'recv string
) gdb-debug-log
))
1029 ;; Recall the left over gud-marker-acc from last time
1030 (setq gud-marker-acc
(concat gud-marker-acc string
))
1031 ;; Start accumulating output for the GUD buffer
1034 ;; Process all the complete markers in this chunk.
1035 (while (string-match "\n\032\032\\(.*\\)\n" gud-marker-acc
)
1036 (let ((annotation (match-string 1 gud-marker-acc
)))
1038 ;; Stuff prior to the match is just ordinary output.
1039 ;; It is either concatenated to OUTPUT or directed
1044 (substring gud-marker-acc
0 (match-beginning 0))))
1046 ;; Take that stuff off the gud-marker-acc.
1047 (setq gud-marker-acc
(substring gud-marker-acc
(match-end 0)))
1049 ;; Parse the tag from the annotation, and maybe its arguments.
1050 (string-match "\\(\\S-*\\) ?\\(.*\\)" annotation
)
1051 (let* ((annotation-type (match-string 1 annotation
))
1052 (annotation-arguments (match-string 2 annotation
))
1053 (annotation-rule (assoc annotation-type
1054 gdb-annotation-rules
)))
1055 ;; Call the handler for this annotation.
1057 (funcall (car (cdr annotation-rule
))
1058 annotation-arguments
)
1059 ;; Else the annotation is not recognized. Ignore it silently,
1060 ;; so that GDB can add new annotations without causing
1064 ;; Does the remaining text end in a partial line?
1065 ;; If it does, then keep part of the gud-marker-acc until we get more.
1066 (if (string-match "\n\\'\\|\n\032\\'\\|\n\032\032.*\\'"
1069 ;; Everything before the potential marker start can be output.
1071 (gdb-concat-output output
1072 (substring gud-marker-acc
0
1073 (match-beginning 0))))
1075 ;; Everything after, we save, to combine with later input.
1076 (setq gud-marker-acc
(substring gud-marker-acc
1077 (match-beginning 0))))
1079 ;; In case we know the gud-marker-acc contains no partial annotations:
1081 (setq output
(gdb-concat-output output gud-marker-acc
))
1082 (setq gud-marker-acc
"")))
1085 (defun gdb-concat-output (so-far new
)
1086 (let ((sink gdb-output-sink
))
1088 ((eq sink
'user
) (concat so-far new
))
1089 ((or (eq sink
'pre-emacs
) (eq sink
'post-emacs
)) so-far
)
1091 (gdb-append-to-partial-output new
)
1093 ((eq sink
'inferior
)
1094 (gdb-append-to-inferior-io new
)
1098 (error "Bogon output sink %S" sink
)))))
1100 (defun gdb-append-to-partial-output (string)
1101 (with-current-buffer (gdb-get-create-buffer 'gdb-partial-output-buffer
)
1102 (goto-char (point-max))
1105 (defun gdb-clear-partial-output ()
1106 (with-current-buffer (gdb-get-create-buffer 'gdb-partial-output-buffer
)
1109 (defun gdb-append-to-inferior-io (string)
1110 (with-current-buffer (gdb-get-create-buffer 'gdb-inferior-io
)
1111 (goto-char (point-max))
1112 (insert-before-markers string
))
1113 (if (not (string-equal string
""))
1114 (gdb-display-buffer (gdb-get-create-buffer 'gdb-inferior-io
))))
1116 (defun gdb-clear-inferior-io ()
1117 (with-current-buffer (gdb-get-create-buffer 'gdb-inferior-io
)
1121 ;; One trick is to have a command who's output is always available in a buffer
1122 ;; of it's own, and is always up to date. We build several buffers of this
1125 ;; There are two aspects to this: gdb has to tell us when the output for that
1126 ;; command might have changed, and we have to be able to run the command
1127 ;; behind the user's back.
1129 ;; The output phasing associated with the variable gdb-output-sink
1130 ;; help us to run commands behind the user's back.
1132 ;; Below is the code for specificly managing buffers of output from one
1136 ;; The trigger function is suitable for use in the assoc GDB-ANNOTATION-RULES
1137 ;; It adds an input for the command we are tracking. It should be the
1138 ;; annotation rule binding of whatever gdb sends to tell us this command
1139 ;; might have changed it's output.
1141 ;; NAME is the function name. DEMAND-PREDICATE tests if output is really needed.
1142 ;; GDB-COMMAND is a string of such. OUTPUT-HANDLER is the function bound to the
1143 ;; input in the input queue (see comment about ``gdb communications'' above).
1145 (defmacro def-gdb-auto-update-trigger
(name demand-predicate gdb-command
1147 `(defun ,name
(&optional ignored
)
1148 (if (and (,demand-predicate
)
1150 gdb-pending-triggers
)))
1153 (list ,gdb-command
',output-handler
))
1154 (push ',name gdb-pending-triggers
)))))
1156 (defmacro def-gdb-auto-update-handler
(name trigger buf-key custom-defun
)
1158 (setq gdb-pending-triggers
1160 gdb-pending-triggers
))
1161 (let ((buf (gdb-get-buffer ',buf-key
)))
1163 (with-current-buffer buf
1164 (let ((p (window-point (get-buffer-window buf
0)))
1165 (buffer-read-only nil
))
1167 (insert-buffer-substring (gdb-get-create-buffer
1168 'gdb-partial-output-buffer
))
1169 (set-window-point (get-buffer-window buf
0) p
)))))
1170 ;; put customisation here
1173 (defmacro def-gdb-auto-updated-buffer
(buffer-key
1174 trigger-name gdb-command
1175 output-handler-name custom-defun
)
1177 (def-gdb-auto-update-trigger ,trigger-name
1178 ;; The demand predicate:
1179 (lambda () (gdb-get-buffer ',buffer-key
))
1181 ,output-handler-name
)
1182 (def-gdb-auto-update-handler ,output-handler-name
1183 ,trigger-name
,buffer-key
,custom-defun
)))
1187 ;; Breakpoint buffer : This displays the output of `info breakpoints'.
1189 (gdb-set-buffer-rules 'gdb-breakpoints-buffer
1190 'gdb-breakpoints-buffer-name
1191 'gdb-breakpoints-mode
)
1193 (def-gdb-auto-updated-buffer gdb-breakpoints-buffer
1194 ;; This defines the auto update rule for buffers of type
1195 ;; `gdb-breakpoints-buffer'.
1197 ;; It defines a function to serve as the annotation handler that
1198 ;; handles the `foo-invalidated' message. That function is called:
1199 gdb-invalidate-breakpoints
1201 ;; To update the buffer, this command is sent to gdb.
1202 "server info breakpoints\n"
1204 ;; This also defines a function to be the handler for the output
1205 ;; from the command above. That function will copy the output into
1206 ;; the appropriately typed buffer. That function will be called:
1207 gdb-info-breakpoints-handler
1208 ;; buffer specific functions
1209 gdb-info-breakpoints-custom
)
1211 (defconst breakpoint-xpm-data
1213 static char *magick[] = {
1214 /* columns rows colors chars-per-pixel */
1230 "XPM data used for breakpoint icon.")
1232 (defconst breakpoint-enabled-pbm-data
1235 0 0 0 0 1 1 1 1 0 0 0 0
1236 0 0 0 1 1 1 1 1 1 0 0 0
1237 0 0 1 1 1 1 1 1 1 1 0 0
1238 0 1 1 1 1 1 1 1 1 1 1 0
1239 0 1 1 1 1 1 1 1 1 1 1 0
1240 0 1 1 1 1 1 1 1 1 1 1 0
1241 0 1 1 1 1 1 1 1 1 1 1 0
1242 0 0 1 1 1 1 1 1 1 1 0 0
1243 0 0 0 1 1 1 1 1 1 0 0 0
1244 0 0 0 0 1 1 1 1 0 0 0 0"
1245 "PBM data used for enabled breakpoint icon.")
1247 (defconst breakpoint-disabled-pbm-data
1259 0 0 0 1 0 1 0 1 0 0"
1260 "PBM data used for disabled breakpoint icon.")
1262 (defvar breakpoint-enabled-icon nil
1263 "Icon for enabled breakpoint in display margin.")
1265 (defvar breakpoint-disabled-icon nil
1266 "Icon for disabled breakpoint in display margin.")
1268 ;; Bitmap for breakpoint in fringe
1269 (and (display-images-p)
1270 (define-fringe-bitmap 'breakpoint
1271 "\x3c\x7e\xff\xff\xff\xff\x7e\x3c"))
1273 (defface breakpoint-enabled
1277 "Face for enabled breakpoint icon in fringe."
1279 ;; compatibility alias for old name
1280 (put 'breakpoint-enabled-bitmap-face
'face-alias
'breakpoint-enabled
)
1282 (defface breakpoint-disabled
1283 ;; We use different values of grey for different background types,
1284 ;; so that on low-color displays it will end up as something visible
1285 ;; if it has to be approximated.
1286 '((((background dark
)) :foreground
"grey60")
1287 (((background light
)) :foreground
"grey40"))
1288 "Face for disabled breakpoint icon in fringe."
1290 ;; compatibility alias for old name
1291 (put 'breakpoint-disabled-bitmap-face
'face-alias
'breakpoint-disabled
)
1293 ;;-put breakpoint icons in relevant margins (even those set in the GUD buffer)
1294 (defun gdb-info-breakpoints-custom ()
1295 (let ((flag) (bptno))
1296 ;; remove all breakpoint-icons in source buffers but not assembler buffer
1297 (dolist (buffer (buffer-list))
1298 (with-current-buffer buffer
1299 (if (and (eq gud-minor-mode
'gdba
)
1300 (not (string-match "\\`\\*.+\\*\\'" (buffer-name))))
1301 (gdb-remove-breakpoint-icons (point-min) (point-max)))))
1302 (with-current-buffer (gdb-get-buffer 'gdb-breakpoints-buffer
)
1304 (goto-char (point-min))
1305 (while (< (point) (- (point-max) 1))
1307 (if (looking-at "[^\t].*?breakpoint")
1309 (looking-at "\\([0-9]+\\)\\s-+\\S-+\\s-+\\S-+\\s-+\\(.\\)")
1310 (setq bptno
(match-string 1))
1311 (setq flag
(char-after (match-beginning 2)))
1313 (if (re-search-forward " in .* at\\s-+" nil t
)
1315 (looking-at "\\(\\S-+\\):\\([0-9]+\\)")
1316 (let ((line (match-string 2)) (buffer-read-only nil
)
1317 (file (match-string 1)))
1318 (add-text-properties (line-beginning-position)
1320 '(mouse-face highlight
1321 help-echo
"mouse-2, RET: visit breakpoint"))
1322 (unless (file-exists-p file
)
1323 (setq file
(cdr (assoc bptno gdb-location-alist
))))
1325 (not (string-equal file
"File not found")))
1326 (with-current-buffer (find-file-noselect file
)
1327 (set (make-local-variable 'gud-minor-mode
)
1329 (set (make-local-variable 'tool-bar-map
)
1331 ;; only want one breakpoint icon at each
1334 (goto-line (string-to-number line
))
1335 (gdb-put-breakpoint-icon (eq flag ?y
) bptno
)))
1339 (match-string-no-properties 1) ":1\n")
1342 (list "info source\n"
1343 `(lambda () (gdb-get-location
1344 ,bptno
,line
,flag
))))))))))
1346 (if (gdb-get-buffer 'gdb-assembler-buffer
) (gdb-assembler-custom)))
1348 (defun gdb-mouse-set-clear-breakpoint (event)
1349 "Set/clear breakpoint in left fringe/margin with mouse click."
1351 (mouse-minibuffer-check event
)
1352 (let ((posn (event-end event
)))
1353 (if (numberp (posn-point posn
))
1354 (with-selected-window (posn-window posn
)
1356 (goto-char (posn-point posn
))
1357 (if (or (posn-object posn
)
1358 (eq (car (fringe-bitmaps-at-pos (posn-point posn
)))
1361 (gud-break nil
)))))))
1363 (defun gdb-mouse-toggle-breakpoint (event)
1364 "Enable/disable breakpoint in left fringe/margin with mouse click."
1366 (mouse-minibuffer-check event
)
1367 (let ((posn (event-end event
)))
1368 (if (numberp (posn-point posn
))
1369 (with-selected-window (posn-window posn
)
1371 (goto-char (posn-point posn
))
1375 ; (eq (car (fringe-bitmaps-at-pos (posn-point posn)))
1379 (let ((bptno (get-text-property
1380 0 'gdb-bptno
(car (posn-string posn
)))))
1382 (if (get-text-property
1383 0 'gdb-enabled
(car (posn-string posn
)))
1386 bptno
"\n")) 'ignore
))))))))
1388 (defun gdb-breakpoints-buffer-name ()
1389 (with-current-buffer gud-comint-buffer
1390 (concat "*breakpoints of " (gdb-get-target-string) "*")))
1392 (defun gdb-display-breakpoints-buffer ()
1393 "Display status of user-settable breakpoints."
1396 (gdb-get-create-buffer 'gdb-breakpoints-buffer
)))
1398 (defconst gdb-frame-parameters
1399 '((height .
14) (width .
80)
1401 (tool-bar-lines . nil
)
1402 (menu-bar-lines . nil
)
1403 (minibuffer . nil
)))
1405 (defun gdb-frame-breakpoints-buffer ()
1406 "Display status of user-settable breakpoints in a new frame."
1408 (let ((special-display-regexps (append special-display-regexps
'(".*")))
1409 (special-display-frame-alist gdb-frame-parameters
))
1410 (display-buffer (gdb-get-create-buffer 'gdb-breakpoints-buffer
))))
1412 (defvar gdb-breakpoints-mode-map
1413 (let ((map (make-sparse-keymap))
1414 (menu (make-sparse-keymap "Breakpoints")))
1415 (define-key menu
[quit] '("Quit" . kill-this-buffer))
1416 (define-key menu [goto] '("Goto" . gdb-goto-breakpoint))
1417 (define-key menu [delete] '("Delete" . gdb-delete-breakpoint))
1418 (define-key menu [toggle] '("Toggle" . gdb-toggle-breakpoint))
1419 (suppress-keymap map)
1420 (define-key map [menu-bar breakpoints] (cons "Breakpoints" menu))
1421 (define-key map " " 'gdb-toggle-breakpoint)
1422 (define-key map "d" 'gdb-delete-breakpoint)
1423 (define-key map "q" 'kill-this-buffer)
1424 (define-key map "\r" 'gdb-goto-breakpoint)
1425 (define-key map [mouse-2] 'gdb-goto-breakpoint)
1426 (define-key map [follow-link] 'mouse-face)
1429 (defun gdb-breakpoints-mode ()
1430 "Major mode for gdb breakpoints.
1432 \\{gdb-breakpoints-mode-map}"
1433 (kill-all-local-variables)
1434 (setq major-mode 'gdb-breakpoints-mode)
1435 (setq mode-name "Breakpoints")
1436 (use-local-map gdb-breakpoints-mode-map)
1437 (setq buffer-read-only t)
1438 (run-mode-hooks 'gdb-breakpoints-mode-hook)
1439 (if (with-current-buffer gud-comint-buffer (eq gud-minor-mode 'gdba))
1440 'gdb-invalidate-breakpoints
1441 'gdbmi-invalidate-breakpoints))
1443 (defun gdb-toggle-breakpoint ()
1444 "Enable/disable breakpoint at current line."
1447 (beginning-of-line 1)
1448 (if (if (with-current-buffer gud-comint-buffer (eq gud-minor-mode 'gdba))
1449 (looking-at "\\([0-9]+\\).*?point\\s-+\\S-+\\s-+\\(.\\)\\s-+")
1451 "\\([0-9]+\\)\\s-+\\S-+\\s-+\\S-+\\s-+\\(.\\)\\s-+\\S-+\\s-+\\S-+:[0-9]+"))
1454 (concat gdb-server-prefix
1455 (if (eq ?y (char-after (match-beginning 2)))
1458 (match-string 1) "\n") 'ignore))
1459 (error "Not recognized as break/watchpoint line"))))
1461 (defun gdb-delete-breakpoint ()
1462 "Delete the breakpoint at current line."
1464 (beginning-of-line 1)
1465 (if (if (with-current-buffer gud-comint-buffer (eq gud-minor-mode 'gdba))
1466 (looking-at "\\([0-9]+\\).*?point\\s-+\\S-+\\s-+\\(.\\)")
1468 "\\([0-9]+\\)\\s-+\\S-+\\s-+\\S-+\\s-+\\s-+\\S-+\\s-+\\S-+:[0-9]+"))
1471 (concat gdb-server-prefix "delete " (match-string 1) "\n") 'ignore))
1472 (error "Not recognized as break/watchpoint line")))
1474 (defun gdb-goto-breakpoint (&optional event)
1475 "Display the breakpoint location specified at current line."
1476 (interactive (list last-input-event))
1477 (if event (mouse-set-point event))
1479 (beginning-of-line 1)
1480 (if (if (with-current-buffer gud-comint-buffer (eq gud-minor-mode 'gdba))
1481 (looking-at "\\([0-9]+\\) .+ in .+ at\\s-+\\(\\S-+\\):\\([0-9]+\\)")
1483 "\\([0-9]+\\)\\s-+\\S-+\\s-+\\S-+\\s-+.\\s-+\\S-+\\s-+\
1484 \\(\\S-+\\):\\([0-9]+\\)"))
1485 (let ((bptno (match-string 1))
1486 (file (match-string 2))
1487 (line (match-string 3)))
1488 (save-selected-window
1489 (let* ((buf (find-file-noselect
1490 (if (file-exists-p file) file
1491 (cdr (assoc bptno gdb-location-alist)))))
1492 (window (display-buffer buf)))
1493 (with-current-buffer buf
1494 (goto-line (string-to-number line))
1495 (set-window-point window (point))))))
1496 (error "Not recognized as break/watchpoint line"))))
1499 ;; Frames buffer. This displays a perpetually correct bactracktrace
1500 ;; (from the command `where').
1502 ;; Alas, if your stack is deep, it is costly.
1504 (gdb-set-buffer-rules 'gdb-stack-buffer
1505 'gdb-stack-buffer-name
1508 (def-gdb-auto-updated-buffer gdb-stack-buffer
1509 gdb-invalidate-frames
1511 gdb-info-frames-handler
1512 gdb-info-frames-custom)
1514 (defun gdb-info-frames-custom ()
1515 (with-current-buffer (gdb-get-buffer 'gdb-stack-buffer)
1517 (let ((buffer-read-only nil))
1518 (goto-char (point-min))
1519 (while (< (point) (point-max))
1520 (add-text-properties (line-beginning-position) (line-end-position)
1521 '(mouse-face highlight
1522 help-echo "mouse-2, RET: Select frame"))
1524 (when (and (looking-at "^#\\([0-9]+\\)")
1525 (equal (match-string 1) gdb-frame-number))
1526 (put-text-property (line-beginning-position) (line-end-position)
1527 'face '(:inverse-video t)))
1528 (forward-line 1))))))
1530 (defun gdb-stack-buffer-name ()
1531 (with-current-buffer gud-comint-buffer
1532 (concat "*stack frames of " (gdb-get-target-string) "*")))
1534 (defun gdb-display-stack-buffer ()
1535 "Display backtrace of current stack."
1538 (gdb-get-create-buffer 'gdb-stack-buffer)))
1540 (defun gdb-frame-stack-buffer ()
1541 "Display backtrace of current stack in a new frame."
1543 (let ((special-display-regexps (append special-display-regexps '(".*")))
1544 (special-display-frame-alist gdb-frame-parameters))
1545 (display-buffer (gdb-get-create-buffer 'gdb-stack-buffer))))
1547 (defvar gdb-frames-mode-map
1548 (let ((map (make-sparse-keymap)))
1549 (suppress-keymap map)
1550 (define-key map "q" 'kill-this-buffer)
1551 (define-key map "\r" 'gdb-frames-select)
1552 (define-key map [mouse-2] 'gdb-frames-select)
1553 (define-key map [follow-link] 'mouse-face)
1556 (defun gdb-frames-mode ()
1557 "Major mode for gdb frames.
1559 \\{gdb-frames-mode-map}"
1560 (kill-all-local-variables)
1561 (setq major-mode 'gdb-frames-mode)
1562 (setq mode-name "Frames")
1563 (setq buffer-read-only t)
1564 (use-local-map gdb-frames-mode-map)
1566 (run-mode-hooks 'gdb-frames-mode-hook)
1567 (if (with-current-buffer gud-comint-buffer (eq gud-minor-mode 'gdba))
1568 'gdb-invalidate-frames
1569 'gdbmi-invalidate-frames))
1571 (defun gdb-get-frame-number ()
1573 (let* ((pos (re-search-backward "^#*\\([0-9]*\\)" nil t))
1574 (n (or (and pos (match-string-no-properties 1)) "0")))
1577 (defun gdb-frames-select (&optional event)
1578 "Select the frame and display the relevant source."
1579 (interactive (list last-input-event))
1580 (if event (mouse-set-point event))
1582 (list (concat gdb-server-prefix "frame "
1583 (gdb-get-frame-number) "\n") 'ignore))
1584 (gud-display-frame))
1587 ;; Threads buffer. This displays a selectable thread list.
1589 (gdb-set-buffer-rules 'gdb-threads-buffer
1590 'gdb-threads-buffer-name
1593 (def-gdb-auto-updated-buffer gdb-threads-buffer
1594 gdb-invalidate-threads
1595 (concat gdb-server-prefix "info threads\n")
1596 gdb-info-threads-handler
1597 gdb-info-threads-custom)
1599 (defun gdb-info-threads-custom ()
1600 (with-current-buffer (gdb-get-buffer 'gdb-threads-buffer)
1601 (let ((buffer-read-only nil))
1602 (goto-char (point-min))
1603 (while (< (point) (point-max))
1604 (add-text-properties (line-beginning-position) (line-end-position)
1605 '(mouse-face highlight
1606 help-echo "mouse-2, RET: select thread"))
1607 (forward-line 1)))))
1609 (defun gdb-threads-buffer-name ()
1610 (with-current-buffer gud-comint-buffer
1611 (concat "*threads of " (gdb-get-target-string) "*")))
1613 (defun gdb-display-threads-buffer ()
1614 "Display IDs of currently known threads."
1617 (gdb-get-create-buffer 'gdb-threads-buffer)))
1619 (defun gdb-frame-threads-buffer ()
1620 "Display IDs of currently known threads in a new frame."
1622 (let ((special-display-regexps (append special-display-regexps '(".*")))
1623 (special-display-frame-alist gdb-frame-parameters))
1624 (display-buffer (gdb-get-create-buffer 'gdb-threads-buffer))))
1626 (defvar gdb-threads-mode-map
1627 (let ((map (make-sparse-keymap)))
1628 (suppress-keymap map)
1629 (define-key map "q" 'kill-this-buffer)
1630 (define-key map "\r" 'gdb-threads-select)
1631 (define-key map [mouse-2] 'gdb-threads-select)
1634 (defun gdb-threads-mode ()
1635 "Major mode for gdb frames.
1637 \\{gdb-threads-mode-map}"
1638 (kill-all-local-variables)
1639 (setq major-mode 'gdb-threads-mode)
1640 (setq mode-name "Threads")
1641 (setq buffer-read-only t)
1642 (use-local-map gdb-threads-mode-map)
1643 (run-mode-hooks 'gdb-threads-mode-hook)
1644 'gdb-invalidate-threads)
1646 (defun gdb-get-thread-number ()
1648 (re-search-backward "^\\s-*\\([0-9]*\\)" nil t)
1649 (match-string-no-properties 1)))
1651 (defun gdb-threads-select (&optional event)
1652 "Select the thread and display the relevant source."
1653 (interactive (list last-input-event))
1654 (if event (mouse-set-point event))
1656 (list (concat "thread " (gdb-get-thread-number) "\n") 'ignore))
1657 (gud-display-frame))
1660 ;; Registers buffer.
1662 (defcustom gdb-all-registers nil
1663 "Non-nil means include floating-point registers."
1668 (gdb-set-buffer-rules 'gdb-registers-buffer
1669 'gdb-registers-buffer-name
1670 'gdb-registers-mode)
1672 (def-gdb-auto-updated-buffer gdb-registers-buffer
1673 gdb-invalidate-registers
1675 gdb-server-prefix "info " (if gdb-all-registers "all-") "registers\n")
1676 gdb-info-registers-handler
1677 gdb-info-registers-custom)
1679 (defun gdb-info-registers-custom ())
1681 (defvar gdb-registers-mode-map
1682 (let ((map (make-sparse-keymap)))
1683 (suppress-keymap map)
1684 (define-key map " " 'toggle-gdb-all-registers)
1685 (define-key map "q" 'kill-this-buffer)
1688 (defun gdb-registers-mode ()
1689 "Major mode for gdb registers.
1691 \\{gdb-registers-mode-map}"
1692 (kill-all-local-variables)
1693 (setq major-mode 'gdb-registers-mode)
1694 (setq mode-name "Registers:")
1695 (setq buffer-read-only t)
1696 (use-local-map gdb-registers-mode-map)
1697 (run-mode-hooks 'gdb-registers-mode-hook)
1698 'gdb-invalidate-registers)
1700 (defun gdb-registers-buffer-name ()
1701 (with-current-buffer gud-comint-buffer
1702 (concat "*registers of " (gdb-get-target-string) "*")))
1704 (defun gdb-display-registers-buffer ()
1705 "Display integer register contents."
1708 (gdb-get-create-buffer 'gdb-registers-buffer)))
1710 (defun gdb-frame-registers-buffer ()
1711 "Display integer register contents in a new frame."
1713 (let ((special-display-regexps (append special-display-regexps '(".*")))
1714 (special-display-frame-alist gdb-frame-parameters))
1715 (display-buffer (gdb-get-create-buffer 'gdb-registers-buffer))))
1717 (defun toggle-gdb-all-registers ()
1718 "Toggle the display of floating-point registers."
1720 (if gdb-all-registers
1722 (setq gdb-all-registers nil)
1723 (with-current-buffer (gdb-get-buffer 'gdb-registers-buffer)
1724 (setq mode-name "Registers:")))
1725 (setq gdb-all-registers t)
1726 (with-current-buffer (gdb-get-buffer 'gdb-registers-buffer)
1727 (setq mode-name "Registers:All")))
1728 (gdb-invalidate-registers))
1733 (defcustom gdb-memory-repeat-count 32
1734 "Number of data items in memory window."
1739 (defcustom gdb-memory-format "x"
1740 "Display format of data items in memory window."
1741 :type '(choice (const :tag "Hexadecimal" "x")
1742 (const :tag "Signed decimal" "d")
1743 (const :tag "Unsigned decimal" "u")
1744 (const :tag "Octal" "o")
1745 (const :tag "Binary" "t"))
1749 (defcustom gdb-memory-unit "w"
1750 "Unit size of data items in memory window."
1751 :type '(choice (const :tag "Byte" "b")
1752 (const :tag "Halfword" "h")
1753 (const :tag "Word" "w")
1754 (const :tag "Giant word" "g"))
1758 (gdb-set-buffer-rules 'gdb-memory-buffer
1759 'gdb-memory-buffer-name
1762 (def-gdb-auto-updated-buffer gdb-memory-buffer
1763 gdb-invalidate-memory
1764 (concat gdb-server-prefix "x/" (number-to-string gdb-memory-repeat-count)
1765 gdb-memory-format gdb-memory-unit " " gdb-memory-address "\n")
1766 gdb-read-memory-handler
1767 gdb-read-memory-custom)
1769 (defun gdb-read-memory-custom ()
1771 (goto-char (point-min))
1772 (if (looking-at "0x[[:xdigit:]]+")
1773 (setq gdb-memory-address (match-string 0)))))
1775 (defvar gdb-memory-mode-map
1776 (let ((map (make-sparse-keymap)))
1777 (suppress-keymap map)
1778 (define-key map "q" 'kill-this-buffer)
1781 (defun gdb-memory-set-address (event)
1782 "Set the start memory address."
1784 (save-selected-window
1785 (select-window (posn-window (event-start event)))
1786 (let ((arg (read-from-minibuffer "Memory address: ")))
1787 (setq gdb-memory-address arg))
1788 (gdb-invalidate-memory)))
1790 (defun gdb-memory-set-repeat-count (event)
1791 "Set the number of data items in memory window."
1793 (save-selected-window
1794 (select-window (posn-window (event-start event)))
1795 (let* ((arg (read-from-minibuffer "Repeat count: "))
1796 (count (string-to-number arg)))
1798 (error "Positive numbers only")
1799 (customize-set-variable 'gdb-memory-repeat-count count)
1800 (gdb-invalidate-memory)))))
1802 (defun gdb-memory-format-binary ()
1803 "Set the display format to binary."
1805 (customize-set-variable 'gdb-memory-format "t")
1806 (gdb-invalidate-memory))
1808 (defun gdb-memory-format-octal ()
1809 "Set the display format to octal."
1811 (customize-set-variable 'gdb-memory-format "o")
1812 (gdb-invalidate-memory))
1814 (defun gdb-memory-format-unsigned ()
1815 "Set the display format to unsigned decimal."
1817 (customize-set-variable 'gdb-memory-format "u")
1818 (gdb-invalidate-memory))
1820 (defun gdb-memory-format-signed ()
1821 "Set the display format to decimal."
1823 (customize-set-variable 'gdb-memory-format "d")
1824 (gdb-invalidate-memory))
1826 (defun gdb-memory-format-hexadecimal ()
1827 "Set the display format to hexadecimal."
1829 (customize-set-variable 'gdb-memory-format "x")
1830 (gdb-invalidate-memory))
1832 (defvar gdb-memory-format-keymap
1833 (let ((map (make-sparse-keymap)))
1834 (define-key map [header-line down-mouse-3] 'gdb-memory-format-menu-1)
1836 "Keymap to select format in the header line.")
1838 (defvar gdb-memory-format-menu (make-sparse-keymap "Format")
1839 "Menu of display formats in the header line.")
1841 (define-key gdb-memory-format-menu [binary]
1842 '(menu-item "Binary" gdb-memory-format-binary
1843 :button (:radio . (equal gdb-memory-format "t"))))
1844 (define-key gdb-memory-format-menu [octal]
1845 '(menu-item "Octal" gdb-memory-format-octal
1846 :button (:radio . (equal gdb-memory-format "o"))))
1847 (define-key gdb-memory-format-menu [unsigned]
1848 '(menu-item "Unsigned Decimal" gdb-memory-format-unsigned
1849 :button (:radio . (equal gdb-memory-format "u"))))
1850 (define-key gdb-memory-format-menu [signed]
1851 '(menu-item "Signed Decimal" gdb-memory-format-signed
1852 :button (:radio . (equal gdb-memory-format "d"))))
1853 (define-key gdb-memory-format-menu [hexadecimal]
1854 '(menu-item "Hexadecimal" gdb-memory-format-hexadecimal
1855 :button (:radio . (equal gdb-memory-format "x"))))
1857 (defun gdb-memory-format-menu (event)
1859 (x-popup-menu event gdb-memory-format-menu))
1861 (defun gdb-memory-format-menu-1 (event)
1863 (save-selected-window
1864 (select-window (posn-window (event-start event)))
1865 (let* ((selection (gdb-memory-format-menu event))
1866 (binding (and selection (lookup-key gdb-memory-format-menu
1867 (vector (car selection))))))
1868 (if binding (call-interactively binding)))))
1870 (defun gdb-memory-unit-giant ()
1871 "Set the unit size to giant words (eight bytes)."
1873 (customize-set-variable 'gdb-memory-unit "g")
1874 (gdb-invalidate-memory))
1876 (defun gdb-memory-unit-word ()
1877 "Set the unit size to words (four bytes)."
1879 (customize-set-variable 'gdb-memory-unit "w")
1880 (gdb-invalidate-memory))
1882 (defun gdb-memory-unit-halfword ()
1883 "Set the unit size to halfwords (two bytes)."
1885 (customize-set-variable 'gdb-memory-unit "h")
1886 (gdb-invalidate-memory))
1888 (defun gdb-memory-unit-byte ()
1889 "Set the unit size to bytes."
1891 (customize-set-variable 'gdb-memory-unit "b")
1892 (gdb-invalidate-memory))
1894 (defvar gdb-memory-unit-keymap
1895 (let ((map (make-sparse-keymap)))
1896 (define-key map [header-line down-mouse-3] 'gdb-memory-unit-menu-1)
1898 "Keymap to select units in the header line.")
1900 (defvar gdb-memory-unit-menu (make-sparse-keymap "Unit")
1901 "Menu of units in the header line.")
1903 (define-key gdb-memory-unit-menu [giantwords]
1904 '(menu-item "Giant words" gdb-memory-unit-giant
1905 :button (:radio . (equal gdb-memory-unit "g"))))
1906 (define-key gdb-memory-unit-menu [words]
1907 '(menu-item "Words" gdb-memory-unit-word
1908 :button (:radio . (equal gdb-memory-unit "w"))))
1909 (define-key gdb-memory-unit-menu [halfwords]
1910 '(menu-item "Halfwords" gdb-memory-unit-halfword
1911 :button (:radio . (equal gdb-memory-unit "h"))))
1912 (define-key gdb-memory-unit-menu [bytes]
1913 '(menu-item "Bytes" gdb-memory-unit-byte
1914 :button (:radio . (equal gdb-memory-unit "b"))))
1916 (defun gdb-memory-unit-menu (event)
1918 (x-popup-menu event gdb-memory-unit-menu))
1920 (defun gdb-memory-unit-menu-1 (event)
1922 (save-selected-window
1923 (select-window (posn-window (event-start event)))
1924 (let* ((selection (gdb-memory-unit-menu event))
1925 (binding (and selection (lookup-key gdb-memory-unit-menu
1926 (vector (car selection))))))
1927 (if binding (call-interactively binding)))))
1929 ;;from make-mode-line-mouse-map
1930 (defun gdb-make-header-line-mouse-map (mouse function) "\
1931 Return a keymap with single entry for mouse key MOUSE on the header line.
1932 MOUSE is defined to run function FUNCTION with no args in the buffer
1933 corresponding to the mode line clicked."
1934 (let ((map (make-sparse-keymap)))
1935 (define-key map (vector 'header-line mouse) function)
1936 (define-key map (vector 'header-line 'down-mouse-1) 'ignore)
1939 (defun gdb-memory-mode ()
1940 "Major mode for examining memory.
1942 \\{gdb-memory-mode-map}"
1943 (kill-all-local-variables)
1944 (setq major-mode 'gdb-memory-mode)
1945 (setq mode-name "Memory")
1946 (setq buffer-read-only t)
1947 (use-local-map gdb-memory-mode-map)
1948 (setq header-line-format
1954 'face font-lock-warning-face
1955 'help-echo "mouse-1: Decrement address"
1956 'mouse-face 'mode-line-highlight
1958 (gdb-make-header-line-mouse-map
1960 #'(lambda () (interactive)
1961 (let ((gdb-memory-address
1962 ;; let GDB do the arithmetic
1964 gdb-memory-address " - "
1966 (* gdb-memory-repeat-count
1967 (cond ((string= gdb-memory-unit "b") 1)
1968 ((string= gdb-memory-unit "h") 2)
1969 ((string= gdb-memory-unit "w") 4)
1970 ((string= gdb-memory-unit "g") 8)))))))
1971 (gdb-invalidate-memory)))))
1974 'face font-lock-warning-face
1975 'help-echo "mouse-1: Increment address"
1976 'mouse-face 'mode-line-highlight
1977 'local-map (gdb-make-header-line-mouse-map
1979 #'(lambda () (interactive)
1980 (let ((gdb-memory-address nil))
1981 (gdb-invalidate-memory)))))
1983 (propertize gdb-memory-address
1984 'face font-lock-warning-face
1985 'help-echo "mouse-1: Set memory address"
1986 'mouse-face 'mode-line-highlight
1987 'local-map (gdb-make-header-line-mouse-map
1989 #'gdb-memory-set-address))
1991 (propertize (number-to-string gdb-memory-repeat-count)
1992 'face font-lock-warning-face
1993 'help-echo "mouse-1: Set repeat count"
1994 'mouse-face 'mode-line-highlight
1995 'local-map (gdb-make-header-line-mouse-map
1997 #'gdb-memory-set-repeat-count))
1999 (propertize gdb-memory-format
2000 'face font-lock-warning-face
2001 'help-echo "mouse-3: Select display format"
2002 'mouse-face 'mode-line-highlight
2003 'local-map gdb-memory-format-keymap)
2005 (propertize gdb-memory-unit
2006 'face font-lock-warning-face
2007 'help-echo "mouse-3: Select unit size"
2008 'mouse-face 'mode-line-highlight
2009 'local-map gdb-memory-unit-keymap))))
2010 (run-mode-hooks 'gdb-memory-mode-hook)
2011 'gdb-invalidate-memory)
2013 (defun gdb-memory-buffer-name ()
2014 (with-current-buffer gud-comint-buffer
2015 (concat "*memory of " (gdb-get-target-string) "*")))
2017 (defun gdb-display-memory-buffer ()
2018 "Display memory contents."
2021 (gdb-get-create-buffer 'gdb-memory-buffer)))
2023 (defun gdb-frame-memory-buffer ()
2024 "Display memory contents in a new frame."
2026 (let ((special-display-regexps (append special-display-regexps '(".*")))
2027 (special-display-frame-alist gdb-frame-parameters))
2028 (display-buffer (gdb-get-create-buffer 'gdb-memory-buffer))))
2033 (gdb-set-buffer-rules 'gdb-locals-buffer
2034 'gdb-locals-buffer-name
2037 (def-gdb-auto-updated-buffer gdb-locals-buffer
2038 gdb-invalidate-locals
2039 "server info locals\n"
2040 gdb-info-locals-handler
2041 gdb-info-locals-custom)
2043 ;; Abbreviate for arrays and structures.
2044 ;; These can be expanded using gud-display.
2045 (defun gdb-info-locals-handler nil
2046 (setq gdb-pending-triggers (delq 'gdb-invalidate-locals
2047 gdb-pending-triggers))
2048 (let ((buf (gdb-get-buffer 'gdb-partial-output-buffer)))
2049 (with-current-buffer buf
2050 (goto-char (point-min))
2051 (while (re-search-forward "^[ }].*\n" nil t)
2052 (replace-match "" nil nil))
2053 (goto-char (point-min))
2054 (while (re-search-forward "{\\(.*=.*\n\\|\n\\)" nil t)
2055 (replace-match "(structure);\n" nil nil))
2056 (goto-char (point-min))
2057 (while (re-search-forward "\\s-*{.*\n" nil t)
2058 (replace-match " (array);\n" nil nil))))
2059 (let ((buf (gdb-get-buffer 'gdb-locals-buffer)))
2060 (and buf (with-current-buffer buf
2062 (buffer-read-only nil))
2063 (delete-region (point-min) (point-max))
2064 (insert-buffer-substring (gdb-get-create-buffer
2065 'gdb-partial-output-buffer))
2067 (run-hooks 'gdb-info-locals-hook))
2069 (defun gdb-info-locals-custom ()
2072 (defvar gdb-locals-mode-map
2073 (let ((map (make-sparse-keymap)))
2074 (suppress-keymap map)
2075 (define-key map "q" 'kill-this-buffer)
2078 (defun gdb-locals-mode ()
2079 "Major mode for gdb locals.
2081 \\{gdb-locals-mode-map}"
2082 (kill-all-local-variables)
2083 (setq major-mode 'gdb-locals-mode)
2084 (setq mode-name (concat "Locals:" gdb-selected-frame))
2085 (setq buffer-read-only t)
2086 (use-local-map gdb-locals-mode-map)
2087 (run-mode-hooks 'gdb-locals-mode-hook)
2088 (if (with-current-buffer gud-comint-buffer (eq gud-minor-mode 'gdba))
2089 'gdb-invalidate-locals
2090 'gdbmi-invalidate-locals))
2092 (defun gdb-locals-buffer-name ()
2093 (with-current-buffer gud-comint-buffer
2094 (concat "*locals of " (gdb-get-target-string) "*")))
2096 (defun gdb-display-locals-buffer ()
2097 "Display local variables of current stack and their values."
2100 (gdb-get-create-buffer 'gdb-locals-buffer)))
2102 (defun gdb-frame-locals-buffer ()
2103 "Display local variables of current stack and their values in a new frame."
2105 (let ((special-display-regexps (append special-display-regexps '(".*")))
2106 (special-display-frame-alist gdb-frame-parameters))
2107 (display-buffer (gdb-get-create-buffer 'gdb-locals-buffer))))
2110 ;;;; Window management
2111 (defun gdb-display-buffer (buf &optional size)
2112 (let ((answer (get-buffer-window buf 0))
2115 (display-buffer buf nil 0) ;Raise the frame if necessary.
2116 ;; The buffer is not yet displayed.
2117 (pop-to-buffer gud-comint-buffer) ;Select the right frame.
2118 (let ((window (get-lru-window)))
2120 (not (eq window (get-buffer-window gud-comint-buffer))))
2122 (set-window-buffer window buf)
2123 (setq answer window))
2124 (setq must-split t)))
2126 (let* ((largest (get-largest-window))
2127 (cur-size (window-height largest))
2128 (new-size (and size (< size cur-size) (- cur-size size))))
2129 (setq answer (split-window largest new-size))
2130 (set-window-buffer answer buf)
2131 (set-window-dedicated-p answer t)))
2135 ;;; Shared keymap initialization:
2137 (let ((menu (make-sparse-keymap "GDB-Windows")))
2138 (define-key gud-menu-map [displays]
2139 `(menu-item "GDB-Windows" ,menu
2140 :visible (memq gud-minor-mode '(gdbmi gdba))))
2141 (define-key menu [gdb] '("Gdb" . gdb-display-gdb-buffer))
2142 (define-key menu [threads] '("Threads" . gdb-display-threads-buffer))
2143 (define-key menu [memory] '("Memory" . gdb-display-memory-buffer))
2144 (define-key menu [disassembly]
2145 '("Disassembly" . gdb-display-assembler-buffer))
2146 (define-key menu [registers] '("Registers" . gdb-display-registers-buffer))
2147 (define-key menu [inferior]
2148 '(menu-item "Inferior IO" gdb-display-inferior-io-buffer
2149 :enable gdb-use-inferior-io-buffer))
2150 (define-key menu [locals] '("Locals" . gdb-display-locals-buffer))
2151 (define-key menu [frames] '("Stack" . gdb-display-stack-buffer))
2152 (define-key menu [breakpoints]
2153 '("Breakpoints" . gdb-display-breakpoints-buffer)))
2155 (let ((menu (make-sparse-keymap "GDB-Frames")))
2156 (define-key gud-menu-map [frames]
2157 `(menu-item "GDB-Frames" ,menu
2158 :visible (memq gud-minor-mode '(gdbmi gdba))))
2159 (define-key menu [gdb] '("Gdb" . gdb-frame-gdb-buffer))
2160 (define-key menu [threads] '("Threads" . gdb-frame-threads-buffer))
2161 (define-key menu [memory] '("Memory" . gdb-frame-memory-buffer))
2162 (define-key menu [disassembly] '("Disassembiy" . gdb-frame-assembler-buffer))
2163 (define-key menu [registers] '("Registers" . gdb-frame-registers-buffer))
2164 (define-key menu [inferior]
2165 '(menu-item "Inferior IO" gdb-frame-inferior-io-buffer
2166 :enable gdb-use-inferior-io-buffer))
2167 (define-key menu [locals] '("Locals" . gdb-frame-locals-buffer))
2168 (define-key menu [frames] '("Stack" . gdb-frame-stack-buffer))
2169 (define-key menu [breakpoints]
2170 '("Breakpoints" . gdb-frame-breakpoints-buffer)))
2172 (let ((menu (make-sparse-keymap "GDB-UI")))
2173 (define-key gud-menu-map [ui]
2174 `(menu-item "GDB-UI" ,menu :visible (eq gud-minor-mode 'gdba)))
2175 (define-key menu [gdb-restore-windows]
2176 '(menu-item "Restore Window Layout" gdb-restore-windows
2177 :help "Restore standard layout for debug session."))
2178 (define-key menu [gdb-many-windows]
2179 '(menu-item "Display Other Windows" gdb-many-windows
2180 :help "Toggle display of locals, stack and breakpoint information"
2181 :button (:toggle . gdb-many-windows)))
2182 (define-key menu [gdb-use-inferior-io]
2183 (menu-bar-make-toggle toggle-gdb-use-inferior-io-buffer
2184 gdb-use-inferior-io-buffer
2185 "Separate inferior IO" "Use separate IO %s"
2186 "Toggle separate IO for inferior.")))
2188 (defadvice toggle-gdb-use-inferior-io-buffer (after gdb-kill-io-buffer activate)
2189 (unless gdb-use-inferior-io-buffer
2190 (kill-buffer (gdb-inferior-io-name))))
2192 (defun gdb-frame-gdb-buffer ()
2193 "Display GUD buffer in a new frame."
2195 (select-frame (make-frame gdb-frame-parameters))
2196 (switch-to-buffer (gdb-get-create-buffer 'gdba))
2197 (set-window-dedicated-p (selected-window) t))
2199 (defun gdb-display-gdb-buffer ()
2200 "Display GUD buffer."
2203 (gdb-get-create-buffer 'gdba)))
2205 (defun gdb-set-window-buffer (name)
2206 (set-window-buffer (selected-window) (get-buffer name))
2207 (set-window-dedicated-p (selected-window) t))
2209 (defun gdb-setup-windows ()
2210 "Layout the window pattern for gdb-many-windows."
2211 (gdb-display-locals-buffer)
2212 (gdb-display-stack-buffer)
2213 (delete-other-windows)
2214 (gdb-display-breakpoints-buffer)
2215 (delete-other-windows)
2217 (pop-to-buffer gud-comint-buffer)
2218 (split-window nil ( / ( * (window-height) 3) 4))
2219 (split-window nil ( / (window-height) 3))
2220 (split-window-horizontally)
2222 (gdb-set-window-buffer (gdb-locals-buffer-name))
2225 (if gud-last-last-frame
2226 (gud-find-file (car gud-last-last-frame))
2227 (gud-find-file gdb-main-file)))
2228 (when gdb-use-inferior-io-buffer
2229 (split-window-horizontally)
2231 (gdb-set-window-buffer
2232 (gdb-get-create-buffer 'gdb-inferior-io)))
2234 (gdb-set-window-buffer (gdb-stack-buffer-name))
2235 (split-window-horizontally)
2237 (gdb-set-window-buffer (gdb-breakpoints-buffer-name))
2240 (defcustom gdb-many-windows nil
2241 "Nil means just pop up the GUD buffer unless `gdb-show-main' is t.
2242 In this case it starts with two windows: one displaying the GUD
2243 buffer and the other with the source file with the main routine
2244 of the inferior. Non-nil means display the layout shown for
2250 (defun gdb-many-windows (arg)
2251 "Toggle the number of windows in the basic arrangement."
2253 (setq gdb-many-windows
2255 (not gdb-many-windows)
2256 (> (prefix-numeric-value arg) 0)))
2258 (gdb-restore-windows)
2261 (defun gdb-restore-windows ()
2262 "Restore the basic arrangement of windows used by gdba.
2263 This arrangement depends on the value of `gdb-many-windows'."
2265 (pop-to-buffer gud-comint-buffer) ;Select the right window and frame.
2266 (delete-other-windows)
2267 (if gdb-many-windows
2272 (if gud-last-last-frame
2273 (gud-find-file (car gud-last-last-frame))
2274 (gud-find-file gdb-main-file)))
2278 "Exit a debugging session cleanly.
2279 Kills the gdb buffers and resets the source buffers."
2280 (dolist (buffer (buffer-list))
2281 (unless (eq buffer gud-comint-buffer)
2282 (with-current-buffer buffer
2283 (if (memq gud-minor-mode '(gdbmi gdba))
2284 (if (string-match "\\`\\*.+\\*\\'" (buffer-name))
2286 (gdb-remove-breakpoint-icons (point-min) (point-max) t)
2287 (setq gud-minor-mode nil)
2288 (kill-local-variable 'tool-bar-map)
2289 (kill-local-variable 'gdb-define-alist))))))
2290 (when (markerp gdb-overlay-arrow-position)
2291 (move-marker gdb-overlay-arrow-position nil)
2292 (setq gdb-overlay-arrow-position nil))
2293 (setq overlay-arrow-variable-list
2294 (delq 'gdb-overlay-arrow-position overlay-arrow-variable-list))
2295 (setq gud-running nil)
2296 (setq gdb-active-process nil)
2297 (remove-hook 'after-save-hook 'gdb-create-define-alist t))
2299 (defun gdb-source-info ()
2300 "Find the source file where the program starts and displays it with related
2302 (goto-char (point-min))
2303 (if (and (search-forward "Located in " nil t)
2304 (looking-at "\\S-+"))
2305 (setq gdb-main-file (match-string 0)))
2306 (goto-char (point-min))
2307 (if (search-forward "Includes preprocessor macro info." nil t)
2308 (setq gdb-macro-info t))
2309 (if gdb-many-windows
2311 (gdb-get-create-buffer 'gdb-breakpoints-buffer)
2313 (let ((pop-up-windows t))
2314 (display-buffer (gud-find-file gdb-main-file))))))
2316 (defun gdb-get-location (bptno line flag)
2317 "Find the directory containing the relevant source file.
2318 Put in buffer and place breakpoint icon."
2319 (goto-char (point-min))
2320 (catch 'file-not-found
2321 (if (search-forward "Located in " nil t)
2322 (when (looking-at "\\S-+")
2323 (delete (cons bptno "File not found") gdb-location-alist)
2324 (push (cons bptno (match-string 0)) gdb-location-alist))
2326 (unless (assoc bptno gdb-location-alist)
2327 (push (cons bptno "File not found") gdb-location-alist)
2328 (message-box "Cannot find source file for breakpoint location.\n\
2329 Add directory to search path for source files using the GDB command, dir."))
2330 (throw 'file-not-found nil))
2331 (with-current-buffer
2332 (find-file-noselect (match-string 0))
2333 (save-current-buffer
2334 (set (make-local-variable 'gud-minor-mode) 'gdba)
2335 (set (make-local-variable 'tool-bar-map) gud-tool-bar-map))
2336 ;; only want one breakpoint icon at each location
2338 (goto-line (string-to-number line))
2339 (gdb-put-breakpoint-icon (eq flag ?y) bptno)))))
2341 (add-hook 'find-file-hook 'gdb-find-file-hook)
2343 (defun gdb-find-file-hook ()
2344 (if (and (not gdb-find-file-unhook)
2345 ;; in case gud or gdb-ui is just loaded
2347 (buffer-name gud-comint-buffer)
2348 (with-current-buffer gud-comint-buffer
2349 (eq gud-minor-mode 'gdba)))
2352 (list (concat gdb-server-prefix "list "
2353 (file-name-nondirectory buffer-file-name)
2355 `(lambda () (gdb-set-gud-minor-mode ,(current-buffer)))))
2356 (error (setq gdb-find-file-unhook t)))))
2359 (defun gdb-put-string (putstring pos &optional dprop)
2360 "Put string PUTSTRING in front of POS in the current buffer.
2361 PUTSTRING is displayed by putting an overlay into the current buffer with a
2362 `before-string' STRING that has a `display' property whose value is
2364 (let ((string (make-string 1 ?x))
2365 (buffer (current-buffer)))
2366 (setq putstring (copy-sequence putstring))
2367 (let ((overlay (make-overlay pos pos buffer))
2369 (list (list 'margin 'left-margin) putstring))))
2370 (put-text-property 0 (length string) 'display prop string)
2371 (overlay-put overlay 'put-break t)
2372 (overlay-put overlay 'before-string string))))
2374 ;;from remove-images
2375 (defun gdb-remove-strings (start end &optional buffer)
2376 "Remove strings between START and END in BUFFER.
2377 Remove only strings that were put in BUFFER with calls to `gdb-put-string'.
2378 BUFFER nil or omitted means use the current buffer."
2380 (setq buffer (current-buffer)))
2381 (dolist (overlay (overlays-in start end))
2382 (when (overlay-get overlay 'put-break)
2383 (delete-overlay overlay))))
2385 (defun gdb-put-breakpoint-icon (enabled bptno)
2386 (let ((start (- (line-beginning-position) 1))
2387 (end (+ (line-end-position) 1))
2388 (putstring (if enabled "B" "b")))
2389 (add-text-properties
2390 0 1 '(help-echo "mouse-1: set/clear bkpt, mouse-3: enable/disable bkpt")
2392 (if enabled (add-text-properties
2393 0 1 `(gdb-bptno ,bptno gdb-enabled t) putstring)
2394 (add-text-properties
2395 0 1 `(gdb-bptno ,bptno gdb-enabled nil) putstring))
2396 (gdb-remove-breakpoint-icons start end)
2397 (if (display-images-p)
2398 (if (>= (car (window-fringes)) 8)
2401 `(left-fringe breakpoint
2404 'breakpoint-disabled)))
2405 (when (< left-margin-width 2)
2406 (save-current-buffer
2407 (setq left-margin-width 2)
2408 (if (get-buffer-window (current-buffer) 0)
2410 (get-buffer-window (current-buffer) 0)
2411 left-margin-width right-margin-width))))
2414 (or breakpoint-enabled-icon
2415 (setq breakpoint-enabled-icon
2416 (find-image `((:type xpm :data
2417 ,breakpoint-xpm-data
2418 :ascent 100 :pointer hand)
2420 ,breakpoint-enabled-pbm-data
2421 :ascent 100 :pointer hand)))))
2422 (or breakpoint-disabled-icon
2423 (setq breakpoint-disabled-icon
2424 (find-image `((:type xpm :data
2425 ,breakpoint-xpm-data
2426 :conversion disabled
2429 ,breakpoint-disabled-pbm-data
2434 (when (< left-margin-width 2)
2435 (save-current-buffer
2436 (setq left-margin-width 2)
2437 (if (get-buffer-window (current-buffer) 0)
2439 (get-buffer-window (current-buffer) 0)
2440 left-margin-width right-margin-width))))
2442 (propertize putstring
2443 'face (if enabled 'breakpoint-enabled 'breakpoint-disabled))
2446 (defun gdb-remove-breakpoint-icons (start end &optional remove-margin)
2447 (gdb-remove-strings start end)
2448 (if (display-images-p)
2449 (remove-images start end))
2451 (setq left-margin-width 0)
2452 (if (get-buffer-window (current-buffer) 0)
2454 (get-buffer-window (current-buffer) 0)
2455 left-margin-width right-margin-width))))
2459 ;; Assembler buffer.
2461 (gdb-set-buffer-rules 'gdb-assembler-buffer
2462 'gdb-assembler-buffer-name
2463 'gdb-assembler-mode)
2465 (def-gdb-auto-updated-buffer gdb-assembler-buffer
2466 gdb-invalidate-assembler
2467 (concat gdb-server-prefix "disassemble "
2468 (if (member gdb-frame-address '(nil "main")) nil "0x")
2469 gdb-frame-address "\n")
2470 gdb-assembler-handler
2471 gdb-assembler-custom)
2473 (defun gdb-assembler-custom ()
2474 (let ((buffer (gdb-get-buffer 'gdb-assembler-buffer))
2475 (pos 1) (address) (flag) (bptno))
2476 (with-current-buffer buffer
2478 (if (not (equal gdb-frame-address "main"))
2480 (goto-char (point-min))
2481 (if (and gdb-frame-address
2482 (re-search-forward gdb-frame-address nil t))
2486 (or gdb-overlay-arrow-position
2487 (setq gdb-overlay-arrow-position (make-marker)))
2488 (set-marker gdb-overlay-arrow-position
2489 (point) (current-buffer))))))
2490 ;; remove all breakpoint-icons in assembler buffer before updating.
2491 (gdb-remove-breakpoint-icons (point-min) (point-max))))
2492 (with-current-buffer (gdb-get-buffer 'gdb-breakpoints-buffer)
2493 (goto-char (point-min))
2494 (while (< (point) (- (point-max) 1))
2496 (if (looking-at "[^\t].*?breakpoint")
2499 "\\([0-9]+\\)\\s-+\\S-+\\s-+\\S-+\\s-+\\(.\\)\\s-+0x0*\\(\\S-+\\)")
2500 (setq bptno (match-string 1))
2501 (setq flag (char-after (match-beginning 2)))
2502 (setq address (match-string 3))
2503 (with-current-buffer buffer
2505 (goto-char (point-min))
2506 (if (re-search-forward address nil t)
2507 (gdb-put-breakpoint-icon (eq flag ?y) bptno))))))))
2508 (if (not (equal gdb-frame-address "main"))
2509 (set-window-point (get-buffer-window buffer 0) pos))))
2511 (defvar gdb-assembler-mode-map
2512 (let ((map (make-sparse-keymap)))
2513 (suppress-keymap map)
2514 (define-key map "q" 'kill-this-buffer)
2517 (defvar gdb-assembler-font-lock-keywords
2518 '(;; <__function.name+n>
2519 ("<\\(\\(\\sw\\|[_.]\\)+\\)\\(\\+[0-9]+\\)?>"
2520 (1 font-lock-function-name-face))
2521 ;; 0xNNNNNNNN <__function.name+n>: opcode
2522 ("^0x[0-9a-f]+ \\(<\\(\\(\\sw\\|[_.]\\)+\\)\\+[0-9]+>\\)?:[ \t]+\\(\\sw+\\)"
2523 (4 font-lock-keyword-face))
2524 ;; %register(at least i386)
2525 ("%\\sw+" . font-lock-variable-name-face)
2526 ("^\\(Dump of assembler code for function\\) \\(.+\\):"
2527 (1 font-lock-comment-face)
2528 (2 font-lock-function-name-face))
2529 ("^\\(End of assembler dump\\.\\)" . font-lock-comment-face))
2530 "Font lock keywords used in `gdb-assembler-mode'.")
2532 (defun gdb-assembler-mode ()
2533 "Major mode for viewing code assembler.
2535 \\{gdb-assembler-mode-map}"
2536 (kill-all-local-variables)
2537 (setq major-mode 'gdb-assembler-mode)
2538 (setq mode-name (concat "Machine:" gdb-selected-frame))
2539 (setq gdb-overlay-arrow-position nil)
2540 (add-to-list 'overlay-arrow-variable-list 'gdb-overlay-arrow-position)
2541 (setq fringes-outside-margins t)
2542 (setq buffer-read-only t)
2543 (use-local-map gdb-assembler-mode-map)
2544 (gdb-invalidate-assembler)
2545 (set (make-local-variable 'font-lock-defaults)
2546 '(gdb-assembler-font-lock-keywords))
2547 (run-mode-hooks 'gdb-assembler-mode-hook)
2548 'gdb-invalidate-assembler)
2550 (defun gdb-assembler-buffer-name ()
2551 (with-current-buffer gud-comint-buffer
2552 (concat "*Disassembly of " (gdb-get-target-string) "*")))
2554 (defun gdb-display-assembler-buffer ()
2555 "Display disassembly view."
2557 (setq gdb-previous-frame nil)
2559 (gdb-get-create-buffer 'gdb-assembler-buffer)))
2561 (defun gdb-frame-assembler-buffer ()
2562 "Display disassembly view in a new frame."
2564 (setq gdb-previous-frame nil)
2565 (let ((special-display-regexps (append special-display-regexps '(".*")))
2566 (special-display-frame-alist gdb-frame-parameters))
2567 (display-buffer (gdb-get-create-buffer 'gdb-assembler-buffer))))
2569 ;; modified because if gdb-frame-address has changed value a new command
2570 ;; must be enqueued to update the buffer with the new output
2571 (defun gdb-invalidate-assembler (&optional ignored)
2572 (if (gdb-get-buffer 'gdb-assembler-buffer)
2574 (unless (and gdb-selected-frame
2575 (string-equal gdb-selected-frame gdb-previous-frame))
2576 (if (or (not (member 'gdb-invalidate-assembler
2577 gdb-pending-triggers))
2578 (not (string-equal gdb-frame-address
2579 gdb-previous-frame-address)))
2581 ;; take previous disassemble command, if any, off the queue
2582 (with-current-buffer gud-comint-buffer
2583 (let ((queue gdb-input-queue))
2584 (dolist (item queue)
2585 (if (equal (cdr item) '(gdb-assembler-handler))
2586 (setq gdb-input-queue
2587 (delete item gdb-input-queue))))))
2590 (concat gdb-server-prefix "disassemble "
2591 (if (member gdb-frame-address '(nil "main")) nil "0x")
2592 gdb-frame-address "\n")
2593 'gdb-assembler-handler))
2594 (push 'gdb-invalidate-assembler gdb-pending-triggers)
2595 (setq gdb-previous-frame-address gdb-frame-address)
2596 (setq gdb-previous-frame gdb-selected-frame)))))))
2598 (defun gdb-get-selected-frame ()
2599 (if (not (member 'gdb-get-selected-frame gdb-pending-triggers))
2602 (list (concat gdb-server-prefix "info frame\n") 'gdb-frame-handler))
2603 (push 'gdb-get-selected-frame
2604 gdb-pending-triggers))))
2606 (defun gdb-frame-handler ()
2607 (setq gdb-pending-triggers
2608 (delq 'gdb-get-selected-frame gdb-pending-triggers))
2609 (with-current-buffer (gdb-get-create-buffer 'gdb-partial-output-buffer)
2610 (goto-char (point-min))
2611 (if (re-search-forward "Stack level \\([0-9]+\\)" nil t)
2612 (setq gdb-frame-number (match-string 1)))
2613 (goto-char (point-min))
2614 (if (re-search-forward
2615 ".*=\\s-+0x0*\\(\\S-*\\)\\s-+in\\s-+\\(\\S-*?\\);? " nil t)
2617 (setq gdb-selected-frame (match-string 2))
2618 (if (gdb-get-buffer 'gdb-locals-buffer)
2619 (with-current-buffer (gdb-get-buffer 'gdb-locals-buffer)
2620 (setq mode-name (concat "Locals:" gdb-selected-frame))))
2621 (if (gdb-get-buffer 'gdb-assembler-buffer)
2622 (with-current-buffer (gdb-get-buffer 'gdb-assembler-buffer)
2623 (setq mode-name (concat "Machine:" gdb-selected-frame))))
2624 (setq gdb-frame-address (match-string 1))))
2625 (goto-char (point-min))
2626 (if (re-search-forward " source language \\(\\S-*\\)\." nil t)
2627 (setq gdb-current-language (match-string 1))))
2628 (gdb-invalidate-assembler))
2632 ;; arch-tag: e9fb00c5-74ef-469f-a088-37384caae352
2633 ;;; gdb-ui.el ends here