changeset 75093:5b3d80ea3c0e

(gdb-max-children): New customizable variable. (gdb-speedbar-expand-node): Ask user for confirmation before expanding large structures/arrays.
author Nick Roberts <nickrob@snap.net.nz>
date Fri, 05 Jan 2007 04:20:20 +0000
parents e566d4fc8dd2
children 2fe956115500
files lisp/progmodes/gdb-ui.el
diffstat 1 files changed, 17 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/progmodes/gdb-ui.el	Fri Jan 05 02:09:07 2007 +0000
+++ b/lisp/progmodes/gdb-ui.el	Fri Jan 05 04:20:20 2007 +0000
@@ -896,6 +896,12 @@
   :group 'gud
   :version "22.1")
 
+(defcustom gdb-max-children 40
+  "Maximum number of children allowed before Emacs asks"
+  :type 'integer
+  :group 'gud
+  :version "22.1")
+
 (defun gdb-speedbar-expand-node (text token indent)
   "Expand the node the user clicked on.
 TEXT is the text of the button we clicked on, a + or - item.
@@ -904,11 +910,17 @@
   (if (and gud-comint-buffer (buffer-name gud-comint-buffer))
       (progn
 	(cond ((string-match "+" text)	;expand this node
-	       (if (and (eq (buffer-local-value
-			     'gud-minor-mode gud-comint-buffer) 'gdba)
-			(string-equal gdb-version "pre-6.4"))
-		   (gdb-var-list-children token)
-		 (gdb-var-list-children-1 token)))
+	       (let* ((var (assoc token gdb-var-list))
+		      (expr (nth 1 var)) (children (nth 2 var)))
+		 (if (or (<= (string-to-number children) gdb-max-children)
+			  (y-or-n-p
+			   (format
+			    "%s has %s children. Continue? " expr children)))
+		     (if (and (eq (buffer-local-value
+				   'gud-minor-mode gud-comint-buffer) 'gdba)
+			      (string-equal gdb-version "pre-6.4"))
+			 (gdb-var-list-children token)
+		       (gdb-var-list-children-1 token)))))
 	      ((string-match "-" text)	;contract this node
 	       (dolist (var gdb-var-list)
 		 (if (string-match (concat token "\\.") (car var))