美文网首页
安装 GDB 7.12.1

安装 GDB 7.12.1

作者: juniway | 来源:发表于2017-02-11 13:38 被阅读272次

    Introduction

    GDB, the GNU Project debugger, allows you to see what is going on “inside” another program while it executes -- or what another program was doing at the moment it crashed. Note that GDB is most effective when tracing programs and libraries that were built with debugging symbols and not stripped.

    Package Information

    Download (HTTP): https://ftp.gnu.org/gnu/gdb/gdb-7.12.1.tar.xz
    Download (FTP): ftp://ftp.gnu.org/gnu/gdb/gdb-7.12.1.tar.xz
    Download MD5 sum: 193453347ddced7acb6b1cd2ee8f2e4b
    Download size: 18 MB
    Estimated disk space required: 413 MB (add 158 MB for tests, add 665 MB for docs)
    Estimated build time: 2.7 SBU (add 22 SBU for tests, add 0.7 for docs)

    Dependencies

    Optional
    DejaGnu-1.6 (for tests), Doxygen-1.8.13, Guile-2.0.13, Python-2.7.13, Valgrind-3.12.0, and SystemTap (run-time dependency, also used in a few tests)

    建议: 给特定用户安装 GDB 的 pretty-printer 打印出可读性更好的 stdc++ 的 STL 容器
    在编译 GDB 之前,先安装 ncurses 库和 Python 库(用于在 GDB 中 开启 Python
    支持,编译 GDB 时必须添加 --with-python 选项)。

    (1)安装 ncurses 开发库头文件:

    sudo apt-get install libncurses-dev
    

    (2)GDB 依赖 libreadline,执行下列命令来安装:

    sudo apt-get install libreadline-dev
    

    (3)GDB 需要 makeinfo,这个是在 texinfo 包中

    sudo apt-get install texinfo
    

    (4)安装 python-dev, 开发库头文件

    sudo apt-get install python-dev
    

    [GCC源码目录]/libstdc++-v3/python 复制到任意一个目录(比如 ~/.gdb 目录下),
    如果源码目录下没有上述 python 目录,也可以用如下方式从远程库拉取之后再放到 ~/.gdb 目录下:

    svn co svn://gcc.gnu.org/svn/gcc/trunk/libstdc++-v3/python
    

    然后,编辑 ~/.gdbinit,添加如下内容:

    python
    import sys
    import os
    p = os.path.expanduser('~/.gdb/python') 
    print p
    if os.path.exists(p):
        sys.path.insert(0, p)
        from libstdcxx.v6.printers import register_libstdcxx_printers
        register_libstdcxx_printers(None)
    end
    

    注意: 上述脚本在 os.path.expanduser('~/.gdb/python') 中指定了 python 目录的位置。

    Installation

    ./configure --prefix=/usr --with-system-readline --with-python
    make
    make -C gdb install
    

    Contents

    Installed Programs:
    gcore, gdb and gdbserver
    Installed Library:
    libinproctrace.so
    Installed Directories:
    /usr/{include,share}/gdb and /usr/share/doc/gdb-7.12.1

    Short Descriptions

    gcore

    generates a core dump of a running program.

    • gdb the GNU Debugger.
    • gdbserver a remote server for the GNU debugger (it allows programs to be debugged from a different machine).
    • libinproctrace.so contains functions for the in-process tracing agent. The agent allows for installing fast tracepoints, listing static tracepoint markers, probing static tracepoints markers, and starting trace monitoring.

    安装 cgdb

    cgdb 是一个开源的 gdb 前端,可以提供实时的代码预览,极大的方便了调试。

    获取源码
    $ git clone git://github.com/cgdb/cgdb.git
    
    依赖

    flex( gettext ),autoconf, aclocal, automake, help2man

    安装依赖
    (1) flex

    $ sudo apt-get install flex
    

    (2) aclocal, automake, autoconf, autoheader
    这些 utilities 都在 automake 包中,因此安装automake 就够了。

    $ sudo apt-get install automake
    $ sudo apt-get install autotools-dev
    

    (3) makeinfo,这个 utility 在 texinfo 包中

    $ sudo apt-get install texinfo
    

    (3)help2man

    $ sudo apt-get install help2man
    
    编译和安装
    $ cd cgdb
    $ ./autogen.sh
    $ ./configure --prefix=/usr/local
    $ make
    $ sudo make install
    

    参考

    http://www.linuxfromscratch.org/blfs/view/cvs/general/gdb.html

    相关文章

      网友评论

          本文标题:安装 GDB 7.12.1

          本文链接:https://www.haomeiwen.com/subject/ubqoittx.html