Skip to content

Commit 2f94b18

Browse files
conarakar-rahul-awschinglee-iot
authored
Add Trace Hook Macros and function that returns the start of the stack. (#659)
* Add Trace Hook Macros and function that returns the start of the stack. * Remove obsolete functions. --------- Co-authored-by: kar-rahul-aws <[email protected]> Co-authored-by: Rahul Kar <[email protected]> Co-authored-by: chinglee-iot <[email protected]>
1 parent f13ad77 commit 2f94b18

File tree

4 files changed

+36
-2
lines changed

4 files changed

+36
-2
lines changed

include/FreeRTOS.h

+20
Original file line numberDiff line numberDiff line change
@@ -653,6 +653,14 @@
653653
#define tracePOST_MOVED_TASK_TO_READY_STATE( pxTCB )
654654
#endif
655655

656+
#ifndef traceMOVED_TASK_TO_DELAYED_LIST
657+
#define traceMOVED_TASK_TO_DELAYED_LIST()
658+
#endif
659+
660+
#ifndef traceMOVED_TASK_TO_OVERFLOW_DELAYED_LIST
661+
#define traceMOVED_TASK_TO_OVERFLOW_DELAYED_LIST()
662+
#endif
663+
656664
#ifndef traceQUEUE_CREATE
657665
#define traceQUEUE_CREATE( pxNewQueue )
658666
#endif
@@ -901,6 +909,18 @@
901909
#define traceTASK_NOTIFY_GIVE_FROM_ISR( uxIndexToNotify )
902910
#endif
903911

912+
#ifndef traceISR_EXIT_TO_SCHEDULER
913+
#define traceISR_EXIT_TO_SCHEDULER()
914+
#endif
915+
916+
#ifndef traceISR_EXIT
917+
#define traceISR_EXIT()
918+
#endif
919+
920+
#ifndef traceISR_ENTER
921+
#define traceISR_ENTER()
922+
#endif
923+
904924
#ifndef traceSTREAM_BUFFER_CREATE_FAILED
905925
#define traceSTREAM_BUFFER_CREATE_FAILED( xIsMessageBuffer )
906926
#endif

portable/GCC/ARM_CM7/r0p1/port.c

+7
Original file line numberDiff line numberDiff line change
@@ -511,14 +511,21 @@ void xPortSysTickHandler( void )
511511
* save and then restore the interrupt mask value as its value is already
512512
* known. */
513513
portDISABLE_INTERRUPTS();
514+
traceISR_ENTER();
514515
{
515516
/* Increment the RTOS tick. */
516517
if( xTaskIncrementTick() != pdFALSE )
517518
{
519+
traceISR_EXIT_TO_SCHEDULER();
520+
518521
/* A context switch is required. Context switching is performed in
519522
* the PendSV interrupt. Pend the PendSV interrupt. */
520523
portNVIC_INT_CTRL_REG = portNVIC_PENDSVSET_BIT;
521524
}
525+
else
526+
{
527+
traceISR_EXIT();
528+
}
522529
}
523530
portENABLE_INTERRUPTS();
524531
}

portable/GCC/ARM_CM7/r0p1/portmacro.h

+5-2
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,11 @@ typedef unsigned long UBaseType_t;
9595

9696
#define portNVIC_INT_CTRL_REG ( *( ( volatile uint32_t * ) 0xe000ed04 ) )
9797
#define portNVIC_PENDSVSET_BIT ( 1UL << 28UL )
98-
#define portEND_SWITCHING_ISR( xSwitchRequired ) do { if( xSwitchRequired != pdFALSE ) portYIELD( ); } while( 0 )
99-
#define portYIELD_FROM_ISR( x ) portEND_SWITCHING_ISR( x )
98+
#define portEND_SWITCHING_ISR( xSwitchRequired ) \
99+
do { if( xSwitchRequired != pdFALSE ) { traceISR_EXIT_TO_SCHEDULER(); portYIELD(); } \
100+
else { traceISR_EXIT(); } \
101+
} while( 0 )
102+
#define portYIELD_FROM_ISR( x ) portEND_SWITCHING_ISR( x )
100103
/*-----------------------------------------------------------*/
101104

102105
/* Critical section management. */

tasks.c

+4
Original file line numberDiff line numberDiff line change
@@ -7577,12 +7577,14 @@ static void prvAddCurrentTaskToDelayedList( TickType_t xTicksToWait,
75777577
{
75787578
/* Wake time has overflowed. Place this item in the overflow
75797579
* list. */
7580+
traceMOVED_TASK_TO_OVERFLOW_DELAYED_LIST();
75807581
vListInsert( pxOverflowDelayedTaskList, &( pxCurrentTCB->xStateListItem ) );
75817582
}
75827583
else
75837584
{
75847585
/* The wake time has not overflowed, so the current block list
75857586
* is used. */
7587+
traceMOVED_TASK_TO_DELAYED_LIST();
75867588
vListInsert( pxDelayedTaskList, &( pxCurrentTCB->xStateListItem ) );
75877589

75887590
/* If the task entering the blocked state was placed at the
@@ -7611,11 +7613,13 @@ static void prvAddCurrentTaskToDelayedList( TickType_t xTicksToWait,
76117613

76127614
if( xTimeToWake < xConstTickCount )
76137615
{
7616+
traceMOVED_TASK_TO_OVERFLOW_DELAYED_LIST();
76147617
/* Wake time has overflowed. Place this item in the overflow list. */
76157618
vListInsert( pxOverflowDelayedTaskList, &( pxCurrentTCB->xStateListItem ) );
76167619
}
76177620
else
76187621
{
7622+
traceMOVED_TASK_TO_DELAYED_LIST();
76197623
/* The wake time has not overflowed, so the current block list is used. */
76207624
vListInsert( pxDelayedTaskList, &( pxCurrentTCB->xStateListItem ) );
76217625

0 commit comments

Comments
 (0)