How does one debug smbd?

Andrew Bartlett abartlet at
Thu Jul 19 05:02:05 GMT 2001

"Michael H. Warfield" wrote:
> On Wed, Jul 18, 2001 at 03:41:42PM -0700, eric steadle wrote:
> > --- "Michael H. Warfield" <mhw at> wrote:
> > >     Why not start up smbd separately and then run gdb on the object file
> > > and then attack to the PID you want to debug?
> > A splendid idea. When I tried it though, I can't seem to get breakpoints to
> > work - gdb complains that it can't load the symbols for the process. But that's
> > more of a gdb problem, not a Samba problem, so I won't be offended if we decide
> > not to discuss it here. Still, any ideas are welcome :)
>         Make sure that your copy of smbd is not "stripped".  If it's
> an installed version (i.e. from .rpm or from .deb), it probably is
> stripped.
> > >     I think that's controlled from the "-D" option.  Don't use it
> > > and it shouldn't fork.  (?)
> >
> > Actually, you are correct. "-D" controls daemon mode, except I didn't bother to
> > show you what happens when that line of code executes....
> >
> > if (!is_daemon && !is_a_socket(0)) {
> >     DEBUG (...) ;
> >     is_daemon = true ;
> > }
> > So if that test on is_a_socket(0) returns false (which it always seems to do
> > while I'm running in a debugger) then is_daemon will get set to true and I'm
> > back where I started.
>         Hmmm...  I see...
> > Like I said before, I'm not a daemon expert and I don't know how to control
> > processes under *nix. This is my first experience hacking a daemon and I'm
> > floundering.
>         One other thing, and I'm sure my fellow Samba Team members will
> chime in on this...  Tridge use to have some procedure for debugging
> those daemons.  Last I heard of any discussion around it was years ago
> and it may no longer be applicable, but I remember Jeremy and Tridge
> both mention it in face to face discussions.  Should be some comments
> buried in the docs somewhere.  I never had need to use it so I don't
> really remember what the exact procedure was.

Some of this has changed recently, making life a tad easier: 

We now can run properly as non-root, and we can also run in a
'self-loopback' mode from the smbclient utilties (not as much use in
your case, but invaluable for debugging things that can be done with
smbclient).  Of particular value here is that if it SIG11s (or otherwise
exits abnormally) the core-file is actualy generated and root access
isn't required.

For your case I would recommend running smbd from inetd as yourself (not
root) and attaching the debugger as indicated.  

Andrew Bartlett

Andrew Bartlett
abartlet at
abartlet at

More information about the samba-technical mailing list