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
20using 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());
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());
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}
bool ReadRegister(const lldb_private::RegisterInfo *reg_info, lldb_private::RegisterValue &value) override
RegisterContextCorePOSIX_ppc64le(lldb_private::Thread &thread, lldb_private::RegisterInfoInterface *register_info, const lldb_private::DataExtractor &gpregset, llvm::ArrayRef< lldb_private::CoreNote > notes)
bool WriteRegister(const lldb_private::RegisterInfo *reg_info, const lldb_private::RegisterValue &value) override
An architecture specification class.
Definition: ArchSpec.h:31
llvm::Triple & GetTriple()
Architecture triple accessor.
Definition: ArchSpec.h:450
An data extractor class.
Definition: DataExtractor.h:48
lldb::offset_t CopyData(lldb::offset_t offset, lldb::offset_t length, void *dst) const
Copy length bytes from *offset, without swapping bytes.
void SetByteOrder(lldb::ByteOrder byte_order)
Set the byte_order value.
uint64_t GetByteSize() const
Get the number of bytes contained in this object.
const uint8_t * GetDataStart() const
Get the data start pointer.
lldb::offset_t SetData(const void *bytes, lldb::offset_t length, lldb::ByteOrder byte_order)
Set data with a buffer that is caller owned.
uint64_t GetMaxU64(lldb::offset_t *offset_ptr, size_t byte_size) const
Extract an unsigned integer of size byte_size from *offset_ptr.
lldb::ByteOrder GetByteOrder() const
Get the current byte order value.
RegisterInfo interface to patch RegisterInfo structure for archs.
const lldb_private::ArchSpec & GetTargetArchitecture() const
void SetBytes(const void *bytes, size_t length, lldb::ByteOrder byte_order)
@ k_num_vsx_registers_ppc64le
@ k_num_vmx_registers_ppc64le
@ k_num_fpr_registers_ppc64le
A class that represents a running process on the host machine.
DataExtractor getRegset(llvm::ArrayRef< CoreNote > Notes, const llvm::Triple &Triple, llvm::ArrayRef< RegsetDesc > RegsetDescs)
constexpr RegsetDesc FPR_Desc[]
constexpr RegsetDesc PPC_VSX_Desc[]
constexpr RegsetDesc PPC_VMX_Desc[]
uint64_t offset_t
Definition: lldb-types.h:85
@ eRegisterKindLLDB
lldb's internal register numbers
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.
uint32_t kinds[lldb::kNumRegisterKinds]
Holds all of the various register numbers for all register kinds.