summaryrefslogtreecommitdiff
path: root/src/common/nullpo.c
diff options
context:
space:
mode:
authormalufett <malufett.eat.my.binaries@gmail.com>2015-05-31 12:10:53 +0800
committermalufett <malufett.eat.my.binaries@gmail.com>2015-05-31 12:10:53 +0800
commit893e29db87053b1668878dd3c96cf312fb7ef93c (patch)
treeaffc1dffe355f2e3179a73e123b323d34469cfd5 /src/common/nullpo.c
parenta5a86059b8e70420f0a78d6a377b5702cdfe6792 (diff)
parentbba4ce885b0667f92e0b3f2a26759059317a4c3d (diff)
downloadhercules-893e29db87053b1668878dd3c96cf312fb7ef93c.tar.gz
hercules-893e29db87053b1668878dd3c96cf312fb7ef93c.tar.bz2
hercules-893e29db87053b1668878dd3c96cf312fb7ef93c.tar.xz
hercules-893e29db87053b1668878dd3c96cf312fb7ef93c.zip
Merge branch 'master' of https://github.com/HerculesWS/Hercules
Diffstat (limited to 'src/common/nullpo.c')
-rw-r--r--src/common/nullpo.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/common/nullpo.c b/src/common/nullpo.c
index e61d52257..97b206835 100644
--- a/src/common/nullpo.c
+++ b/src/common/nullpo.c
@@ -8,7 +8,11 @@
#include <stdio.h>
#include <stdarg.h>
+#include <stdlib.h>
#include <string.h>
+#ifdef __GNUC__
+#include <execinfo.h>
+#endif
#include "../common/showmsg.h"
@@ -24,6 +28,12 @@ struct nullpo_interface nullpo_s;
* @param title Message title to display (i.e. failed assertion or nullpo info)
*/
void assert_report(const char *file, int line, const char *func, const char *targetname, const char *title) {
+#ifdef __GNUC__
+ void *array[10];
+ int size;
+ char **strings;
+ int i;
+#endif
if (file == NULL)
file = "??";
@@ -32,6 +42,13 @@ void assert_report(const char *file, int line, const char *func, const char *tar
ShowError("--- %s --------------------------------------------\n", title);
ShowError("%s:%d: '%s' in function `%s'\n", file, line, targetname, func);
+#ifdef __GNUC__
+ size = backtrace (array, 10);
+ strings = backtrace_symbols (array, size);
+ for (i = 0; i < size; i++)
+ ShowError("%s\n", strings[i]);
+ free (strings);
+#endif
ShowError("--- end %s ----------------------------------------\n", title);
}