This is an automated email from Gerrit.

"Evgeniy Naydanov <[email protected]>" just uploaded a new patch 
set to Gerrit, which you can find at https://review.openocd.org/c/openocd/+/9158

-- gerrit

commit ef4c97705b1d6ca1e7a21de428128555b6f3f3b7
Author: Evgeniy Naydanov <[email protected]>
Date:   Wed Oct 1 15:53:11 2025 +0300

    tcl: adjust `gdb-attach` handlers to remove BPs and WPs
    
    The commit 9f9c4fd4cf236837433bb80de9f75b635aaed544 ("move BP/WP removal
    to `gdb-attach` handler") changed the default `gdb-attach` handler.
    Adjust custom handlers accordingly.
    
    Change-Id: Id0fd0943401df7af277a9b27b132814b0c94014a
    Signed-off-by: Evgeniy Naydanov <[email protected]>

diff --git a/tcl/board/at91rm9200-dk.cfg b/tcl/board/at91rm9200-dk.cfg
index 3751103fcd..0cc44ac078 100644
--- a/tcl/board/at91rm9200-dk.cfg
+++ b/tcl/board/at91rm9200-dk.cfg
@@ -10,7 +10,13 @@ source [find target/at91rm9200.cfg]
 
 reset_config trst_and_srst
 
-$_TARGETNAME configure -event gdb-attach { reset init }
+$_TARGETNAME configure -event gdb-attach {
+       try {
+               try {rbp all} finally {rwp all}
+       } finally {
+               reset init
+       }
+}
 $_TARGETNAME configure -event reset-init { at91rm9200_dk_init }
 
 #flash bank <name> <driver> <base> <size> <chip_width> <bus_width> <target>
diff --git a/tcl/board/at91rm9200-ek.cfg b/tcl/board/at91rm9200-ek.cfg
index e38914e46a..181983ca8b 100644
--- a/tcl/board/at91rm9200-ek.cfg
+++ b/tcl/board/at91rm9200-ek.cfg
@@ -13,7 +13,13 @@ source [find target/at91rm9200.cfg]
 
 reset_config trst_and_srst
 
-$_TARGETNAME configure -event gdb-attach { reset init }
+$_TARGETNAME configure -event gdb-attach {
+       try {
+               try {rbp all} finally {rwp all}
+       } finally {
+               reset init
+       }
+}
 $_TARGETNAME configure -event reset-init { at91rm9200_ek_init }
 
 ## flash bank <name> <driver> <base> <size> <chip_width> <bus_width> <target>
diff --git a/tcl/board/at91sam9261-ek.cfg b/tcl/board/at91sam9261-ek.cfg
index c2d97b04e9..0975a64eb2 100644
--- a/tcl/board/at91sam9261-ek.cfg
+++ b/tcl/board/at91sam9261-ek.cfg
@@ -17,7 +17,13 @@ uplevel #0 [list source [find 
chip/atmel/at91/at91sam9_init.cfg]]
 reset_config srst_only
 
 scan_chain
-$_TARGETNAME configure -event gdb-attach { reset init }
+$_TARGETNAME configure -event gdb-attach {
+       try {
+               try {rbp all} finally {rwp all}
+       } finally {
+               reset init
+       }
+}
 $_TARGETNAME configure -event reset-init { at91sam9261ek_reset_init }
 $_TARGETNAME configure -event reset-start { at91sam9_reset_start }
 
diff --git a/tcl/board/at91sam9263-ek.cfg b/tcl/board/at91sam9263-ek.cfg
index 328a792a4f..14c2670075 100644
--- a/tcl/board/at91sam9263-ek.cfg
+++ b/tcl/board/at91sam9263-ek.cfg
@@ -17,7 +17,13 @@ uplevel #0 [list source [find 
chip/atmel/at91/at91sam9_init.cfg]]
 reset_config srst_only
 
 scan_chain
-$_TARGETNAME configure -event gdb-attach { reset init }
+$_TARGETNAME configure -event gdb-attach {
+       try {
+               try {rbp all} finally {rwp all}
+       } finally {
+               reset init
+       }
+}
 $_TARGETNAME configure -event reset-init { at91sam9263ek_reset_init }
 $_TARGETNAME configure -event reset-start { at91sam9_reset_start }
 
