debugging child threads

S

sunil

Hi All,
I am tring to debug the following program.I written this
program in HP-Unix and I am using the GDB as a debugger.

#include <stdio.h>
#include<unistd.h>
int main()
{
int pid;
pid = fork();
if(pid == 0)
{
printf("I am the child process,my processid is\t
%d\n",getpid());
printf("I am the child's parent process,my processid
is\t %d\n",getppid());
sleep(20);
printf("I am the child process,my processid is\t
%d\n",getpid());
printf("I am the child's parent process,my processid
is\t %d\n",getppid());
}
else
{
printf("I am the parent process,my processid is\t
%d\n",getpid());
printf("I am the parent's parent process,my processid
is\t %d\n",getppid());
}
}

While debugging using any debugger by default it will take only
parent process to debug.If u want to debug the child process we have to
use the "info threads" command and get the thread numbers.
And we have to switch to the child thread,this is what the
general procedure is.
But in my case it is showing only one entry after executing the
info threads command,I executed this command after the if loop.
Could anybody suggest how to trap that child thread and how to
debug that process.i put the break point at the if loop.If anybody
couldn't get it plz revert back to me.

Regards
Sunil
 
C

Christopher Benson-Manica

sunil said:
I am tring to debug the following program.I written this
program in HP-Unix and I am using the GDB as a debugger.

(snip question relating to threads)

(This question is better suited for a different newsgroup, possibly
comp.unix.programmer or comp.programming.threads.)

Your post is off-topic for comp.lang.c. Please visit

http://www.ungerhu.com/jxh/clc.welcome.txt
http://c-faq.com
http://benpfaff.org/writings/clc/off-topic.html

for posting guidelines and frequently asked questions. Thank you.
 
R

Richard

sunil said:
Hi All,
I am tring to debug the following program.I written this
program in HP-Unix and I am using the GDB as a debugger.

Hi sunil,

You've already been informed that this is Off Topic here : but I just
happened to be reading something recently which might help you.

It can be confusing. But gdb stops all execution of all
threads at a break. See here for further info:

http://sources.redhat.com/gdb/current/onlinedocs/gdb_6.html#SEC45

I'm assuming you DID set a breakpoint at if(pid==0) ?

good luck,

r.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top