How do I attatch wvideo to a forked process (Watcom)

After I’ve forked a process, how do I get wvideo to “switch” over to the
child and
allow me to continue debugging the child instead of the parent?

I have look up the child using sin and tried to wvideo its pid.
I’m using Watcom C 9.52

Any help or tips would be much appreciated.

/Anders

Anders Welin wrote:

After I’ve forked a process, how do I get wvideo to “switch” over to the
child and
allow me to continue debugging the child instead of the parent?

I have look up the child using sin and tried to wvideo its pid.
I’m using Watcom C 9.52

Any help or tips would be much appreciated.

use a second debugger session: wd … pid is the process id of the
new process.

Armin

When a connect to the child process (wvideo pid) only a blank screen
appears. No sorce code is avalible.
P.s. I’m using wvideo 9.5 not wd 10.6 D.s.

/Anders
“Armin Steinhoff” <a-steinhoff@web_.de> wrote in message
news:3CB172C2.D1DBC1C@web_.de…

Anders Welin wrote:

After I’ve forked a process, how do I get wvideo to “switch” over to the
child and
allow me to continue debugging the child instead of the parent?

I have look up the child using sin and tried to wvideo its pid.
I’m using Watcom C 9.52

Any help or tips would be much appreciated.

use a second debugger session: wd … pid is the process id of the
new process.

Armin

You have to tell wvideo the names of the symbol and source files. I don’t
remember how to do that. But you can look at the menu, I think.

“Anders Welin” <anders.welin@marine.combitech.se> wrote in message
news:a8u8s4$70a$1@inn.qnx.com

When a connect to the child process (wvideo pid) only a blank screen
appears. No sorce code is avalible.
P.s. I’m using wvideo 9.5 not wd 10.6 D.s.

/Anders
“Armin Steinhoff” <a-steinhoff@web_.de> wrote in message
news:3CB172C2.D1DBC1C@web_.de…


Anders Welin wrote:

After I’ve forked a process, how do I get wvideo to “switch” over to
the
child and
allow me to continue debugging the child instead of the parent?

I have look up the child using sin and tried to wvideo its pid.
I’m using Watcom C 9.52

Any help or tips would be much appreciated.

use a second debugger session: wd … pid is the process id of the
new process.

Armin

“Bill Caroselli (Q-TPS)” <QTPS@earthlink.net> wrote:

You have to tell wvideo the names of the symbol and source files. I don’t
remember how to do that. But you can look at the menu, I think.

wvideo :symbol_file pid

Or, you can switch to assembly view – you will then see the
assembly at the current point. Even after loading the symbols,
you won’t see anything unless you’re in assembly view – the program
is usually stopped at the start of the C initialization code, before
main() is called.

Normally, you would put a breakpoint at the start of main(), then
tell the program to continue. Then debug the new program from
main() onwards.

-David


QNX Training Services
http://www.qnx.com/support/training/
Please followup in this newsgroup if you have further questions.

His issue was looking at a process that had just fork()ed. It won’t be stoped.

If you need to STOP it, put a little delay loop right after the fork() ten you can set a break point on the instruction after the loop and terminate the loop.

In code:
pid = fork();
if( pid == 0 )
{
// this is the child
x=1;
while(x) sleep(1);
nextinstruction;

}

Then you can load wvideo with the symbol and source files, set a breakpoint on nextinstruction, and set x=0.

“David Gibbs” <dagibbs@qnx.com> wrote in message news:a8vbl3$p47$4@nntp.qnx.com

“Bill Caroselli (Q-TPS)” <> QTPS@earthlink.net> > wrote:
You have to tell wvideo the names of the symbol and source files. I don’t
remember how to do that. But you can look at the menu, I think.

wvideo :symbol_file pid

Or, you can switch to assembly view – you will then see the
assembly at the current point. Even after loading the symbols,
you won’t see anything unless you’re in assembly view – the program
is usually stopped at the start of the C initialization code, before
main() is called.

Normally, you would put a breakpoint at the start of main(), then
tell the program to continue. Then debug the new program from
main() onwards.

-David


QNX Training Services
http://www.qnx.com/support/training/
Please followup in this newsgroup if you have further questions.

“Bill Caroselli (Q-TPS)” <QTPS@earthlink.net> wrote:

His issue was looking at a process that had just fork()ed.
It won’t be stoped.

It should be.

blah.c:

printf(“fork returned %d\n”, fork());

I step over this line in wd.

I find the parent and child:

12 2981 //61/home/dagibbs/blah 10o HELD — 4096 16k
12 9185 //61/home/dagibbs/blah 10o HELD — 4096 16k

Of course, I used wd not wvideo – but I’m pretty sure the behaviour
is the same. The debugger spawns all children HELD.

When I do “wd :blah 9185”, I get control.

I put a breakpoint at the next line, then tell it to run, and it does
so.


If you need to STOP it, put a little delay loop right after the
fork() ten you can set a break point on the instruction after
the loop and terminate the loop.

In code:
pid = fork();
if( pid == 0 )
{
// this is the child
x=1;
while(x) sleep(1);
nextinstruction;

}

Ugh. If you are doing something like this, and not using the debugger
on the parent, but want to debug the child, a lot cleaner would be:

