Mercurial > emacs
comparison lisp/progmodes/gdb-ui.el @ 83405:1955a4462bf9
Merged from miles@gnu.org--gnu-2005 (patch 659-663)
Patches applied:
* miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-659
Update from CVS
* miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-660
Update from CVS
* miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-661
Update from CVS
* miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-662
Update from CVS
* miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-663
Update from CVS
git-archimport-id: lorentey@elte.hu--2004/emacs--multi-tty--0--patch-445
author | Karoly Lorentey <lorentey@elte.hu> |
---|---|
date | Sat, 03 Dec 2005 14:25:50 +0000 |
parents | 69e184bbba16 f8729e3300dc |
children | 37d0562504bf |
comparison
equal
deleted
inserted
replaced
83404:69e184bbba16 | 83405:1955a4462bf9 |
---|---|
39 ;; This file has evolved from gdba.el that was included with GDB 5.0 and | 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. | 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, | 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 | 42 ;; but if you are interested developing the mode itself, then see the |
43 ;; Annotations section in the GDB info manual. | 43 ;; Annotations section in the GDB info manual. |
44 ;; | 44 |
45 ;; GDB developers plan to make the annotation interface obsolete. A new | 45 ;; GDB developers plan to make the annotation interface obsolete. A new |
46 ;; interface called GDB/MI (machine interface) has been designed to replace | 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 | 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 | 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 | 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 | 50 ;; still under development and is part of a process to migrate Emacs from |
51 ;; annotations to GDB/MI. | 51 ;; annotations to GDB/MI. |
52 ;; | 52 |
53 ;; This mode SHOULD WORK WITH GDB 5.0 ONWARDS but you will NEED GDB 6.0 | 53 ;; This mode SHOULD WORK WITH GDB 5.0 onwards but you will NEED GDB 6.0 |
54 ;; ONWARDS TO USE WATCH EXPRESSIONS. | 54 ;; onwards to use watch expressions. |
55 ;; | 55 |
56 ;; Windows Platforms: | 56 ;;; Windows Platforms: |
57 ;; | 57 |
58 ;; If you are using Emacs and GDB on Windows you will need to flush the buffer | 58 ;; If you are using Emacs and GDB on Windows you will need to flush the buffer |
59 ;; explicitly in your program if you want timely display of I/O in Emacs. | 59 ;; explicitly in your program if you want timely display of I/O in Emacs. |
60 ;; Alternatively you can make the output stream unbuffered, for example, by | 60 ;; Alternatively you can make the output stream unbuffered, for example, by |
61 ;; using a macro: | 61 ;; using a macro: |
62 ;; | 62 |
63 ;; #ifdef UNBUFFERED | 63 ;; #ifdef UNBUFFERED |
64 ;; setvbuf (stdout, (char *) NULL, _IONBF, 0); | 64 ;; setvbuf (stdout, (char *) NULL, _IONBF, 0); |
65 ;; #endif | 65 ;; #endif |
66 ;; | 66 |
67 ;; and compiling with -DUNBUFFERED while debugging. | 67 ;; and compiling with -DUNBUFFERED while debugging. |
68 ;; | 68 |
69 ;; Known Bugs: | 69 ;;; Known Bugs: |
70 ;; | 70 |
71 ;; TODO: | 71 ;; 1) Strings that are watched don't update in the speedbar when their |
72 ;; contents change. | |
73 ;; 2) Watch expressions go out of scope when the inferior is re-run. | |
74 ;; 3) Cannot handle multiple debug sessions. | |
75 | |
76 ;;; TODO: | |
77 | |
72 ;; 1) Use MI command -data-read-memory for memory window. | 78 ;; 1) Use MI command -data-read-memory for memory window. |
73 ;; 2) Highlight changed register values (use MI commands | 79 ;; 2) Highlight changed register values (use MI commands |
74 ;; -data-list-register-values and -data-list-changed-registers instead | 80 ;; -data-list-register-values and -data-list-changed-registers instead |
75 ;; of 'info registers'. | 81 ;; of 'info registers'. |
76 ;; 3) Use tree-widget.el instead of the speedbar for watch-expressions? | 82 ;; 3) Use tree-widget.el instead of the speedbar for watch-expressions? |
394 (define-key gud-minor-mode-map [left-fringe mouse-1] | 400 (define-key gud-minor-mode-map [left-fringe mouse-1] |
395 'gdb-mouse-set-clear-breakpoint) | 401 'gdb-mouse-set-clear-breakpoint) |
396 (define-key gud-minor-mode-map [left-fringe mouse-2] | 402 (define-key gud-minor-mode-map [left-fringe mouse-2] |
397 'gdb-mouse-until) | 403 'gdb-mouse-until) |
398 (define-key gud-minor-mode-map [left-fringe drag-mouse-1] | 404 (define-key gud-minor-mode-map [left-fringe drag-mouse-1] |
405 'gdb-mouse-until) | |
406 (define-key gud-minor-mode-map [left-margin mouse-2] | |
399 'gdb-mouse-until) | 407 'gdb-mouse-until) |
400 (define-key gud-minor-mode-map [left-margin mouse-3] | 408 (define-key gud-minor-mode-map [left-margin mouse-3] |
401 'gdb-mouse-toggle-breakpoint-margin) | 409 'gdb-mouse-toggle-breakpoint-margin) |
402 (define-key gud-minor-mode-map [left-fringe mouse-3] | 410 (define-key gud-minor-mode-map [left-fringe mouse-3] |
403 'gdb-mouse-toggle-breakpoint-fringe) | 411 'gdb-mouse-toggle-breakpoint-fringe) |
469 (save-excursion | 477 (save-excursion |
470 (goto-line (line-number-at-pos (posn-point end))) | 478 (goto-line (line-number-at-pos (posn-point end))) |
471 (forward-char 2) | 479 (forward-char 2) |
472 (gud-call (concat "until *%a"))))))))) | 480 (gud-call (concat "until *%a"))))))))) |
473 | 481 |
482 (defcustom gdb-speedbar-auto-raise t | |
483 "If non-nil raise speedbar every time display of watch expressions is\ | |
484 updated." | |
485 :type 'boolean | |
486 :group 'gud | |
487 :version "22.1") | |
488 | |
489 (defun gdb-speedbar-auto-raise (arg) | |
490 "Toggle automatic raising of the speedbar for watch expressions." | |
491 (interactive "P") | |
492 (setq gdb-speedbar-auto-raise | |
493 (if (null arg) | |
494 (not gdb-speedbar-auto-raise) | |
495 (> (prefix-numeric-value arg) 0)))) | |
496 | |
474 (defcustom gdb-use-colon-colon-notation nil | 497 (defcustom gdb-use-colon-colon-notation nil |
475 "If non-nil use FUN::VAR format to display variables in the speedbar." | 498 "If non-nil use FUN::VAR format to display variables in the speedbar." |
476 :type 'boolean | 499 :type 'boolean |
477 :group 'gud | 500 :group 'gud |
478 :version "22.1") | 501 :version "22.1") |
512 (push var gdb-var-list) | 535 (push var gdb-var-list) |
513 (speedbar 1) | 536 (speedbar 1) |
514 (unless (string-equal | 537 (unless (string-equal |
515 speedbar-initial-expansion-list-name "GUD") | 538 speedbar-initial-expansion-list-name "GUD") |
516 (speedbar-change-initial-expansion-list "GUD")) | 539 (speedbar-change-initial-expansion-list "GUD")) |
517 (if (or (equal (nth 2 var) "0") | 540 (gdb-enqueue-input |
518 (and (equal (nth 2 var) "1") | 541 (list |
519 (string-match "char \\*" (nth 3 var)))) | 542 (if (eq (buffer-local-value 'gud-minor-mode gud-comint-buffer) |
520 (gdb-enqueue-input | 543 'gdba) |
521 (list | 544 (concat "server interpreter mi \"-var-evaluate-expression " |
522 (if (eq (buffer-local-value 'gud-minor-mode gud-comint-buffer) | 545 (nth 1 var) "\"\n") |
523 'gdba) | 546 (concat "-var-evaluate-expression " (nth 1 var) "\n")) |
524 (concat "server interpreter mi \"-var-evaluate-expression " | 547 `(lambda () (gdb-var-evaluate-expression-handler |
525 (nth 1 var) "\"\n") | 548 ,(nth 1 var) nil)))) |
526 (concat "-var-evaluate-expression " (nth 1 var) "\n")) | 549 (setq gdb-var-changed t)) |
527 `(lambda () (gdb-var-evaluate-expression-handler | |
528 ,(nth 1 var) nil)))) | |
529 (setq gdb-var-changed t))) | |
530 (if (re-search-forward "Undefined command" nil t) | 550 (if (re-search-forward "Undefined command" nil t) |
531 (message-box "Watching expressions requires gdb 6.0 onwards") | 551 (message-box "Watching expressions requires gdb 6.0 onwards") |
532 (message "No symbol \"%s\" in current context." expr))))) | 552 (message "No symbol \"%s\" in current context." expr))))) |
533 | 553 |
534 (defun gdb-var-evaluate-expression-handler (varnum changed) | 554 (defun gdb-var-evaluate-expression-handler (varnum changed) |
573 nil nil))) | 593 nil nil))) |
574 (dolist (var1 gdb-var-list) | 594 (dolist (var1 gdb-var-list) |
575 (if (string-equal (cadr var1) (cadr varchild)) | 595 (if (string-equal (cadr var1) (cadr varchild)) |
576 (throw 'child-already-watched nil))) | 596 (throw 'child-already-watched nil))) |
577 (push varchild var-list) | 597 (push varchild var-list) |
578 (if (or (equal (nth 2 varchild) "0") | 598 (gdb-enqueue-input |
579 (and (equal (nth 2 varchild) "1") | 599 (list |
580 (string-match "char \\*" (nth 3 varchild)))) | 600 (concat |
581 (gdb-enqueue-input | 601 "server interpreter mi \"-var-evaluate-expression " |
582 (list | 602 (nth 1 varchild) "\"\n") |
583 (concat | 603 `(lambda () (gdb-var-evaluate-expression-handler |
584 "server interpreter mi \"-var-evaluate-expression " | 604 ,(nth 1 varchild) nil))))))) |
585 (nth 1 varchild) "\"\n") | |
586 `(lambda () (gdb-var-evaluate-expression-handler | |
587 ,(nth 1 varchild) nil)))))))) | |
588 (push var var-list))) | 605 (push var var-list))) |
589 (setq gdb-var-list (nreverse var-list)))))) | 606 (setq gdb-var-list (nreverse var-list)))))) |
590 | 607 |
591 (defun gdb-var-update () | 608 (defun gdb-var-update () |
592 (when (not (member 'gdb-var-update gdb-pending-triggers)) | 609 (when (not (member 'gdb-var-update gdb-pending-triggers)) |
602 (goto-char (point-min)) | 619 (goto-char (point-min)) |
603 (while (re-search-forward gdb-var-update-regexp nil t) | 620 (while (re-search-forward gdb-var-update-regexp nil t) |
604 (catch 'var-found-1 | 621 (catch 'var-found-1 |
605 (let ((varnum (match-string 1))) | 622 (let ((varnum (match-string 1))) |
606 (dolist (var gdb-var-list) | 623 (dolist (var gdb-var-list) |
607 (when (and (string-equal varnum (cadr var)) | 624 (gdb-enqueue-input |
608 (or (equal (nth 2 var) "0") | 625 (list |
609 (and (equal (nth 2 var) "1") | 626 (concat "server interpreter mi \"-var-evaluate-expression " |
610 (string-match "char \\*" (nth 3 var))))) | 627 varnum "\"\n") |
611 (gdb-enqueue-input | 628 `(lambda () (gdb-var-evaluate-expression-handler ,varnum t)))) |
612 (list | 629 (throw 'var-found-1 nil)))))) |
613 (concat "server interpreter mi \"-var-evaluate-expression " | |
614 varnum "\"\n") | |
615 `(lambda () (gdb-var-evaluate-expression-handler ,varnum t)))) | |
616 (throw 'var-found-1 nil))))))) | |
617 (setq gdb-pending-triggers | 630 (setq gdb-pending-triggers |
618 (delq 'gdb-var-update gdb-pending-triggers)) | 631 (delq 'gdb-var-update gdb-pending-triggers)) |
619 (when (and (boundp 'speedbar-frame) (frame-live-p speedbar-frame)) | 632 (when (and (boundp 'speedbar-frame) (frame-live-p speedbar-frame)) |
620 ;; Dummy command to update speedbar at right time. | 633 ;; Dummy command to update speedbar at right time. |
621 (gdb-enqueue-input (list "server pwd\n" 'gdb-speedbar-timer-fn)) | 634 (gdb-enqueue-input (list "server pwd\n" 'gdb-speedbar-timer-fn)) |
1003 | 1016 |
1004 (defun gdb-pre-prompt (ignored) | 1017 (defun gdb-pre-prompt (ignored) |
1005 "An annotation handler for `pre-prompt'. | 1018 "An annotation handler for `pre-prompt'. |
1006 This terminates the collection of output from a previous command if that | 1019 This terminates the collection of output from a previous command if that |
1007 happens to be in effect." | 1020 happens to be in effect." |
1021 (setq gdb-error nil) | |
1008 (let ((sink gdb-output-sink)) | 1022 (let ((sink gdb-output-sink)) |
1009 (cond | 1023 (cond |
1010 ((eq sink 'user) t) | 1024 ((eq sink 'user) t) |
1011 ((eq sink 'emacs) | 1025 ((eq sink 'emacs) |
1012 (setq gdb-output-sink 'post-emacs)) | 1026 (setq gdb-output-sink 'post-emacs)) |
1095 (defun gdb-stopped (ignored) | 1109 (defun gdb-stopped (ignored) |
1096 "An annotation handler for `stopped'. | 1110 "An annotation handler for `stopped'. |
1097 It is just like `gdb-stopping', except that if we already set the output | 1111 It is just like `gdb-stopping', except that if we already set the output |
1098 sink to `user' in `gdb-stopping', that is fine." | 1112 sink to `user' in `gdb-stopping', that is fine." |
1099 (setq gud-running nil) | 1113 (setq gud-running nil) |
1114 (setq gdb-active-process t) | |
1100 (let ((sink gdb-output-sink)) | 1115 (let ((sink gdb-output-sink)) |
1101 (cond | 1116 (cond |
1102 ((eq sink 'inferior) | 1117 ((eq sink 'inferior) |
1103 (setq gdb-output-sink 'user)) | 1118 (setq gdb-output-sink 'user)) |
1104 ((eq sink 'user) t) | 1119 ((eq sink 'user) t) |
1456 (save-excursion | 1471 (save-excursion |
1457 (goto-line (string-to-number line)) | 1472 (goto-line (string-to-number line)) |
1458 (gdb-put-breakpoint-icon (eq flag ?y) bptno))) | 1473 (gdb-put-breakpoint-icon (eq flag ?y) bptno))) |
1459 (gdb-enqueue-input | 1474 (gdb-enqueue-input |
1460 (list | 1475 (list |
1461 (concat "list " | 1476 (concat gdb-server-prefix "list " |
1462 (match-string-no-properties 1) ":1\n") | 1477 (match-string-no-properties 1) ":1\n") |
1463 'ignore)) | 1478 'ignore)) |
1464 (gdb-enqueue-input | 1479 (gdb-enqueue-input |
1465 (list "info source\n" | 1480 (list (concat gdb-server-prefix "info source\n") |
1466 `(lambda () (gdb-get-location | 1481 `(lambda () (gdb-get-location |
1467 ,bptno ,line ,flag)))))))))) | 1482 ,bptno ,line ,flag)))))))))) |
1468 (end-of-line))))) | 1483 (end-of-line))))) |
1469 (if (gdb-get-buffer 'gdb-assembler-buffer) (gdb-assembler-custom))) | 1484 (if (gdb-get-buffer 'gdb-assembler-buffer) (gdb-assembler-custom))) |
1470 | 1485 |
1495 (if (posn-object posn) | 1510 (if (posn-object posn) |
1496 (gdb-enqueue-input | 1511 (gdb-enqueue-input |
1497 (list | 1512 (list |
1498 (let ((bptno (get-text-property | 1513 (let ((bptno (get-text-property |
1499 0 'gdb-bptno (car (posn-string posn))))) | 1514 0 'gdb-bptno (car (posn-string posn))))) |
1500 (concat | 1515 (concat gdb-server-prefix |
1501 (if (get-text-property | 1516 (if (get-text-property |
1502 0 'gdb-enabled (car (posn-string posn))) | 1517 0 'gdb-enabled (car (posn-string posn))) |
1503 "disable " | 1518 "disable " |
1504 "enable ") | 1519 "enable ") |
1505 bptno "\n")) | 1520 bptno "\n")) |
1521 (when (overlay-get overlay 'put-break) | 1536 (when (overlay-get overlay 'put-break) |
1522 (setq obj (overlay-get overlay 'before-string)))) | 1537 (setq obj (overlay-get overlay 'before-string)))) |
1523 (when (stringp obj) | 1538 (when (stringp obj) |
1524 (gdb-enqueue-input | 1539 (gdb-enqueue-input |
1525 (list | 1540 (list |
1526 (concat | 1541 (concat gdb-server-prefix |
1527 (if (get-text-property 0 'gdb-enabled obj) | 1542 (if (get-text-property 0 'gdb-enabled obj) |
1528 "disable " | 1543 "disable " |
1529 "enable ") | 1544 "enable ") |
1530 (get-text-property 0 'gdb-bptno obj) "\n") | 1545 (get-text-property 0 'gdb-bptno obj) "\n") |
1531 'ignore)))))))) | 1546 'ignore)))))))) |
1555 (define-key menu [delete] '("Delete" . gdb-delete-breakpoint)) | 1570 (define-key menu [delete] '("Delete" . gdb-delete-breakpoint)) |
1556 (define-key menu [toggle] '("Toggle" . gdb-toggle-breakpoint)) | 1571 (define-key menu [toggle] '("Toggle" . gdb-toggle-breakpoint)) |
1557 (suppress-keymap map) | 1572 (suppress-keymap map) |
1558 (define-key map [menu-bar breakpoints] (cons "Breakpoints" menu)) | 1573 (define-key map [menu-bar breakpoints] (cons "Breakpoints" menu)) |
1559 (define-key map " " 'gdb-toggle-breakpoint) | 1574 (define-key map " " 'gdb-toggle-breakpoint) |
1560 (define-key map "d" 'gdb-delete-breakpoint) | 1575 (define-key map "D" 'gdb-delete-breakpoint) |
1561 (define-key map "q" 'kill-this-buffer) | 1576 (define-key map "q" 'kill-this-buffer) |
1562 (define-key map "\r" 'gdb-goto-breakpoint) | 1577 (define-key map "\r" 'gdb-goto-breakpoint) |
1563 (define-key map [mouse-2] 'gdb-goto-breakpoint) | 1578 (define-key map [mouse-2] 'gdb-goto-breakpoint) |
1564 (define-key map [follow-link] 'mouse-face) | 1579 (define-key map [follow-link] 'mouse-face) |
1565 map)) | 1580 map)) |
1610 (error "Not recognized as break/watchpoint line"))) | 1625 (error "Not recognized as break/watchpoint line"))) |
1611 | 1626 |
1612 (defun gdb-goto-breakpoint (&optional event) | 1627 (defun gdb-goto-breakpoint (&optional event) |
1613 "Display the breakpoint location specified at current line." | 1628 "Display the breakpoint location specified at current line." |
1614 (interactive (list last-input-event)) | 1629 (interactive (list last-input-event)) |
1615 (if event (mouse-set-point event)) | 1630 (if event (posn-set-point (event-end event))) |
1616 ;; Hack to stop gdb-goto-breakpoint displaying in GUD buffer. | 1631 ;; Hack to stop gdb-goto-breakpoint displaying in GUD buffer. |
1617 (let ((window (get-buffer-window gud-comint-buffer))) | 1632 (let ((window (get-buffer-window gud-comint-buffer))) |
1618 (if window (save-selected-window (select-window window)))) | 1633 (if window (save-selected-window (select-window window)))) |
1619 (save-excursion | 1634 (save-excursion |
1620 (beginning-of-line 1) | 1635 (beginning-of-line 1) |
1659 bl el) | 1674 bl el) |
1660 (goto-char (point-min)) | 1675 (goto-char (point-min)) |
1661 (while (< (point) (point-max)) | 1676 (while (< (point) (point-max)) |
1662 (setq bl (line-beginning-position) | 1677 (setq bl (line-beginning-position) |
1663 el (line-end-position)) | 1678 el (line-end-position)) |
1664 (unless (looking-at "No ") | 1679 (when (looking-at "#") |
1665 (add-text-properties bl el | 1680 (add-text-properties bl el |
1666 '(mouse-face highlight | 1681 '(mouse-face highlight |
1667 help-echo "mouse-2, RET: Select frame"))) | 1682 help-echo "mouse-2, RET: Select frame"))) |
1668 (goto-char bl) | 1683 (goto-char bl) |
1669 (when (looking-at "^#\\([0-9]+\\)") | 1684 (when (looking-at "^#\\([0-9]+\\)") |
1728 'gdbmi-invalidate-frames)) | 1743 'gdbmi-invalidate-frames)) |
1729 | 1744 |
1730 (defun gdb-get-frame-number () | 1745 (defun gdb-get-frame-number () |
1731 (save-excursion | 1746 (save-excursion |
1732 (end-of-line) | 1747 (end-of-line) |
1733 (let* ((pos (re-search-backward "^#*\\([0-9]*\\)" nil t)) | 1748 (let* ((start (line-beginning-position)) |
1749 (pos (re-search-backward "^#*\\([0-9]+\\)" start t)) | |
1734 (n (or (and pos (match-string-no-properties 1)) "0"))) | 1750 (n (or (and pos (match-string-no-properties 1)) "0"))) |
1735 n))) | 1751 n))) |
1736 | 1752 |
1737 (defun gdb-frames-select (&optional event) | 1753 (defun gdb-frames-select (&optional event) |
1738 "Select the frame and display the relevant source." | 1754 "Select the frame and display the relevant source." |
1739 (interactive (list last-input-event)) | 1755 (interactive (list last-input-event)) |
1740 (if event (mouse-set-point event)) | 1756 (if event (posn-set-point (event-end event))) |
1741 (gdb-enqueue-input | 1757 (gdb-enqueue-input |
1742 (list (concat gdb-server-prefix "frame " | 1758 (list (concat gdb-server-prefix "frame " |
1743 (gdb-get-frame-number) "\n") 'ignore)) | 1759 (gdb-get-frame-number) "\n") 'ignore)) |
1744 (gud-display-frame)) | 1760 (gud-display-frame)) |
1745 | 1761 |
1788 (let ((map (make-sparse-keymap))) | 1804 (let ((map (make-sparse-keymap))) |
1789 (suppress-keymap map) | 1805 (suppress-keymap map) |
1790 (define-key map "q" 'kill-this-buffer) | 1806 (define-key map "q" 'kill-this-buffer) |
1791 (define-key map "\r" 'gdb-threads-select) | 1807 (define-key map "\r" 'gdb-threads-select) |
1792 (define-key map [mouse-2] 'gdb-threads-select) | 1808 (define-key map [mouse-2] 'gdb-threads-select) |
1809 (define-key map [follow-link] 'mouse-face) | |
1793 map)) | 1810 map)) |
1794 | 1811 |
1795 (defvar gdb-threads-font-lock-keywords | 1812 (defvar gdb-threads-font-lock-keywords |
1796 '( | 1813 '( |
1797 (") +\\([^ ]+\\) (" (1 font-lock-function-name-face)) | 1814 (") +\\([^ ]+\\) (" (1 font-lock-function-name-face)) |
1820 (match-string-no-properties 1))) | 1837 (match-string-no-properties 1))) |
1821 | 1838 |
1822 (defun gdb-threads-select (&optional event) | 1839 (defun gdb-threads-select (&optional event) |
1823 "Select the thread and display the relevant source." | 1840 "Select the thread and display the relevant source." |
1824 (interactive (list last-input-event)) | 1841 (interactive (list last-input-event)) |
1825 (if event (mouse-set-point event)) | 1842 (if event (posn-set-point (event-end event))) |
1826 (gdb-enqueue-input | 1843 (gdb-enqueue-input |
1827 (list (concat "thread " (gdb-get-thread-number) "\n") 'ignore)) | 1844 (list (concat gdb-server-prefix "thread " |
1845 (gdb-get-thread-number) "\n") 'ignore)) | |
1828 (gud-display-frame)) | 1846 (gud-display-frame)) |
1829 | 1847 |
1830 | 1848 |
1831 ;; Registers buffer. | 1849 ;; Registers buffer. |
1832 ;; | 1850 ;; |
1849 | 1867 |
1850 (defun gdb-info-registers-custom () | 1868 (defun gdb-info-registers-custom () |
1851 (with-current-buffer (gdb-get-buffer 'gdb-registers-buffer) | 1869 (with-current-buffer (gdb-get-buffer 'gdb-registers-buffer) |
1852 (save-excursion | 1870 (save-excursion |
1853 (let ((buffer-read-only nil) | 1871 (let ((buffer-read-only nil) |
1854 bl) | 1872 start end) |
1855 (goto-char (point-min)) | 1873 (goto-char (point-min)) |
1856 (while (< (point) (point-max)) | 1874 (while (< (point) (point-max)) |
1857 (setq bl (line-beginning-position)) | 1875 (setq start (line-beginning-position)) |
1876 (setq end (line-end-position)) | |
1858 (when (looking-at "^[^ ]+") | 1877 (when (looking-at "^[^ ]+") |
1859 (unless (string-equal (match-string 0) "The") | 1878 (unless (string-equal (match-string 0) "The") |
1860 (put-text-property bl (match-end 0) | 1879 (put-text-property start (match-end 0) |
1861 'face font-lock-variable-name-face))) | 1880 'face font-lock-variable-name-face) |
1881 (add-text-properties start end | |
1882 '(help-echo "mouse-2: edit value" | |
1883 mouse-face highlight)))) | |
1862 (forward-line 1)))))) | 1884 (forward-line 1)))))) |
1885 | |
1886 (defun gdb-edit-register-value (&optional event) | |
1887 (interactive (list last-input-event)) | |
1888 (save-excursion | |
1889 (if event (posn-set-point (event-end event))) | |
1890 (beginning-of-line) | |
1891 (let* ((register (current-word)) | |
1892 (value (read-string (format "New value (%s): " register)))) | |
1893 (gdb-enqueue-input | |
1894 (list (concat gdb-server-prefix "set $" register "=" value "\n") | |
1895 'ignore))))) | |
1863 | 1896 |
1864 (defvar gdb-registers-mode-map | 1897 (defvar gdb-registers-mode-map |
1865 (let ((map (make-sparse-keymap))) | 1898 (let ((map (make-sparse-keymap))) |
1866 (suppress-keymap map) | 1899 (suppress-keymap map) |
1900 (define-key map "\r" 'gdb-edit-register-value) | |
1901 (define-key map [mouse-2] 'gdb-edit-register-value) | |
1867 (define-key map " " 'toggle-gdb-all-registers) | 1902 (define-key map " " 'toggle-gdb-all-registers) |
1868 (define-key map "q" 'kill-this-buffer) | 1903 (define-key map "q" 'kill-this-buffer) |
1869 map)) | 1904 map)) |
1870 | 1905 |
1871 (defun gdb-registers-mode () | 1906 (defun gdb-registers-mode () |
1905 (if gdb-all-registers | 1940 (if gdb-all-registers |
1906 (progn | 1941 (progn |
1907 (setq gdb-all-registers nil) | 1942 (setq gdb-all-registers nil) |
1908 (with-current-buffer (gdb-get-buffer 'gdb-registers-buffer) | 1943 (with-current-buffer (gdb-get-buffer 'gdb-registers-buffer) |
1909 (setq mode-name "Registers:"))) | 1944 (setq mode-name "Registers:"))) |
1910 (setq gdb-all-registers t) | 1945 (setq gdb-all-registers t) |
1911 (with-current-buffer (gdb-get-buffer 'gdb-registers-buffer) | 1946 (with-current-buffer (gdb-get-buffer 'gdb-registers-buffer) |
1912 (setq mode-name "Registers:All"))) | 1947 (setq mode-name "Registers:All"))) |
1913 (gdb-invalidate-registers)) | 1948 (gdb-invalidate-registers)) |
1914 | 1949 |
1915 | 1950 |
1916 ;; Memory buffer. | 1951 ;; Memory buffer. |
1917 ;; | 1952 ;; |
2243 (gud-watch))) | 2278 (gud-watch))) |
2244 map) | 2279 map) |
2245 "Keymap to create watch expression of a complex data type local variable.") | 2280 "Keymap to create watch expression of a complex data type local variable.") |
2246 | 2281 |
2247 (defconst gdb-struct-string | 2282 (defconst gdb-struct-string |
2248 (concat (propertize "[struct/union];" | 2283 (concat (propertize "[struct/union]" |
2249 'mouse-face 'highlight | 2284 'mouse-face 'highlight |
2250 'help-echo "mouse-2: create watch expression" | 2285 'help-echo "mouse-2: create watch expression" |
2251 'local-map gdb-locals-watch-keymap) "\n")) | 2286 'local-map gdb-locals-watch-keymap) "\n")) |
2252 | 2287 |
2253 (defconst gdb-array-string | 2288 (defconst gdb-array-string |
2254 (concat " " (propertize "[array];" | 2289 (concat " " (propertize "[array]" |
2255 'mouse-face 'highlight | 2290 'mouse-face 'highlight |
2256 'help-echo "mouse-2: create watch expression" | 2291 'help-echo "mouse-2: create watch expression" |
2257 'local-map gdb-locals-watch-keymap) "\n")) | 2292 'local-map gdb-locals-watch-keymap) "\n")) |
2258 | 2293 |
2259 ;; Abbreviate for arrays and structures. | 2294 ;; Abbreviate for arrays and structures. |