Re: dwarf2_evaluate_loc_desc() in dwarf2loc.c

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Re: dwarf2_evaluate_loc_desc() in dwarf2loc.c

Jim Blandy

Carl Burch <[hidden email]> writes:

>    I had a defect that wandered into dwarf2_evaluate_loc_desc() of
> dwarf2loc.c, specificly the section (in the current FSF CVS top-of-trunk
> version) :
>
>   if (size == 0)
>     {
>       retval = allocate_value (SYMBOL_TYPE (var));
>       VALUE_LVAL (retval) = not_lval;
>       set_value_optimized_out (retval, 1);
>     }
>
> This then clause looks odd.  If "size" actually is zero, then shouldn't
> there be a "return retval;" to close that then block?  If not, the
> value allocated in that block leaks when "retval" is overwritten in
> each case below that.

[CC: changed to [hidden email]]

I think you're right.  I've committed the below as obvious:

gdb/ChangeLog:
2007-01-23  Jim Blandy  <[hidden email]>

        * dwarf2loc.c (dwarf2_evaluate_loc_desc): When the location
        expression is empty, bother to return the 'optimized out' value we
        construct.  (Thanks to Carl Burch.)

Index: gdb/dwarf2loc.c
===================================================================
RCS file: /cvs/src/src/gdb/dwarf2loc.c,v
retrieving revision 1.38
diff -u -r1.38 dwarf2loc.c
--- gdb/dwarf2loc.c 9 Jan 2007 17:58:50 -0000 1.38
+++ gdb/dwarf2loc.c 24 Jan 2007 00:46:25 -0000
@@ -201,6 +201,7 @@
       retval = allocate_value (SYMBOL_TYPE (var));
       VALUE_LVAL (retval) = not_lval;
       set_value_optimized_out (retval, 1);
+      return retval;
     }
 
   baton.frame = frame;