]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/tools/lldb/source/Plugins/Process/Utility/RegisterInfoInterface.h
MFV r326007: less v529.
[FreeBSD/FreeBSD.git] / contrib / llvm / tools / lldb / source / Plugins / Process / Utility / RegisterInfoInterface.h
1 //===-- RegisterInfoInterface.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 lldb_RegisterInfoInterface_h
11 #define lldb_RegisterInfoInterface_h
12
13 #include <vector>
14
15 #include "lldb/Core/ArchSpec.h"
16 #include "lldb/lldb-private-types.h"
17
18 namespace lldb_private {
19
20 ///------------------------------------------------------------------------------
21 /// @class RegisterInfoInterface
22 ///
23 /// @brief RegisterInfo interface to patch RegisterInfo structure for archs.
24 ///------------------------------------------------------------------------------
25 class RegisterInfoInterface {
26 public:
27   RegisterInfoInterface(const lldb_private::ArchSpec &target_arch)
28       : m_target_arch(target_arch) {}
29   virtual ~RegisterInfoInterface() {}
30
31   virtual size_t GetGPRSize() const = 0;
32
33   virtual const lldb_private::RegisterInfo *GetRegisterInfo() const = 0;
34
35   // Returns the number of registers including the user registers and the
36   // lldb internal registers also
37   virtual uint32_t GetRegisterCount() const = 0;
38
39   // Returns the number of the user registers (excluding the registers
40   // kept for lldb internal use only). Subclasses should override it if
41   // they belongs to an architecture with lldb internal registers.
42   virtual uint32_t GetUserRegisterCount() const { return GetRegisterCount(); }
43
44   const lldb_private::ArchSpec &GetTargetArchitecture() const {
45     return m_target_arch;
46   }
47
48   virtual const lldb_private::RegisterInfo *
49   GetDynamicRegisterInfo(const char *reg_name) const {
50     const std::vector<lldb_private::RegisterInfo> *d_register_infos =
51         GetDynamicRegisterInfoP();
52     if (d_register_infos != nullptr) {
53       std::vector<lldb_private::RegisterInfo>::const_iterator pos =
54           d_register_infos->begin();
55       for (; pos < d_register_infos->end(); pos++) {
56         if (::strcmp(reg_name, pos->name) == 0)
57           return (d_register_infos->data() + (pos - d_register_infos->begin()));
58       }
59     }
60     return nullptr;
61   }
62
63   virtual const std::vector<lldb_private::RegisterInfo> *
64   GetDynamicRegisterInfoP() const {
65     return nullptr;
66   }
67
68 public:
69   // FIXME make private.
70   lldb_private::ArchSpec m_target_arch;
71 };
72 }
73
74 #endif