arm-linux-gdb 环境搭建及调试core文件

系统环境:

host:ubuntu12.04

gcc:gcc version 4.6.3 (Ubuntu/Linaro 4.6.3-1ubuntu5)

target:hisi3520d开发板

arm-linux-gcc:SDK中自带的arm-hisiv100nptl-linux-gcc

gdb版本:gdb-7.9


GDB环境搭建

解压gdb-7.9.tar.gz

编译gdb

# cd gbd-7.9

#./configure --target=arm-hisiv100nptl-linux --prefix=$PREFIX

# make

# make install


编译gdb_server

# cd gdb/gdbserver

#./configure --target=arm-hisiv100nptl-linux --host=arm-hisiv100nptl-linux --prefix=$PREFIX


# make

# make install
提示错误:/home/gdb-7.9/missing: line 81: makeinfo: command not found
WARNING: 'makeinfo' is missing on your system.
         You should only need it if you modified a '.texi' file, or
         any other file indirectly affecting the aspect of the manual.
         You might want to install the Texinfo package:
        
         The spurious makeinfo call might also be the consequence of
         using a buggy 'make' (AIX, DU, IRIX), in which case you might
         want to install GNU make:
        
按装库:apt-get install textinfo即可

在安装目录下bin目录生成文件:

arm-hisiv100nptl-linux-gdb  arm-hisiv100nptl-linux-gdbserver  arm-hisiv100nptl-linux-run


GDB调试

在开发板上执行arm-hisiv100nptl-linux-gcc编译生成的代码test,生成core文件,发现core文件大小为0字节。

原因:test文件放在虚拟机上,挂载到开发板上运行导致的,将test拷贝到开发板上就好了。


将开发板上生成core文件拷贝到虚拟机上,将test文件也拷贝到虚拟机上,放在同一目录下。在虚拟机上执行下面命令:

# arm-hisiv100nptl-linux-gdb test core

提示:

For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from bsjgui...(no debugging symbols found)...done.
BFD: Warning: /home/nfs/core is truncated: expected core file size >= 54865920, found: 2793472.
[New LWP 2006]
[New LWP 2009]
[New LWP 2010]
[New LWP 2005]
[New LWP 2011]
[New LWP 2007]
[New LWP 2008]
Cannot access memory at address 0x4005d004
Cannot access memory at address 0x4005d000

发现core文件被剪切了,发现是开发板上的磁盘空间不足导致的,删除开发板上的文件,腾出空间后正常。

重新执行命令:

# arm-hisiv100nptl-linux-gdb test core

提示如下:

warning: Could not load shared library symbols for 12 libraries, e.g. /dvr/ybq/lib/libz.so.1.
Use the "info sharedlibrary" command to see the complete listing.
Do you need "set solib-search-path" or "set sysroot"?
Core was generated by `./bsjgui'.
Program terminated with signal SIGABRT, Aborted.

设置所有的库路径:set solib-search-path /home/nfs/lib:/home/3520D_fs/rootfs/lib/:/home/share/Hi3520D_SDK_V1.0.3.0/mpp/lib
然后执行命令:

# core-file (清除core文件)

# core-file /home/nfs/core (重新导入core文件)

# bt(查看栈数据)

(gdb) bt
#0  0x401b0ba8 in ?? ()
#1  0x401b415c in ?? ()
Backtrace stopped: previous frame identical to this frame (corrupt stack?)

还是不能正常显示,设置绝对路径: set solib-absolute-prefix /home/nfs/lib:/home/3520D_fs/rootfs/lib/:/home/share/Hi3520D_SDK_V1.0.3.0/mpp/lib

然后继续操作:

gdb) bt
#0  0x401b0ba8 in sem_wait () from /home/3520D_fs/rootfs/lib/libpthread-0.9.32.1.so
#1  0x402f9838 in PostSyncMessage (hWnd=1078051432, msg=0, wParam=14140312, lParam=14140312) at message.c:1333
#2  0x402f8b28 in SendTopNotifyMessage (hWnd=14959720, iMsg=0, wParam=1076857640, lParam=3202165340) at message.c:885
#3  0x402b6ab8 in DestroyMainWindow (hWnd=14959720) at window.c:3629
#4  0x402b6a60 in DestroyMainWindow (hWnd=14139928) at window.c:3602
#5  0x0000cae8 in ?? ()
Backtrace stopped: previous frame identical to this frame (corrupt stack?)
(gdb)
还是存在一条信息没有正常显示出来,跳过没有管
(gdb) bt
#0  0x403a2e4c in FT_Activate_Size () from /home/nfs/lib/libfreetype.so.6.7.0
#1  0x401c6408 in get_glyph_bbox (logfont=,
    devfont=,
    glyph_value=,
    px=,
    py=,
    pwidth=,
    pheight=) at freetype2.c:318
Backtrace stopped: Cannot access memory at address 0x4115b98c
(gdb) where(查看程序出错位置信息)
#0  0x403a2e4c in FT_Activate_Size () from /home/nfs/lib/libfreetype.so.6.7.0
#1  0x401c6408 in get_glyph_bbox (logfont=,
    devfont=,
    glyph_value=,
    px=,
    py=,
    pwidth=,
    pheight=) at freetype2.c:318
Backtrace stopped: Cannot access memory at address 0x4115b98c

你可能感兴趣的:(Linux系统)