#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
发布了170 篇原创文章 · 获赞 207 · 访问量 459万+

猜你喜欢

转载自blog.csdn.net/xiaoting451292510/article/details/105228162
今日推荐