Mirror of the gdb mailing list
 help / color / mirror / Atom feed
From: Mark Mitchell <mark@codesourcery.com>
To: gdb@sourceware.cygnus.com, gcc@gcc.gnu.org
Subject: More than one stabn for the same PC
Date: Mon, 29 Nov 1999 16:59:00 -0000	[thread overview]
Message-ID: <19991129165903H.mitchell@codesourcery.com> (raw)

I've been looking at why debugging some C++ source wasn't going very
well, and here's what I've found.  GCC sometimes generates more than
one `.stabn' directive for the same PC, but with different line
numbers.  For example:

  .stabn <line number 9>
  .stabn <line number 5>
  <code here>

Because GDB does not use a stable sort when sorting line tables, this
the labeled code ends up reported as line number 9.  In fact, GDB
explicitly tries to pick the line-entry with the highest line-number;
see `compare_line_numbers' in buildsym.c.

That makes little sense to me; compilers ought to put these out in the
right order.  There is a comment in the code indicating that IBM XCOFF
gets this wrong, which seems to be the motivation for this.

So, I can see three possible fixes:

  o Change GCC to not generate the first entry.

    (Bad if you want to set a breakpoint on that line.)

  o Only do the sort for IBM XCOFF.

  o Change GDB to use a stable sort, i.e., change compare_line_numbers
    to sort by PC, but not perturb the order of elements with the 
    same PC.
 
I like the last option best.  Any objections to such a patch?

--
Mark Mitchell                   mark@codesourcery.com
CodeSourcery, LLC               http://www.codesourcery.com
From law@cygnus.com Mon Nov 29 17:29:00 1999
From: Jeffrey A Law <law@cygnus.com>
To: Mark Mitchell <mark@codesourcery.com>
Cc: gdb@sourceware.cygnus.com, gcc@gcc.gnu.org
Subject: Re: More than one stabn for the same PC 
Date: Mon, 29 Nov 1999 17:29:00 -0000
Message-id: <27496.943925188@upchuck>
References: <19991129165903H.mitchell@codesourcery.com>
X-SW-Source: 1999-q4/msg00360.html
Content-length: 1641

  In message < 19991129165903H.mitchell@codesourcery.com >you write:
  > 
  > I've been looking at why debugging some C++ source wasn't going very
  > well, and here's what I've found.  GCC sometimes generates more than
  > one `.stabn' directive for the same PC, but with different line
  > numbers.  For example:
  > 
  >   .stabn <line number 9>
  >   .stabn <line number 5>
  >   <code here>
  > 
  > Because GDB does not use a stable sort when sorting line tables, this
  > the labeled code ends up reported as line number 9.  In fact, GDB
  > explicitly tries to pick the line-entry with the highest line-number;
  > see `compare_line_numbers' in buildsym.c.
  > 
  > That makes little sense to me; compilers ought to put these out in the
  > right order.  There is a comment in the code indicating that IBM XCOFF
  > gets this wrong, which seems to be the motivation for this.
  > 
  > So, I can see three possible fixes:
  > 
  >   o Change GCC to not generate the first entry.
  > 
  >     (Bad if you want to set a breakpoint on that line.)
  > 
  >   o Only do the sort for IBM XCOFF.
  > 
  >   o Change GDB to use a stable sort, i.e., change compare_line_numbers
  >     to sort by PC, but not perturb the order of elements with the 
  >     same PC.
  >  
  > I like the last option best.  Any objections to such a patch?
Sounds reasonable to me.

Though I am curious, how does this happen?

I'd been thinking about cases where we'd want to emit multiple stabs with
different line numbers for the same pc value to describe certain optimizations
to the debugger but I wasn't aware that we already did this kind of stuff.

jeff


             reply	other threads:[~1999-11-29 16:59 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1999-11-29 16:59 Mark Mitchell [this message]
     [not found] ` <27496.943925188@upchuck>
1999-11-29 22:37   ` Mark Mitchell
     [not found]     ` <28295.943945638@upchuck>
1999-11-29 23:25       ` Mark Mitchell
1999-11-29 23:54         ` Timothy J. Wood

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=19991129165903H.mitchell@codesourcery.com \
    --to=mark@codesourcery.com \
    --cc=gcc@gcc.gnu.org \
    --cc=gdb@sourceware.cygnus.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