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 
25 using namespace lldb_private;
26 using namespace lldb;
27 
28 static const uint32_t g_gpr_regnums[] = {
39 };
40 
41 static const uint32_t g_fpr_regnums[] = {
51 };
52 
53 static const uint32_t g_vmx_regnums[] = {
63 };
64 
65 // Number of register sets provided by this context.
66 enum { k_num_register_sets = 3 };
67 
68 static const RegisterSet g_reg_sets_powerpc[k_num_register_sets] = {
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 
77 static_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 
130 const 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) {
142  ++sets;
143  }
144 
145  return sets;
146 }
147 
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 }
gpr_r25_powerpc
@ gpr_r25_powerpc
Definition: RegisterContextPOSIX_powerpc.h:45
gpr_r27_powerpc
@ gpr_r27_powerpc
Definition: RegisterContextPOSIX_powerpc.h:47
fpr_f11_powerpc
@ fpr_f11_powerpc
Definition: RegisterContextPOSIX_powerpc.h:71
gpr_r10_powerpc
@ gpr_r10_powerpc
Definition: RegisterContextPOSIX_powerpc.h:30
RegisterContextPOSIX_powerpc::GetRegisterInfoAtIndex
const lldb_private::RegisterInfo * GetRegisterInfoAtIndex(size_t reg) override
Definition: RegisterContextPOSIX_powerpc.cpp:131
gpr_r2_powerpc
@ gpr_r2_powerpc
Definition: RegisterContextPOSIX_powerpc.h:22
gpr_r0_powerpc
@ gpr_r0_powerpc
Definition: RegisterContextPOSIX_powerpc.h:20
Scalar.h
gpr_r17_powerpc
@ gpr_r17_powerpc
Definition: RegisterContextPOSIX_powerpc.h:37
vmx_v25_powerpc
@ vmx_v25_powerpc
Definition: RegisterContextPOSIX_powerpc.h:121
RegisterContextPOSIX_powerpc::InvalidateAllRegisters
void InvalidateAllRegisters() override
Definition: RegisterContextPOSIX_powerpc.cpp:102
vmx_v17_powerpc
@ vmx_v17_powerpc
Definition: RegisterContextPOSIX_powerpc.h:113
k_num_gpr_registers_powerpc
@ k_num_gpr_registers_powerpc
Definition: RegisterContextPOSIX_powerpc.h:133
vmx_v11_powerpc
@ vmx_v11_powerpc
Definition: RegisterContextPOSIX_powerpc.h:107
vmx_v16_powerpc
@ vmx_v16_powerpc
Definition: RegisterContextPOSIX_powerpc.h:112
gpr_lr_powerpc
@ gpr_lr_powerpc
Definition: RegisterContextPOSIX_powerpc.h:52
RegisterContextPOSIX_powerpc::GetRegisterSetCount
size_t GetRegisterSetCount() override
Definition: RegisterContextPOSIX_powerpc.cpp:138
k_num_register_sets
@ k_num_register_sets
Definition: RegisterContextPOSIX_powerpc.cpp:66
k_last_gpr_powerpc
@ k_last_gpr_powerpc
Definition: RegisterContextPOSIX_powerpc.h:57
gpr_r9_powerpc
@ gpr_r9_powerpc
Definition: RegisterContextPOSIX_powerpc.h:29
RegisterContextPOSIX_powerpc::GetRegisterCount
size_t GetRegisterCount() override
Definition: RegisterContextPOSIX_powerpc.cpp:114
lldb_private::RegisterInfoInterface
Definition: RegisterInfoInterface.h:21
gpr_r8_powerpc
@ gpr_r8_powerpc
Definition: RegisterContextPOSIX_powerpc.h:28
fpr_f22_powerpc
@ fpr_f22_powerpc
Definition: RegisterContextPOSIX_powerpc.h:82
gpr_r3_powerpc
@ gpr_r3_powerpc
Definition: RegisterContextPOSIX_powerpc.h:23
vmx_v4_powerpc
@ vmx_v4_powerpc
Definition: RegisterContextPOSIX_powerpc.h:100
fpr_f12_powerpc
@ fpr_f12_powerpc
Definition: RegisterContextPOSIX_powerpc.h:72
RegisterContextPOSIX_powerpc::Invalidate
void Invalidate()
Definition: RegisterContextPOSIX_powerpc.cpp:100
RegisterContextPOSIX_powerpc::GetRegisterOffset
virtual unsigned GetRegisterOffset(unsigned reg)
Definition: RegisterContextPOSIX_powerpc.cpp:104
gpr_r26_powerpc
@ gpr_r26_powerpc
Definition: RegisterContextPOSIX_powerpc.h:46
vmx_v8_powerpc
@ vmx_v8_powerpc
Definition: RegisterContextPOSIX_powerpc.h:104
vmx_v1_powerpc
@ vmx_v1_powerpc
Definition: RegisterContextPOSIX_powerpc.h:97
gpr_r29_powerpc
@ gpr_r29_powerpc
Definition: RegisterContextPOSIX_powerpc.h:49
k_last_vmx
@ k_last_vmx
Definition: RegisterContextPOSIX_powerpc.h:130
k_first_fpr
@ k_first_fpr
Definition: RegisterContextPOSIX_powerpc.h:59
gpr_r30_powerpc
@ gpr_r30_powerpc
Definition: RegisterContextPOSIX_powerpc.h:50
gpr_r4_powerpc
@ gpr_r4_powerpc
Definition: RegisterContextPOSIX_powerpc.h:24
RegisterContextPOSIX_powerpc::IsVMX
bool IsVMX(unsigned reg)
Definition: RegisterContextPOSIX_powerpc.cpp:87
vmx_v22_powerpc
@ vmx_v22_powerpc
Definition: RegisterContextPOSIX_powerpc.h:118
RegisterValue.h
vmx_v21_powerpc
@ vmx_v21_powerpc
Definition: RegisterContextPOSIX_powerpc.h:117
vmx_v3_powerpc
@ vmx_v3_powerpc
Definition: RegisterContextPOSIX_powerpc.h:99
fpr_f8_powerpc
@ fpr_f8_powerpc
Definition: RegisterContextPOSIX_powerpc.h:68
fpr_f27_powerpc
@ fpr_f27_powerpc
Definition: RegisterContextPOSIX_powerpc.h:87
vmx_v9_powerpc
@ vmx_v9_powerpc
Definition: RegisterContextPOSIX_powerpc.h:105
fpr_f14_powerpc
@ fpr_f14_powerpc
Definition: RegisterContextPOSIX_powerpc.h:74
gpr_r18_powerpc
@ gpr_r18_powerpc
Definition: RegisterContextPOSIX_powerpc.h:38
fpr_f7_powerpc
@ fpr_f7_powerpc
Definition: RegisterContextPOSIX_powerpc.h:67
RegisterContextPOSIX_powerpc::GetGPRSize
virtual size_t GetGPRSize()
Definition: RegisterContextPOSIX_powerpc.cpp:119
vmx_v30_powerpc
@ vmx_v30_powerpc
Definition: RegisterContextPOSIX_powerpc.h:126
k_num_registers_powerpc
@ k_num_registers_powerpc
Definition: RegisterContextPOSIX_powerpc.h:132
vmx_v18_powerpc
@ vmx_v18_powerpc
Definition: RegisterContextPOSIX_powerpc.h:114
gpr_ctr_powerpc
@ gpr_ctr_powerpc
Definition: RegisterContextPOSIX_powerpc.h:55
RegisterContextPOSIX_powerpc::GetRegisterSet
const lldb_private::RegisterSet * GetRegisterSet(size_t set) override
Definition: RegisterContextPOSIX_powerpc.cpp:148
Process.h
vmx_v14_powerpc
@ vmx_v14_powerpc
Definition: RegisterContextPOSIX_powerpc.h:110
gpr_r24_powerpc
@ gpr_r24_powerpc
Definition: RegisterContextPOSIX_powerpc.h:44
fpr_f21_powerpc
@ fpr_f21_powerpc
Definition: RegisterContextPOSIX_powerpc.h:81
vmx_v20_powerpc
@ vmx_v20_powerpc
Definition: RegisterContextPOSIX_powerpc.h:116
Target.h
g_vmx_regnums
static const uint32_t g_vmx_regnums[]
Definition: RegisterContextPOSIX_powerpc.cpp:53
fpr_f29_powerpc
@ fpr_f29_powerpc
Definition: RegisterContextPOSIX_powerpc.h:89
gpr_r22_powerpc
@ gpr_r22_powerpc
Definition: RegisterContextPOSIX_powerpc.h:42
fpr_f16_powerpc
@ fpr_f16_powerpc
Definition: RegisterContextPOSIX_powerpc.h:76
gpr_xer_powerpc
@ gpr_xer_powerpc
Definition: RegisterContextPOSIX_powerpc.h:54
vmx_v27_powerpc
@ vmx_v27_powerpc
Definition: RegisterContextPOSIX_powerpc.h:123
vmx_v0_powerpc
@ vmx_v0_powerpc
Definition: RegisterContextPOSIX_powerpc.h:96
gpr_r21_powerpc
@ gpr_r21_powerpc
Definition: RegisterContextPOSIX_powerpc.h:41
lldb_private::Thread
Definition: Thread.h:62
k_first_gpr_powerpc
@ k_first_gpr_powerpc
Definition: RegisterContextPOSIX_powerpc.h:19
gpr_r13_powerpc
@ gpr_r13_powerpc
Definition: RegisterContextPOSIX_powerpc.h:33
fpr_fpscr_powerpc
@ fpr_fpscr_powerpc
Definition: RegisterContextPOSIX_powerpc.h:92
gpr_r23_powerpc
@ gpr_r23_powerpc
Definition: RegisterContextPOSIX_powerpc.h:43
fpr_f28_powerpc
@ fpr_f28_powerpc
Definition: RegisterContextPOSIX_powerpc.h:88
vmx_v23_powerpc
@ vmx_v23_powerpc
Definition: RegisterContextPOSIX_powerpc.h:119
RegisterContextPOSIX_powerpc::GetRegisterInfo
virtual const lldb_private::RegisterInfo * GetRegisterInfo()
Definition: RegisterContextPOSIX_powerpc.cpp:123
vmx_v28_powerpc
@ vmx_v28_powerpc
Definition: RegisterContextPOSIX_powerpc.h:124
k_num_fpr_registers_powerpc
@ k_num_fpr_registers_powerpc
Definition: RegisterContextPOSIX_powerpc.h:134
gpr_r16_powerpc
@ gpr_r16_powerpc
Definition: RegisterContextPOSIX_powerpc.h:36
RegisterContextPOSIX_powerpc::IsRegisterSetAvailable
virtual bool IsRegisterSetAvailable(size_t set_index)
Definition: RegisterContextPOSIX_powerpc.cpp:160
fpr_f5_powerpc
@ fpr_f5_powerpc
Definition: RegisterContextPOSIX_powerpc.h:65
vmx_v15_powerpc
@ vmx_v15_powerpc
Definition: RegisterContextPOSIX_powerpc.h:111
RegisterContextPOSIX_powerpc::m_register_info_up
std::unique_ptr< lldb_private::RegisterInfoInterface > m_register_info_up
Definition: RegisterContextPOSIX_powerpc.h:173
fpr_f1_powerpc
@ fpr_f1_powerpc
Definition: RegisterContextPOSIX_powerpc.h:61
vmx_v24_powerpc
@ vmx_v24_powerpc
Definition: RegisterContextPOSIX_powerpc.h:120
fpr_f0_powerpc
@ fpr_f0_powerpc
Definition: RegisterContextPOSIX_powerpc.h:60
fpr_f17_powerpc
@ fpr_f17_powerpc
Definition: RegisterContextPOSIX_powerpc.h:77
RegisterContextPOSIX_powerpc::IsGPR
bool IsGPR(unsigned reg)
Definition: RegisterContextPOSIX_powerpc.cpp:79
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
fpr_f19_powerpc
@ fpr_f19_powerpc
Definition: RegisterContextPOSIX_powerpc.h:79
vmx_vscr_powerpc
@ vmx_vscr_powerpc
Definition: RegisterContextPOSIX_powerpc.h:129
RegisterContextPOSIX_powerpc::IsFPR
bool IsFPR(unsigned reg)
Definition: RegisterContextPOSIX_powerpc.cpp:83
Thread.h
fpr_f10_powerpc
@ fpr_f10_powerpc
Definition: RegisterContextPOSIX_powerpc.h:70
fpr_f20_powerpc
@ fpr_f20_powerpc
Definition: RegisterContextPOSIX_powerpc.h:80
fpr_f15_powerpc
@ fpr_f15_powerpc
Definition: RegisterContextPOSIX_powerpc.h:75
k_num_vmx_registers_powerpc
@ k_num_vmx_registers_powerpc
Definition: RegisterContextPOSIX_powerpc.h:135
gpr_r19_powerpc
@ gpr_r19_powerpc
Definition: RegisterContextPOSIX_powerpc.h:39
lldb_private::RegisterContext
Definition: RegisterContext.h:17
RegisterContextPOSIX_powerpc.h
g_fpr_regnums
static const uint32_t g_fpr_regnums[]
Definition: RegisterContextPOSIX_powerpc.cpp:41
gpr_r7_powerpc
@ gpr_r7_powerpc
Definition: RegisterContextPOSIX_powerpc.h:27
fpr_f23_powerpc
@ fpr_f23_powerpc
Definition: RegisterContextPOSIX_powerpc.h:83
gpr_r11_powerpc
@ gpr_r11_powerpc
Definition: RegisterContextPOSIX_powerpc.h:31
k_last_fpr
@ k_last_fpr
Definition: RegisterContextPOSIX_powerpc.h:93
RegisterContextPOSIX_powerpc::GetRegisterName
const char * GetRegisterName(unsigned reg)
Definition: RegisterContextPOSIX_powerpc.cpp:155
fpr_f26_powerpc
@ fpr_f26_powerpc
Definition: RegisterContextPOSIX_powerpc.h:86
uint32_t
fpr_f24_powerpc
@ fpr_f24_powerpc
Definition: RegisterContextPOSIX_powerpc.h:84
gpr_r5_powerpc
@ gpr_r5_powerpc
Definition: RegisterContextPOSIX_powerpc.h:25
fpr_f30_powerpc
@ fpr_f30_powerpc
Definition: RegisterContextPOSIX_powerpc.h:90
gpr_cr_powerpc
@ gpr_cr_powerpc
Definition: RegisterContextPOSIX_powerpc.h:53
fpr_f18_powerpc
@ fpr_f18_powerpc
Definition: RegisterContextPOSIX_powerpc.h:78
fpr_f25_powerpc
@ fpr_f25_powerpc
Definition: RegisterContextPOSIX_powerpc.h:85
vmx_v6_powerpc
@ vmx_v6_powerpc
Definition: RegisterContextPOSIX_powerpc.h:102
vmx_v7_powerpc
@ vmx_v7_powerpc
Definition: RegisterContextPOSIX_powerpc.h:103
vmx_v10_powerpc
@ vmx_v10_powerpc
Definition: RegisterContextPOSIX_powerpc.h:106
DataExtractor.h
k_first_vmx
@ k_first_vmx
Definition: RegisterContextPOSIX_powerpc.h:95
gpr_r1_powerpc
@ gpr_r1_powerpc
Definition: RegisterContextPOSIX_powerpc.h:21
gpr_r15_powerpc
@ gpr_r15_powerpc
Definition: RegisterContextPOSIX_powerpc.h:35
RegisterContextPOSIX_powerpc::GetRegisterSize
virtual unsigned GetRegisterSize(unsigned reg)
Definition: RegisterContextPOSIX_powerpc.cpp:109
RegisterContextPOSIX_powerpc::~RegisterContextPOSIX_powerpc
~RegisterContextPOSIX_powerpc() override
fpr_f31_powerpc
@ fpr_f31_powerpc
Definition: RegisterContextPOSIX_powerpc.h:91
lldb_private
A class that represents a running process on the host machine.
Definition: SBCommandInterpreterRunOptions.h:16
fpr_f6_powerpc
@ fpr_f6_powerpc
Definition: RegisterContextPOSIX_powerpc.h:66
gpr_r20_powerpc
@ gpr_r20_powerpc
Definition: RegisterContextPOSIX_powerpc.h:40
vmx_v19_powerpc
@ vmx_v19_powerpc
Definition: RegisterContextPOSIX_powerpc.h:115
fpr_f9_powerpc
@ fpr_f9_powerpc
Definition: RegisterContextPOSIX_powerpc.h:69
fpr_f2_powerpc
@ fpr_f2_powerpc
Definition: RegisterContextPOSIX_powerpc.h:62
vmx_v2_powerpc
@ vmx_v2_powerpc
Definition: RegisterContextPOSIX_powerpc.h:98
vmx_v13_powerpc
@ vmx_v13_powerpc
Definition: RegisterContextPOSIX_powerpc.h:109
gpr_r14_powerpc
@ gpr_r14_powerpc
Definition: RegisterContextPOSIX_powerpc.h:34
fpr_f3_powerpc
@ fpr_f3_powerpc
Definition: RegisterContextPOSIX_powerpc.h:63
vmx_v26_powerpc
@ vmx_v26_powerpc
Definition: RegisterContextPOSIX_powerpc.h:122
gpr_r12_powerpc
@ gpr_r12_powerpc
Definition: RegisterContextPOSIX_powerpc.h:32
vmx_v12_powerpc
@ vmx_v12_powerpc
Definition: RegisterContextPOSIX_powerpc.h:108
vmx_v29_powerpc
@ vmx_v29_powerpc
Definition: RegisterContextPOSIX_powerpc.h:125
lldb
Definition: SBAddress.h:15
Endian.h
vmx_vrsave_powerpc
@ vmx_vrsave_powerpc
Definition: RegisterContextPOSIX_powerpc.h:128
vmx_v5_powerpc
@ vmx_v5_powerpc
Definition: RegisterContextPOSIX_powerpc.h:101
vmx_v31_powerpc
@ vmx_v31_powerpc
Definition: RegisterContextPOSIX_powerpc.h:127
gpr_pc_powerpc
@ gpr_pc_powerpc
Definition: RegisterContextPOSIX_powerpc.h:56
fpr_f4_powerpc
@ fpr_f4_powerpc
Definition: RegisterContextPOSIX_powerpc.h:64
DataBufferHeap.h
fpr_f13_powerpc
@ fpr_f13_powerpc
Definition: RegisterContextPOSIX_powerpc.h:73
gpr_r31_powerpc
@ gpr_r31_powerpc
Definition: RegisterContextPOSIX_powerpc.h:51
RegisterContextPOSIX_powerpc::RegisterContextPOSIX_powerpc
RegisterContextPOSIX_powerpc(lldb_private::Thread &thread, uint32_t concrete_frame_idx, lldb_private::RegisterInfoInterface *register_info)
Definition: RegisterContextPOSIX_powerpc.cpp:91
g_reg_sets_powerpc
static const RegisterSet g_reg_sets_powerpc[k_num_register_sets]
Definition: RegisterContextPOSIX_powerpc.cpp:68
gpr_r28_powerpc
@ gpr_r28_powerpc
Definition: RegisterContextPOSIX_powerpc.h:48
g_gpr_regnums
static const uint32_t g_gpr_regnums[]
Definition: RegisterContextPOSIX_powerpc.cpp:28
gpr_r6_powerpc
@ gpr_r6_powerpc
Definition: RegisterContextPOSIX_powerpc.h:26