From 159a49d6a0d357cb5b36726413a34a73eda9166b Mon Sep 17 00:00:00 2001 From: Marek Vrbka Date: Fri, 25 Aug 2023 15:29:19 +0200 Subject: [PATCH] target/riscv: Reject size 2 soft breakpoints when C extension not supported This patch disables software breakpoints of size 2 for targets which don't support compressed instructions. Change-Id: I8200b22a51c97ba2aa89e6328beadde8dd35cdd5 Signed-off-by: Marek Vrbka --- src/target/riscv/riscv.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/target/riscv/riscv.c b/src/target/riscv/riscv.c index ac48abd793..52514c05d2 100644 --- a/src/target/riscv/riscv.c +++ b/src/target/riscv/riscv.c @@ -1199,7 +1199,7 @@ static int riscv_add_breakpoint(struct target *target, struct breakpoint *breakp assert(breakpoint); if (breakpoint->type == BKPT_SOFT) { /** @todo check RVC for size/alignment */ - if (!(breakpoint->length == 4 || breakpoint->length == 2)) { + if (!(breakpoint->length == 4 || (breakpoint->length == 2 && riscv_supports_extension(target, 'C')))) { LOG_TARGET_ERROR(target, "Invalid breakpoint length %d", breakpoint->length); return ERROR_FAIL; }