Commit 2717702e by Nicolas Capens Committed by Nicolas Capens

Eliminate the ABORT() macro

Terminating the process should be done with extreme caution. Usually DABORT() is intended to be used instead. The ABORT() macro was making it too easy to write code that causes the application to terminate in relatively benign circumstances. If scenarios are encountered which demand process termination (as prescribed by the graphics API spec or as a platform requirement), we can still use ::abort(), or bring back this macro with a scarier name. Bug: b/154650520 Change-Id: I53780f72b22faadd62825d000661b605b77b597c Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/44208 Presubmit-Ready: Nicolas Capens <nicolascapens@google.com> Kokoro-Result: kokoro <noreply+kokoro@google.com> Tested-by: 's avatarNicolas Capens <nicolascapens@google.com> Reviewed-by: 's avatarAlexis Hétu <sugoi@google.com>
parent 002b7c19
...@@ -69,23 +69,15 @@ void trace_assert(const char *format, ...) CHECK_PRINTF_ARGS; ...@@ -69,23 +69,15 @@ void trace_assert(const char *format, ...) CHECK_PRINTF_ARGS;
// A macro to print a warning message to the debugging log and stderr. // A macro to print a warning message to the debugging log and stderr.
#define WARN(message, ...) rr::warn("%s:%d WARNING: " message "\n", __FILE__, __LINE__, ##__VA_ARGS__) #define WARN(message, ...) rr::warn("%s:%d WARNING: " message "\n", __FILE__, __LINE__, ##__VA_ARGS__)
// A macro that prints the message to the debugging log and stderr and
// immediately aborts execution of the application.
//
// Note: This will terminate the application regardless of build flags!
// Use with extreme caution!
#undef ABORT
#define ABORT(message, ...) rr::abort("%s:%d ABORT: " message "\n", __FILE__, __LINE__, ##__VA_ARGS__)
// A macro that delegates to: // A macro that delegates to:
// ABORT() in debug builds (!NDEBUG || DCHECK_ALWAYS_ON) // abort() in debug builds (!NDEBUG || DCHECK_ALWAYS_ON)
// or // or
// WARN() in release builds (NDEBUG && !DCHECK_ALWAYS_ON) // warn() in release builds (NDEBUG && !DCHECK_ALWAYS_ON)
#undef DABORT #undef DABORT
#if !defined(NDEBUG) || defined(DCHECK_ALWAYS_ON) #if !defined(NDEBUG) || defined(DCHECK_ALWAYS_ON)
# define DABORT(message, ...) ABORT(message, ##__VA_ARGS__) # define DABORT(message, ...) rr::abort("%s:%d ABORT: " message "\n", __FILE__, __LINE__, ##__VA_ARGS__)
#else #else
# define DABORT(message, ...) WARN(message, ##__VA_ARGS__) # define DABORT(message, ...) rr::warn("%s:%d WARNING: " message "\n", __FILE__, __LINE__, ##__VA_ARGS__);
#endif #endif
// A macro asserting a condition. // A macro asserting a condition.
......
...@@ -69,23 +69,15 @@ void log_trap(const char *format, ...) CHECK_PRINTF_ARGS; ...@@ -69,23 +69,15 @@ void log_trap(const char *format, ...) CHECK_PRINTF_ARGS;
// A macro to print a warning message to the debugging log and stderr. // A macro to print a warning message to the debugging log and stderr.
#define WARN(message, ...) sw::warn("%s:%d WARNING: " message "\n", __FILE__, __LINE__, ##__VA_ARGS__) #define WARN(message, ...) sw::warn("%s:%d WARNING: " message "\n", __FILE__, __LINE__, ##__VA_ARGS__)
// A macro that prints the message to the debugging log and stderr and
// immediately aborts execution of the application.
//
// Note: This will terminate the application regardless of build flags!
// Use with extreme caution!
#undef ABORT
#define ABORT(message, ...) sw::abort("%s:%d ABORT: " message "\n", __FILE__, __LINE__, ##__VA_ARGS__)
// A macro that delegates to: // A macro that delegates to:
// ABORT() in debug builds (!NDEBUG || DCHECK_ALWAYS_ON) // abort() in debug builds (!NDEBUG || DCHECK_ALWAYS_ON)
// or // or
// WARN() in release builds (NDEBUG && !DCHECK_ALWAYS_ON) // warn() in release builds (NDEBUG && !DCHECK_ALWAYS_ON)
#undef DABORT #undef DABORT
#if !defined(NDEBUG) || defined(DCHECK_ALWAYS_ON) #if !defined(NDEBUG) || defined(DCHECK_ALWAYS_ON)
# define DABORT(message, ...) ABORT(message, ##__VA_ARGS__) # define DABORT(message, ...) sw::abort("%s:%d ABORT: " message "\n", __FILE__, __LINE__, ##__VA_ARGS__)
#else #else
# define DABORT(message, ...) WARN(message, ##__VA_ARGS__) # define DABORT(message, ...) sw::warn("%s:%d WARNING: " message "\n", __FILE__, __LINE__, ##__VA_ARGS__);
#endif #endif
// A macro asserting a condition. // A macro asserting a condition.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment