1 //===-- RegisterContextPOSIX.h --------------------------------*- C++ -*-===//
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 #ifndef liblldb_RegisterContextPOSIX_H_
10 #define liblldb_RegisterContextPOSIX_H_
11 
12 #include "Plugins/Process/Utility/RegisterInfoInterface.h"
13 #include "lldb/Target/RegisterContext.h"
14 #include "lldb/Utility/ArchSpec.h"
15 
16 /// \class POSIXBreakpointProtocol
17 ///
18 /// Extends RegisterClass with a few virtual operations useful on POSIX.
19 class POSIXBreakpointProtocol {
20 public:
POSIXBreakpointProtocol()21   POSIXBreakpointProtocol() { m_watchpoints_initialized = false; }
~POSIXBreakpointProtocol()22   virtual ~POSIXBreakpointProtocol() {}
23 
24   /// Updates the register state of the associated thread after hitting a
25   /// breakpoint (if that make sense for the architecture).  Default
26   /// implementation simply returns true for architectures which do not
27   /// require any update.
28   ///
29   /// \return
30   ///    True if the operation succeeded and false otherwise.
31   virtual bool UpdateAfterBreakpoint() = 0;
32 
33   /// Determines the index in lldb's register file given a kernel byte offset.
34   virtual unsigned GetRegisterIndexFromOffset(unsigned offset) = 0;
35 
36   // Checks to see if a watchpoint specified by hw_index caused the inferior
37   // to stop.
38   virtual bool IsWatchpointHit(uint32_t hw_index) = 0;
39 
40   // Resets any watchpoints that have been hit.
41   virtual bool ClearWatchpointHits() = 0;
42 
43   // Returns the watchpoint address associated with a watchpoint hardware
44   // index.
45   virtual lldb::addr_t GetWatchpointAddress(uint32_t hw_index) = 0;
46 
47   virtual bool IsWatchpointVacant(uint32_t hw_index) = 0;
48 
49   virtual bool SetHardwareWatchpointWithIndex(lldb::addr_t addr, size_t size,
50                                               bool read, bool write,
51                                               uint32_t hw_index) = 0;
52 
53   // From lldb_private::RegisterContext
54   virtual uint32_t NumSupportedHardwareWatchpoints() = 0;
55 
56   // Force m_watchpoints_initialized to TRUE
ForceWatchpointsInitialized()57   void ForceWatchpointsInitialized() { m_watchpoints_initialized = true; }
58 
59 protected:
60   bool m_watchpoints_initialized;
61 };
62 
63 #endif // #ifndef liblldb_RegisterContextPOSIX_H_
64