1 //===-- RegisterInfoInterface.h --------------------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #ifndef lldb_RegisterInfoInterface_h
11 #define lldb_RegisterInfoInterface_h
13 #include "lldb/Utility/ArchSpec.h"
14 #include "lldb/lldb-private-types.h"
17 namespace lldb_private {
19 ///------------------------------------------------------------------------------
20 /// @class RegisterInfoInterface
22 /// @brief RegisterInfo interface to patch RegisterInfo structure for archs.
23 ///------------------------------------------------------------------------------
24 class RegisterInfoInterface {
26 RegisterInfoInterface(const lldb_private::ArchSpec &target_arch)
27 : m_target_arch(target_arch) {}
28 virtual ~RegisterInfoInterface() {}
30 virtual size_t GetGPRSize() const = 0;
32 virtual const lldb_private::RegisterInfo *GetRegisterInfo() const = 0;
34 // Returns the number of registers including the user registers and the
35 // lldb internal registers also
36 virtual uint32_t GetRegisterCount() const = 0;
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(); }
43 const lldb_private::ArchSpec &GetTargetArchitecture() const {
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()));
62 virtual const std::vector<lldb_private::RegisterInfo> *
63 GetDynamicRegisterInfoP() const {
68 // FIXME make private.
69 lldb_private::ArchSpec m_target_arch;