This is an automated email from Gerrit. "Adrien Charruel <acharr...@nanoxplore.com>" just uploaded a new patch set to Gerrit, which you can find at https://review.openocd.org/c/openocd/+/8657
-- gerrit commit 67ae60d752d2678cb7697b0e9103046ff97f35ec Author: Adrien Grassein <agrass...@nanoxplore.com> Date: Thu Jan 18 12:03:51 2024 +0100 target/aarch64: Perform halt management even if already done Attaching GDB when the target is already halt will not trigger some important code Change-Id: I1f4710471e7de37e77f31525ba126be0627e1efb Signed-off-by: Adrien Grassein <agrass...@nanoxplore.com> Signed-off-by: Adrien Charruel <acharr...@nanoxplore.com> diff --git a/src/target/aarch64.c b/src/target/aarch64.c index ec317ef410..57d61499b9 100644 --- a/src/target/aarch64.c +++ b/src/target/aarch64.c @@ -535,7 +535,9 @@ static int aarch64_poll(struct target *target) if (prsr & PRSR_HALT) { prev_target_state = target->state; - if (prev_target_state != TARGET_HALTED) { + /* Enter this branch in case of a new halt state or if a halt was issued while in halt state. */ + /* This can be triggered by restarting GDB after a previous debugging session. */ + if (prev_target_state != TARGET_HALTED || target->halt_issued) { enum target_debug_reason debug_reason = target->debug_reason; /* We have a halting debug event */ @@ -563,6 +565,11 @@ static int aarch64_poll(struct target *target) default: break; } + + /* In case of an already halted target, send an event anyway */ + if (prev_target_state == TARGET_HALTED && target->halt_issued) { + target_call_event_callbacks(target, TARGET_EVENT_HALTED); + } } } else if (prsr & PRSR_RESET) { target->state = TARGET_RESET; @@ -978,6 +985,7 @@ static int aarch64_debug_entry(struct target *target) /* Mark the context as dirty this we will modify internal registers of the core. */ aarch64->context_dirty = true; + /* make sure to clear all sticky errors */ retval = mem_ap_write_atomic_u32(armv8->debug_ap, armv8->debug_base + CPUV8_DBG_DRCR, DRCR_CSE); --