Reputation: 19759
I think this may have been asked earlier but i can't find one that satisfied my requirements.
I am debugging(infact trying to understand) a large project by trying to analyze the code flow in various testsuites. But when i try to set breakpoints at some files, i get the error "no source file named filename found".
So my question is:
b filename:*
Any insights are more than welcome.
Edit
I checked these issues with some hello world code and found same results as pointed out in one of the answers.but my issue in the actual project still remains on. I still get the same error even when i can see the edited output of the same line which is not accepted as a breakpoint.
Edit 2
I got it working but don't understand how and why it works..??
(gdb) b /home/neeraj/BTP/trunk/include/header.h:872
No source file named /home/neeraj/BTP/trunk/include/header.h:872
Make breakpoint pending on future shared library load? (y or [n]) n
(gdb) b /home/neeraj/BTP/trunk/src/driver.cpp:2
Breakpoint 1 at 0x806c61a: file ../../../trunk/src/driver.cpp, line 2.
(gdb) b /home/neeraj/BTP/trunk/include/header.h:872
Breakpoint 2 at 0x8052fa0: file ../../../trunk/include/header.h:872, line 872.
(gdb)
Any deeper insights..?
Upvotes: 3
Views: 14227
Reputation: 202505
The other thing to beware of besides shared libraries is that gdb
source file names are relative to the directory where the code was compiled. If you haven't compiled with absolute pathnames, use the dir
command to add the compilation directory to the list of places gdb
searches for source code.
And a hint: I find I am wildly more productive when I use the Data Display Debugger (DDD) graphical front end to gdb
.
Upvotes: 7
Reputation: 6417
Make sure you compile with -g (debug) option. Make sure the sourcepaths are set correctly. Use directory, show directories and dir commands to see/set.
Upvotes: 8