From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 30731 invoked by alias); 9 Aug 2006 06:39:33 -0000 Received: (qmail 30723 invoked by uid 22791); 9 Aug 2006 06:39:32 -0000 X-Spam-Check-By: sourceware.org Received: from smtp-vbr3.xs4all.nl (HELO smtp-vbr3.xs4all.nl) (194.109.24.23) by sourceware.org (qpsmtpd/0.31) with ESMTP; Wed, 09 Aug 2006 06:39:30 +0000 Received: from webmail.xs4all.nl (dovemail3.xs4all.nl [194.109.26.5]) by smtp-vbr3.xs4all.nl (8.13.6/8.13.6) with ESMTP id k796dPQN093567; Wed, 9 Aug 2006 08:39:25 +0200 (CEST) (envelope-from mark.kettenis@xs4all.nl) Received: from 82.92.89.47 (SquirrelMail authenticated user sibelius) by webmail.xs4all.nl with HTTP; Wed, 9 Aug 2006 08:39:26 +0200 (CEST) Message-ID: <18543.82.92.89.47.1155105566.squirrel@webmail.xs4all.nl> In-Reply-To: <3ce33f6c0608082326g5da2ee6co5530fb0de8af94e9@mail.gmail.com> References: <3ce33f6c0608082326g5da2ee6co5530fb0de8af94e9@mail.gmail.com> Date: Wed, 09 Aug 2006 06:39:00 -0000 Subject: Re: Need help in debugging daemons with GDB From: "Mark Kettenis" To: "Shriek" Cc: gdb@sourceware.org User-Agent: SquirrelMail/1.4.5 MIME-Version: 1.0 Content-Type: text/plain;charset=iso-8859-1 Content-Transfer-Encoding: 8bit Mailing-List: contact gdb-help@sourceware.org; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sourceware.org X-SW-Source: 2006-08/txt/msg00063.txt.bz2 > I am not sure this is the correct mailing list for this but did not > find another suitable one ... > I am debugging a daemon in FreeBSD and I am particularly interested in > the initialization functions activity as the daemon starts ... > conventionally I attach the GDB to the PID and supply the unstripped > object file of the daemon as argument. Now the problem with this is > when you stop the daemon and restart there is no info of the PID > avaliable for attaching the GDB, thus I cannot get to see the > initialization functions ... and by the time you get to know PID the > initialization stuff is already history :-) I presume that your daemon calls daemon(3) (or has code equivalent to it) and calls fork(2) early on and does the interesting stuff in the child process. You could change the code and put in a sleep(3) before the initialization code you're interested in to give yourself a bit more time to attach to the child. The real solution would be for the FreeBSD people to implement an extension to ptrace(2) that makes it possible for GDB to get notified when the inferior forks. I implemented this for OpenBSD a while ago and it shouldn't be too difficult to adapt this code to FreeBSD. Mark