User forums > Using Code::Blocks
how to debug mutil-process program under linux
(1/1)
nde:
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
}
Jenna:
Try to add
--- Code: ---set follow-fork-mode child
--- End code ---
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).
nde:
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?
oBFusCATed:
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)
nde:
--- Quote from: 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)
--- End quote ---
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?
Navigation
[0] Message Index
Go to full version