damon:: TRACEBACK() utility macro added to trace back a function call.
authorAmarnath Valluri <amarnath.valluri@linux.intel.com>
Tue, 18 Jun 2013 14:05:27 +0000 (17:05 +0300)
committerAmarnath Valluri <amarnath.valluri@linux.intel.com>
Tue, 18 Jun 2013 14:07:10 +0000 (17:07 +0300)
include/gsignond/gsignond-log.h

index 88c1452..ede7ac4 100644 (file)
 #define __GSIGNOND_LOG_H_
 
 #include <glib.h>
+#include "config.h"
+
+
+#ifdef ENABLE_DEBUG
+
+#include <execinfo.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+#define TRACEBACK() \
+{ \
+    void *array[256];\
+    size_t size, i;\
+    char **strings;\
+\
+    fprintf (stderr, "Backtrace for: %s %s\n", __FILE__, __PRETTY_FUNCTION__); \
+    size = backtrace (array, 256);\
+    strings = backtrace_symbols (array, size);\
+    if (strings) { \
+        for (i=0; i <size; i++) fprintf (stderr, "\t%s\n", strings[i]);\
+        free (strings);\
+    }\
+}
+#endif /* ENABLE_DEBUG */
 
 #define INFO(frmt, args...) g_message("%f %s:%d %s " frmt , \
         g_get_monotonic_time()*1.0e-6, __FILE__, __LINE__, \