[Lldb-commits] [PATCH] D12522: AArch64 Watchpoints: Make sure we are only setting supported no of debug registers.

Muhammad Omair Javaid via lldb-commits lldb-commits at lists.llvm.org
Tue Sep 1 02:52:10 PDT 2015

omjavaid created this revision.
omjavaid added a reviewer: tberghammer.
omjavaid added a subscriber: lldb-commits.
Herald added subscribers: rengolin, aemerson.

This patch makes sure that we are setting the correct number of hardware breakpoint or watchpoint registers while setting/clearing hardware watchpoints/breakpoints.

In current implementation of AArch64 Watchpoints we try to set all debug registers present in user_hwdebug_state structure.

There are more debug registers declared by user_hwdebug_state than the one exported to ptrace for hardware watchpoints and hardware breakpoints.

We only should be setting the N number of registers supported by the target in response to read debug registers calls. 

Failure to do so results in unexpected watchpoint behavior.



Index: source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64.cpp
--- source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64.cpp
+++ source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64.cpp
@@ -816,6 +816,9 @@
             dreg_state.dbg_regs[i].addr = m_hwp_regs[i].address;
             dreg_state.dbg_regs[i].ctrl = m_hwp_regs[i].control;
+        ioVec.iov_len = (offsetof (struct user_hwdebug_state, dbg_regs[m_max_hwp_supported - 1])
+                        + sizeof (dreg_state.dbg_regs [m_max_hwp_supported - 1]));
@@ -826,6 +829,8 @@
             dreg_state.dbg_regs[i].addr = m_hbr_regs[i].address;
             dreg_state.dbg_regs[i].ctrl = m_hbr_regs[i].control;
+        ioVec.iov_len = (offsetof (struct user_hwdebug_state, dbg_regs[m_max_hbp_supported - 1])
+                        + sizeof (dreg_state.dbg_regs [m_max_hbp_supported - 1]));
     return NativeProcessLinux::PtraceWrapper(PTRACE_SETREGSET, m_thread.GetID(), &hwbType, &ioVec, ioVec.iov_len);

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D12522.33671.patch
Type: text/x-patch
Size: 1122 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20150901/cb402302/attachment.bin>

More information about the lldb-commits mailing list