香港云服务器Linux下的dump文件一般称为core文件 ,可以用来记录程序崩溃前的线程callstack信息,内存信息等,可以作为排错的一种辅助手段。生存的core大小可以限制,保存的内容也可以灵活的选择,因此在MID上也可以使用。由于linux的开发性,类似的调试技术比windows上的更为强大,灵活。 1 Core文件的生成输入 ulimit –aMid上的输出信息time(seconds) unlimitedfile(blocks) unlimiteddata(kbytes) unlimitedstack(kbytes) 8192coredump(blocks) 0memory(kbytes) unlimitedlocked memory(kbytes) 32process 1024nofiles 1024vmemory(kbytes) unlimitedlocks unlimited 注意coredump(blocks) 0指定了core 文件的大小为0 block现在修改这个限制,设置成1024个block,如果超过这个值就不再写core文件Ulimit -c 1024 现在用一个测试程序进行验证[code ]#include int just_a_test(){ int * p = NULL; printf("%d /n",*p);}int main(){ just_a_test();}[/code]在scatchbox 中编译 Gcc –Wall -g hello.c将生成的a.out 放入mid中,加上可执行权限Chmod +x a.out执行 ,在同级目录下生成了一个core文件 2 定位出错的地方将core 文件考到编译主机上,在host 上分析该core文件 。接下来一个很重要的步骤就是编译自己的gdb在gnu 上下载源码 ,共享中也有//10.111.0.1/File Exchange Area/zhangwei/gdb/ gdb-7.2.tar.gz 解压后进入gdb目录配置编译参数Host 默认在x86上,target 则为arm./configure --target=arm-linux --enable-shared --prefix=/home/shenghuai/3G-Works/3G-Encoder/src/ampleksy/gdb/gdb-7.2 --without-x --disable-gdbtk --disable-tui --without-included-regex --without-included-gettextMakeMake install将生成的arm-linux-gdb 加入到path路径中来运行 arm-linux-gdb 用--core 指定core文件 henghuai@shenghuai-3G:~/3G-Works/3G-Encoder/src/amplesky/gdb$ arm-linux-gdb --core=coreGNU gdb (GDB) 7.2Copyright (C) 2010 Free Software Foundation, Inc.License GPLv3+: GNU GPL version 3 or later 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=i686-pc-linux-gnu --target=arm-linux".For bug reporting instructions, please see:.[New Thread 1491]Core was generated by `./a.out'.Program terminated with signal 11, Segmentation fault.#0 0x000083a0 in ?? () 接下来指定可执行文件(含调试信息)(gdb) file ./a.outReading symbols from /scratchbox/users/shenghuai/home/shenghuai/marvell-sdk/pxalinux/3G-encoder/src/amplesky/gdb/a.out...done.(gdb) bt#0 0x000083a0 in just_a_test () at hello.c:7#1 0x000083c4 in main () at hello.c:14 很清晰的列出了出错的callstack 。
一诺网络香港免备案专区,提供「香港增强云服务器」和「香港特惠云服务器」两种类型的高可用弹性计算服务,搭载新一代英特尔®至强®铂金处理器,接入CN2低延时高速回国带宽线路,网络访问顺滑、流畅。机房网络架构采用了BGP协议的解决方案可提供多线路互联融合网络,使得不同网络运营商线路的用户都能通过最佳路由实现快速访问。香港云服务器低至29元/月,购买链接:https://www.enuoidc.com/vps.html?typeid=2