LLDB mainline
lldb_private::Arm64RegisterFlagsDetector Class Reference

This class manages the storage and detection of register field information. More...

#include <RegisterFlagsDetector_arm64.h>

Classes

struct  RegisterEntry

Public Member Functions

void DetectFields (uint64_t hwcap, uint64_t hwcap2, uint64_t hwcap3)
 For the registers listed in this class, detect which fields are present.
void UpdateRegisterInfo (const RegisterInfo *reg_info, uint32_t num_regs)
 Add the field information of any registers named in this class, to the relevant RegisterInfo instances.
bool HasDetected () const
 Returns true if field detection has been run at least once.

Private Types

using Fields = std::vector<RegisterFlags::Field>
using DetectorFn = std::function<Fields(uint64_t, uint64_t, uint64_t)>

Static Private Member Functions

static Fields DetectCPSRFields (uint64_t hwcap, uint64_t hwcap2, uint64_t hwcap3)
static Fields DetectFPSRFields (uint64_t hwcap, uint64_t hwcap2, uint64_t hwcap3)
static Fields DetectFPCRFields (uint64_t hwcap, uint64_t hwcap2, uint64_t hwcap3)
static Fields DetectMTECtrlFields (uint64_t hwcap, uint64_t hwcap2, uint64_t hwcap3)
static Fields DetectSVCRFields (uint64_t hwcap, uint64_t hwcap2, uint64_t hwcap3)
static Fields DetectFPMRFields (uint64_t hwcap, uint64_t hwcap2, uint64_t hwcap3)
static Fields DetectGCSFeatureFields (uint64_t hwcap, uint64_t hwcap2, uint64_t hwcap3)

Private Attributes

struct lldb_private::Arm64RegisterFlagsDetector::RegisterEntry m_registers [8]
bool m_has_detected = false

Detailed Description

This class manages the storage and detection of register field information.

The same register may have different fields on different CPUs. This class abstracts out the field detection process so we can use it on live processes and core files.

The way to use this class is:

  • Make an instance somewhere that will last as long as the debug session (because your final register info will point to this instance).
  • Read hardware capabilities from a core note, binary, prctl, etc.
  • Pass those to DetectFields.
  • Call UpdateRegisterInfo with your RegisterInfo to add pointers to the detected fields for all registers listed in this class.

This must be done in that order, and you should ensure that if multiple threads will reference the information, a mutex is used to make sure only one calls DetectFields.

Definition at line 36 of file RegisterFlagsDetector_arm64.h.

Member Typedef Documentation

◆ DetectorFn

using lldb_private::Arm64RegisterFlagsDetector::DetectorFn = std::function<Fields(uint64_t, uint64_t, uint64_t)>
private

Definition at line 56 of file RegisterFlagsDetector_arm64.h.

◆ Fields

Member Function Documentation

◆ DetectCPSRFields()

Arm64RegisterFlagsDetector::Fields Arm64RegisterFlagsDetector::DetectCPSRFields ( uint64_t hwcap,
uint64_t hwcap2,
uint64_t hwcap3 )
staticprivate

Definition at line 188 of file RegisterFlagsDetector_arm64.cpp.

References HWCAP2_BTI, HWCAP2_MTE, HWCAP_DIT, and HWCAP_SSBS.

◆ DetectFields()

void Arm64RegisterFlagsDetector::DetectFields ( uint64_t hwcap,
uint64_t hwcap2,
uint64_t hwcap3 )

For the registers listed in this class, detect which fields are present.

Must be called before UpdateRegisterInfos. If called more than once, fields will be redetected each time from scratch. If the target would not have this register at all, the list of fields will be left empty.

Definition at line 236 of file RegisterFlagsDetector_arm64.cpp.

References m_has_detected, and m_registers.

◆ DetectFPCRFields()

Arm64RegisterFlagsDetector::Fields Arm64RegisterFlagsDetector::DetectFPCRFields ( uint64_t hwcap,
uint64_t hwcap2,
uint64_t hwcap3 )
staticprivate

Definition at line 124 of file RegisterFlagsDetector_arm64.cpp.

References HWCAP2_AFP, HWCAP2_EBF16, HWCAP_ASIMDHP, and HWCAP_FPHP.

◆ DetectFPMRFields()

