Question

Does any program compiled with the -g command have its source code available for gbd to list even if the source code files are unavailable?? Also when you set the breakpoints at a line in a program with a complicated multi source file structure do you need the names of the source code files??

Was it helpful?

Solution

OP's 1st Question:

Does any program compiled with the -g command have its source code available for gbd to list even if the source code files are unavailable??

No. If there is no path to the sources, then you will not see the source.

OP's 2nd Question:

[...] when you set the breakpoints at a line in a program with a complicated multi source file structure do you need the names of the source code files??

Not always. There are a few ways of setting breakpoints. The only two I remember are breaking on a line or breaking on a function. If you wanted to break on the first line of a function, use

break functionname

If the function lives in a module

break __modulename_MOD_functionname

The modulename and functionname should be lowercase, no matter how you've declared them in the code. Note the two underscores before the module name. If you are not sure, use nm on the executable to find out what the symbol is.

If you have the source code available and you are using a graphical environment, try ddd. It stops me swearing and takes a lot of guesswork out of gdb. If the source is available, it will show up straight away.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top