LLDB mainline
lldb_private::Arm64RegisterTypeDetector Class Reference

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

#include <RegisterTypeDetector_arm64.h>

Classes

class  DetectedTypesHolder
struct  RegisterEntry

Public Member Functions

void DetectTypes (uint64_t hwcap, uint64_t hwcap2, uint64_t hwcap3)
 For the registers listed in this class, detect which fields are present and build types for those.
void UpdateRegisterInfo (const RegisterInfo *reg_info, uint32_t num_regs)
 Add the type 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 DetectorFn

Private Member Functions

const RegisterTypeDetectCPSRType (uint64_t hwcap, uint64_t hwcap2, uint64_t hwcap3)
const RegisterTypeDetectFPSRType (uint64_t hwcap, uint64_t hwcap2, uint64_t hwcap3)
const RegisterTypeDetectFPCRType (uint64_t hwcap, uint64_t hwcap2, uint64_t hwcap3)
const RegisterTypeDetectMTECtrlType (uint64_t hwcap, uint64_t hwcap2, uint64_t hwcap3)
const RegisterTypeDetectSVCRType (uint64_t hwcap, uint64_t hwcap2, uint64_t hwcap3)
const RegisterTypeDetectFPMRType (uint64_t hwcap, uint64_t hwcap2, uint64_t hwcap3)
const RegisterTypeDetectGCSFeaturesType (uint64_t hwcap, uint64_t hwcap2, uint64_t hwcap3)
const RegisterTypeDetectPOREL0Type (uint64_t hwcap, uint64_t hwcap2, uint64_t hwcap3)
template<typename T, typename... Args>
const T * MakeType (Args &&...args)

Private Attributes

struct lldb_private::Arm64RegisterTypeDetector::RegisterEntry m_registers [8]
bool m_has_detected = false
class lldb_private::Arm64RegisterTypeDetector::DetectedTypesHolder m_detected_types

Detailed Description

This class manages the storage and detection of register type 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 DetectTypes.
  • Call UpdateRegisterInfo with your RegisterInfo to add pointers to the detected types 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 DetectTypes.

Definition at line 35 of file RegisterTypeDetector_arm64.h.

Member Typedef Documentation

◆ DetectorFn

Initial value:
const RegisterType *(
Arm64RegisterTypeDetector::*)(uint64_t, uint64_t, uint64_t)
This class manages the storage and detection of register type information.

Definition at line 57 of file RegisterTypeDetector_arm64.h.

Member Function Documentation

◆ DetectCPSRType()

const RegisterType * Arm64RegisterTypeDetector::DetectCPSRType ( uint64_t hwcap,
uint64_t hwcap2,
uint64_t hwcap3 )
private

Definition at line 238 of file RegisterTypeDetector_arm64.cpp.

References HWCAP2_BTI, HWCAP2_MTE, HWCAP_DIT, HWCAP_SSBS, and MakeType().

◆ DetectFPCRType()

const RegisterType * Arm64RegisterTypeDetector::DetectFPCRType ( uint64_t hwcap,
uint64_t hwcap2,
uint64_t hwcap3 )
private

◆ DetectFPMRType()

const RegisterType * Arm64RegisterTypeDetector::DetectFPMRType ( uint64_t hwcap,
uint64_t hwcap2,
uint64_t hwcap3 )
private

Definition at line 78 of file RegisterTypeDetector_arm64.cpp.

References HWCAP2_FPMR, and MakeType().

◆ DetectFPSRType()

const RegisterType * Arm64RegisterTypeDetector::DetectFPSRType ( uint64_t hwcap,
uint64_t hwcap2,
uint64_t hwcap3 )
private

Definition at line 214 of file RegisterTypeDetector_arm64.cpp.

References MakeType().

◆ DetectGCSFeaturesType()

const RegisterType * Arm64RegisterTypeDetector::DetectGCSFeaturesType ( uint64_t hwcap,
uint64_t hwcap2,
uint64_t hwcap3 )
private

Definition at line 105 of file RegisterTypeDetector_arm64.cpp.

References HWCAP_GCS, and MakeType().

◆ DetectMTECtrlType()

const RegisterType * Arm64RegisterTypeDetector::DetectMTECtrlType ( uint64_t hwcap,
uint64_t hwcap2,
uint64_t hwcap3 )
private

Definition at line 137 of file RegisterTypeDetector_arm64.cpp.

References HWCAP2_MTE, HWCAP3_MTE_STORE_ONLY, and MakeType().

◆ DetectPOREL0Type()

const RegisterType * Arm64RegisterTypeDetector::DetectPOREL0Type ( uint64_t hwcap,
uint64_t hwcap2,
uint64_t hwcap3 )
private

Definition at line 37 of file RegisterTypeDetector_arm64.cpp.

References HWCAP2_POE, and MakeType().

◆ DetectSVCRType()

const RegisterType * Arm64RegisterTypeDetector::DetectSVCRType ( uint64_t hwcap,
uint64_t hwcap2,
uint64_t hwcap3 )
private

Definition at line 119 of file RegisterTypeDetector_arm64.cpp.

References HWCAP2_SME, and MakeType().

◆ DetectTypes()

void Arm64RegisterTypeDetector::DetectTypes ( uint64_t hwcap,
uint64_t hwcap2,
uint64_t hwcap3 )

For the registers listed in this class, detect which fields are present and build types for those.

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, no type is produced.

Definition at line 290 of file RegisterTypeDetector_arm64.cpp.

References m_has_detected, and m_registers.

◆ HasDetected()

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

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

Definition at line 51 of file RegisterTypeDetector_arm64.h.

References m_has_detected.

◆ MakeType()

template<typename T, typename... Args>
const T * lldb_private::Arm64RegisterTypeDetector::MakeType ( Args &&... args)
inlineprivate

◆ UpdateRegisterInfo()

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

Add the type 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 297 of file RegisterTypeDetector_arm64.cpp.

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

Member Data Documentation

◆ m_detected_types

class lldb_private::Arm64RegisterTypeDetector::DetectedTypesHolder lldb_private::Arm64RegisterTypeDetector::m_detected_types
private

Referenced by MakeType().

◆ m_has_detected

bool lldb_private::Arm64RegisterTypeDetector::m_has_detected = false
private

Definition at line 101 of file RegisterTypeDetector_arm64.h.

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

◆ m_registers

struct lldb_private::Arm64RegisterTypeDetector::RegisterEntry lldb_private::Arm64RegisterTypeDetector::m_registers[8]
private
Initial value:
= {
RegisterEntry({"fpcr"}, &Arm64RegisterTypeDetector::DetectFPCRType),
RegisterEntry({"mte_ctrl"},
RegisterEntry({"gcs_features_enabled", "gcs_features_locked"},
}
const RegisterType * DetectPOREL0Type(uint64_t hwcap, uint64_t hwcap2, uint64_t hwcap3)
const RegisterType * DetectFPCRType(uint64_t hwcap, uint64_t hwcap2, uint64_t hwcap3)
const RegisterType * DetectFPMRType(uint64_t hwcap, uint64_t hwcap2, uint64_t hwcap3)
const RegisterType * DetectMTECtrlType(uint64_t hwcap, uint64_t hwcap2, uint64_t hwcap3)
const RegisterType * DetectGCSFeaturesType(uint64_t hwcap, uint64_t hwcap2, uint64_t hwcap3)
const RegisterType * DetectCPSRType(uint64_t hwcap, uint64_t hwcap2, uint64_t hwcap3)
const RegisterType * DetectFPSRType(uint64_t hwcap, uint64_t hwcap2, uint64_t hwcap3)
const RegisterType * DetectSVCRType(uint64_t hwcap, uint64_t hwcap2, uint64_t hwcap3)

Referenced by DetectTypes(), and UpdateRegisterInfo().


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