aboutsummaryrefslogtreecommitdiff
path: root/sim
diff options
context:
space:
mode:
authorBernd Edlinger <bernd.edlinger@hotmail.de>2024-04-12 08:55:11 +0200
committerBernd Edlinger <bernd.edlinger@hotmail.de>2024-04-15 10:20:50 +0200
commitae14cde6fd2c527c407a115fa1684c2002749552 (patch)
tree3570633578e0075fc8da3e9f87ee8535f8738a74 /sim
parent5966e2eb3fed61ebe5c091a074b368b9238a68c1 (diff)
downloadgdb-ae14cde6fd2c527c407a115fa1684c2002749552.zip
gdb-ae14cde6fd2c527c407a115fa1684c2002749552.tar.gz
gdb-ae14cde6fd2c527c407a115fa1684c2002749552.tar.bz2
sim: riscv: Fix PC at gdb breakpoints
The uncompressed EBREAK instruction does not work correctly this way, and the comment saying that GDB expects us to step over EBREAK is just wrong. The PC was always 4 bytes too high, which skips one instruction at break and step over commands, and causes complete chaos. The compressed EBREAK was already implemented correctly. Tested by using gdb's "target sim" and single-stepping. Approved-By: Andrew Burgess <aburgess@redhat.com>
Diffstat (limited to 'sim')
-rw-r--r--sim/riscv/sim-main.c4
1 files changed, 1 insertions, 3 deletions
diff --git a/sim/riscv/sim-main.c b/sim/riscv/sim-main.c
index adff999..ddc7e1d 100644
--- a/sim/riscv/sim-main.c
+++ b/sim/riscv/sim-main.c
@@ -623,9 +623,7 @@ execute_i (SIM_CPU *cpu, unsigned_word iw, const struct riscv_opcode *op)
break;
case MATCH_EBREAK:
TRACE_INSN (cpu, "ebreak;");
- /* GDB expects us to step over EBREAK. */
- sim_engine_halt (sd, cpu, NULL, riscv_cpu->pc + 4, sim_stopped,
- SIM_SIGTRAP);
+ sim_engine_halt (sd, cpu, NULL, riscv_cpu->pc, sim_stopped, SIM_SIGTRAP);
break;
case MATCH_ECALL:
TRACE_INSN (cpu, "ecall;");