mutex: move mutex.h to standard name/location
[c11tester.git] / common.cc
1 #include <execinfo.h>
2 #include <stdio.h>
3 #include <stdlib.h>
4
5 #include "common.h"
6 #include "model.h"
7 #include "stacktrace.h"
8
9 #define MAX_TRACE_LEN 100
10
11 #define CONFIG_STACKTRACE
12 /** Print a backtrace of the current program state. */
13 void print_trace(void)
14 {
15 #ifdef CONFIG_STACKTRACE
16         print_stacktrace(stdout);
17 #else
18         void *array[MAX_TRACE_LEN];
19         char **strings;
20         int size, i;
21
22         size = backtrace(array, MAX_TRACE_LEN);
23         strings = backtrace_symbols(array, size);
24
25         printf("\nDumping stack trace (%d frames):\n", size);
26
27         for (i = 0; i < size; i++)
28                 printf("\t%s\n", strings[i]);
29
30         free(strings);
31 #endif /* CONFIG_STACKTRACE */
32 }
33
34 void model_print_summary(void)
35 {
36         model->print_summary();
37 }
38
39 void assert_hook(void)
40 {
41         printf("Add breakpoint to line %u in file %s.\n",__LINE__,__FILE__);
42 }