@@ -333,55 +333,40 @@ NativeRegisterContextLinux_arm::WriteHardwareDebugRegs(DREGType hwbType) {
333333#endif // ifdef __arm__
334334}
335335
336+ #ifdef __arm__
336337llvm::Error
337338NativeRegisterContextLinux_arm::WriteHardwareDebugReg (DREGType hwbType,
338339 int hwb_index) {
339340 Status error;
340341 lldb::addr_t *addr_buf;
341342 uint32_t *ctrl_buf;
343+ int addr_idx = (hwb_index << 1 ) + 1 ;
344+ int ctrl_idx = addr_idx + 1 ;
342345
343346 if (hwbType == NativeRegisterContextDBReg::eDREGTypeWATCH) {
347+ addr_idx *= -1 ;
344348 addr_buf = &m_hwp_regs[hwb_index].address ;
349+ ctrl_idx *= -1 ;
345350 ctrl_buf = &m_hwp_regs[hwb_index].control ;
346-
347- error = NativeProcessLinux::PtraceWrapper (
348- PTRACE_SETHBPREGS, m_thread.GetID (),
349- (PTRACE_TYPE_ARG3)(intptr_t ) - ((hwb_index << 1 ) + 1 ), addr_buf,
350- sizeof (unsigned int ));
351-
352- if (error.Fail ())
353- return error.ToError ();
354-
355- error = NativeProcessLinux::PtraceWrapper (
356- PTRACE_SETHBPREGS, m_thread.GetID (),
357- (PTRACE_TYPE_ARG3)(intptr_t ) - ((hwb_index << 1 ) + 2 ), ctrl_buf,
358- sizeof (unsigned int ));
359-
360- if (error.Fail ())
361- return error.ToError ();
362351 } else {
363352 addr_buf = &m_hbp_regs[hwb_index].address ;
364353 ctrl_buf = &m_hbp_regs[hwb_index].control ;
354+ }
365355
366- error = NativeProcessLinux::PtraceWrapper (
367- PTRACE_SETHBPREGS, m_thread.GetID (),
368- (PTRACE_TYPE_ARG3)(intptr_t )((hwb_index << 1 ) + 1 ), addr_buf,
369- sizeof (unsigned int ));
370-
371- if (error.Fail ())
372- return error.ToError ();
356+ error = NativeProcessLinux::PtraceWrapper (
357+ PTRACE_SETHBPREGS, m_thread.GetID (), (PTRACE_TYPE_ARG3)(intptr_t )addr_idx,
358+ addr_buf, sizeof (unsigned int ));
373359
374- error = NativeProcessLinux::PtraceWrapper (
375- PTRACE_SETHBPREGS, m_thread.GetID (),
376- (PTRACE_TYPE_ARG3)(intptr_t )((hwb_index << 1 ) + 2 ), ctrl_buf,
377- sizeof (unsigned int ));
360+ if (error.Fail ())
361+ return error.ToError ();
378362
379- if (error. Fail ())
380- return error. ToError ();
381- }
363+ error = NativeProcessLinux::PtraceWrapper (
364+ PTRACE_SETHBPREGS, m_thread. GetID (), (PTRACE_TYPE_ARG3)( intptr_t )ctrl_idx,
365+ ctrl_buf, sizeof ( unsigned int ));
382366
383367 return error.ToError ();
384368}
369+ #endif // ifdef __arm__
385370
386371uint32_t NativeRegisterContextLinux_arm::CalculateFprOffset (
387372 const RegisterInfo *reg_info) const {
0 commit comments