From 5f3e8ea83455e60b88f2b2d9b31e567ef715d330 Mon Sep 17 00:00:00 2001 From: Parshintsev Anatoly Date: Wed, 13 Nov 2024 19:53:58 +0300 Subject: [PATCH] target/riscv: detailed error messages for cases when resume operation fails This change aims to provide more context in case if resume operation fails. Before the change messages were quite confusing. --- src/target/riscv/riscv-013.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/target/riscv/riscv-013.c b/src/target/riscv/riscv-013.c index a94bf029b..b15bb8861 100644 --- a/src/target/riscv/riscv-013.c +++ b/src/target/riscv/riscv-013.c @@ -5418,16 +5418,22 @@ static int riscv013_step_or_resume_current_hart(struct target *target, return ERROR_OK; } + LOG_TARGET_ERROR(target, "unable to %s. dmstatus=0x%08x", + step ? "single-step" : "resume", dmstatus); + dm_write(target, DM_DMCONTROL, dmcontrol); + LOG_TARGET_ERROR(target, " cancelling RESUMEREQ"); - LOG_TARGET_ERROR(target, "unable to resume"); if (dmstatus_read(target, &dmstatus, true) != ERROR_OK) return ERROR_FAIL; - LOG_TARGET_ERROR(target, " dmstatus=0x%08x", dmstatus); + + LOG_TARGET_ERROR(target, " dmstatus after cancellation=0x%08x", dmstatus); if (step) { - LOG_TARGET_ERROR(target, " was stepping, halting"); + LOG_TARGET_ERROR(target, + " trying to restore from failed single-step, by requesting throw-away halt"); riscv_halt(target); + // TODO: returning ERROR_OK is questionable, this code needs to be revised return ERROR_OK; }