How to compile GDB

本文详细介绍了如何在Cygwin环境下编译安装GDB,并提供了在Linux环境下交叉编译GDB及GDBserver的具体步骤。适用于希望在不同环境中使用GDB进行调试的开发者。

 

 

您可以直接從網站上下載安裝,如果網路是好的話,請參考網站http://www.cygwin.com/,請注意安裝libiconv到你的cygwin中去。

如果你相信上面的那個公司自己的cygwin安裝包,請雙擊,一路到底。如果可能請注冊你的cygwin/bin到你的環境變量中。

 

首先請下載你的GDB從http://ftp.gnu.org/gnu/gdb/

這時你將得到gdb-6.8.tar.gz軟件包,下面是一個sample, 執行下列操作,你將完成GDB的編譯,獲得arm-linux-gdb.exe.

雙擊桌面上的cygwin快捷方式,登錄cygwin 模擬環境。

cd /cygdrive/g/gdb

tar zxvf gdb-6.8.tar.gz

mkdir gdb-build

cd gdb-build

../gdb-6.8/configure --target=arm-linux --enable-shared --prefix=/cygdrive/g/gdb/gdb-build --without-x --disable-gdbtk --disable-tui --without-included-regex --without-included-gettext

Make

Make install

OK, you will get arm-linux-gdb.exe, of course, it is not strip. If you strip it, please execute “strip arm-linux-gdb.exe”

 

2 Linux下compile GDB and GDB server

First, please setup your arm cross-compile toolschain。

 

2.1 Gdb-6.8 

首先請下載你的GDB從http://ftp.gnu.org/gnu/gdb/

這時你將得到gdb-6.8.tar.gz軟件包,下面是一個sample, 執行下列操作,你將完成GDB的編譯,獲得arm-linux-gdb  arm-linux-gdbserver.

 

cd /home/user/gdb-test/

tar zxvf gdb-6.8.tar.gz

mkdir gdb-build

cd gdb-build

../gdb-6.8/configure --target=arm-linux --prefix=/home/user/gdb-test/gdb-build

Make 

Make install

 

將生成下列的arm elf 文件:

arm-linux-gdb arm-linux-gdbtui  arm-linux-run  

如果你要strip 它的話,請用strip arm-linux-gdb。

 

mkdir gdbserver

cd gdbserver

CC=arm11_mtk_le-gcc ../../gdb-6.8/gdb/gdbserver/configure --target=arm-linux --host=arm-linux

Make

Make install

 

arm 格式gdbserver 將被生成。

如果你要strip 它的話,請用arm11_mtk_le-strip gdbserver。

 

3 Linux下compile ARM GDB

Please setup your arm cross-compile toolschain。

3.1 Gdb-6.8 

首先請下載你的GDB從http://ftp.gnu.org/gnu/gdb/

這時你將得到gdb-6.8.tar.gz軟件包,下面是一個sample, 執行下列操作,你將完成GDB的編譯,獲得arm-linux-gdb.exe.

 

cd /home/user/gdb-test/

tar zxvf gdb-6.8.tar.gz

mkdir arm-gdb-build

cd arm-gdb-build

CC=arm11_mtk_le-gcc AR=arm11_mtk_le-ar RANLIB=arm11_mtk_le-ranlib AS=arm11_mtk_le-as LD=arm11_mtk_le-ld ../gdb-6.8/configure --build=i686-pc-linux-gnu  --host=arm-linux --target=arm-linux  --prefix=/home/user/gdb-test/arm-gdb-build/ --enable-shared --without-x --disable-gdbtk --disable-tui --without-included-regex --without-included-gettextMake

Make install

 

Gdb 將被生成。

如果你要strip 它的話,請用arm11_mtk_le-strip arm-linux-gdb。

 

(Short version: Kcov, a new project of mine for code coverage testing)When developing software, I've often found measuring code coverage useful and important for development. A few years ago, I wrote shcov, which provides code coverage measurement for shell scripts. However, traditionally C and C++ code is more important, and the standard tool for measuring code coverage in UNIX is Gcov.Gcov is unfortunately a bit crude: you have to compile your program with special switches, running the program outputs lots and lots of temporary files and collecting the data is done with a command-line tool. It also adds instructions count each basic block, so in addition it makes your program (slightly) slower. The output can be made nicer by using Lcov (I used the lcov HTML for shcov), but this introduces yet another step in the build/run/collection sequence. Because of all this, I seldomly use gcov despite its usefulness.But can't code coverage collection be done in some better way? Yes, it can.Thomas Neumann has written a nice tool called Bcov which improves a lot on the gcov experience: No need for special build switches, a single collection and a single report stage and lcov-style output directly. How does it do this? Well, Thomas realised that all the required information for code coverage is already present in the binary in the form of DWARF debugging information. After all, GDB and addr2line is clearly able to translate instruction addresses into code lines already.Bcov, I presume, is short for Breakpoint COVerage. It uses ptrace to setup temporary breakpoints in the binary and then run the application until it stops, notes which line the instruction corresponds to and clears the breakpoint, lets it continue until it stops the next time and so on. So bcov replaces gcov and lcov, with the restriction that it doesn't count the number of hits per line, but simply if it has been hit, and all of that in less than 1500 lines of code!So what is Kcov then? Well, while bcov is a great tool, I still have a few problems with it, so I decided to try to make it better. First, while it's much easier to use than gcov+lcov, it's still two steps (collection and reporting), and I'd like to reduce that to a single one. Second, many applications are long running (or even, like deamons, never terminate), and collecting all output at the end then is hard, so I'd like continuous output. Third, I think the same principle will work for the kernel, which explains the name. That particular part isn't finished yet though, so for now K will have to stand for something else.The output is still Lcov-like:
最新发布
08-14
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值