LLDB  mainline
RegisterContextPOSIXCore_powerpc.cpp
Go to the documentation of this file.
1 //===-- RegisterContextPOSIXCore_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 
10 
11 #include "lldb/Target/Thread.h"
14 
15 #include <memory>
16 
17 using namespace lldb_private;
18 
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());
26  m_gpr.SetByteOrder(gpregset.GetByteOrder());
27 
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());
33  m_fpr.SetByteOrder(fpregset.GetByteOrder());
34 
35  DataExtractor vregset = getRegset(notes, arch.GetTriple(), PPC_VMX_Desc);
36  m_vec_buffer = std::make_shared<DataBufferHeap>(vregset.GetDataStart(),
37  vregset.GetByteSize());
39  m_vec.SetByteOrder(vregset.GetByteOrder());
40 }
41 
43 
45 
47 
49 
51  assert(0);
52  return false;
53 }
54 
56  assert(0);
57  return false;
58 }
59 
61  assert(0);
62  return false;
63 }
64 
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) {
71  value = v;
72  return true;
73  }
74  } else if (IsVMX(reg_info->kinds[lldb::eRegisterKindLLDB])) {
75  uint32_t v[4];
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());
79  return true;
80  }
81  } else {
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))
85  value = (uint32_t)v;
86  else
87  value = v;
88  return true;
89  }
90  }
91  return false;
92 }
93 
95  lldb::DataBufferSP &data_sp) {
96  return false;
97 }
98 
100  const RegisterInfo *reg_info, const RegisterValue &value) {
101  return false;
102 }
103 
105  const lldb::DataBufferSP &data_sp) {
106  return false;
107 }
108 
110  return false;
111 }
lldb_private::ArchSpec
Definition: ArchSpec.h:33
RegisterContextCorePOSIX_powerpc::WriteVMX
bool WriteVMX() override
Definition: RegisterContextPOSIXCore_powerpc.cpp:60
lldb_private::RegisterValue
Definition: RegisterValue.h:28
lldb_private::FPR_Desc
constexpr RegsetDesc FPR_Desc[]
Definition: RegisterUtilities.h:102
lldb_private::RegisterInfoInterface
Definition: RegisterInfoInterface.h:21
RegisterContextCorePOSIX_powerpc::WriteGPR
bool WriteGPR() override
Definition: RegisterContextPOSIXCore_powerpc.cpp:50
RegisterContextCorePOSIX_powerpc::ReadRegister
bool ReadRegister(const lldb_private::RegisterInfo *reg_info, lldb_private::RegisterValue &value) override
Definition: RegisterContextPOSIXCore_powerpc.cpp:65
RegisterContextCorePOSIX_powerpc::HardwareSingleStep
bool HardwareSingleStep(bool enable) override
Definition: RegisterContextPOSIXCore_powerpc.cpp:109
lldb_private::RegisterInfoInterface::GetTargetArchitecture
const lldb_private::ArchSpec & GetTargetArchitecture() const
Definition: RegisterInfoInterface.h:40
RegisterContextPOSIX_powerpc::IsVMX
bool IsVMX(unsigned reg)
Definition: RegisterContextPOSIX_powerpc.cpp:87
lldb::offset_t
uint64_t offset_t
Definition: lldb-types.h:87
RegisterValue.h
lldb_private::ArchSpec::GetTriple
llvm::Triple & GetTriple()
Architecture triple accessor.
Definition: ArchSpec.h:444
lldb_private::DataExtractor::SetData
lldb::offset_t SetData(const void *bytes, lldb::offset_t length, lldb::ByteOrder byte_order)
Set data with a buffer that is caller owned.
Definition: DataExtractor.cpp:225
lldb_private::RegisterValue::SetBytes
void SetBytes(const void *bytes, size_t length, lldb::ByteOrder byte_order)
Definition: RegisterValue.cpp:752
RegisterContextCorePOSIX_powerpc::ReadFPR
bool ReadFPR() override
Definition: RegisterContextPOSIXCore_powerpc.cpp:46
RegisterContextCorePOSIX_powerpc::m_gpr_buffer
lldb::DataBufferSP m_gpr_buffer
Definition: RegisterContextPOSIXCore_powerpc.h:52
lldb_private::DataExtractor::SetByteOrder
void SetByteOrder(lldb::ByteOrder byte_order)
Set the byte_order value.
Definition: DataExtractor.h:920
RegisterContextCorePOSIX_powerpc::ReadGPR
bool ReadGPR() override
Definition: RegisterContextPOSIXCore_powerpc.cpp:44
lldb::eRegisterKindLLDB
@ eRegisterKindLLDB
lldb's internal register numbers
Definition: lldb-enumerations.h:234
lldb_private::DataExtractor
Definition: DataExtractor.h:48
RegisterContextCorePOSIX_powerpc::WriteFPR
bool WriteFPR() override
Definition: RegisterContextPOSIXCore_powerpc.cpp:55
lldb_private::Thread
Definition: Thread.h:62
lldb_private::PPC_VMX_Desc
constexpr RegsetDesc PPC_VMX_Desc[]
Definition: RegisterUtilities.h:126
lldb_private::DataExtractor::GetDataStart
const uint8_t * GetDataStart() const
Get the data start pointer.
Definition: DataExtractor.h:411
lldb_private::DataExtractor::GetByteOrder
lldb::ByteOrder GetByteOrder() const
Get the current byte order value.
Definition: DataExtractor.h:583
RegisterContextCorePOSIX_powerpc::RegisterContextCorePOSIX_powerpc
RegisterContextCorePOSIX_powerpc(lldb_private::Thread &thread, lldb_private::RegisterInfoInterface *register_info, const lldb_private::DataExtractor &gpregset, llvm::ArrayRef< lldb_private::CoreNote > notes)
Definition: RegisterContextPOSIXCore_powerpc.cpp:19
RegisterContextCorePOSIX_powerpc::m_gpr
lldb_private::DataExtractor m_gpr
Definition: RegisterContextPOSIXCore_powerpc.h:55
RegisterContextPOSIX_powerpc::IsFPR
bool IsFPR(unsigned reg)
Definition: RegisterContextPOSIX_powerpc.cpp:83
Thread.h
RegisterContextCorePOSIX_powerpc::m_fpr
lldb_private::DataExtractor m_fpr
Definition: RegisterContextPOSIXCore_powerpc.h:56
RegisterContextPOSIX_powerpc
Definition: RegisterContextPOSIX_powerpc.h:138
RegisterContextPOSIXCore_powerpc.h
lldb_private::getRegset
DataExtractor getRegset(llvm::ArrayRef< CoreNote > Notes, const llvm::Triple &Triple, llvm::ArrayRef< RegsetDesc > RegsetDescs)
Definition: RegisterUtilities.cpp:28
RegisterContextCorePOSIX_powerpc::WriteAllRegisterValues
bool WriteAllRegisterValues(const lldb::DataBufferSP &data_sp) override
Definition: RegisterContextPOSIXCore_powerpc.cpp:104
uint32_t
RegisterContextCorePOSIX_powerpc::ReadVMX
bool ReadVMX() override
Definition: RegisterContextPOSIXCore_powerpc.cpp:48
lldb_private::DataExtractor::GetMaxU64
uint64_t GetMaxU64(lldb::offset_t *offset_ptr, size_t byte_size) const
Extract an unsigned integer of size byte_size from *offset_ptr.
Definition: DataExtractor.cpp:526
RegisterContextCorePOSIX_powerpc::ReadAllRegisterValues
bool ReadAllRegisterValues(lldb::DataBufferSP &data_sp) override
Definition: RegisterContextPOSIXCore_powerpc.cpp:94
RegisterContextCorePOSIX_powerpc::~RegisterContextCorePOSIX_powerpc
~RegisterContextCorePOSIX_powerpc() override
lldb_private::DataExtractor::CopyData
lldb::offset_t CopyData(lldb::offset_t offset, lldb::offset_t length, void *dst) const
Copy length bytes from *offset, without swapping bytes.
Definition: DataExtractor.cpp:680
lldb_private
A class that represents a running process on the host machine.
Definition: SBCommandInterpreterRunOptions.h:16
RegisterContextCorePOSIX_powerpc::m_fpr_buffer
lldb::DataBufferSP m_fpr_buffer
Definition: RegisterContextPOSIXCore_powerpc.h:53
RegisterContextCorePOSIX_powerpc::WriteRegister
bool WriteRegister(const lldb_private::RegisterInfo *reg_info, const lldb_private::RegisterValue &value) override
Definition: RegisterContextPOSIXCore_powerpc.cpp:99
RegisterContextCorePOSIX_powerpc::m_vec
lldb_private::DataExtractor m_vec
Definition: RegisterContextPOSIXCore_powerpc.h:57
RegisterContextCorePOSIX_powerpc::m_vec_buffer
lldb::DataBufferSP m_vec_buffer
Definition: RegisterContextPOSIXCore_powerpc.h:54
lldb_private::DataExtractor::GetByteSize
uint64_t GetByteSize() const
Get the number of bytes contained in this object.
Definition: DataExtractor.h:259
DataBufferHeap.h