diff --git a/src/node.cc b/src/node.cc index bc328ad88a..fe53b9629e 100644 --- a/src/node.cc +++ b/src/node.cc @@ -1788,8 +1788,15 @@ void GetActiveHandles(const FunctionCallbackInfo& args) { } +NO_RETURN void Abort() { + DumpBacktrace(stderr); + fflush(stderr); + ABORT_NO_BACKTRACE(); +} + + static void Abort(const FunctionCallbackInfo& args) { - ABORT(); + Abort(); } diff --git a/src/node_internals.h b/src/node_internals.h index f9370c0a29..7d0a37e5d0 100644 --- a/src/node_internals.h +++ b/src/node_internals.h @@ -134,12 +134,10 @@ constexpr size_t arraysize(const T(&)[N]) { return N; } # define ROUND_UP(a, b) ((a) % (b) ? ((a) + (b)) - ((a) % (b)) : (a)) #endif -#if defined(__GNUC__) && __GNUC__ >= 4 +#ifdef __GNUC__ # define MUST_USE_RESULT __attribute__((warn_unused_result)) -# define NO_RETURN __attribute__((noreturn)) #else # define MUST_USE_RESULT -# define NO_RETURN #endif bool IsExceptionDecorated(Environment* env, v8::Local er); diff --git a/src/util.h b/src/util.h index f3f123c6d1..a02639affb 100644 --- a/src/util.h +++ b/src/util.h @@ -19,6 +19,13 @@ namespace node { +#ifdef __GNUC__ +#define NO_RETURN __attribute__((noreturn)) +#else +#define NO_RETURN +#endif + +NO_RETURN void Abort(); void DumpBacktrace(FILE* fp); #ifdef __APPLE__ @@ -43,12 +50,7 @@ template using remove_reference = std::remove_reference; #define ABORT_NO_BACKTRACE() abort() #endif -#define ABORT() \ - do { \ - node::DumpBacktrace(stderr); \ - fflush(stderr); \ - ABORT_NO_BACKTRACE(); \ - } while (0) +#define ABORT() node::Abort() #if defined(NDEBUG) # define ASSERT(expression)