Code::Blocks Forums

User forums => Using Code::Blocks => Topic started by: nde on June 10, 2009, 06:04:43 am

Title: how to debug mutil-process program under linux
Post by: nde on June 10, 2009, 06:04:43 am
pid = fork ();

if ( pid == 0 ) {
// I want to debug the code here, but the debugger never enter here
}

if ( pid > 0 ) {
// the debugger always enter here
}
Title: Re: how to debug mutil-process program under linux
Post by: Jenna on June 10, 2009, 06:55:06 am
Try to add
Code
set follow-fork-mode child
in "Settings -> Comiler and debugger ... -> Debugger settings -> Debugger initializations commands".

On linux gdb now follows the child process.

This will most likely not work on windows (referring to the gdb docs).
Title: Re: how to debug mutil-process program under linux
Post by: nde on June 10, 2009, 08:24:43 am
It really works.
Thanks a lot. :D

Further question: how to debug 2 processes in the same time?
Can I run two Codeblocks IDEs, one for debugging father process, the other for debugging son process?
Title: Re: how to debug mutil-process program under linux
Post by: oBFusCATed on June 10, 2009, 09:00:57 am
Yes, you can

Go to Settings -> Environment -> something I don't remember -> allow multiple instances.

This way you can start two c::b's and in the second one you can attach to the father process (Debug -> Attach to process menu)
Title: Re: how to debug mutil-process program under linux
Post by: nde on June 10, 2009, 11:35:25 am
Yes, you can

Go to Settings -> Environment -> something I don't remember -> allow multiple instances.

This way you can start two c::b's and in the second one you can attach to the father process (Debug -> Attach to process menu)

I start the 2nd CB IDEs,then attach to the father process.
The watches window shows "no symbol table info available".
The debug command "Next line/Next instruction/Step into/Step out" work properly.
The debug command "Start/Continue/Run to cursor" will kill the process being attached and start a new program to trace.
It looks like something wrong with the debug command "Start/Continue/Run to cursor" , or do I miss anything?