summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Bartell <pbartell@amazon.com>2023-03-20 11:05:53 -0700
committerPaul Bartell <paul.bartell@gmail.com>2023-03-30 12:32:55 -0700
commitc6325a02ff6f5ca680f41ad9c8a91b071ff668c8 (patch)
treeacd14b2761dd6563449b3628a630d65ff0f5b8b7
parent84ad9250daf05b3799658c1ae9e99c652b9e27e7 (diff)
downloadfreertos-git-c6325a02ff6f5ca680f41ad9c8a91b071ff668c8.tar.gz
Improve vAssertCalled function to include filename / line number info.
-rw-r--r--FreeRTOS/Demo/CORTEX_M3_MPS2_QEMU_GCC/FreeRTOSConfig.h20
-rw-r--r--FreeRTOS/Demo/CORTEX_M3_MPS2_QEMU_GCC/main.c55
2 files changed, 44 insertions, 31 deletions
diff --git a/FreeRTOS/Demo/CORTEX_M3_MPS2_QEMU_GCC/FreeRTOSConfig.h b/FreeRTOS/Demo/CORTEX_M3_MPS2_QEMU_GCC/FreeRTOSConfig.h
index 5455d1bcf..c312f4272 100644
--- a/FreeRTOS/Demo/CORTEX_M3_MPS2_QEMU_GCC/FreeRTOSConfig.h
+++ b/FreeRTOS/Demo/CORTEX_M3_MPS2_QEMU_GCC/FreeRTOSConfig.h
@@ -39,13 +39,25 @@
* See https://www.freertos.org/a00110.html
*----------------------------------------------------------*/
-#define configASSERT_DEFINED 1
-extern void vAssertCalled( void );
-#define configASSERT( x ) if( ( x ) == 0 ) vAssertCalled()
+#define configASSERT_DEFINED 1
+
+extern void vAssertCalled( const char * pcFileName,
+ int line );
+
+#define __NAME_ARG__ ( __builtin_strrchr( __BASE_FILE__, '/' ) ? __builtin_strrchr( __BASE_FILE__, '/' ) + 1 : __BASE_FILE__ )
+
+#define configASSERT( x ) \
+ do { \
+ if( ( x ) == 0 ) { \
+ vAssertCalled( __NAME_ARG__, __LINE__ ); \
+ } \
+ } while( 0 )
+
+
#define configQUEUE_REGISTRY_SIZE 20
#ifdef PICOLIBC_TLS
-#define configUSE_PICOLIBC_TLS 1
+ #define configUSE_PICOLIBC_TLS 1
#endif
#define configUSE_PREEMPTION 1
diff --git a/FreeRTOS/Demo/CORTEX_M3_MPS2_QEMU_GCC/main.c b/FreeRTOS/Demo/CORTEX_M3_MPS2_QEMU_GCC/main.c
index 9b534f38d..a8dd1e608 100644
--- a/FreeRTOS/Demo/CORTEX_M3_MPS2_QEMU_GCC/main.c
+++ b/FreeRTOS/Demo/CORTEX_M3_MPS2_QEMU_GCC/main.c
@@ -32,6 +32,7 @@
#include <string.h>
#include <stdarg.h>
#include <stdio.h>
+#include <stdlib.h>
void vApplicationStackOverflowHook( TaskHandle_t pxTask,
char * pcTaskName );
@@ -56,17 +57,17 @@ StackType_t uxTimerTaskStack[ configTIMER_TASK_STACK_DEPTH ];
int main()
{
#if ( mainCREATE_SIMPLE_BLINKY_DEMO_ONLY == 1 )
- {
- main_blinky();
- }
+ {
+ main_blinky();
+ }
#elif ( mainCREATE_FULL_DEMO_ONLY == 1 )
- {
- main_full();
- }
+ {
+ main_full();
+ }
#else
- {
- #error "Invalid Selection...\nPlease Select a Demo application from the main command"
- }
+ {
+ #error "Invalid Selection...\nPlease Select a Demo application from the main command"
+ }
#endif /* if ( mainCREATE_SIMPLE_BLINKY_DEMO_ONLY == 1 ) */
return 0;
}
@@ -108,11 +109,11 @@ void vApplicationStackOverflowHook( TaskHandle_t pxTask,
void vApplicationIdleHook( void )
{
#if ( mainCREATE_FULL_DEMO_ONLY == 1 )
- {
- /* Call the idle task processing used by the full demo. The simple
- * blinky demo does not use the idle task hook. */
- vFullDemoIdleFunction();
- }
+ {
+ /* Call the idle task processing used by the full demo. The simple
+ * blinky demo does not use the idle task hook. */
+ vFullDemoIdleFunction();
+ }
#endif
}
/*-----------------------------------------------------------*/
@@ -120,28 +121,28 @@ void vApplicationIdleHook( void )
void vApplicationTickHook( void )
{
#if ( mainCREATE_FULL_DEMO_ONLY == 1 )
- {
- vFullDemoTickHookFunction();
- }
+ {
+ vFullDemoTickHookFunction();
+ }
#endif /* mainSELECTED_APPLICATION */
}
+
/*-----------------------------------------------------------*/
-void vAssertCalled( void )
+void vAssertCalled( const char * pcFileName,
+ int line )
{
- volatile unsigned long looping = 0;
+ printf( "Assertion failed at %s: %d\n", pcFileName, line );
+ fflush( NULL );
- taskENTER_CRITICAL();
+ while( 1 )
{
- /* Use the debugger to set ul to a non-zero value in order to step out
- * of this function to determine why it was called. */
- while( looping == 0LU )
- {
- portNOP();
- }
+ asm ( "nop" );
}
- taskEXIT_CRITICAL();
+
+ exit( 1 );
}
+
/*-----------------------------------------------------------*/
void vLoggingPrintf( const char * pcFormat,
... )