1.下载gdb的源码 2.编译:
cd gdb-7.10.1./configure --target=arm-linux --PRefix=$PWD/installed -v解释一下: –target配置gdb的目标平台; –prefix配置安装路径,我在gdb-7.10.1的目录下创建了installed这个目录,用来存放编译后生成的文件。 下面就是开始编译了。
编译 make
安装 make install
至此,gdb安装完成。
接下来为linux-arm安装gdbserver
进入gdb-7.10.1/gdb/gdbserver
配置
./configure --target=arm-linux --host=arm-linuxmake CC=arm-linux-gcc
没有错误的话就在当前路径下生成gdbserver. 下面是做一下权限的修改和去掉无关的调试信息,这些东西用不到,去掉后还能减少文件大小。
chmod 777 gdbserver arm-linux-strip gdbserver
此时需要注意的是 1.gdbserver这个文件需要通过nfs弄到板子上去,且在板子上运行; 2.与gdbserver配套的需要使用刚才编译gdb时生成的arm-linux-gdb,它在pc上运行。
开始调试: 在板子的终端中运行 gdbserver –multi 10.0.14.38:1234 这里没有指定待调试的应用程序文件名,这个文件名一会将会在pc端使用命令指定,然后pc端的arm-linux-gdb通过网络把这写信息发给gdbserver。 10.0.14.38这个地址是我的pc端的IP
在PC端运行
[zhang@zwfedora23 tmp]$ ./arm-linux-gdb GNU gdb (GDB) 7.10.1Copyright (C) 2015 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 redistribute it.There is NO WARRANTY, to the extent permitted by law. Type "show copying"and "show warranty" for details.This GDB was configured as "--host=x86_64-unknown-linux-gnu --target=arm-linux".Type "show configuration" for configuration details.For bug reporting instructions, please see:<http://www.gnu.org/software/gdb/bugs/>.Find the GDB manual and other documentation resources online at:<http://www.gnu.org/software/gdb/documentation/>.For help, type "help".Type "apropos Word" to search for commands related to "word".(gdb) target extended-remote 10.0.14.221:1234Remote debugging using 10.0.14.221:1234(gdb) set remote exec-file /mnt/nfs/sample_audio(gdb) file ~/work/60G/my_tools/hi3518-mpp/bak/ mpp/ mpp-2017-02-06-static-ok.tar.bz2 convertfile.sh mpp-2017-01-24-dynamic-ok.tar.bz2 mpp.tgz (gdb) file ~/work/60G/my_tools/hi3518-mpp/bak/ mpp/ mpp-2017-02-06-static-ok.tar.bz2 convertfile.sh mpp-2017-01-24-dynamic-ok.tar.bz2 mpp.tgz (gdb) file ~/work/60G/my_tools/hi3518-mpp/mpp/Makefile.param component/ cscope.out extdrv/ include/ ko/ lib/ sample/ tags tools/ types_c.taghl(gdb) file ~/work/60G/my_tools/hi3518-mpp/mpp/sample/audio/sample_audioReading symbols from ~/work/60G/my_tools/hi3518-mpp/mpp/sample/audio/sample_audio...done.(gdb) b mainBreakpoint 1 at 0xa61c: file sample_audio.c, line 457.(gdb) rStarting program: /home/zhang/work/60G/my_tools/hi3518-mpp/mpp/sample/audio/sample_audio Reading /lib/ld-linux.so.3 from remote target...warning: File transfers from remote targets can be slow. Use "set sysroot" to access files locally instead.Reading /lib/ld-linux.so.3 from remote target...Reading /lib/libpthread.so.0 from remote target...Reading /lib/libm.so.6 from remote target...Reading /system/lib/libasound.so.2 from remote target...Reading /usr/lib/librb.so from remote target...Reading /lib/libc.so.6 from remote target...Reading /lib/libdl.so.2 from remote target...Reading /system/lib/librt.so.1 from remote target...Reading /system/lib/libgcc_s.so.1 from remote target...Breakpoint 1, main (argc=1, argv=0xbefffe54) at sample_audio.c:457457 HI_S32 s32Ret= HI_SUCCESS;(gdb) cContinuing.说明: 1.target extended_remote 10.0.14.221:1234 这里的ip是板子的ip。
2.(gdb) set remote exec-file /mnt/nfs/sample_audio 指定在板子上需要运行的应用程序路径。
3.file ~/work/60G/my_tools/hi3518-mpp/mpp/sample/audio/sample_audio 指定在PC上需要调试的应用程序的路径。
接下来就行了。 设置断点就可以开始调试了。
新闻热点
疑难解答