[debug] prefer user provided assert to system assert (#5624)

This allows users to enable OT_ASSERT in release builds on posix systems.
This commit is contained in:
Jiacheng Guo
2020-10-13 08:09:05 -07:00
committed by GitHub
parent 5ac1fbeade
commit 831406ce90
2 changed files with 15 additions and 7 deletions
+7 -7
View File
@@ -41,13 +41,7 @@
#if OPENTHREAD_CONFIG_ASSERT_ENABLE
#if defined(__APPLE__) || defined(__linux__)
#include <assert.h>
#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 <assert.h>
#define OT_ASSERT(cond) assert(cond)
#else // OPENTHREAD_CONFIG_PLATFORM_ASSERT_MANAGEMENT
#define OT_ASSERT(cond) \
+8
View File
@@ -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);