Visit the LQ Articles and Editorials section
Go Back > Forums > Linux Forums > Linux - Desktop
User Name
Linux - Desktop This forum is for the discussion of all Linux Software used in a desktop context.


  Search this Thread
Old 10-11-2006, 11:03 PM   #1
LQ Newbie
Registered: Sep 2006
Posts: 27

Rep: Reputation: 15
attach gdb to a running process

i am a newman for linux and just began to learn linux program a few days ago.
one of the advanced features of gdb is that attaching gdb to a runing process,i don't know the benefits of doing that ,and when should we do that ,and how to do?
Old 10-15-2006, 02:50 AM   #2
Senior Member
Registered: Jul 2004
Location: Denmark
Distribution: Ubuntu, Debian
Posts: 1,524

Rep: Reputation: 46
The benefits of attaching to a running process is that you don't have to kill it and start a new process. I can think of two reasons for wanting to avoid that: you want zero downtime, and/or you want to preserve any state that is in the current process (say, network connections).

You want to do that when you think there's an actual benefit.

The way to do it is this:
$ gdb /sbin/init 1
where /sbin/init is the path to the executable, and 1 is the process id you wish to attach to.

Hint for debugging your own C code: pause() when you get a(n otherwise killing) signal.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
normal gdb and spec gdb for kgdb Igor007 Programming 1 09-23-2005 05:15 PM
gdb attach detach - strange behaviour on RHEL 3.0 pankajtakawale Linux - Enterprise 0 07-11-2005 11:12 AM
How to use gdb to debug child process? ariana Programming 2 05-03-2005 02:50 PM
gdb .. looking for 32 bit gdb.. for ia64 suse.. nkshirsagar SUSE / openSUSE 0 12-09-2004 04:02 AM
How can i attach gdb to a daemon process praveengujar Linux - General 0 08-11-2004 07:58 AM

All times are GMT -5. The time now is 07:00 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration