기본 콘텐츠로 건너뛰기

3월, 2013의 게시물 표시

glog 를 이용하여 SIGSEGV 스택정보 파일로 저장하기.

unix계열에서  c/c++로 코딩하면 전체 core파일을 용량때문에 남기기 힘든데 glog를 사용하면 sigsegv가 발생해도 stack정보를 남길 수 있는 function을 제공합니다. #include <cstdio> #include <sys/types.h> #include <sys/stat.h> #include <fcntl.h> int fd = 0; void write_to_core(const char* data, int size) { write(fd, data, size); } int main(int argc, char *argv[]) { InstallFailureWriter(write_to_core); InstallFailureSignalHandler(); InitGoogleLogging(argv[0]); fd = open("core.txt", O_CREAT | O_WRONLY , 0644); int a = 10 / 0; return 0; } 참고: http://google-glog.googlecode.com/svn/trunk/doc/glog.html