xref: /openbsd-src/gnu/llvm/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_loongarch64.h (revision f6aab3d83b51b91c24247ad2c2573574de475a82)
1 //===-- NativeRegisterContextLinux_loongarch64.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(__loongarch__) && __loongarch_grlen == 64
10 
11 #ifndef lldb_NativeRegisterContextLinux_loongarch64_h
12 #define lldb_NativeRegisterContextLinux_loongarch64_h
13 
14 #include "Plugins/Process/Linux/NativeRegisterContextLinux.h"
15 #include "Plugins/Process/Utility/RegisterInfoPOSIX_loongarch64.h"
16 
17 #include <asm/ptrace.h>
18 
19 namespace lldb_private {
20 namespace process_linux {
21 
22 class NativeProcessLinux;
23 
24 class NativeRegisterContextLinux_loongarch64
25     : public NativeRegisterContextLinux {
26 public:
27   NativeRegisterContextLinux_loongarch64(
28       const ArchSpec &target_arch, NativeThreadProtocol &native_thread,
29       std::unique_ptr<RegisterInfoPOSIX_loongarch64> register_info_up);
30 
31   uint32_t GetRegisterSetCount() const override;
32 
33   uint32_t GetUserRegisterCount() const override;
34 
35   const RegisterSet *GetRegisterSet(uint32_t set_index) const override;
36 
37   Status ReadRegister(const RegisterInfo *reg_info,
38                       RegisterValue &reg_value) override;
39 
40   Status WriteRegister(const RegisterInfo *reg_info,
41                        const RegisterValue &reg_value) override;
42 
43   Status ReadAllRegisterValues(lldb::WritableDataBufferSP &data_sp) override;
44 
45   Status WriteAllRegisterValues(const lldb::DataBufferSP &data_sp) override;
46 
47   void InvalidateAllRegisters() override;
48 
49   std::vector<uint32_t>
50   GetExpeditedRegisters(ExpeditedRegs expType) const override;
51 
RegisterOffsetIsDynamic()52   bool RegisterOffsetIsDynamic() const override { return true; }
53 
54 protected:
55   Status ReadGPR() override;
56 
57   Status WriteGPR() override;
58 
59   Status ReadFPR() override;
60 
61   Status WriteFPR() override;
62 
GetGPRBuffer()63   void *GetGPRBuffer() override { return &m_gpr; }
64 
GetFPRBuffer()65   void *GetFPRBuffer() override { return &m_fpr; }
66 
GetGPRSize()67   size_t GetGPRSize() const override { return GetRegisterInfo().GetGPRSize(); }
68 
GetFPRSize()69   size_t GetFPRSize() override { return GetRegisterInfo().GetFPRSize(); }
70 
71 private:
72   bool m_gpr_is_valid;
73   bool m_fpu_is_valid;
74 
75   RegisterInfoPOSIX_loongarch64::GPR m_gpr;
76 
77   RegisterInfoPOSIX_loongarch64::FPR m_fpr;
78 
79   bool IsGPR(unsigned reg) const;
80 
81   bool IsFPR(unsigned reg) const;
82 
83   uint32_t CalculateFprOffset(const RegisterInfo *reg_info) const;
84 
85   const RegisterInfoPOSIX_loongarch64 &GetRegisterInfo() const;
86 };
87 
88 } // namespace process_linux
89 } // namespace lldb_private
90 
91 #endif // #ifndef lldb_NativeRegisterContextLinux_loongarch64_h
92 
93 #endif // defined(__loongarch__) && __loongarch_grlen == 64
94