From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 9978 invoked by alias); 31 Jul 2007 11:53:31 -0000 Received: (qmail 9969 invoked by uid 22791); 31 Jul 2007 11:53:30 -0000 X-Spam-Check-By: sourceware.org Received: from bay0-omc3-s14.bay0.hotmail.com (HELO bay0-omc3-s14.bay0.hotmail.com) (65.54.246.214) by sourceware.org (qpsmtpd/0.31) with ESMTP; Tue, 31 Jul 2007 11:53:27 +0000 Received: from hotmail.com ([65.55.155.119]) by bay0-omc3-s14.bay0.hotmail.com with Microsoft SMTPSVC(6.0.3790.2668); Tue, 31 Jul 2007 04:53:26 -0700 Received: from mail pickup service by hotmail.com with Microsoft SMTPSVC; Tue, 31 Jul 2007 04:53:25 -0700 Message-ID: Received: from 65.55.155.123 by by144fd.bay144.hotmail.msn.com with HTTP; Tue, 31 Jul 2007 11:53:23 GMT X-Sender: kal_pana@hotmail.com From: "Kalpana Ramamurthy" To: gdb@sourceware.org Cc: kalpana.balaji@symphonysv.com Bcc: Subject: gdb registers multiple definition of symbols : patch to fix this Date: Tue, 31 Jul 2007 12:02:00 -0000 Mime-Version: 1.0 Content-Type: text/plain; format=flowed Mailing-List: contact gdb-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sourceware.org X-SW-Source: 2007-07/txt/msg00220.txt.bz2 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