This is the mail archive of the gdb@sourceware.cygnus.com mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

More than one stabn for the same PC



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

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]