确定我的C程序核心在solaris上转储的位置 [英] Determine where my C program core dump on solaris
问题描述
我想知道我的C程序核心转储的位置(哪一行)。
如何做到这一点?
是否有一个描述该程序的网站? br />
一种方法是使用mdb调试器的堆栈跟踪,但我没有完全了解它的输出。
例如如何解释堆栈跟踪以找出测试程序中
coredump_func函数内的哪一行导致了
核心转储?
$ CC -g coredump_fn.c
$ a.out
hello
分段错误(核心转储)
$ mdb core
加载模块:[libc.so.1 ld.so.1]
:: stack
libc.so.1`strlen + 0x18(10c76,ffbffbc4,ffbff441,7b,0,0)
libc.so .1`printf + 0xd8(10c70,ff2e87dc,ff2e87fa,ff2e8368,ff2e4280,4)
__1cNcoredump_func6F_i_ + 0x20(6,ff2e87dc,ff2e87fa,ff2e8368,ff2e4280,
6 )
main + 0x20(1,ffbffcbc,ffbffcc4,20c00,ff3301c0,ff330200)
_start + 0xb8(0,0,0,0,0)
>
/ * coredump_fn.c:核心转储生成的C测试程序* /
#include< stdio.h> ;
int coredump_func(){
char * ptr = 0;
ptr =(char *)123;
printf(" ptr%s \ n",ptr);
返回0;
}
int main(int argc,char * argv [])
{
int i = 0;
double x;
printf(" hello \ n");
coredump_func();
x = 1.0 / i;
printf(" x%f\ n",x);
返回0;
}
>
CC -g coredump_fn.c
a.out
你好
分段错误(核心转储)
mdb核心
加载模块:[libc.so.1 ld .so.1]
:: stack
libc.so.1`strl en + 0x18(10c76,ffbffbc4,ffbff441,7b,0,0)
libc.so.1`printf + 0xd8(10c70,ff2e87dc,ff2e87fa,ff2e8368,ff2e4280,4)
__1cNcoredump_func6F_i_ + 0x20(6,ff2e87dc,ff2e87fa,ff2e8368,ff2e4280,
6)
main + 0x20(1,ffbffcbc,ffbffcc4,20c00,ff3301c0, ff330200)
_start + 0xb8(0,0,0,0,0,0)
>
/ * coredump_fn.c:核心转储生成的C测试程序* /
#include< stdio.h> ;
int coredump_func(){
char * ptr = 0;
ptr =(char *)123;
printf(" ptr%s \ n",ptr);
返回0;
}
int main(int argc,char * argv [])
{
int i = 0;
double x;
printf(" hello \ n");
coredump_func();
x = 1.0 / i;
printf(" x%f\ n",x);
返回0;
}
>
I want to find out where (which line) my C program core dump.
How to do that?
Is there a web site describing the procedure?
One approach is to use stack trace of the mdb debugger, but I does not
understand its output completely.
e.g. How to interpret the stack trace to find out which line inside the
coredump_func function of a test program caused the
core dump?
$ CC -g coredump_fn.c
$ a.out
hello
Segmentation Fault (core dumped)
$ mdb core
Loading modules: [ libc.so.1 ld.so.1 ]
::stack
libc.so.1`strlen+0x18(10c76, ffbffbc4, ffbff441, 7b, 0, 0)
libc.so.1`printf+0xd8(10c70, ff2e87dc, ff2e87fa, ff2e8368, ff2e4280, 4)
__1cNcoredump_func6F_i_+0x20(6, ff2e87dc, ff2e87fa, ff2e8368, ff2e4280,
6)
main+0x20(1, ffbffcbc, ffbffcc4, 20c00, ff3301c0, ff330200)
_start+0xb8(0, 0, 0, 0, 0, 0)
>
/* coredump_fn.c : C test program for core dump generation */
#include <stdio.h>
int coredump_func() {
char *ptr = 0;
ptr = (char *) 123;
printf("ptr %s\n", ptr);
return 0;
}
int main(int argc, char *argv[])
{
int i = 0;
double x;
printf("hello\n");
coredump_func();
x = 1.0 / i;
printf("x %f\n", x);
return 0;
}
CC -g coredump_fn.c
a.out
hello
Segmentation Fault (core dumped)
mdb core
Loading modules: [ libc.so.1 ld.so.1 ]::stacklibc.so.1`strlen+0x18(10c76, ffbffbc4, ffbff441, 7b, 0, 0)
libc.so.1`printf+0xd8(10c70, ff2e87dc, ff2e87fa, ff2e8368, ff2e4280, 4)
__1cNcoredump_func6F_i_+0x20(6, ff2e87dc, ff2e87fa, ff2e8368, ff2e4280,
6)
main+0x20(1, ffbffcbc, ffbffcc4, 20c00, ff3301c0, ff330200)
_start+0xb8(0, 0, 0, 0, 0, 0)>
/* coredump_fn.c : C test program for core dump generation */
#include <stdio.h>
int coredump_func() {
char *ptr = 0;
ptr = (char *) 123;
printf("ptr %s\n", ptr);
return 0;
}
int main(int argc, char *argv[])
{
int i = 0;
double x;
printf("hello\n");
coredump_func();
x = 1.0 / i;
printf("x %f\n", x);
return 0;
}
这篇关于确定我的C程序核心在solaris上转储的位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!