This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: dwarf2_evaluate_loc_desc() in dwarf2loc.c
- From: Jim Blandy <jimb at codesourcery dot com>
- To: Carl Burch <cdb at cup dot hp dot com>
- Cc: gdb-patches at sourceware dot org
- Date: Tue, 23 Jan 2007 16:47:35 -0800
- Subject: Re: dwarf2_evaluate_loc_desc() in dwarf2loc.c
- References: <200701240005.QAA20531@adlwrk03.cup.hp.com>
Carl Burch <cdb@cup.hp.com> 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 gdb-patches@sourceware.org]
I think you're right. I've committed the below as obvious:
gdb/ChangeLog:
2007-01-23 Jim Blandy <jimb@codesourcery.com>
* 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;