This is the mail archive of the
mailing list for the GDB project.
Re: FYI: minor simplification in add_psymbol_to_bcache
>>>>> "Daniel" == Daniel Jacobowitz <firstname.lastname@example.org> writes:
>> On Wed, Nov 04, 2009 at 12:16:27PM -0700, Tom Tromey wrote:
>> TBH I was not thinking too soundly, I suppose, when I nuked this. I
>> think your point is a good one. If you'd prefer, I will leave this
>> static and just zero out that field.
Daniel> Unless you have a good reason not to, I suggest making that change.
Here is the patch I am checking in.
2009-11-05 Tom Tromey <email@example.com>
* symfile.c (add_psymbol_to_bcache): Make 'psymbol' static again.
Zero the 'value' field.
RCS file: /cvs/src/src/gdb/symfile.c,v
retrieving revision 1.253
diff -u -r1.253 symfile.c
--- symfile.c 5 Nov 2009 19:53:04 -0000 1.253
+++ symfile.c 5 Nov 2009 22:15:30 -0000
@@ -3105,9 +3105,15 @@
enum language language, struct objfile *objfile,
- struct partial_symbol psymbol;
- memset (&psymbol, 0, sizeof (struct partial_symbol));
+ /* psymbol is static so that there will be no uninitialized gaps in the
+ structure which might contain random data, causing cache misses in
+ bcache. */
+ static struct partial_symbol psymbol;
+ /* However, we must ensure that the entire 'value' field has been
+ zeroed before assigning to it, because an assignment may not
+ write the entire field. */
+ memset (&psymbol.ginfo.value, 0, sizeof (psymbol.ginfo.value));
/* val and coreaddr are mutually exclusive, one of them *will* be zero */
if (val != 0)