1254721Semaste//===-- RegisterContextPOSIX.h --------------------------------*- C++ -*-===//
2254721Semaste//
3254721Semaste//                     The LLVM Compiler Infrastructure
4254721Semaste//
5254721Semaste// This file is distributed under the University of Illinois Open Source
6254721Semaste// License. See LICENSE.TXT for details.
7254721Semaste//
8254721Semaste//===----------------------------------------------------------------------===//
9254721Semaste
10254721Semaste#ifndef liblldb_RegisterContextPOSIX_H_
11254721Semaste#define liblldb_RegisterContextPOSIX_H_
12254721Semaste
13254721Semaste// C Includes
14254721Semaste// C++ Includes
15254721Semaste// Other libraries and framework includes
16263363Semaste#include "lldb/Core/ArchSpec.h"
17254721Semaste#include "lldb/Target/RegisterContext.h"
18254721Semaste
19254721Semaste//------------------------------------------------------------------------------
20263363Semaste/// @class POSIXBreakpointProtocol
21254721Semaste///
22254721Semaste/// @brief Extends RegisterClass with a few virtual operations useful on POSIX.
23263363Semasteclass POSIXBreakpointProtocol
24254721Semaste{
25254721Semastepublic:
26263363Semaste    POSIXBreakpointProtocol()
27254721Semaste        { m_watchpoints_initialized = false; }
28263363Semaste    virtual ~POSIXBreakpointProtocol() {}
29254721Semaste
30254721Semaste    /// Updates the register state of the associated thread after hitting a
31254721Semaste    /// breakpoint (if that make sense for the architecture).  Default
32254721Semaste    /// implementation simply returns true for architectures which do not
33254721Semaste    /// require any update.
34254721Semaste    ///
35254721Semaste    /// @return
36254721Semaste    ///    True if the operation succeeded and false otherwise.
37263363Semaste    virtual bool UpdateAfterBreakpoint() = 0;
38254721Semaste
39254721Semaste    /// Determines the index in lldb's register file given a kernel byte offset.
40254721Semaste    virtual unsigned
41263363Semaste    GetRegisterIndexFromOffset(unsigned offset) = 0;
42254721Semaste
43254721Semaste    // Checks to see if a watchpoint specified by hw_index caused the inferior
44254721Semaste    // to stop.
45254721Semaste    virtual bool
46263363Semaste    IsWatchpointHit (uint32_t hw_index) = 0;
47254721Semaste
48254721Semaste    // Resets any watchpoints that have been hit.
49254721Semaste    virtual bool
50263363Semaste    ClearWatchpointHits () = 0;
51254721Semaste
52254721Semaste    // Returns the watchpoint address associated with a watchpoint hardware
53254721Semaste    // index.
54254721Semaste    virtual lldb::addr_t
55263363Semaste    GetWatchpointAddress (uint32_t hw_index) = 0;
56254721Semaste
57254721Semaste    virtual bool
58263363Semaste    IsWatchpointVacant (uint32_t hw_index) = 0;
59254721Semaste
60254721Semaste    virtual bool
61254721Semaste    SetHardwareWatchpointWithIndex (lldb::addr_t addr, size_t size,
62254721Semaste                                    bool read, bool write,
63263363Semaste                                    uint32_t hw_index) = 0;
64254721Semaste
65263363Semaste    // From lldb_private::RegisterContext
66263363Semaste    virtual uint32_t
67263363Semaste    NumSupportedHardwareWatchpoints () = 0;
68263363Semaste
69269024Semaste    // Force m_watchpoints_initialized to TRUE
70269024Semaste    void
71269024Semaste    ForceWatchpointsInitialized () {m_watchpoints_initialized = true;}
72269024Semaste
73254721Semasteprotected:
74254721Semaste    bool m_watchpoints_initialized;
75254721Semaste};
76254721Semaste
77263363Semaste//------------------------------------------------------------------------------
78263363Semaste/// @class RegisterInfoInterface
79263363Semaste///
80263363Semaste/// @brief RegisterInfo interface to patch RegisterInfo structure for archs.
81263363Semasteclass RegisterInfoInterface
82263363Semaste{
83263363Semastepublic:
84263363Semaste    RegisterInfoInterface(const lldb_private::ArchSpec& target_arch) : m_target_arch(target_arch) {}
85263363Semaste    virtual ~RegisterInfoInterface () {}
86263363Semaste
87263363Semaste    virtual size_t
88263363Semaste    GetGPRSize () = 0;
89263363Semaste
90263363Semaste    virtual const lldb_private::RegisterInfo *
91263363Semaste    GetRegisterInfo () = 0;
92263363Semaste
93263363Semastepublic:
94263363Semaste    lldb_private::ArchSpec m_target_arch;
95263363Semaste};
96263363Semaste
97254721Semaste#endif // #ifndef liblldb_RegisterContextPOSIX_H_
98263363Semaste
99