GDB是什么

簡(jiǎn)介

GDB是GNU開(kāi)源組織發(fā)布的一個(gè)強(qiáng)大的UNIX下的程序調(diào)試工具。

編譯和測(cè)試方式

1.選擇操作環(huán)境

本文選用華為鯤鵬云服務(wù)ECS KC1實(shí)例做測(cè)試

2.獲取源代碼

https://ftp.gnu.org/gnu/gdb/ 提供GDB各版本的源碼壓縮包,可以直接下載。

3.編譯源代碼

本文以“gdb-7.6.1”版本為例,下載源碼,并編譯安裝。

要求gcc的版本為“4.8.5”。

1)下載GDB的依賴包termcap的源代碼。

wget https://ftp.gnu.org/gnu/termcap/termcap-1.3.1.tar.gz

2)解壓termcap源碼。

tar -zxvf termcap-1.3.1.tar.gz

3)編譯安裝termcap。

cd termcap-1.3.1/

./configure && make && make install

4)下載GDB源碼。

cd ~

wget https://ftp.gnu.org/gnu/gdb/gdb-7.6.1.tar.gz

5)解壓GDB源碼

tar -zxvf gdb-7.6.1.tar.gz

6)編譯安裝GDB。

cd gdb-7.6.1/

./configure && make && make install

7)查看GDB安裝路徑。

find / -name "gdb*" |grep bin

回顯信息如下,GDB安裝路徑為“ /usr/local/bin/gdb”。

/usr/bin/gdbus

/usr/local/bin/gdbserver

/usr/local/bin/gdb

8)(可選)建立軟鏈接。

要求GDB的安裝路徑為“ /usr/bin/gdb”,如果上一步查詢到的安裝路徑為此路徑,則不需要執(zhí)行。

cd /usr/local/bin

ln ./gdb /usr/bin/gdb

9)查看GDB是否安裝成功。

gdb --version

回顯信息如下,則GDB安裝成功:

GNU gdb (GDB) 7.6.1

Copyright (C) 2013 Free Software Foundation, Inc.

License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>

This is free software: you are free to change and redis tribute it.

There is NO WARRANTY, to the extent permitted by law.  Type "show copying"

and "show warranty" for details.

This GDB was configured as "aarch64-unknown-linux-gnu".

For bug reporting instructions, please see:

<http://www.gnu.org/software/gdb/bugs/>.