Skip to content

fix: preserve riscv trap pc - #2384

Open
Jvlegod wants to merge 1 commit into
unicorn-engine:devfrom
Jvlegod:fix-riscv-intr-pc
Open

fix: preserve riscv trap pc#2384
Jvlegod wants to merge 1 commit into
unicorn-engine:devfrom
Jvlegod:fix-riscv-intr-pc

Conversation

@Jvlegod

@Jvlegod Jvlegod commented Aug 9, 2026

Copy link
Copy Markdown

This PR fixes RISC-V exception PC handling in interrupt hooks.

Previously, Unicorn unconditionally advanced the RISC-V PC by 4 before invoking UC_HOOK_INTR. That behavior was added to solve ecall resume problem reported in #1477, but it also made interrupt hooks observe the wrong PC for other exceptions, as reported in #1990.

This change preserves the faulting instruction address while the interrupt hook is running, and only advances PC to the saved next PC after a handled RISC-V ecall.

Note: ebreak will follow the UC_ERR_INSN_INVALID path is not affected by this change.

Signed-off-by: Jvle <keke.oerv@isrc.iscas.ac.cn>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant