From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 30888 invoked by alias); 9 Mar 2005 06:21:43 -0000 Mailing-List: contact gdb-patches-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sources.redhat.com Received: (qmail 30763 invoked from network); 9 Mar 2005 06:21:28 -0000 Received: from unknown (HELO priv-edtnes46.telusplanet.net) (199.185.220.240) by sourceware.org with SMTP; 9 Mar 2005 06:21:28 -0000 Received: from takamaka.act-europe.fr ([142.179.108.108]) by priv-edtnes46.telusplanet.net (InterMail vM.6.01.04.00 201-2131-118-20041027) with ESMTP id <20050309062123.BKUI8068.priv-edtnes46.telusplanet.net@takamaka.act-europe.fr>; Tue, 8 Mar 2005 23:21:23 -0700 Received: by takamaka.act-europe.fr (Postfix, from userid 507) id B059847DC0; Tue, 8 Mar 2005 22:21:22 -0800 (PST) Date: Wed, 09 Mar 2005 06:21:00 -0000 From: Joel Brobecker To: gdb-patches@sources.redhat.com Cc: phdm@macqel.be Subject: PING (4 months) Re: [RFA/tru64] Compute bfd_section for minimal symbols Message-ID: <20050309062122.GL1156@adacore.com> References: <20041110180139.GL649@gnat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20041110180139.GL649@gnat.com> User-Agent: Mutt/1.4i X-SW-Source: 2005-03/txt/msg00141.txt.bz2 Hello, I am wondering who could review this patch. This is related to COFF, and hence would fall in Philippe De Muyter's area of expertise, but I don't remember seeing him being active anymore. Perhaps a global maintainer could have a look? On Wed, Nov 10, 2004 at 10:01:39AM -0800, Joel Brobecker wrote: > Hello, > > I noticed we had a lot of errors like this in the testsuite logs: > > (gdb) break main > warning: (Internal error: pc 0x12000134c in read in psymtab, but not in symtab.) > > Breakpoint 1 at 0x120001364: file ./gdb.base/advance.c, line 41. > > The reason for this is the following check in in find_pc_sect_symtab(): > > fixup_symbol_section (sym, objfile); > if (section == SYMBOL_BFD_SECTION (sym)) > break; > > This check makes sure that the symbol section matches the section > in which we expect to find the symbol. Unfortunately for us on Tru64, > the symbol bfd_section is not set. So we fail the check, and end up > discarding the correct symbol table. > > Then when find_pc_sect_symtab() falls back to searching the partial > symtabs, it founds the psymtab corresponding to the symtab we just > rejected, and is surprised to see that it has already been read in. > > ps = find_pc_sect_psymtab (pc, section); > if (ps) > { > if (ps->readin) > /* Might want to error() here (in case symtab is corrupt and > will cause a core dump), but maybe we can successfully > continue, so let's not. */ > warning ("\ > (Internal error: pc 0x%s in read in psymtab, but not in symtab.)\n", > paddr_nz (pc)); > s = PSYMTAB_TO_SYMTAB (ps); > > Investigating the source of the problem showed that symbol bfd_section > is not provided by the debugging information, and hence it is retrieved > using the minimal symbols through: > > fixup_symbol_section (sym, objfile); > > That lead me to find that the bfd_section for the symbols was not > set either. The attached patch fixes this. > > 2004-11-10 Joel Brobecker > > * mdebugread.c (record_minimal_symbol): New procedure. > (parse_partial_symbols): Use record_minimal_symbol to record > the new minimal symbols instead of prim_record_minimal_symbol > and prim_record_minimal_symbol_and_info. > > Tested on alpha-tru64, fixes a few hundred regressions. > OK to apply? > > Note that I only modified the code that loads the symbol table from > objects generated by GCC. I don't have a DEC C compiler, so I didn't > modify the part of parse_partial_symbols that deals with non-gcc > symbol tables because I wouldn't be able to test the changes. I can > make the changes blindly, but ... > > Thanks, > -- > Joel > Index: mdebugread.c > =================================================================== > RCS file: /cvs/src/src/gdb/mdebugread.c,v > retrieving revision 1.71 > diff -u -p -r1.71 mdebugread.c > --- mdebugread.c 31 Oct 2004 17:57:43 -0000 1.71 > +++ mdebugread.c 10 Nov 2004 17:34:02 -0000 > @@ -2173,6 +2173,85 @@ function_outside_compilation_unit_compla > arg1); > } > > +/* Use the STORAGE_CLASS to compute which section the given symbol > + belongs to, and then records this new minimal symbol. */ > + > +static void > +record_minimal_symbol (const char *name, const CORE_ADDR address, > + enum minimal_symbol_type ms_type, int storage_class, > + struct objfile *objfile) > +{ > + int section; > + asection *bfd_section; > + > + switch (storage_class) > + { > + case scText: > + section = SECT_OFF_TEXT (objfile); > + bfd_section = bfd_get_section_by_name (cur_bfd, ".text"); > + break; > + case scData: > + section = SECT_OFF_DATA (objfile); > + bfd_section = bfd_get_section_by_name (cur_bfd, ".data"); > + break; > + case scBss: > + section = SECT_OFF_BSS (objfile); > + bfd_section = bfd_get_section_by_name (cur_bfd, ".bss"); > + break; > + case scSData: > + section = get_section_index (objfile, ".sdata"); > + bfd_section = bfd_get_section_by_name (cur_bfd, ".sdata"); > + break; > + case scSBss: > + section = get_section_index (objfile, ".sbss"); > + bfd_section = bfd_get_section_by_name (cur_bfd, ".sbss"); > + break; > + case scRData: > + section = get_section_index (objfile, ".rdata"); > + bfd_section = bfd_get_section_by_name (cur_bfd, ".rdata"); > + break; > + case scInit: > + section = get_section_index (objfile, ".init"); > + bfd_section = bfd_get_section_by_name (cur_bfd, ".init"); > + break; > + case scXData: > + section = get_section_index (objfile, ".xdata"); > + bfd_section = bfd_get_section_by_name (cur_bfd, ".xdata"); > + break; > + case scPData: > + section = get_section_index (objfile, ".pdata"); > + bfd_section = bfd_get_section_by_name (cur_bfd, ".pdata"); > + break; > + case scFini: > + section = get_section_index (objfile, ".fini"); > + bfd_section = bfd_get_section_by_name (cur_bfd, ".fini"); > + break; > + case scRConst: > + section = get_section_index (objfile, ".rconst"); > + bfd_section = bfd_get_section_by_name (cur_bfd, ".rconst"); > + break; > +#ifdef scTlsData > + case scTlsData: > + section = get_section_index (objfile, ".tlsdata"); > + bfd_section = bfd_get_section_by_name (cur_bfd, ".tlsdata"); > + break; > +#endif > +#ifdef scTlsBss > + case scTlsBss: > + section = get_section_index (objfile, ".tlsbss"); > + bfd_section = bfd_get_section_by_name (cur_bfd, ".tlsbss"); > + break; > +#endif > + default: > + /* This kind of symbol is not associated to a section. */ > + section = -1; > + bfd_section = NULL; > + } > + > + prim_record_minimal_symbol_and_info (name, address, ms_type, NULL, > + section, bfd_section, objfile); > +} > + > /* Master parsing procedure for first-pass reading of file symbols > into a partial_symtab. */ > > @@ -2487,7 +2566,8 @@ parse_partial_symbols (struct objfile *o > unknown_ext_complaint (name); > } > if (!ECOFF_IN_ELF (cur_bfd)) > - prim_record_minimal_symbol (name, svalue, ms_type, objfile); > + record_minimal_symbol (name, svalue, ms_type, ext_in->asym.sc, > + objfile); > } > > /* Pass 3 over files, over local syms: fill in static symbols */ > @@ -2604,13 +2684,9 @@ parse_partial_symbols (struct objfile *o > if (sh.st == stStaticProc) > { > namestring = debug_info->ss + fh->issBase + sh.iss; > - prim_record_minimal_symbol_and_info (namestring, > - sh.value, > - mst_file_text, > - NULL, > - SECT_OFF_TEXT (objfile), > - NULL, > - objfile); > + record_minimal_symbol (namestring, sh.value, > + mst_file_text, sh.sc, > + objfile); > } > procaddr = sh.value; > > @@ -2652,13 +2728,9 @@ parse_partial_symbols (struct objfile *o > case scXData: > namestring = debug_info->ss + fh->issBase + sh.iss; > sh.value += ANOFFSET (objfile->section_offsets, SECT_OFF_DATA (objfile)); > - prim_record_minimal_symbol_and_info (namestring, > - sh.value, > - mst_file_data, > - NULL, > - SECT_OFF_DATA (objfile), > - NULL, > - objfile); > + record_minimal_symbol (namestring, sh.value, > + mst_file_data, sh.sc, > + objfile); > break; > > default: > @@ -2666,13 +2738,9 @@ parse_partial_symbols (struct objfile *o > then have the default be abs? */ > namestring = debug_info->ss + fh->issBase + sh.iss; > sh.value += ANOFFSET (objfile->section_offsets, SECT_OFF_BSS (objfile)); > - prim_record_minimal_symbol_and_info (namestring, > - sh.value, > - mst_file_bss, > - NULL, > - SECT_OFF_BSS (objfile), > - NULL, > - objfile); > + record_minimal_symbol (namestring, sh.value, > + mst_file_bss, sh.sc, > + objfile); > break; > } > } -- Joel