pid = fork();
if (pid == 0)
{
/* this is the child /
raise( SIGSTOP );
/
rest of child */
}

Then, you can either attach to it with the debugger – or if you
don’t want to, just "kill -s SIGCONT ", or
“slay -s SIGCONT progname” and only say yes for the child.

-David

Then you can load wvideo with the symbol and source files, set a breakpoint on nextinstruction, and set x=0.

“David Gibbs” <> dagibbs@qnx.com> > wrote in message news:a8vbl3$p47$> 4@nntp.qnx.com> …
“Bill Caroselli (Q-TPS)” <> QTPS@earthlink.net> > wrote:
You have to tell wvideo the names of the symbol and source files. I don’t
remember how to do that. But you can look at the menu, I think.

wvideo :symbol_file pid

Or, you can switch to assembly view – you will then see the
assembly at the current point. Even after loading the symbols,
you won’t see anything unless you’re in assembly view – the program
is usually stopped at the start of the C initialization code, before
main() is called.

Normally, you would put a breakpoint at the start of main(), then
tell the program to continue. Then debug the new program from
main() onwards.

-David


QNX Training Services
http://www.qnx.com/support/training/
Please followup in this newsgroup if you have further questions.


QNX Training Services
http://www.qnx.com/support/training/
Please followup in this newsgroup if you have further questions.

David Gibbs <dagibbs@qnx.com> wrote:

“Bill Caroselli (Q-TPS)” <> QTPS@earthlink.net> > wrote:
His issue was looking at a process that had just fork()ed.
It won’t be stoped.

It should be.

blah.c:

printf(“fork returned %d\n”, fork());

I step over this line in wd.

I find the parent and child:

12 2981 //61/home/dagibbs/blah 10o HELD — 4096 16k
12 9185 //61/home/dagibbs/blah 10o HELD — 4096 16k

Of course, he was using wvideo instead of wd. wd creates the children
HELD, wvideo does not.

If you need to STOP it, put a little delay loop right after the
fork() ten you can set a break point on the instruction after
the loop and terminate the loop.

So, yes with wvideo you need something to stop the child.

In code:
pid = fork();
if( pid == 0 )
{
// this is the child
x=1;
while(x) sleep(1);
nextinstruction;

}

But, I still like raise(SIGSTOP) better. :slight_smile:

-David

QNX Training Services
http://www.qnx.com/support/training/
Please followup in this newsgroup if you have further questions.

I didn’t know that the parent and child would be HELD after the fork().

Even so, your SIGSTOP method is much cleaner.

I actually have my own methods for debugging real-time apps and rarely use
the debugger.

Thanks Dave

“David Gibbs” <dagibbs@qnx.com> wrote in message
news:a8vntj$43r$1@nntp.qnx.com

“Bill Caroselli (Q-TPS)” <> QTPS@earthlink.net> > wrote:
His issue was looking at a process that had just fork()ed.
It won’t be stoped.

It should be.

blah.c:

printf(“fork returned %d\n”, fork());

I step over this line in wd.

I find the parent and child:

12 2981 //61/home/dagibbs/blah 10o HELD — 4096 16k
12 9185 //61/home/dagibbs/blah 10o HELD — 4096 16k

Of course, I used wd not wvideo – but I’m pretty sure the behaviour
is the same. The debugger spawns all children HELD.

When I do “wd :blah 9185”, I get control.

I put a breakpoint at the next line, then tell it to run, and it does
so.


If you need to STOP it, put a little delay loop right after the
fork() ten you can set a break point on the instruction after
the loop and terminate the loop.

In code:
pid = fork();
if( pid == 0 )
{
// this is the child
x=1;
while(x) sleep(1);
nextinstruction;

}

Ugh. If you are doing something like this, and not using the debugger
on the parent, but want to debug the child, a lot cleaner would be:

pid = fork();
if (pid == 0)
{
/* this is the child /
raise( SIGSTOP );
/
rest of child */
}

Then, you can either attach to it with the debugger – or if you
don’t want to, just "kill -s SIGCONT ", or
“slay -s SIGCONT progname” and only say yes for the child.

-David

Then you can load wvideo with the symbol and source files, set a
breakpoint on nextinstruction, and set x=0.

“David Gibbs” <> dagibbs@qnx.com> > wrote in message
news:a8vbl3$p47$> 4@nntp.qnx.com> …
“Bill Caroselli (Q-TPS)” <> QTPS@earthlink.net> > wrote:
You have to tell wvideo the names of the symbol and source files. I
don’t
remember how to do that. But you can look at the menu, I
think.

wvideo :symbol_file pid

Or, you can switch to assembly view – you will then see the
assembly at the current point. Even after loading the symbols,
you won’t see anything unless you’re in assembly view – the program
is usually stopped at the start of the C initialization code, before
main() is called.

Normally, you would put a breakpoint at the start of main(), then
tell the program to continue. Then debug the new program from
main() onwards.

-David


QNX Training Services
http://www.qnx.com/support/training/
Please followup in this newsgroup if you have further questions.

\

QNX Training Services
http://www.qnx.com/support/training/
Please followup in this newsgroup if you have further questions.