Code::Blocks Forums

User forums => Using Code::Blocks => Topic started by: Azra on February 17, 2008, 02:54:28 pm

Title: gdb doesn't find sources ( No source file named...)
Post by: Azra on February 17, 2008, 02:54:28 pm
I've got a problem with the gdb debugger

It tells me, that it can't find the source file, if I try to set a breakpoint

Code
No source file named L:/CodeBlocks/Projects/Irr_02/Game.h.
Breakpoint 1 ("L:/CodeBlocks/Projects/Irr_02/Game.h:38) pending.

I've activated debugging symbols in the Compiler Options, whats the problem Oo
Title: Re: gdb doesn't find sources ( No source file named...)
Post by: Jenna on February 17, 2008, 03:11:27 pm
Which gdb-version ?
Code
gdb -v

I had a similar problem on W2K and XP with gdb 6.5.
I upgraded to 6.6 and everything is ok.
Title: Re: gdb doesn't find sources ( No source file named...)
Post by: Azra on February 17, 2008, 03:33:51 pm
6.7.50.20071127
Title: Re: gdb doesn't find sources ( No source file named...)
Post by: Jenna on February 17, 2008, 03:46:26 pm
I just saw that you put the breakpoint into a header file, that does not work.
Title: Re: gdb doesn't find sources ( No source file named...)
Post by: Azra on February 17, 2008, 03:59:30 pm
Oh :shock:, thanks.  :)

But I've got one little question: why?  :?
Title: Re: gdb doesn't find sources ( No source file named...)
Post by: thomas on February 17, 2008, 05:29:51 pm
I just saw that you put the breakpoint into a header file, that does not work.
Huh? I do the like all the time, why shouldn't that work?

The only thing that confirmedly doesn't work (to my knowledge) is putting breakpoints in constructors (limitation of gdb).
Title: Re: gdb doesn't find sources ( No source file named...)
Post by: nenin on February 17, 2008, 05:51:41 pm
I just saw that you put the breakpoint into a header file, that does not work.
Huh? I do the like all the time, why shouldn't that work?

The only thing that confirmedly doesn't work (to my knowledge) is putting breakpoints in constructors (limitation of gdb).
It is very odd, but in some cases GDB can not find headers. It was like that, and it do not changes  for me when I move from Dev-C++ to C::B (it was main reason  :D ). Than I move to GDB 6, than to gcc 4, now to gcc with dwarf2... but breakpoint in some headers still are "pending". IMHO, problem is derived from directories project structure. If project has some headers in sub-directories, it is very likely than breakpoints in this files will be lost. I use defines with stub functions to catch breaks.   
Title: Re: gdb doesn't find sources ( No source file named...)
Post by: erSitzt on February 17, 2008, 05:54:20 pm
I had this problem too, but with breakpoints in the cpp files and i also had problems with the debugger starting the wrong build target.

But breakpoints in the constructor are working for me.
Title: Re: gdb doesn't find sources ( No source file named...)
Post by: Jenna on February 17, 2008, 06:01:48 pm
I just saw that you put the breakpoint into a header file, that does not work.
Huh? I do the like all the time, why shouldn't that work?

The only thing that confirmedly doesn't work (to my knowledge) is putting breakpoints in constructors (limitation of gdb).

You're partly right.

If the .h-file has (for example) a function in it, it works if the breakpoint is on a declaration, that is before the function or in the function itself.
But if a breakpoint is put into a header after any executable code or in a header withoutout any executable code (just declarations) you get exactly the errormessage the OP had.

By the weay I put breakpoints into my class-constructors and gdb has no problems to stop there.
Title: Re: gdb doesn't find sources ( No source file named...)
Post by: thomas on February 17, 2008, 07:08:52 pm
About the constructor thing I am not sure, it may either that either the model was changed in gcc 4.x or the more recent gdb contains a kind of workaround.
The reason why breakpoints on constructors do/did not work is that gcc 3.x always emits two separate constructors, and gdb can't figure out which one to break in. So it is kind of normal, rather than a bug.

