반응형
How to print a stack trace in your user space linux application
원본> http://kungjohan.blogspot.kr/2012/06/how-to-print-stack-trace-in-your-user.html
Compile the program with:
gcc -g -rdynamic stack_trace.c -o stack_trace
Test program:
#include <stdio.h>
#include <stdlib.h>
#include <execinfo.h>
#include <stdlib.h>
#include <execinfo.h>
void stack_trace(){
void *trace[16];
char **messages = (char **)NULL;
int i, trace_size = 0;
trace_size = backtrace(trace, 16);
messages = backtrace_symbols(trace, trace_size);
printf("[stack trace]>>>\n");
for (i=0; i < trace_size; i++)
printf("%s\n", messages[i]);
printf("<<<[stack trace]\n");
free(messages);
}
void main(){
stack_trace();
}
보다 자세한 참조는 아래 링크를 참조바랍니다
반응형
'프로그램...' 카테고리의 다른 글
[용어] ALC(RFC 3450=>5775 - Asynchronous Layered Coding) (0) | 2017.11.15 |
---|---|
[Python] 파이썬 다운 생각 (0) | 2017.10.17 |
[특수문자] (0) | 2016.01.14 |
[C1004W] Booting Log (0) | 2015.10.29 |
[C-printf] %n %*s 포맷 사용법 (0) | 2015.10.05 |