comparison lisp/progmodes/gdb-ui.el @ 59988:fb52ec059049

(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.
author Nick Roberts <nickrob@snap.net.nz>
date Tue, 08 Feb 2005 11:53:43 +0000
parents 79e9767b47c8
children aac0a33f5772
comparison
equal deleted inserted replaced
59987:0e6dbaf59d79 59988:fb52ec059049
246 (setq gdb-current-item nil) 246 (setq gdb-current-item nil)
247 (setq gdb-pending-triggers nil) 247 (setq gdb-pending-triggers nil)
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 ;;
254 (if gdb-use-inferior-io-buffer (gdb-clear-inferior-io)) 255 (if gdb-use-inferior-io-buffer (gdb-clear-inferior-io))
255 ;; 256 ;;
1044 ;; the appropriately typed buffer. That function will be called: 1045 ;; the appropriately typed buffer. That function will be called:
1045 gdb-info-breakpoints-handler 1046 gdb-info-breakpoints-handler
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 */
1053 static char *magick[] = { 1054 static char *magick[] = {
1054 /* columns rows colors chars-per-pixel */ 1055 /* columns rows colors chars-per-pixel */
1143 (progn 1144 (progn
1144 (looking-at "\\([0-9]+\\)\\s-+\\S-+\\s-+\\S-+\\s-+\\(.\\)") 1145 (looking-at "\\([0-9]+\\)\\s-+\\S-+\\s-+\\S-+\\s-+\\(.\\)")
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)
1152 (file (match-string 1))) 1153 (file (match-string 1)))
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
1171 (defun gdb-mouse-set-clear-breakpoint (event) 1184 (defun gdb-mouse-set-clear-breakpoint (event)
1172 "Set/clear breakpoint in left fringe/margin with mouse click." 1185 "Set/clear breakpoint in left fringe/margin with mouse click."
1298 (interactive (list last-input-event)) 1311 (interactive (list last-input-event))
1299 (if event (mouse-set-point event)) 1312 (if event (mouse-set-point event))
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))
1315 (set-window-point window (point)))))) 1329 (set-window-point window (point))))))
1316 (error "Not recognized as break/watchpoint line")))) 1330 (error "Not recognized as break/watchpoint line"))))
2037 2051
2038 (defun gdb-source-info () 2052 (defun gdb-source-info ()
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))))))
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))))
2056 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.
2060 PUTSTRING is displayed by putting an overlay into the current buffer with a 2090 PUTSTRING is displayed by putting an overlay into the current buffer with a