]> mj.ucw.cz Git - libucw.git/commitdiff
Failed ASSERT now dumps core.
authorMartin Mares <mj@ucw.cz>
Wed, 17 Jul 2002 19:14:09 +0000 (19:14 +0000)
committerMartin Mares <mj@ucw.cz>
Wed, 17 Jul 2002 19:14:09 +0000 (19:14 +0000)
lib/lib.h
lib/log.c

index e2bc3ef434cf34a166175ba2e085eeab6393b160..8ca2d156dca249984c1314176603937ef8dbb1f2 100644 (file)
--- a/lib/lib.h
+++ b/lib/lib.h
 
 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
index eb3c0ab26d4736034b906fca3d5dacc445f61649..a0e0b532ca76429c699f6dcff23207135d5c92c4 100644 (file)
--- 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)
 {