LLDB  mainline
RegisterContextPOSIX_mips64.cpp
Go to the documentation of this file.
1 //===-- RegisterContextPOSIX_mips64.cpp -----------------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
9 #include <cerrno>
10 #include <cstdint>
11 #include <cstring>
12 
13 #include "lldb/Target/Process.h"
14 #include "lldb/Target/Target.h"
15 #include "lldb/Target/Thread.h"
18 #include "lldb/Utility/Endian.h"
20 #include "lldb/Utility/Scalar.h"
21 #include "llvm/Support/Compiler.h"
22 
25 
26 using namespace lldb_private;
27 using namespace lldb;
28 
30  return reg < m_registers_count[gpr_registers_count]; // GPR's come first.
31 }
32 
34  int set = GetRegisterSetCount();
35  if (set > 1)
36  return reg < (m_registers_count[fpr_registers_count]
37  + m_registers_count[gpr_registers_count]);
38  return false;
39 }
40 
42  Thread &thread, uint32_t concrete_frame_idx,
43  RegisterInfoInterface *register_info)
44  : RegisterContext(thread, concrete_frame_idx) {
45  m_register_info_up.reset(register_info);
47  int set = GetRegisterSetCount();
48 
49  const RegisterSet *reg_set_ptr;
50  for(int i = 0; i < set; ++i) {
51  reg_set_ptr = GetRegisterSet(i);
52  m_registers_count[i] = reg_set_ptr->num_registers;
53  }
54 
55  assert(m_num_registers ==
59 }
60 
62 
64 
66 
68  assert(reg < m_num_registers && "Invalid register number.");
69  return GetRegisterInfo()[reg].byte_offset;
70 }
71 
73  assert(reg < m_num_registers && "Invalid register number.");
74  return GetRegisterInfo()[reg].byte_size;
75 }
76 
78  return m_register_info_up->GetRegisterCount();
79 }
80 
82  return m_register_info_up->GetGPRSize();
83 }
84 
86  // Commonly, this method is overridden and g_register_infos is copied and
87  // specialized. So, use GetRegisterInfo() rather than g_register_infos in
88  // this scope.
89  return m_register_info_up->GetRegisterInfo();
90 }
91 
92 const RegisterInfo *
94  if (reg < m_num_registers)
95  return &GetRegisterInfo()[reg];
96  else
97  return nullptr;
98 }
99 
101  ArchSpec target_arch = m_register_info_up->GetTargetArchitecture();
102  switch (target_arch.GetTriple().getOS()) {
103  default: {
104  const auto *context = static_cast<const RegisterContextFreeBSD_mips64 *>(
105  m_register_info_up.get());
106  return context->GetRegisterSetCount();
107  }
108 
109  }
110 }
111 
113  ArchSpec target_arch = m_register_info_up->GetTargetArchitecture();
114  switch (target_arch.GetTriple().getOS()) {
115  default: {
116  const auto *context = static_cast<const RegisterContextFreeBSD_mips64 *>(
117  m_register_info_up.get());
118  return context->GetRegisterSet(set);
119  }
120  }
121 }
122 
124  assert(reg < m_num_registers && "Invalid register offset.");
125  return GetRegisterInfo()[reg].name;
126 }
127 
129  size_t num_sets = GetRegisterSetCount();
130 
131  return (set_index < num_sets);
132 }
133 
134 // Used when parsing DWARF and EH frame information and any other object file
135 // sections that contain register numbers in them.
137  lldb::RegisterKind kind, uint32_t num) {
138  const uint32_t num_regs = m_num_registers;
139 
140  assert(kind < kNumRegisterKinds);
141  for (uint32_t reg_idx = 0; reg_idx < num_regs; ++reg_idx) {
142  const RegisterInfo *reg_info = GetRegisterInfoAtIndex(reg_idx);
143 
144  if (reg_info->kinds[kind] == num)
145  return reg_idx;
146  }
147 
148  return LLDB_INVALID_REGNUM;
149 }
RegisterContextPOSIX_mips64.h
Scalar.h
lldb_private::ArchSpec
Definition: ArchSpec.h:33
LLDB_INVALID_REGNUM
#define LLDB_INVALID_REGNUM
Definition: lldb-defines.h:91
RegisterContextPOSIX_mips64::fpr_registers_count
@ fpr_registers_count
Definition: RegisterContextPOSIX_mips64.h:22
RegisterContextPOSIX_mips64::GetRegisterSize
virtual unsigned GetRegisterSize(unsigned reg)
Definition: RegisterContextPOSIX_mips64.cpp:72
RegisterContextFreeBSD_mips64::GetRegisterSet
const lldb_private::RegisterSet * GetRegisterSet(size_t set) const
Definition: RegisterContextFreeBSD_mips64.cpp:160
lldb_private::RegisterInfoInterface
Definition: RegisterInfoInterface.h:21
RegisterContextPOSIX_mips64::Invalidate
void Invalidate()
Definition: RegisterContextPOSIX_mips64.cpp:63
RegisterContextPOSIX_mips64::IsGPR
bool IsGPR(unsigned reg)
Definition: RegisterContextPOSIX_mips64.cpp:29
lldb::kNumRegisterKinds
@ kNumRegisterKinds
Definition: lldb-enumerations.h:235
RegisterValue.h
lldb_private::ArchSpec::GetTriple
llvm::Triple & GetTriple()
Architecture triple accessor.
Definition: ArchSpec.h:444
RegisterContextPOSIX_mips64::GetRegisterOffset
virtual unsigned GetRegisterOffset(unsigned reg)
Definition: RegisterContextPOSIX_mips64.cpp:67
Process.h
RegisterContextFreeBSD_mips64.h
Target.h
RegisterContextPOSIX_mips64::msa_registers_count
@ msa_registers_count
Definition: RegisterContextPOSIX_mips64.h:23
RegisterContextPOSIX_mips64::GetRegisterInfoAtIndex
const lldb_private::RegisterInfo * GetRegisterInfoAtIndex(size_t reg) override
Definition: RegisterContextPOSIX_mips64.cpp:93
lldb_private::Thread
Definition: Thread.h:60
RegisterContextFreeBSD_mips64::GetRegisterSetCount
size_t GetRegisterSetCount() const
Definition: RegisterContextFreeBSD_mips64.cpp:167
RegisterContextPOSIX_mips64::m_num_registers
uint32_t m_num_registers
Definition: RegisterContextPOSIX_mips64.h:57
RegisterContextPOSIX_mips64::gpr_registers_count
@ gpr_registers_count
Definition: RegisterContextPOSIX_mips64.h:21
set
set(option_framework FRAMEWORK) endif() if(LLDB_ENABLE_PYTHON) get_target_property(python_bindings_dir swig_wrapper_python BINARY_DIR) set(lldb_python_wrapper $
Definition: API/CMakeLists.txt:9
RegisterContextPOSIX_mips64::GetRegisterCount
size_t GetRegisterCount() override
Definition: RegisterContextPOSIX_mips64.cpp:77
Thread.h
lldb_private::RegisterContext
Definition: RegisterContext.h:17
lldb::RegisterKind
RegisterKind
Register numbering types.
Definition: lldb-enumerations.h:227
RegisterContextPOSIX_mips64::GetRegisterSetCount
size_t GetRegisterSetCount() override
Definition: RegisterContextPOSIX_mips64.cpp:100
RegisterContextPOSIX_mips64::m_register_info_up
std::unique_ptr< lldb_private::RegisterInfoInterface > m_register_info_up
Definition: RegisterContextPOSIX_mips64.h:60
RegisterContextPOSIX_mips64::ConvertRegisterKindToRegisterNumber
uint32_t ConvertRegisterKindToRegisterNumber(lldb::RegisterKind kind, uint32_t num) override
Convert from a given register numbering scheme to the lldb register numbering scheme.
Definition: RegisterContextPOSIX_mips64.cpp:136
uint32_t
RegisterContextPOSIX_mips64::GetGPRSize
virtual size_t GetGPRSize()
Definition: RegisterContextPOSIX_mips64.cpp:81
RegisterContextPOSIX_mips64::GetRegisterInfo
virtual const lldb_private::RegisterInfo * GetRegisterInfo()
Definition: RegisterContextPOSIX_mips64.cpp:85
RegisterContextPOSIX_mips64::GetRegisterName
const char * GetRegisterName(unsigned reg)
Definition: RegisterContextPOSIX_mips64.cpp:123
RegisterContextPOSIX_mips64::GetRegisterSet
const lldb_private::RegisterSet * GetRegisterSet(size_t set) override
Definition: RegisterContextPOSIX_mips64.cpp:112
DataExtractor.h
RegisterContextPOSIX_mips64::IsRegisterSetAvailable
virtual bool IsRegisterSetAvailable(size_t set_index)
Definition: RegisterContextPOSIX_mips64.cpp:128
RegisterContextPOSIX_mips64::~RegisterContextPOSIX_mips64
~RegisterContextPOSIX_mips64() override
lldb_private
A class that represents a running process on the host machine.
Definition: SBCommandInterpreterRunOptions.h:16
RegisterContextPOSIX_mips64::m_registers_count
uint8_t m_registers_count[register_set_count]
Definition: RegisterContextPOSIX_mips64.h:58
RegisterContextFreeBSD_mips64
Definition: RegisterContextFreeBSD_mips64.h:14
RegisterContextPOSIX_mips64::RegisterContextPOSIX_mips64
RegisterContextPOSIX_mips64(lldb_private::Thread &thread, uint32_t concrete_frame_idx, lldb_private::RegisterInfoInterface *register_info)
Definition: RegisterContextPOSIX_mips64.cpp:41
RegisterContextPOSIX_mips64::InvalidateAllRegisters
void InvalidateAllRegisters() override
Definition: RegisterContextPOSIX_mips64.cpp:65
lldb
Definition: SBAddress.h:15
Endian.h
DataBufferHeap.h
RegisterContextPOSIX_mips64::IsFPR
bool IsFPR(unsigned reg)
Definition: RegisterContextPOSIX_mips64.cpp:33