Skip to content

Commit

Permalink
src: move ABORT() logic into node::Abort()
Browse files Browse the repository at this point in the history
Don't inline calls to node::DumpBacktrace() and fflush(), it makes the
generated code bigger.  A secondary benefit of moving it to a function
is that it gives you something to put a breakpoint on.

PR-URL: nodejs#6734
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
  • Loading branch information
bnoordhuis committed Jun 29, 2016
1 parent 64edd06 commit be767cf
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 10 deletions.
9 changes: 8 additions & 1 deletion src/node.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1734,8 +1734,15 @@ void GetActiveHandles(const FunctionCallbackInfo<Value>& args) {
}


NO_RETURN void Abort() {
DumpBacktrace(stderr);
fflush(stderr);
ABORT_NO_BACKTRACE();
}


static void Abort(const FunctionCallbackInfo<Value>& args) {
ABORT();
Abort();
}


Expand Down
4 changes: 1 addition & 3 deletions src/node_internals.h
Original file line number Diff line number Diff line change
Expand Up @@ -127,12 +127,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<v8::Value> er);
Expand Down
14 changes: 8 additions & 6 deletions src/util.h
Original file line number Diff line number Diff line change
Expand Up @@ -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__
Expand All @@ -43,12 +50,7 @@ template <typename T> using remove_reference = std::remove_reference<T>;
#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)
Expand Down

0 comments on commit be767cf

Please sign in to comment.