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 
14 using 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 
57 bool RegisterContextCorePOSIX_x86_64::ReadRegister(const RegisterInfo *reg_info,
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 
75  Status error;
76  value.SetFromMemoryData(reg_info, src + offset, reg_info->byte_size,
78 
79  return error.Success();
80 }
81 
83  lldb::DataBufferSP &data_sp) {
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 }
RegisterContextCorePOSIX_x86_64::WriteFPR
bool WriteFPR() override
Definition: RegisterContextPOSIXCore_x86_64.cpp:52
RegisterContextCorePOSIX_x86_64::m_fpregset
std::unique_ptr< uint8_t[]> m_fpregset
Definition: RegisterContextPOSIXCore_x86_64.h:46
RegisterContextCorePOSIX_x86_64::WriteAllRegisterValues
bool WriteAllRegisterValues(const lldb::DataBufferSP &data_sp) override
Definition: RegisterContextPOSIXCore_x86_64.cpp:92
lldb_private::RegisterValue
Definition: RegisterValue.h:28
RegisterContextCorePOSIX_x86_64::WriteGPR
bool WriteGPR() override
Definition: RegisterContextPOSIXCore_x86_64.cpp:47
lldb_private::FPR_Desc
constexpr RegsetDesc FPR_Desc[]
Definition: RegisterUtilities.h:102
lldb_private::RegisterInfoInterface
Definition: RegisterInfoInterface.h:21
lldb_private::RegisterInfoInterface::GetTargetArchitecture
const lldb_private::ArchSpec & GetTargetArchitecture() const
Definition: RegisterInfoInterface.h:40
RegisterValue.h
RegisterContextCorePOSIX_x86_64::HardwareSingleStep
bool HardwareSingleStep(bool enable) override
Definition: RegisterContextPOSIXCore_x86_64.cpp:97
lldb_private::ArchSpec::GetTriple
llvm::Triple & GetTriple()
Architecture triple accessor.
Definition: ArchSpec.h:444
lldb_private::DataExtractor::ExtractBytes
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.
Definition: DataExtractor.cpp:661
error
static llvm::raw_ostream & error(Stream &strm)
Definition: CommandReturnObject.cpp:17
RegisterContextCorePOSIX_x86_64::ReadRegister
bool ReadRegister(const lldb_private::RegisterInfo *reg_info, lldb_private::RegisterValue &value) override
Definition: RegisterContextPOSIXCore_x86_64.cpp:57
RegisterContextCorePOSIX_x86_64::ReadFPR
bool ReadFPR() override
Definition: RegisterContextPOSIXCore_x86_64.cpp:43
lldb_private::DataExtractor
Definition: DataExtractor.h:48
lldb_private::Thread
Definition: Thread.h:60
lldb_private::FXSAVE
Definition: RegisterContext_x86.h:266
RegisterContextCorePOSIX_x86_64::RegisterContextCorePOSIX_x86_64
RegisterContextCorePOSIX_x86_64(lldb_private::Thread &thread, lldb_private::RegisterInfoInterface *register_info, const lldb_private::DataExtractor &gpregset, llvm::ArrayRef< lldb_private::CoreNote > notes)
Definition: RegisterContextPOSIXCore_x86_64.cpp:16
RegisterContextCorePOSIX_x86_64::m_gpregset
std::unique_ptr< uint8_t[]> m_gpregset
Definition: RegisterContextPOSIXCore_x86_64.h:45
RegisterContextCorePOSIX_x86_64::ReadAllRegisterValues
bool ReadAllRegisterValues(lldb::DataBufferSP &data_sp) override
Definition: RegisterContextPOSIXCore_x86_64.cpp:82
Thread.h
RegisterContextCorePOSIX_x86_64::ReadGPR
bool ReadGPR() override
Definition: RegisterContextPOSIXCore_x86_64.cpp:39
RegisterContextPOSIXCore_x86_64.h
lldb_private::getRegset
DataExtractor getRegset(llvm::ArrayRef< CoreNote > Notes, const llvm::Triple &Triple, llvm::ArrayRef< RegsetDesc > RegsetDescs)
Definition: RegisterUtilities.cpp:28
RegisterContextPOSIX_x86::GetGPRSize
virtual size_t GetGPRSize()
Definition: RegisterContextPOSIX_x86.cpp:485
lldb_private::RegisterValue::SetFromMemoryData
uint32_t SetFromMemoryData(const RegisterInfo *reg_info, const void *src, uint32_t src_len, lldb::ByteOrder src_byte_order, Status &error)
Definition: RegisterValue.cpp:84
lldb_private::Status
Definition: Status.h:44
DataExtractor.h
RegisterContextCorePOSIX_x86_64::WriteRegister
bool WriteRegister(const lldb_private::RegisterInfo *reg_info, const lldb_private::RegisterValue &value) override
Definition: RegisterContextPOSIXCore_x86_64.cpp:87
lldb_private
A class that represents a running process on the host machine.
Definition: SBCommandInterpreterRunOptions.h:16
RegisterContextPOSIX_x86
Definition: RegisterContextPOSIX_x86.h:18
lldb::eByteOrderLittle
@ eByteOrderLittle
Definition: lldb-enumerations.h:142
RegisterContextPOSIX_x86::GetFXSAVEOffset
virtual size_t GetFXSAVEOffset()
Definition: RegisterContextPOSIX_x86.cpp:489