Author Topic: Current directory when debugging with GDB  (Read 6029 times)

Offline Folco

  • Regular
  • ***
  • Posts: 343
    • Folco's blog (68k lover)
Current directory when debugging with GDB
« on: June 02, 2010, 06:21:19 pm »
Hi all,

First, my config : Debian Lenny 32 bits, C::B svn 6297, packages by Jens.

I currently get a Segfault when running one of my programs. It happens when doing a strlen.
I have specified the "executing working directory" in "Project > Properties > Build target" (for both Release and Debug targets).
The default path work when I run my program with "Run" or "Build and run" icons.
But when I use "Run to cursor" to debug my program, the "executing working directory" doesn't seem to be handled, so my program terminates because it hasn't found an image which it has to load : an exception occurs, I handle it and close the program.

But this occur before the Segfault, so I can't see when it occurs !

The question is : How could I specify the "executing working directory" for GDB ? Without that, I can't debug my program. :(
Kernel Extremist - PedroM power ©

Offline Folco

  • Regular
  • ***
  • Posts: 343
    • Folco's blog (68k lover)
Re: Current directory when debugging with GDB
« Reply #1 on: June 02, 2010, 06:37:20 pm »
BTW : I just found my bug (giving NULL to a string constructor, so strlen tried to work at a NULL adress...).
Nevertheless, I'm always interested in having a way to solve my problem. :)
Kernel Extremist - PedroM power ©

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13406
    • Travis build status
Re: Current directory when debugging with GDB
« Reply #2 on: June 02, 2010, 07:05:58 pm »
Memory errors are easier to catch with valgrind...

Can you give us the debugger's log?

Settings -> Compiler & Debugger -> Debugger -> Show debugger's debug log
(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 Folco

  • Regular
  • ***
  • Posts: 343
    • Folco's blog (68k lover)
Re: Current directory when debugging with GDB
« Reply #3 on: June 02, 2010, 08:43:16 pm »
The debugger log doesn't seem to help me a lot :
Quote
Building to ensure sources are up-to-date
Build succeeded
Selecting target:
Debug
Adding source dir: /mnt/Data/Programmation/PC/FPG2 cpp/src/
Adding source dir: /mnt/Data/Programmation/PC/FPG2 cpp/src/
Changing directory to: "../../FPG2 cpp"
Adding file: bin/Debug/FPG2
Starting debugger:
done
Registered new type: wxString
Registered new type: STL String
Registered new type: STL Vector
Setting breakpoints
Debugger name and version: GNU gdb 6.8-debian
Child process PID: 7779
Program exited with code 01.
Debugger finished with status 0
But thanks for valgrind, I'll look at it. I usually use it just to know if my programs don't leak memory.
Kernel Extremist - PedroM power ©

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13406
    • Travis build status
Re: Current directory when debugging with GDB
« Reply #4 on: June 02, 2010, 11:28:15 pm »
The log string you've posted is from the normal debugger's plugin log.
There is another one, but is not enabled by default, go here to enable it:
Settings -> Compiler & Debugger -> Debugger -> Show debugger's debug log

Valgrind is way more powerful than that :)
(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!]