Mercurial > emacs
comparison lisp/progmodes/gdb-ui.el @ 69106:3f5044e40e3e
(gdb-signalled): New variable and function.
(gdb-debug-log-ring): Rename from gdb-debug-log and make a ring.
(gdb-send, gdb-send-item, gud-gdba-marker-filter): Use it.
(gdb-debug-log-length): Customize it's length.
(gud-watch, gdb-var-create-handler): Display function::var format
but don't use to create variable object.
(gdb-var-create-handler): Use message-box in place of message.
(gdb-stopped): Call gdb-exited if signalled.
author | Nick Roberts <nickrob@snap.net.nz> |
---|---|
date | Wed, 22 Feb 2006 22:01:35 +0000 |
parents | 01ec984a6ce6 |
children | 8ff0077b3342 856efda75a1b |
comparison
equal
deleted
inserted
replaced
69105:f04b50463c62 | 69106:3f5044e40e3e |
---|---|
121 and #define directives otherwise.") | 121 and #define directives otherwise.") |
122 (defvar gdb-error "Non-nil when GDB is reporting an error.") | 122 (defvar gdb-error "Non-nil when GDB is reporting an error.") |
123 (defvar gdb-macro-info nil | 123 (defvar gdb-macro-info nil |
124 "Non-nil if GDB knows that the inferior includes preprocessor macro info.") | 124 "Non-nil if GDB knows that the inferior includes preprocessor macro info.") |
125 (defvar gdb-buffer-fringe-width nil) | 125 (defvar gdb-buffer-fringe-width nil) |
126 (defvar gdb-signalled nil) | |
126 | 127 |
127 (defvar gdb-buffer-type nil | 128 (defvar gdb-buffer-type nil |
128 "One of the symbols bound in `gdb-buffer-rules'.") | 129 "One of the symbols bound in `gdb-buffer-rules'.") |
129 (make-variable-buffer-local 'gdb-buffer-type) | 130 (make-variable-buffer-local 'gdb-buffer-type) |
130 | 131 |
256 ;; | 257 ;; |
257 ;; Let's start with a basic gud-gdb buffer and then modify it a bit. | 258 ;; Let's start with a basic gud-gdb buffer and then modify it a bit. |
258 (gdb command-line) | 259 (gdb command-line) |
259 (gdb-init-1)) | 260 (gdb-init-1)) |
260 | 261 |
261 (defvar gdb-debug-log nil) | 262 (defcustom gdb-debug-log-length 128 |
263 "Length of `gdb-debug-log-ring'." | |
264 :group 'gud | |
265 :type 'integer | |
266 :version "22.1") | |
267 | |
268 (defvar gdb-debug-log-ring (make-ring gdb-debug-log-length) | |
269 "Ring of commands sent to and replies received from GDB. | |
270 This variable is used to debug GDB-UI. Just need most recent | |
271 messages and a ring limits the size.") | |
262 | 272 |
263 ;;;###autoload | 273 ;;;###autoload |
264 (defcustom gdb-enable-debug-log nil | 274 (defcustom gdb-enable-debug-log nil |
265 "Non-nil means record the process input and output in `gdb-debug-log'." | 275 "Non-nil means record the process input and output in `gdb-debug-log-ring'." |
266 :type 'boolean | 276 :type 'boolean |
267 :group 'gud | 277 :group 'gud |
268 :version "22.1") | 278 :version "22.1") |
269 | 279 |
270 (defcustom gdb-cpp-define-alist-program "gcc -E -dM -" | 280 (defcustom gdb-cpp-define-alist-program "gcc -E -dM -" |
388 (if (string-equal (nth 1 var1) (match-string 1 varno)) | 398 (if (string-equal (nth 1 var1) (match-string 1 varno)) |
389 (setq expr (concat (car var1) "." (match-string 2 varno))))) | 399 (setq expr (concat (car var1) "." (match-string 2 varno))))) |
390 expr)) | 400 expr)) |
391 | 401 |
392 (defun gdb-init-1 () | 402 (defun gdb-init-1 () |
393 (setq gdb-debug-log nil) | |
394 (set (make-local-variable 'gud-minor-mode) 'gdba) | 403 (set (make-local-variable 'gud-minor-mode) 'gdba) |
395 (set (make-local-variable 'gud-marker-filter) 'gud-gdba-marker-filter) | 404 (set (make-local-variable 'gud-marker-filter) 'gud-gdba-marker-filter) |
396 ;; | 405 ;; |
397 (gud-def gud-break (if (not (string-match "Machine" mode-name)) | 406 (gud-def gud-break (if (not (string-match "Machine" mode-name)) |
398 (gud-call "break %f:%l" arg) | 407 (gud-call "break %f:%l" arg) |
467 gdb-flush-pending-output nil | 476 gdb-flush-pending-output nil |
468 gdb-location-alist nil | 477 gdb-location-alist nil |
469 gdb-source-file-list nil | 478 gdb-source-file-list nil |
470 gdb-error nil | 479 gdb-error nil |
471 gdb-macro-info nil | 480 gdb-macro-info nil |
472 gdb-buffer-fringe-width (car (window-fringes))) | 481 gdb-buffer-fringe-width (car (window-fringes)) |
482 gdb-debug-log-ring (make-ring gdb-debug-log-length) | |
483 gdb-signalled nil) | |
473 | 484 |
474 (setq gdb-buffer-type 'gdba) | 485 (setq gdb-buffer-type 'gdba) |
475 | 486 |
476 (if gdb-use-separate-io-buffer (gdb-clear-inferior-io)) | 487 (if gdb-use-separate-io-buffer (gdb-clear-inferior-io)) |
477 | 488 |
478 ;; Hack to see test for GDB 6.4+ (-stack-info-frame was implemented in 6.4) | 489 ;; Hack to see test for GDB 6.4+ (-stack-info-frame was implemented in 6.4) |
479 (setq gdb-version nil) | |
480 (gdb-enqueue-input (list "server interpreter mi -stack-info-frame\n" | 490 (gdb-enqueue-input (list "server interpreter mi -stack-info-frame\n" |
481 'gdb-get-version))) | 491 'gdb-get-version))) |
482 | 492 |
483 (defun gdb-init-2 () | 493 (defun gdb-init-2 () |
484 (if (eq window-system 'w32) | 494 (if (eq window-system 'w32) |
571 (interactive (list last-input-event)) | 581 (interactive (list last-input-event)) |
572 (if event (posn-set-point (event-end event))) | 582 (if event (posn-set-point (event-end event))) |
573 (require 'tooltip) | 583 (require 'tooltip) |
574 (save-selected-window | 584 (save-selected-window |
575 (let ((expr (tooltip-identifier-from-point (point)))) | 585 (let ((expr (tooltip-identifier-from-point (point)))) |
576 (if (and (string-equal gdb-current-language "c") | |
577 gdb-use-colon-colon-notation gdb-selected-frame) | |
578 (setq expr (concat gdb-selected-frame "::" expr))) | |
579 (catch 'already-watched | 586 (catch 'already-watched |
580 (dolist (var gdb-var-list) | 587 (dolist (var gdb-var-list) |
581 (if (string-equal expr (car var)) (throw 'already-watched nil))) | 588 (if (string-equal expr (car var)) (throw 'already-watched nil))) |
582 (set-text-properties 0 (length expr) nil expr) | 589 (set-text-properties 0 (length expr) nil expr) |
583 (gdb-enqueue-input | 590 (gdb-enqueue-input |
591 "name=\"\\(.*?\\)\",numchild=\"\\(.*?\\)\",type=\"\\(.*?\\)\"") | 598 "name=\"\\(.*?\\)\",numchild=\"\\(.*?\\)\",type=\"\\(.*?\\)\"") |
592 | 599 |
593 (defun gdb-var-create-handler (expr) | 600 (defun gdb-var-create-handler (expr) |
594 (goto-char (point-min)) | 601 (goto-char (point-min)) |
595 (if (re-search-forward gdb-var-create-regexp nil t) | 602 (if (re-search-forward gdb-var-create-regexp nil t) |
596 (let ((var (list expr | 603 (let ((var (list |
597 (match-string 1) | 604 (if (and (string-equal gdb-current-language "c") |
598 (match-string 2) | 605 gdb-use-colon-colon-notation gdb-selected-frame) |
599 (match-string 3) | 606 (setq expr (concat gdb-selected-frame "::" expr)) |
600 nil nil))) | 607 expr) |
608 (match-string 1) | |
609 (match-string 2) | |
610 (match-string 3) | |
611 nil nil))) | |
601 (push var gdb-var-list) | 612 (push var gdb-var-list) |
602 (speedbar 1) | 613 (speedbar 1) |
603 (unless (string-equal | 614 (unless (string-equal |
604 speedbar-initial-expansion-list-name "GUD") | 615 speedbar-initial-expansion-list-name "GUD") |
605 (speedbar-change-initial-expansion-list "GUD")) | 616 (speedbar-change-initial-expansion-list "GUD")) |
611 (concat "-var-evaluate-expression " (nth 1 var) "\n")) | 622 (concat "-var-evaluate-expression " (nth 1 var) "\n")) |
612 `(lambda () (gdb-var-evaluate-expression-handler | 623 `(lambda () (gdb-var-evaluate-expression-handler |
613 ,(nth 1 var) nil))))) | 624 ,(nth 1 var) nil))))) |
614 (if (search-forward "Undefined command" nil t) | 625 (if (search-forward "Undefined command" nil t) |
615 (message-box "Watching expressions requires gdb 6.0 onwards") | 626 (message-box "Watching expressions requires gdb 6.0 onwards") |
616 (message "No symbol \"%s\" in current context." expr)))) | 627 (message-box "No symbol \"%s\" in current context." expr)))) |
617 | 628 |
618 (defun gdb-var-evaluate-expression-handler (varnum changed) | 629 (defun gdb-var-evaluate-expression-handler (varnum changed) |
619 (goto-char (point-min)) | 630 (goto-char (point-min)) |
620 (re-search-forward ".*value=\\(\".*\"\\)" nil t) | 631 (re-search-forward ".*value=\\(\".*\"\\)" nil t) |
621 (catch 'var-found | 632 (catch 'var-found |
862 (concat "*input/output of " | 873 (concat "*input/output of " |
863 (gdb-get-target-string) | 874 (gdb-get-target-string) |
864 "*")) | 875 "*")) |
865 | 876 |
866 (defun gdb-display-separate-io-buffer () | 877 (defun gdb-display-separate-io-buffer () |
867 "Display IO of inferior in a separate window." | 878 "Display IO of debugged program in a separate window." |
868 (interactive) | 879 (interactive) |
869 (if gdb-use-separate-io-buffer | 880 (if gdb-use-separate-io-buffer |
870 (gdb-display-buffer | 881 (gdb-display-buffer |
871 (gdb-get-create-buffer 'gdb-inferior-io)))) | 882 (gdb-get-create-buffer 'gdb-inferior-io)))) |
872 | 883 |
961 (let ((inhibit-read-only t)) | 972 (let ((inhibit-read-only t)) |
962 (remove-text-properties (point-min) (point-max) '(face)))) | 973 (remove-text-properties (point-min) (point-max) '(face)))) |
963 (let ((item (concat string "\n"))) | 974 (let ((item (concat string "\n"))) |
964 (if gud-running | 975 (if gud-running |
965 (progn | 976 (progn |
966 (if gdb-enable-debug-log (push (cons 'send item) gdb-debug-log)) | 977 (if gdb-enable-debug-log (push (cons 'send item) gdb-debug-log-ring)) |
967 (process-send-string proc item)) | 978 (process-send-string proc item)) |
968 (gdb-enqueue-input item)))) | 979 (gdb-enqueue-input item)))) |
969 | 980 |
970 ;; Note: Stuff enqueued here will be sent to the next prompt, even if it | 981 ;; Note: Stuff enqueued here will be sent to the next prompt, even if it |
971 ;; is a query, or other non-top-level prompt. | 982 ;; is a query, or other non-top-level prompt. |
984 (unless (nbutlast queue) (setq gdb-input-queue '())) | 995 (unless (nbutlast queue) (setq gdb-input-queue '())) |
985 last)))) | 996 last)))) |
986 | 997 |
987 (defun gdb-send-item (item) | 998 (defun gdb-send-item (item) |
988 (setq gdb-flush-pending-output nil) | 999 (setq gdb-flush-pending-output nil) |
989 (if gdb-enable-debug-log (push (cons 'send-item item) gdb-debug-log)) | 1000 (if gdb-enable-debug-log |
1001 (ring-insert gdb-debug-log-ring (cons 'send-item item))) | |
990 (setq gdb-current-item item) | 1002 (setq gdb-current-item item) |
991 (let ((process (get-buffer-process gud-comint-buffer))) | 1003 (let ((process (get-buffer-process gud-comint-buffer))) |
992 (if (eq (buffer-local-value 'gud-minor-mode gud-comint-buffer) 'gdba) | 1004 (if (eq (buffer-local-value 'gud-minor-mode gud-comint-buffer) 'gdba) |
993 (if (stringp item) | 1005 (if (stringp item) |
994 (progn | 1006 (progn |
1037 ("prompt-for-continue" gdb-subprompt) | 1049 ("prompt-for-continue" gdb-subprompt) |
1038 ("post-prompt" gdb-post-prompt) | 1050 ("post-prompt" gdb-post-prompt) |
1039 ("source" gdb-source) | 1051 ("source" gdb-source) |
1040 ("starting" gdb-starting) | 1052 ("starting" gdb-starting) |
1041 ("exited" gdb-exited) | 1053 ("exited" gdb-exited) |
1042 ("signalled" gdb-exited) | 1054 ("signalled" gdb-signalled) |
1043 ("signal" gdb-stopping) | 1055 ("signal" gdb-stopping) |
1044 ("breakpoint" gdb-stopping) | 1056 ("breakpoint" gdb-stopping) |
1045 ("watchpoint" gdb-stopping) | 1057 ("watchpoint" gdb-stopping) |
1046 ("frame-begin" gdb-frame-begin) | 1058 ("frame-begin" gdb-frame-begin) |
1047 ("stopped" gdb-stopped) | 1059 ("stopped" gdb-stopped) |
1154 (setq gdb-active-process nil) | 1166 (setq gdb-active-process nil) |
1155 (setq gud-overlay-arrow-position nil) | 1167 (setq gud-overlay-arrow-position nil) |
1156 (setq gdb-overlay-arrow-position nil) | 1168 (setq gdb-overlay-arrow-position nil) |
1157 (gdb-stopping ignored)) | 1169 (gdb-stopping ignored)) |
1158 | 1170 |
1171 (defun gdb-signalled (ignored) | |
1172 (setq gdb-signalled t)) | |
1173 | |
1159 (defun gdb-frame-begin (ignored) | 1174 (defun gdb-frame-begin (ignored) |
1160 (let ((sink gdb-output-sink)) | 1175 (let ((sink gdb-output-sink)) |
1161 (cond | 1176 (cond |
1162 ((eq sink 'inferior) | 1177 ((eq sink 'inferior) |
1163 (setq gdb-output-sink 'user)) | 1178 (setq gdb-output-sink 'user)) |
1170 (defun gdb-stopped (ignored) | 1185 (defun gdb-stopped (ignored) |
1171 "An annotation handler for `stopped'. | 1186 "An annotation handler for `stopped'. |
1172 It is just like `gdb-stopping', except that if we already set the output | 1187 It is just like `gdb-stopping', except that if we already set the output |
1173 sink to `user' in `gdb-stopping', that is fine." | 1188 sink to `user' in `gdb-stopping', that is fine." |
1174 (setq gud-running nil) | 1189 (setq gud-running nil) |
1175 (setq gdb-active-process t) | |
1176 (let ((sink gdb-output-sink)) | 1190 (let ((sink gdb-output-sink)) |
1177 (cond | 1191 (cond |
1178 ((eq sink 'inferior) | 1192 ((eq sink 'inferior) |
1179 (setq gdb-output-sink 'user)) | 1193 (setq gdb-output-sink 'user)) |
1180 ((eq sink 'user) t) | 1194 ((eq sink 'user) t) |
1181 (t | 1195 (t |
1182 (gdb-resync) | 1196 (gdb-resync) |
1183 (error "Unexpected stopped annotation"))))) | 1197 (error "Unexpected stopped annotation")))) |
1198 (if gdb-signalled (gdb-exited ignored))) | |
1184 | 1199 |
1185 (defun gdb-error (ignored) | 1200 (defun gdb-error (ignored) |
1186 (setq gdb-error (not gdb-error))) | 1201 (setq gdb-error (not gdb-error))) |
1187 | 1202 |
1188 (defun gdb-post-prompt (ignored) | 1203 (defun gdb-post-prompt (ignored) |
1231 | 1246 |
1232 (defun gud-gdba-marker-filter (string) | 1247 (defun gud-gdba-marker-filter (string) |
1233 "A gud marker filter for gdb. Handle a burst of output from GDB." | 1248 "A gud marker filter for gdb. Handle a burst of output from GDB." |
1234 (if gdb-flush-pending-output | 1249 (if gdb-flush-pending-output |
1235 nil | 1250 nil |
1236 (if gdb-enable-debug-log (push (cons 'recv string) gdb-debug-log)) | 1251 (if gdb-enable-debug-log |
1252 (ring-insert gdb-debug-log-ring (cons 'recv string))) | |
1237 ;; Recall the left over gud-marker-acc from last time. | 1253 ;; Recall the left over gud-marker-acc from last time. |
1238 (setq gud-marker-acc (concat gud-marker-acc string)) | 1254 (setq gud-marker-acc (concat gud-marker-acc string)) |
1239 ;; Start accumulating output for the GUD buffer. | 1255 ;; Start accumulating output for the GUD buffer. |
1240 (let ((output "")) | 1256 (let ((output "")) |
1241 ;; | 1257 ;; |