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