* gdb registers multiple definition of symbols : patch to fix this
@ 2007-07-31 12:02 Kalpana Ramamurthy
2007-07-31 17:16 ` Daniel Jacobowitz
0 siblings, 1 reply; 4+ messages in thread
From: Kalpana Ramamurthy @ 2007-07-31 12:02 UTC (permalink / raw)
To: gdb; +Cc: kalpana.balaji
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
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: gdb registers multiple definition of symbols : patch to fix this
2007-07-31 12:02 gdb registers multiple definition of symbols : patch to fix this Kalpana Ramamurthy
@ 2007-07-31 17:16 ` Daniel Jacobowitz
2007-08-01 4:45 ` gdb registers multiple definition of symbols : patch to fixthis Kalpana Ramamurthy
0 siblings, 1 reply; 4+ messages in thread
From: Daniel Jacobowitz @ 2007-07-31 17:16 UTC (permalink / raw)
To: Kalpana Ramamurthy; +Cc: gdb, kalpana.balaji
On Tue, Jul 31, 2007 at 11:53:23AM +0000, Kalpana Ramamurthy wrote:
> Why this patch is required with the code is compiled with gcc 3.4.6 is
> something that I still don't
> know.
It sounds to me like your compiler is generating bogus information.
--
Daniel Jacobowitz
CodeSourcery
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: gdb registers multiple definition of symbols : patch to fixthis
2007-07-31 17:16 ` Daniel Jacobowitz
@ 2007-08-01 4:45 ` Kalpana Ramamurthy
2007-08-01 11:21 ` Daniel Jacobowitz
0 siblings, 1 reply; 4+ messages in thread
From: Kalpana Ramamurthy @ 2007-08-01 4:45 UTC (permalink / raw)
To: drow; +Cc: gdb
How do we verify the information generated by the compiler ? I wanted to see
all the definitions
generated by the compiler for that symbol. How can I do that ? I couldn't
decipher anything
with readelf and objdump.
Regards,
Kalpana
====
>From: Daniel Jacobowitz <drow@false.org>
>To: Kalpana Ramamurthy <kal_pana@hotmail.com>
>CC: gdb@sourceware.org, kalpana.balaji@symphonysv.com
>Subject: Re: gdb registers multiple definition of symbols : patch to
>fixthis
>Date: Tue, 31 Jul 2007 08:02:44 -0400
>
>On Tue, Jul 31, 2007 at 11:53:23AM +0000, Kalpana Ramamurthy wrote:
> > Why this patch is required with the code is compiled with gcc 3.4.6 is
> > something that I still don't
> > know.
>
>It sounds to me like your compiler is generating bogus information.
>
>--
>Daniel Jacobowitz
>CodeSourcery
_________________________________________________________________
Real Estate classifieds on MSN - for free.www.yello.in
http://www.yello.in/home.php?utm_source=hotmailtag&utm_medium=email&utm_content=in&utm_campaign=jun
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2007-08-01 11:21 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-07-31 12:02 gdb registers multiple definition of symbols : patch to fix this Kalpana Ramamurthy
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
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox