安裝 GDB 7.12.1

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

最后編輯于
?著作權歸作者所有,轉載或內容合作請聯系作者
平臺聲明:文章內容(如有圖片或視頻亦包括在內)由作者上傳并發布,文章內容僅代表作者本人觀點,簡書系信息發布平臺,僅提供信息存儲服務。

推薦閱讀更多精彩內容