emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Patch: gdba stack frame fix


From: Tom Tromey
Subject: Patch: gdba stack frame fix
Date: Tue, 09 Oct 2007 11:32:31 -0600
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.990 (gnu/linux)

I'm using gdb in "many windows" mode.

The stack in my inferior has more frames than there are lines in the
gdb stack frames window.  If I go "up" enough, the fringe bitmap
representing the current frame will simply disappear.

I think it is more useful in this case for the stack frame window to
scroll, making sure that the current frame is always visible.

This patch implements this idea.  The patch looks much bigger than it
is, because I added a new let binding and thus had to reindent most of
the function's body.

Tom

2007-10-09  Tom Tromey  <address@hidden>

        * progmodes/gdb-ui.el (gdb-info-stack-custom): Ensure current
        frame is visible.

Index: lisp/progmodes/gdb-ui.el
===================================================================
RCS file: /sources/emacs/emacs/lisp/progmodes/gdb-ui.el,v
retrieving revision 1.211
diff -u -r1.211 gdb-ui.el
--- lisp/progmodes/gdb-ui.el    9 Oct 2007 08:52:43 -0000       1.211
+++ lisp/progmodes/gdb-ui.el    9 Oct 2007 17:53:50 -0000
@@ -2120,62 +2120,72 @@
 
 (defun gdb-info-stack-custom ()
   (with-current-buffer (gdb-get-buffer 'gdb-stack-buffer)
-    (save-excursion
-      (unless (eq gdb-look-up-stack 'delete)
-       (let ((buffer-read-only nil)
-             bl el)
-         (goto-char (point-min))
-         (while (< (point) (point-max))
-           (setq bl (line-beginning-position)
-                 el (line-end-position))
-           (when (looking-at "#")
-             (add-text-properties bl el
-                                  '(mouse-face highlight
-                                    help-echo "mouse-2, RET: Select frame")))
-           (goto-char bl)
-           (when (looking-at "^#\\([0-9]+\\)")
-             (when (string-equal (match-string 1) gdb-frame-number)
-               (if (> (car (window-fringes)) 0)
-                   (progn
-                     (or gdb-stack-position
-                         (setq gdb-stack-position (make-marker)))
-                     (set-marker gdb-stack-position (point)))
-                 (put-text-property bl (+ bl 4)
-                                    'face '(:inverse-video t))))
-             (when (re-search-forward
-                    (concat
-                     (if (string-equal (match-string 1) "0") "" " in ")
-                     "\\([^ ]+\\) (") el t)
-               (put-text-property (match-beginning 1) (match-end 1)
-                                  'face font-lock-function-name-face)
-               (setq bl (match-end 0))
-               (while (re-search-forward "<\\([^>]+\\)>" el t)
-                 (put-text-property (match-beginning 1) (match-end 1)
-                                    'face font-lock-function-name-face))
-               (goto-char bl)
-               (while (re-search-forward "\\(\\(\\sw\\|[_.]\\)+\\)=" el t)
-                 (put-text-property (match-beginning 1) (match-end 1)
-                                    'face font-lock-variable-name-face))))
-           (forward-line 1))
-         (forward-line -1)
-         (when (looking-at "(More stack frames follow...)")
-           (add-text-properties (match-beginning 0) (match-end 0)
-            '(mouse-face highlight
-              gdb-max-frames t
-              help-echo
-               "mouse-2, RET: customize gdb-max-frames to see more frames")))))
-      (when gdb-look-up-stack
+    (let (move-to)
+      (save-excursion
+       (unless (eq gdb-look-up-stack 'delete)
+         (let ((buffer-read-only nil)
+               bl el)
            (goto-char (point-min))
-           (when (re-search-forward "\\(\\S-+?\\):\\([0-9]+\\)" nil t)
-             (let ((start (line-beginning-position))
-                   (file (match-string 1))
-                   (line (match-string 2)))
-               (re-search-backward "^#*\\([0-9]+\\)" start t)
-               (gdb-enqueue-input
-                (list (concat gdb-server-prefix "frame "
-                              (match-string 1) "\n") 'gdb-set-hollow))
-               (gdb-enqueue-input
-                (list (concat gdb-server-prefix "frame 0\n") 'ignore)))))))
+           (while (< (point) (point-max))
+             (setq bl (line-beginning-position)
+                   el (line-end-position))
+             (when (looking-at "#")
+               (add-text-properties bl el
+                                    '(mouse-face highlight
+                                                 help-echo "mouse-2, RET: 
Select frame")))
+             (goto-char bl)
+             (when (looking-at "^#\\([0-9]+\\)")
+               (when (string-equal (match-string 1) gdb-frame-number)
+                 (if (> (car (window-fringes)) 0)
+                     (progn
+                       (or gdb-stack-position
+                           (setq gdb-stack-position (make-marker)))
+                       (set-marker gdb-stack-position (point))
+                       (setq move-to gdb-stack-position))
+                   (put-text-property bl (+ bl 4)
+                                      'face '(:inverse-video t))
+                   (setq move-to bl)))
+               (when (re-search-forward
+                      (concat
+                       (if (string-equal (match-string 1) "0") "" " in ")
+                       "\\([^ ]+\\) (") el t)
+                 (put-text-property (match-beginning 1) (match-end 1)
+                                    'face font-lock-function-name-face)
+                 (setq bl (match-end 0))
+                 (while (re-search-forward "<\\([^>]+\\)>" el t)
+                   (put-text-property (match-beginning 1) (match-end 1)
+                                      'face font-lock-function-name-face))
+                 (goto-char bl)
+                 (while (re-search-forward "\\(\\(\\sw\\|[_.]\\)+\\)=" el t)
+                   (put-text-property (match-beginning 1) (match-end 1)
+                                      'face font-lock-variable-name-face))))
+             (forward-line 1))
+           (forward-line -1)
+           (when (looking-at "(More stack frames follow...)")
+             (add-text-properties (match-beginning 0) (match-end 0)
+                                  '(mouse-face highlight
+                                               gdb-max-frames t
+                                               help-echo
+                                               "mouse-2, RET: customize 
gdb-max-frames to see more frames")))))
+       (when gdb-look-up-stack
+         (goto-char (point-min))
+         (when (re-search-forward "\\(\\S-+?\\):\\([0-9]+\\)" nil t)
+           (let ((start (line-beginning-position))
+                 (file (match-string 1))
+                 (line (match-string 2)))
+             (re-search-backward "^#*\\([0-9]+\\)" start t)
+             (gdb-enqueue-input
+              (list (concat gdb-server-prefix "frame "
+                            (match-string 1) "\n") 'gdb-set-hollow))
+             (gdb-enqueue-input
+              (list (concat gdb-server-prefix "frame 0\n") 'ignore))))))
+      (when move-to
+       (let ((window (get-buffer-window (current-buffer) 0)))
+         (when window
+           (with-selected-window window
+             (goto-char move-to)
+             (unless (pos-visible-in-window-p)
+               (recenter '(center)))))))))
   (if (eq gdb-look-up-stack 'delete)
       (kill-buffer (gdb-get-buffer 'gdb-stack-buffer)))
   (setq gdb-look-up-stack nil))




reply via email to

[Prev in Thread] Current Thread [Next in Thread]