Mercurial > emacs
diff lisp/progmodes/gdb-mi.el @ 104233:fbce43fef5e3
(gdb-line-posns): New helper which helps not to use `goto-line'.
(gdb-place-breakpoints, gdb-get-location): Rewritten without
`goto-line'.
(gdb-invalidate-disassembly): Do not refresh upon receiving
'update signal. Instead, update all disassembly buffers only after
threads list.
author | Dmitry Dzhus <dima@sphinx.net.ru> |
---|---|
date | Tue, 11 Aug 2009 13:53:10 +0000 |
parents | 23230e6cbc19 |
children | e2940cb3d84e |
line wrap: on
line diff
--- a/lisp/progmodes/gdb-mi.el Tue Aug 11 10:48:56 2009 +0000 +++ b/lisp/progmodes/gdb-mi.el Tue Aug 11 13:53:10 2009 +0000 @@ -1282,7 +1282,7 @@ (gdb-add-subscriber gdb-buf-publisher (cons (current-buffer) (gdb-bind-function-to-buffer trigger (current-buffer)))) - (funcall trigger 'update)) + (funcall trigger 'start)) (current-buffer)))))) (defun gdb-bind-function-to-buffer (expr buffer) @@ -2068,6 +2068,13 @@ (with-current-buffer (gdb-get-buffer-create 'gdb-partial-output-buffer) (gdb-json-read-buffer fix-key fix-list))) +(defun gdb-line-posns (line) + "Return a pair of LINE beginning and end positions." + (let ((offset (1+ (- line (line-number-at-pos))))) + (cons + (line-beginning-position offset) + (line-end-position offset)))) + (defmacro gdb-mark-line (line variable) "Set VARIABLE marker to point at beginning of LINE. @@ -2075,9 +2082,9 @@ Return position where LINE begins." `(save-excursion - (let* ((offset (1+ (- ,line (line-number-at-pos)))) - (start-posn (line-beginning-position offset)) - (end-posn (line-end-position offset))) + (let* ((posns (gdb-line-posns ,line)) + (start-posn (car posns)) + (end-posn (cdr posns))) (set-marker ,variable (copy-marker start-posn)) (when (not (> (car (window-fringes)) 0)) (put-text-property start-posn end-posn @@ -2233,7 +2240,7 @@ (def-gdb-trigger-and-handler gdb-invalidate-breakpoints "-break-list" gdb-breakpoints-list-handler gdb-breakpoints-list-handler-custom - '(update)) + '(start update)) (gdb-set-buffer-rules 'gdb-breakpoints-buffer @@ -2303,9 +2310,8 @@ (find-file-noselect file 'nowarn) (gdb-init-buffer) ;; Only want one breakpoint icon at each location. - (save-excursion - (goto-line (string-to-number line)) - (gdb-put-breakpoint-icon (string-equal flag "y") bptno))) + (gdb-put-breakpoint-icon (string-equal flag "y") bptno + (string-to-number line))) (gdb-input (list (concat "list " file ":1") 'ignore)) @@ -2333,9 +2339,7 @@ (with-current-buffer (find-file-noselect (match-string 1)) (gdb-init-buffer) ;; only want one breakpoint icon at each location - (save-excursion - (goto-line (string-to-number line)) - (gdb-put-breakpoint-icon (eq flag ?y) bptno))))) + (gdb-put-breakpoint-icon (eq flag ?y) bptno (string-to-number line))))) (add-hook 'find-file-hook 'gdb-find-file-hook) @@ -2501,7 +2505,7 @@ (def-gdb-trigger-and-handler gdb-invalidate-threads (gdb-current-context-command "-thread-info" gud-running) gdb-thread-list-handler gdb-thread-list-handler-custom - '(update update-threads)) + '(start update update-threads)) (gdb-set-buffer-rules 'gdb-threads-buffer @@ -2763,7 +2767,7 @@ gdb-memory-columns) gdb-read-memory-handler gdb-read-memory-custom - '(update)) + '(start update)) (gdb-set-buffer-rules 'gdb-memory-buffer @@ -3138,8 +3142,8 @@ (format "-data-disassemble -f %s -l %s -n -1 -- 0" file line))) gdb-disassembly-handler ;; We update disassembly only after we have actual frame information - ;; about all threads - '(update update-disassembly)) + ;; about all threads, so no there's `update' signal in this list + '(start update-disassembly)) (def-gdb-auto-update-handler gdb-disassembly-handler @@ -3307,7 +3311,7 @@ (def-gdb-trigger-and-handler gdb-invalidate-frames (gdb-current-context-command "-stack-list-frames") gdb-stack-list-frames-handler gdb-stack-list-frames-custom - '(update)) + '(start update)) (gdb-set-buffer-rules 'gdb-stack-buffer @@ -3417,7 +3421,7 @@ gdb-invalidate-locals (concat (gdb-current-context-command "-stack-list-locals") " --simple-values") gdb-locals-handler gdb-locals-handler-custom - '(update)) + '(start update)) (gdb-set-buffer-rules 'gdb-locals-buffer @@ -3540,7 +3544,7 @@ (concat (gdb-current-context-command "-data-list-register-values") " x") gdb-registers-handler gdb-registers-handler-custom - '(update)) + '(start update)) (gdb-set-buffer-rules 'gdb-registers-buffer @@ -4044,11 +4048,12 @@ (when (overlay-get overlay 'put-break) (delete-overlay overlay)))) -(defun gdb-put-breakpoint-icon (enabled bptno) - (let ((start (- (line-beginning-position) 1)) - (end (+ (line-end-position) 1)) - (putstring (if enabled "B" "b")) - (source-window (get-buffer-window (current-buffer) 0))) +(defun gdb-put-breakpoint-icon (enabled bptno &optional line) + (let* ((posns (gdb-line-posns (or line (line-number-at-pos)))) + (start (- (car posns) 1)) + (end (+ (cdr posns) 1)) + (putstring (if enabled "B" "b")) + (source-window (get-buffer-window (current-buffer) 0))) (add-text-properties 0 1 '(help-echo "mouse-1: clear bkpt, mouse-3: enable/disable bkpt") putstring)