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 notunderstand its output completely.e.g. How to interpret the stack trace to find out which line inside thecoredump_func function of a test program caused thecore dump?$ CC -g coredump_fn.c$ a.outhelloSegmentation Fault (core dumped)$ mdb coreLoading modules: [ libc.so.1 ld.so.1 ]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;} 解决方案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;} 这篇关于确定我的C程序核心在solaris上转储的位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
09-05 08:55