comparison lisp/gdb-ui.el @ 51529:39126c23006f

(gdb-get-current-frame, gdb-frame-handler): Use Gdb command `info frame' instead of `frame' to preserve point. (gdb-invalidate-assembler): Only run disassemble again if frame has changed. (gdb-append-to-inferior-io): Revert change from 2003-05-17.
author Nick Roberts <nickrob@snap.net.nz>
date Sun, 08 Jun 2003 01:20:51 +0000
parents a1e2454a02ec
children cef03ad7bf21
comparison
equal deleted inserted replaced
51528:611abdca734b 51529:39126c23006f
29 ;; GDB through the GUD buffer in the usual way, but there are also further 29 ;; GDB through the GUD buffer in the usual way, but there are also further
30 ;; buffers which control the execution and describe the state of your program. 30 ;; buffers which control the execution and describe the state of your program.
31 ;; It separates the input/output of your program from that of GDB and displays 31 ;; It separates the input/output of your program from that of GDB and displays
32 ;; expressions and their current values in their own buffers. It also uses 32 ;; expressions and their current values in their own buffers. It also uses
33 ;; features of Emacs 21 such as the display margin for breakpoints, and the 33 ;; features of Emacs 21 such as the display margin for breakpoints, and the
34 ;; toolbar (see the GDB User Interface section in the Emacs info manual). 34 ;; toolbar (see the GDB Graphical Interface section in the Emacs info manual).
35 35
36 ;; Start the debugger with M-x gdba. 36 ;; Start the debugger with M-x gdba.
37 37
38 ;; This file is based on gdba.el from GDB 5.0 written by Tom Lord and Jim 38 ;; This file is based on gdba.el from GDB 5.0 written by Tom Lord and Jim
39 ;; Kingdon and uses GDB's annotation interface. You don't need to know about 39 ;; Kingdon and uses GDB's annotation interface. You don't need to know about
60 :type 'integer 60 :type 'integer
61 :group 'gud) 61 :group 'gud)
62 62
63 (defvar gdb-current-address nil "Initialisation for Assembler buffer.") 63 (defvar gdb-current-address nil "Initialisation for Assembler buffer.")
64 (defvar gdb-previous-address nil) 64 (defvar gdb-previous-address nil)
65 (defvar gdb-previous-frame nil)
65 (defvar gdb-display-in-progress nil) 66 (defvar gdb-display-in-progress nil)
66 (defvar gdb-dive nil) 67 (defvar gdb-dive nil)
67 (defvar gdb-view-source t "Non-nil means that source code can be viewed") 68 (defvar gdb-view-source t "Non-nil means that source code can be viewed")
68 (defvar gdb-selected-view 'source "Code type that user wishes to view") 69 (defvar gdb-selected-view 'source "Code type that user wishes to view")
69 (defvar gdb-buffer-type nil) 70 (defvar gdb-buffer-type nil)
158 (setq comint-input-sender 'gdb-send) 159 (setq comint-input-sender 'gdb-send)
159 ;; 160 ;;
160 ;; (re-)initialise 161 ;; (re-)initialise
161 (setq gdb-current-address "main") 162 (setq gdb-current-address "main")
162 (setq gdb-previous-address nil) 163 (setq gdb-previous-address nil)
164 (setq gdb-previous-frame nil)
163 (setq gdb-display-in-progress nil) 165 (setq gdb-display-in-progress nil)
164 (setq gdb-dive nil) 166 (setq gdb-dive nil)
165 (setq gdb-view-source t) 167 (setq gdb-view-source t)
166 (setq gdb-selected-view 'source) 168 (setq gdb-selected-view 'source)
167 ;; 169 ;;
1160 (defun gdb-append-to-inferior-io (string) 1162 (defun gdb-append-to-inferior-io (string)
1161 (with-current-buffer (gdb-get-create-buffer 'gdb-inferior-io) 1163 (with-current-buffer (gdb-get-create-buffer 'gdb-inferior-io)
1162 (goto-char (point-max)) 1164 (goto-char (point-max))
1163 (insert-before-markers string)) 1165 (insert-before-markers string))
1164 (if (not (string-equal string "")) 1166 (if (not (string-equal string ""))
1165 (select-window 1167 (gdb-display-buffer (gdb-get-create-buffer 'gdb-inferior-io))))
1166 (gdb-display-buffer (gdb-get-create-buffer 'gdb-inferior-io)))))
1167 1168
1168 (defun gdb-clear-inferior-io () 1169 (defun gdb-clear-inferior-io ()
1169 (with-current-buffer (gdb-get-create-buffer 'gdb-inferior-io) 1170 (with-current-buffer (gdb-get-create-buffer 'gdb-inferior-io)
1170 (delete-region (point-min) (point-max)))) 1171 (delete-region (point-min) (point-max))))
1171 1172
2314 (looking-at 2315 (looking-at
2315 "[0-9]*\\s-*\\S-*\\s-*\\S-*\\s-*\\(.\\)\\s-*0x\\(\\S-*\\)") 2316 "[0-9]*\\s-*\\S-*\\s-*\\S-*\\s-*\\(.\\)\\s-*0x\\(\\S-*\\)")
2316 (setq flag (char-after (match-beginning 1))) 2317 (setq flag (char-after (match-beginning 1)))
2317 (setq address (match-string 2)) 2318 (setq address (match-string 2))
2318 ;; remove leading 0s from output of info break. 2319 ;; remove leading 0s from output of info break.
2319 (if (string-match "0+\\(.*\\)" address) 2320 (if (string-match "^0+\\(.*\\)" address)
2320 (setq address (match-string 1 address))) 2321 (setq address (match-string 1 address)))
2321 (with-current-buffer buffer 2322 (with-current-buffer buffer
2322 (goto-char (point-min)) 2323 (goto-char (point-min))
2323 (if (re-search-forward address nil t) 2324 (if (re-search-forward address nil t)
2324 (let ((start (progn (beginning-of-line) (- (point) 1))) 2325 (let ((start (progn (beginning-of-line) (- (point) 1)))
2373 (gdb-get-create-buffer 'gdb-assembler-buffer))) 2374 (gdb-get-create-buffer 'gdb-assembler-buffer)))
2374 2375
2375 ;; modified because if gdb-current-address has changed value a new command 2376 ;; modified because if gdb-current-address has changed value a new command
2376 ;; must be enqueued to update the buffer with the new output 2377 ;; must be enqueued to update the buffer with the new output
2377 (defun gdb-invalidate-assembler (&optional ignored) 2378 (defun gdb-invalidate-assembler (&optional ignored)
2378 (if (and (gdb-get-buffer 'gdb-assembler-buffer) 2379 (if (gdb-get-buffer 'gdb-assembler-buffer)
2379 (or (not (member 'gdb-invalidate-assembler
2380 (gdb-get-pending-triggers)))
2381 (not (string-equal gdb-current-address gdb-previous-address))))
2382 (progn 2380 (progn
2383 ;; take previous disassemble command off the queue 2381 (if (string-equal gdb-current-frame gdb-previous-frame)
2384 (with-current-buffer gud-comint-buffer 2382 (gdb-assembler-custom)
2385 (let ((queue (gdb-get-idle-input-queue)) (item)) 2383 (if (or (not (member 'gdb-invalidate-assembler
2386 (dolist (item queue) 2384 (gdb-get-pending-triggers)))
2387 (if (equal (cdr item) '(gdb-assembler-handler)) 2385 (not (string-equal gdb-current-address
2388 (gdb-set-idle-input-queue 2386 gdb-previous-address)))
2389 (delete item (gdb-get-idle-input-queue))))))) 2387 (progn
2390 (gdb-enqueue-idle-input 2388 ;; take previous disassemble command off the queue
2391 (list (concat "server disassemble " gdb-current-address "\n") 2389 (with-current-buffer gud-comint-buffer
2392 'gdb-assembler-handler)) 2390 (let ((queue (gdb-get-idle-input-queue)) (item))
2393 (gdb-set-pending-triggers 2391 (dolist (item queue)
2394 (cons 'gdb-invalidate-assembler 2392 (if (equal (cdr item) '(gdb-assembler-handler))
2395 (gdb-get-pending-triggers))) 2393 (gdb-set-idle-input-queue
2396 (setq gdb-previous-address gdb-current-address)))) 2394 (delete item (gdb-get-idle-input-queue)))))))
2395 (gdb-enqueue-idle-input
2396 (list (concat "server disassemble " gdb-current-address "\n")
2397 'gdb-assembler-handler))
2398 (gdb-set-pending-triggers
2399 (cons 'gdb-invalidate-assembler
2400 (gdb-get-pending-triggers)))
2401 (setq gdb-previous-address gdb-current-address)
2402 (setq gdb-previous-frame gdb-current-frame)))))))
2397 2403
2398 (defun gdb-get-current-frame () 2404 (defun gdb-get-current-frame ()
2399 (if (not (member 'gdb-get-current-frame (gdb-get-pending-triggers))) 2405 (if (not (member 'gdb-get-current-frame (gdb-get-pending-triggers)))
2400 (progn 2406 (progn
2401 (gdb-enqueue-idle-input 2407 (gdb-enqueue-idle-input
2402 (list (concat "server frame\n") 'gdb-frame-handler)) 2408 (list (concat "server info frame\n") 'gdb-frame-handler))
2403 (gdb-set-pending-triggers 2409 (gdb-set-pending-triggers
2404 (cons 'gdb-get-current-frame 2410 (cons 'gdb-get-current-frame
2405 (gdb-get-pending-triggers)))))) 2411 (gdb-get-pending-triggers))))))
2406 2412
2407 (defun gdb-frame-handler () 2413 (defun gdb-frame-handler ()
2408 (gdb-set-pending-triggers 2414 (gdb-set-pending-triggers
2409 (delq 'gdb-get-current-frame (gdb-get-pending-triggers))) 2415 (delq 'gdb-get-current-frame (gdb-get-pending-triggers)))
2410 (with-current-buffer (gdb-get-create-buffer 'gdb-partial-output-buffer) 2416 (with-current-buffer (gdb-get-create-buffer 'gdb-partial-output-buffer)
2411 (goto-char (point-min)) 2417 (goto-char (point-min))
2412 (if (looking-at "^#[0-9]*\\s-*\\(\\S-*\\) in \\(\\S-*\\)") 2418 (forward-line)
2419 (if (looking-at ".*= 0x\\(\\S-*\\) in \\(\\S-*\\)")
2413 (progn 2420 (progn
2414 (setq gdb-current-frame (match-string 2)) 2421 (setq gdb-current-frame (match-string 2))
2415 (let ((address (match-string 1))) 2422 (let ((address (match-string 1)))
2416 ;; remove leading 0s from output of frame command. 2423 ;; remove leading 0s from output of info frame command.
2417 (if (string-match "0x0+\\(.*\\)" address) 2424 (if (string-match "^0+\\(.*\\)" address)
2418 (setq gdb-current-address 2425 (setq gdb-current-address
2419 (concat "0x" (match-string 1 address))) 2426 (concat "0x" (match-string 1 address)))
2420 (setq gdb-current-address address))) 2427 (setq gdb-current-address (concat "0x" address))))
2421 (if (or (if (not (looking-at ".*) at ")) 2428 (if (or (if (not (looking-at ".*(\\S-*:[0-9]*)"))
2422 (progn (setq gdb-view-source nil) t)) 2429 (progn (setq gdb-view-source nil) t))
2423 (eq gdb-selected-view 'assembler)) 2430 (eq gdb-selected-view 'assembler))
2424 (progn 2431 (progn
2425 (set-window-buffer 2432 (set-window-buffer
2426 gdb-source-window 2433 gdb-source-window
2427 (gdb-get-create-buffer 'gdb-assembler-buffer)) 2434 (gdb-get-create-buffer 'gdb-assembler-buffer))
2428 (gdb-invalidate-assembler)))) 2435 (gdb-invalidate-assembler)))))))
2429 (if (looking-at "^#0\\s-*\\(\\S-*\\)")
2430 (setq gdb-current-frame (match-string 1))))))
2431 2436
2432 (provide 'gdb-ui) 2437 (provide 'gdb-ui)
2433 2438
2434 ;;; gdb-ui.el ends here 2439 ;;; gdb-ui.el ends here