How does one debug smbd?

Michael H. Warfield mhw at
Thu Jul 19 00:35:21 GMT 2001

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

> > 	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.


 Michael H. Warfield    |  (770) 985-6132   |  mhw at
  (The Mad Wizard)      |  (678) 463-0932   |
  NIC whois:  MHW9      |  An optimist believes we live in the best of all
 PGP Key: 0xDF1DD471    |  possible worlds.  A pessimist is sure of it!

More information about the samba-technical mailing list