summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2016-04-30 01:41:34 +0300
committerAndrei Karas <akaras@inbox.ru>2016-04-30 01:41:34 +0300
commit22795c4301cd6b62a8270b45a72a850ed888daf8 (patch)
tree6180229d4c537ea46d24b187251c67f0131197b4 /src
parent3fcfe6db5678ecde9ca20ca058c1a603cc8abfc2 (diff)
downloadplus-22795c4301cd6b62a8270b45a72a850ed888daf8.tar.gz
plus-22795c4301cd6b62a8270b45a72a850ed888daf8.tar.bz2
plus-22795c4301cd6b62a8270b45a72a850ed888daf8.tar.xz
plus-22795c4301cd6b62a8270b45a72a850ed888daf8.zip
Add function for report call stack.
Diffstat (limited to 'src')
-rw-r--r--src/utils/checkutils.cpp34
-rw-r--r--src/utils/checkutils.h6
2 files changed, 40 insertions, 0 deletions
diff --git a/src/utils/checkutils.cpp b/src/utils/checkutils.cpp
index 8aa82bc11..2fc471d7e 100644
--- a/src/utils/checkutils.cpp
+++ b/src/utils/checkutils.cpp
@@ -24,6 +24,10 @@
#include "logger.h"
+#if defined __linux__ || defined __linux
+#include <execinfo.h>
+#endif // defined __linux__ || defined __linux
+
#include "debug.h"
bool reportFalseReal(const bool val, const char *const file,
@@ -42,4 +46,34 @@ bool reportTrueReal(const bool val, const char *const file,
return val;
}
+void reportStack(const char *const file,
+ const unsigned int line,
+ const char *const func,
+ const char *const name,
+ const char *const text)
+{
+#if defined __linux__ || defined __linux
+ void *array[15];
+ int size;
+ char **strings;
+ int i;
+#endif // defined __linux__ || defined __linux
+
+ logger->log("--- %s --------------------------------------------",
+ name);
+ logger->log("%s:%u: '%s' in function `%s'",
+ file,
+ line,
+ text,
+ func);
+#if defined __linux__ || defined __linux
+ size = (int)backtrace(array, 15);
+ strings = backtrace_symbols(array, size);
+ for (i = 0; i < size; i++)
+ logger->log1(strings[i]);
+ free(strings);
+#endif // defined __linux__ || defined __linux
+
+}
+
#endif // ENABLE_ASSERTS
diff --git a/src/utils/checkutils.h b/src/utils/checkutils.h
index ce4fcdc61..21f439743 100644
--- a/src/utils/checkutils.h
+++ b/src/utils/checkutils.h
@@ -35,6 +35,12 @@ bool reportFalseReal(const bool val, const char *const file,
bool reportTrueReal(const bool val, const char *const file,
const unsigned line);
+void reportStack(const char *const file,
+ const unsigned int line,
+ const char *const func,
+ const char *const name,
+ const char *const text);
+
#else // ENABLE_ASSERTS
#define reportFalse(val) (val)