Re: Function supposedly in multiple locations

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Amittai Aviram <amittai.aviram.0@xxxxxxxxx> writes:

> I am using GDB to debug a C program I compiled with GCC 4.6.2.  My program has a function called "foo."  When I insert a breakpoint at foo, GDB reports "2 locations."  On "info break," GDB shows that the two locations are two instruction lines but the same source code line.  When I look at the objdump disassembly of my program, I see that the first of the two locations is the first instruction in foo, while the second instruction is simply another instruction further down in foo.  Why am I seeing this?  I'm presuming that GCC with the -g flag must have inserted two entries for foo, one at its beginning and one at its 23rd instruction 80 bytes later.  If that is correct, why would GDB do this?  Thanks!

This is normal behaviour when optimizing.  Statements are often
implemented by non-adjacent instructions.  It's rarely clear what the
best debugging behaviour is in such a case.  GCC normally will annotate
each instruction with the source line that it corresponds to.  I guess
your version of GDB will set breakpoints on each instruction annotated
that way.

Ian


[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux