我该如何使用GDB调试Samba

时间:2013-08-22 03:11:37

标签: debugging gdb samba

我不擅长英语,我很抱歉。 现在,有一个关于何时用GDB调试samba的问题。

    # gdb /usr/local/samba/sbin/smbd
    GNU gdb Red Hat Linux (5.2.1-4)
    Copyright 2002 Free Software Foundation, Inc.
    GDB is free software, covered by the GNU General Public License, and you are
    welcome to change it and/or distribute copies of it under certain conditions.
    Type "show copying" to see the conditions.
    There is absolutely no warranty for GDB.  Type "show warranty" for details.
    This GDB was configured as "i386-redhat-linux"...
    (gdb) r
    Starting program: /usr/local/samba/sbin/smbd 
    Program exited normally.
    (gdb) info program

正在调试的程序没有运行。 那么,我应该如何使用GDB调试samba?

ps:Samba 3.0.5版本我从源代码安装samba。

2 个答案:

答案 0 :(得分:1)

您可以使用sudo ./smbd -i启动smbd,看看它有什么问题。 在我的情况下: smbd尝试在/usr/local/samba/etc/smb.conf中找到smb.conf并且没有一个,所以退出。 我将/etc/samba/smb.conf复制到disired路径,然后一切正常。

希望这可以帮到你。

答案 1 :(得分:0)

  1. http://www.samba.org下载samba源代码并编译它(没有源代码,将无法进行符号调试)。
  2. 停止或终止任何其他samba实例。
  3. 在gdb下启动samba:

    gdb <path/to/compiled/smbd>
    
  4. 指定smbd参数:

    set args -i -M single
    
  5. 参数-i -M single强制smbd作为单个进程启动,不要守护并将所有消息和错误打印到stdout / stderr。

    现在,您可以像平常一样设置断点并跟踪源代码。

    注意:您可能会发现使用gdb(gdb文本用户界面)或使用其他调试程序(如gdb-tui)更方便,而不是使用ddd