Author Topic: how to debug mutil-process program under linux  (Read 6100 times)

Offline nde

  • Single posting newcomer
  • *
  • Posts: 6
how to debug mutil-process program under linux
« 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
}

Offline Jenna

  • Administrator
  • Lives here!
  • *****
  • Posts: 7255
Re: how to debug mutil-process program under linux
« Reply #1 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).

Offline nde

  • Single posting newcomer
  • *
  • Posts: 6
Re: how to debug mutil-process program under linux
« Reply #2 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?

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: how to debug mutil-process program under linux
« Reply #3 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)
(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 nde

  • Single posting newcomer
  • *
  • Posts: 6
Re: how to debug mutil-process program under linux
« Reply #4 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?
« Last Edit: June 11, 2009, 10:51:59 am by nde »