diff --git a/src/core/common/debug.hpp b/src/core/common/debug.hpp index 50dd2b2b2..81bc5596f 100644 --- a/src/core/common/debug.hpp +++ b/src/core/common/debug.hpp @@ -41,13 +41,7 @@ #if OPENTHREAD_CONFIG_ASSERT_ENABLE -#if defined(__APPLE__) || defined(__linux__) - -#include - -#define OT_ASSERT(cond) assert(cond) - -#elif OPENTHREAD_CONFIG_PLATFORM_ASSERT_MANAGEMENT +#if OPENTHREAD_CONFIG_PLATFORM_ASSERT_MANAGEMENT #include "openthread/platform/misc.h" @@ -71,6 +65,12 @@ } \ } while (0) +#elif defined(__APPLE__) || defined(__linux__) + +#include + +#define OT_ASSERT(cond) assert(cond) + #else // OPENTHREAD_CONFIG_PLATFORM_ASSERT_MANAGEMENT #define OT_ASSERT(cond) \ diff --git a/src/posix/platform/misc.cpp b/src/posix/platform/misc.cpp index ee9825442..b72fe7168 100644 --- a/src/posix/platform/misc.cpp +++ b/src/posix/platform/misc.cpp @@ -76,6 +76,14 @@ otError otPlatSetMcuPowerState(otInstance *aInstance, otPlatMcuPowerState aState return error; } +void otPlatAssertFail(const char *aFilename, int aLineNumber) +{ + otLogCritPlat("assert failed at %s:%d", aFilename, aLineNumber); + // For debug build, use assert to genreate a core dump + assert(false); + exit(1); +} + otPlatMcuPowerState otPlatGetMcuPowerState(otInstance *aInstance) { OT_UNUSED_VARIABLE(aInstance);