Mercurial > emacs
comparison lisp/progmodes/gdb-mi.el @ 104232:23230e6cbc19
*** empty log message ***
author | Dmitry Dzhus <dima@sphinx.net.ru> |
---|---|
date | Tue, 11 Aug 2009 10:48:56 +0000 |
parents | 8642d488076f |
children | fbce43fef5e3 |
comparison
equal
deleted
inserted
replaced
104231:bfb43cf93581 | 104232:23230e6cbc19 |
---|---|
132 value.") | 132 value.") |
133 | 133 |
134 (defvar gdb-frame-number nil | 134 (defvar gdb-frame-number nil |
135 "Selected frame level for main current thread. | 135 "Selected frame level for main current thread. |
136 | 136 |
137 Reset whenever current thread changes.") | 137 Updated according to the following rules: |
138 | |
139 When a thread is selected or current thread stops, set to \"0\". | |
140 | |
141 When current thread goes running (and possibly exits eventually), | |
142 set to nil. | |
143 | |
144 May be manually changed by user with `gdb-select-frame'.") | |
138 | 145 |
139 ;; Used to show overlay arrow in source buffer. All set in | 146 ;; Used to show overlay arrow in source buffer. All set in |
140 ;; gdb-get-main-selected-frame. Disassembly buffer should not use | 147 ;; gdb-get-main-selected-frame. Disassembly buffer should not use |
141 ;; these but rely on buffer-local thread information instead. | 148 ;; these but rely on buffer-local thread information instead. |
142 (defvar gdb-selected-frame nil | 149 (defvar gdb-selected-frame nil |
563 (not noall)) | 570 (not noall)) |
564 (concat command " --all ") | 571 (concat command " --all ") |
565 (gdb-current-context-command command t)) | 572 (gdb-current-context-command command t)) |
566 command)) | 573 command)) |
567 | 574 |
568 ;; TODO Document this. We use noarg when not in gud-def | 575 (defmacro gdb-gud-context-call (cmd1 &optional cmd2 noall noarg) |
569 (defun gdb-gud-context-call (cmd1 &optional cmd2 noall noarg) | 576 "`gud-call' wrapper which adds --thread/--all options between |
570 (gud-call | 577 CMD1 and CMD2. NOALL is the same as in `gdb-gud-context-command'. |
571 (concat | 578 |
572 (gdb-gud-context-command cmd1 noall) | 579 NOARG must be t when this macro is used outside `gud-def'" |
573 cmd2) (when (not noarg) 'arg))) | 580 `(gud-call |
581 (concat | |
582 (gdb-gud-context-command ,cmd1 ,noall) | |
583 ,cmd2) ,(when (not noarg) 'arg))) | |
574 | 584 |
575 ;;;###autoload | 585 ;;;###autoload |
576 (defun gdb (command-line) | 586 (defun gdb (command-line) |
577 "Run gdb on program FILE in buffer *gud-FILE*. | 587 "Run gdb on program FILE in buffer *gud-FILE*. |
578 The directory containing FILE becomes the initial working directory | 588 The directory containing FILE becomes the initial working directory |
1653 (setq gdb-thread-number number) | 1663 (setq gdb-thread-number number) |
1654 (setq gdb-frame-number "0") | 1664 (setq gdb-frame-number "0") |
1655 (gdb-update-gud-running)) | 1665 (gdb-update-gud-running)) |
1656 | 1666 |
1657 (defun gdb-update-gud-running () | 1667 (defun gdb-update-gud-running () |
1658 "Set `gud-running' and `gdb-frame-number' according to the state | 1668 "Set `gud-running' according to the state of current thread. |
1659 of current thread. | 1669 |
1660 | 1670 `gdb-frame-number' is set to 0 if current thread is now stopped. |
1661 `gdb-frame-number' is set to nil if new current thread is | |
1662 running. | |
1663 | 1671 |
1664 Note that when `gdb-gud-control-all-threads' is t, `gud-running' | 1672 Note that when `gdb-gud-control-all-threads' is t, `gud-running' |
1665 cannot be reliably used to determine whether or not execution | 1673 cannot be reliably used to determine whether or not execution |
1666 control buttons should be shown in menu or toolbar. Use | 1674 control buttons should be shown in menu or toolbar. Use |
1667 `gdb-running-threads-count' and `gdb-stopped-threads-count' | 1675 `gdb-running-threads-count' and `gdb-stopped-threads-count' |
1671 is running." | 1679 is running." |
1672 (let ((old-value gud-running)) | 1680 (let ((old-value gud-running)) |
1673 (setq gud-running | 1681 (setq gud-running |
1674 (string= (gdb-get-field (gdb-current-buffer-thread) 'state) | 1682 (string= (gdb-get-field (gdb-current-buffer-thread) 'state) |
1675 "running")) | 1683 "running")) |
1676 ;; We change frame number only if the state of current thread has | 1684 ;; Set frame number to "0" when _current_ threads stops |
1677 ;; changed or there's no current thread. | 1685 (when (and (gdb-current-buffer-thread) |
1678 (when (not (eq gud-running old-value)) | 1686 (not (eq gud-running old-value))) |
1679 (if (or gud-running (not (gdb-current-buffer-thread))) | 1687 (setq gdb-frame-number "0")))) |
1680 (setq gdb-frame-number nil) | |
1681 (setq gdb-frame-number "0"))))) | |
1682 | 1688 |
1683 (defun gdb-show-run-p () | 1689 (defun gdb-show-run-p () |
1684 "Return t if \"Run/continue\" should be shown on the toolbar." | 1690 "Return t if \"Run/continue\" should be shown on the toolbar." |
1685 (or (not gdb-active-process) | 1691 (or (not gdb-active-process) |
1686 (and (or | 1692 (and (or |
1799 | 1805 |
1800 ;; gdb-invalidate-threads is defined to accept 'update-threads signal | 1806 ;; gdb-invalidate-threads is defined to accept 'update-threads signal |
1801 (defun gdb-thread-created (output-field)) | 1807 (defun gdb-thread-created (output-field)) |
1802 (defun gdb-thread-exited (output-field) | 1808 (defun gdb-thread-exited (output-field) |
1803 "Handle =thread-exited async record: unset `gdb-thread-number' | 1809 "Handle =thread-exited async record: unset `gdb-thread-number' |
1804 if current thread exited and update threads list." | 1810 if current thread exited and update threads list." |
1805 (let* ((thread-id (gdb-get-field (gdb-json-string output-field) 'id))) | 1811 (let* ((thread-id (gdb-get-field (gdb-json-string output-field) 'id))) |
1806 (if (string= gdb-thread-number thread-id) | 1812 (if (string= gdb-thread-number thread-id) |
1807 (gdb-setq-thread-number nil)) | 1813 (gdb-setq-thread-number nil)) |
1808 ;; When we continue current thread and it quickly exits, | 1814 ;; When we continue current thread and it quickly exits, |
1809 ;; gdb-pending-triggers left after gdb-running disallow us to | 1815 ;; gdb-pending-triggers left after gdb-running disallow us to |