2015-03-13 11:36:47 +00:00
|
|
|
//===-- NativeRegisterContextLinux_arm64.h ---------------------*- C++ -*-===//
|
|
|
|
|
//
|
2019-01-19 08:50:56 +00:00
|
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
|
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
|
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
2015-03-13 11:36:47 +00:00
|
|
|
//
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
2015-05-26 11:58:52 +00:00
|
|
|
#if defined(__arm64__) || defined(__aarch64__)
|
2015-03-13 11:36:47 +00:00
|
|
|
|
|
|
|
|
#ifndef lldb_NativeRegisterContextLinux_arm64_h
|
|
|
|
|
#define lldb_NativeRegisterContextLinux_arm64_h
|
|
|
|
|
|
2015-05-26 11:58:52 +00:00
|
|
|
#include "Plugins/Process/Linux/NativeRegisterContextLinux.h"
|
2020-07-07 20:24:14 +05:00
|
|
|
#include "Plugins/Process/Utility/RegisterInfoPOSIX_arm64.h"
|
2015-03-13 11:36:47 +00:00
|
|
|
|
2020-08-19 12:38:30 +05:00
|
|
|
#include <asm/ptrace.h>
|
|
|
|
|
|
2015-03-31 09:52:22 +00:00
|
|
|
namespace lldb_private {
|
|
|
|
|
namespace process_linux {
|
|
|
|
|
|
2015-03-13 11:36:47 +00:00
|
|
|
class NativeProcessLinux;
|
|
|
|
|
|
2015-05-26 11:58:52 +00:00
|
|
|
class NativeRegisterContextLinux_arm64 : public NativeRegisterContextLinux {
|
2015-03-13 11:36:47 +00:00
|
|
|
public:
|
2015-05-26 11:58:52 +00:00
|
|
|
NativeRegisterContextLinux_arm64(const ArchSpec &target_arch,
|
Clean up NativeRegisterContext
Summary:
This commit removes the concrete_frame_idx member from
NativeRegisterContext and related functions, which was always set to
zero and never used.
I also change the native thread class to store a NativeRegisterContext
as a unique_ptr (documenting the ownership) and make sure it is always
initialized (most of the code was already blindly dereferencing the
register context pointer, assuming it would always be present -- this
makes its treatment consistent).
Reviewers: eugene, clayborg, krytarowski
Subscribers: aemerson, sdardis, nemanjai, javed.absar, arichardson, kristof.beyls, kbarton, uweigand, alexandreyy, lldb-commits
Differential Revision: https://reviews.llvm.org/D39837
llvm-svn: 317881
2017-11-10 11:05:49 +00:00
|
|
|
NativeThreadProtocol &native_thread);
|
2015-03-13 11:36:47 +00:00
|
|
|
|
|
|
|
|
uint32_t GetRegisterSetCount() const override;
|
|
|
|
|
|
2015-07-03 11:17:07 +00:00
|
|
|
uint32_t GetUserRegisterCount() const override;
|
|
|
|
|
|
2015-03-13 11:36:47 +00:00
|
|
|
const RegisterSet *GetRegisterSet(uint32_t set_index) const override;
|
|
|
|
|
|
2017-05-12 04:51:55 +00:00
|
|
|
Status ReadRegister(const RegisterInfo *reg_info,
|
|
|
|
|
RegisterValue ®_value) override;
|
2015-03-13 11:36:47 +00:00
|
|
|
|
2017-05-12 04:51:55 +00:00
|
|
|
Status WriteRegister(const RegisterInfo *reg_info,
|
|
|
|
|
const RegisterValue ®_value) override;
|
2015-03-13 11:36:47 +00:00
|
|
|
|
2017-05-12 04:51:55 +00:00
|
|
|
Status ReadAllRegisterValues(lldb::DataBufferSP &data_sp) override;
|
2015-03-13 11:36:47 +00:00
|
|
|
|
2017-05-12 04:51:55 +00:00
|
|
|
Status WriteAllRegisterValues(const lldb::DataBufferSP &data_sp) override;
|
2015-03-13 11:36:47 +00:00
|
|
|
|
2019-12-06 22:12:39 +05:00
|
|
|
void InvalidateAllRegisters() override;
|
|
|
|
|
|
2020-11-26 12:55:29 +05:00
|
|
|
std::vector<uint32_t>
|
|
|
|
|
GetExpeditedRegisters(ExpeditedRegs expType) const override;
|
|
|
|
|
|
2020-12-02 03:09:14 +05:00
|
|
|
bool RegisterOffsetIsDynamic() const override { return true; }
|
|
|
|
|
|
2018-05-29 09:10:46 +00:00
|
|
|
// Hardware breakpoints/watchpoint management functions
|
2015-05-15 06:29:58 +00:00
|
|
|
|
2017-02-24 13:27:31 +00:00
|
|
|
uint32_t NumSupportedHardwareBreakpoints() override;
|
|
|
|
|
|
2015-05-15 06:29:58 +00:00
|
|
|
uint32_t SetHardwareBreakpoint(lldb::addr_t addr, size_t size) override;
|
|
|
|
|
|
|
|
|
|
bool ClearHardwareBreakpoint(uint32_t hw_idx) override;
|
|
|
|
|
|
2017-05-12 04:51:55 +00:00
|
|
|
Status ClearAllHardwareBreakpoints() override;
|
2017-02-24 13:27:31 +00:00
|
|
|
|
2017-05-12 04:51:55 +00:00
|
|
|
Status GetHardwareBreakHitIndex(uint32_t &bp_index,
|
|
|
|
|
lldb::addr_t trap_addr) override;
|
2017-02-24 13:27:31 +00:00
|
|
|
|
2015-05-15 06:29:58 +00:00
|
|
|
uint32_t NumSupportedHardwareWatchpoints() override;
|
|
|
|
|
|
|
|
|
|
uint32_t SetHardwareWatchpoint(lldb::addr_t addr, size_t size,
|
|
|
|
|
uint32_t watch_flags) override;
|
|
|
|
|
|
|
|
|
|
bool ClearHardwareWatchpoint(uint32_t hw_index) override;
|
|
|
|
|
|
2017-05-12 04:51:55 +00:00
|
|
|
Status ClearAllHardwareWatchpoints() override;
|
2015-05-15 06:29:58 +00:00
|
|
|
|
2017-05-12 04:51:55 +00:00
|
|
|
Status GetWatchpointHitIndex(uint32_t &wp_index,
|
|
|
|
|
lldb::addr_t trap_addr) override;
|
2015-05-15 06:29:58 +00:00
|
|
|
|
2016-06-16 16:41:22 +00:00
|
|
|
lldb::addr_t GetWatchpointHitAddress(uint32_t wp_index) override;
|
|
|
|
|
|
2015-05-15 06:29:58 +00:00
|
|
|
lldb::addr_t GetWatchpointAddress(uint32_t wp_index) override;
|
|
|
|
|
|
|
|
|
|
uint32_t GetWatchpointSize(uint32_t wp_index);
|
|
|
|
|
|
|
|
|
|
bool WatchpointIsEnabled(uint32_t wp_index);
|
|
|
|
|
|
2015-08-12 13:42:24 +00:00
|
|
|
// Debug register type select
|
|
|
|
|
enum DREGType { eDREGTypeWATCH = 0, eDREGTypeBREAK };
|
|
|
|
|
|
2015-05-26 11:58:52 +00:00
|
|
|
protected:
|
|
|
|
|
|
NativeProcessLinux: Remove some register context boilerplate
Summary:
This patch follows the spirit of D63594, and removes some null checks
for things which should be operating invariants. Specifically
{Read,Write}[GF]PR now no longer check whether the supplied buffers are
null, because they never are. After this, the Do*** versions of these
function no longer serve any purpose and are inlined into their callers.
Other cleanups are possible here too, but I am taking this one step at a
time because this involves a lot of architecture-specific code, which I
don't have the hardware to test on (I did do a build-test though).
Reviewers: mgorny, jankratochvil, omjavaid, alexandreyy, uweigand
Subscribers: nemanjai, javed.absar, kbarton, lldb-commits
Differential Revision: https://reviews.llvm.org/D66744
llvm-svn: 370653
2019-09-02 12:50:18 +00:00
|
|
|
Status ReadGPR() override;
|
2015-05-26 11:58:52 +00:00
|
|
|
|
NativeProcessLinux: Remove some register context boilerplate
Summary:
This patch follows the spirit of D63594, and removes some null checks
for things which should be operating invariants. Specifically
{Read,Write}[GF]PR now no longer check whether the supplied buffers are
null, because they never are. After this, the Do*** versions of these
function no longer serve any purpose and are inlined into their callers.
Other cleanups are possible here too, but I am taking this one step at a
time because this involves a lot of architecture-specific code, which I
don't have the hardware to test on (I did do a build-test though).
Reviewers: mgorny, jankratochvil, omjavaid, alexandreyy, uweigand
Subscribers: nemanjai, javed.absar, kbarton, lldb-commits
Differential Revision: https://reviews.llvm.org/D66744
llvm-svn: 370653
2019-09-02 12:50:18 +00:00
|
|
|
Status WriteGPR() override;
|
2015-05-26 11:58:52 +00:00
|
|
|
|
NativeProcessLinux: Remove some register context boilerplate
Summary:
This patch follows the spirit of D63594, and removes some null checks
for things which should be operating invariants. Specifically
{Read,Write}[GF]PR now no longer check whether the supplied buffers are
null, because they never are. After this, the Do*** versions of these
function no longer serve any purpose and are inlined into their callers.
Other cleanups are possible here too, but I am taking this one step at a
time because this involves a lot of architecture-specific code, which I
don't have the hardware to test on (I did do a build-test though).
Reviewers: mgorny, jankratochvil, omjavaid, alexandreyy, uweigand
Subscribers: nemanjai, javed.absar, kbarton, lldb-commits
Differential Revision: https://reviews.llvm.org/D66744
llvm-svn: 370653
2019-09-02 12:50:18 +00:00
|
|
|
Status ReadFPR() override;
|
2015-05-26 11:58:52 +00:00
|
|
|
|
NativeProcessLinux: Remove some register context boilerplate
Summary:
This patch follows the spirit of D63594, and removes some null checks
for things which should be operating invariants. Specifically
{Read,Write}[GF]PR now no longer check whether the supplied buffers are
null, because they never are. After this, the Do*** versions of these
function no longer serve any purpose and are inlined into their callers.
Other cleanups are possible here too, but I am taking this one step at a
time because this involves a lot of architecture-specific code, which I
don't have the hardware to test on (I did do a build-test though).
Reviewers: mgorny, jankratochvil, omjavaid, alexandreyy, uweigand
Subscribers: nemanjai, javed.absar, kbarton, lldb-commits
Differential Revision: https://reviews.llvm.org/D66744
llvm-svn: 370653
2019-09-02 12:50:18 +00:00
|
|
|
Status WriteFPR() override;
|
2015-05-26 11:58:52 +00:00
|
|
|
|
|
|
|
|
void *GetGPRBuffer() override { return &m_gpr_arm64; }
|
|
|
|
|
|
2020-12-02 03:09:14 +05:00
|
|
|
// GetGPRBufferSize returns sizeof arm64 GPR ptrace buffer, it is different
|
|
|
|
|
// from GetGPRSize which returns sizeof RegisterInfoPOSIX_arm64::GPR.
|
|
|
|
|
size_t GetGPRBufferSize() { return sizeof(m_gpr_arm64); }
|
|
|
|
|
|
2015-05-26 11:58:52 +00:00
|
|
|
void *GetFPRBuffer() override { return &m_fpr; }
|
|
|
|
|
|
|
|
|
|
size_t GetFPRSize() override { return sizeof(m_fpr); }
|
|
|
|
|
|
2015-03-13 11:36:47 +00:00
|
|
|
private:
|
2019-12-06 22:12:39 +05:00
|
|
|
bool m_gpr_is_valid;
|
|
|
|
|
bool m_fpu_is_valid;
|
2020-08-19 12:38:30 +05:00
|
|
|
bool m_sve_buffer_is_valid;
|
|
|
|
|
|
|
|
|
|
bool m_sve_header_is_valid;
|
2019-12-06 22:12:39 +05:00
|
|
|
|
2020-12-02 03:09:14 +05:00
|
|
|
struct user_pt_regs m_gpr_arm64; // 64-bit general purpose registers.
|
2015-03-13 11:36:47 +00:00
|
|
|
|
2020-07-07 20:24:14 +05:00
|
|
|
RegisterInfoPOSIX_arm64::FPU
|
|
|
|
|
m_fpr; // floating-point registers including extended register sets.
|
2020-08-19 12:38:30 +05:00
|
|
|
|
|
|
|
|
SVEState m_sve_state;
|
|
|
|
|
struct user_sve_header m_sve_header;
|
|
|
|
|
std::vector<uint8_t> m_sve_ptrace_payload;
|
|
|
|
|
|
2015-05-15 06:29:58 +00:00
|
|
|
// Debug register info for hardware breakpoints and watchpoints management.
|
|
|
|
|
struct DREG {
|
|
|
|
|
lldb::addr_t address; // Breakpoint/watchpoint address value.
|
2016-06-16 16:41:22 +00:00
|
|
|
lldb::addr_t hit_addr; // Address at which last watchpoint trigger exception
|
|
|
|
|
// occurred.
|
|
|
|
|
lldb::addr_t real_addr; // Address value that should cause target to stop.
|
2015-05-15 06:29:58 +00:00
|
|
|
uint32_t control; // Breakpoint/watchpoint control value.
|
2018-05-29 09:10:46 +00:00
|
|
|
uint32_t refcount; // Serves as enable/disable and reference counter.
|
2015-05-15 06:29:58 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct DREG m_hbr_regs[16]; // Arm native linux hardware breakpoints
|
|
|
|
|
struct DREG m_hwp_regs[16]; // Arm native linux hardware watchpoints
|
|
|
|
|
|
|
|
|
|
uint32_t m_max_hwp_supported;
|
|
|
|
|
uint32_t m_max_hbp_supported;
|
|
|
|
|
bool m_refresh_hwdebug_info;
|
|
|
|
|
|
2015-03-13 11:36:47 +00:00
|
|
|
bool IsGPR(unsigned reg) const;
|
|
|
|
|
|
|
|
|
|
bool IsFPR(unsigned reg) const;
|
|
|
|
|
|
2020-08-19 12:38:30 +05:00
|
|
|
Status ReadAllSVE();
|
|
|
|
|
|
|
|
|
|
Status WriteAllSVE();
|
|
|
|
|
|
|
|
|
|
Status ReadSVEHeader();
|
|
|
|
|
|
|
|
|
|
Status WriteSVEHeader();
|
|
|
|
|
|
|
|
|
|
bool IsSVE(unsigned reg) const;
|
|
|
|
|
|
|
|
|
|
uint64_t GetSVERegVG() { return m_sve_header.vl / 8; }
|
|
|
|
|
|
|
|
|
|
void SetSVERegVG(uint64_t vg) { m_sve_header.vl = vg * 8; }
|
|
|
|
|
|
|
|
|
|
void *GetSVEHeader() { return &m_sve_header; }
|
|
|
|
|
|
|
|
|
|
void *GetSVEBuffer();
|
|
|
|
|
|
|
|
|
|
size_t GetSVEHeaderSize() { return sizeof(m_sve_header); }
|
|
|
|
|
|
|
|
|
|
size_t GetSVEBufferSize() { return m_sve_ptrace_payload.size(); }
|
|
|
|
|
|
2017-05-12 04:51:55 +00:00
|
|
|
Status ReadHardwareDebugInfo();
|
2015-03-13 11:36:47 +00:00
|
|
|
|
2017-05-12 04:51:55 +00:00
|
|
|
Status WriteHardwareDebugRegs(int hwbType);
|
2015-09-07 10:11:23 +00:00
|
|
|
|
|
|
|
|
uint32_t CalculateFprOffset(const RegisterInfo *reg_info) const;
|
2020-07-07 20:24:14 +05:00
|
|
|
|
|
|
|
|
RegisterInfoPOSIX_arm64 &GetRegisterInfo() const;
|
2020-08-19 12:38:30 +05:00
|
|
|
|
|
|
|
|
void ConfigureRegisterContext();
|
|
|
|
|
|
|
|
|
|
uint32_t CalculateSVEOffset(const RegisterInfo *reg_info) const;
|
2015-03-13 11:36:47 +00:00
|
|
|
};
|
2015-03-31 09:52:22 +00:00
|
|
|
|
|
|
|
|
} // namespace process_linux
|
|
|
|
|
} // namespace lldb_private
|
2015-03-13 11:36:47 +00:00
|
|
|
|
|
|
|
|
#endif // #ifndef lldb_NativeRegisterContextLinux_arm64_h
|
|
|
|
|
|
2015-05-26 11:58:52 +00:00
|
|
|
#endif // defined (__arm64__) || defined (__aarch64__)
|