Debugging a running process in GDB


 
Thread Tools Search this Thread
Top Forums Programming Debugging a running process in GDB
# 1  
Old 02-19-2009
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 case.
The process say p21 is running .
now i execute a testcase .
p21 do message handling ...(whatever).

I want to use gdb to see , what all functions are called during the test.

I do not have the idea to do it.

I came to know something like.

run gdb // this i have done
attach the process id to the gdb
attach <pid of p21> // this i have done

next i m hung up , what to do next.

Could some one gdb user help me out


Thanks a lot.
Aki
# 2  
Old 02-19-2009
you should read some good manual to use gdb.
By the way if you want to debug the program my_program because of a seg fault for instance you can do this :


Code:
// Don't forget to add the -ggdb option at compilation
$ gcc -c -ggdb my_program.c
$ gcc -o my_program my_program.o
$ gdb ./my_program
//some useless text
(gdb) r
// r means run, it launch the program.
// now say the program fails because of a seg fault 
(gdb) bt
// bt means backtrace, it will print on the screen the call tree until the error

else you can go step by step, by replacing r by s. you can also put some breakpoint.
you should type this :
Code:
 (gdb) help
 // it will print some section
 (gdb) help section
// more information about the sections

if you want something visual you can use ddd.

but i repeat, there is some usefull manual all over the Internet.
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Programming

Best guide or video for gdb <register level debugging>

would like to know best guide or document for gdb for different architectures x86 , power pc etc.. would like to understand how to debug segmentation faults because of stack corruption .. understand utilities ELF , objdump etc.. please guide me (1 Reply)
Discussion started by: Gopi Krishna P
1 Replies

2. Programming

64 bit code debugging using gdb and ddd

Hello I have built our application on AIX 7.1 as a 64 bit application. My queries are as follows: Can a 32bit gdb (v7.6) and ddd (data display debugger - v3.3.12), debug a 64bit executable ? If I have a small 64bit a.exe executable that seems to work. If I have a more complicated executable... (4 Replies)
Discussion started by: biju64
4 Replies

3. Red Hat

Gdb error while debugging core file

Hi, I am trying to analyze one core file on my RHEL 6.5, but I am getting below error related to the core file. So I am not getting any stack trace about the crash. # gdb MyDebugBin /var/core/MyDebugBin.27005 GNU gdb (GDB) Red Hat Enterprise Linux (7.2-60.el6_4.1) Copyright (C) 2010 Free... (2 Replies)
Discussion started by: sanzee007
2 Replies

4. UNIX for Dummies Questions & Answers

GDB Debugging Problem

I have added some code in my file. I have created executable rpm file of our code and also I have created debuginfo and debugsource files and installed all three. But when I debug in gdb I see the the code changes in soucre file. But the break point does not hit at that place as if it did not... (1 Reply)
Discussion started by: rupeshkp728
1 Replies

5. Shell Programming and Scripting

debugging the shell script with out actually running

Hello, Some one asked me in the inteview.... The question is, How do we debug the schell script before even running..... Interviewer told me one clue... There is SET command to accomplish this... Can any one tell me what kind of set commands.... Thanks. (2 Replies)
Discussion started by: govindts
2 Replies

6. 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

7. UNIX for Advanced & Expert Users

debugging an already running bash script

# ps -ef | grep rc root 13903 1 0 08:56 ? 00:00:00 /usr/sbin/automount --timeout=60 /archive file /etc/auto_archive root 10706 1 0 08:55 ? 00:00:00 /bin/bash /etc/rc.d/rc 3 root 2933 20071 0 19:38 pts/1 00:00:00 grep rc Is there any way to debug the... (1 Reply)
Discussion started by: marcpascual
1 Replies

8. Programming

Debugging 64bit code with gdb and ddd in AIX

I'm trying to use the GDB debugger and DDD to debug 64bit code. It seems that the AIX toolkit gdb version 6.0 works with 64bit code. But the ddd tool when running gdb gives the following errors : Starting program: <my binary> <my params> warning: "": not in executable format: There is an input... (2 Replies)
Discussion started by: bean66
2 Replies

9. UNIX for Advanced & Expert Users

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... (4 Replies)
Discussion started by: shriashishpatil
4 Replies
Login or Register to Ask a Question