From 65474ccb9f865e1e8267bb4e544997634764dcb1 Mon Sep 17 00:00:00 2001 From: Martin Mares Date: Wed, 17 Jul 2002 19:14:09 +0000 Subject: [PATCH] Failed ASSERT now dumps core. --- lib/lib.h | 3 ++- lib/log.c | 7 +++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/lib.h b/lib/lib.h index e2bc3ef4..8ca2d156 100644 --- a/lib/lib.h +++ b/lib/lib.h @@ -47,12 +47,13 @@ void log(unsigned int cat, const char *msg, ...) __attribute__((format(printf,2,3))); void die(byte *, ...) NONRET; +void assert_failed(char *assertion, char *file, int line) NONRET; void log_init(byte *); void log_file(byte *); void log_fork(void); #ifdef DEBUG -#define ASSERT(x) do { if (!(x)) die("Assertion `%s' failed at %s:%d", #x, __FILE__, __LINE__); } while(0) +#define ASSERT(x) do { if (!(x)) assert_failed(#x, __FILE__, __LINE__); } while(0) #else #define ASSERT(x) do { } while(0) #endif diff --git a/lib/log.c b/lib/log.c index eb3c0ab2..a0e0b532 100644 --- a/lib/log.c +++ b/lib/log.c @@ -93,6 +93,13 @@ die(byte *msg, ...) exit(1); } +void +assert_failed(char *assertion, char *file, int line) +{ + log(L_FATAL, "Assertion `%s' failed at %s:%d", assertion, file, line); + abort(); +} + static byte * log_basename(byte *n) { -- 2.39.2