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 17 namespace lldb_private 18 { 19 20 ///------------------------------------------------------------------------------ 21 /// @class RegisterInfoInterface 22 /// 23 /// @brief RegisterInfo interface to patch RegisterInfo structure for archs. 24 ///------------------------------------------------------------------------------ 25 class RegisterInfoInterface 26 { 27 public: 28 RegisterInfoInterface(const lldb_private::ArchSpec& target_arch) : m_target_arch(target_arch) {} 29 virtual ~RegisterInfoInterface () {} 30 31 virtual size_t 32 GetGPRSize () const = 0; 33 34 virtual const lldb_private::RegisterInfo * 35 GetRegisterInfo () const = 0; 36 37 // Returns the number of registers including the user registers and the 38 // lldb internal registers also 39 virtual uint32_t 40 GetRegisterCount () const = 0; 41 42 // Returns the number of the user registers (excluding the registers 43 // kept for lldb internal use only). Subclasses should override it if 44 // they belongs to an architecture with lldb internal registers. 45 virtual uint32_t 46 GetUserRegisterCount () const 47 { 48 return GetRegisterCount(); 49 } 50 51 const lldb_private::ArchSpec& 52 GetTargetArchitecture() const 53 { return m_target_arch; } 54 55 virtual const lldb_private::RegisterInfo * 56 GetDynamicRegisterInfo(const char *reg_name) const 57 { 58 const std::vector <lldb_private::RegisterInfo> * d_register_infos = GetDynamicRegisterInfoP(); 59 if(d_register_infos != nullptr) 60 { 61 std::vector <lldb_private::RegisterInfo> ::const_iterator pos = d_register_infos->begin(); 62 for(; pos < d_register_infos->end() ; pos++) 63 { 64 if(::strcmp(reg_name, pos->name) == 0) 65 return(d_register_infos->data() + (pos - d_register_infos->begin()) ); 66 } 67 } 68 return nullptr; 69 } 70 71 virtual const std::vector<lldb_private::RegisterInfo> * 72 GetDynamicRegisterInfoP() const 73 { return nullptr; } 74 75 public: 76 // FIXME make private. 77 lldb_private::ArchSpec m_target_arch; 78 }; 79 80 } 81 82 #endif 83