This is an archive of the discontinued LLVM Phabricator instance.

[LLDB][RISCV] Add riscv software breakpoint trap code
ClosedPublic

Authored by Emmmer on Aug 10 2022, 6:58 AM.

Details

Summary

Added:

  • Take RISC-V ebreak instruction as breakpoint trap code, so our breakpoint works as expected now.

Further work:

  • RISC-V does not support hardware single stepping yet. A software implementation may come in future PR.
  • Add support for RVC extension (the trap code, etc.).

Diff Detail

Event Timeline

Emmmer created this revision.Aug 10 2022, 6:58 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 10 2022, 6:58 AM
Emmmer requested review of this revision.Aug 10 2022, 6:58 AM
DavidSpickett accepted this revision.Aug 10 2022, 9:02 AM

LGTM thanks again for splitting it up.

When you say riscv doesn't support hardware single stepping do you mean lldb on riscv? In https://riscv.org/wp-content/uploads/2019/03/riscv-debug-release.pdf B.5 Single Step I see it described at least for bare metal debug, I don't know if that's available via ptrace yet. Just curious, not a blocker of any sort.

This revision is now accepted and ready to land.Aug 10 2022, 9:02 AM

LGTM thanks again for splitting it up.

When you say riscv doesn't support hardware single stepping do you mean lldb on riscv? In https://riscv.org/wp-content/uploads/2019/03/riscv-debug-release.pdf B.5 Single Step I see it described at least for bare metal debug, I don't know if that's available via ptrace yet. Just curious, not a blocker of any sort.

I look through the riscv's Linux kernel code, and it's a pity that the kernel does not support PTRACE_SINGLESTEP, which is used by lldb-server as hardware breakpoint implementation.

The riscv-debug-spec is still a draft, so it is not implemented by qemu (my only available platform)

This revision was automatically updated to reflect the committed changes.