From: Tom Tromey <tromey@redhat.com>
To: gdb-patches@sourceware.org
Subject: FYI: minor simplification in add_psymbol_to_bcache
Date: Tue, 03 Nov 2009 20:10:00 -0000 [thread overview]
Message-ID: <m3iqdr9xov.fsf@fleche.redhat.com> (raw)
This patch changes add_psymbol_to_bcache in two ways.
First, it removes the gratuitous use of a 'static' local variable.
Second, it removes the copying of 'name'. I think this copy is not
needed because SYMBOL_SET_NAMES handles this case itself.
Built and regtested on x86-64 (compile farm).
I'll wait a while in case anybody has any comments on this.
Tom
2009-11-03 Tom Tromey <tromey@redhat.com>
* symfile.c (add_psymbol_to_bcache): Don't copy name. Make
'psymbol' non-static.
Index: symfile.c
===================================================================
RCS file: /cvs/src/src/gdb/symfile.c,v
retrieving revision 1.251
diff -u -r1.251 symfile.c
--- symfile.c 2 Nov 2009 14:59:51 -0000 1.251
+++ symfile.c 3 Nov 2009 20:08:33 -0000
@@ -3106,19 +3106,9 @@
enum language language, struct objfile *objfile,
int *added)
{
- char *buf = name;
- /* 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;
-
- if (name[namelength] != '\0')
- {
- buf = alloca (namelength + 1);
- /* Create local copy of the partial symbol */
- memcpy (buf, name, namelength);
- buf[namelength] = '\0';
- }
+ struct partial_symbol psymbol;
+
+ memset (&psymbol, 0, sizeof (struct partial_symbol));
/* val and coreaddr are mutually exclusive, one of them *will* be zero */
if (val != 0)
{
@@ -3133,7 +3123,7 @@
PSYMBOL_DOMAIN (&psymbol) = domain;
PSYMBOL_CLASS (&psymbol) = class;
- SYMBOL_SET_NAMES (&psymbol, buf, namelength, objfile);
+ SYMBOL_SET_NAMES (&psymbol, name, namelength, objfile);
/* Stash the partial symbol away in the cache */
return bcache_full (&psymbol, sizeof (struct partial_symbol),
next reply other threads:[~2009-11-03 20:10 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-11-03 20:10 Tom Tromey [this message]
2009-11-03 20:21 ` Daniel Jacobowitz
2009-11-04 19:16 ` Tom Tromey
2009-11-05 20:03 ` Daniel Jacobowitz
2009-11-05 22:16 ` Tom Tromey
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=m3iqdr9xov.fsf@fleche.redhat.com \
--to=tromey@redhat.com \
--cc=gdb-patches@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox