common: improve backtrace function
authorBrian Norris <banorris@uci.edu>
Sat, 6 Oct 2012 02:34:01 +0000 (19:34 -0700)
committerBrian Norris <banorris@uci.edu>
Sun, 7 Oct 2012 23:27:19 +0000 (16:27 -0700)
Utilize freely-available backtrace function that helps make output more
readable. Previous implementation is kept for now, as it is simpler and
more well-tested.

common.cc

index e05e094ea0105a9c2ce8e221cf95a1613d21074b..b274989f48bc4d885f6976b596139b1e5bde42ed 100644 (file)
--- a/common.cc
+++ b/common.cc
@@ -4,12 +4,17 @@
 
 #include "common.h"
 #include "model.h"
+#include "stacktrace.h"
 
 #define MAX_TRACE_LEN 100
 
+#define CONFIG_STACKTRACE
 /** Print a backtrace of the current program state. */
 void print_trace(void)
 {
+#ifdef CONFIG_STACKTRACE
+       print_stacktrace(stdout);
+#else
        void *array[MAX_TRACE_LEN];
        char **strings;
        int size, i;
@@ -23,6 +28,7 @@ void print_trace(void)
                printf("\t%s\n", strings[i]);
 
        free(strings);
+#endif /* CONFIG_STACKTRACE */
 }
 
 void model_print_summary(void)