1 //===-- RegisterContextPOSIXCore_powerpc.cpp ------------------------------===//
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
7 //===----------------------------------------------------------------------===//
9 #include "RegisterContextPOSIXCore_powerpc.h"
11 #include "lldb/Target/Thread.h"
12 #include "lldb/Utility/DataBufferHeap.h"
13 #include "lldb/Utility/RegisterValue.h"
17 using namespace lldb_private
;
19 RegisterContextCorePOSIX_powerpc::RegisterContextCorePOSIX_powerpc(
20 Thread
&thread
, RegisterInfoInterface
*register_info
,
21 const DataExtractor
&gpregset
, llvm::ArrayRef
<CoreNote
> notes
)
22 : RegisterContextPOSIX_powerpc(thread
, 0, register_info
) {
23 m_gpr_buffer
= std::make_shared
<DataBufferHeap
>(gpregset
.GetDataStart(),
24 gpregset
.GetByteSize());
25 m_gpr
.SetData(m_gpr_buffer
);
26 m_gpr
.SetByteOrder(gpregset
.GetByteOrder());
28 ArchSpec arch
= register_info
->GetTargetArchitecture();
29 DataExtractor fpregset
= getRegset(notes
, arch
.GetTriple(), FPR_Desc
);
30 m_fpr_buffer
= std::make_shared
<DataBufferHeap
>(fpregset
.GetDataStart(),
31 fpregset
.GetByteSize());
32 m_fpr
.SetData(m_fpr_buffer
);
33 m_fpr
.SetByteOrder(fpregset
.GetByteOrder());
35 DataExtractor vregset
= getRegset(notes
, arch
.GetTriple(), PPC_VMX_Desc
);
36 m_vec_buffer
= std::make_shared
<DataBufferHeap
>(vregset
.GetDataStart(),
37 vregset
.GetByteSize());
38 m_vec
.SetData(m_vec_buffer
);
39 m_vec
.SetByteOrder(vregset
.GetByteOrder());
42 RegisterContextCorePOSIX_powerpc::~RegisterContextCorePOSIX_powerpc() = default;
44 bool RegisterContextCorePOSIX_powerpc::ReadGPR() { return true; }
46 bool RegisterContextCorePOSIX_powerpc::ReadFPR() { return true; }
48 bool RegisterContextCorePOSIX_powerpc::ReadVMX() { return true; }
50 bool RegisterContextCorePOSIX_powerpc::WriteGPR() {
55 bool RegisterContextCorePOSIX_powerpc::WriteFPR() {
60 bool RegisterContextCorePOSIX_powerpc::WriteVMX() {
65 bool RegisterContextCorePOSIX_powerpc::ReadRegister(
66 const RegisterInfo
*reg_info
, RegisterValue
&value
) {
67 lldb::offset_t offset
= reg_info
->byte_offset
;
68 if (IsFPR(reg_info
->kinds
[lldb::eRegisterKindLLDB
])) {
69 uint64_t v
= m_fpr
.GetMaxU64(&offset
, reg_info
->byte_size
);
70 if (offset
== reg_info
->byte_offset
+ reg_info
->byte_size
) {
74 } else if (IsVMX(reg_info
->kinds
[lldb::eRegisterKindLLDB
])) {
76 offset
= m_vec
.CopyData(offset
, reg_info
->byte_size
, &v
);
77 if (offset
== reg_info
->byte_size
) {
78 value
.SetBytes(v
, reg_info
->byte_size
, m_vec
.GetByteOrder());
82 uint64_t v
= m_gpr
.GetMaxU64(&offset
, reg_info
->byte_size
);
83 if (offset
== reg_info
->byte_offset
+ reg_info
->byte_size
) {
84 if (reg_info
->byte_size
< sizeof(v
))
94 bool RegisterContextCorePOSIX_powerpc::ReadAllRegisterValues(
95 lldb::WritableDataBufferSP
&data_sp
) {
99 bool RegisterContextCorePOSIX_powerpc::WriteRegister(
100 const RegisterInfo
*reg_info
, const RegisterValue
&value
) {
104 bool RegisterContextCorePOSIX_powerpc::WriteAllRegisterValues(
105 const lldb::DataBufferSP
&data_sp
) {
109 bool RegisterContextCorePOSIX_powerpc::HardwareSingleStep(bool enable
) {