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]

Re: More than one stabn for the same PC



  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


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