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
26using namespace lldb_private;
27using 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)
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
92const 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
112const RegisterSet *RegisterContextPOSIX_mips64::GetRegisterSet(size_t set) {
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}
const lldb_private::RegisterSet * GetRegisterSet(size_t set) const
RegisterContextPOSIX_mips64(lldb_private::Thread &thread, uint32_t concrete_frame_idx, lldb_private::RegisterInfoInterface *register_info)
uint32_t ConvertRegisterKindToRegisterNumber(lldb::RegisterKind kind, uint32_t num) override
Convert from a given register numbering scheme to the lldb register numbering scheme.
virtual unsigned GetRegisterOffset(unsigned reg)
virtual unsigned GetRegisterSize(unsigned reg)
uint8_t m_registers_count[register_set_count]
std::unique_ptr< lldb_private::RegisterInfoInterface > m_register_info_up
virtual const lldb_private::RegisterInfo * GetRegisterInfo()
virtual bool IsRegisterSetAvailable(size_t set_index)
const lldb_private::RegisterSet * GetRegisterSet(size_t set) override
~RegisterContextPOSIX_mips64() override
const lldb_private::RegisterInfo * GetRegisterInfoAtIndex(size_t reg) override
const char * GetRegisterName(unsigned reg)
An architecture specification class.
Definition: ArchSpec.h:32
llvm::Triple & GetTriple()
Architecture triple accessor.
Definition: ArchSpec.h:463
RegisterInfo interface to patch RegisterInfo structure for archs.
#define LLDB_INVALID_REGNUM
Definition: lldb-defines.h:79
A class that represents a running process on the host machine.
Definition: SBAddress.h:15
RegisterKind
Register numbering types.
@ kNumRegisterKinds