LLDB mainline
RegisterContextPOSIXCore_x86_64.cpp
Go to the documentation of this file.
1//===-- RegisterContextPOSIXCore_x86_64.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#include "lldb/Target/Thread.h"
13
14using namespace lldb_private;
15
17 Thread &thread, RegisterInfoInterface *register_info,
18 const DataExtractor &gpregset, llvm::ArrayRef<CoreNote> notes)
19 : RegisterContextPOSIX_x86(thread, 0, register_info) {
20 size_t size, len;
21
22 size = GetGPRSize();
23 m_gpregset.reset(new uint8_t[size]);
24 len =
25 gpregset.ExtractBytes(0, size, lldb::eByteOrderLittle, m_gpregset.get());
26 if (len != size)
27 m_gpregset.reset();
28
29 DataExtractor fpregset = getRegset(
30 notes, register_info->GetTargetArchitecture().GetTriple(), FPR_Desc);
31 size = sizeof(FXSAVE);
32 m_fpregset.reset(new uint8_t[size]);
33 len =
34 fpregset.ExtractBytes(0, size, lldb::eByteOrderLittle, m_fpregset.get());
35 if (len != size)
36 m_fpregset.reset();
37}
38
40 return m_gpregset != nullptr;
41}
42
44 return m_fpregset != nullptr;
45}
46
48 assert(0);
49 return false;
50}
51
53 assert(0);
54 return false;
55}
56
58 RegisterValue &value) {
59 const uint8_t *src;
60 size_t offset;
61 const size_t fxsave_offset = reg_info->byte_offset - GetFXSAVEOffset();
62 // make the offset relative to the beginning of the FXSAVE structure because
63 // this is the data that we have (not the entire UserArea)
64
65 if (m_gpregset && reg_info->byte_offset < GetGPRSize()) {
66 src = m_gpregset.get();
67 offset = reg_info->byte_offset;
68 } else if (m_fpregset && fxsave_offset < sizeof(FXSAVE)) {
69 src = m_fpregset.get();
70 offset = fxsave_offset;
71 } else {
72 return false;
73 }
74
76 value.SetFromMemoryData(*reg_info, src + offset, reg_info->byte_size,
78
79 return error.Success();
80}
81
84 return false;
85}
86
88 const RegisterInfo *reg_info, const RegisterValue &value) {
89 return false;
90}
91
93 const lldb::DataBufferSP &data_sp) {
94 return false;
95}
96
98 return false;
99}
static llvm::raw_ostream & error(Stream &strm)
bool ReadRegister(const lldb_private::RegisterInfo *reg_info, lldb_private::RegisterValue &value) override
bool ReadAllRegisterValues(lldb::WritableDataBufferSP &data_sp) override
RegisterContextCorePOSIX_x86_64(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
bool WriteAllRegisterValues(const lldb::DataBufferSP &data_sp) override
llvm::Triple & GetTriple()
Architecture triple accessor.
Definition: ArchSpec.h:450
An data extractor class.
Definition: DataExtractor.h:48
size_t ExtractBytes(lldb::offset_t offset, lldb::offset_t length, lldb::ByteOrder dst_byte_order, void *dst) const
Extract an arbitrary number of bytes in the specified byte order.
RegisterInfo interface to patch RegisterInfo structure for archs.
const lldb_private::ArchSpec & GetTargetArchitecture() const
uint32_t SetFromMemoryData(const RegisterInfo &reg_info, const void *src, uint32_t src_len, lldb::ByteOrder src_byte_order, Status &error)
An error handling class.
Definition: Status.h:44
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[]
@ eByteOrderLittle
std::shared_ptr< lldb_private::DataBuffer > DataBufferSP
Definition: lldb-forward.h:334
std::shared_ptr< lldb_private::WritableDataBuffer > WritableDataBufferSP
Definition: lldb-forward.h:335
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.