diff options
| author | Nick Roberts | 2005-02-08 11:53:43 +0000 |
|---|---|---|
| committer | Nick Roberts | 2005-02-08 11:53:43 +0000 |
| commit | 94cd554acd6bad3138e631dda9acff8e33a76586 (patch) | |
| tree | bc31aac56746c293bb9b3a3a550b8148ef0c1b42 | |
| parent | 76f8cd56df71e2d5c331b730939e6284e796b872 (diff) | |
| download | emacs-94cd554acd6bad3138e631dda9acff8e33a76586.tar.gz emacs-94cd554acd6bad3138e631dda9acff8e33a76586.zip | |
(gdb-location-list): New variable.
(gdb-cdir): Delete
(gdb-info-breakpoints-custom, gdb-goto-breakpoint)
(gdb-source-info): Treat case when source file is in another
directory properly.
(gdb-get-location): New function.
| -rw-r--r-- | lisp/progmodes/gdb-ui.el | 80 |
1 files changed, 55 insertions, 25 deletions
diff --git a/lisp/progmodes/gdb-ui.el b/lisp/progmodes/gdb-ui.el index 9c15fc5be52..bdcce671a9c 100644 --- a/lisp/progmodes/gdb-ui.el +++ b/lisp/progmodes/gdb-ui.el | |||
| @@ -248,6 +248,7 @@ detailed description of this mode. | |||
| 248 | (setq gdb-output-sink 'user) | 248 | (setq gdb-output-sink 'user) |
| 249 | (setq gdb-server-prefix "server ") | 249 | (setq gdb-server-prefix "server ") |
| 250 | (setq gdb-flush-pending-output nil) | 250 | (setq gdb-flush-pending-output nil) |
| 251 | (setq gdb-location-list nil) | ||
| 251 | ;; | 252 | ;; |
| 252 | (setq gdb-buffer-type 'gdba) | 253 | (setq gdb-buffer-type 'gdba) |
| 253 | ;; | 254 | ;; |
| @@ -1046,7 +1047,7 @@ happens to be appropriate." | |||
| 1046 | ;; buffer specific functions | 1047 | ;; buffer specific functions |
| 1047 | gdb-info-breakpoints-custom) | 1048 | gdb-info-breakpoints-custom) |
| 1048 | 1049 | ||
| 1049 | (defvar gdb-cdir nil "Compilation directory.") | 1050 | (defvar gdb-location-list nil "List of directories for source files.") |
| 1050 | 1051 | ||
| 1051 | (defconst breakpoint-xpm-data | 1052 | (defconst breakpoint-xpm-data |
| 1052 | "/* XPM */ | 1053 | "/* XPM */ |
| @@ -1145,7 +1146,7 @@ static char *magick[] = { | |||
| 1145 | (setq bptno (match-string 1)) | 1146 | (setq bptno (match-string 1)) |
| 1146 | (setq flag (char-after (match-beginning 2))) | 1147 | (setq flag (char-after (match-beginning 2))) |
| 1147 | (beginning-of-line) | 1148 | (beginning-of-line) |
| 1148 | (if (re-search-forward "in.*at\\s-+" nil t) | 1149 | (if (re-search-forward " in .* at\\s-+" nil t) |
| 1149 | (progn | 1150 | (progn |
| 1150 | (looking-at "\\(\\S-+\\):\\([0-9]+\\)") | 1151 | (looking-at "\\(\\S-+\\):\\([0-9]+\\)") |
| 1151 | (let ((line (match-string 2)) (buffer-read-only nil) | 1152 | (let ((line (match-string 2)) (buffer-read-only nil) |
| @@ -1153,18 +1154,30 @@ static char *magick[] = { | |||
| 1153 | (add-text-properties (point-at-bol) (point-at-eol) | 1154 | (add-text-properties (point-at-bol) (point-at-eol) |
| 1154 | '(mouse-face highlight | 1155 | '(mouse-face highlight |
| 1155 | help-echo "mouse-2, RET: visit breakpoint")) | 1156 | help-echo "mouse-2, RET: visit breakpoint")) |
| 1156 | (with-current-buffer | 1157 | (unless (file-exists-p file) |
| 1157 | (find-file-noselect | 1158 | (setq file (cdr (assoc bptno gdb-location-list)))) |
| 1158 | (if (file-exists-p file) file | 1159 | (unless (string-equal file "File not found") |
| 1159 | (expand-file-name file gdb-cdir))) | 1160 | (if file |
| 1160 | (save-current-buffer | 1161 | (with-current-buffer |
| 1161 | (set (make-local-variable 'gud-minor-mode) 'gdba) | 1162 | (find-file-noselect file) |
| 1162 | (set (make-local-variable 'tool-bar-map) | 1163 | (save-current-buffer |
| 1163 | gud-tool-bar-map)) | 1164 | (set (make-local-variable 'gud-minor-mode) |
| 1164 | ;; only want one breakpoint icon at each location | 1165 | 'gdba) |
| 1165 | (save-excursion | 1166 | (set (make-local-variable 'tool-bar-map) |
| 1166 | (goto-line (string-to-number line)) | 1167 | gud-tool-bar-map)) |
| 1167 | (gdb-put-breakpoint-icon (eq flag ?y) bptno)))))))) | 1168 | ;; only want one breakpoint icon at each location |
| 1169 | (save-excursion | ||
| 1170 | (goto-line (string-to-number line)) | ||
| 1171 | (gdb-put-breakpoint-icon (eq flag ?y) bptno))) | ||
| 1172 | (gdb-enqueue-input | ||
| 1173 | (list (concat gdb-server-prefix "list " | ||
| 1174 | (match-string-no-properties 1) ":1\n") | ||
| 1175 | 'ignore)) | ||
| 1176 | (gdb-enqueue-input | ||
| 1177 | (list (concat gdb-server-prefix "info source\n") | ||
| 1178 | `(lambda () | ||
| 1179 | (gdb-get-location | ||
| 1180 | ,bptno ,line ,flag))))))))))) | ||
| 1168 | (end-of-line))))) | 1181 | (end-of-line))))) |
| 1169 | (if (gdb-get-buffer 'gdb-assembler-buffer) (gdb-assembler-custom))) | 1182 | (if (gdb-get-buffer 'gdb-assembler-buffer) (gdb-assembler-custom))) |
| 1170 | 1183 | ||
| @@ -1300,15 +1313,16 @@ static char *magick[] = { | |||
| 1300 | (save-excursion | 1313 | (save-excursion |
| 1301 | (beginning-of-line 1) | 1314 | (beginning-of-line 1) |
| 1302 | (if (if (with-current-buffer gud-comint-buffer (eq gud-minor-mode 'gdba)) | 1315 | (if (if (with-current-buffer gud-comint-buffer (eq gud-minor-mode 'gdba)) |
| 1303 | (looking-at ".*in.*at\\s-+\\(\\S-*\\):\\([0-9]+\\)") | 1316 | (looking-at "\\([0-9]+\\) .* in .* at\\s-+\\(\\S-*\\):\\([0-9]+\\)") |
| 1304 | (looking-at | 1317 | (looking-at |
| 1305 | "[0-9]+\\s-*\\S-*\\s-*\\S-*\\s-*.\\s-*\\S-*\\s-*\\(\\S-*\\):\\([0-9]+\\)")) | 1318 | "\\([0-9]+\\)\\s-*\\S-*\\s-*\\S-*\\s-*.\\s-*\\S-*\\s-*\\(\\S-*\\):\\([0-9]+\\)")) |
| 1306 | (let ((line (match-string 2)) | 1319 | (let ((bptno (match-string 1)) |
| 1307 | (file (match-string 1))) | 1320 | (file (match-string 2)) |
| 1321 | (line (match-string 3))) | ||
| 1308 | (save-selected-window | 1322 | (save-selected-window |
| 1309 | (let* ((buf (find-file-noselect (if (file-exists-p file) | 1323 | (let* ((buf (find-file-noselect (if (file-exists-p file) |
| 1310 | file | 1324 | file |
| 1311 | (expand-file-name file gdb-cdir)))) | 1325 | (cdr (assoc bptno gdb-location-list))))) |
| 1312 | (window (display-buffer buf))) | 1326 | (window (display-buffer buf))) |
| 1313 | (with-current-buffer buf | 1327 | (with-current-buffer buf |
| 1314 | (goto-line (string-to-number line)) | 1328 | (goto-line (string-to-number line)) |
| @@ -2039,21 +2053,37 @@ Kills the gdb buffers and resets the source buffers." | |||
| 2039 | "Find the source file where the program starts and displays it with related | 2053 | "Find the source file where the program starts and displays it with related |
| 2040 | buffers." | 2054 | buffers." |
| 2041 | (goto-char (point-min)) | 2055 | (goto-char (point-min)) |
| 2042 | (if (search-forward "directory is " nil t) | ||
| 2043 | (if (looking-at "\\S-*:\\(\\S-*\\)") | ||
| 2044 | (setq gdb-cdir (match-string 1)) | ||
| 2045 | (looking-at "\\S-*") | ||
| 2046 | (setq gdb-cdir (match-string 0)))) | ||
| 2047 | (if (search-forward "Located in " nil t) | 2056 | (if (search-forward "Located in " nil t) |
| 2048 | (if (looking-at "\\S-*") | 2057 | (if (looking-at "\\S-*") |
| 2049 | (setq gdb-main-file (match-string 0)))) | 2058 | (setq gdb-main-file (match-string 0)))) |
| 2050 | (if gdb-many-windows | 2059 | (if gdb-many-windows |
| 2051 | (gdb-setup-windows) | 2060 | (gdb-setup-windows) |
| 2052 | (gdb-get-create-buffer 'gdb-breakpoints-buffer) | 2061 | (gdb-get-create-buffer 'gdb-breakpoints-buffer) |
| 2053 | (if gdb-show-main | 2062 | (if gdb-show-main |
| 2054 | (let ((pop-up-windows t)) | 2063 | (let ((pop-up-windows t)) |
| 2055 | (display-buffer (gud-find-file gdb-main-file)))))) | 2064 | (display-buffer (gud-find-file gdb-main-file)))))) |
| 2056 | 2065 | ||
| 2066 | (defun gdb-get-location (bptno line flag) | ||
| 2067 | "Find the directory containing the relevant source file. | ||
| 2068 | Put in buffer and place breakpoint icon." | ||
| 2069 | (goto-char (point-min)) | ||
| 2070 | (if (search-forward "Located in " nil t) | ||
| 2071 | (if (looking-at "\\S-*") | ||
| 2072 | (push (cons bptno (match-string 0)) gdb-location-list)) | ||
| 2073 | (gdb-resync) | ||
| 2074 | (push (cons bptno "File not found") gdb-location-list) | ||
| 2075 | (error "Cannot find source file for breakpoint location. | ||
| 2076 | Add directory to search path for source files using the GDB command, dir.")) | ||
| 2077 | (with-current-buffer | ||
| 2078 | (find-file-noselect (match-string 0)) | ||
| 2079 | (save-current-buffer | ||
| 2080 | (set (make-local-variable 'gud-minor-mode) 'gdba) | ||
| 2081 | (set (make-local-variable 'tool-bar-map) gud-tool-bar-map)) | ||
| 2082 | ;; only want one breakpoint icon at each location | ||
| 2083 | (save-excursion | ||
| 2084 | (goto-line (string-to-number line)) | ||
| 2085 | (gdb-put-breakpoint-icon (eq flag ?y) bptno)))) | ||
| 2086 | |||
| 2057 | ;;from put-image | 2087 | ;;from put-image |
| 2058 | (defun gdb-put-string (putstring pos &optional dprop) | 2088 | (defun gdb-put-string (putstring pos &optional dprop) |
| 2059 | "Put string PUTSTRING in front of POS in the current buffer. | 2089 | "Put string PUTSTRING in front of POS in the current buffer. |