forked from OSchip/llvm-project
[lldb] Delete register info definitions in the x86_64 ABI classes
Summary: These definitions are used to "augment" information received from the remote target with eh/debug frame and "generic" register numbers. Besides being verbose, this information was also incomplete (new registers like xmm16-31 were missing) and sometimes even downright wrong (ymm register numbers). Most of this information is available via llvm's MCRegisterInfo. This patch creates a new class, MCBasedABI, which retrieves the eh and debug frame register numbers this way. The tricky part here is that the llvm class uses all-caps register names, whereas lldb register are lowercase, and sometimes called slightly differently. Therefore this class introduces some hooks to allow a subclass to customize the MC lookup. The subclass also needs to suply the "generic" register numbers, as this is an lldb invention. This patch ports the x86_64 ABI classes to use the new register info mechanism. It also creates a new "ABIx86_64" class which can be used to house code common to x86_64 both ABIs. Right now, this just consists of a single function, but there are plenty of other things that could be moved here too. Reviewers: JDevlieghere, jasonmolenda Subscribers: mgorny, lldb-commits Tags: #lldb Differential Revision: https://reviews.llvm.org/D74244
This commit is contained in:
parent
801627ee49
commit
07355c1c08
|
@ -163,6 +163,28 @@ protected:
|
|||
virtual const RegisterInfo *GetRegisterInfoArray(uint32_t &count) = 0;
|
||||
};
|
||||
|
||||
class MCBasedABI : public ABI {
|
||||
public:
|
||||
void AugmentRegisterInfo(RegisterInfo &info) override;
|
||||
|
||||
/// If the register name is of the form "<from_prefix>[<number>]" then change
|
||||
/// the name to "<to_prefix>[<number>]". Otherwise, leave the name unchanged.
|
||||
static void MapRegisterName(std::string ®, llvm::StringRef from_prefix,
|
||||
llvm::StringRef to_prefix);
|
||||
protected:
|
||||
using ABI::ABI;
|
||||
|
||||
/// Return eh_frame and dwarf numbers for the given register.
|
||||
virtual std::pair<uint32_t, uint32_t> GetEHAndDWARFNums(llvm::StringRef reg);
|
||||
|
||||
/// Return the generic number of the given register.
|
||||
virtual uint32_t GetGenericNum(llvm::StringRef reg) = 0;
|
||||
|
||||
/// For the given (capitalized) lldb register name, return the name of this
|
||||
/// register in the MCRegisterInfo struct.
|
||||
virtual std::string GetMCName(std::string reg) { return reg; }
|
||||
};
|
||||
|
||||
} // namespace lldb_private
|
||||
|
||||
#endif // liblldb_ABI_h_
|
||||
|
|
|
@ -55,162 +55,8 @@ enum dwarf_regnums {
|
|||
dwarf_r14,
|
||||
dwarf_r15,
|
||||
dwarf_rip,
|
||||
dwarf_xmm0,
|
||||
dwarf_xmm1,
|
||||
dwarf_xmm2,
|
||||
dwarf_xmm3,
|
||||
dwarf_xmm4,
|
||||
dwarf_xmm5,
|
||||
dwarf_xmm6,
|
||||
dwarf_xmm7,
|
||||
dwarf_xmm8,
|
||||
dwarf_xmm9,
|
||||
dwarf_xmm10,
|
||||
dwarf_xmm11,
|
||||
dwarf_xmm12,
|
||||
dwarf_xmm13,
|
||||
dwarf_xmm14,
|
||||
dwarf_xmm15,
|
||||
dwarf_stmm0,
|
||||
dwarf_stmm1,
|
||||
dwarf_stmm2,
|
||||
dwarf_stmm3,
|
||||
dwarf_stmm4,
|
||||
dwarf_stmm5,
|
||||
dwarf_stmm6,
|
||||
dwarf_stmm7,
|
||||
dwarf_ymm0,
|
||||
dwarf_ymm1,
|
||||
dwarf_ymm2,
|
||||
dwarf_ymm3,
|
||||
dwarf_ymm4,
|
||||
dwarf_ymm5,
|
||||
dwarf_ymm6,
|
||||
dwarf_ymm7,
|
||||
dwarf_ymm8,
|
||||
dwarf_ymm9,
|
||||
dwarf_ymm10,
|
||||
dwarf_ymm11,
|
||||
dwarf_ymm12,
|
||||
dwarf_ymm13,
|
||||
dwarf_ymm14,
|
||||
dwarf_ymm15,
|
||||
dwarf_bnd0 = 126,
|
||||
dwarf_bnd1,
|
||||
dwarf_bnd2,
|
||||
dwarf_bnd3
|
||||
};
|
||||
|
||||
static RegisterInfo g_register_infos[] = {
|
||||
// clang-format off
|
||||
// NAME ALT SZ OFF ENCODING FORMAT EH_FRAME DWARF GENERIC LLDB NATIVE
|
||||
// ======== ======= == === ============= =================== ======================= ===================== =========================== ===================== ======================
|
||||
{"rax", nullptr, 8, 0, eEncodingUint, eFormatHex, {dwarf_rax, dwarf_rax, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
|
||||
{"rbx", nullptr, 8, 0, eEncodingUint, eFormatHex, {dwarf_rbx, dwarf_rbx, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
|
||||
{"rcx", "arg4", 8, 0, eEncodingUint, eFormatHex, {dwarf_rcx, dwarf_rcx, LLDB_REGNUM_GENERIC_ARG4, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
|
||||
{"rdx", "arg3", 8, 0, eEncodingUint, eFormatHex, {dwarf_rdx, dwarf_rdx, LLDB_REGNUM_GENERIC_ARG3, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
|
||||
{"rsi", "arg2", 8, 0, eEncodingUint, eFormatHex, {dwarf_rsi, dwarf_rsi, LLDB_REGNUM_GENERIC_ARG2, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
|
||||
{"rdi", "arg1", 8, 0, eEncodingUint, eFormatHex, {dwarf_rdi, dwarf_rdi, LLDB_REGNUM_GENERIC_ARG1, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
|
||||
{"rbp", "fp", 8, 0, eEncodingUint, eFormatHex, {dwarf_rbp, dwarf_rbp, LLDB_REGNUM_GENERIC_FP, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
|
||||
{"rsp", "sp", 8, 0, eEncodingUint, eFormatHex, {dwarf_rsp, dwarf_rsp, LLDB_REGNUM_GENERIC_SP, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
|
||||
{"r8", "arg5", 8, 0, eEncodingUint, eFormatHex, {dwarf_r8, dwarf_r8, LLDB_REGNUM_GENERIC_ARG5, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
|
||||
{"r9", "arg6", 8, 0, eEncodingUint, eFormatHex, {dwarf_r9, dwarf_r9, LLDB_REGNUM_GENERIC_ARG6, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
|
||||
{"r10", nullptr, 8, 0, eEncodingUint, eFormatHex, {dwarf_r10, dwarf_r10, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
|
||||
{"r11", nullptr, 8, 0, eEncodingUint, eFormatHex, {dwarf_r11, dwarf_r11, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
|
||||
{"r12", nullptr, 8, 0, eEncodingUint, eFormatHex, {dwarf_r12, dwarf_r12, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
|
||||
{"r13", nullptr, 8, 0, eEncodingUint, eFormatHex, {dwarf_r13, dwarf_r13, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
|
||||
{"r14", nullptr, 8, 0, eEncodingUint, eFormatHex, {dwarf_r14, dwarf_r14, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
|
||||
{"r15", nullptr, 8, 0, eEncodingUint, eFormatHex, {dwarf_r15, dwarf_r15, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
|
||||
{"rip", "pc", 8, 0, eEncodingUint, eFormatHex, {dwarf_rip, dwarf_rip, LLDB_REGNUM_GENERIC_PC, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
|
||||
{"rflags", nullptr, 4, 0, eEncodingUint, eFormatHex, {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_REGNUM_GENERIC_FLAGS, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
|
||||
{"cs", nullptr, 4, 0, eEncodingUint, eFormatHex, {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
|
||||
{"ss", nullptr, 4, 0, eEncodingUint, eFormatHex, {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
|
||||
{"ds", nullptr, 4, 0, eEncodingUint, eFormatHex, {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
|
||||
{"es", nullptr, 4, 0, eEncodingUint, eFormatHex, {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
|
||||
{"fs", nullptr, 4, 0, eEncodingUint, eFormatHex, {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
|
||||
{"gs", nullptr, 4, 0, eEncodingUint, eFormatHex, {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
|
||||
{"stmm0", nullptr, 10, 0, eEncodingVector, eFormatVectorOfUInt8, {dwarf_stmm0, dwarf_stmm0, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
|
||||
{"stmm1", nullptr, 10, 0, eEncodingVector, eFormatVectorOfUInt8, {dwarf_stmm1, dwarf_stmm1, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
|
||||
{"stmm2", nullptr, 10, 0, eEncodingVector, eFormatVectorOfUInt8, {dwarf_stmm2, dwarf_stmm2, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
|
||||
{"stmm3", nullptr, 10, 0, eEncodingVector, eFormatVectorOfUInt8, {dwarf_stmm3, dwarf_stmm3, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
|
||||
{"stmm4", nullptr, 10, 0, eEncodingVector, eFormatVectorOfUInt8, {dwarf_stmm4, dwarf_stmm4, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
|
||||
{"stmm5", nullptr, 10, 0, eEncodingVector, eFormatVectorOfUInt8, {dwarf_stmm5, dwarf_stmm5, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
|
||||
{"stmm6", nullptr, 10, 0, eEncodingVector, eFormatVectorOfUInt8, {dwarf_stmm6, dwarf_stmm6, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
|
||||
{"stmm7", nullptr, 10, 0, eEncodingVector, eFormatVectorOfUInt8, {dwarf_stmm7, dwarf_stmm7, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
|
||||
{"fctrl", nullptr, 4, 0, eEncodingUint, eFormatHex, {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
|
||||
{"fstat", nullptr, 4, 0, eEncodingUint, eFormatHex, {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
|
||||
{"ftag", nullptr, 4, 0, eEncodingUint, eFormatHex, {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
|
||||
{"fiseg", nullptr, 4, 0, eEncodingUint, eFormatHex, {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
|
||||
{"fioff", nullptr, 4, 0, eEncodingUint, eFormatHex, {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
|
||||
{"foseg", nullptr, 4, 0, eEncodingUint, eFormatHex, {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
|
||||
{"fooff", nullptr, 4, 0, eEncodingUint, eFormatHex, {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
|
||||
{"fop", nullptr, 4, 0, eEncodingUint, eFormatHex, {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
|
||||
{"xmm0", nullptr, 16, 0, eEncodingVector, eFormatVectorOfUInt8, {dwarf_xmm0, dwarf_xmm0, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
|
||||
{"xmm1", nullptr, 16, 0, eEncodingVector, eFormatVectorOfUInt8, {dwarf_xmm1, dwarf_xmm1, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
|
||||
{"xmm2", nullptr, 16, 0, eEncodingVector, eFormatVectorOfUInt8, {dwarf_xmm2, dwarf_xmm2, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
|
||||
{"xmm3", nullptr, 16, 0, eEncodingVector, eFormatVectorOfUInt8, {dwarf_xmm3, dwarf_xmm3, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
|
||||
{"xmm4", nullptr, 16, 0, eEncodingVector, eFormatVectorOfUInt8, {dwarf_xmm4, dwarf_xmm4, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
|
||||
{"xmm5", nullptr, 16, 0, eEncodingVector, eFormatVectorOfUInt8, {dwarf_xmm5, dwarf_xmm5, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
|
||||
{"xmm6", nullptr, 16, 0, eEncodingVector, eFormatVectorOfUInt8, {dwarf_xmm6, dwarf_xmm6, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
|
||||
{"xmm7", nullptr, 16, 0, eEncodingVector, eFormatVectorOfUInt8, {dwarf_xmm7, dwarf_xmm7, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
|
||||
{"xmm8", nullptr, 16, 0, eEncodingVector, eFormatVectorOfUInt8, {dwarf_xmm8, dwarf_xmm8, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
|
||||
{"xmm9", nullptr, 16, 0, eEncodingVector, eFormatVectorOfUInt8, {dwarf_xmm9, dwarf_xmm9, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
|
||||
{"xmm10", nullptr, 16, 0, eEncodingVector, eFormatVectorOfUInt8, {dwarf_xmm10, dwarf_xmm10, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
|
||||
{"xmm11", nullptr, 16, 0, eEncodingVector, eFormatVectorOfUInt8, {dwarf_xmm11, dwarf_xmm11, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
|
||||
{"xmm12", nullptr, 16, 0, eEncodingVector, eFormatVectorOfUInt8, {dwarf_xmm12, dwarf_xmm12, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
|
||||
{"xmm13", nullptr, 16, 0, eEncodingVector, eFormatVectorOfUInt8, {dwarf_xmm13, dwarf_xmm13, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
|
||||
{"xmm14", nullptr, 16, 0, eEncodingVector, eFormatVectorOfUInt8, {dwarf_xmm14, dwarf_xmm14, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
|
||||
{"xmm15", nullptr, 16, 0, eEncodingVector, eFormatVectorOfUInt8, {dwarf_xmm15, dwarf_xmm15, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
|
||||
{"mxcsr", nullptr, 4, 0, eEncodingUint, eFormatHex, {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
|
||||
{"ymm0", nullptr, 32, 0, eEncodingVector, eFormatVectorOfUInt8, {dwarf_ymm0, dwarf_ymm0, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
|
||||
{"ymm1", nullptr, 32, 0, eEncodingVector, eFormatVectorOfUInt8, {dwarf_ymm1, dwarf_ymm1, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
|
||||
{"ymm2", nullptr, 32, 0, eEncodingVector, eFormatVectorOfUInt8, {dwarf_ymm2, dwarf_ymm2, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
|
||||
{"ymm3", nullptr, 32, 0, eEncodingVector, eFormatVectorOfUInt8, {dwarf_ymm3, dwarf_ymm3, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
|
||||
{"ymm4", nullptr, 32, 0, eEncodingVector, eFormatVectorOfUInt8, {dwarf_ymm4, dwarf_ymm4, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
|
||||
{"ymm5", nullptr, 32, 0, eEncodingVector, eFormatVectorOfUInt8, {dwarf_ymm5, dwarf_ymm5, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
|
||||
{"ymm6", nullptr, 32, 0, eEncodingVector, eFormatVectorOfUInt8, {dwarf_ymm6, dwarf_ymm6, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
|
||||
{"ymm7", nullptr, 32, 0, eEncodingVector, eFormatVectorOfUInt8, {dwarf_ymm7, dwarf_ymm7, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
|
||||
{"ymm8", nullptr, 32, 0, eEncodingVector, eFormatVectorOfUInt8, {dwarf_ymm8, dwarf_ymm8, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
|
||||
{"ymm9", nullptr, 32, 0, eEncodingVector, eFormatVectorOfUInt8, {dwarf_ymm9, dwarf_ymm9, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
|
||||
{"ymm10", nullptr, 32, 0, eEncodingVector, eFormatVectorOfUInt8, {dwarf_ymm10, dwarf_ymm10, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
|
||||
{"ymm11", nullptr, 32, 0, eEncodingVector, eFormatVectorOfUInt8, {dwarf_ymm11, dwarf_ymm11, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
|
||||
{"ymm12", nullptr, 32, 0, eEncodingVector, eFormatVectorOfUInt8, {dwarf_ymm12, dwarf_ymm12, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
|
||||
{"ymm13", nullptr, 32, 0, eEncodingVector, eFormatVectorOfUInt8, {dwarf_ymm13, dwarf_ymm13, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
|
||||
{"ymm14", nullptr, 32, 0, eEncodingVector, eFormatVectorOfUInt8, {dwarf_ymm14, dwarf_ymm14, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
|
||||
{"ymm15", nullptr, 32, 0, eEncodingVector, eFormatVectorOfUInt8, {dwarf_ymm15, dwarf_ymm15, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
|
||||
{"bnd0", nullptr, 16, 0, eEncodingVector, eFormatVectorOfUInt64, {dwarf_bnd0, dwarf_bnd0, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
|
||||
{"bnd1", nullptr, 16, 0, eEncodingVector, eFormatVectorOfUInt64, {dwarf_bnd1, dwarf_bnd1, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
|
||||
{"bnd2", nullptr, 16, 0, eEncodingVector, eFormatVectorOfUInt64, {dwarf_bnd2, dwarf_bnd2, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
|
||||
{"bnd3", nullptr, 16, 0, eEncodingVector, eFormatVectorOfUInt64, {dwarf_bnd3, dwarf_bnd3, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
|
||||
{"bndcfgu", nullptr, 8, 0, eEncodingVector, eFormatVectorOfUInt8, {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
|
||||
{"bndstatus",nullptr, 8, 0, eEncodingVector, eFormatVectorOfUInt8, {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
|
||||
// clang-format on
|
||||
};
|
||||
|
||||
static const uint32_t k_num_register_infos =
|
||||
llvm::array_lengthof(g_register_infos);
|
||||
static bool g_register_info_names_constified = false;
|
||||
|
||||
const lldb_private::RegisterInfo *
|
||||
ABISysV_x86_64::GetRegisterInfoArray(uint32_t &count) {
|
||||
// Make the C-string names and alt_names for the register infos into const
|
||||
// C-string values by having the ConstString unique the names in the global
|
||||
// constant C-string pool.
|
||||
if (!g_register_info_names_constified) {
|
||||
g_register_info_names_constified = true;
|
||||
for (uint32_t i = 0; i < k_num_register_infos; ++i) {
|
||||
if (g_register_infos[i].name)
|
||||
g_register_infos[i].name =
|
||||
ConstString(g_register_infos[i].name).GetCString();
|
||||
if (g_register_infos[i].alt_name)
|
||||
g_register_infos[i].alt_name =
|
||||
ConstString(g_register_infos[i].alt_name).GetCString();
|
||||
}
|
||||
}
|
||||
count = k_num_register_infos;
|
||||
return g_register_infos;
|
||||
}
|
||||
|
||||
bool ABISysV_x86_64::GetPointerReturnRegister(const char *&name) {
|
||||
name = "rax";
|
||||
return true;
|
||||
|
@ -1080,6 +926,21 @@ bool ABISysV_x86_64::RegisterIsCalleeSaved(const RegisterInfo *reg_info) {
|
|||
return IsCalleeSaved;
|
||||
}
|
||||
|
||||
uint32_t ABISysV_x86_64::GetGenericNum(llvm::StringRef name) {
|
||||
return llvm::StringSwitch<uint32_t>(name)
|
||||
.Case("rip", LLDB_REGNUM_GENERIC_PC)
|
||||
.Case("rsp", LLDB_REGNUM_GENERIC_SP)
|
||||
.Case("rbp", LLDB_REGNUM_GENERIC_FP)
|
||||
.Case("rflags", LLDB_REGNUM_GENERIC_FLAGS)
|
||||
.Case("rdi", LLDB_REGNUM_GENERIC_ARG1)
|
||||
.Case("rsi", LLDB_REGNUM_GENERIC_ARG2)
|
||||
.Case("rdx", LLDB_REGNUM_GENERIC_ARG3)
|
||||
.Case("rcx", LLDB_REGNUM_GENERIC_ARG4)
|
||||
.Case("r8", LLDB_REGNUM_GENERIC_ARG5)
|
||||
.Case("r9", LLDB_REGNUM_GENERIC_ARG6)
|
||||
.Default(LLDB_INVALID_REGNUM);
|
||||
}
|
||||
|
||||
void ABISysV_x86_64::Initialize() {
|
||||
PluginManager::RegisterPlugin(
|
||||
GetPluginNameStatic(), "System V ABI for x86_64 targets", CreateInstance);
|
||||
|
|
|
@ -9,10 +9,9 @@
|
|||
#ifndef liblldb_ABISysV_x86_64_h_
|
||||
#define liblldb_ABISysV_x86_64_h_
|
||||
|
||||
#include "lldb/Target/ABI.h"
|
||||
#include "lldb/lldb-private.h"
|
||||
#include "Plugins/ABI/X86/ABIX86_64.h"
|
||||
|
||||
class ABISysV_x86_64 : public lldb_private::RegInfoBasedABI {
|
||||
class ABISysV_x86_64 : public ABIX86_64 {
|
||||
public:
|
||||
~ABISysV_x86_64() override = default;
|
||||
|
||||
|
@ -67,9 +66,6 @@ public:
|
|||
return true;
|
||||
}
|
||||
|
||||
const lldb_private::RegisterInfo *
|
||||
GetRegisterInfoArray(uint32_t &count) override;
|
||||
|
||||
bool GetPointerReturnRegister(const char *&name) override;
|
||||
|
||||
// Static Functions
|
||||
|
@ -96,9 +92,10 @@ protected:
|
|||
lldb_private::CompilerType &ast_type) const;
|
||||
|
||||
bool RegisterIsCalleeSaved(const lldb_private::RegisterInfo *reg_info);
|
||||
uint32_t GetGenericNum(llvm::StringRef reg) override;
|
||||
|
||||
private:
|
||||
using lldb_private::RegInfoBasedABI::RegInfoBasedABI; // Call CreateInstance instead.
|
||||
using ABIX86_64::ABIX86_64; // Call CreateInstance instead.
|
||||
};
|
||||
|
||||
#endif // liblldb_ABISysV_x86_64_h_
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -9,10 +9,9 @@
|
|||
#ifndef liblldb_ABIWindows_x86_64_h_
|
||||
#define liblldb_ABIWindows_x86_64_h_
|
||||
|
||||
#include "lldb/Target/ABI.h"
|
||||
#include "lldb/lldb-private.h"
|
||||
#include "Plugins/ABI/X86/ABIX86_64.h"
|
||||
|
||||
class ABIWindows_x86_64 : public lldb_private::RegInfoBasedABI {
|
||||
class ABIWindows_x86_64 : public ABIX86_64 {
|
||||
public:
|
||||
~ABIWindows_x86_64() override = default;
|
||||
|
||||
|
@ -56,9 +55,6 @@ public:
|
|||
return true;
|
||||
}
|
||||
|
||||
const lldb_private::RegisterInfo *
|
||||
GetRegisterInfoArray(uint32_t &count) override;
|
||||
|
||||
bool GetPointerReturnRegister(const char *&name) override;
|
||||
|
||||
//------------------------------------------------------------------
|
||||
|
@ -89,9 +85,10 @@ protected:
|
|||
lldb_private::CompilerType &ast_type) const;
|
||||
|
||||
bool RegisterIsCalleeSaved(const lldb_private::RegisterInfo *reg_info);
|
||||
uint32_t GetGenericNum(llvm::StringRef reg) override;
|
||||
|
||||
private:
|
||||
using lldb_private::RegInfoBasedABI::RegInfoBasedABI; // Call CreateInstance instead.
|
||||
using ABIX86_64::ABIX86_64; // Call CreateInstance instead.
|
||||
};
|
||||
|
||||
#endif // liblldb_ABISysV_x86_64_h_
|
||||
|
|
|
@ -0,0 +1,26 @@
|
|||
//===-- ABIX86_64.h ---------------------------------------------*- C++ -*-===//
|
||||
//
|
||||
// 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
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef LLDB_PLUGIN_ABI_X86_ABIX86_64_H
|
||||
#define LLDB_PLUGIN_ABI_X86_ABIX86_64_H
|
||||
|
||||
#include "lldb/Target/ABI.h"
|
||||
#include "lldb/lldb-private.h"
|
||||
|
||||
class ABIX86_64 : public lldb_private::MCBasedABI {
|
||||
protected:
|
||||
std::string GetMCName(std::string name) override {
|
||||
MapRegisterName(name, "stmm", "st");
|
||||
return name;
|
||||
}
|
||||
|
||||
private:
|
||||
using lldb_private::MCBasedABI::MCBasedABI;
|
||||
};
|
||||
|
||||
#endif // LLDB_PLUGIN_ABI_X86_ABIX86_64_H
|
|
@ -228,3 +228,43 @@ void RegInfoBasedABI::AugmentRegisterInfo(RegisterInfo &info) {
|
|||
if (info.kinds[eRegisterKindGeneric] == LLDB_INVALID_REGNUM)
|
||||
info.kinds[eRegisterKindGeneric] = abi_info.kinds[eRegisterKindGeneric];
|
||||
}
|
||||
|
||||
void MCBasedABI::AugmentRegisterInfo(RegisterInfo &info) {
|
||||
uint32_t eh, dwarf;
|
||||
std::tie(eh, dwarf) = GetEHAndDWARFNums(info.name);
|
||||
|
||||
if (info.kinds[eRegisterKindEHFrame] == LLDB_INVALID_REGNUM)
|
||||
info.kinds[eRegisterKindEHFrame] = eh;
|
||||
if (info.kinds[eRegisterKindDWARF] == LLDB_INVALID_REGNUM)
|
||||
info.kinds[eRegisterKindDWARF] = dwarf;
|
||||
if (info.kinds[eRegisterKindGeneric] == LLDB_INVALID_REGNUM)
|
||||
info.kinds[eRegisterKindGeneric] = GetGenericNum(info.name);
|
||||
}
|
||||
|
||||
std::pair<uint32_t, uint32_t>
|
||||
MCBasedABI::GetEHAndDWARFNums(llvm::StringRef name) {
|
||||
std::string mc_name = GetMCName(name.str());
|
||||
llvm::transform(mc_name, mc_name.begin(), std::toupper);
|
||||
int eh = -1;
|
||||
int dwarf = -1;
|
||||
for (unsigned reg = 0; reg < m_mc_register_info_up->getNumRegs(); ++reg) {
|
||||
if (m_mc_register_info_up->getName(reg) == mc_name) {
|
||||
eh = m_mc_register_info_up->getDwarfRegNum(reg, /*isEH=*/true);
|
||||
dwarf = m_mc_register_info_up->getDwarfRegNum(reg, /*isEH=*/false);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return std::pair<uint32_t, uint32_t>(eh == -1 ? LLDB_INVALID_REGNUM : eh,
|
||||
dwarf == -1 ? LLDB_INVALID_REGNUM
|
||||
: dwarf);
|
||||
}
|
||||
|
||||
void MCBasedABI::MapRegisterName(std::string &name, llvm::StringRef from_prefix,
|
||||
llvm::StringRef to_prefix) {
|
||||
llvm::StringRef name_ref = name;
|
||||
if (!name_ref.consume_front(from_prefix))
|
||||
return;
|
||||
uint64_t _;
|
||||
if (name_ref.empty() || to_integer(name_ref, _, 10))
|
||||
name = (to_prefix + name_ref).str();
|
||||
}
|
||||
|
|
|
@ -0,0 +1,26 @@
|
|||
//===-- ABITest.cpp -------------------------------------------------------===//
|
||||
//
|
||||
// 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
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "lldb/Target/ABI.h"
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
using namespace lldb_private;
|
||||
|
||||
TEST(MCBasedABI, MapRegisterName) {
|
||||
auto map = [](std::string name) {
|
||||
MCBasedABI::MapRegisterName(name, "foo", "bar");
|
||||
return name;
|
||||
};
|
||||
EXPECT_EQ("bar", map("foo"));
|
||||
EXPECT_EQ("bar0", map("foo0"));
|
||||
EXPECT_EQ("bar47", map("foo47"));
|
||||
EXPECT_EQ("foo47x", map("foo47x"));
|
||||
EXPECT_EQ("fooo47", map("fooo47"));
|
||||
EXPECT_EQ("bar47", map("bar47"));
|
||||
}
|
||||
|
|
@ -1,4 +1,5 @@
|
|||
add_lldb_unittest(TargetTests
|
||||
ABITest.cpp
|
||||
ExecutionContextTest.cpp
|
||||
MemoryRegionInfoTest.cpp
|
||||
ModuleCacheTest.cpp
|
||||
|
|
Loading…
Reference in New Issue