gdb to child process


 
Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users gdb to child process
# 1  
Old 12-07-2005
gdb to child process

Hi,

I want to debug a child process which is forked from other process.
Whenever I try to attach the pid of child process to gbd, the
process gets killed and the parent process starts a new child process.

any idea what could be the reason.
In general how can i debug a child process with gdb.

thanks in advance.

-Ashish
# 2  
Old 12-07-2005
Basically you have to pause the child, get it's pid, then have gdb attach to it.

See:
http://www.cs.ust.hk/~keithlau/Pilot...16/gdb_26.html
# 3  
Old 12-08-2005
gdb to child process

thanks for your help.

I tried to place sleep in child process. But the child process exec another
process. I tried to keep sleep at the start od execed program too, but it get defuncted immediately after I attach the pid to gdb.
Any pointers in this direction,

thanks in advance,
# 4  
Old 12-09-2005
Try creating a signal handler in the "second" child. Have it wait forever for a user defined signal like SIGUSR1 for example.

The idea is to prevent the process from doing anything until you have attached to it.
# 5  
Old 12-12-2005
Jim,
thanks for ur help.

I am able to attach the pid of child process to gdb (by putting sleep in main) . But it(child) gets defuncted in a while and my parent process starts a new child process.
Parent process uses a hell lot of threads and might be that is causing the problem.
Jim, I wish u would sit beside me and tell these fundas in depth :-).

Any pointers in this direction would help.

Thanks in advance.
-Ashish
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

forking a child process and kill its parent to show that child process has init() as its parent

Hi everyone i am very new to linux , working on bash shell. I am trying to solve the given problem 1. Create a process and then create children using fork 2. Check the Status of the application for successful running. 3. Kill all the process(threads) except parent and first child... (2 Replies)
Discussion started by: vizz_k
2 Replies

2. Emergency UNIX and Linux Support

signal between parent process and child process

Hello, everyone. Here's a program: pid_t pid = fork(); if (0 == pid) // child process { execvp ...; } I send a signal (such as SIGINT) to the parent process, the child process receive the signal as well as the parent process. However I don't want to child process to receive the... (7 Replies)
Discussion started by: jackliang
7 Replies

3. Shell Programming and Scripting

script to get child process for a process

!/bin/sh pid=$(ps -Aj | grep MSTRSvr | grep -v grep | awk '{print $1}') sid=$(ps -Aj | grep MSTRSvr | grep -v grep | awk '{print $3}') ps -s "$sid" I am not able to get the desired output it says process list error if i use watch ps -s "$sid" it considers only the first session id (5 Replies)
Discussion started by: schippada
5 Replies

4. Shell Programming and Scripting

[KSH/Bash] Starting a parent process from a child process?

Hey all, I need to launch a script from within 2 other scripts that can run independently of the two parent scripts... Im having a hard time doing this, if anyone knows how please let me know. More detail. ScriptA (bash), ScriptB (ksh), ScriptC (bash) ScriptA, launches ScriptB ScirptB,... (7 Replies)
Discussion started by: trey85stang
7 Replies

5. Shell Programming and Scripting

Child Process Name

Hi , I want to find out the child process name given its PID. I have used the ps command but it displays the parent process name against child PID. Is there any way to find out name of child program executing under any parent program? (1 Reply)
Discussion started by: sneha_heda
1 Replies

6. Shell Programming and Scripting

How to make the parent process to wait for the child process

Hi All, I have two ksh script. 1st script calls the 2nd script and the second script calls an 'C' program. I want 1st script to wait until the 'C' program completes. I cant able to get the process id for the 'C' program (child process) to make the 1st script to wait for the second... (7 Replies)
Discussion started by: sennidurai
7 Replies

7. Programming

Debug two process Using GDB

Hi All I know How to attach a process to beubg it .But for my application I am using client as well server.Both are two separate process .Suppose I need to debug both .How to attach both of them together .Or I have to attach them separetly . Suppose client process id is 1325 and server is... (2 Replies)
Discussion started by: mr_deb
2 Replies

8. Programming

Debugging a running process in GDB

Hi , Any gdb user could see my problem. Let me describe what i want to do. i have a test utility to send message to running process. My interest is to go through to functions calls when my test case starts. In a simple way i want have a code walk for a particular scenario of a test... (1 Reply)
Discussion started by: meet123321
1 Replies

9. UNIX for Advanced & Expert Users

How to prevent gdb to send Interrupt signals to child processes

Hi, I have a program which invokes child processes and communicates with the processes. When I run the program under gdb and say interrupt, all the child processes are dying. Here I am not interested in debugging the child processes. But I don't want my child processes to be killed as my parent... (2 Replies)
Discussion started by: klnarayana
2 Replies

10. UNIX for Dummies Questions & Answers

about child process

hello every one, i want to know more about creation of child process. UNDER WHAT CIRCUMSTANCES child process is created? WHAT ARE THE PREREQUISITES for a child process to be created? let us say we have a prog.c, prog.obj(compiled.c),.a\.out files. is any child PROCESS CREATED... (12 Replies)
Discussion started by: compbug
12 Replies
Login or Register to Ask a Question