#windows# gdb交叉編譯arm-linux-gnueabihf-gdb

#linux# gdb交叉編譯arm-linux-gnueabihf-gdb

https://blog.csdn.net/xiaoting451292510/article/details/105166739

GDB(GNU symbolic debugger)簡單地說就是一個調試工具。它是一個受通用公共許可證即GPL保護的自由軟件。

像所有的調試器一樣,GDB可以讓你調試一個程序,包括讓程序在你希望的地方停下,此時你可以查看變量、寄存器、內存及堆棧。更進一步你可以修改變量及內存值。GDB是一個功能很強大的調試器,它可以調試多種語言。在此我們僅涉及 C 和 C++ 的調試,而不包括其它語言。還有一點要說明的是,GDB是一個調試器,而不像 VC 是一個集成環境。你可以使用一些前端工具如XXGDB、DDD等。他們都有圖形化界面,因此使用更方便,但它們僅是GDB的一層外殼。因此,你仍應熟悉GDB命令。事實上,當你使用這些圖形化界面時間較長時,你纔會發現熟悉GDB命令的重要性。

嵌入式Linux的GDB調試環境由Host端(PC機)和Target端(ARM)兩部分組成,Host端使用arm-linux-gdb調試工具,而Target端需要運行gdbserver,兩者之間可通過串口或者網口連接,把ARM應用程序在Target端的執行情況返回Host。調試跟蹤命令從Host端的arm-linux-gdb中發出。因此,你需要GDB交叉調試。

你可以從http://ftp.gnu.org/gnu/gdb/網址下載對應版本GDB。目前最新版本gdb-9.1.tar.xz。本人使用8.2較多,因此編譯版本爲8.2版本

要想對源代碼進行編譯,我們還需要安裝MSYS

http://sourceforge.net/projects/mingwbuilds/files/external-binary-packages/  

打開msys.bat文件,接着進入gdb的目錄下,具體編譯與#linux# gdb交叉編譯arm-linux-gnueabihf-gdb幾乎無太大差別。--host不填寫,使用默認情況下會提示

./configure --target=arm-linux-gnueabihf --program-prefix=arm-linux-gnueabihf- CC=arm-linux-gnueabihf-gcc --prefix=/c/arm-linux-gnueabihf-gdb-8.2
$ ./configure --target=arm-linux-gnueabihf --program-prefix=arm-linux-gnueabihf- CC=arm-linux-gnueabihf-gcc --prefix=/c
/arm-linux-gnueabihf-gdb-8.2
checking build system type... i686-pc-mingw32
checking host system type... i686-pc-mingw32
checking target system type... arm-unknown-linux-gnueabihf
checking for a BSD-compatible install... /bin/install -c
checking whether ln works... yes
checking whether ln -s works... no, using cp -pR
checking for a sed that does not truncate output... /bin/sed
checking for gawk... gawk
checking for gcc... arm-linux-gnueabihf-gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... configure: error: in `/c/99_temp/gdb-8.2':
configure: error: cannot run C compiled programs.
If you meant to cross compile, use `--host'.
See `config.log' for more details

使用默認配置./configure查看當前的--host=i686-pc-mingw32

$ ./configure
checking build system type... i686-pc-mingw32
checking host system type... i686-pc-mingw32
checking target system type... i686-pc-mingw32
checking for a BSD-compatible install... /bin/install -c
checking whether ln works... yes
checking whether ln -s works... no, using cp -pR

加入 --host=i686-pc-mingw32

./configure --target=arm-linux-gnueabihf --host=i686-pc-mingw32 --program-prefix=arm-linux-gnueabihf- CC=arm-linux-gnueabihf-gcc --prefix=/c/arm-linux-gnueabihf-gdb-8.2

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章