This is the mail archive of the gdb@sources.redhat.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: breakpoint setting weirdness in C++


>
> Two things strike me as weird. The first is that I cannot set a
> breakpoint in a *.h or *.i file unless I first set a breakpoint in a
> *.cpp file beforehand. The second is that when I set the breakpoint in
> the log.cpp file it did not print out the absolution pathname as it
> did for the log.h and log.i files. Any clues?

Well, I don't have any ideas of the logic inside gdb to set source
breakpoints but i've some feelings:

First it seems awkward to set brekapoint in includes file. Do they really
contains codes? Usually not but it is possible. But usually such code is
either inlined or it will be "duplicated" in each source file where it is
included. So this doesn't seems very logical. Yet I guess in C++ this
happens quite often.

Anyway, the compiler won't compile the .i or .h files but will for the .cpp
files. And so i guess that when including debugging information gcc have to
include some kind of info in each ".o"  file that include an .h. So when you
want to access some info in the ".h" file you need to know from what file it
has been included. This means you have to precise the ".c" file before.

So maybe this is what is done by gdb. When you set the breakpoint to the
source file then it have some contextual informations.

This is pure speculation of my part but that seems plausible.

You should try some tests like:

1/ Set a break in a source file and then in an unrelated include file.
2/ Set a break in a source file then in a related include file. Note the
actual adresse of the break, then try with another source file with the same
include file. And compare the actual address of the break.


Regards,

-- 
Fabrice Gautier
fabrice_gautier@sdesigns.com 


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