From: OpenOCD-Gerrit <ope...@us...> - 2021-05-02 21:43:26
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "Main OpenOCD repository". The branch, master has been updated via a115b589a71d665787759cf8f2ff07210fd47164 (commit) from b60d06ae325c00979e9ff17bb35e868879e6047f (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit a115b589a71d665787759cf8f2ff07210fd47164 Author: Tarek BOCHKATI <tar...@gm...> Date: Thu Apr 22 20:47:23 2021 +0100 cortex_m: implement hit_watchpoint function this change aims to provide a better gdb debugging experience, by making gdb understand what's really happening. before this change when hitting a watchpoint - openocd reports "T05" to gdb - gdb displays: Program received signal SIGTRAP, Trace/breakpoint trap. after the change - openocd reports "T05watch:20000000;" to gdb - gdb displays: Hardware watchpoint 1: *0x20000000 Old value = 16000000 New value = 170000000 ... Change-Id: Iac3a85eadd86663617889001dd04513a4211ced9 Signed-off-by: Tarek BOCHKATI <tar...@gm...> Reviewed-on: http://openocd.zylin.com/6181 Tested-by: jenkins Reviewed-by: Tomas Vanek <va...@fb...> diff --git a/src/target/cortex_m.c b/src/target/cortex_m.c index 46b0e3c2a..2b38b4a7f 100644 --- a/src/target/cortex_m.c +++ b/src/target/cortex_m.c @@ -1596,6 +1596,35 @@ int cortex_m_remove_watchpoint(struct target *target, struct watchpoint *watchpo return ERROR_OK; } +int cortex_m_hit_watchpoint(struct target *target, struct watchpoint **hit_watchpoint) +{ + if (target->debug_reason != DBG_REASON_WATCHPOINT) + return ERROR_FAIL; + + struct cortex_m_common *cortex_m = target_to_cm(target); + + for (struct watchpoint *wp = target->watchpoints; wp; wp = wp->next) { + if (!wp->set) + continue; + + unsigned int dwt_num = wp->set - 1; + struct cortex_m_dwt_comparator *comparator = cortex_m->dwt_comparator_list + dwt_num; + + uint32_t dwt_function; + int retval = target_read_u32(target, comparator->dwt_comparator_address + 8, &dwt_function); + if (retval != ERROR_OK) + return ERROR_FAIL; + + /* check the MATCHED bit */ + if (dwt_function & BIT(24)) { + *hit_watchpoint = wp; + return ERROR_OK; + } + } + + return ERROR_FAIL; +} + void cortex_m_enable_watchpoints(struct target *target) { struct watchpoint *watchpoint = target->watchpoints; @@ -2523,6 +2552,7 @@ struct target_type cortexm_target = { .remove_breakpoint = cortex_m_remove_breakpoint, .add_watchpoint = cortex_m_add_watchpoint, .remove_watchpoint = cortex_m_remove_watchpoint, + .hit_watchpoint = cortex_m_hit_watchpoint, .commands = cortex_m_command_handlers, .target_create = cortex_m_target_create, ----------------------------------------------------------------------- Summary of changes: src/target/cortex_m.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) hooks/post-receive -- Main OpenOCD repository |