diff --git a/tcl/board/calao-usb-a9g20-c01.cfg 
b/tcl/board/calao-usb-a9g20-c01.cfg
index d2017864a9..d7bccdd7a8 100644
--- a/tcl/board/calao-usb-a9g20-c01.cfg
+++ b/tcl/board/calao-usb-a9g20-c01.cfg
@@ -167,6 +167,12 @@ proc at91sam9g20_reset_init { } {
         mww 0xffffea04 0x0000039c
 }
 
-$_TARGETNAME configure -event gdb-attach { reset init }
+$_TARGETNAME configure -event gdb-attach {
+       try {
+               try {rbp all} finally {rwp all}
+       } finally {
+               reset init
+       }
+}
 $_TARGETNAME configure -event reset-start {at91sam9g20_reset_start}
 $_TARGETNAME configure -event reset-init {at91sam9g20_reset_init}
diff --git a/tcl/board/csb732.cfg b/tcl/board/csb732.cfg
index 6df17500c6..40423db9a5 100644
--- a/tcl/board/csb732.cfg
+++ b/tcl/board/csb732.cfg
@@ -8,7 +8,13 @@ reset_config trst_and_srst combined
 adapter srst delay 200
 jtag_ntrst_delay 200
 
-$_TARGETNAME configure -event gdb-attach { reset init }
+$_TARGETNAME configure -event gdb-attach {
+       try {
+               try {rbp all} finally {rwp all}
+       } finally {
+               reset init
+       }
+}
 $_TARGETNAME configure -event reset-init { csb732_init }
 
 # Bare-bones initialization of core clocks and SDRAM
diff --git a/tcl/board/imx27ads.cfg b/tcl/board/imx27ads.cfg
index 79d3c51359..188ad3bcb2 100644
--- a/tcl/board/imx27ads.cfg
+++ b/tcl/board/imx27ads.cfg
@@ -3,7 +3,13 @@
 # The IMX27 ADS eval board has a single IMX27 chip
 # Note: tested on IMX27ADS Board REV-2.6 and REV-2.8
 source [find target/imx27.cfg]
-$_TARGETNAME configure -event gdb-attach { reset init }
+$_TARGETNAME configure -event gdb-attach {
+       try {
+               try {rbp all} finally {rwp all}
+       } finally {
+               reset init
+       }
+}
 $_TARGETNAME configure -event reset-init { imx27ads_init }
 
 # The IMX27 ADS board has a NOR flash on CS0
diff --git a/tcl/board/imx27lnst.cfg b/tcl/board/imx27lnst.cfg
index 24f6ed8b2e..76e80c6af3 100644
--- a/tcl/board/imx27lnst.cfg
+++ b/tcl/board/imx27lnst.cfg
@@ -3,7 +3,13 @@
 # The Linuxstamp-mx27 is board has a single IMX27 chip
 # For further info see http://opencircuits.com/Linuxstamp_mx27#OpenOCD
 source [find target/imx27.cfg]
