Mirror of the gdb mailing list
 help / color / mirror / Atom feed
From: "Mark Kettenis" <mark.kettenis@xs4all.nl>
To: "Shriek" <shriek.007@gmail.com>
Cc: gdb@sourceware.org
Subject: Re: Need help in debugging daemons with GDB
Date: Wed, 09 Aug 2006 06:39:00 -0000	[thread overview]
Message-ID: <18543.82.92.89.47.1155105566.squirrel@webmail.xs4all.nl> (raw)
In-Reply-To: <3ce33f6c0608082326g5da2ee6co5530fb0de8af94e9@mail.gmail.com>

>  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


  reply	other threads:[~2006-08-09  6:39 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-08-09  6:26 Shriek
2006-08-09  6:39 ` Mark Kettenis [this message]
     [not found] ` <113c79ae0608082338l1975b171p70ecb223cb468c1@mail.gmail.com>
2006-08-09 14:20   ` Shiladitya (শিলাদিত্য)

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=18543.82.92.89.47.1155105566.squirrel@webmail.xs4all.nl \
    --to=mark.kettenis@xs4all.nl \
    --cc=gdb@sourceware.org \
    --cc=shriek.007@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox