Mercurial > emacs
comparison lisp/progmodes/gdb-ui.el @ 71348:10a6583c5ff7
(gdb-same-frame): New option.
(gud-old-arrow, gdb-frame-begin, gdb-printing): New variables.
(gdb-init-1): Initialise them.
(gdb-starting): Reset gdb-printing
(gdb-starting): Save value of gud-overlay-arrow-position.
(gdb-frame-begin): Set gdb-frame-begin, gdb-printing.
(gdb-stopped): Don't look for source if calling procedure e.g "p a ()".
Use gdb-*-gdb-buffer conditionally on gdb-same-frame.
(gdb-frame-gdb-buffer): Keep menu bar, tool bar for GUD buffer.
author | Nick Roberts <nickrob@snap.net.nz> |
---|---|
date | Thu, 15 Jun 2006 00:57:53 +0000 |
parents | 99ed754e8f50 |
children | f723aa5cf2de 138027c8c982 |
comparison
equal
deleted
inserted
replaced
71347:27a7e14de688 | 71348:10a6583c5ff7 |
---|---|
74 ;; contents change unless the first character changes. | 74 ;; contents change unless the first character changes. |
75 ;; 2) Cannot handle multiple debug sessions. | 75 ;; 2) Cannot handle multiple debug sessions. |
76 ;; 3) M-x gdb doesn't work with "run" command in .gdbinit, use M-x gdba instead. | 76 ;; 3) M-x gdb doesn't work with "run" command in .gdbinit, use M-x gdba instead. |
77 ;; 4) M-x gdb doesn't work if the corefile is specified in the command in the | 77 ;; 4) M-x gdb doesn't work if the corefile is specified in the command in the |
78 ;; minibuffer, use M-x gdba instead (or specify the core in the GUD buffer). | 78 ;; minibuffer, use M-x gdba instead (or specify the core in the GUD buffer). |
79 ;; 5) If you wish to call procedures from your program in GDB | |
80 ;; e.g "call myproc ()", "p mysquare (5)" then use level 2 annotations | |
81 ;; "gdb --annotate=2 myprog" to keep source buffer/selected frame fixed. | |
79 | 82 |
80 ;;; Problems with watch expressions, GDB/MI: | 83 ;;; Problems with watch expressions, GDB/MI: |
81 ;; 1) They go out of scope when the inferior is re-run. | 84 ;; 1) They go out of scope when the inferior is re-run. |
82 ;; 2) -stack-list-locals has a type field but also prints type in values field. | 85 ;; 2) -stack-list-locals has a type field but also prints type in values field. |
83 ;; 3) VARNUM increments even when variable object is not created | 86 ;; 3) VARNUM increments even when variable object is not created |
108 "List of variables in watch window. | 111 "List of variables in watch window. |
109 Each element has the form (VARNUM EXPRESSION NUMCHILD TYPE VALUE STATUS FP) | 112 Each element has the form (VARNUM EXPRESSION NUMCHILD TYPE VALUE STATUS FP) |
110 where STATUS is nil (unchanged), `changed' or `out-of-scope', FP the frame | 113 where STATUS is nil (unchanged), `changed' or `out-of-scope', FP the frame |
111 address for root variables.") | 114 address for root variables.") |
112 (defvar gdb-main-file nil "Source file from which program execution begins.") | 115 (defvar gdb-main-file nil "Source file from which program execution begins.") |
116 (defvar gud-old-arrow nil) | |
113 (defvar gdb-overlay-arrow-position nil) | 117 (defvar gdb-overlay-arrow-position nil) |
114 (defvar gdb-server-prefix nil) | 118 (defvar gdb-server-prefix nil) |
115 (defvar gdb-flush-pending-output nil) | 119 (defvar gdb-flush-pending-output nil) |
116 (defvar gdb-location-alist nil | 120 (defvar gdb-location-alist nil |
117 "Alist of breakpoint numbers and full filenames.") | 121 "Alist of breakpoint numbers and full filenames.") |
124 (defvar gdb-signalled nil) | 128 (defvar gdb-signalled nil) |
125 (defvar gdb-source-window nil) | 129 (defvar gdb-source-window nil) |
126 (defvar gdb-inferior-status nil) | 130 (defvar gdb-inferior-status nil) |
127 (defvar gdb-continuation nil) | 131 (defvar gdb-continuation nil) |
128 (defvar gdb-look-up-stack nil) | 132 (defvar gdb-look-up-stack nil) |
133 (defvar gdb-frame-begin nil | |
134 "Non-nil when GDB generates frame-begin annotation.") | |
135 (defvar gdb-printing t) | |
129 | 136 |
130 (defvar gdb-buffer-type nil | 137 (defvar gdb-buffer-type nil |
131 "One of the symbols bound in `gdb-buffer-rules'.") | 138 "One of the symbols bound in `gdb-buffer-rules'.") |
132 (make-variable-buffer-local 'gdb-buffer-type) | 139 (make-variable-buffer-local 'gdb-buffer-type) |
133 | 140 |
541 gdb-debug-ring nil | 548 gdb-debug-ring nil |
542 gdb-signalled nil | 549 gdb-signalled nil |
543 gdb-source-window nil | 550 gdb-source-window nil |
544 gdb-inferior-status nil | 551 gdb-inferior-status nil |
545 gdb-continuation nil | 552 gdb-continuation nil |
546 gdb-look-up-stack nil) | 553 gdb-look-up-stack nil |
554 gdb-frame-begin nil | |
555 gdb-printing t | |
556 gud-old-arrow nil) | |
547 | 557 |
548 (setq gdb-buffer-type 'gdba) | 558 (setq gdb-buffer-type 'gdba) |
549 | 559 |
550 (if gdb-use-separate-io-buffer (gdb-clear-inferior-io)) | 560 (if gdb-use-separate-io-buffer (gdb-clear-inferior-io)) |
551 | 561 |
1268 (defun gdb-starting (ignored) | 1278 (defun gdb-starting (ignored) |
1269 "An annotation handler for `starting'. | 1279 "An annotation handler for `starting'. |
1270 This says that I/O for the subprocess is now the program being debugged, | 1280 This says that I/O for the subprocess is now the program being debugged, |
1271 not GDB." | 1281 not GDB." |
1272 (setq gdb-active-process t) | 1282 (setq gdb-active-process t) |
1283 (setq gdb-printing t) | |
1273 (let ((sink gdb-output-sink)) | 1284 (let ((sink gdb-output-sink)) |
1274 (cond | 1285 (cond |
1275 ((eq sink 'user) | 1286 ((eq sink 'user) |
1276 (progn | 1287 (progn |
1277 (setq gud-running t) | 1288 (setq gud-running t) |
1278 (setq gdb-inferior-status "running") | 1289 (setq gdb-inferior-status "running") |
1279 (gdb-force-mode-line-update gdb-inferior-status) | 1290 (gdb-force-mode-line-update gdb-inferior-status) |
1280 (gdb-remove-text-properties) | 1291 (gdb-remove-text-properties) |
1292 (setq gud-old-arrow gud-overlay-arrow-position) | |
1281 (setq gud-overlay-arrow-position nil) | 1293 (setq gud-overlay-arrow-position nil) |
1282 (setq gdb-overlay-arrow-position nil) | 1294 (setq gdb-overlay-arrow-position nil) |
1283 (if gdb-use-separate-io-buffer | 1295 (if gdb-use-separate-io-buffer |
1284 (setq gdb-output-sink 'inferior)))) | 1296 (setq gdb-output-sink 'inferior)))) |
1285 (t | 1297 (t |
1319 | 1331 |
1320 (defun gdb-signalled (ignored) | 1332 (defun gdb-signalled (ignored) |
1321 (setq gdb-signalled t)) | 1333 (setq gdb-signalled t)) |
1322 | 1334 |
1323 (defun gdb-frame-begin (ignored) | 1335 (defun gdb-frame-begin (ignored) |
1336 (setq gdb-frame-begin t) | |
1337 (setq gdb-printing nil) | |
1324 (let ((sink gdb-output-sink)) | 1338 (let ((sink gdb-output-sink)) |
1325 (cond | 1339 (cond |
1326 ((eq sink 'inferior) | 1340 ((eq sink 'inferior) |
1327 (setq gdb-output-sink 'user)) | 1341 (setq gdb-output-sink 'user)) |
1328 ((eq sink 'user) t) | 1342 ((eq sink 'user) t) |
1329 ((eq sink 'emacs) t) | 1343 ((eq sink 'emacs) t) |
1330 (t | 1344 (t |
1331 (gdb-resync) | 1345 (gdb-resync) |
1332 (error "Unexpected frame-begin annotation (%S)" sink))))) | 1346 (error "Unexpected frame-begin annotation (%S)" sink))))) |
1333 | 1347 |
1348 (defcustom gdb-same-frame focus-follows-mouse | |
1349 "Non-nil means pop up GUD buffer in same frame." | |
1350 :group 'gud | |
1351 :type 'boolean | |
1352 :version "22.1") | |
1353 | |
1334 (defun gdb-stopped (ignored) | 1354 (defun gdb-stopped (ignored) |
1335 "An annotation handler for `stopped'. | 1355 "An annotation handler for `stopped'. |
1336 It is just like `gdb-stopping', except that if we already set the output | 1356 It is just like `gdb-stopping', except that if we already set the output |
1337 sink to `user' in `gdb-stopping', that is fine." | 1357 sink to `user' in `gdb-stopping', that is fine." |
1338 (setq gud-running nil) | 1358 (setq gud-running nil) |
1339 (unless (or gud-overlay-arrow-position gud-last-frame) | 1359 (unless (or gud-overlay-arrow-position gud-last-frame) |
1360 (if (and gdb-frame-begin gdb-printing) | |
1361 (setq gud-overlay-arrow-position gud-old-arrow) | |
1340 ;;Pop up GUD buffer to display current frame when it doesn't have source | 1362 ;;Pop up GUD buffer to display current frame when it doesn't have source |
1341 ;;information i.e id not compiled with -g as with libc routines generally. | 1363 ;;information i.e id not compiled with -g as with libc routines generally. |
1342 (let ((special-display-regexps (append special-display-regexps '(".*"))) | 1364 (if gdb-same-frame |
1343 (special-display-frame-alist gdb-frame-parameters) | 1365 (gdb-display-gdb-buffer) |
1344 (same-window-regexps nil)) | 1366 (gdb-frame-gdb-buffer)) |
1345 (display-buffer gud-comint-buffer)) | |
1346 ;;Try to find source further up stack e.g after signal. | 1367 ;;Try to find source further up stack e.g after signal. |
1347 (setq gdb-look-up-stack | 1368 (setq gdb-look-up-stack |
1348 (if (gdb-get-buffer 'gdb-stack-buffer) 'keep | 1369 (if (gdb-get-buffer 'gdb-stack-buffer) |
1370 'keep | |
1349 (progn | 1371 (progn |
1350 (gdb-get-buffer-create 'gdb-stack-buffer) | 1372 (gdb-get-buffer-create 'gdb-stack-buffer) |
1351 (gdb-invalidate-frames) | 1373 (gdb-invalidate-frames) |
1352 'delete)))) | 1374 'delete))))) |
1353 (unless (member gdb-inferior-status '("exited" "signal")) | 1375 (unless (member gdb-inferior-status '("exited" "signal")) |
1354 (setq gdb-inferior-status "stopped") | 1376 (setq gdb-inferior-status "stopped") |
1355 (gdb-force-mode-line-update gdb-inferior-status)) | 1377 (gdb-force-mode-line-update gdb-inferior-status)) |
1356 (let ((sink gdb-output-sink)) | 1378 (let ((sink gdb-output-sink)) |
1357 (cond | 1379 (cond |
2755 | 2777 |
2756 (defun gdb-frame-gdb-buffer () | 2778 (defun gdb-frame-gdb-buffer () |
2757 "Display GUD buffer in a new frame." | 2779 "Display GUD buffer in a new frame." |
2758 (interactive) | 2780 (interactive) |
2759 (let ((special-display-regexps (append special-display-regexps '(".*"))) | 2781 (let ((special-display-regexps (append special-display-regexps '(".*"))) |
2760 (special-display-frame-alist gdb-frame-parameters) | 2782 (special-display-frame-alist |
2783 (remove '(menu-bar-lines) (remove '(tool-bar-lines) | |
2784 gdb-frame-parameters))) | |
2761 (same-window-regexps nil)) | 2785 (same-window-regexps nil)) |
2762 (display-buffer gud-comint-buffer))) | 2786 (display-buffer gud-comint-buffer))) |
2763 | 2787 |
2764 (defun gdb-display-gdb-buffer () | 2788 (defun gdb-display-gdb-buffer () |
2765 "Display GUD buffer." | 2789 "Display GUD buffer." |