This is an automated email from Gerrit. "Evgeniy Naydanov <evgeniy.nayda...@syntacore.com>" just uploaded a new patch set to Gerrit, which you can find at https://review.openocd.org/c/openocd/+/8487
-- gerrit commit 1fc7e21c61d774e58bf8766c9a54375b9f1a673c Author: Evgeniy Naydanov <evgeniy.nayda...@syntacore.com> Date: Thu Sep 12 13:49:59 2024 +0300 move BP/WP removal to `gdb-attach` handler * On GDB connection, `breakpoint_clear_target()` and `watchpoint_clear_target()` were called before `gdb-attach` handler, that by default used to just halt the target. This resulted in unnecessary failures to access memory on running target. * Suggested approach is more flexible (can be re-defined by user). Change-Id: I1ea84d6beacdf86b58220b4550a82ae20486fa56 Signed-off-by: Evgeniy Naydanov <evgeniy.nayda...@syntacore.com> diff --git a/doc/openocd.texi b/doc/openocd.texi index 2e48d8e208..69e22da5a2 100644 --- a/doc/openocd.texi +++ b/doc/openocd.texi @@ -5485,6 +5485,7 @@ The following target events are defined: starts. GDB expects the target is halted during attachment. @xref{gdbmeminspect,,GDB as a non-intrusive memory inspector}, how to connect GDB to running target. +Default handler also removes all breakpoints and watchpoints. The event can be also used to set up the target so it is possible to probe flash. Probing flash is necessary during GDB connect if you want to use @pxref{programmingusinggdb,,programming using GDB}. diff --git a/src/server/gdb_server.c b/src/server/gdb_server.c index 2db3123a04..6c3f68420e 100644 --- a/src/server/gdb_server.c +++ b/src/server/gdb_server.c @@ -1008,13 +1008,6 @@ static int gdb_new_connection(struct connection *connection) /* output goes through gdb connection */ command_set_output_handler(connection->cmd_ctx, gdb_output, connection); - /* we must remove all breakpoints registered to the target as a previous - * GDB session could leave dangling breakpoints if e.g. communication - * timed out. - */ - breakpoint_clear_target(target); - watchpoint_clear_target(target); - /* Since version 3.95 (gdb-19990504), with the exclusion of 6.5~6.8, GDB * sends an ACK at connection with the following comment in its source code: * "Ack any packet which the remote side has already sent." diff --git a/src/target/startup.tcl b/src/target/startup.tcl index e9646097f0..34073159df 100644 --- a/src/target/startup.tcl +++ b/src/target/startup.tcl @@ -211,7 +211,10 @@ proc init_target_events {} { foreach t $targets { set_default_target_event $t gdb-flash-erase-start "reset init" set_default_target_event $t gdb-flash-write-end "reset halt" - set_default_target_event $t gdb-attach "halt 1000" + set_default_target_event $t gdb-attach { + halt 1000 + try {rbp all} finally {rwp all} + } } } --