Arm64RegisterFlagsDetector::Fields Arm64RegisterFlagsDetector::DetectFPMRFields ( uint64_t hwcap,
uint64_t hwcap2,
uint64_t hwcap3 )
staticprivate

Definition at line 34 of file RegisterFlagsDetector_arm64.cpp.

References HWCAP2_FPMR.

◆ DetectFPSRFields()

Arm64RegisterFlagsDetector::Fields Arm64RegisterFlagsDetector::DetectFPSRFields ( uint64_t hwcap,
uint64_t hwcap2,
uint64_t hwcap3 )
staticprivate

Definition at line 166 of file RegisterFlagsDetector_arm64.cpp.

◆ DetectGCSFeatureFields()

Arm64RegisterFlagsDetector::Fields Arm64RegisterFlagsDetector::DetectGCSFeatureFields ( uint64_t hwcap,
uint64_t hwcap2,
uint64_t hwcap3 )
staticprivate

Definition at line 59 of file RegisterFlagsDetector_arm64.cpp.

References HWCAP_GCS.

◆ DetectMTECtrlFields()

Arm64RegisterFlagsDetector::Fields Arm64RegisterFlagsDetector::DetectMTECtrlFields ( uint64_t hwcap,
uint64_t hwcap2,
uint64_t hwcap3 )
staticprivate

Definition at line 94 of file RegisterFlagsDetector_arm64.cpp.

References HWCAP2_MTE, and HWCAP3_MTE_STORE_ONLY.

◆ DetectSVCRFields()

Arm64RegisterFlagsDetector::Fields Arm64RegisterFlagsDetector::DetectSVCRFields ( uint64_t hwcap,
uint64_t hwcap2,
uint64_t hwcap3 )
staticprivate

Definition at line 76 of file RegisterFlagsDetector_arm64.cpp.

References HWCAP2_SME.

◆ HasDetected()

bool lldb_private::Arm64RegisterFlagsDetector::HasDetected ( ) const
inline

Returns true if field detection has been run at least once.

Definition at line 52 of file RegisterFlagsDetector_arm64.h.

References m_has_detected.

◆ UpdateRegisterInfo()

void Arm64RegisterFlagsDetector::UpdateRegisterInfo ( const RegisterInfo * reg_info,
uint32_t num_regs )

Add the field information of any registers named in this class, to the relevant RegisterInfo instances.

Note that this will be done with a pointer to the instance of this class that you call this on, so the lifetime of that instance must be at least that of the register info.

Definition at line 243 of file RegisterFlagsDetector_arm64.cpp.

References lldb_private::RegisterInfo::flags_type, m_has_detected, and m_registers.

Member Data Documentation

◆ m_has_detected

bool lldb_private::Arm64RegisterFlagsDetector::m_has_detected = false
private

Definition at line 93 of file RegisterFlagsDetector_arm64.h.

Referenced by DetectFields(), HasDetected(), and UpdateRegisterInfo().

◆ m_registers

struct lldb_private::Arm64RegisterFlagsDetector::RegisterEntry lldb_private::Arm64RegisterFlagsDetector::m_registers[8]
private
Initial value:
= {
RegisterEntry("gcs_features_enabled", 8, DetectGCSFeatureFields),
RegisterEntry("gcs_features_locked", 8, DetectGCSFeatureFields),
}
static Fields DetectFPCRFields(uint64_t hwcap, uint64_t hwcap2, uint64_t hwcap3)
static Fields DetectSVCRFields(uint64_t hwcap, uint64_t hwcap2, uint64_t hwcap3)
static Fields DetectFPMRFields(uint64_t hwcap, uint64_t hwcap2, uint64_t hwcap3)
static Fields DetectFPSRFields(uint64_t hwcap, uint64_t hwcap2, uint64_t hwcap3)
static Fields DetectMTECtrlFields(uint64_t hwcap, uint64_t hwcap2, uint64_t hwcap3)
static Fields DetectGCSFeatureFields(uint64_t hwcap, uint64_t hwcap2, uint64_t hwcap3)
static Fields DetectCPSRFields(uint64_t hwcap, uint64_t hwcap2, uint64_t hwcap3)

Referenced by DetectFields(), and UpdateRegisterInfo().


The documentation for this class was generated from the following files: