120 lines · c
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-exception6//7//===----------------------------------------------------------------------===//8 9#if defined(__loongarch__) && __loongarch_grlen == 6410 11#ifndef lldb_NativeRegisterContextLinux_loongarch64_h12#define lldb_NativeRegisterContextLinux_loongarch64_h13 14#include "Plugins/Process/Linux/NativeRegisterContextLinux.h"15#include "Plugins/Process/Utility/NativeRegisterContextDBReg_loongarch.h"16#include "Plugins/Process/Utility/RegisterInfoPOSIX_loongarch64.h"17 18#include <asm/ptrace.h>19 20namespace lldb_private {21namespace process_linux {22 23class NativeProcessLinux;24 25class NativeRegisterContextLinux_loongarch6426 : public NativeRegisterContextLinux,27 public NativeRegisterContextDBReg_loongarch {28public:29 NativeRegisterContextLinux_loongarch64(30 const ArchSpec &target_arch, NativeThreadProtocol &native_thread,31 std::unique_ptr<RegisterInfoPOSIX_loongarch64> register_info_up);32 33 uint32_t GetRegisterSetCount() const override;34 35 uint32_t GetUserRegisterCount() const override;36 37 const RegisterSet *GetRegisterSet(uint32_t set_index) const override;38 39 Status ReadRegister(const RegisterInfo *reg_info,40 RegisterValue ®_value) override;41 42 Status WriteRegister(const RegisterInfo *reg_info,43 const RegisterValue ®_value) override;44 45 Status ReadAllRegisterValues(lldb::WritableDataBufferSP &data_sp) override;46 47 Status WriteAllRegisterValues(const lldb::DataBufferSP &data_sp) override;48 49 void InvalidateAllRegisters() override;50 51 std::vector<uint32_t>52 GetExpeditedRegisters(ExpeditedRegs expType) const override;53 54 bool RegisterOffsetIsDynamic() const override { return true; }55 56protected:57 Status ReadGPR() override;58 59 Status WriteGPR() override;60 61 Status ReadFPR() override;62 63 Status WriteFPR() override;64 65 Status ReadLSX();66 67 Status WriteLSX();68 69 Status ReadLASX();70 71 Status WriteLASX();72 73 void *GetGPRBuffer() override { return &m_gpr; }74 75 void *GetFPRBuffer() override { return &m_fpr; }76 77 size_t GetGPRSize() const override { return GetRegisterInfo().GetGPRSize(); }78 79 size_t GetFPRSize() override { return GetRegisterInfo().GetFPRSize(); }80 81private:82 bool m_gpr_is_valid;83 bool m_fpu_is_valid;84 bool m_lsx_is_valid;85 bool m_lasx_is_valid;86 bool m_refresh_hwdebug_info;87 88 RegisterInfoPOSIX_loongarch64::GPR m_gpr;89 RegisterInfoPOSIX_loongarch64::FPR m_fpr;90 RegisterInfoPOSIX_loongarch64::LSX m_lsx;91 RegisterInfoPOSIX_loongarch64::LASX m_lasx;92 93 bool IsGPR(unsigned reg) const;94 95 bool IsFPR(unsigned reg) const;96 97 bool IsLSX(unsigned reg) const;98 99 bool IsLASX(unsigned reg) const;100 101 uint32_t CalculateFprOffset(const RegisterInfo *reg_info) const;102 103 uint32_t CalculateLsxOffset(const RegisterInfo *reg_info) const;104 105 uint32_t CalculateLasxOffset(const RegisterInfo *reg_info) const;106 107 const RegisterInfoPOSIX_loongarch64 &GetRegisterInfo() const;108 109 llvm::Error ReadHardwareDebugInfo() override;110 111 llvm::Error WriteHardwareDebugRegs(DREGType hwbType) override;112};113 114} // namespace process_linux115} // namespace lldb_private116 117#endif // #ifndef lldb_NativeRegisterContextLinux_loongarch64_h118 119#endif // defined(__loongarch__) && __loongarch_grlen == 64120