-$_TARGETNAME configure -event gdb-attach { reset init }
+$_TARGETNAME configure -event gdb-attach {
+       try {
+               try {rbp all} finally {rwp all}
+       } finally {
+               reset init
+       }
+}
 $_TARGETNAME configure -event reset-init { imx27lnst_init }
 
 proc imx27lnst_init { } {
diff --git a/tcl/board/imx28evk.cfg b/tcl/board/imx28evk.cfg
index cc13c51854..a83c2992c6 100644
--- a/tcl/board/imx28evk.cfg
+++ b/tcl/board/imx28evk.cfg
@@ -6,7 +6,13 @@
 # Authors: James Robinson & Fabio Estevam
 
 source [find target/imx28.cfg]
-$_TARGETNAME configure -event gdb-attach { imx28evk_init }
+$_TARGETNAME configure -event gdb-attach {
+       try {
+               try {rbp all} finally {rwp all}
+       } finally {
+               imx28evk_init
+       }
+}
 $_TARGETNAME configure -event reset-init { imx28evk_init }
 
 proc imx28evk_init { } {
diff --git a/tcl/board/phytec_lpc3250.cfg b/tcl/board/phytec_lpc3250.cfg
index 036b16f2bb..0840cc718d 100644
--- a/tcl/board/phytec_lpc3250.cfg
+++ b/tcl/board/phytec_lpc3250.cfg
@@ -9,7 +9,13 @@ reset_config trst_and_srst separate
 
 arm7_9 dcc_downloads enable
 
-$_TARGETNAME configure -event gdb-attach { reset init }
+$_TARGETNAME configure -event gdb-attach {
+       try {
+               try {rbp all} finally {rwp all}
+       } finally {
+               reset init
+       }
+}
 
 $_TARGETNAME configure -event reset-start {
              arm7_9 fast_memory_access disable
diff --git a/tcl/board/topas910.cfg b/tcl/board/topas910.cfg
index f45f6e7eea..d126f86b45 100644
--- a/tcl/board/topas910.cfg
+++ b/tcl/board/topas910.cfg
@@ -12,7 +12,13 @@ source [find target/tmpa910.cfg]
 # Target configuration
 ######################
 
-#$_TARGETNAME configure -event gdb-attach { reset init }
+#$_TARGETNAME configure -event gdb-attach {
+       try {
+               try {rbp all} finally {rwp all}
+       } finally {
+               reset init
+       }
+}
 $_TARGETNAME configure -event reset-init { topas910_init }
 
 proc topas910_init { } {
diff --git a/tcl/board/topasa900.cfg b/tcl/board/topasa900.cfg
index d6ddc44efe..ad0da5080b 100644
--- a/tcl/board/topasa900.cfg
+++ b/tcl/board/topasa900.cfg
@@ -11,7 +11,13 @@ source [find target/tmpa900.cfg]
 # Target configuration
 ######################
 
-#$_TARGETNAME configure -event gdb-attach { reset init }
+#$_TARGETNAME configure -event gdb-attach {
+       try {
+               try {rbp all} finally {rwp all}
+       } finally {
+               reset init
+       }
+}
 $_TARGETNAME configure -event reset-init { topasa900_init }
 
 proc topasa900_init { } {
diff --git a/tcl/board/tx25_stk5.cfg b/tcl/board/tx25_stk5.cfg
index 5bf8fd03e7..c312899365 100644
--- a/tcl/board/tx25_stk5.cfg
+++ b/tcl/board/tx25_stk5.cfg
@@ -15,7 +15,13 @@ source [find target/imx25.cfg]
        nand device K9F1G08UOC mxc imx25.cpu mx25 hwecc biswap
 
 
-$_TARGETNAME configure -event gdb-attach { reset init }
+$_TARGETNAME configure -event gdb-attach {
+       try {
+               try {rbp all} finally {rwp all}
+       } finally {
+               reset init
+       }
+}
 $_TARGETNAME configure -event reset-init { tx25_init }
 
 
diff --git a/tcl/board/tx27_stk5.cfg b/tcl/board/tx27_stk5.cfg
index 061f1f9cca..fe9b462398 100644
--- a/tcl/board/tx27_stk5.cfg
+++ b/tcl/board/tx27_stk5.cfg
@@ -6,7 +6,13 @@
 #
 source [find target/imx27.cfg]
 
-$_TARGETNAME configure -event gdb-attach { reset init }
+$_TARGETNAME configure -event gdb-attach {
+       try {
+               try {rbp all} finally {rwp all}
+       } finally {
+               reset init
+       }
+}
 $_TARGETNAME configure -event reset-init { tx27_init }
 
 proc tx27_init { } {
diff --git a/tcl/board/uptech_2410.cfg b/tcl/board/uptech_2410.cfg
index ba269f5d07..950926cd3d 100644
--- a/tcl/board/uptech_2410.cfg
+++ b/tcl/board/uptech_2410.cfg
@@ -7,7 +7,13 @@
 source [find target/samsung_s3c2410.cfg]
 
 $_TARGETNAME configure -event reset-init { uptech2410_init }
-$_TARGETNAME configure -event gdb-attach { reset init }
+$_TARGETNAME configure -event gdb-attach {
+       try {
+               try {rbp all} finally {rwp all}
+       } finally {
+               reset init
+       }
+}
 
 proc init_pll_sdram { } {
        #echo "---------- Initializing PLL and SDRAM ---------"
diff --git a/tcl/target/amdm37x.cfg b/tcl/target/amdm37x.cfg
index d9adae9047..a7caf22ce8 100644
--- a/tcl/target/amdm37x.cfg
+++ b/tcl/target/amdm37x.cfg
@@ -182,12 +182,15 @@ $_TARGETNAME configure -event reset-assert-post {
 }
 
 $_TARGETNAME configure -event gdb-attach {
-
-   global _TARGETNAME
-   amdm37x_dbginit $_TARGETNAME
-
-   echo "Halting target"
-   halt
+       try {
+               try {rbp all} finally {rwp all}
+       } finally {
+               global _TARGETNAME
+               amdm37x_dbginit $_TARGETNAME
+
+               echo "Halting target"
+               halt
+       }
 }
 
 ######
diff --git a/tcl/target/esp_common.cfg b/tcl/target/esp_common.cfg
index e9a188f9f6..5b8f49bcb0 100644
--- a/tcl/target/esp_common.cfg
+++ b/tcl/target/esp_common.cfg
@@ -139,24 +139,13 @@ proc configure_event_gdb_attach { } {
        global _TARGETNAME_0 _TARGETNAME_1 _ONLYCPU
 
        $_TARGETNAME_0 configure -event gdb-attach {
-               if { $_ESP_SMP_BREAK != 0 } {
-                       $_TARGETNAME_0 xtensa smpbreak BreakIn BreakOut
-               }
-               # necessary to auto-probe flash bank when GDB is connected and 
generate proper memory map
-               halt 1000
-               if { [$_ESP_MEMPROT_IS_ENABLED] } {
-                       # 'reset halt' to disable memory protection and allow 
flasher to work correctly
-                       echo "Memory protection is enabled. Reset target to 
disable it..."
-                       reset halt
-               }
-       }
-
-       if { $_ONLYCPU != 1 } {
-               $_TARGETNAME_1 configure -event gdb-attach {
+               try {
+                       try {rbp all} finally {rwp all}
+               } finally {
                        if { $_ESP_SMP_BREAK != 0 } {
-                               $_TARGETNAME_1 xtensa smpbreak BreakIn BreakOut
+                               $_TARGETNAME_0 xtensa smpbreak BreakIn BreakOut
                        }
-                       # necessary to auto-probe flash bank when GDB is 
connected
+                       # necessary to auto-probe flash bank when GDB is 
connected and generate proper memory map
                        halt 1000
                        if { [$_ESP_MEMPROT_IS_ENABLED] } {
                                # 'reset halt' to disable memory protection and 
allow flasher to work correctly
@@ -165,6 +154,25 @@ proc configure_event_gdb_attach { } {
                        }
                }
        }
+
+       if { $_ONLYCPU != 1 } {
+               $_TARGETNAME_1 configure -event gdb-attach {
+                       try {
+                               try {rbp all} finally {rwp all}
+                       } finally {
+                               if { $_ESP_SMP_BREAK != 0 } {
+                                       $_TARGETNAME_0 xtensa smpbreak BreakIn 
BreakOut
+                               }
+                               # necessary to auto-probe flash bank when GDB 
is connected and generate proper memory map
+                               halt 1000
+                               if { [$_ESP_MEMPROT_IS_ENABLED] } {
+                                       # 'reset halt' to disable memory 
protection and allow flasher to work correctly
+                                       echo "Memory protection is enabled. 
Reset target to disable it..."
+                                       reset halt
+                               }
+                       }
+               }
+       }
 }
 
 proc configure_openocd_events { } {
diff --git a/tcl/target/nordic/nrf53.cfg b/tcl/target/nordic/nrf53.cfg
index 0dcfd55eca..6d43c3220f 100644
--- a/tcl/target/nordic/nrf53.cfg
+++ b/tcl/target/nordic/nrf53.cfg
@@ -82,7 +82,13 @@ if { ![using_hla] } {
        $_TARGETNAME_APP configure -event examine-fail { _nrf_check_ap_lock 2 3 
}
        $_TARGETNAME_NET configure -event examine-fail { _nrf_check_ap_lock 3 3 
}
 
-       $_TARGETNAME_NET configure -event gdb-attach "_nrf53_cpunet_gdb_attach 
$_CHIPNAME"
+       $_TARGETNAME_NET configure -event gdb-attach "
+               try {
+                       try {rbp all} finally {rwp all}
+               } finally {
+                       _nrf53_cpunet_gdb_attach $_CHIPNAME
+               }
+       "
 
        proc _nrf53_cpunet_gdb_attach { _CHIPNAME } {
                set _TARGETNAME_APP $_CHIPNAME.cpuapp
diff --git a/tcl/target/ti_k3.cfg b/tcl/target/ti_k3.cfg
index 0dee74e5ee..2d914d95fc 100644
--- a/tcl/target/ti_k3.cfg
+++ b/tcl/target/ti_k3.cfg
@@ -385,6 +385,11 @@ target create $_TARGETNAME.sysctrl cortex_m -dap 
$_CHIPNAME.dap \
 
 $_TARGETNAME.sysctrl configure -event reset-assert { }
 
+proc prepend_default_handler {target event script} {
+       set handler [$target cget -event $event]
+       $target configure -event $event "${script}; ${handler}"
+}
+
 proc sysctrl_up {} {
        # To access sysctrl, we need to enable the JTAG access for the same.
        # Ensure Power-AP unlocked
@@ -394,11 +399,7 @@ proc sysctrl_up {} {
        $::_TARGETNAME.sysctrl arp_examine
 }
 
-$_TARGETNAME.sysctrl configure -event gdb-attach {
-       sysctrl_up
-       # gdb-attach default rule
-       halt 1000
-}
+prepend_default_handler $_TARGETNAME.sysctrl gdb-attach sysctrl_up
 
 proc _cpu_no_smp_up {} {
        set _current_target [target current]
@@ -432,17 +433,9 @@ for { set _core 0 } { $_core < $_armv8_cores } { incr 
_core } {
        set _v8_smp_targets "$_v8_smp_targets 
$_TARGETNAME.$_armv8_cpu_name.$_core"
 
        if { $_v8_smp_debug == 0 } {
-               $_TARGETNAME.$_armv8_cpu_name.$_core configure -event 
gdb-attach {
-                       _cpu_no_smp_up
-                       # gdb-attach default rule
-                       halt 1000
-               }
+               prepend_default_handler $_TARGETNAME.$_armv8_cpu_name.$_core 
gdb-attach _cpu_no_smp_up
        } else {
-               $_TARGETNAME.$_armv8_cpu_name.$_core configure -event 
gdb-attach {
-                       _armv8_smp_up
-                       # gdb-attach default rule
-                       halt 1000
-               }
+               prepend_default_handler $_TARGETNAME.$_armv8_cpu_name.$_core 
gdb-attach _armv8_smp_up
        }
 }
 
@@ -478,11 +471,8 @@ for { set _core 0 } { $_core < $_r5_cores } { incr _core } 
{
                -dbgbase [lindex $R5_DBGBASE $_core] -ap-num $_r5_ap_num 
-defer-examine \
                -rtos [_get_rtos_type_for_cpu $_TARGETNAME.$_r5_name]
 
-       $_TARGETNAME.$_r5_name configure -event gdb-attach {
-               _cpu_no_smp_up
-               # gdb-attach default rule
-               halt 1000
-       }
+
+       prepend_default_handler $_TARGETNAME.$_r5_name gdb-attach _cpu_no_smp_up
 }
 
 proc r5_up { args } {
@@ -507,11 +497,7 @@ if { $_gp_mcu_cores != 0 } {
                $::_TARGETNAME.gp_mcu arp_examine
        }
 
-       $_TARGETNAME.gp_mcu configure -event gdb-attach {
-               gp_mcu_up
-               # gdb-attach default rule
-               halt 1000
-       }
+       prepend_default_handler $_TARGETNAME.gp_mcu gdb-attach gp_mcu_up
 }
 
 # In case of DMEM access, configure the dmem adapter with offsets from above.
@@ -542,3 +528,5 @@ proc dbg_sys_reset {} {
 }
 
 add_help_text dbg_sys_reset "Debugger initiated system reset attempt via 
Power-AP"
+
+rename prepend_default_handler {}

-- 

Reply via email to