1 //===-- RegisterContextPOSIX.h --------------------------------*- C++ -*-===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 
10 #ifndef liblldb_RegisterContextPOSIX_H_
11 #define liblldb_RegisterContextPOSIX_H_
12 
13 // C Includes
14 // C++ Includes
15 // Other libraries and framework includes
16 #include "lldb/Core/ArchSpec.h"
17 #include "lldb/Target/RegisterContext.h"
18 
19 //------------------------------------------------------------------------------
20 /// @class POSIXBreakpointProtocol
21 ///
22 /// @brief Extends RegisterClass with a few virtual operations useful on POSIX.
23 class POSIXBreakpointProtocol
24 {
25 public:
POSIXBreakpointProtocol()26     POSIXBreakpointProtocol()
27         { m_watchpoints_initialized = false; }
~POSIXBreakpointProtocol()28     virtual ~POSIXBreakpointProtocol() {}
29 
30     /// Updates the register state of the associated thread after hitting a
31     /// breakpoint (if that make sense for the architecture).  Default
32     /// implementation simply returns true for architectures which do not
33     /// require any update.
34     ///
35     /// @return
36     ///    True if the operation succeeded and false otherwise.
37     virtual bool UpdateAfterBreakpoint() = 0;
38 
39     /// Determines the index in lldb's register file given a kernel byte offset.
40     virtual unsigned
41     GetRegisterIndexFromOffset(unsigned offset) = 0;
42 
43     // Checks to see if a watchpoint specified by hw_index caused the inferior
44     // to stop.
45     virtual bool
46     IsWatchpointHit (uint32_t hw_index) = 0;
47 
48     // Resets any watchpoints that have been hit.
49     virtual bool
50     ClearWatchpointHits () = 0;
51 
52     // Returns the watchpoint address associated with a watchpoint hardware
53     // index.
54     virtual lldb::addr_t
55     GetWatchpointAddress (uint32_t hw_index) = 0;
56 
57     virtual bool
58     IsWatchpointVacant (uint32_t hw_index) = 0;
59 
60     virtual bool
61     SetHardwareWatchpointWithIndex (lldb::addr_t addr, size_t size,
62                                     bool read, bool write,
63                                     uint32_t hw_index) = 0;
64 
65     // From lldb_private::RegisterContext
66     virtual uint32_t
67     NumSupportedHardwareWatchpoints () = 0;
68 
69     // Force m_watchpoints_initialized to TRUE
70     void
ForceWatchpointsInitialized()71     ForceWatchpointsInitialized () {m_watchpoints_initialized = true;}
72 
73 protected:
74     bool m_watchpoints_initialized;
75 };
76 
77 //------------------------------------------------------------------------------
78 /// @class RegisterInfoInterface
79 ///
80 /// @brief RegisterInfo interface to patch RegisterInfo structure for archs.
81 class RegisterInfoInterface
82 {
83 public:
RegisterInfoInterface(const lldb_private::ArchSpec & target_arch)84     RegisterInfoInterface(const lldb_private::ArchSpec& target_arch) : m_target_arch(target_arch) {}
~RegisterInfoInterface()85     virtual ~RegisterInfoInterface () {}
86 
87     virtual size_t
88     GetGPRSize () = 0;
89 
90     virtual const lldb_private::RegisterInfo *
91     GetRegisterInfo () = 0;
92 
93 public:
94     lldb_private::ArchSpec m_target_arch;
95 };
96 
97 #endif // #ifndef liblldb_RegisterContextPOSIX_H_
98 
99