LLDB mainline
NativeRegisterContextFreeBSD_x86.h
Go to the documentation of this file.
1//===-- NativeRegisterContextFreeBSD_x86_64.h -------------------*- C++ -*-===//
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
9#if defined(__i386__) || defined(__x86_64__)
10
11#ifndef lldb_NativeRegisterContextFreeBSD_x86_64_h
12#define lldb_NativeRegisterContextFreeBSD_x86_64_h
13
14// clang-format off
15#include <sys/param.h>
16#include <sys/ptrace.h>
17#include <sys/types.h>
18#include <machine/reg.h>
19// clang-format on
20
21#include <array>
22#include <optional>
23
28
29#define LLDB_INVALID_XSAVE_OFFSET UINT32_MAX
30
31namespace lldb_private {
32namespace process_freebsd {
33
35
36class NativeRegisterContextFreeBSD_x86 : public NativeRegisterContextFreeBSD,
37 public NativeRegisterContextDBReg_x86 {
38public:
39 NativeRegisterContextFreeBSD_x86(const ArchSpec &target_arch,
40 NativeThreadFreeBSD &native_thread);
41 uint32_t GetRegisterSetCount() const override;
42
43 const RegisterSet *GetRegisterSet(uint32_t set_index) const override;
44
45 Status ReadRegister(const RegisterInfo *reg_info,
46 RegisterValue &reg_value) override;
47
48 Status WriteRegister(const RegisterInfo *reg_info,
49 const RegisterValue &reg_value) override;
50
51 Status ReadAllRegisterValues(lldb::WritableDataBufferSP &data_sp) override;
52
53 Status WriteAllRegisterValues(const lldb::DataBufferSP &data_sp) override;
54
55 llvm::Error
56 CopyHardwareWatchpointsFrom(NativeRegisterContextFreeBSD &source) override;
57
58private:
59 // Private member types.
60 enum RegSetKind {
61 GPRegSet,
62 FPRegSet,
63 DBRegSet,
64 YMMRegSet,
65 MPXRegSet,
66 MaxRegSet = MPXRegSet,
67 };
68
69 // Private member variables.
70 std::array<uint8_t, sizeof(struct reg)> m_gpr;
71 std::array<uint8_t, 512> m_fpr; // FXSAVE
72 std::array<uint8_t, sizeof(struct dbreg)> m_dbr;
73 std::vector<uint8_t> m_xsave;
74 std::array<uint32_t, MaxRegSet + 1> m_xsave_offsets;
75 std::array<size_t, MaxRegSet + 1> m_regset_offsets;
76
77 std::optional<RegSetKind> GetSetForNativeRegNum(uint32_t reg_num) const;
78
79 Status ReadRegisterSet(RegSetKind set);
80 Status WriteRegisterSet(RegSetKind set);
81
82 uint8_t *GetOffsetRegSetData(RegSetKind set, size_t reg_offset);
83
84 struct YMMSplitPtr {
85 void *xmm;
86 void *ymm_hi;
87 };
88 std::optional<YMMSplitPtr> GetYMMSplitReg(uint32_t reg);
89};
90
91} // namespace process_freebsd
92} // namespace lldb_private
93
94#endif // #ifndef lldb_NativeRegisterContextFreeBSD_x86_64_h
95
96#endif // defined(__i386__) || defined(__x86_64__)
Manages communication with the inferior (debugee) process.
A class that represents a running process on the host machine.
std::shared_ptr< lldb_private::DataBuffer > DataBufferSP
std::shared_ptr< lldb_private::WritableDataBuffer > WritableDataBufferSP