From: "Kalpana Ramamurthy" <kal_pana@hotmail.com>
To: gdb@sourceware.org
Cc: kalpana.balaji@symphonysv.com
Subject: gdb registers multiple definition of symbols : patch to fix this
Date: Tue, 31 Jul 2007 12:02:00 -0000 [thread overview]
Message-ID: <BAY144-F39B459E1498322EF7ACDF5E8EF0@phx.gbl> (raw)
Hello,
My code is written for 64 bit support. I have upgraded the compiler to 3.4.6
which was previously 3.2.2. I think the default debug information generated
is dwarf-2 (the code was compiled with -ggdb option). I have a class
definition containing about 10 fields. But when I say "ptype cGroupCache",
it shows me only 1 field !. This happened to a some of the other classes too
that I tested. But in those cases, when I start gdb with --readnow option, I
see all the fields. But for this particular class, --readnow option doesn't
help either.
Why this patch is required with the code is compiled with gcc 3.4.6 is
something that I still don't
know.
Currently to workaround this problem, I patched the symtab.c code with the
following algorithm in the function lookup_symbol_aux_symtabs().
1. Browse across all the definitions of the symbol
2. For each definition found, get the number of fields
3. If the number is greater thatn the number of fields of the last saved
defintion, save the definition.
4. At the end of the browsing, return the saved definition (if it exists).
Please note that though this patch fixes the problem, its only a workaround.
The root cause is still
unknown. Why is gdb registering multiple definitions of the symbol ? And
even if that's necessary,
why is it not picking the correct definition ?
Code snippet that was patched :
***************************************************
/* Add declarations for sym1, block1, s1 and maxfields */
struct symbol * sym, *sym1;
const struct block *block, *block1 ;
struct symtab *s, *s1 ;
int maxfields = -1;
/* Initialize sym1 to NULL */
sym1 = NULL ;
ALL_SYMTABS (objfile, s)
{
bv = BLOCKVECTOR (s)
block = BLOCKVECTOR_BLOCK (bv, block_index) ;
sym = lookup_block_symbol (block, name, linkage_name, domain);
/* PATCH begins */
if (sym)
{
int fields = 0 ;
if (sym->type && sym->type->main_type)
{
fields = sym->type->main_type->nfields;
}
if (fields >= maxfields)
{
maxfields = fields ;
sym1 = sym ;
block1 = block ;
s1 = s ;
}
}
if (sym1)
{
block_found = block1 ;
if (symtab != NULL)
*symtab = s1 ;
sym = fixup_symbol_section (sym1, objfile) ;
return (sym1) ;
}
}
*******************************************************
_________________________________________________________________
Catch all the cricketing action right here. Live score, match reports,
photos et al. http://content.msn.co.in/Sports/Cricket/Default.aspx
next reply other threads:[~2007-07-31 11:53 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-07-31 12:02 Kalpana Ramamurthy [this message]
2007-07-31 17:16 ` Daniel Jacobowitz
2007-08-01 4:45 ` gdb registers multiple definition of symbols : patch to fixthis Kalpana Ramamurthy
2007-08-01 11:21 ` Daniel Jacobowitz
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=BAY144-F39B459E1498322EF7ACDF5E8EF0@phx.gbl \
--to=kal_pana@hotmail.com \
--cc=gdb@sourceware.org \
--cc=kalpana.balaji@symphonysv.com \
/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