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. http://reviews.llvm.org/D12522 Files: source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64.cpp 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])); } else { @@ -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);
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])); } else { @@ -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);
_______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits