News:

Accounts with zero posts and zero activity during the last months will be deleted periodically to fight SPAM!

Main Menu

how to debug mutil-process program under linux

Started by nde, June 10, 2009, 06:04:43 AM

Previous topic - Next topic

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 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).

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)
(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!]

nde

#4
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)

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?