473,387 Members | 1,844 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

debugging child threads

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

Aug 2 '06 #1
2 1961
sunil <su*******@gmail.comwrote:
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.

--
C. Benson Manica | I *should* know what I'm talking about - if I
cbmanica(at)gmail.com | don't, I need to know. Flames welcome.
Aug 2 '06 #2
"sunil" <su*******@gmail.comwrites:
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/curren...b_6.html#SEC45

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

good luck,

r.
>
#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
--
Lint early. Lint often.
Aug 3 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Manisha | last post by:
Hi, I am creating a C++ dll which is used to process data passed to it through one of its exported functions. It should be able to process 160 simultaneous requests. For this reason, I have...
23
by: Jeff Rodriguez | last post by:
Here's what I want do: Have a main daemon which starts up several threads in a Boss-Queue structure. From those threads, I want them all to sit and watch a queue. Once an entry goes into the...
3
by: Development | last post by:
I am creating 10 threads that do ecatly the same thing. I am having a very hard time debugging this scenario. It seems that by default when you are doing f10 or f11 all threads execute. You can...
4
by: Bonj | last post by:
Further to my last post, I have managed to get a child window to display. But its messages are routed to the same WNDPROC that the main window's messages are routed to - what is the way of...
4
by: Bruno van Dooren | last post by:
Hi, i was debugging a multithreaded app, when i stumbled across some weird behavior of the debugger. in the destructor of my main object i send a stop event to the worker thread, and then...
16
by: Serdar Kalaycý | last post by:
Hi everybody, My problem seems a bit clichè but I could not work around. Well I read lots of MSDN papers and discussions, but my problem is a bit different from them. When I tried to run the...
10
by: Doug Robertson | last post by:
First off, I'm a hardware/OS guy. I just write code on the side and I'm completely self taught - so bear in mind my total lack of expertise. I have a program originally written in VB2003 using...
1
by: james_w77 | last post by:
I am trying to use Peter's StoppableThread(threading.Thread). What I want to do is to start 5 child threads, then do something, then when got ^C keyboard exception, stop the child thread. For...
8
by: Jim B. Wilson | last post by:
I have the mother (of all) application(s, written in C++) that occasionally outsources certain tasks to a child Python script. The mother fork/execs (or equivalent) the child and then begins...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.