diff options
author | Nick Mathewson <nickm@torproject.org> | 2013-07-19 14:09:58 -0400 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2013-11-18 10:43:14 -0500 |
commit | 063bea58bcc1c27864a0351bba07254855903377 (patch) | |
tree | 8a0f0ea303fbbc4b86d31c54dd9da761f658f4e2 /src/common/util.c | |
parent | f6d8bc9389db72dc654560d0f86fd3edd3b14934 (diff) | |
download | tor-063bea58bcc1c27864a0351bba07254855903377.tar tor-063bea58bcc1c27864a0351bba07254855903377.tar.gz |
Basic backtrace ability
On platforms with the backtrace/backtrace_symbols_fd interface, Tor
can now dump stack traces on assertion failure. By default, I log
them to DataDir/stack_dump and to stderr.
Diffstat (limited to 'src/common/util.c')
-rw-r--r-- | src/common/util.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/common/util.c b/src/common/util.c index 814eb1379..0b65437b0 100644 --- a/src/common/util.c +++ b/src/common/util.c @@ -24,6 +24,7 @@ #include "torint.h" #include "container.h" #include "address.h" +#include "backtrace.h" #ifdef _WIN32 #include <io.h> @@ -101,8 +102,13 @@ void tor_assertion_failed_(const char *fname, unsigned int line, const char *func, const char *expr) { + char buf[256]; log_err(LD_BUG, "%s:%u: %s: Assertion %s failed; aborting.", fname, line, func, expr); + tor_snprintf(buf, sizeof(buf), + "Assertion %s failed in %s at %s:%u", + expr, func, fname, line); + dump_backtrace(buf); fprintf(stderr,"%s:%u: %s: Assertion %s failed; aborting.\n", fname, line, func, expr); } |