Author Topic: How to set custom source search path when debugging?  (Read 5969 times)

Offline Calmarius

  • Multiple posting newcomer
  • *
  • Posts: 32
How to set custom source search path when debugging?
« 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.

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: How to set custom source search path when debugging?
« Reply #1 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.
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5917
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: How to set custom source search path when debugging?
« Reply #2 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) have this file already, but I'm not sure when it will be put in gdb cvs HEAD.


 
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

Offline Jenna

  • Administrator
  • Lives here!
  • *****
  • Posts: 7255
Re: How to set custom source search path when debugging?
« Reply #3 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"

Offline Calmarius

  • Multiple posting newcomer
  • *
  • Posts: 32
Re: How to set custom source search path when debugging?
« Reply #4 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.

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5917
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: How to set custom source search path when debugging?
« Reply #5 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.
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.