diff options
| author | Nick Roberts | 2005-02-15 09:19:13 +0000 |
|---|---|---|
| committer | Nick Roberts | 2005-02-15 09:19:13 +0000 |
| commit | e7212bb36eb43c99a23b7698566c3d94357a153d (patch) | |
| tree | d988c35c160e803fb76801d134c44a14523886bf | |
| parent | 34093ed7822a17664193ffa1c9512798b4455965 (diff) | |
| download | emacs-e7212bb36eb43c99a23b7698566c3d94357a153d.tar.gz emacs-e7212bb36eb43c99a23b7698566c3d94357a153d.zip | |
(gdb-find-file-unhook): New variable.
(gdb-set-gud-minor-mode, gdb-set-gud-minor-mode-1)
(gdb-set-gud-minor-mode-existing-buffers): New functions.
(gdb-find-file-hook): New hook. Add it to find-file-hook.
(gdb-info-breakpoints-custom, gdb-source-info): Simplify.
| -rw-r--r-- | lisp/progmodes/gdb-ui.el | 73 |
1 files changed, 59 insertions, 14 deletions
diff --git a/lisp/progmodes/gdb-ui.el b/lisp/progmodes/gdb-ui.el index 97511376086..1e5f622ea30 100644 --- a/lisp/progmodes/gdb-ui.el +++ b/lisp/progmodes/gdb-ui.el | |||
| @@ -79,6 +79,8 @@ | |||
| 79 | (defvar gdb-overlay-arrow-position nil) | 79 | (defvar gdb-overlay-arrow-position nil) |
| 80 | (defvar gdb-server-prefix nil) | 80 | (defvar gdb-server-prefix nil) |
| 81 | (defvar gdb-flush-pending-output nil) | 81 | (defvar gdb-flush-pending-output nil) |
| 82 | (defvar gdb-location-list nil "List of directories for source files.") | ||
| 83 | (defvar gdb-find-file-unhook nil) | ||
| 82 | 84 | ||
| 83 | (defvar gdb-buffer-type nil | 85 | (defvar gdb-buffer-type nil |
| 84 | "One of the symbols bound in `gdb-buffer-rules'.") | 86 | "One of the symbols bound in `gdb-buffer-rules'.") |
| @@ -191,6 +193,35 @@ detailed description of this mode. | |||
| 191 | :group 'gud | 193 | :group 'gud |
| 192 | :version "22.1") | 194 | :version "22.1") |
| 193 | 195 | ||
| 196 | (defun gdb-set-gud-minor-mode (buffer) | ||
| 197 | "Set gud-minor-mode from find-file if appropriate." | ||
| 198 | (goto-char (point-min)) | ||
| 199 | (unless (search-forward "No source file named " nil t) | ||
| 200 | (condition-case nil | ||
| 201 | (gdb-enqueue-input | ||
| 202 | (list (concat gdb-server-prefix "info source\n") | ||
| 203 | `(lambda () (gdb-set-gud-minor-mode-1 ,buffer)))) | ||
| 204 | (error (setq gdb-find-file-unhook t))))) | ||
| 205 | |||
| 206 | (defun gdb-set-gud-minor-mode-1 (buffer) | ||
| 207 | (goto-char (point-min)) | ||
| 208 | (if (and (search-forward "Located in " nil t) | ||
| 209 | (looking-at "\\S-*") | ||
| 210 | (string-equal (buffer-file-name buffer) | ||
| 211 | (match-string 0))) | ||
| 212 | (with-current-buffer buffer | ||
| 213 | (set (make-local-variable 'gud-minor-mode) 'gdba) | ||
| 214 | (set (make-local-variable 'tool-bar-map) gud-tool-bar-map)))) | ||
| 215 | |||
| 216 | (defun gdb-set-gud-minor-mode-existing-buffers () | ||
| 217 | (dolist (buffer (buffer-list)) | ||
| 218 | (let ((file (buffer-file-name buffer))) | ||
| 219 | (if file | ||
| 220 | (progn | ||
| 221 | (gdb-enqueue-input | ||
| 222 | (list (concat "list " (file-name-nondirectory file) ":1\n") | ||
| 223 | `(lambda () (gdb-set-gud-minor-mode ,buffer))))))))) | ||
| 224 | |||
| 194 | (defun gdb-ann3 () | 225 | (defun gdb-ann3 () |
| 195 | (setq gdb-debug-log nil) | 226 | (setq gdb-debug-log nil) |
| 196 | (set (make-local-variable 'gud-minor-mode) 'gdba) | 227 | (set (make-local-variable 'gud-minor-mode) 'gdba) |
| @@ -249,6 +280,7 @@ detailed description of this mode. | |||
| 249 | (setq gdb-server-prefix "server ") | 280 | (setq gdb-server-prefix "server ") |
| 250 | (setq gdb-flush-pending-output nil) | 281 | (setq gdb-flush-pending-output nil) |
| 251 | (setq gdb-location-list nil) | 282 | (setq gdb-location-list nil) |
| 283 | (setq gdb-find-file-unhook nil) | ||
| 252 | ;; | 284 | ;; |
| 253 | (setq gdb-buffer-type 'gdba) | 285 | (setq gdb-buffer-type 'gdba) |
| 254 | ;; | 286 | ;; |
| @@ -263,6 +295,7 @@ detailed description of this mode. | |||
| 263 | (gdb-enqueue-input (list "server list MAIN__\n" 'ignore)) ; Fortran program | 295 | (gdb-enqueue-input (list "server list MAIN__\n" 'ignore)) ; Fortran program |
| 264 | (gdb-enqueue-input (list "server info source\n" 'gdb-source-info)) | 296 | (gdb-enqueue-input (list "server info source\n" 'gdb-source-info)) |
| 265 | ;; | 297 | ;; |
| 298 | (gdb-set-gud-minor-mode-existing-buffers) | ||
| 266 | (run-hooks 'gdba-mode-hook)) | 299 | (run-hooks 'gdba-mode-hook)) |
| 267 | 300 | ||
| 268 | (defcustom gdb-use-colon-colon-notation nil | 301 | (defcustom gdb-use-colon-colon-notation nil |
| @@ -1048,8 +1081,6 @@ happens to be appropriate." | |||
| 1048 | ;; buffer specific functions | 1081 | ;; buffer specific functions |
| 1049 | gdb-info-breakpoints-custom) | 1082 | gdb-info-breakpoints-custom) |
| 1050 | 1083 | ||
| 1051 | (defvar gdb-location-list nil "List of directories for source files.") | ||
| 1052 | |||
| 1053 | (defconst breakpoint-xpm-data | 1084 | (defconst breakpoint-xpm-data |
| 1054 | "/* XPM */ | 1085 | "/* XPM */ |
| 1055 | static char *magick[] = { | 1086 | static char *magick[] = { |
| @@ -1159,13 +1190,11 @@ static char *magick[] = { | |||
| 1159 | (setq file (cdr (assoc bptno gdb-location-list)))) | 1190 | (setq file (cdr (assoc bptno gdb-location-list)))) |
| 1160 | (unless (string-equal file "File not found") | 1191 | (unless (string-equal file "File not found") |
| 1161 | (if file | 1192 | (if file |
| 1162 | (with-current-buffer | 1193 | (with-current-buffer (find-file-noselect file) |
| 1163 | (find-file-noselect file) | 1194 | (set (make-local-variable 'gud-minor-mode) |
| 1164 | (save-current-buffer | ||
| 1165 | (set (make-local-variable 'gud-minor-mode) | ||
| 1166 | 'gdba) | 1195 | 'gdba) |
| 1167 | (set (make-local-variable 'tool-bar-map) | 1196 | (set (make-local-variable 'tool-bar-map) |
| 1168 | gud-tool-bar-map)) | 1197 | gud-tool-bar-map) |
| 1169 | ;; only want one breakpoint icon at each location | 1198 | ;; only want one breakpoint icon at each location |
| 1170 | (save-excursion | 1199 | (save-excursion |
| 1171 | (goto-line (string-to-number line)) | 1200 | (goto-line (string-to-number line)) |
| @@ -2054,15 +2083,15 @@ Kills the gdb buffers and resets the source buffers." | |||
| 2054 | "Find the source file where the program starts and displays it with related | 2083 | "Find the source file where the program starts and displays it with related |
| 2055 | buffers." | 2084 | buffers." |
| 2056 | (goto-char (point-min)) | 2085 | (goto-char (point-min)) |
| 2057 | (if (search-forward "Located in " nil t) | 2086 | (if (and (search-forward "Located in " nil t) |
| 2058 | (if (looking-at "\\S-*") | 2087 | (looking-at "\\S-*")) |
| 2059 | (setq gdb-main-file (match-string 0)))) | 2088 | (setq gdb-main-file (match-string 0))) |
| 2060 | (if gdb-many-windows | 2089 | (if gdb-many-windows |
| 2061 | (gdb-setup-windows) | 2090 | (gdb-setup-windows) |
| 2062 | (gdb-get-create-buffer 'gdb-breakpoints-buffer) | 2091 | (gdb-get-create-buffer 'gdb-breakpoints-buffer) |
| 2063 | (if gdb-show-main | 2092 | (if gdb-show-main |
| 2064 | (let ((pop-up-windows t)) | 2093 | (let ((pop-up-windows t)) |
| 2065 | (display-buffer (gud-find-file gdb-main-file)))))) | 2094 | (display-buffer (gud-find-file gdb-main-file)))))) |
| 2066 | 2095 | ||
| 2067 | (defun gdb-get-location (bptno line flag) | 2096 | (defun gdb-get-location (bptno line flag) |
| 2068 | "Find the directory containing the relevant source file. | 2097 | "Find the directory containing the relevant source file. |
| @@ -2085,6 +2114,22 @@ Add directory to search path for source files using the GDB command, dir.")) | |||
| 2085 | (goto-line (string-to-number line)) | 2114 | (goto-line (string-to-number line)) |
| 2086 | (gdb-put-breakpoint-icon (eq flag ?y) bptno)))) | 2115 | (gdb-put-breakpoint-icon (eq flag ?y) bptno)))) |
| 2087 | 2116 | ||
| 2117 | (add-hook 'find-file-hook 'gdb-find-file-hook) | ||
| 2118 | |||
| 2119 | (defun gdb-find-file-hook () | ||
| 2120 | (if (and (not gdb-find-file-unhook) | ||
| 2121 | ;; in case gud or gdb-ui is just loaded | ||
| 2122 | gud-comint-buffer | ||
| 2123 | (buffer-name gud-comint-buffer) | ||
| 2124 | (with-current-buffer gud-comint-buffer | ||
| 2125 | (eq gud-minor-mode 'gdba))) | ||
| 2126 | (condition-case nil | ||
| 2127 | (gdb-enqueue-input | ||
| 2128 | (list (concat "list " (file-name-nondirectory buffer-file-name) | ||
| 2129 | ":1\n") | ||
| 2130 | `(lambda () (gdb-set-gud-minor-mode ,(current-buffer))))) | ||
| 2131 | (error (setq gdb-find-file-unhook t))))) | ||
| 2132 | |||
| 2088 | ;;from put-image | 2133 | ;;from put-image |
| 2089 | (defun gdb-put-string (putstring pos &optional dprop) | 2134 | (defun gdb-put-string (putstring pos &optional dprop) |
| 2090 | "Put string PUTSTRING in front of POS in the current buffer. | 2135 | "Put string PUTSTRING in front of POS in the current buffer. |