This is the mail archive of the gdb-patches@sources.redhat.com mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH]: read var leak


On Wed, Feb 09, 2005 at 10:59:55AM +0000, Nathan Sidwell wrote:
> hi,
> this patch fixes a leak of value objects.  When a value's symbol is
> LOC_COMPUTED or ARG_LOC_COMPUTED, the symbol's read_variable method
> allocates the value object.  The current ordering in read_var_value
> has already created a value object for the value, so we end up with
> an empty value object on the value chain.  This isn't fatal, but
> is confusing.
> 
> built & tested on i686-pc-linux-gnu and an unreleased architecture, ok?

Generally OK, but I wanted to rearrange it a little bit; I've checked
in this instead.  It shows that the HP code is a bit rotting...

-- 
Daniel Jacobowitz
CodeSourcery, LLC

2005-03-07  Daniel Jacobowitz  <dan@codesourcery.com>

	* findvar.c (read_var_value): Don't allocate V when it will not
	be used.  Add missing break for LOC_INDIRECT.

Index: findvar.c
===================================================================
RCS file: /cvs/src/src/gdb/findvar.c,v
retrieving revision 1.89
diff -u -p -r1.89 findvar.c
--- findvar.c	11 Feb 2005 18:13:49 -0000	1.89
+++ findvar.c	7 Mar 2005 22:21:34 -0000
@@ -385,12 +385,20 @@ read_var_value (struct symbol *var, stru
   CORE_ADDR addr;
   int len;
 
-  v = allocate_value (type);
-  VALUE_LVAL (v) = lval_memory;	/* The most likely possibility.  */
+  if (SYMBOL_CLASS (var) == LOC_COMPUTED
+      || SYMBOL_CLASS (var) == LOC_COMPUTED_ARG
+      || SYMBOL_CLASS (var) == LOC_REGISTER
+      || SYMBOL_CLASS (var) == LOC_REGPARM)
+    /* These cases do not use V.  */
+    v = NULL;
+  else
+    {
+      v = allocate_value (type);
+      VALUE_LVAL (v) = lval_memory;	/* The most likely possibility.  */
+    }
 
   len = TYPE_LENGTH (type);
 
-
   /* FIXME drow/2003-09-06: this call to the selected frame should be
      pushed upwards to the callers.  */
   if (frame == NULL)
@@ -452,6 +460,7 @@ addresses have not been bound by the dyn
 	locaddr = SYMBOL_VALUE_ADDRESS (var);
 	loc = value_at (lookup_pointer_type (type), locaddr);
 	addr = value_as_address (loc);
+	break;
       }
 
     case LOC_ARG:


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]