From: Christian Grothoff Date: Sat, 5 Nov 2011 18:47:50 +0000 (+0000) Subject: introducing GNUNET_abort X-Git-Tag: initial-import-from-subversion-38251~16020 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=e1196c2c76e6a4a142a91bb9e0a0fae1a06f68fc;p=oweals%2Fgnunet.git introducing GNUNET_abort --- diff --git a/src/datacache/plugin_datacache_mysql.c b/src/datacache/plugin_datacache_mysql.c index cf282dbdc..9185c5ca1 100644 --- a/src/datacache/plugin_datacache_mysql.c +++ b/src/datacache/plugin_datacache_mysql.c @@ -100,7 +100,7 @@ * a failure of the command 'cmd' with the message given * by strerror(errno). */ -#define DIE_MYSQL(cmd, dbh) do { GNUNET_log(GNUNET_ERROR_TYPE__ERROR, _("`%s' failed at %s:%d with error: %s\n"), cmd, __FILE__, __LINE__, mysql_error((dbh)->dbf)); abort(); } while(0); +#define DIE_MYSQL(cmd, dbh) do { GNUNET_log(GNUNET_ERROR_TYPE__ERROR, _("`%s' failed at %s:%d with error: %s\n"), cmd, __FILE__, __LINE__, mysql_error((dbh)->dbf)); GNUNET_abort(); } while(0); /** * Log an error message at log-level 'level' that indicates diff --git a/src/datastore/plugin_datastore_mysql.c b/src/datastore/plugin_datastore_mysql.c index 1048a370f..a6e65eeec 100644 --- a/src/datastore/plugin_datastore_mysql.c +++ b/src/datastore/plugin_datastore_mysql.c @@ -136,7 +136,7 @@ * a failure of the command 'cmd' with the message given * by strerror(errno). */ -#define DIE_MYSQL(cmd, dbh) do { GNUNET_log(GNUNET_ERROR_TYPE_ERROR, _("`%s' failed at %s:%d with error: %s\n"), cmd, __FILE__, __LINE__, mysql_error((dbh)->dbf)); abort(); } while(0); +#define DIE_MYSQL(cmd, dbh) do { GNUNET_log(GNUNET_ERROR_TYPE_ERROR, _("`%s' failed at %s:%d with error: %s\n"), cmd, __FILE__, __LINE__, mysql_error((dbh)->dbf)); GNUNET_abort(); } while(0); /** * Log an error message at log-level 'level' that indicates diff --git a/src/fs/fs.c b/src/fs/fs.c index 93971075a..83c0bf271 100644 --- a/src/fs/fs.c +++ b/src/fs/fs.c @@ -2464,7 +2464,7 @@ deserialize_download (struct GNUNET_FS_Handle *h, } if (parent != NULL) { - abort (); // for debugging for now + GNUNET_abort (); // for debugging for now - FIXME GNUNET_CONTAINER_DLL_insert (parent->child_head, parent->child_tail, dc); } if (search != NULL) diff --git a/src/hello/hello.c b/src/hello/hello.c index a0c26d1ab..a95c0eee2 100644 --- a/src/hello/hello.c +++ b/src/hello/hello.c @@ -130,7 +130,6 @@ get_hello_address_size (const char *buf, size_t max, uint16_t * ralen) { /* 0-termination not found */ GNUNET_break_op (0); - abort (); return 0; } pos++; diff --git a/src/include/gnunet_common.h b/src/include/gnunet_common.h index 8f3ff8127..69a428bb5 100644 --- a/src/include/gnunet_common.h +++ b/src/include/gnunet_common.h @@ -245,6 +245,13 @@ GNUNET_log_from_nocheck (enum GNUNET_ErrorType kind, const char *comp, #define GNUNET_log_from(...) #endif + +/** + * Abort the process, generate a core dump if possible. + */ +void +GNUNET_abort (void); + /** * Ignore the next n calls to the log function. * @@ -351,12 +358,12 @@ GNUNET_error_type_to_string (enum GNUNET_ErrorType kind); /** * Use this for fatal errors that cannot be handled */ -#define GNUNET_assert(cond) do { if (! (cond)) { GNUNET_log(GNUNET_ERROR_TYPE_ERROR, _("Assertion failed at %s:%d.\n"), __FILE__, __LINE__); abort(); } } while(0) +#define GNUNET_assert(cond) do { if (! (cond)) { GNUNET_log(GNUNET_ERROR_TYPE_ERROR, _("Assertion failed at %s:%d.\n"), __FILE__, __LINE__); GNUNET_abort(); } } while(0) /** * Use this for fatal errors that cannot be handled */ -#define GNUNET_assert_at(cond, f, l) do { if (! (cond)) { GNUNET_log(GNUNET_ERROR_TYPE_ERROR, _("Assertion failed at %s:%d.\n"), f, l); abort(); } } while(0) +#define GNUNET_assert_at(cond, f, l) do { if (! (cond)) { GNUNET_log(GNUNET_ERROR_TYPE_ERROR, _("Assertion failed at %s:%d.\n"), f, l); GNUNET_abort(); } } while(0) /** * Use this for internal assertion violations that are diff --git a/src/util/common_allocation.c b/src/util/common_allocation.c index 340ad5334..fd5e993e2 100644 --- a/src/util/common_allocation.c +++ b/src/util/common_allocation.c @@ -67,7 +67,7 @@ GNUNET_xmalloc_ (size_t size, const char *filename, int linenumber) if (ret == NULL) { LOG_STRERROR (GNUNET_ERROR_TYPE_ERROR, "malloc"); - abort (); + GNUNET_abort (); } return ret; } @@ -103,7 +103,7 @@ GNUNET_xmemdup_ (const void *buf, size_t size, const char *filename, if (ret == NULL) { LOG_STRERROR (GNUNET_ERROR_TYPE_ERROR, "malloc"); - abort (); + GNUNET_abort (); } #ifdef W32_MEM_LIMIT *((size_t *) ret) = size; @@ -174,7 +174,7 @@ GNUNET_xrealloc_ (void *ptr, size_t n, const char *filename, int linenumber) if ((NULL == ptr) && (n > 0)) { LOG_STRERROR (GNUNET_ERROR_TYPE_ERROR, "realloc"); - abort (); + GNUNET_abort (); } #ifdef W32_MEM_LIMIT ptr = &((size_t *) ptr)[1]; diff --git a/src/util/common_logging.c b/src/util/common_logging.c index 101f2fd9f..e96fb8e78 100644 --- a/src/util/common_logging.c +++ b/src/util/common_logging.c @@ -260,6 +260,20 @@ resize_logdefs () logdefs = GNUNET_realloc (logdefs, logdefs_size * sizeof (struct LogDef)); } + +/** + * Abort the process, generate a core dump if possible. + */ +void +GNUNET_abort () +{ +#if WINDOWS + DebugBreak(); +#endif + abort(); +} + + /** * Utility function - adds a parsed definition to logdefs array. * diff --git a/src/util/crypto_random.c b/src/util/crypto_random.c index c74d60f4f..719acf07c 100644 --- a/src/util/crypto_random.c +++ b/src/util/crypto_random.c @@ -266,7 +266,7 @@ void __attribute__ ((constructor)) GNUNET_CRYPTO_random_init () _ ("libgcrypt has not the expected version (version %s is required).\n"), GCRYPT_VERSION); - abort (); + GNUNET_abort (); } #ifdef gcry_fast_random_poll gcry_fast_random_poll (); diff --git a/src/util/scheduler.c b/src/util/scheduler.c index 0c4374471..82b888fec 100644 --- a/src/util/scheduler.c +++ b/src/util/scheduler.c @@ -676,7 +676,7 @@ run_ready (struct GNUNET_NETWORK_FDSet *rs, struct GNUNET_NETWORK_FDSet *ws) if (((tc.reason & GNUNET_SCHEDULER_REASON_WRITE_READY) != 0) && (pos->write_fd != -1) && (!GNUNET_NETWORK_fdset_test_native (ws, pos->write_fd))) - abort (); // added to ready in previous select loop! + GNUNET_abort (); // added to ready in previous select loop! #if DEBUG_TASKS LOG (GNUNET_ERROR_TYPE_DEBUG, "Running task: %llu / %p\n", pos->id, pos->callback_cls); @@ -852,7 +852,7 @@ GNUNET_SCHEDULER_run (GNUNET_SCHEDULER_Task task, void *task_cls) LOG_STRERROR (GNUNET_ERROR_TYPE_WARNING, "system"); #endif #endif - abort (); + GNUNET_abort (); break; } if ((ret == 0) && (timeout.rel_value == 0) && (busy_wait_warning > 16))