Debugging 我应该如何用GDB调试Samba

Debugging 我应该如何用GDB调试Samba,debugging,gdb,samba,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 we

我英语不好,对此我很抱歉。 现在,有一个关于何时使用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

  • 从下载samba源代码并编译它(没有源代码,就不可能进行符号调试)
  • 停止或杀死任何其他samba实例
  • 在gdb下启动samba:

    gdb <path/to/compiled/smbd>
    
  • 参数
    -i-M single
    强制
    smbd
    作为单个进程启动,不要将所有消息和错误后台监控并打印到stdout/stderr

    现在,您可以设置断点并跟踪您的源代码,就像您通常使用任何其他程序一样


    注意:使用
    gdb
    ,您可能会发现使用
    gdb-tui
    (gdb文本用户界面)或使用其他调试器(如
    ddd
    )比使用
    sudo./smbd-i
    更方便,您可以使用
    sudo./smbd-i
    启动smbd,看看有什么问题。 就我而言: smbd尝试在/usr/local/samba/etc/smb.conf中查找smb.conf,但没有,所以退出。 我将/etc/samba/smb.conf复制到disired路径,然后一切正常


    希望这能对您有所帮助。

    使用gdb,没错。非常感谢你!Gdb tui?对不起,从来没有普遍使用过a)gdb)b)断点c)rd)>然后,显示源:-)原来,我也这么认为。但是最近,我越来越喜欢使用
    gdbtui
    set args -i -M single