LLDB mainline
RegisterContextPOSIX_powerpc.cpp
Go to the documentation of this file.
1//===-- RegisterContextPOSIX_powerpc.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[] = {
39};
40
41static const uint32_t g_fpr_regnums[] = {
51};
52
53static const uint32_t g_vmx_regnums[] = {
63};
64
65// Number of register sets provided by this context.
67
69 {"General Purpose Registers", "gpr", k_num_gpr_registers_powerpc,
71 {"Floating Point Registers", "fpr", k_num_fpr_registers_powerpc,
73 {"Altivec/VMX Registers", "vmx", k_num_vmx_registers_powerpc,
75};
76
77static_assert(k_first_gpr_powerpc == 0,
78 "GPRs must index starting at 0, or fix IsGPR()");
80 return (reg <= k_last_gpr_powerpc); // GPR's come first.
81}
82
84 return (reg >= k_first_fpr) && (reg <= k_last_fpr);
85}
86
88 return (reg >= k_first_vmx) && (reg <= k_last_vmx);
89}
90
92 Thread &thread, uint32_t concrete_frame_idx,
93 RegisterInfoInterface *register_info)
94 : RegisterContext(thread, concrete_frame_idx) {
95 m_register_info_up.reset(register_info);
96}
97
99
101
103
105 assert(reg < k_num_registers_powerpc && "Invalid register number.");
106 return GetRegisterInfo()[reg].byte_offset;
107}
108
110 assert(reg < k_num_registers_powerpc && "Invalid register number.");
111 return GetRegisterInfo()[reg].byte_size;
112}
113
115 size_t num_registers = k_num_registers_powerpc;
116 return num_registers;
117}
118
120 return m_register_info_up->GetGPRSize();
121}
122
124 // Commonly, this method is overridden and g_register_infos is copied and
125 // specialized. So, use GetRegisterInfo() rather than g_register_infos in
126 // this scope.
127 return m_register_info_up->GetRegisterInfo();
128}
129
130const RegisterInfo *
132 if (reg < k_num_registers_powerpc)
133 return &GetRegisterInfo()[reg];
134 else
135 return nullptr;
136}
137
139 size_t sets = 0;
140 for (size_t set = 0; set < k_num_register_sets; ++set) {
141 if (IsRegisterSetAvailable(set))
142 ++sets;
143 }
144
145 return sets;
146}
147
149 if (IsRegisterSetAvailable(set))
150 return &g_reg_sets_powerpc[set];
151 else
152 return nullptr;
153}
154
156 assert(reg < k_num_registers_powerpc && "Invalid register offset.");
157 return GetRegisterInfo()[reg].name;
158}
159
161 size_t num_sets = k_num_register_sets;
162
163 return (set_index < num_sets);
164}
constexpr size_t k_num_register_sets
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_powerpc[k_num_register_sets]
@ k_num_fpr_registers_powerpc
@ k_num_vmx_registers_powerpc
@ k_num_gpr_registers_powerpc
const char * GetRegisterName(unsigned reg)
virtual unsigned GetRegisterOffset(unsigned reg)
RegisterContextPOSIX_powerpc(lldb_private::Thread &thread, uint32_t concrete_frame_idx, lldb_private::RegisterInfoInterface *register_info)
const lldb_private::RegisterSet * GetRegisterSet(size_t set) override
virtual unsigned GetRegisterSize(unsigned reg)
virtual const lldb_private::RegisterInfo * GetRegisterInfo()
const lldb_private::RegisterInfo * GetRegisterInfoAtIndex(size_t reg) override
virtual bool IsRegisterSetAvailable(size_t set_index)
~RegisterContextPOSIX_powerpc() override
std::unique_ptr< lldb_private::RegisterInfoInterface > m_register_info_up
RegisterInfo interface to patch RegisterInfo structure for archs.
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.