6 #define FW_ASSERT_DFL_MSG_LEN 256
8 #if FW_ASSERT_LEVEL == FW_NO_ASSERT
12 #if FW_ASSERT_LEVEL == FW_FILEID_ASSERT
13 #define fileIdFs "Assert file ID 0x%08X: Line: %d "
15 #define fileIdFs "Assert file \"%s\": Line: %d "
20 void defaultPrintAssert(
const CHAR* msg) {
21 (void)fprintf(stderr,
"%s\n", msg);
41 (void)snprintf(destBuffer,buffSize,fileIdFs,file,lineNo);
44 (void)snprintf(destBuffer,buffSize,fileIdFs
"%d",file,lineNo,
48 (void)snprintf(destBuffer,buffSize,fileIdFs
"%d %d",file,lineNo,
52 (void)snprintf(destBuffer,buffSize,fileIdFs
"%d %d %d",file,lineNo,
56 (void)snprintf(destBuffer,buffSize,fileIdFs
"%d %d %d %d",file,lineNo,
60 (void)snprintf(destBuffer,buffSize,fileIdFs
"%d %d %d %d %d",file,lineNo,
61 arg1,arg2,arg3,arg4,arg5);
64 (void)snprintf(destBuffer,buffSize,fileIdFs
"%d %d %d %d %d %d",file,lineNo,
65 arg1,arg2,arg3,arg4,arg5,arg6);
72 destBuffer[buffSize-1] = 0;
76 void AssertHook::printAssert(
const CHAR* msg) {
77 defaultPrintAssert(msg);
80 void AssertHook::reportAssert
109 this->printAssert(destBuffer);
112 void AssertHook::doAssert() {
116 STATIC AssertHook* s_assertHook =
nullptr;
118 void AssertHook::registerHook() {
119 this->previousHook = s_assertHook;
123 void AssertHook::deregisterHook() {
124 s_assertHook = this->previousHook;
128 if (
nullptr == s_assertHook) {
135 assertMsg,
sizeof(assertMsg));
137 defaultPrintAssert(assertMsg);
141 s_assertHook->reportAssert(
146 s_assertHook->doAssert();
153 if (
nullptr == s_assertHook) {
160 assertMsg,
sizeof(assertMsg));
162 defaultPrintAssert(assertMsg);
166 s_assertHook->reportAssert(
171 s_assertHook->doAssert();
179 if (
nullptr == s_assertHook) {
186 assertMsg,
sizeof(assertMsg));
187 defaultPrintAssert(assertMsg);
191 s_assertHook->reportAssert(
196 s_assertHook->doAssert();
205 if (
nullptr == s_assertHook) {
211 arg1,arg2,arg3,0,0,0,
212 assertMsg,
sizeof(assertMsg));
213 defaultPrintAssert(assertMsg);
217 s_assertHook->reportAssert(
221 arg1,arg2,arg3,0,0,0);
222 s_assertHook->doAssert();
232 if (
nullptr == s_assertHook) {
238 arg1,arg2,arg3,arg4,0,0,
239 assertMsg,
sizeof(assertMsg));
240 defaultPrintAssert(assertMsg);
244 s_assertHook->reportAssert(
248 arg1,arg2,arg3,arg4,0,0);
249 s_assertHook->doAssert();
260 if (
nullptr == s_assertHook) {
266 arg1,arg2,arg3,arg4,arg5,0,
267 assertMsg,
sizeof(assertMsg));
268 defaultPrintAssert(assertMsg);
272 s_assertHook->reportAssert(
276 arg1,arg2,arg3,arg4,arg5,0);
277 s_assertHook->doAssert();
289 if (
nullptr == s_assertHook) {
295 arg1,arg2,arg3,arg4,arg5,arg6,
296 assertMsg,
sizeof(assertMsg));
297 defaultPrintAssert(assertMsg);
301 s_assertHook->reportAssert(
305 arg1,arg2,arg3,arg4,arg5,arg6);
306 s_assertHook->doAssert();
318 if (
nullptr == Fw::s_assertHook) {
325 assertMsg,
sizeof(assertMsg));
328 Fw::s_assertHook->reportAssert(
333 Fw::s_assertHook->doAssert();
338 #endif // FW_NO_ASSERT