Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Elena Zannoni <ezannoni@cygnus.com>
To: Joel Brobecker <brobecker@act-europe.fr>
Cc: gdb-patches@sources.redhat.com
Subject: Re: [patch] Fix uninitialized section index internal error
Date: Tue, 12 Jun 2001 14:18:00 -0000	[thread overview]
Message-ID: <15142.34631.889495.152234@kwikemart.cygnus.com> (raw)
In-Reply-To: <20010510234031.A17108@act-europe.fr>

Hi Joel, thanks for the patch. 
See my comments below.


Joel Brobecker writes:
 > Hi,
 > 
 >   it has been pointed to me that it is better to put the change log
 > inside the mail body rather than putting it inside the patch. So, I'll
 > start over. Please discard my previous message. Thanks.
 > 
 > While working with gdb on Tru64 5.1, we noticed the following internal
 > error sometimes happening at the begining of a gdb session:
 > 
 > | gdb/mdebugread.c:2448: gdb-internal-error: Section index is uninitialized
 > |
 > | An internal GDB error was detected.  This may make further
 > | debugging unreliable.  Continue this debugging session? (y or n) n
 >     

I see what's happening, your symbol is in section scSBss and not in scBss.
This macro in mdebugread.c:
SC_IS_BSS(sc) ((sc) == scBss || (sc) == scSBss)

evaluates to true, so you get to execute:

	  else if (SC_IS_BSS (ext_in->asym.sc))
	    {
	      ms_type = mst_bss;
	      svalue += ANOFFSET (objfile->section_offsets, SECT_OFF_BSS (objfile));

or (a few lines below):

	  else if (SC_IS_BSS (ext_in->asym.sc))
	    {
	      ms_type = mst_file_bss;
	      svalue += ANOFFSET (objfile->section_offsets, SECT_OFF_BSS (objfile));
	    }


The SECT_OFF_BSS then is -1. It shouldn't be used in this case,
because the symbol may not be in the bss section.

That said, may I suggest a different approach?  I think the bug is
really in mdebugread.c, not symfile.c.  I think the SC_IS_BSS macro
should be split in 2 separate ones: a proper SC_IS_BSS and another
SC_IS_SBSS for your case.  Then the above code would work ok, if you
don't have the .bss section, because it wouldn't trigger.  As for the
SC_IS_SBSS case, you would have to figure out what the correct value
to be added to svalue needs to be, and for this you need to find the
index of the .sbss section.

Thanks
Elena


 > To reproduce the problem, simply compile the following C program:
 > 
 > mach.c:
 > <<
 > int
 > main (void)
 > {
 >    return 0;
 > };
 > >>
 > 
 > Make sure libmach is linked in when building the program:
 > % gcc -o mach mach.c -lmach   
 > 
 > After for investigation, I found that gdb was looking for a symbol in
 > the .bss section of libmach.so, but there is none (which explains why
 > the section index is not initialized). Instead, there is a .sbss
 > section, where the symbol is localized.
 > 
 > I modified default_symfile_offsets () to use the .sbss section if the
 > .bss one does not exist. In that change, I am assuming that a bss and a
 > sbss section are mutually exclusive.
 > 
 > This change has been integrated in ACT's version of gdb a few months
 > ago, and has worked well so far.
 > 
 > Here is the change log:
 > 
 > 2001-05-10  J. Brobecker <brobecker@act-europe.fr>
 > 
 >         * symfile.c (default_symfile_offsets): use the .sbss section in
 >         place of the .bss section when the latter does not exist.
 > 
 > -- 
 > Joel
 > Index: gdb/symfile.c
 > ===================================================================
 > RCS file: /cvs/src/src/gdb/symfile.c,v
 > retrieving revision 1.31
 > diff -c -3 -p -r1.31 symfile.c
 > *** symfile.c	2001/04/05 02:02:13	1.31
 > --- symfile.c	2001/05/10 19:41:39
 > *************** default_symfile_offsets (struct objfile 
 > *** 529,534 ****
 > --- 529,536 ----
 >       objfile->sect_index_data = sect->index;
 >   
 >     sect = bfd_get_section_by_name (objfile->obfd, ".bss");
 > +   if (!sect)
 > +     sect = bfd_get_section_by_name (objfile->obfd, ".sbss");
 >     if (sect) 
 >       objfile->sect_index_bss = sect->index;
 >   


  reply	other threads:[~2001-06-12 14:18 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-05-10 14:40 Joel Brobecker
2001-06-12 14:18 ` Elena Zannoni [this message]
2001-06-14 23:40   ` Joel Brobecker
2001-06-27 22:32     ` Elena Zannoni
2001-06-28  5:23       ` Joel Brobecker
2001-06-28 20:17         ` Elena Zannoni
2001-11-06  7:40     ` Joel Brobecker

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=15142.34631.889495.152234@kwikemart.cygnus.com \
    --to=ezannoni@cygnus.com \
    --cc=brobecker@act-europe.fr \
    --cc=gdb-patches@sources.redhat.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