* Need help in debugging daemons with GDB
@ 2006-08-09 6:26 Shriek
2006-08-09 6:39 ` Mark Kettenis
[not found] ` <113c79ae0608082338l1975b171p70ecb223cb468c1@mail.gmail.com>
0 siblings, 2 replies; 3+ messages in thread
From: Shriek @ 2006-08-09 6:26 UTC (permalink / raw)
To: gdb
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 :-)
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Need help in debugging daemons with GDB
2006-08-09 6:26 Need help in debugging daemons with GDB Shriek
@ 2006-08-09 6:39 ` Mark Kettenis
[not found] ` <113c79ae0608082338l1975b171p70ecb223cb468c1@mail.gmail.com>
1 sibling, 0 replies; 3+ messages in thread
From: Mark Kettenis @ 2006-08-09 6:39 UTC (permalink / raw)
To: Shriek; +Cc: gdb
> 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
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Need help in debugging daemons with GDB
[not found] ` <113c79ae0608082338l1975b171p70ecb223cb468c1@mail.gmail.com>
@ 2006-08-09 14:20 ` Shiladitya (শিলাদিত্য)
0 siblings, 0 replies; 3+ messages in thread
From: Shiladitya (শিলাদিত্য) @ 2006-08-09 14:20 UTC (permalink / raw)
To: Shriek, gdb
There is a simple way to get around that. Create a shell script by the same
name as the daemon that you intend to debug and replace the daemon by
the script. Let us say you daemon is called "shriek". Rename it to
"shriek_real" and name your shell script as "shriek". shriek will
look like this :
"
#! /bin/sh
/usr/bin/xterm -e gdb -x {full_path}/gdb_script
"
and your gdb_script will look like this:
"
file {full_path}/shriek_real
b addr
r
"
You will be able to get control of the daemon right at its entry point
when you restart the daemon "script".
Hope that helps
> On 8/9/06, Shriek <shriek.007@gmail.com> wrote:
> > 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 :-)
> >
>
>
> --
> --
> Shiladitya
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2006-08-09 14:20 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-08-09 6:26 Need help in debugging daemons with GDB Shriek
2006-08-09 6:39 ` Mark Kettenis
[not found] ` <113c79ae0608082338l1975b171p70ecb223cb468c1@mail.gmail.com>
2006-08-09 14:20 ` Shiladitya (শিলাদিত্য)
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox