wd to debug a program spawn a process

Hi there,

How do I use the watcom debugger to debug a program which has spawned a
process? The problem now is that every time I use wd to debug my program, it
hangs there and that’s because in my program I have spawned a new process.

Thanks!

Teresa

Teresa Tao <ttao@neontech.com> wrote:

Hi there,

How do I use the watcom debugger to debug a program which has spawned a
process? The problem now is that every time I use wd to debug my program, it
hangs there and that’s because in my program I have spawned a new process.

This can be done… I just have to remember how…

Usually, what happens is that wd won’t takeover the child or automatically
split, but the child will be spawned in the HELD state. You should then
invoke another instance of wd, giving it the pid of the child, and it
will take over control of the child. You can now control the parent and
the child independently. The parent may not be continuing depending on
what parameters you gave to the spawn(), do you choose P_WAIT or
P_NOWAIT?

-David

In article <8t25qq$cva$4@nntp.qnx.com>, dagibbs@qnx.com says…

Teresa Tao <> ttao@neontech.com> > wrote:
Hi there,

How do I use the watcom debugger to debug a program which has spawned a
process? The problem now is that every time I use wd to debug my program, it
hangs there and that’s because in my program I have spawned a new process.

This can be done… I just have to remember how…

Usually, what happens is that wd won’t takeover the child or automatically
split, but the child will be spawned in the HELD state. You should then
invoke another instance of wd, giving it the pid of the child, and it
will take over control of the child. You can now control the parent and
the child independently. The parent may not be continuing depending on
what parameters you gave to the spawn(), do you choose P_WAIT or
P_NOWAIT?

-David

When we spawn, we set SPAWN_HELD option if debugging is enabled (NDEBUG not
defined).

Previously, David Gibbs wrote in comp.os.qnx:

Teresa Tao <> ttao@neontech.com> > wrote:
Hi there,

How do I use the watcom debugger to debug a program which has spawned a
process? The problem now is that every time I use wd to debug my program, it
hangs there and that’s because in my program I have spawned a new process.

This can be done… I just have to remember how…

Usually, what happens is that wd won’t takeover the child or automatically
split, but the child will be spawned in the HELD state. You should then
invoke another instance of wd, giving it the pid of the child, and it
will take over control of the child. You can now control the parent and
the child independently. The parent may not be continuing depending on
what parameters you gave to the spawn(), do you choose P_WAIT or
P_NOWAIT?

-David

I’ve been using a less sophisticated way to do this. Instead of spawning the child program, I spawn a shell script that runs wd on the child program. It’s easy to change back when debugging is finished.

  • Pete