comparison lisp/gdb-ui.el @ 51028:323ddc93f3fe

(gdb-info-frames-custom): Reverse contrast of face for selected frame. (gdb-annotation-rules): Stop using frames-invalid and breakpoints-invalid annotations. Update after post-prompt instead. (gdb-post-prompt): Update frames and breakpoints here. (gdb-invalidate-frame-and-assembler) (gdb-invalidate-breakpoints-and-assembler): Remove. (gdb-current-address): Remove. (gdb-previous-address): New variable. (gud-until): Extend to work in Assembler buffer (gdb-append-to-inferior-io): Select IO buffer when there is output. (gdb-assembler-custom): Try to get line marker (arrow) to display in window. Correct parsing for OS dependent output syntax of Gdb command, where. (gdb-frame-handler): Correct parsing for OS dependent output syntax of Gdb command, frame. (gdb-invalidate-assembler): Update assembler buffer correctly when frame changes (revisited).
author Nick Roberts <nickrob@snap.net.nz>
date Sat, 17 May 2003 10:17:57 +0000
parents 8a38e6c7aa44
children 3b5b1167fdf4
comparison
equal deleted inserted replaced
51027:08b938c3a5fc 51028:323ddc93f3fe
56 (defcustom gdb-window-width 30 56 (defcustom gdb-window-width 30
57 "Width of a frame for a displayed expression in GDB-UI." 57 "Width of a frame for a displayed expression in GDB-UI."
58 :type 'integer 58 :type 'integer
59 :group 'gud) 59 :group 'gud)
60 60
61 (defvar gdb-main-or-pc nil "Initialisation for Assembler buffer.") 61 (defvar gdb-current-address nil "Initialisation for Assembler buffer.")
62 (defvar gdb-current-address nil) 62 (defvar gdb-previous-address nil)
63 (defvar gdb-display-in-progress nil) 63 (defvar gdb-display-in-progress nil)
64 (defvar gdb-dive nil) 64 (defvar gdb-dive nil)
65 (defvar gdb-buffer-type nil) 65 (defvar gdb-buffer-type nil)
66 (defvar gdb-variables '() 66 (defvar gdb-variables '()
67 "A list of variables that are local to the GUD buffer.") 67 "A list of variables that are local to the GUD buffer.")
141 (beginning-of-line) 141 (beginning-of-line)
142 (forward-char 2) 142 (forward-char 2)
143 (gud-call "clear *%a" arg))) 143 (gud-call "clear *%a" arg)))
144 "\C-d" "Remove breakpoint at current line or address.") 144 "\C-d" "Remove breakpoint at current line or address.")
145 ;; 145 ;;
146 (gud-def gud-until (if (not (string-equal mode-name "Assembler"))
147 (gud-call "until %f:%l" arg)
148 (save-excursion
149 (beginning-of-line)
150 (forward-char 2)
151 (gud-call "until *%a" arg)))
152 "\C-u" "Continue up to current line or address.")
153
146 (setq comint-input-sender 'gdb-send) 154 (setq comint-input-sender 'gdb-send)
147 ;; 155 ;;
148 ;; (re-)initialise 156 ;; (re-)initialise
149 (setq gdb-main-or-pc "main") 157 (setq gdb-current-address "main")
150 (setq gdb-current-address nil) 158 (setq gdb-previous-address nil)
151 (setq gdb-display-in-progress nil) 159 (setq gdb-display-in-progress nil)
152 (setq gdb-dive nil) 160 (setq gdb-dive nil)
153 ;; 161 ;;
154 (mapc 'make-local-variable gdb-variables) 162 (mapc 'make-local-variable gdb-variables)
155 (setq gdb-buffer-type 'gdba) 163 (setq gdb-buffer-type 'gdba)
506 "Default command to execute an executable under the GDB-UI debugger." 514 "Default command to execute an executable under the GDB-UI debugger."
507 :type 'string 515 :type 'string
508 :group 'gud) 516 :group 'gud)
509 517
510 (defvar gdb-annotation-rules 518 (defvar gdb-annotation-rules
511 '(("frames-invalid" gdb-invalidate-frame-and-assembler) 519 '(("pre-prompt" gdb-pre-prompt)
512 ("breakpoints-invalid" gdb-invalidate-breakpoints-and-assembler)
513 ("pre-prompt" gdb-pre-prompt)
514 ("prompt" gdb-prompt) 520 ("prompt" gdb-prompt)
515 ("commands" gdb-subprompt) 521 ("commands" gdb-subprompt)
516 ("overload-choice" gdb-subprompt) 522 ("overload-choice" gdb-subprompt)
517 ("query" gdb-subprompt) 523 ("query" gdb-subprompt)
518 ("prompt-for-continue" gdb-subprompt) 524 ("prompt-for-continue" gdb-subprompt)
522 ("exited" gdb-stopping) 528 ("exited" gdb-stopping)
523 ("signalled" gdb-stopping) 529 ("signalled" gdb-stopping)
524 ("signal" gdb-stopping) 530 ("signal" gdb-stopping)
525 ("breakpoint" gdb-stopping) 531 ("breakpoint" gdb-stopping)
526 ("watchpoint" gdb-stopping) 532 ("watchpoint" gdb-stopping)
527 ; ("frame-begin" gdb-frame-begin) 533 ("frame-begin" gdb-frame-begin)
528 ("stopped" gdb-stopped) 534 ("stopped" gdb-stopped)
529 ("display-begin" gdb-display-begin) 535 ("display-begin" gdb-display-begin)
530 ("display-end" gdb-display-end) 536 ("display-end" gdb-display-end)
531 ; GDB commands info stack, info locals and frame generate an error-begin 537 ; GDB commands info stack, info locals and frame generate an error-begin
532 ; annotation at start when there is no stack but this is a quirk/bug in 538 ; annotation at start when there is no stack but this is a quirk/bug in
553 (setq gud-last-frame 559 (setq gud-last-frame
554 (cons 560 (cons
555 (match-string 1 args) 561 (match-string 1 args)
556 (string-to-int (match-string 2 args)))) 562 (string-to-int (match-string 2 args))))
557 (setq gdb-current-address (match-string 3 args)) 563 (setq gdb-current-address (match-string 3 args))
558 (setq gdb-main-or-pc gdb-current-address)
559 ;;update with new frame for machine code if necessary 564 ;;update with new frame for machine code if necessary
560 (gdb-invalidate-assembler)) 565 (gdb-invalidate-assembler))
561 566
562 (defun gdb-send-item (item) 567 (defun gdb-send-item (item)
563 (gdb-set-current-item item) 568 (gdb-set-current-item item)
661 "An annotation handler for `post-prompt'. This begins the collection of 666 "An annotation handler for `post-prompt'. This begins the collection of
662 output from the current command if that happens to be appropriate." 667 output from the current command if that happens to be appropriate."
663 (if (not (gdb-get-pending-triggers)) 668 (if (not (gdb-get-pending-triggers))
664 (progn 669 (progn
665 (gdb-get-current-frame) 670 (gdb-get-current-frame)
666 (gdb-invalidate-registers ignored) 671 (gdb-invalidate-frames)
667 (gdb-invalidate-locals ignored) 672 (gdb-invalidate-breakpoints)
668 (gdb-invalidate-display ignored) 673 (gdb-invalidate-assembler)
674 (gdb-invalidate-registers)
675 (gdb-invalidate-locals)
676 (gdb-invalidate-display)
669 (gdb-invalidate-threads))) 677 (gdb-invalidate-threads)))
670 (let ((sink (gdb-get-output-sink))) 678 (let ((sink (gdb-get-output-sink)))
671 (cond 679 (cond
672 ((eq sink 'user) t) 680 ((eq sink 'user) t)
673 ((eq sink 'pre-emacs) 681 ((eq sink 'pre-emacs)
1158 (set-buffer 1166 (set-buffer
1159 (gdb-get-create-buffer 'gdb-inferior-io)) 1167 (gdb-get-create-buffer 'gdb-inferior-io))
1160 (goto-char (point-max)) 1168 (goto-char (point-max))
1161 (insert-before-markers string)) 1169 (insert-before-markers string))
1162 (if (not (string-equal string "")) 1170 (if (not (string-equal string ""))
1163 (gdb-display-buffer 1171 (select-window
1164 (gdb-get-create-buffer 'gdb-inferior-io)))) 1172 (gdb-display-buffer (gdb-get-create-buffer 'gdb-inferior-io)))))
1165 1173
1166 (defun gdb-clear-inferior-io () 1174 (defun gdb-clear-inferior-io ()
1167 (save-excursion 1175 (save-excursion
1168 (set-buffer 1176 (set-buffer
1169 (gdb-get-create-buffer 'gdb-inferior-io)) 1177 (gdb-get-create-buffer 'gdb-inferior-io))
1349 (goto-char (point-min)) 1357 (goto-char (point-min))
1350 (while (< (point) (- (point-max) 1)) 1358 (while (< (point) (- (point-max) 1))
1351 (forward-line 1) 1359 (forward-line 1)
1352 (if (looking-at "[^\t].*breakpoint") 1360 (if (looking-at "[^\t].*breakpoint")
1353 (progn 1361 (progn
1354 (looking-at "\\([0-9]*\\)\\s-*\\S-*\\s-*\\S-*\\s-*\\(.\\)") 1362 (looking-at "[0-9]*\\s-*\\S-*\\s-*\\S-*\\s-*\\(.\\)")
1355 (setq flag (char-after (match-beginning 2))) 1363 (setq flag (char-after (match-beginning 1)))
1356 (beginning-of-line) 1364 (beginning-of-line)
1357 (if (re-search-forward "in\\s-+\\S-+\\s-+at\\s-+" nil t) 1365 (if (re-search-forward "in\\s-+\\S-+\\s-+at\\s-+" nil t)
1358 (progn 1366 (progn
1359 (looking-at "\\(\\S-*\\):\\([0-9]+\\)") 1367 (looking-at "\\(\\S-*\\):\\([0-9]+\\)")
1360 (let ((line (match-string 2)) (buffer-read-only nil) 1368 (let ((line (match-string 2)) (buffer-read-only nil)
1510 gdb-info-frames-custom) 1518 gdb-info-frames-custom)
1511 1519
1512 (defun gdb-info-frames-custom () 1520 (defun gdb-info-frames-custom ()
1513 (save-excursion 1521 (save-excursion
1514 (set-buffer (gdb-get-buffer 'gdb-stack-buffer)) 1522 (set-buffer (gdb-get-buffer 'gdb-stack-buffer))
1515 (let ((buffer-read-only nil)) 1523 (save-excursion
1516 (goto-char (point-min)) 1524 (let ((buffer-read-only nil))
1517 (while (< (point) (point-max)) 1525 (goto-char (point-min))
1518 (put-text-property (progn (beginning-of-line) (point)) 1526 (while (< (point) (point-max))
1519 (progn (end-of-line) (point)) 1527 (put-text-property (progn (beginning-of-line) (point))
1520 'mouse-face 'highlight) 1528 (progn (end-of-line) (point))
1521 (forward-line 1))))) 1529 'mouse-face 'highlight)
1530 (beginning-of-line)
1531 (if (or (looking-at "^#[0-9]*\\s-*\\S-* in \\(\\S-*\\)")
1532 (looking-at "^#[0-9]*\\s-*\\(\\S-*\\)"))
1533 (if (equal (match-string 1) gdb-current-frame)
1534 (put-text-property (progn (beginning-of-line) (point))
1535 (progn (end-of-line) (point))
1536 'face
1537 `(:background ,(face-attribute 'default :foreground)
1538 :foreground ,(face-attribute 'default :background)))))
1539 (forward-line 1))))))
1522 1540
1523 (defun gdb-stack-buffer-name () 1541 (defun gdb-stack-buffer-name ()
1524 (with-current-buffer gud-comint-buffer 1542 (with-current-buffer gud-comint-buffer
1525 (concat "*stack frames of " (gdb-get-target-string) "*"))) 1543 (concat "*stack frames of " (gdb-get-target-string) "*")))
1526 1544
1547 \\{gdb-frames-mode-map}" 1565 \\{gdb-frames-mode-map}"
1548 (setq major-mode 'gdb-frames-mode) 1566 (setq major-mode 'gdb-frames-mode)
1549 (setq mode-name "Frames") 1567 (setq mode-name "Frames")
1550 (setq buffer-read-only t) 1568 (setq buffer-read-only t)
1551 (use-local-map gdb-frames-mode-map) 1569 (use-local-map gdb-frames-mode-map)
1570 (font-lock-mode -1)
1552 (gdb-invalidate-frames)) 1571 (gdb-invalidate-frames))
1553 1572
1554 (defun gdb-get-frame-number () 1573 (defun gdb-get-frame-number ()
1555 (save-excursion 1574 (save-excursion
1556 (let* ((pos (re-search-backward "^#\\([0-9]*\\)" nil t)) 1575 (let* ((pos (re-search-backward "^#\\([0-9]*\\)" nil t))
2212 'gdb-assembler-buffer-name 2231 'gdb-assembler-buffer-name
2213 'gdb-assembler-mode) 2232 'gdb-assembler-mode)
2214 2233
2215 (def-gdb-auto-updated-buffer gdb-assembler-buffer 2234 (def-gdb-auto-updated-buffer gdb-assembler-buffer
2216 gdb-invalidate-assembler 2235 gdb-invalidate-assembler
2217 (concat "server disassemble " gdb-main-or-pc "\n") 2236 (concat "server disassemble " gdb-current-address "\n")
2218 gdb-assembler-handler 2237 gdb-assembler-handler
2219 gdb-assembler-custom) 2238 gdb-assembler-custom)
2220 2239
2221 (defun gdb-assembler-custom () 2240 (defun gdb-assembler-custom ()
2222 (let ((buffer (gdb-get-buffer 'gdb-assembler-buffer)) 2241 (let ((buffer (gdb-get-buffer 'gdb-assembler-buffer))
2223 (gdb-arrow-position) (address) (flag)) 2242 (address) (flag))
2224 (if gdb-current-address 2243 (save-excursion
2225 (progn 2244 (set-buffer buffer)
2226 (save-excursion 2245 (if (not (equal gdb-current-address "main"))
2227 (set-buffer buffer) 2246 (progn
2228 (remove-arrow) 2247 (remove-arrow)
2229 (goto-char (point-min)) 2248 (goto-char (point-min))
2230 (re-search-forward gdb-current-address) 2249 (if (re-search-forward gdb-current-address nil t)
2231 (setq gdb-arrow-position (point)) 2250 (progn
2232 (put-arrow "=>" gdb-arrow-position nil 'left-margin)))) 2251 (put-arrow "=>" (point) nil 'left-margin)
2233 ;; remove all breakpoint-icons in assembler buffer before updating. 2252 (set-window-point gdb-source-window (point))))))
2234 (save-excursion 2253 ;; remove all breakpoint-icons in assembler buffer before updating.
2235 (set-buffer buffer) 2254 (save-excursion
2236 (if (display-graphic-p) 2255 (if (display-graphic-p)
2237 (remove-images (point-min) (point-max)) 2256 (remove-images (point-min) (point-max))
2238 (remove-strings (point-min) (point-max)))) 2257 (remove-strings (point-min) (point-max))))
2239 (save-excursion
2240 (set-buffer (gdb-get-buffer 'gdb-breakpoints-buffer)) 2258 (set-buffer (gdb-get-buffer 'gdb-breakpoints-buffer))
2241 (goto-char (point-min)) 2259 (goto-char (point-min))
2242 (while (< (point) (- (point-max) 1)) 2260 (while (< (point) (- (point-max) 1))
2243 (forward-line 1) 2261 (forward-line 1)
2244 (if (looking-at "[^\t].*breakpoint") 2262 (if (looking-at "[^\t].*breakpoint")
2245 (progn 2263 (progn
2246 (looking-at 2264 (looking-at
2247 "\\([0-9]*\\)\\s-*\\S-*\\s-*\\S-*\\s-*\\(.\\)\\s-*0x0\\(\\S-*\\)") 2265 "[0-9]*\\s-*\\S-*\\s-*\\S-*\\s-*\\(.\\)\\s-*0x\\(\\S-*\\)")
2248 ;; info break gives '0x0' (8 digit) while dump gives '0x' (7 digit) 2266 (setq flag (char-after (match-beginning 1)))
2249 (setq address (concat "0x" (match-string 3))) 2267 (let ((number (match-string 2)))
2250 (setq flag (char-after (match-beginning 2))) 2268 ;; remove leading 0s from output of info break.
2269 (if (string-match "0x0+\\(.*\\)" number)
2270 (setq address (concat "0x" (match-string 1 address)))
2271 (setq address number)))
2251 (save-excursion 2272 (save-excursion
2252 (set-buffer buffer) 2273 (set-buffer buffer)
2253 (goto-char (point-min)) 2274 (save-excursion
2254 (if (re-search-forward address nil t) 2275 (goto-char (point-min))
2255 (let ((start (progn (beginning-of-line) (- (point) 1))) 2276 (if (re-search-forward address nil t)
2256 (end (progn (end-of-line) (+ (point) 1)))) 2277 (let ((start (progn (beginning-of-line) (- (point) 1)))
2257 (if (display-graphic-p) 2278 (end (progn (end-of-line) (+ (point) 1))))
2258 (progn 2279 (if (display-graphic-p)
2259 (remove-images start end) 2280 (progn
2260 (if (eq ?y flag) 2281 (remove-images start end)
2261 (put-image breakpoint-enabled-icon (point) 2282 (if (eq ?y flag)
2262 "breakpoint icon enabled" 2283 (put-image breakpoint-enabled-icon (point)
2263 'left-margin) 2284 "breakpoint icon enabled"
2264 (put-image breakpoint-disabled-icon (point) 2285 'left-margin)
2265 "breakpoint icon disabled" 2286 (put-image breakpoint-disabled-icon (point)
2266 'left-margin))) 2287 "breakpoint icon disabled"
2267 (remove-strings start end) 2288 'left-margin)))
2268 (if (eq ?y flag) 2289 (remove-strings start end)
2269 (put-string "B" (point) "enabled" 'left-margin) 2290 (if (eq ?y flag)
2270 (put-string "b" (point) "disabled" 2291 (put-string "B" (point) "enabled" 'left-margin)
2271 'left-margin)))))))))) 2292 (put-string "b" (point) "disabled"
2272 (if gdb-current-address 2293 'left-margin)))))))))))))
2273 (set-window-point (get-buffer-window buffer) gdb-arrow-position))))
2274 2294
2275 (defvar gdb-assembler-mode-map 2295 (defvar gdb-assembler-mode-map
2276 (let ((map (make-sparse-keymap))) 2296 (let ((map (make-sparse-keymap)))
2277 (suppress-keymap map) 2297 (suppress-keymap map)
2278 map)) 2298 map))
2301 (defun gdb-frame-assembler-buffer () 2321 (defun gdb-frame-assembler-buffer ()
2302 (interactive) 2322 (interactive)
2303 (switch-to-buffer-other-frame 2323 (switch-to-buffer-other-frame
2304 (gdb-get-create-buffer 'gdb-assembler-buffer))) 2324 (gdb-get-create-buffer 'gdb-assembler-buffer)))
2305 2325
2306 (defun gdb-invalidate-frame-and-assembler (&optional ignored) 2326 ;; modified because if gdb-current-address has changed value a new command
2307 (gdb-invalidate-frames)
2308 (gdb-invalidate-assembler))
2309
2310 (defun gdb-invalidate-breakpoints-and-assembler (&optional ignored)
2311 (gdb-invalidate-breakpoints)
2312 (gdb-invalidate-assembler))
2313
2314 (defvar gdb-prev-main-or-pc nil)
2315
2316 ;; modified because if gdb-main-or-pc has changed value a new command
2317 ;; must be enqueued to update the buffer with the new output 2327 ;; must be enqueued to update the buffer with the new output
2318 (defun gdb-invalidate-assembler (&optional ignored) 2328 (defun gdb-invalidate-assembler (&optional ignored)
2319 (if (and (gdb-get-buffer 'gdb-assembler-buffer) 2329 (if (and (gdb-get-buffer 'gdb-assembler-buffer)
2320 (or (not (member 'gdb-invalidate-assembler 2330 (or (not (member 'gdb-invalidate-assembler
2321 (gdb-get-pending-triggers))) 2331 (gdb-get-pending-triggers)))
2322 (not (string-equal gdb-main-or-pc gdb-prev-main-or-pc)))) 2332 (not (string-equal gdb-current-address gdb-previous-address))))
2323 (progn 2333 (progn
2324 ;; take previous disassemble command off the queue 2334 ;; take previous disassemble command off the queue
2325 (save-excursion 2335 (save-excursion
2326 (set-buffer gud-comint-buffer) 2336 (set-buffer gud-comint-buffer)
2327 (let ((queue gdb-idle-input-queue) (item)) 2337 (let ((queue (gdb-get-idle-input-queue)) (item))
2328 (dolist (item queue) 2338 (dolist (item queue)
2329 (setq item (car queue))
2330 (if (equal (cdr item) '(gdb-assembler-handler)) 2339 (if (equal (cdr item) '(gdb-assembler-handler))
2331 (setq gdb-idle-input-queue 2340 (gdb-set-idle-input-queue
2332 (delete item gdb-idle-input-queue)))))) 2341 (delete item (gdb-get-idle-input-queue)))))))
2333 (gdb-enqueue-idle-input 2342 (gdb-enqueue-idle-input
2334 (list (concat "server disassemble " gdb-main-or-pc "\n") 2343 (list (concat "server disassemble " gdb-current-address "\n")
2335 'gdb-assembler-handler)) 2344 'gdb-assembler-handler))
2336 (gdb-set-pending-triggers 2345 (gdb-set-pending-triggers
2337 (cons 'gdb-invalidate-assembler 2346 (cons 'gdb-invalidate-assembler
2338 (gdb-get-pending-triggers))) 2347 (gdb-get-pending-triggers)))
2339 (setq gdb-prev-main-or-pc gdb-main-or-pc)))) 2348 (setq gdb-previous-address gdb-current-address))))
2340 2349
2341 (defun gdb-get-current-frame () 2350 (defun gdb-get-current-frame ()
2342 (if (not (member 'gdb-get-current-frame (gdb-get-pending-triggers))) 2351 (if (not (member 'gdb-get-current-frame (gdb-get-pending-triggers)))
2343 (progn 2352 (progn
2344 (gdb-enqueue-idle-input 2353 (gdb-enqueue-idle-input
2351 (gdb-set-pending-triggers 2360 (gdb-set-pending-triggers
2352 (delq 'gdb-get-current-frame (gdb-get-pending-triggers))) 2361 (delq 'gdb-get-current-frame (gdb-get-pending-triggers)))
2353 (save-excursion 2362 (save-excursion
2354 (set-buffer (gdb-get-create-buffer 'gdb-partial-output-buffer)) 2363 (set-buffer (gdb-get-create-buffer 'gdb-partial-output-buffer))
2355 (goto-char (point-min)) 2364 (goto-char (point-min))
2356 (if (looking-at "^#[0-9]*\\s-*0x\\S-* in \\(\\S-*\\)") 2365 (if (looking-at "^#[0-9]*\\s-*\\(\\S-*\\) in \\(\\S-*\\)")
2357 (setq gdb-current-frame (match-string 1)) 2366 (progn
2367 (setq gdb-current-frame (match-string 2))
2368 (let ((address (match-string 1)))
2369 ;; remove leading 0s from output of frame command.
2370 (if (string-match "0x0+\\(.*\\)" address)
2371 (setq gdb-current-address (concat "0x" (match-string 1 address)))
2372 (setq gdb-current-address address)))
2373 (if (not (looking-at ".*) at "))
2374 (progn
2375 (set-window-buffer gdb-source-window
2376 (gdb-get-create-buffer 'gdb-assembler-buffer))
2377 (gdb-invalidate-assembler))))
2358 (if (looking-at "^#[0-9]*\\s-*\\(\\S-*\\)") 2378 (if (looking-at "^#[0-9]*\\s-*\\(\\S-*\\)")
2359 (setq gdb-current-frame (match-string 1)))))) 2379 (setq gdb-current-frame (match-string 1))))))
2360 2380
2361 (provide 'gdb-ui) 2381 (provide 'gdb-ui)
2362 2382