From eebcf3cff16afbce2c57cf2dba6f562e17713093 Mon Sep 17 00:00:00 2001 From: Marek Vrbka Date: Mon, 5 Jun 2023 08:35:09 +0200 Subject: [PATCH] riscv/semihosting: Fix ebreak skip on fileio mode This patch fixes skipping the semihosting sequence if the fileio mode is enabled on riscv. This change was tested by me and is in the riscv-openocd fork for a year now. Original merge request: https://github.com/riscv/riscv-openocd/pull/699 Original author: Wu Zhigang zhigang.wu@starfivetech.com https://github.com/wzgpeter Change-Id: Iadaa0a48d1f82d3a7ca168f8a6b656ff6ab78e03 Signed-off-by: Marek Vrbka Reviewed-on: https://review.openocd.org/c/openocd/+/7729 Tested-by: jenkins Reviewed-by: Tim Newsome --- src/target/riscv/riscv_semihosting.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/target/riscv/riscv_semihosting.c b/src/target/riscv/riscv_semihosting.c index 1bc4e1a16..da237ef33 100644 --- a/src/target/riscv/riscv_semihosting.c +++ b/src/target/riscv/riscv_semihosting.c @@ -141,16 +141,16 @@ enum semihosting_result riscv_semihosting(struct target *target, int *retval) } } + /* Resume right after the EBREAK 4 bytes instruction. */ + *retval = riscv_set_register(target, GDB_REGNO_PC, pc + 4); + if (*retval != ERROR_OK) + return SEMIHOSTING_ERROR; + /* * Resume target if we are not waiting on a fileio * operation to complete. */ if (semihosting->is_resumable && !semihosting->hit_fileio) { - /* Resume right after the EBREAK 4 bytes instruction. */ - *retval = riscv_set_register(target, GDB_REGNO_PC, pc + 4); - if (*retval != ERROR_OK) - return SEMIHOSTING_ERROR; - LOG_DEBUG(" -> HANDLED"); return SEMIHOSTING_HANDLED; }