34 lines
516 B
C
34 lines
516 B
C
#include <stdio.h>
|
|
#include "ucore/backtrace.h"
|
|
|
|
//note , compiling this without -rdynamic does not
|
|
//translate addresses to function names. Use the addr2line in that case
|
|
void func2(void)
|
|
{
|
|
uc_backtrace_fd(2);
|
|
}
|
|
|
|
void func3(void)
|
|
{
|
|
uc_backtrace_fd(2);
|
|
}
|
|
|
|
void func4(void)
|
|
{
|
|
char trace[256];
|
|
uc_backtrace_buf(trace, sizeof trace);
|
|
printf("Stacktrace from %s:\n%s", __func__, trace);
|
|
}
|
|
|
|
void func1(void)
|
|
{
|
|
func2();
|
|
func4();
|
|
}
|
|
|
|
int main(int argc, char *argv[])
|
|
{
|
|
func1();
|
|
return;
|
|
}
|