|
在freertos例子中检测堆栈溢出的两种方法,没找到钩子函数在哪里调用了- void vApplicationStackOverflowHook( TaskHandle_t xTask, signed char *pcTaskName )
- {
- printf("任务:%s堆栈溢出\r\n", pcTaskName);
- }
复制代码
- /*-----------------------------------------------------------*/
- __asm void xPortPendSVHandler( void )
- {
- extern uxCriticalNesting;
- extern pxCurrentTCB;
- extern vTaskSwitchContext;
- PRESERVE8
- mrs r0, psp
- isb
- ldr r3, =pxCurrentTCB /* Get the location of the current TCB. */
- ldr r2, [r3]
- stmdb r0!, {r4-r11} /* Save the remaining registers. */
- str r0, [r2] /* Save the new top of stack into the first member of the TCB. */
- stmdb sp!, {r3, r14}
- mov r0, #configMAX_SYSCALL_INTERRUPT_PRIORITY
- msr basepri, r0
- bl vTaskSwitchContext
- mov r0, #0
- msr basepri, r0
- ldmia sp!, {r3, r14}
- ldr r1, [r3]
- ldr r0, [r1] /* The first item in pxCurrentTCB is the task top of stack. */
- ldmia r0!, {r4-r11} /* Pop the registers and the critical nesting count. */
- msr psp, r0
- isb
- bx r14
- nop
- }
- /*-----------------------------------------------------------*/
- void xPortSysTickHandler( void )
- {
- /* The SysTick runs at the lowest interrupt priority, so when this interrupt
- executes all interrupts must be unmasked. There is therefore no need to
- save and then restore the interrupt mask value as its value is already
- known. */
- ( void ) portSET_INTERRUPT_MASK_FROM_ISR();
- {
- /* Increment the RTOS tick. */
- if( xTaskIncrementTick() != pdFALSE )
- {
- /* A context switch is required. Context switching is performed in
- the PendSV interrupt. Pend the PendSV interrupt. */
- portNVIC_INT_CTRL_REG = portNVIC_PENDSVSET_BIT;
- }
- }
- portCLEAR_INTERRUPT_MASK_FROM_ISR( 0 );
- }
- /*-----------------------------------------------------------*/
复制代码
|
-
|