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]

[PATCH]: read var leak


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?

nathan
--
Nathan Sidwell    ::   http://www.codesourcery.com   ::     CodeSourcery LLC
nathan@codesourcery.com    ::     http://www.planetfall.pwp.blueyonder.co.uk

2005-02-09  Nathan Sidwell  <nathan@codesourcery.com>

	* findvar.c (read_var_value): Reorder LOC_COMPUTED and
	LOC_COMPUTED_ARG to avoid value object leak.

Index: findvar.c
===================================================================
RCS file: /cvs/src/src/gdb/findvar.c,v
retrieving revision 1.86
diff -c -3 -p -r1.86 findvar.c
*** findvar.c	7 Feb 2005 15:04:42 -0000	1.86
--- findvar.c	9 Feb 2005 10:38:38 -0000
*************** read_var_value (struct symbol *var, stru
*** 385,401 ****
    CORE_ADDR addr;
    int len;
  
-   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)
      frame = deprecated_safe_get_selected_frame ();
  
    switch (SYMBOL_CLASS (var))
      {
      case LOC_CONST:
--- 385,412 ----
    CORE_ADDR addr;
    int len;
  
    /* FIXME drow/2003-09-06: this call to the selected frame should be
       pushed upwards to the callers.  */
    if (frame == NULL)
      frame = deprecated_safe_get_selected_frame ();
  
+   if (SYMBOL_CLASS (var) == LOC_COMPUTED
+       || SYMBOL_CLASS (var) == LOC_COMPUTED_ARG)
+     {
+       /* FIXME: cagney/2004-01-26: It should be possible to
+ 	 unconditionally call the SYMBOL_OPS method when available.
+ 	 Unfortunately DWARF 2 stores the frame-base (instead of the
+ 	 function) location in a function's symbol.  Oops!  For the
+ 	 moment enable this when/where applicable.  */
+       if (frame == 0 && SYMBOL_OPS (var)->read_needs_frame (var))
+ 	return 0;
+       return SYMBOL_OPS (var)->read_variable (var, frame);
+     }
+   
+   v = allocate_value (type);
+   VALUE_LVAL (v) = lval_memory;	/* The most likely possibility.  */
+   len = TYPE_LENGTH (type);
+   
    switch (SYMBOL_CLASS (var))
      {
      case LOC_CONST:
*************** addresses have not been bound by the dyn
*** 548,564 ****
        }
        break;
  
-     case LOC_COMPUTED:
-     case LOC_COMPUTED_ARG:
-       /* FIXME: cagney/2004-01-26: It should be possible to
- 	 unconditionally call the SYMBOL_OPS method when available.
- 	 Unfortunately DWARF 2 stores the frame-base (instead of the
- 	 function) location in a function's symbol.  Oops!  For the
- 	 moment enable this when/where applicable.  */
-       if (frame == 0 && SYMBOL_OPS (var)->read_needs_frame (var))
- 	return 0;
-       return SYMBOL_OPS (var)->read_variable (var, frame);
- 
      case LOC_UNRESOLVED:
        {
  	struct minimal_symbol *msym;
--- 559,564 ----

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