LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Desktop
User Name
Password
Linux - Desktop This forum is for the discussion of all Linux Software used in a desktop context.

Notices


Reply
  Search this Thread
Old 10-11-2006, 10:03 PM   #1
linwenyuan
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, 01:50 AM   #2
jonaskoelker
Senior Member
 
Registered: Jul 2004
Location: Denmark
Distribution: Ubuntu, Debian
Posts: 1,524

Rep: Reputation: 47
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:
Code:
$ 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.
 
  


Reply



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 04:15 PM
gdb attach detach - strange behaviour on RHEL 3.0 pankajtakawale Linux - Enterprise 0 07-11-2005 10:12 AM
How to use gdb to debug child process? ariana Programming 2 05-03-2005 01:50 PM
gdb .. looking for 32 bit gdb.. for ia64 suse.. nkshirsagar SUSE / openSUSE 0 12-09-2004 03:02 AM
How can i attach gdb to a daemon process praveengujar Linux - General 0 08-11-2004 06:58 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Desktop

All times are GMT -5. The time now is 12:09 AM.

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