Skip to content

Commit

Permalink
util.c: backtrace is a GLIBC only feature.
Browse files Browse the repository at this point in the history
  • Loading branch information
Gottox committed May 16, 2016
1 parent 39aa39a commit a2eec4b
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions util.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@
#include <stdint.h>
#include <ctype.h>
#include <inttypes.h>
#ifdef __GLIBC__
#include <execinfo.h>
#endif
#include <sys/time.h>

#include "debug.h"
Expand Down Expand Up @@ -125,12 +127,14 @@ void print_stack_trace(void)
char **messages = (char **)NULL;
int i, trace_size = 0;

#ifdef __GLIBC__
trace_size = backtrace(trace, 16);
messages = backtrace_symbols(trace, trace_size);
printf("[stack trace follows]\n");
for (i=0; i < trace_size; i++)
printf("%s\n", messages[i]);
free(messages);
#endif
}

void record_start(struct elapsed_time *e, const char *name)
Expand Down

0 comments on commit a2eec4b

Please sign in to comment.