aboutsummaryrefslogtreecommitdiff
path: root/lldb/source/Host/common/NativeProcessProtocol.cpp
diff options
context:
space:
mode:
authorEmmmer <yjhdandan@163.com>2022-08-10 21:36:48 +0800
committerEmmmer <yjhdandan@163.com>2022-08-11 14:26:22 +0800
commit0247b5aaae7ae02f140ca9509dc68078cfe55898 (patch)
tree27f0d225e9b42652c4cd95de0cc40fe8c69a6394 /lldb/source/Host/common/NativeProcessProtocol.cpp
parentbcc90f6268182a42205bd546be996fac6d05a071 (diff)
downloadllvm-0247b5aaae7ae02f140ca9509dc68078cfe55898.zip
llvm-0247b5aaae7ae02f140ca9509dc68078cfe55898.tar.gz
llvm-0247b5aaae7ae02f140ca9509dc68078cfe55898.tar.bz2
[LLDB][RISCV] Add riscv software breakpoint trap code
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.). Reviewed By: DavidSpickett Differential Revision: https://reviews.llvm.org/D131566
Diffstat (limited to 'lldb/source/Host/common/NativeProcessProtocol.cpp')
-rw-r--r--lldb/source/Host/common/NativeProcessProtocol.cpp7
1 files changed, 7 insertions, 0 deletions
diff --git a/lldb/source/Host/common/NativeProcessProtocol.cpp b/lldb/source/Host/common/NativeProcessProtocol.cpp
index be521a3..3636993 100644
--- a/lldb/source/Host/common/NativeProcessProtocol.cpp
+++ b/lldb/source/Host/common/NativeProcessProtocol.cpp
@@ -505,6 +505,7 @@ NativeProcessProtocol::GetSoftwareBreakpointTrapOpcode(size_t size_hint) {
static const uint8_t g_s390x_opcode[] = {0x00, 0x01};
static const uint8_t g_ppc_opcode[] = {0x7f, 0xe0, 0x00, 0x08}; // trap
static const uint8_t g_ppcle_opcode[] = {0x08, 0x00, 0xe0, 0x7f}; // trap
+ static const uint8_t g_riscv_opcode[] = {0x73, 0x00, 0x10, 0x00}; // ebreak
switch (GetArchitecture().GetMachine()) {
case llvm::Triple::aarch64:
@@ -533,6 +534,10 @@ NativeProcessProtocol::GetSoftwareBreakpointTrapOpcode(size_t size_hint) {
case llvm::Triple::ppc64le:
return llvm::makeArrayRef(g_ppcle_opcode);
+ case llvm::Triple::riscv32:
+ case llvm::Triple::riscv64:
+ return llvm::makeArrayRef(g_riscv_opcode);
+
default:
return llvm::createStringError(llvm::inconvertibleErrorCode(),
"CPU type not supported!");
@@ -557,6 +562,8 @@ size_t NativeProcessProtocol::GetSoftwareBreakpointPCOffset() {
case llvm::Triple::ppc:
case llvm::Triple::ppc64:
case llvm::Triple::ppc64le:
+ case llvm::Triple::riscv32:
+ case llvm::Triple::riscv64:
// On these architectures the PC doesn't get updated for breakpoint hits.
return 0;