Code::Blocks Forums

User forums => Using Code::Blocks => Topic started by: Calmarius on July 25, 2012, 01:46:18 pm

Title: How to set custom source search path when debugging?
Post by: Calmarius on July 25, 2012, 01:46:18 pm
I'm using CB to compile, debug and develop our company's product using a custom makefile. The source code is somewhere else, not next to the project. Everything is working fine, but
when try to use the Call stack and click on a frame to open source file, it cannot find it because it tries to find the sources relative to the project directory, not at the actual source directory.

Is there way to set custom source directories somehow? (All directory settings seems to affect the compiler tools not the IDE.)

The only rough workaround is making symbolic links to these source directories.
Title: Re: How to set custom source search path when debugging?
Post by: oBFusCATed on July 25, 2012, 03:13:32 pm
Unfortunately, you can't.

But you can modify your makefile to use full paths, so they will be embedded in the debug info and probably gdb will use full paths instead of relative paths, when generating the backtraces.
Title: Re: How to set custom source search path when debugging?
Post by: ollydbg on July 25, 2012, 04:34:31 pm
I have the same issue when debug into a wxwidgets-debug-dll.

1, gdb's bt command will return the file-name which is used when you build the target. I mean: if you makefile have some command:
Code
gcc ../c/a.cpp 
then bt will return something like
Code
../c/a.cpp:line_number
if you use some absolute file-name, like
Code
gcc /f/a.cpp
then bt will return the same absolute file-name.

2, I believe that our C::B can only handle two situations:
2.1, the returned file path is an absolute file path, so c::b can locate and open the file.
2.2, when a relative file path is returned from bt command, c::b try to locate the file relative to the project file(cbp file). This is your case, then c::b failed to locate the real file.

3, there is a solution:
There is a patch for gdb which can let the "bt" command return three type of filenames: basename, absolute-name, relative-name, see:
http://sourceware.org/ml/gdb-patches/2012-04/msg00106.html
Then you can let the gdb to handle this case, and gdb can always return the absolute-name. By use the command:
Code
set backtrace filename-display absolute

My build of gdb (see: [OT] unofficial MinGW GDB gdb with python released (http://forums.codeblocks.org/index.php/topic,11301.msg77000.html#msg77000)) have this file already, but I'm not sure when it will be put in gdb cvs HEAD.


 
Title: Re: How to set custom source search path when debugging?
Post by: Jenna on July 25, 2012, 04:54:42 pm
What works for me (if debugging into wxwidgets for example) is to add
Code
--directory=/path/to/the/root/of/the/build/directory
as argument for my gdb-debugger in "Settings -> Debugger -> GDB/CDB debugger -> [the debugger I use] -> Arguments"
Title: Re: How to set custom source search path when debugging?
Post by: Calmarius on July 26, 2012, 03:55:57 pm
It works fine when I switch frames, but double clicking on the frame ("jump to this frame") still cannot open the source file.

It would be nice to be able to set these external source paths in the IDE in the future.
Title: Re: How to set custom source search path when debugging?
Post by: ollydbg on July 26, 2012, 04:22:32 pm
It works fine when I switch frames, but double clicking on the frame ("jump to this frame") still cannot open the source file.

Can you enable the "debugger log" (In debugger plugin setting dialog), then paste all the debug session log message here. Thanks.