esp_expression_with_stack: added watchpoint on stack parameter before use it
This commit is contained in:
parent
88dd15c806
commit
5e18cd4e13
2 changed files with 16 additions and 6 deletions
|
@ -17,22 +17,32 @@
|
||||||
|
|
||||||
#include "freertos/FreeRTOS.h"
|
#include "freertos/FreeRTOS.h"
|
||||||
#include "freertos/semphr.h"
|
#include "freertos/semphr.h"
|
||||||
|
#include "esp_debug_helpers.h"
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Executes a 1-line expression with a application alocated stack
|
* @brief Executes a 1-line expression with a application alocated stack
|
||||||
* @param lock Mutex object to protect in case of shared stack
|
* @param lock Mutex object to protect in case of shared stack
|
||||||
* @param stack Pointer to user alocated stack, it must points to its top
|
* @param stack Pointer to user alocated stack
|
||||||
|
* @param stack_size Size of current stack in bytes
|
||||||
* @param expression Expression or function to be executed using the stack
|
* @param expression Expression or function to be executed using the stack
|
||||||
*/
|
*/
|
||||||
#define ESP_EXECUTE_EXPRESSION_WITH_STACK(lock, stack, expression) \
|
#define ESP_EXECUTE_EXPRESSION_WITH_STACK(lock, stack, stack_size, expression) \
|
||||||
({ \
|
({ \
|
||||||
if(lock) { \
|
if(lock && stack && stack_size) { \
|
||||||
uint32_t backup; \
|
uint32_t backup; \
|
||||||
|
int watchpoint_place=(int)stack; \
|
||||||
|
portSTACK_TYPE *top_of_stack = &stack[0] + \
|
||||||
|
(sizeof(stack_size * sizeof(portSTACK_TYPE)) / \
|
||||||
|
sizeof(portSTACK_TYPE)); \
|
||||||
|
watchpoint_place=(watchpoint_place+31)&(~31); \
|
||||||
xSemaphoreTake(lock, portMAX_DELAY); \
|
xSemaphoreTake(lock, portMAX_DELAY); \
|
||||||
esp_switch_stack_enter(stack, &backup); \
|
esp_set_watchpoint(2, (char*)watchpoint_place, 32, ESP_WATCHPOINT_STORE);\
|
||||||
|
esp_switch_stack_enter(top_of_stack, &backup); \
|
||||||
{ \
|
{ \
|
||||||
expression; \
|
expression; \
|
||||||
} \
|
} \
|
||||||
|
esp_clear_watchpoint(2); \
|
||||||
esp_switch_stack_exit(&backup); \
|
esp_switch_stack_exit(&backup); \
|
||||||
xSemaphoreGive(lock); \
|
xSemaphoreGive(lock); \
|
||||||
} \
|
} \
|
||||||
|
|
|
@ -26,7 +26,7 @@ TEST_CASE("test printf using shared buffer stack", "[newlib]")
|
||||||
TEST_ASSERT(shared_stack != NULL);
|
TEST_ASSERT(shared_stack != NULL);
|
||||||
|
|
||||||
SemaphoreHandle_t printf_lock = xSemaphoreCreateMutex();
|
SemaphoreHandle_t printf_lock = xSemaphoreCreateMutex();
|
||||||
ESP_EXECUTE_EXPRESSION_WITH_STACK(printf_lock, ext_stack_top, printf("Executing this from external stack! \n"));
|
ESP_EXECUTE_EXPRESSION_WITH_STACK(printf_lock, shared_stack,8192,printf("Executing printf from external stack! \n"));
|
||||||
ESP_EXECUTE_EXPRESSION_WITH_STACK(printf_lock, ext_stack_top, check_stack(ext_stack_top, shared_stack));
|
ESP_EXECUTE_EXPRESSION_WITH_STACK(printf_lock, shared_stack,8192,check_stack(ext_stack_top, shared_stack));
|
||||||
free(shared_stack);
|
free(shared_stack);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue