changeset 68993:3d9e09ba3ace

(gdb-var-evaluate-expression-handler) (gdb-var-update-handler): Detect out of scope variables with pre GDB 6.4 too. (gdb-post-prompt): Revert changet 2006-02-17 (force update). Reset status of variable objexts to nil in update handlers. (gdb-var-update-handler-1): Detect when a variable object comes in scope. setcar on var changes gdb-var-list directly.
author Nick Roberts <nickrob@snap.net.nz>
date Sat, 18 Feb 2006 22:58:26 +0000
parents dccdda472b02
children 9dadad58610c
files lisp/progmodes/gdb-ui.el
diffstat 1 files changed, 37 insertions(+), 24 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/progmodes/gdb-ui.el	Sat Feb 18 22:57:05 2006 +0000
+++ b/lisp/progmodes/gdb-ui.el	Sat Feb 18 22:58:26 2006 +0000
@@ -624,7 +624,7 @@
       (dolist (var gdb-var-list)
 	(if (string-equal varnum (cadr var))
 	    (progn
-	      (if changed (setcar (nthcdr 5 var) t))
+	      (if changed (setcar (nthcdr 5 var) 'changed))
 	      (setcar (nthcdr 4 var) (read (match-string 1)))
 	      (setcar (nthcdr num gdb-var-list) var)
 	      (throw 'var-found nil)))
@@ -679,16 +679,26 @@
 
 (defun gdb-var-update-handler ()
   (goto-char (point-min))
+  (dolist (var gdb-var-list)
+    (when (and (eq (car (nthcdr 5 var)) 'out-of-scope)
+	       (not (re-search-forward gdb-var-update-regexp-1 nil t))
+	       (not gdb-var-changed))
+      (setq gdb-var-changed t))
+    (setcar (nthcdr 5 var) nil))
+  (goto-char (point-min))
   (while (re-search-forward gdb-var-update-regexp nil t)
-    (catch 'var-found-1
-      (let ((varnum (match-string 1)))
-	(dolist (var gdb-var-list)
-	  (gdb-enqueue-input
-	   (list
-	    (concat "server interpreter mi \"-var-evaluate-expression "
-		    varnum "\"\n")
-	    `(lambda () (gdb-var-evaluate-expression-handler ,varnum t))))
-	  (throw 'var-found-1 nil)))))
+    (let ((varnum (match-string 1)))
+      (if  (string-equal (match-string 2) "false")
+	  (catch 'var-found
+	    (dolist (var gdb-var-list)
+	      (if (string-equal varnum (cadr var))
+		  (setcar (nthcdr 5 var) 'out-of-scope)
+		(throw 'var-found nil))))
+	(gdb-enqueue-input
+	 (list
+	  (concat "server interpreter mi \"-var-evaluate-expression "
+		  varnum "\"\n")
+	  `(lambda () (gdb-var-evaluate-expression-handler ,varnum t)))))))
   (setq gdb-pending-triggers
 	(delq 'gdb-var-update gdb-pending-triggers))
   (when (and (boundp 'speedbar-frame) (frame-live-p speedbar-frame))
@@ -1217,8 +1227,7 @@
       ;; FIXME: with GDB-6 on Darwin, this might very well work.
       ;; Only needed/used with speedbar/watch expressions.
       (when (and (boundp 'speedbar-frame) (frame-live-p speedbar-frame))
-	(dolist (var gdb-var-list)
-	  (setcar (nthcdr 5 var) nil))
+	(setq gdb-var-changed t)    ; force update
 	(if (string-equal gdb-version "pre-6.4")
 	    (gdb-var-update)
 	  (gdb-var-update-1)))))
@@ -3045,21 +3054,25 @@
 
 (defun gdb-var-update-handler-1 ()
   (goto-char (point-min))
+  (dolist (var gdb-var-list)
+    (when (and (eq (car (nthcdr 5 var)) 'out-of-scope)
+	       (not (re-search-forward gdb-var-update-regexp-1 nil t))
+	       (not gdb-var-changed))
+      (setq gdb-var-changed t))
+    (setcar (nthcdr 5 var) nil))
+  (goto-char (point-min))
   (while (re-search-forward gdb-var-update-regexp-1 nil t)
     (let ((varnum (match-string 1)))
       (catch 'var-found1
-	(let ((num 0))
-	  (dolist (var gdb-var-list)
-	    (if (string-equal varnum (cadr var))
-		(progn
-		  (if (string-equal (match-string 3) "false")
-		      (setcar (nthcdr 5 var) 'out-of-scope)
-		    (setcar (nthcdr 5 var) 'changed)
-		    (setcar (nthcdr 4 var)
-			    (read (match-string 2))))
-		  (setcar (nthcdr num gdb-var-list) var)
-		  (throw 'var-found1 nil)))
-	    (setq num (+ num 1))))))
+	(dolist (var gdb-var-list)
+	  (if (string-equal varnum (cadr var))
+	      (progn
+		(if (string-equal (match-string 3) "false")
+		    (setcar (nthcdr 5 var) 'out-of-scope)
+		  (setcar (nthcdr 5 var) 'changed)
+		  (setcar (nthcdr 4 var)
+			  (read (match-string 2))))
+		(throw 'var-found1 nil))))))
     (setq gdb-var-changed t))
   (setq gdb-pending-triggers
    (delq 'gdb-var-update gdb-pending-triggers))