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
15 #include "lldb/Core/ArchSpec.h"
16 #include "lldb/lldb-private-types.h"
18 namespace lldb_private {
20 ///------------------------------------------------------------------------------
21 /// @class RegisterInfoInterface
23 /// @brief RegisterInfo interface to patch RegisterInfo structure for archs.
24 ///------------------------------------------------------------------------------
25 class RegisterInfoInterface {
27 RegisterInfoInterface(const lldb_private::ArchSpec &target_arch)
28 : m_target_arch(target_arch) {}
29 virtual ~RegisterInfoInterface() {}
31 virtual size_t GetGPRSize() const = 0;
33 virtual const lldb_private::RegisterInfo *GetRegisterInfo() const = 0;
35 // Returns the number of registers including the user registers and the
36 // lldb internal registers also
37 virtual uint32_t GetRegisterCount() const = 0;
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(); }
44 const lldb_private::ArchSpec &GetTargetArchitecture() const {
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()));
63 virtual const std::vector<lldb_private::RegisterInfo> *
64 GetDynamicRegisterInfoP() const {
69 // FIXME make private.
70 lldb_private::ArchSpec m_target_arch;