util_bug.c 788 B

12345678910111213141516171819202122232425262728
  1. /* Copyright (c) 2003, Roger Dingledine
  2. * Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
  3. * Copyright (c) 2007-2016, The Tor Project, Inc. */
  4. /* See LICENSE for licensing information */
  5. /**
  6. * \file util_bug.c
  7. **/
  8. #include "orconfig.h"
  9. #include "util_bug.h"
  10. #include "torlog.h"
  11. #include "backtrace.h"
  12. /** Helper for tor_assert: report the assertion failure. */
  13. void
  14. tor_assertion_failed_(const char *fname, unsigned int line,
  15. const char *func, const char *expr)
  16. {
  17. char buf[256];
  18. log_err(LD_BUG, "%s:%u: %s: Assertion %s failed; aborting.",
  19. fname, line, func, expr);
  20. tor_snprintf(buf, sizeof(buf),
  21. "Assertion %s failed in %s at %s:%u",
  22. expr, func, fname, line);
  23. log_backtrace(LOG_ERR, LD_BUG, buf);
  24. }