LLDB mainline
RegisterContextPOSIX_ppc64le.cpp
Go to the documentation of this file.
1//===-- RegisterContextPOSIX_ppc64le.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
24
25using namespace lldb_private;
26using namespace lldb;
27
28static const uint32_t g_gpr_regnums[] = {
40};
41
42static const uint32_t g_fpr_regnums[] = {
52};
53
54static const uint32_t g_vmx_regnums[] = {
64};
65
66static const uint32_t g_vsx_regnums[] = {
83};
84
85// Number of register sets provided by this context.
87
89 {"General Purpose Registers", "gpr", k_num_gpr_registers_ppc64le,
91 {"Floating Point Registers", "fpr", k_num_fpr_registers_ppc64le,
93 {"Altivec/VMX Registers", "vmx", k_num_vmx_registers_ppc64le,
95 {"VSX Registers", "vsx", k_num_vsx_registers_ppc64le, g_vsx_regnums},
96};
97
99 return (reg <= k_last_gpr_ppc64le); // GPR's come first.
100}
101
103 return (reg >= k_first_fpr_ppc64le) && (reg <= k_last_fpr_ppc64le);
104}
105
107 return (reg >= k_first_vmx_ppc64le) && (reg <= k_last_vmx_ppc64le);
108}
109
111 return (reg >= k_first_vsx_ppc64le) && (reg <= k_last_vsx_ppc64le);
112}
113
115 Thread &thread, uint32_t concrete_frame_idx,
116 RegisterInfoInterface *register_info)
117 : RegisterContext(thread, concrete_frame_idx) {
118 m_register_info_up.reset(register_info);
119}
120
122
124 assert(reg < k_num_registers_ppc64le && "Invalid register number.");
125 return GetRegisterInfo()[reg].byte_offset;
126}
127
129 assert(reg < k_num_registers_ppc64le && "Invalid register number.");
130 return GetRegisterInfo()[reg].byte_size;
131}
132
134 size_t num_registers = k_num_registers_ppc64le;
135 return num_registers;
136}
137
139 return m_register_info_up->GetGPRSize();
140}
141
143 // Commonly, this method is overridden and g_register_infos is copied and
144 // specialized. So, use GetRegisterInfo() rather than g_register_infos in
145 // this scope.
146 return m_register_info_up->GetRegisterInfo();
147}
148
149const RegisterInfo *
151 if (reg < k_num_registers_ppc64le)
152 return &GetRegisterInfo()[reg];
153 else
154 return nullptr;
155}
156
158 size_t sets = 0;
159 for (size_t set = 0; set < k_num_register_sets; ++set) {
160 if (IsRegisterSetAvailable(set))
161 ++sets;
162 }
163
164 return sets;
165}
166
168 if (IsRegisterSetAvailable(set))
169 return &g_reg_sets_ppc64le[set];
170 else
171 return nullptr;
172}
173
175 assert(reg < k_num_registers_ppc64le && "Invalid register offset.");
176 return GetRegisterInfo()[reg].name;
177}
178
180 size_t num_sets = k_num_register_sets;
181
182 return (set_index < num_sets);
183}
constexpr size_t k_num_register_sets
static const uint32_t g_vsx_regnums[]
static const uint32_t g_fpr_regnums[]
static const uint32_t g_gpr_regnums[]
static const uint32_t g_vmx_regnums[]
static const RegisterSet g_reg_sets_ppc64le[k_num_register_sets]
const lldb_private::RegisterInfo * GetRegisterInfoAtIndex(size_t reg) override
virtual unsigned GetRegisterOffset(unsigned reg)
virtual unsigned GetRegisterSize(unsigned reg)
const char * GetRegisterName(unsigned reg)
const lldb_private::RegisterSet * GetRegisterSet(size_t set) override
std::unique_ptr< lldb_private::RegisterInfoInterface > m_register_info_up
virtual const lldb_private::RegisterInfo * GetRegisterInfo()
RegisterContextPOSIX_ppc64le(lldb_private::Thread &thread, uint32_t concrete_frame_idx, lldb_private::RegisterInfoInterface *register_info)
virtual bool IsRegisterSetAvailable(size_t set_index)
RegisterInfo interface to patch RegisterInfo structure for archs.
@ k_num_gpr_registers_ppc64le
@ k_num_vsx_registers_ppc64le
@ k_num_vmx_registers_ppc64le
@ k_num_fpr_registers_ppc64le
A class that represents a running process on the host machine.
Definition: SBAddress.h:15
Every register is described in detail including its name, alternate name (optional),...
uint32_t byte_offset
The byte offset in the register context data where this register's value is found.
uint32_t byte_size
Size in bytes of the register.
const char * name
Name of this register, can't be NULL.
Registers are grouped into register sets.