From: Martin Mares Date: Wed, 17 Jul 2002 19:14:09 +0000 (+0000) Subject: Failed ASSERT now dumps core. X-Git-Tag: holmes-import~1377 X-Git-Url: http://mj.ucw.cz/gitweb/?a=commitdiff_plain;h=65474ccb9f865e1e8267bb4e544997634764dcb1;p=libucw.git Failed ASSERT now dumps core. --- 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) {