This is an automated email from Gerrit.

"Erhan Kurubas <erhan.kuru...@espressif.com>" just uploaded a new patch set to 
Gerrit, which you can find at https://review.openocd.org/c/openocd/+/7442

-- gerrit

commit 5e622ea4478e2c13c5406e9d222ecf95ad918d48
Author: Erhan Kurubas <erhan.kuru...@espressif.com>
Date:   Sat Jan 21 20:10:21 2023 +0100

    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.kuru...@espressif.com>
    Change-Id: Icbc9ed66a052fc2cc0ef67e3ec4d85ab0c2c1b94

diff --git a/src/rtos/rtos.c b/src/rtos/rtos.c
index 2e76b501ae..dfa158d016 100644
--- a/src/rtos/rtos.c
+++ b/src/rtos/rtos.c
@@ -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");
diff --git a/src/rtos/rtos.h b/src/rtos/rtos.h
index ace57514af..9128c163c7 100644
--- a/src/rtos/rtos.h
+++ b/src/rtos/rtos.h
@@ -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)

-- 

Reply via email to