diff --git a/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_loongarch64.cpp b/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_loongarch64.cpp index 601dde250094..c4841950f1e0 100644 --- a/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_loongarch64.cpp +++ b/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_loongarch64.cpp @@ -50,6 +50,23 @@ #define REG_CONTEXT_SIZE \ (GetGPRSize() + GetFPRSize() + sizeof(m_lsx) + sizeof(m_lasx)) +// ptrace has a struct type user_watch_state, which was replaced by +// user_watch_state_v2 when more watchpoints were added, so this file +// may be built on systems with one or both in the system headers. +// The type below has the same layout as user_watch_state_v2 but will +// not clash with that name if it exists. We can use the v2 layout even +// on old kernels as we will only see 8 watchpoints and the kernel will +// truncate any extra data we send to it. +struct loongarch_user_watch_state { + uint64_t dbg_info; + struct { + uint64_t addr; + uint64_t mask; + uint32_t ctrl; + uint32_t pad; + } dbg_regs[14]; +}; + using namespace lldb; using namespace lldb_private; using namespace lldb_private::process_linux; @@ -539,7 +556,7 @@ llvm::Error NativeRegisterContextLinux_loongarch64::ReadHardwareDebugInfo() { int regset = NT_LOONGARCH_HW_WATCH; struct iovec ioVec; - struct user_watch_state dreg_state; + struct loongarch_user_watch_state dreg_state; Status error; ioVec.iov_base = &dreg_state; @@ -567,7 +584,7 @@ llvm::Error NativeRegisterContextLinux_loongarch64::ReadHardwareDebugInfo() { llvm::Error NativeRegisterContextLinux_loongarch64::WriteHardwareDebugRegs( DREGType hwbType) { struct iovec ioVec; - struct user_watch_state dreg_state; + struct loongarch_user_watch_state dreg_state; int regset; memset(&dreg_state, 0, sizeof(dreg_state));