• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //===-- NativeRegisterContextWindows_WoW64.cpp ----------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
9 #if defined(__x86_64__) || defined(_M_X64)
10 
11 #include "NativeRegisterContextWindows_WoW64.h"
12 
13 #include "NativeThreadWindows.h"
14 #include "Plugins/Process/Utility/RegisterContextWindows_i386.h"
15 #include "ProcessWindowsLog.h"
16 #include "lldb/Host/HostInfo.h"
17 #include "lldb/Host/HostThread.h"
18 #include "lldb/Host/windows/HostThreadWindows.h"
19 #include "lldb/Host/windows/windows.h"
20 
21 #include "lldb/Utility/Log.h"
22 #include "lldb/Utility/RegisterValue.h"
23 #include "llvm/ADT/STLExtras.h"
24 
25 using namespace lldb;
26 using namespace lldb_private;
27 
28 #define REG_CONTEXT_SIZE sizeof(::WOW64_CONTEXT)
29 
30 namespace {
31 static const uint32_t g_gpr_regnums_WoW64[] = {
32     lldb_eax_i386,      lldb_ebx_i386,    lldb_ecx_i386, lldb_edx_i386,
33     lldb_edi_i386,      lldb_esi_i386,    lldb_ebp_i386, lldb_esp_i386,
34     lldb_eip_i386,      lldb_eflags_i386, lldb_cs_i386,  lldb_fs_i386,
35     lldb_gs_i386,       lldb_ss_i386,     lldb_ds_i386,  lldb_es_i386,
36     LLDB_INVALID_REGNUM // Register set must be terminated with this flag.
37 };
38 
39 static const RegisterSet g_reg_sets_WoW64[] = {
40     {"General Purpose Registers", "gpr",
41      llvm::array_lengthof(g_gpr_regnums_WoW64) - 1, g_gpr_regnums_WoW64},
42 };
43 enum { k_num_register_sets = 1 };
44 
45 static const DWORD kWoW64ContextFlags =
46     WOW64_CONTEXT_CONTROL | WOW64_CONTEXT_INTEGER | WOW64_CONTEXT_SEGMENTS;
47 
48 } // namespace
49 
50 static RegisterInfoInterface *
CreateRegisterInfoInterface(const ArchSpec & target_arch)51 CreateRegisterInfoInterface(const ArchSpec &target_arch) {
52   // i686 32bit instruction set.
53   assert((target_arch.GetAddressByteSize() == 4 &&
54           HostInfo::GetArchitecture().GetAddressByteSize() == 8) &&
55          "Register setting path assumes this is a 64-bit host");
56   return new RegisterContextWindows_i386(target_arch);
57 }
58 
59 static Status
GetWoW64ThreadContextHelper(lldb::thread_t thread_handle,PWOW64_CONTEXT context_ptr,const DWORD control_flag=kWoW64ContextFlags)60 GetWoW64ThreadContextHelper(lldb::thread_t thread_handle,
61                             PWOW64_CONTEXT context_ptr,
62                             const DWORD control_flag = kWoW64ContextFlags) {
63   Log *log = ProcessWindowsLog::GetLogIfAny(WINDOWS_LOG_REGISTERS);
64   Status error;
65   memset(context_ptr, 0, sizeof(::WOW64_CONTEXT));
66   context_ptr->ContextFlags = control_flag;
67   if (!::Wow64GetThreadContext(thread_handle, context_ptr)) {
68     error.SetError(GetLastError(), eErrorTypeWin32);
69     LLDB_LOG(log, "{0} Wow64GetThreadContext failed with error {1}",
70              __FUNCTION__, error);
71     return error;
72   }
73   return Status();
74 }
75 
SetWoW64ThreadContextHelper(lldb::thread_t thread_handle,PWOW64_CONTEXT context_ptr)76 static Status SetWoW64ThreadContextHelper(lldb::thread_t thread_handle,
77                                           PWOW64_CONTEXT context_ptr) {
78   Log *log = ProcessWindowsLog::GetLogIfAny(WINDOWS_LOG_REGISTERS);
79   Status error;
80   if (!::Wow64SetThreadContext(thread_handle, context_ptr)) {
81     error.SetError(GetLastError(), eErrorTypeWin32);
82     LLDB_LOG(log, "{0} Wow64SetThreadContext failed with error {1}",
83              __FUNCTION__, error);
84     return error;
85   }
86   return Status();
87 }
88 
NativeRegisterContextWindows_WoW64(const ArchSpec & target_arch,NativeThreadProtocol & native_thread)89 NativeRegisterContextWindows_WoW64::NativeRegisterContextWindows_WoW64(
90     const ArchSpec &target_arch, NativeThreadProtocol &native_thread)
91     : NativeRegisterContextWindows(native_thread,
92                                    CreateRegisterInfoInterface(target_arch)) {}
93 
IsGPR(uint32_t reg_index) const94 bool NativeRegisterContextWindows_WoW64::IsGPR(uint32_t reg_index) const {
95   return (reg_index >= k_first_gpr_i386 && reg_index < k_first_alias_i386);
96 }
97 
IsDR(uint32_t reg_index) const98 bool NativeRegisterContextWindows_WoW64::IsDR(uint32_t reg_index) const {
99   return (reg_index >= lldb_dr0_i386 && reg_index <= lldb_dr7_i386);
100 }
101 
GetRegisterSetCount() const102 uint32_t NativeRegisterContextWindows_WoW64::GetRegisterSetCount() const {
103   return k_num_register_sets;
104 }
105 
106 const RegisterSet *
GetRegisterSet(uint32_t set_index) const107 NativeRegisterContextWindows_WoW64::GetRegisterSet(uint32_t set_index) const {
108   if (set_index >= k_num_register_sets)
109     return nullptr;
110   return &g_reg_sets_WoW64[set_index];
111 }
112 
GPRRead(const uint32_t reg,RegisterValue & reg_value)113 Status NativeRegisterContextWindows_WoW64::GPRRead(const uint32_t reg,
114                                                    RegisterValue &reg_value) {
115   ::WOW64_CONTEXT tls_context;
116   Status error = GetWoW64ThreadContextHelper(GetThreadHandle(), &tls_context);
117   if (error.Fail())
118     return error;
119 
120   switch (reg) {
121   case lldb_eax_i386:
122     reg_value.SetUInt32(tls_context.Eax);
123     break;
124   case lldb_ebx_i386:
125     reg_value.SetUInt32(tls_context.Ebx);
126     break;
127   case lldb_ecx_i386:
128     reg_value.SetUInt32(tls_context.Ecx);
129     break;
130   case lldb_edx_i386:
131     reg_value.SetUInt32(tls_context.Edx);
132     break;
133   case lldb_edi_i386:
134     reg_value.SetUInt32(tls_context.Edi);
135     break;
136   case lldb_esi_i386:
137     reg_value.SetUInt32(tls_context.Esi);
138     break;
139   case lldb_ebp_i386:
140     reg_value.SetUInt32(tls_context.Ebp);
141     break;
142   case lldb_esp_i386:
143     reg_value.SetUInt32(tls_context.Esp);
144     break;
145   case lldb_eip_i386:
146     reg_value.SetUInt32(tls_context.Eip);
147     break;
148   case lldb_eflags_i386:
149     reg_value.SetUInt32(tls_context.EFlags);
150     break;
151   case lldb_cs_i386:
152     reg_value.SetUInt32(tls_context.SegCs);
153     break;
154   case lldb_fs_i386:
155     reg_value.SetUInt32(tls_context.SegFs);
156     break;
157   case lldb_gs_i386:
158     reg_value.SetUInt32(tls_context.SegGs);
159     break;
160   case lldb_ss_i386:
161     reg_value.SetUInt32(tls_context.SegSs);
162     break;
163   case lldb_ds_i386:
164     reg_value.SetUInt32(tls_context.SegDs);
165     break;
166   case lldb_es_i386:
167     reg_value.SetUInt32(tls_context.SegEs);
168     break;
169   }
170 
171   return error;
172 }
173 
174 Status
GPRWrite(const uint32_t reg,const RegisterValue & reg_value)175 NativeRegisterContextWindows_WoW64::GPRWrite(const uint32_t reg,
176                                              const RegisterValue &reg_value) {
177   ::WOW64_CONTEXT tls_context;
178   auto thread_handle = GetThreadHandle();
179   Status error = GetWoW64ThreadContextHelper(thread_handle, &tls_context);
180   if (error.Fail())
181     return error;
182 
183   switch (reg) {
184   case lldb_eax_i386:
185     tls_context.Eax = reg_value.GetAsUInt32();
186     break;
187   case lldb_ebx_i386:
188     tls_context.Ebx = reg_value.GetAsUInt32();
189     break;
190   case lldb_ecx_i386:
191     tls_context.Ecx = reg_value.GetAsUInt32();
192     break;
193   case lldb_edx_i386:
194     tls_context.Edx = reg_value.GetAsUInt32();
195     break;
196   case lldb_edi_i386:
197     tls_context.Edi = reg_value.GetAsUInt32();
198     break;
199   case lldb_esi_i386:
200     tls_context.Esi = reg_value.GetAsUInt32();
201     break;
202   case lldb_ebp_i386:
203     tls_context.Ebp = reg_value.GetAsUInt32();
204     break;
205   case lldb_esp_i386:
206     tls_context.Esp = reg_value.GetAsUInt32();
207     break;
208   case lldb_eip_i386:
209     tls_context.Eip = reg_value.GetAsUInt32();
210     break;
211   case lldb_eflags_i386:
212     tls_context.EFlags = reg_value.GetAsUInt32();
213     break;
214   case lldb_cs_i386:
215     tls_context.SegCs = reg_value.GetAsUInt32();
216     break;
217   case lldb_fs_i386:
218     tls_context.SegFs = reg_value.GetAsUInt32();
219     break;
220   case lldb_gs_i386:
221     tls_context.SegGs = reg_value.GetAsUInt32();
222     break;
223   case lldb_ss_i386:
224     tls_context.SegSs = reg_value.GetAsUInt32();
225     break;
226   case lldb_ds_i386:
227     tls_context.SegDs = reg_value.GetAsUInt32();
228     break;
229   case lldb_es_i386:
230     tls_context.SegEs = reg_value.GetAsUInt32();
231     break;
232   }
233 
234   return SetWoW64ThreadContextHelper(thread_handle, &tls_context);
235 }
236 
DRRead(const uint32_t reg,RegisterValue & reg_value)237 Status NativeRegisterContextWindows_WoW64::DRRead(const uint32_t reg,
238                                                   RegisterValue &reg_value) {
239   ::WOW64_CONTEXT tls_context;
240   DWORD context_flag = CONTEXT_DEBUG_REGISTERS;
241   Status error = GetWoW64ThreadContextHelper(GetThreadHandle(), &tls_context,
242                                              context_flag);
243   if (error.Fail())
244     return error;
245 
246   switch (reg) {
247   case lldb_dr0_i386:
248     reg_value.SetUInt32(tls_context.Dr0);
249     break;
250   case lldb_dr1_i386:
251     reg_value.SetUInt32(tls_context.Dr1);
252     break;
253   case lldb_dr2_i386:
254     reg_value.SetUInt32(tls_context.Dr2);
255     break;
256   case lldb_dr3_i386:
257     reg_value.SetUInt32(tls_context.Dr3);
258     break;
259   case lldb_dr4_i386:
260     return Status("register DR4 is obsolete");
261   case lldb_dr5_i386:
262     return Status("register DR5 is obsolete");
263   case lldb_dr6_i386:
264     reg_value.SetUInt32(tls_context.Dr6);
265     break;
266   case lldb_dr7_i386:
267     reg_value.SetUInt32(tls_context.Dr7);
268     break;
269   }
270 
271   return {};
272 }
273 
274 Status
DRWrite(const uint32_t reg,const RegisterValue & reg_value)275 NativeRegisterContextWindows_WoW64::DRWrite(const uint32_t reg,
276                                             const RegisterValue &reg_value) {
277   ::WOW64_CONTEXT tls_context;
278   DWORD context_flag = CONTEXT_DEBUG_REGISTERS;
279   auto thread_handle = GetThreadHandle();
280   Status error =
281       GetWoW64ThreadContextHelper(thread_handle, &tls_context, context_flag);
282   if (error.Fail())
283     return error;
284 
285   switch (reg) {
286   case lldb_dr0_i386:
287     tls_context.Dr0 = reg_value.GetAsUInt32();
288     break;
289   case lldb_dr1_i386:
290     tls_context.Dr1 = reg_value.GetAsUInt32();
291     break;
292   case lldb_dr2_i386:
293     tls_context.Dr2 = reg_value.GetAsUInt32();
294     break;
295   case lldb_dr3_i386:
296     tls_context.Dr3 = reg_value.GetAsUInt32();
297     break;
298   case lldb_dr4_i386:
299     return Status("register DR4 is obsolete");
300   case lldb_dr5_i386:
301     return Status("register DR5 is obsolete");
302   case lldb_dr6_i386:
303     tls_context.Dr6 = reg_value.GetAsUInt32();
304     break;
305   case lldb_dr7_i386:
306     tls_context.Dr7 = reg_value.GetAsUInt32();
307     break;
308   }
309 
310   return SetWoW64ThreadContextHelper(thread_handle, &tls_context);
311 }
312 
313 Status
ReadRegister(const RegisterInfo * reg_info,RegisterValue & reg_value)314 NativeRegisterContextWindows_WoW64::ReadRegister(const RegisterInfo *reg_info,
315                                                  RegisterValue &reg_value) {
316   Status error;
317   if (!reg_info) {
318     error.SetErrorString("reg_info NULL");
319     return error;
320   }
321 
322   const uint32_t reg = reg_info->kinds[lldb::eRegisterKindLLDB];
323   if (reg == LLDB_INVALID_REGNUM) {
324     // This is likely an internal register for lldb use only and should not be
325     // directly queried.
326     error.SetErrorStringWithFormat("register \"%s\" is an internal-only lldb "
327                                    "register, cannot read directly",
328                                    reg_info->name);
329     return error;
330   }
331 
332   if (IsGPR(reg))
333     return GPRRead(reg, reg_value);
334 
335   if (IsDR(reg))
336     return DRRead(reg, reg_value);
337 
338   return Status("unimplemented");
339 }
340 
WriteRegister(const RegisterInfo * reg_info,const RegisterValue & reg_value)341 Status NativeRegisterContextWindows_WoW64::WriteRegister(
342     const RegisterInfo *reg_info, const RegisterValue &reg_value) {
343   Status error;
344 
345   if (!reg_info) {
346     error.SetErrorString("reg_info NULL");
347     return error;
348   }
349 
350   const uint32_t reg = reg_info->kinds[lldb::eRegisterKindLLDB];
351   if (reg == LLDB_INVALID_REGNUM) {
352     // This is likely an internal register for lldb use only and should not be
353     // directly written.
354     error.SetErrorStringWithFormat("register \"%s\" is an internal-only lldb "
355                                    "register, cannot write directly",
356                                    reg_info->name);
357     return error;
358   }
359 
360   if (IsGPR(reg))
361     return GPRWrite(reg, reg_value);
362 
363   if (IsDR(reg))
364     return DRWrite(reg, reg_value);
365 
366   return Status("unimplemented");
367 }
368 
ReadAllRegisterValues(lldb::DataBufferSP & data_sp)369 Status NativeRegisterContextWindows_WoW64::ReadAllRegisterValues(
370     lldb::DataBufferSP &data_sp) {
371   const size_t data_size = REG_CONTEXT_SIZE;
372   data_sp = std::make_shared<DataBufferHeap>(data_size, 0);
373   ::WOW64_CONTEXT tls_context;
374   Status error = GetWoW64ThreadContextHelper(GetThreadHandle(), &tls_context);
375   if (error.Fail())
376     return error;
377 
378   uint8_t *dst = data_sp->GetBytes();
379   ::memcpy(dst, &tls_context, data_size);
380   return error;
381 }
382 
WriteAllRegisterValues(const lldb::DataBufferSP & data_sp)383 Status NativeRegisterContextWindows_WoW64::WriteAllRegisterValues(
384     const lldb::DataBufferSP &data_sp) {
385   Status error;
386   const size_t data_size = REG_CONTEXT_SIZE;
387   if (!data_sp) {
388     error.SetErrorStringWithFormat(
389         "NativeRegisterContextWindows_WoW64::%s invalid data_sp provided",
390         __FUNCTION__);
391     return error;
392   }
393 
394   if (data_sp->GetByteSize() != data_size) {
395     error.SetErrorStringWithFormatv(
396         "data_sp contained mismatched data size, expected {0}, actual {1}",
397         data_size, data_sp->GetByteSize());
398     return error;
399   }
400 
401   ::WOW64_CONTEXT tls_context;
402   memcpy(&tls_context, data_sp->GetBytes(), data_size);
403   return SetWoW64ThreadContextHelper(GetThreadHandle(), &tls_context);
404 }
405 
IsWatchpointHit(uint32_t wp_index,bool & is_hit)406 Status NativeRegisterContextWindows_WoW64::IsWatchpointHit(uint32_t wp_index,
407                                                            bool &is_hit) {
408   is_hit = false;
409 
410   if (wp_index >= NumSupportedHardwareWatchpoints())
411     return Status("watchpoint index out of range");
412 
413   RegisterValue reg_value;
414   Status error = DRRead(lldb_dr6_i386, reg_value);
415   if (error.Fail())
416     return error;
417 
418   is_hit = reg_value.GetAsUInt32() & (1 << wp_index);
419 
420   return {};
421 }
422 
GetWatchpointHitIndex(uint32_t & wp_index,lldb::addr_t trap_addr)423 Status NativeRegisterContextWindows_WoW64::GetWatchpointHitIndex(
424     uint32_t &wp_index, lldb::addr_t trap_addr) {
425   wp_index = LLDB_INVALID_INDEX32;
426 
427   for (uint32_t i = 0; i < NumSupportedHardwareWatchpoints(); i++) {
428     bool is_hit;
429     Status error = IsWatchpointHit(i, is_hit);
430     if (error.Fail())
431       return error;
432 
433     if (is_hit) {
434       wp_index = i;
435       return {};
436     }
437   }
438 
439   return {};
440 }
441 
IsWatchpointVacant(uint32_t wp_index,bool & is_vacant)442 Status NativeRegisterContextWindows_WoW64::IsWatchpointVacant(uint32_t wp_index,
443                                                               bool &is_vacant) {
444   is_vacant = false;
445 
446   if (wp_index >= NumSupportedHardwareWatchpoints())
447     return Status("Watchpoint index out of range");
448 
449   RegisterValue reg_value;
450   Status error = DRRead(lldb_dr7_i386, reg_value);
451   if (error.Fail())
452     return error;
453 
454   is_vacant = !(reg_value.GetAsUInt32() & (1 << (2 * wp_index)));
455 
456   return error;
457 }
458 
ClearHardwareWatchpoint(uint32_t wp_index)459 bool NativeRegisterContextWindows_WoW64::ClearHardwareWatchpoint(
460     uint32_t wp_index) {
461   if (wp_index >= NumSupportedHardwareWatchpoints())
462     return false;
463 
464   // for watchpoints 0, 1, 2, or 3, respectively, clear bits 0, 1, 2, or 3 of
465   // the debug status register (DR6)
466 
467   RegisterValue reg_value;
468   Status error = DRRead(lldb_dr6_i386, reg_value);
469   if (error.Fail())
470     return false;
471 
472   uint32_t bit_mask = 1 << wp_index;
473   uint32_t status_bits = reg_value.GetAsUInt32() & ~bit_mask;
474   error = DRWrite(lldb_dr6_i386, RegisterValue(status_bits));
475   if (error.Fail())
476     return false;
477 
478   // for watchpoints 0, 1, 2, or 3, respectively, clear bits {0-1,16-19},
479   // {2-3,20-23}, {4-5,24-27}, or {6-7,28-31} of the debug control register
480   // (DR7)
481 
482   error = DRRead(lldb_dr7_i386, reg_value);
483   if (error.Fail())
484     return false;
485 
486   bit_mask = (0x3 << (2 * wp_index)) | (0xF << (16 + 4 * wp_index));
487   uint32_t control_bits = reg_value.GetAsUInt32() & ~bit_mask;
488   return DRWrite(lldb_dr7_i386, RegisterValue(control_bits)).Success();
489 }
490 
ClearAllHardwareWatchpoints()491 Status NativeRegisterContextWindows_WoW64::ClearAllHardwareWatchpoints() {
492   RegisterValue reg_value;
493 
494   // clear bits {0-4} of the debug status register (DR6)
495 
496   Status error = DRRead(lldb_dr6_i386, reg_value);
497   if (error.Fail())
498     return error;
499 
500   uint32_t status_bits = reg_value.GetAsUInt32() & ~0xF;
501   error = DRWrite(lldb_dr6_i386, RegisterValue(status_bits));
502   if (error.Fail())
503     return error;
504 
505   // clear bits {0-7,16-31} of the debug control register (DR7)
506 
507   error = DRRead(lldb_dr7_i386, reg_value);
508   if (error.Fail())
509     return error;
510 
511   uint32_t control_bits = reg_value.GetAsUInt32() & ~0xFFFF00FF;
512   return DRWrite(lldb_dr7_i386, RegisterValue(control_bits));
513 }
514 
SetHardwareWatchpoint(lldb::addr_t addr,size_t size,uint32_t watch_flags)515 uint32_t NativeRegisterContextWindows_WoW64::SetHardwareWatchpoint(
516     lldb::addr_t addr, size_t size, uint32_t watch_flags) {
517   switch (size) {
518   case 1:
519   case 2:
520   case 4:
521     break;
522   default:
523     return LLDB_INVALID_INDEX32;
524   }
525 
526   if (watch_flags == 0x2)
527     watch_flags = 0x3;
528 
529   if (watch_flags != 0x1 && watch_flags != 0x3)
530     return LLDB_INVALID_INDEX32;
531 
532   for (uint32_t wp_index = 0; wp_index < NumSupportedHardwareWatchpoints();
533        ++wp_index) {
534     bool is_vacant;
535     if (IsWatchpointVacant(wp_index, is_vacant).Fail())
536       return LLDB_INVALID_INDEX32;
537 
538     if (is_vacant) {
539       if (!ClearHardwareWatchpoint(wp_index))
540         return LLDB_INVALID_INDEX32;
541 
542       if (ApplyHardwareBreakpoint(wp_index, addr, size, watch_flags).Fail())
543         return LLDB_INVALID_INDEX32;
544 
545       return wp_index;
546     }
547   }
548   return LLDB_INVALID_INDEX32;
549 }
550 
ApplyHardwareBreakpoint(uint32_t wp_index,lldb::addr_t addr,size_t size,uint32_t flags)551 Status NativeRegisterContextWindows_WoW64::ApplyHardwareBreakpoint(
552     uint32_t wp_index, lldb::addr_t addr, size_t size, uint32_t flags) {
553   RegisterValue reg_value;
554   auto error = DRRead(lldb_dr7_i386, reg_value);
555   if (error.Fail())
556     return error;
557 
558   // for watchpoints 0, 1, 2, or 3, respectively, set bits 1, 3, 5, or 7
559   uint32_t enable_bit = 1 << (2 * wp_index);
560 
561   // set bits 16-17, 20-21, 24-25, or 28-29
562   // with 0b01 for write, and 0b11 for read/write
563   uint32_t rw_bits = flags << (16 + 4 * wp_index);
564 
565   // set bits 18-19, 22-23, 26-27, or 30-31
566   // with 0b00, 0b01, 0b10, or 0b11
567   // for 1, 2, 8 (if supported), or 4 bytes, respectively
568   uint32_t size_bits = (size == 8 ? 0x2 : size - 1) << (18 + 4 * wp_index);
569 
570   uint32_t bit_mask = (0x3 << (2 * wp_index)) | (0xF << (16 + 4 * wp_index));
571 
572   uint32_t control_bits = reg_value.GetAsUInt32() & ~bit_mask;
573   control_bits |= enable_bit | rw_bits | size_bits;
574 
575   error = DRWrite(lldb_dr7_i386, RegisterValue(control_bits));
576   if (error.Fail())
577     return error;
578 
579   error = DRWrite(lldb_dr0_i386 + wp_index, RegisterValue(addr));
580   if (error.Fail())
581     return error;
582 
583   return {};
584 }
585 
586 lldb::addr_t
GetWatchpointAddress(uint32_t wp_index)587 NativeRegisterContextWindows_WoW64::GetWatchpointAddress(uint32_t wp_index) {
588   if (wp_index >= NumSupportedHardwareWatchpoints())
589     return LLDB_INVALID_ADDRESS;
590 
591   RegisterValue reg_value;
592   if (DRRead(lldb_dr0_i386 + wp_index, reg_value).Fail())
593     return LLDB_INVALID_ADDRESS;
594 
595   return reg_value.GetAsUInt32();
596 }
597 
NumSupportedHardwareWatchpoints()598 uint32_t NativeRegisterContextWindows_WoW64::NumSupportedHardwareWatchpoints() {
599   return 4;
600 }
601 
602 #endif // defined(__x86_64__) || defined(_M_X64)
603