summaryrefslogtreecommitdiff
path: root/src/common/util_bug.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2016-04-03 16:48:44 -0400
committerNick Mathewson <nickm@torproject.org>2016-04-04 11:06:04 -0400
commit7865402106e9af273b9c887484b8371a899683ad (patch)
treeb35419624bb3bdaccd02b0b515453760700e6b25 /src/common/util_bug.c
parent705d3b221e4011b4d041dd486c98f42201322193 (diff)
downloadtor-7865402106e9af273b9c887484b8371a899683ad.tar.gz
tor-7865402106e9af273b9c887484b8371a899683ad.zip
Move tor_assert implementation into its own header/module.
Diffstat (limited to 'src/common/util_bug.c')
-rw-r--r--src/common/util_bug.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/src/common/util_bug.c b/src/common/util_bug.c
new file mode 100644
index 0000000000..139d139e8c
--- /dev/null
+++ b/src/common/util_bug.c
@@ -0,0 +1,28 @@
+/* Copyright (c) 2003, Roger Dingledine
+ * Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
+ * Copyright (c) 2007-2016, The Tor Project, Inc. */
+/* See LICENSE for licensing information */
+
+/**
+ * \file util_bug.c
+ **/
+
+#include "orconfig.h"
+#include "util_bug.h"
+#include "torlog.h"
+#include "backtrace.h"
+
+/** Helper for tor_assert: report the assertion failure. */
+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);
+ log_backtrace(LOG_ERR, LD_BUG, buf);
+}
+