LLDB  mainline
RegisterContextPOSIXCore_ppc64le.cpp
Go to the documentation of this file.
1 //===-- RegisterContextPOSIXCore_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 
10 
11 #include "lldb/Target/Thread.h"
14 
17 
18 #include <memory>
19 
20 using namespace lldb_private;
21 
23  Thread &thread, RegisterInfoInterface *register_info,
24  const DataExtractor &gpregset, llvm::ArrayRef<CoreNote> notes)
25  : RegisterContextPOSIX_ppc64le(thread, 0, register_info) {
26  m_gpr_buffer = std::make_shared<DataBufferHeap>(gpregset.GetDataStart(),
27  gpregset.GetByteSize());
29  m_gpr.SetByteOrder(gpregset.GetByteOrder());
30 
31  ArchSpec arch = register_info->GetTargetArchitecture();
32  DataExtractor fpregset = getRegset(notes, arch.GetTriple(), FPR_Desc);
33  m_fpr_buffer = std::make_shared<DataBufferHeap>(fpregset.GetDataStart(),
34  fpregset.GetByteSize());
36  m_fpr.SetByteOrder(fpregset.GetByteOrder());
37 
38  DataExtractor vmxregset = getRegset(notes, arch.GetTriple(), PPC_VMX_Desc);
39  m_vmx_buffer = std::make_shared<DataBufferHeap>(vmxregset.GetDataStart(),
40  vmxregset.GetByteSize());
42  m_vmx.SetByteOrder(vmxregset.GetByteOrder());
43 
44  DataExtractor vsxregset = getRegset(notes, arch.GetTriple(), PPC_VSX_Desc);
45  m_vsx_buffer = std::make_shared<DataBufferHeap>(vsxregset.GetDataStart(),
46  vsxregset.GetByteSize());
48  m_vsx.SetByteOrder(vsxregset.GetByteOrder());
49 }
50 
52  return k_num_fpr_registers_ppc64le * sizeof(uint64_t);
53 }
54 
56  return (k_num_vmx_registers_ppc64le - 1) * sizeof(uint64_t) * 2 +
57  sizeof(uint32_t);
58 }
59 
61  return k_num_vsx_registers_ppc64le * sizeof(uint64_t) * 2;
62 }
63 
65  const RegisterInfo *reg_info, RegisterValue &value) {
66  lldb::offset_t offset = reg_info->byte_offset;
67 
68  if (IsFPR(reg_info->kinds[lldb::eRegisterKindLLDB])) {
69  uint64_t v;
70  offset -= GetGPRSize();
71  offset = m_fpr.CopyData(offset, reg_info->byte_size, &v);
72 
73  if (offset == reg_info->byte_size) {
74  value.SetBytes(&v, reg_info->byte_size, m_fpr.GetByteOrder());
75  return true;
76  }
77  } else if (IsVMX(reg_info->kinds[lldb::eRegisterKindLLDB])) {
78  uint32_t v[4];
79  offset -= GetGPRSize() + GetFPRSize();
80  offset = m_vmx.CopyData(offset, reg_info->byte_size, &v);
81 
82  if (offset == reg_info->byte_size) {
83  value.SetBytes(v, reg_info->byte_size, m_vmx.GetByteOrder());
84  return true;
85  }
86  } else if (IsVSX(reg_info->kinds[lldb::eRegisterKindLLDB])) {
87  uint32_t v[4];
88  lldb::offset_t tmp_offset;
89  offset -= GetGPRSize() + GetFPRSize() + GetVMXSize();
90 
91  if (offset < GetVSXSize() / 2) {
92  tmp_offset = m_vsx.CopyData(offset / 2, reg_info->byte_size / 2, &v);
93 
94  if (tmp_offset != reg_info->byte_size / 2) {
95  return false;
96  }
97 
98  uint8_t *dst = (uint8_t *)&v + sizeof(uint64_t);
99  tmp_offset = m_fpr.CopyData(offset / 2, reg_info->byte_size / 2, dst);
100 
101  if (tmp_offset != reg_info->byte_size / 2) {
102  return false;
103  }
104 
105  value.SetBytes(&v, reg_info->byte_size, m_vsx.GetByteOrder());
106  return true;
107  } else {
108  offset =
109  m_vmx.CopyData(offset - GetVSXSize() / 2, reg_info->byte_size, &v);
110  if (offset == reg_info->byte_size) {
111  value.SetBytes(v, reg_info->byte_size, m_vmx.GetByteOrder());
112  return true;
113  }
114  }
115  } else {
116  uint64_t v = m_gpr.GetMaxU64(&offset, reg_info->byte_size);
117 
118  if (offset == reg_info->byte_offset + reg_info->byte_size) {
119  if (reg_info->byte_size < sizeof(v))
120  value = (uint32_t)v;
121  else
122  value = v;
123  return true;
124  }
125  }
126 
127  return false;
128 }
129 
131  const RegisterInfo *reg_info, const RegisterValue &value) {
132  return false;
133 }
k_num_vmx_registers_ppc64le
@ k_num_vmx_registers_ppc64le
Definition: lldb-ppc64le-register-enums.h:203
lldb_private::ArchSpec
Definition: ArchSpec.h:33
RegisterContextCorePOSIX_ppc64le::m_fpr_buffer
lldb::DataBufferSP m_fpr_buffer
Definition: RegisterContextPOSIXCore_ppc64le.h:39
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_ppc64le::WriteRegister
bool WriteRegister(const lldb_private::RegisterInfo *reg_info, const lldb_private::RegisterValue &value) override
Definition: RegisterContextPOSIXCore_ppc64le.cpp:130
RegisterUtilities.h
RegisterContextCorePOSIX_ppc64le::m_gpr
lldb_private::DataExtractor m_gpr
Definition: RegisterContextPOSIXCore_ppc64le.h:42
lldb_private::RegisterInfoInterface::GetTargetArchitecture
const lldb_private::ArchSpec & GetTargetArchitecture() const
Definition: RegisterInfoInterface.h:40
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
k_num_vsx_registers_ppc64le
@ k_num_vsx_registers_ppc64le
Definition: lldb-ppc64le-register-enums.h:204
RegisterContextCorePOSIX_ppc64le::m_fpr
lldb_private::DataExtractor m_fpr
Definition: RegisterContextPOSIXCore_ppc64le.h:43
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
RegisterContextPOSIX_ppc64le::GetGPRSize
virtual size_t GetGPRSize()
Definition: RegisterContextPOSIX_ppc64le.cpp:138
RegisterContextPOSIX_ppc64le
Definition: RegisterContextPOSIX_ppc64le.h:18
lldb_private::DataExtractor::SetByteOrder
void SetByteOrder(lldb::ByteOrder byte_order)
Set the byte_order value.
Definition: DataExtractor.h:931
RegisterContextCorePOSIX_ppc64le::m_vmx_buffer
lldb::DataBufferSP m_vmx_buffer
Definition: RegisterContextPOSIXCore_ppc64le.h:40
lldb::eRegisterKindLLDB
@ eRegisterKindLLDB
lldb's internal register numbers
Definition: lldb-enumerations.h:234
RegisterContextPOSIX_ppc64le::IsVSX
bool IsVSX(unsigned reg)
Definition: RegisterContextPOSIX_ppc64le.cpp:110
lldb_private::DataExtractor
Definition: DataExtractor.h:48
RegisterContextCorePOSIX_ppc64le::ReadRegister
bool ReadRegister(const lldb_private::RegisterInfo *reg_info, lldb_private::RegisterValue &value) override
Definition: RegisterContextPOSIXCore_ppc64le.cpp:64
lldb_private::Thread
Definition: Thread.h:60
lldb_private::PPC_VMX_Desc
constexpr RegsetDesc PPC_VMX_Desc[]
Definition: RegisterUtilities.h:126
RegisterContextCorePOSIX_ppc64le::RegisterContextCorePOSIX_ppc64le
RegisterContextCorePOSIX_ppc64le(lldb_private::Thread &thread, lldb_private::RegisterInfoInterface *register_info, const lldb_private::DataExtractor &gpregset, llvm::ArrayRef< lldb_private::CoreNote > notes)
Definition: RegisterContextPOSIXCore_ppc64le.cpp:22
RegisterContextCorePOSIX_ppc64le::m_gpr_buffer
lldb::DataBufferSP m_gpr_buffer
Definition: RegisterContextPOSIXCore_ppc64le.h:38
lldb_private::DataExtractor::GetDataStart
const uint8_t * GetDataStart() const
Get the data start pointer.
Definition: DataExtractor.h:422
lldb_private::DataExtractor::GetByteOrder
lldb::ByteOrder GetByteOrder() const
Get the current byte order value.
Definition: DataExtractor.h:594
RegisterContextCorePOSIX_ppc64le::m_vsx
lldb_private::DataExtractor m_vsx
Definition: RegisterContextPOSIXCore_ppc64le.h:45
Thread.h
RegisterContextPOSIX_ppc64le::IsVMX
bool IsVMX(unsigned reg)
Definition: RegisterContextPOSIX_ppc64le.cpp:106
RegisterContextCorePOSIX_ppc64le::GetVMXSize
size_t GetVMXSize() const
Definition: RegisterContextPOSIXCore_ppc64le.cpp:55
lldb_private::getRegset
DataExtractor getRegset(llvm::ArrayRef< CoreNote > Notes, const llvm::Triple &Triple, llvm::ArrayRef< RegsetDesc > RegsetDescs)
Definition: RegisterUtilities.cpp:28
lldb-ppc64le-register-enums.h
uint32_t
RegisterContextCorePOSIX_ppc64le::m_vmx
lldb_private::DataExtractor m_vmx
Definition: RegisterContextPOSIXCore_ppc64le.h:44
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_ppc64le::GetFPRSize
size_t GetFPRSize() const
Definition: RegisterContextPOSIXCore_ppc64le.cpp:51
RegisterContextPOSIX_ppc64le::IsFPR
bool IsFPR(unsigned reg)
Definition: RegisterContextPOSIX_ppc64le.cpp:102
k_num_fpr_registers_ppc64le
@ k_num_fpr_registers_ppc64le
Definition: lldb-ppc64le-register-enums.h:202
RegisterContextCorePOSIX_ppc64le::m_vsx_buffer
lldb::DataBufferSP m_vsx_buffer
Definition: RegisterContextPOSIXCore_ppc64le.h:41
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_ppc64le::GetVSXSize
size_t GetVSXSize() const
Definition: RegisterContextPOSIXCore_ppc64le.cpp:60
RegisterContextPOSIXCore_ppc64le.h
lldb_private::PPC_VSX_Desc
constexpr RegsetDesc PPC_VSX_Desc[]
Definition: RegisterUtilities.h:131
lldb_private::DataExtractor::GetByteSize
uint64_t GetByteSize() const
Get the number of bytes contained in this object.
Definition: DataExtractor.h:270
DataBufferHeap.h