rtos: add custom stack read function

This is optional field for the targets which has to implement
their custom stack read function.

Signed-off-by: Erhan Kurubas <erhan.kurubas@espressif.com>
Change-Id: Icbc9ed66a052fc2cc0ef67e3ec4d85ab0c2c1b94
Reviewed-on: https://review.openocd.org/c/openocd/+/7442
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
This commit is contained in:
Erhan Kurubas 2023-01-21 20:10:21 +01:00 committed by Antonio Borneo
parent dfbbfac4d7
commit 59bc761d56
2 changed files with 11 additions and 1 deletions

View File

@ -632,7 +632,10 @@ int rtos_generic_stack_read(struct target *target,
if (stacking->stack_growth_direction == 1)
address -= stacking->stack_registers_size;
retval = target_read_buffer(target, address, stacking->stack_registers_size, stack_data);
if (stacking->read_stack)
retval = stacking->read_stack(target, address, stacking, stack_data);
else
retval = target_read_buffer(target, address, stacking->stack_registers_size, stack_data);
if (retval != ERROR_OK) {
free(stack_data);
LOG_ERROR("Error reading stack frame from thread");

View File

@ -102,6 +102,13 @@ struct rtos_register_stacking {
const struct rtos_register_stacking *stacking,
target_addr_t stack_ptr);
const struct stack_register_offset *register_offsets;
/* Optional field for targets which may have to implement their own stack read function.
* Because stack format can be weird or stack data needed to be edited before passing to the gdb.
*/
int (*read_stack)(struct target *target,
int64_t stack_ptr,
const struct rtos_register_stacking *stacking,
uint8_t *stack_data);
};
#define GDB_THREAD_PACKET_NOT_CONSUMED (-40)