If this works for you now, then that's good news (and a sign that I should soon update my compiler/debugger). :)
Title: Re: gdb doesn't find sources ( No source file named...)
Post by: Belgabor on February 18, 2008, 08:11:41 pm
I had this problem too, but with breakpoints in the cpp files and i also had problems with the debugger starting the wrong build target.

I also had that problem and figured out that (at last in my case) the problem was that my release and debug binary differed by " d" (and were in the same directory). The space seems to throw something off, CB reliably started my release binary claiming happily it was the debug target. As soon as I removed the space (ie just added "d" for the debug binary), everything worked as it should.
Title: Re: gdb doesn't find sources ( No source file named...)
Post by: lapique on April 02, 2008, 05:35:32 pm
I have the same problem since I moved some files :
projdir\src --> projdir\..\common\src
projdir\include --> projdir\..\common\include

When I manually run gdb in a DOS shell and type "directory projdir\..\common\src" and set the same breakpoint manually, it DOES work.

So, the problem is that C::B does not actually add source directories as it should (and as it claims it does) !
Title: Re: gdb doesn't find sources ( No source file named...)
Post by: killerbot on April 02, 2008, 06:14:19 pm
About the constructor thing I am not sure, it may either that either the model was changed in gcc 4.x or the more recent gdb contains a kind of workaround.
The reason why breakpoints on constructors do/did not work is that gcc 3.x always emits two separate constructors, and gdb can't figure out which one to break in. So it is kind of normal, rather than a bug.

If this works for you now, then that's good news (and a sign that I should soon update my compiler/debugger). :)
no idea if gcc4.x or latest gdb, but it does work for some time now : breakpoints in the constructor
Title: Re: gdb doesn't find sources ( No source file named...)
Post by: lobby on April 16, 2008, 12:03:17 am
i had the same problem, it happened after i have moved the project folder (like lapique),
i tried to rebuild many times etc... but it didn't work.

After a while, i have deleted the obj directory (containing debug and release directories for object files)
and after the rebuild, all was fixed.

I don't know exactly if that was a bug or not (i think it was), the only thing i changed in my project, is that the debug and release .exe file ouput in the same directory.

Title: Re: gdb doesn't find sources ( No source file named...)
Post by: lobby on April 16, 2008, 01:58:46 am
i tried to move headers in another folder in a "../" directory, and i get the bug back :/
deleting obj directory don't change anything that time, i really have no idea how it has been fixed the first
time.

the strange thing is that i have other projects with some includes in "../" and it works fine, maybe because i have never moved those headers since projects have been created or something like that

someone have an idea to locate/fix the bug ?

Title: Re: gdb doesn't find sources ( No source file named...)
Post by: MortenMacFly on April 16, 2008, 08:33:30 am
someone have an idea to locate/fix the bug ?
Did you foget to re-compile your project after you have moved the header files?!
Title: Re: gdb doesn't find sources ( No source file named...)
Post by: lobby on April 16, 2008, 03:18:22 pm
i did a build=>clean then rebuild and that's not working (project compile fine but still breakpoint in header problem)
i tried to move headers in some other directories:

/myproject/macro/   => doesn't work (gdb: no file named etc...)
/myproject/src/       => same directory as source files, it works
/myproject/src/new  => another directory included in the src directory, it works

note:
#include "new/header.h" works
#include "../src/new/header.h" works only after clean/rebuild (not with simple build)

i didn't use my project since few weeks, but before #include "../macro/header.h" worked without problem
and the only change i think i have done is moving the entire project directory somewhere else

Title: Re: gdb doesn't find sources ( No source file named...)
Post by: lobby on April 21, 2008, 04:54:24 am
i have read the topic about this "bug":
http://forums.codeblocks.org/index.php/topic,4850.msg38322.html

since its a gdb issue, there is 2 things that can make things work:
-setting breakpoints using the filename only, the problem is that if there is 2 identical files in the project, gdb set break on the first he'll find

-using "info sources" command to find the proper file path that gdb use
 it is not very clean but will work perfectly (and only breaks that return "no source file named etc.." will do that)

i have read that the last one was the best solution for gui, i don't know how others handle that but that would be nice to get it work properly :)

i hope there is no more problems like that with the last versions of gdb, it's disapointing to see this debugger having that kind of issue ;(