diff options
Diffstat (limited to 'source/Plugins/ABI')
26 files changed, 18512 insertions, 11364 deletions
diff --git a/source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.cpp b/source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.cpp index ea906f613890..969c7d3c071e 100644 --- a/source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.cpp +++ b/source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.cpp @@ -32,710 +32,1831 @@ #include "lldb/Target/Target.h" #include "lldb/Target/Thread.h" +#include "Plugins/Process/Utility/ARMDefines.h" #include "Utility/ARM_DWARF_Registers.h" #include "Utility/ARM_ehframe_Registers.h" -#include "Plugins/Process/Utility/ARMDefines.h" using namespace lldb; using namespace lldb_private; -static RegisterInfo g_register_infos[] = -{ - // NAME ALT SZ OFF ENCODING FORMAT EH_FRAME DWARF GENERIC PROCESS PLUGIN LLDB NATIVE VALUE REGS INVALIDATE REGS - // ========== ======= == === ============= ============ ======================= =================== =========================== ======================= ====================== ========== =============== - { "r0", "arg1", 4, 0, eEncodingUint , eFormatHex, { ehframe_r0, dwarf_r0, LLDB_REGNUM_GENERIC_ARG1, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "r1", "arg2", 4, 0, eEncodingUint , eFormatHex, { ehframe_r1, dwarf_r1, LLDB_REGNUM_GENERIC_ARG2, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "r2", "arg3", 4, 0, eEncodingUint , eFormatHex, { ehframe_r2, dwarf_r2, LLDB_REGNUM_GENERIC_ARG3, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "r3", "arg4", 4, 0, eEncodingUint , eFormatHex, { ehframe_r3, dwarf_r3, LLDB_REGNUM_GENERIC_ARG4, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "r4", nullptr, 4, 0, eEncodingUint , eFormatHex, { ehframe_r4, dwarf_r4, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "r5", nullptr, 4, 0, eEncodingUint , eFormatHex, { ehframe_r5, dwarf_r5, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "r6", nullptr, 4, 0, eEncodingUint , eFormatHex, { ehframe_r6, dwarf_r6, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "r7", nullptr, 4, 0, eEncodingUint , eFormatHex, { ehframe_r7, dwarf_r7, LLDB_REGNUM_GENERIC_FP, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "r8", nullptr, 4, 0, eEncodingUint , eFormatHex, { ehframe_r8, dwarf_r8, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "r9", nullptr, 4, 0, eEncodingUint , eFormatHex, { ehframe_r9, dwarf_r9, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "r10", nullptr, 4, 0, eEncodingUint , eFormatHex, { ehframe_r10, dwarf_r10, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "r11", nullptr, 4, 0, eEncodingUint , eFormatHex, { ehframe_r11, dwarf_r11, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "r12", nullptr, 4, 0, eEncodingUint , eFormatHex, { ehframe_r12, dwarf_r12, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "sp", "r13", 4, 0, eEncodingUint , eFormatHex, { ehframe_sp, dwarf_sp, LLDB_REGNUM_GENERIC_SP, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "lr", "r14", 4, 0, eEncodingUint , eFormatHex, { ehframe_lr, dwarf_lr, LLDB_REGNUM_GENERIC_RA, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "pc", "r15", 4, 0, eEncodingUint , eFormatHex, { ehframe_pc, dwarf_pc, LLDB_REGNUM_GENERIC_PC, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "cpsr", "psr", 4, 0, eEncodingUint , eFormatHex, { ehframe_cpsr, dwarf_cpsr, LLDB_REGNUM_GENERIC_FLAGS, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "s0", nullptr, 4, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s0, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "s1", nullptr, 4, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s1, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "s2", nullptr, 4, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s2, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "s3", nullptr, 4, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s3, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "s4", nullptr, 4, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s4, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "s5", nullptr, 4, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s5, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "s6", nullptr, 4, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s6, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "s7", nullptr, 4, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s7, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "s8", nullptr, 4, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s8, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "s9", nullptr, 4, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s9, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "s10", nullptr, 4, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s10, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "s11", nullptr, 4, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s11, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "s12", nullptr, 4, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s12, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "s13", nullptr, 4, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s13, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "s14", nullptr, 4, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s14, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "s15", nullptr, 4, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s15, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "s16", nullptr, 4, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s16, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "s17", nullptr, 4, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s17, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "s18", nullptr, 4, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s18, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "s19", nullptr, 4, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s19, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "s20", nullptr, 4, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s20, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "s21", nullptr, 4, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s21, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "s22", nullptr, 4, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s22, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "s23", nullptr, 4, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s23, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "s24", nullptr, 4, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s24, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "s25", nullptr, 4, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s25, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "s26", nullptr, 4, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s26, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "s27", nullptr, 4, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s27, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "s28", nullptr, 4, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s28, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "s29", nullptr, 4, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s29, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "s30", nullptr, 4, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s30, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "s31", nullptr, 4, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s31, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "fpscr", nullptr, 4, 0, eEncodingUint , eFormatHex , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "d0", nullptr, 8, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d0, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "d1", nullptr, 8, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d1, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "d2", nullptr, 8, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d2, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "d3", nullptr, 8, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d3, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "d4", nullptr, 8, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d4, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "d5", nullptr, 8, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d5, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "d6", nullptr, 8, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d6, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "d7", nullptr, 8, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d7, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "d8", nullptr, 8, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d8, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "d9", nullptr, 8, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d9, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "d10", nullptr, 8, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d10, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "d11", nullptr, 8, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d11, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "d12", nullptr, 8, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d12, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "d13", nullptr, 8, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d13, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "d14", nullptr, 8, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d14, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "d15", nullptr, 8, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d15, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "d16", nullptr, 8, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d16, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "d17", nullptr, 8, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d17, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "d18", nullptr, 8, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d18, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "d19", nullptr, 8, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d19, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "d20", nullptr, 8, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d20, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "d21", nullptr, 8, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d21, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "d22", nullptr, 8, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d22, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "d23", nullptr, 8, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d23, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "d24", nullptr, 8, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d24, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "d25", nullptr, 8, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d25, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "d26", nullptr, 8, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d26, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "d27", nullptr, 8, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d27, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "d28", nullptr, 8, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d28, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "d29", nullptr, 8, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d29, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "d30", nullptr, 8, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d30, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "d31", nullptr, 8, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d31, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "r8_usr", nullptr, 4, 0, eEncodingUint , eFormatHex, { LLDB_INVALID_REGNUM, dwarf_r8_usr, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "r9_usr", nullptr, 4, 0, eEncodingUint , eFormatHex, { LLDB_INVALID_REGNUM, dwarf_r9_usr, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "r10_usr", nullptr, 4, 0, eEncodingUint , eFormatHex, { LLDB_INVALID_REGNUM, dwarf_r10_usr, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "r11_usr", nullptr, 4, 0, eEncodingUint , eFormatHex, { LLDB_INVALID_REGNUM, dwarf_r11_usr, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "r12_usr", nullptr, 4, 0, eEncodingUint , eFormatHex, { LLDB_INVALID_REGNUM, dwarf_r12_usr, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "r13_usr", "sp_usr", 4, 0, eEncodingUint , eFormatHex, { LLDB_INVALID_REGNUM, dwarf_r13_usr, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "r14_usr", "lr_usr", 4, 0, eEncodingUint , eFormatHex, { LLDB_INVALID_REGNUM, dwarf_r14_usr, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "r8_fiq", nullptr, 4, 0, eEncodingUint , eFormatHex, { LLDB_INVALID_REGNUM, dwarf_r8_fiq, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "r9_fiq", nullptr, 4, 0, eEncodingUint , eFormatHex, { LLDB_INVALID_REGNUM, dwarf_r9_fiq, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "r10_fiq", nullptr, 4, 0, eEncodingUint , eFormatHex, { LLDB_INVALID_REGNUM, dwarf_r10_fiq, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "r11_fiq", nullptr, 4, 0, eEncodingUint , eFormatHex, { LLDB_INVALID_REGNUM, dwarf_r11_fiq, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "r12_fiq", nullptr, 4, 0, eEncodingUint , eFormatHex, { LLDB_INVALID_REGNUM, dwarf_r12_fiq, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "r13_fiq", "sp_fiq", 4, 0, eEncodingUint , eFormatHex, { LLDB_INVALID_REGNUM, dwarf_r13_fiq, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "r14_fiq", "lr_fiq", 4, 0, eEncodingUint , eFormatHex, { LLDB_INVALID_REGNUM, dwarf_r14_fiq, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "r13_irq", "sp_irq", 4, 0, eEncodingUint , eFormatHex, { LLDB_INVALID_REGNUM, dwarf_r13_irq, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "r14_irq", "lr_irq", 4, 0, eEncodingUint , eFormatHex, { LLDB_INVALID_REGNUM, dwarf_r14_irq, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "r13_abt", "sp_abt", 4, 0, eEncodingUint , eFormatHex, { LLDB_INVALID_REGNUM, dwarf_r13_abt, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "r14_abt", "lr_abt", 4, 0, eEncodingUint , eFormatHex, { LLDB_INVALID_REGNUM, dwarf_r14_abt, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "r13_und", "sp_und", 4, 0, eEncodingUint , eFormatHex, { LLDB_INVALID_REGNUM, dwarf_r13_und, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "r14_und", "lr_und", 4, 0, eEncodingUint , eFormatHex, { LLDB_INVALID_REGNUM, dwarf_r14_und, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "r13_svc", "sp_svc", 4, 0, eEncodingUint , eFormatHex, { LLDB_INVALID_REGNUM, dwarf_r13_svc, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "r14_svc", "lr_svc", 4, 0, eEncodingUint , eFormatHex, { LLDB_INVALID_REGNUM, dwarf_r14_svc, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr } -}; - -static const uint32_t k_num_register_infos = llvm::array_lengthof(g_register_infos); +static RegisterInfo g_register_infos[] = { + // NAME ALT SZ OFF ENCODING FORMAT EH_FRAME + // DWARF GENERIC PROCESS PLUGIN + // LLDB NATIVE + // ========== ======= == === ============= ============ + // ======================= =================== =========================== + // ======================= ====================== + {"r0", + "arg1", + 4, + 0, + eEncodingUint, + eFormatHex, + {ehframe_r0, dwarf_r0, LLDB_REGNUM_GENERIC_ARG1, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"r1", + "arg2", + 4, + 0, + eEncodingUint, + eFormatHex, + {ehframe_r1, dwarf_r1, LLDB_REGNUM_GENERIC_ARG2, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"r2", + "arg3", + 4, + 0, + eEncodingUint, + eFormatHex, + {ehframe_r2, dwarf_r2, LLDB_REGNUM_GENERIC_ARG3, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"r3", + "arg4", + 4, + 0, + eEncodingUint, + eFormatHex, + {ehframe_r3, dwarf_r3, LLDB_REGNUM_GENERIC_ARG4, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"r4", + nullptr, + 4, + 0, + eEncodingUint, + eFormatHex, + {ehframe_r4, dwarf_r4, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"r5", + nullptr, + 4, + 0, + eEncodingUint, + eFormatHex, + {ehframe_r5, dwarf_r5, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"r6", + nullptr, + 4, + 0, + eEncodingUint, + eFormatHex, + {ehframe_r6, dwarf_r6, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"r7", + nullptr, + 4, + 0, + eEncodingUint, + eFormatHex, + {ehframe_r7, dwarf_r7, LLDB_REGNUM_GENERIC_FP, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"r8", + nullptr, + 4, + 0, + eEncodingUint, + eFormatHex, + {ehframe_r8, dwarf_r8, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"r9", + nullptr, + 4, + 0, + eEncodingUint, + eFormatHex, + {ehframe_r9, dwarf_r9, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"r10", + nullptr, + 4, + 0, + eEncodingUint, + eFormatHex, + {ehframe_r10, dwarf_r10, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"r11", + nullptr, + 4, + 0, + eEncodingUint, + eFormatHex, + {ehframe_r11, dwarf_r11, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"r12", + nullptr, + 4, + 0, + eEncodingUint, + eFormatHex, + {ehframe_r12, dwarf_r12, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"sp", + "r13", + 4, + 0, + eEncodingUint, + eFormatHex, + {ehframe_sp, dwarf_sp, LLDB_REGNUM_GENERIC_SP, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"lr", + "r14", + 4, + 0, + eEncodingUint, + eFormatHex, + {ehframe_lr, dwarf_lr, LLDB_REGNUM_GENERIC_RA, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"pc", + "r15", + 4, + 0, + eEncodingUint, + eFormatHex, + {ehframe_pc, dwarf_pc, LLDB_REGNUM_GENERIC_PC, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"cpsr", + "psr", + 4, + 0, + eEncodingUint, + eFormatHex, + {ehframe_cpsr, dwarf_cpsr, LLDB_REGNUM_GENERIC_FLAGS, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"s0", + nullptr, + 4, + 0, + eEncodingIEEE754, + eFormatFloat, + {LLDB_INVALID_REGNUM, dwarf_s0, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"s1", + nullptr, + 4, + 0, + eEncodingIEEE754, + eFormatFloat, + {LLDB_INVALID_REGNUM, dwarf_s1, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"s2", + nullptr, + 4, + 0, + eEncodingIEEE754, + eFormatFloat, + {LLDB_INVALID_REGNUM, dwarf_s2, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"s3", + nullptr, + 4, + 0, + eEncodingIEEE754, + eFormatFloat, + {LLDB_INVALID_REGNUM, dwarf_s3, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"s4", + nullptr, + 4, + 0, + eEncodingIEEE754, + eFormatFloat, + {LLDB_INVALID_REGNUM, dwarf_s4, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"s5", + nullptr, + 4, + 0, + eEncodingIEEE754, + eFormatFloat, + {LLDB_INVALID_REGNUM, dwarf_s5, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"s6", + nullptr, + 4, + 0, + eEncodingIEEE754, + eFormatFloat, + {LLDB_INVALID_REGNUM, dwarf_s6, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"s7", + nullptr, + 4, + 0, + eEncodingIEEE754, + eFormatFloat, + {LLDB_INVALID_REGNUM, dwarf_s7, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"s8", + nullptr, + 4, + 0, + eEncodingIEEE754, + eFormatFloat, + {LLDB_INVALID_REGNUM, dwarf_s8, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"s9", + nullptr, + 4, + 0, + eEncodingIEEE754, + eFormatFloat, + {LLDB_INVALID_REGNUM, dwarf_s9, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"s10", + nullptr, + 4, + 0, + eEncodingIEEE754, + eFormatFloat, + {LLDB_INVALID_REGNUM, dwarf_s10, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"s11", + nullptr, + 4, + 0, + eEncodingIEEE754, + eFormatFloat, + {LLDB_INVALID_REGNUM, dwarf_s11, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"s12", + nullptr, + 4, + 0, + eEncodingIEEE754, + eFormatFloat, + {LLDB_INVALID_REGNUM, dwarf_s12, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"s13", + nullptr, + 4, + 0, + eEncodingIEEE754, + eFormatFloat, + {LLDB_INVALID_REGNUM, dwarf_s13, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"s14", + nullptr, + 4, + 0, + eEncodingIEEE754, + eFormatFloat, + {LLDB_INVALID_REGNUM, dwarf_s14, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"s15", + nullptr, + 4, + 0, + eEncodingIEEE754, + eFormatFloat, + {LLDB_INVALID_REGNUM, dwarf_s15, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"s16", + nullptr, + 4, + 0, + eEncodingIEEE754, + eFormatFloat, + {LLDB_INVALID_REGNUM, dwarf_s16, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"s17", + nullptr, + 4, + 0, + eEncodingIEEE754, + eFormatFloat, + {LLDB_INVALID_REGNUM, dwarf_s17, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"s18", + nullptr, + 4, + 0, + eEncodingIEEE754, + eFormatFloat, + {LLDB_INVALID_REGNUM, dwarf_s18, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"s19", + nullptr, + 4, + 0, + eEncodingIEEE754, + eFormatFloat, + {LLDB_INVALID_REGNUM, dwarf_s19, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"s20", + nullptr, + 4, + 0, + eEncodingIEEE754, + eFormatFloat, + {LLDB_INVALID_REGNUM, dwarf_s20, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"s21", + nullptr, + 4, + 0, + eEncodingIEEE754, + eFormatFloat, + {LLDB_INVALID_REGNUM, dwarf_s21, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"s22", + nullptr, + 4, + 0, + eEncodingIEEE754, + eFormatFloat, + {LLDB_INVALID_REGNUM, dwarf_s22, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"s23", + nullptr, + 4, + 0, + eEncodingIEEE754, + eFormatFloat, + {LLDB_INVALID_REGNUM, dwarf_s23, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"s24", + nullptr, + 4, + 0, + eEncodingIEEE754, + eFormatFloat, + {LLDB_INVALID_REGNUM, dwarf_s24, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"s25", + nullptr, + 4, + 0, + eEncodingIEEE754, + eFormatFloat, + {LLDB_INVALID_REGNUM, dwarf_s25, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"s26", + nullptr, + 4, + 0, + eEncodingIEEE754, + eFormatFloat, + {LLDB_INVALID_REGNUM, dwarf_s26, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"s27", + nullptr, + 4, + 0, + eEncodingIEEE754, + eFormatFloat, + {LLDB_INVALID_REGNUM, dwarf_s27, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"s28", + nullptr, + 4, + 0, + eEncodingIEEE754, + eFormatFloat, + {LLDB_INVALID_REGNUM, dwarf_s28, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"s29", + nullptr, + 4, + 0, + eEncodingIEEE754, + eFormatFloat, + {LLDB_INVALID_REGNUM, dwarf_s29, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"s30", + nullptr, + 4, + 0, + eEncodingIEEE754, + eFormatFloat, + {LLDB_INVALID_REGNUM, dwarf_s30, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"s31", + nullptr, + 4, + 0, + eEncodingIEEE754, + eFormatFloat, + {LLDB_INVALID_REGNUM, dwarf_s31, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"fpscr", + nullptr, + 4, + 0, + eEncodingUint, + eFormatHex, + {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"d0", + nullptr, + 8, + 0, + eEncodingIEEE754, + eFormatFloat, + {LLDB_INVALID_REGNUM, dwarf_d0, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"d1", + nullptr, + 8, + 0, + eEncodingIEEE754, + eFormatFloat, + {LLDB_INVALID_REGNUM, dwarf_d1, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"d2", + nullptr, + 8, + 0, + eEncodingIEEE754, + eFormatFloat, + {LLDB_INVALID_REGNUM, dwarf_d2, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"d3", + nullptr, + 8, + 0, + eEncodingIEEE754, + eFormatFloat, + {LLDB_INVALID_REGNUM, dwarf_d3, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"d4", + nullptr, + 8, + 0, + eEncodingIEEE754, + eFormatFloat, + {LLDB_INVALID_REGNUM, dwarf_d4, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"d5", + nullptr, + 8, + 0, + eEncodingIEEE754, + eFormatFloat, + {LLDB_INVALID_REGNUM, dwarf_d5, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"d6", + nullptr, + 8, + 0, + eEncodingIEEE754, + eFormatFloat, + {LLDB_INVALID_REGNUM, dwarf_d6, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"d7", + nullptr, + 8, + 0, + eEncodingIEEE754, + eFormatFloat, + {LLDB_INVALID_REGNUM, dwarf_d7, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"d8", + nullptr, + 8, + 0, + eEncodingIEEE754, + eFormatFloat, + {LLDB_INVALID_REGNUM, dwarf_d8, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"d9", + nullptr, + 8, + 0, + eEncodingIEEE754, + eFormatFloat, + {LLDB_INVALID_REGNUM, dwarf_d9, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"d10", + nullptr, + 8, + 0, + eEncodingIEEE754, + eFormatFloat, + {LLDB_INVALID_REGNUM, dwarf_d10, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"d11", + nullptr, + 8, + 0, + eEncodingIEEE754, + eFormatFloat, + {LLDB_INVALID_REGNUM, dwarf_d11, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"d12", + nullptr, + 8, + 0, + eEncodingIEEE754, + eFormatFloat, + {LLDB_INVALID_REGNUM, dwarf_d12, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"d13", + nullptr, + 8, + 0, + eEncodingIEEE754, + eFormatFloat, + {LLDB_INVALID_REGNUM, dwarf_d13, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"d14", + nullptr, + 8, + 0, + eEncodingIEEE754, + eFormatFloat, + {LLDB_INVALID_REGNUM, dwarf_d14, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"d15", + nullptr, + 8, + 0, + eEncodingIEEE754, + eFormatFloat, + {LLDB_INVALID_REGNUM, dwarf_d15, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"d16", + nullptr, + 8, + 0, + eEncodingIEEE754, + eFormatFloat, + {LLDB_INVALID_REGNUM, dwarf_d16, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"d17", + nullptr, + 8, + 0, + eEncodingIEEE754, + eFormatFloat, + {LLDB_INVALID_REGNUM, dwarf_d17, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"d18", + nullptr, + 8, + 0, + eEncodingIEEE754, + eFormatFloat, + {LLDB_INVALID_REGNUM, dwarf_d18, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"d19", + nullptr, + 8, + 0, + eEncodingIEEE754, + eFormatFloat, + {LLDB_INVALID_REGNUM, dwarf_d19, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"d20", + nullptr, + 8, + 0, + eEncodingIEEE754, + eFormatFloat, + {LLDB_INVALID_REGNUM, dwarf_d20, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"d21", + nullptr, + 8, + 0, + eEncodingIEEE754, + eFormatFloat, + {LLDB_INVALID_REGNUM, dwarf_d21, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"d22", + nullptr, + 8, + 0, + eEncodingIEEE754, + eFormatFloat, + {LLDB_INVALID_REGNUM, dwarf_d22, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"d23", + nullptr, + 8, + 0, + eEncodingIEEE754, + eFormatFloat, + {LLDB_INVALID_REGNUM, dwarf_d23, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"d24", + nullptr, + 8, + 0, + eEncodingIEEE754, + eFormatFloat, + {LLDB_INVALID_REGNUM, dwarf_d24, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"d25", + nullptr, + 8, + 0, + eEncodingIEEE754, + eFormatFloat, + {LLDB_INVALID_REGNUM, dwarf_d25, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"d26", + nullptr, + 8, + 0, + eEncodingIEEE754, + eFormatFloat, + {LLDB_INVALID_REGNUM, dwarf_d26, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"d27", + nullptr, + 8, + 0, + eEncodingIEEE754, + eFormatFloat, + {LLDB_INVALID_REGNUM, dwarf_d27, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"d28", + nullptr, + 8, + 0, + eEncodingIEEE754, + eFormatFloat, + {LLDB_INVALID_REGNUM, dwarf_d28, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"d29", + nullptr, + 8, + 0, + eEncodingIEEE754, + eFormatFloat, + {LLDB_INVALID_REGNUM, dwarf_d29, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"d30", + nullptr, + 8, + 0, + eEncodingIEEE754, + eFormatFloat, + {LLDB_INVALID_REGNUM, dwarf_d30, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"d31", + nullptr, + 8, + 0, + eEncodingIEEE754, + eFormatFloat, + {LLDB_INVALID_REGNUM, dwarf_d31, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"r8_usr", + nullptr, + 4, + 0, + eEncodingUint, + eFormatHex, + {LLDB_INVALID_REGNUM, dwarf_r8_usr, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"r9_usr", + nullptr, + 4, + 0, + eEncodingUint, + eFormatHex, + {LLDB_INVALID_REGNUM, dwarf_r9_usr, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"r10_usr", + nullptr, + 4, + 0, + eEncodingUint, + eFormatHex, + {LLDB_INVALID_REGNUM, dwarf_r10_usr, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"r11_usr", + nullptr, + 4, + 0, + eEncodingUint, + eFormatHex, + {LLDB_INVALID_REGNUM, dwarf_r11_usr, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"r12_usr", + nullptr, + 4, + 0, + eEncodingUint, + eFormatHex, + {LLDB_INVALID_REGNUM, dwarf_r12_usr, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"r13_usr", + "sp_usr", + 4, + 0, + eEncodingUint, + eFormatHex, + {LLDB_INVALID_REGNUM, dwarf_r13_usr, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"r14_usr", + "lr_usr", + 4, + 0, + eEncodingUint, + eFormatHex, + {LLDB_INVALID_REGNUM, dwarf_r14_usr, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"r8_fiq", + nullptr, + 4, + 0, + eEncodingUint, + eFormatHex, + {LLDB_INVALID_REGNUM, dwarf_r8_fiq, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"r9_fiq", + nullptr, + 4, + 0, + eEncodingUint, + eFormatHex, + {LLDB_INVALID_REGNUM, dwarf_r9_fiq, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"r10_fiq", + nullptr, + 4, + 0, + eEncodingUint, + eFormatHex, + {LLDB_INVALID_REGNUM, dwarf_r10_fiq, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"r11_fiq", + nullptr, + 4, + 0, + eEncodingUint, + eFormatHex, + {LLDB_INVALID_REGNUM, dwarf_r11_fiq, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"r12_fiq", + nullptr, + 4, + 0, + eEncodingUint, + eFormatHex, + {LLDB_INVALID_REGNUM, dwarf_r12_fiq, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"r13_fiq", + "sp_fiq", + 4, + 0, + eEncodingUint, + eFormatHex, + {LLDB_INVALID_REGNUM, dwarf_r13_fiq, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"r14_fiq", + "lr_fiq", + 4, + 0, + eEncodingUint, + eFormatHex, + {LLDB_INVALID_REGNUM, dwarf_r14_fiq, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"r13_irq", + "sp_irq", + 4, + 0, + eEncodingUint, + eFormatHex, + {LLDB_INVALID_REGNUM, dwarf_r13_irq, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"r14_irq", + "lr_irq", + 4, + 0, + eEncodingUint, + eFormatHex, + {LLDB_INVALID_REGNUM, dwarf_r14_irq, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"r13_abt", + "sp_abt", + 4, + 0, + eEncodingUint, + eFormatHex, + {LLDB_INVALID_REGNUM, dwarf_r13_abt, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"r14_abt", + "lr_abt", + 4, + 0, + eEncodingUint, + eFormatHex, + {LLDB_INVALID_REGNUM, dwarf_r14_abt, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"r13_und", + "sp_und", + 4, + 0, + eEncodingUint, + eFormatHex, + {LLDB_INVALID_REGNUM, dwarf_r13_und, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"r14_und", + "lr_und", + 4, + 0, + eEncodingUint, + eFormatHex, + {LLDB_INVALID_REGNUM, dwarf_r14_und, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"r13_svc", + "sp_svc", + 4, + 0, + eEncodingUint, + eFormatHex, + {LLDB_INVALID_REGNUM, dwarf_r13_svc, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"r14_svc", + "lr_svc", + 4, + 0, + eEncodingUint, + eFormatHex, + {LLDB_INVALID_REGNUM, dwarf_r14_svc, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}}; + +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 * -ABIMacOSX_arm::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(); - } +ABIMacOSX_arm::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; + } + count = k_num_register_infos; + return g_register_infos; } -size_t -ABIMacOSX_arm::GetRedZoneSize () const -{ - return 0; -} +size_t ABIMacOSX_arm::GetRedZoneSize() const { return 0; } //------------------------------------------------------------------ // Static Functions //------------------------------------------------------------------ ABISP -ABIMacOSX_arm::CreateInstance (const ArchSpec &arch) -{ - static ABISP g_abi_sp; - const llvm::Triple::ArchType arch_type = arch.GetTriple().getArch(); - const llvm::Triple::VendorType vendor_type = arch.GetTriple().getVendor(); - - if (vendor_type == llvm::Triple::Apple) - { - if ((arch_type == llvm::Triple::arm) || - (arch_type == llvm::Triple::thumb)) - { - if (!g_abi_sp) - g_abi_sp.reset (new ABIMacOSX_arm); - return g_abi_sp; - } +ABIMacOSX_arm::CreateInstance(const ArchSpec &arch) { + static ABISP g_abi_sp; + const llvm::Triple::ArchType arch_type = arch.GetTriple().getArch(); + const llvm::Triple::VendorType vendor_type = arch.GetTriple().getVendor(); + + if (vendor_type == llvm::Triple::Apple) { + if ((arch_type == llvm::Triple::arm) || + (arch_type == llvm::Triple::thumb)) { + if (!g_abi_sp) + g_abi_sp.reset(new ABIMacOSX_arm); + return g_abi_sp; } + } - return ABISP(); + return ABISP(); } -bool -ABIMacOSX_arm::PrepareTrivialCall (Thread &thread, - addr_t sp, - addr_t function_addr, - addr_t return_addr, - llvm::ArrayRef<addr_t> args) const -{ - RegisterContext *reg_ctx = thread.GetRegisterContext().get(); - if (!reg_ctx) - return false; - - const uint32_t pc_reg_num = reg_ctx->ConvertRegisterKindToRegisterNumber (eRegisterKindGeneric, LLDB_REGNUM_GENERIC_PC); - const uint32_t sp_reg_num = reg_ctx->ConvertRegisterKindToRegisterNumber (eRegisterKindGeneric, LLDB_REGNUM_GENERIC_SP); - const uint32_t ra_reg_num = reg_ctx->ConvertRegisterKindToRegisterNumber (eRegisterKindGeneric, LLDB_REGNUM_GENERIC_RA); - - RegisterValue reg_value; - - const char *reg_names[] = { "r0", "r1", "r2", "r3" }; - - llvm::ArrayRef<addr_t>::iterator ai = args.begin(), ae = args.end(); - - for (size_t i = 0; i < llvm::array_lengthof(reg_names); ++i) - { - if (ai == ae) - break; - - reg_value.SetUInt32(*ai); - if (!reg_ctx->WriteRegister(reg_ctx->GetRegisterInfoByName(reg_names[i]), reg_value)) - return false; - - ++ai; - } - - if (ai != ae) - { - // Spill onto the stack - size_t num_stack_regs = ae - ai; - - sp -= (num_stack_regs * 4); - // Keep the stack 16 byte aligned - sp &= ~(16ull-1ull); - - // just using arg1 to get the right size - const RegisterInfo *reg_info = reg_ctx->GetRegisterInfo(eRegisterKindGeneric, LLDB_REGNUM_GENERIC_ARG1); - - addr_t arg_pos = sp; - - for (; ai != ae; ++ai) - { - reg_value.SetUInt32(*ai); - if (reg_ctx->WriteRegisterValueToMemory(reg_info, arg_pos, reg_info->byte_size, reg_value).Fail()) - return false; - arg_pos += reg_info->byte_size; - } - } - - TargetSP target_sp (thread.CalculateTarget()); - Address so_addr; - - // Figure out if our return address is ARM or Thumb by using the - // Address::GetCallableLoadAddress(Target*) which will figure out the ARM - // thumb-ness and set the correct address bits for us. - so_addr.SetLoadAddress (return_addr, target_sp.get()); - return_addr = so_addr.GetCallableLoadAddress (target_sp.get()); - - // Set "lr" to the return address - if (!reg_ctx->WriteRegisterFromUnsigned (ra_reg_num, return_addr)) - return false; +bool ABIMacOSX_arm::PrepareTrivialCall(Thread &thread, addr_t sp, + addr_t function_addr, addr_t return_addr, + llvm::ArrayRef<addr_t> args) const { + RegisterContext *reg_ctx = thread.GetRegisterContext().get(); + if (!reg_ctx) + return false; - // Set "sp" to the requested value - if (!reg_ctx->WriteRegisterFromUnsigned (sp_reg_num, sp)) - return false; - - // If bit zero or 1 is set, this must be a thumb function, no need to figure - // this out from the symbols. - so_addr.SetLoadAddress (function_addr, target_sp.get()); - function_addr = so_addr.GetCallableLoadAddress (target_sp.get()); - - const RegisterInfo *cpsr_reg_info = reg_ctx->GetRegisterInfoByName("cpsr"); - const uint32_t curr_cpsr = reg_ctx->ReadRegisterAsUnsigned(cpsr_reg_info, 0); - - // Make a new CPSR and mask out any Thumb IT (if/then) bits - uint32_t new_cpsr = curr_cpsr & ~MASK_CPSR_IT_MASK; - // If bit zero or 1 is set, this must be thumb... - if (function_addr & 1ull) - new_cpsr |= MASK_CPSR_T; // Set T bit in CPSR - else - new_cpsr &= ~MASK_CPSR_T; // Clear T bit in CPSR + const uint32_t pc_reg_num = reg_ctx->ConvertRegisterKindToRegisterNumber( + eRegisterKindGeneric, LLDB_REGNUM_GENERIC_PC); + const uint32_t sp_reg_num = reg_ctx->ConvertRegisterKindToRegisterNumber( + eRegisterKindGeneric, LLDB_REGNUM_GENERIC_SP); + const uint32_t ra_reg_num = reg_ctx->ConvertRegisterKindToRegisterNumber( + eRegisterKindGeneric, LLDB_REGNUM_GENERIC_RA); - if (new_cpsr != curr_cpsr) - { - if (!reg_ctx->WriteRegisterFromUnsigned (cpsr_reg_info, new_cpsr)) - return false; - } + RegisterValue reg_value; + + const char *reg_names[] = {"r0", "r1", "r2", "r3"}; + + llvm::ArrayRef<addr_t>::iterator ai = args.begin(), ae = args.end(); + + for (size_t i = 0; i < llvm::array_lengthof(reg_names); ++i) { + if (ai == ae) + break; + + reg_value.SetUInt32(*ai); + if (!reg_ctx->WriteRegister(reg_ctx->GetRegisterInfoByName(reg_names[i]), + reg_value)) + return false; + + ++ai; + } + + if (ai != ae) { + // Spill onto the stack + size_t num_stack_regs = ae - ai; + + sp -= (num_stack_regs * 4); + // Keep the stack 16 byte aligned + sp &= ~(16ull - 1ull); - function_addr &= ~1ull; // clear bit zero since the CPSR will take care of the mode for us - - // Set "pc" to the address requested - if (!reg_ctx->WriteRegisterFromUnsigned (pc_reg_num, function_addr)) + // just using arg1 to get the right size + const RegisterInfo *reg_info = reg_ctx->GetRegisterInfo( + eRegisterKindGeneric, LLDB_REGNUM_GENERIC_ARG1); + + addr_t arg_pos = sp; + + for (; ai != ae; ++ai) { + reg_value.SetUInt32(*ai); + if (reg_ctx + ->WriteRegisterValueToMemory(reg_info, arg_pos, + reg_info->byte_size, reg_value) + .Fail()) return false; + arg_pos += reg_info->byte_size; + } + } + + TargetSP target_sp(thread.CalculateTarget()); + Address so_addr; + + // Figure out if our return address is ARM or Thumb by using the + // Address::GetCallableLoadAddress(Target*) which will figure out the ARM + // thumb-ness and set the correct address bits for us. + so_addr.SetLoadAddress(return_addr, target_sp.get()); + return_addr = so_addr.GetCallableLoadAddress(target_sp.get()); + + // Set "lr" to the return address + if (!reg_ctx->WriteRegisterFromUnsigned(ra_reg_num, return_addr)) + return false; + + // Set "sp" to the requested value + if (!reg_ctx->WriteRegisterFromUnsigned(sp_reg_num, sp)) + return false; - return true; + // If bit zero or 1 is set, this must be a thumb function, no need to figure + // this out from the symbols. + so_addr.SetLoadAddress(function_addr, target_sp.get()); + function_addr = so_addr.GetCallableLoadAddress(target_sp.get()); + + const RegisterInfo *cpsr_reg_info = reg_ctx->GetRegisterInfoByName("cpsr"); + const uint32_t curr_cpsr = reg_ctx->ReadRegisterAsUnsigned(cpsr_reg_info, 0); + + // Make a new CPSR and mask out any Thumb IT (if/then) bits + uint32_t new_cpsr = curr_cpsr & ~MASK_CPSR_IT_MASK; + // If bit zero or 1 is set, this must be thumb... + if (function_addr & 1ull) + new_cpsr |= MASK_CPSR_T; // Set T bit in CPSR + else + new_cpsr &= ~MASK_CPSR_T; // Clear T bit in CPSR + + if (new_cpsr != curr_cpsr) { + if (!reg_ctx->WriteRegisterFromUnsigned(cpsr_reg_info, new_cpsr)) + return false; + } + + function_addr &= + ~1ull; // clear bit zero since the CPSR will take care of the mode for us + + // Set "pc" to the address requested + if (!reg_ctx->WriteRegisterFromUnsigned(pc_reg_num, function_addr)) + return false; + + return true; } -bool -ABIMacOSX_arm::GetArgumentValues (Thread &thread, - ValueList &values) const -{ - uint32_t num_values = values.GetSize(); - - ExecutionContext exe_ctx (thread.shared_from_this()); - // For now, assume that the types in the AST values come from the Target's - // scratch AST. - - // Extract the register context so we can read arguments from registers - - RegisterContext *reg_ctx = thread.GetRegisterContext().get(); - - if (!reg_ctx) +bool ABIMacOSX_arm::GetArgumentValues(Thread &thread, ValueList &values) const { + uint32_t num_values = values.GetSize(); + + ExecutionContext exe_ctx(thread.shared_from_this()); + // For now, assume that the types in the AST values come from the Target's + // scratch AST. + + // Extract the register context so we can read arguments from registers + + RegisterContext *reg_ctx = thread.GetRegisterContext().get(); + + if (!reg_ctx) + return false; + + addr_t sp = 0; + + for (uint32_t value_idx = 0; value_idx < num_values; ++value_idx) { + // We currently only support extracting values with Clang QualTypes. + // Do we care about others? + Value *value = values.GetValueAtIndex(value_idx); + + if (!value) + return false; + + CompilerType compiler_type = value->GetCompilerType(); + if (compiler_type) { + bool is_signed = false; + size_t bit_width = 0; + if (compiler_type.IsIntegerOrEnumerationType(is_signed)) { + bit_width = compiler_type.GetBitSize(&thread); + } else if (compiler_type.IsPointerOrReferenceType()) { + bit_width = compiler_type.GetBitSize(&thread); + } else { + // We only handle integer, pointer and reference types currently... return false; - - addr_t sp = 0; - - for (uint32_t value_idx = 0; value_idx < num_values; ++value_idx) - { - // We currently only support extracting values with Clang QualTypes. - // Do we care about others? - Value *value = values.GetValueAtIndex(value_idx); - - if (!value) - return false; - - CompilerType compiler_type = value->GetCompilerType(); - if (compiler_type) - { - bool is_signed = false; - size_t bit_width = 0; - if (compiler_type.IsIntegerOrEnumerationType (is_signed)) - { - bit_width = compiler_type.GetBitSize(&thread); - } - else if (compiler_type.IsPointerOrReferenceType ()) - { - bit_width = compiler_type.GetBitSize(&thread); + } + + if (bit_width <= (exe_ctx.GetProcessRef().GetAddressByteSize() * 8)) { + if (value_idx < 4) { + // Arguments 1-4 are in r0-r3... + const RegisterInfo *arg_reg_info = nullptr; + // Search by generic ID first, then fall back to by name + uint32_t arg_reg_num = reg_ctx->ConvertRegisterKindToRegisterNumber( + eRegisterKindGeneric, LLDB_REGNUM_GENERIC_ARG1 + value_idx); + if (arg_reg_num != LLDB_INVALID_REGNUM) { + arg_reg_info = reg_ctx->GetRegisterInfoAtIndex(arg_reg_num); + } else { + switch (value_idx) { + case 0: + arg_reg_info = reg_ctx->GetRegisterInfoByName("r0"); + break; + case 1: + arg_reg_info = reg_ctx->GetRegisterInfoByName("r1"); + break; + case 2: + arg_reg_info = reg_ctx->GetRegisterInfoByName("r2"); + break; + case 3: + arg_reg_info = reg_ctx->GetRegisterInfoByName("r3"); + break; } - else - { - // We only handle integer, pointer and reference types currently... + } + + if (arg_reg_info) { + RegisterValue reg_value; + + if (reg_ctx->ReadRegister(arg_reg_info, reg_value)) { + if (is_signed) + reg_value.SignExtend(bit_width); + if (!reg_value.GetScalarValue(value->GetScalar())) return false; + continue; } - - if (bit_width <= (exe_ctx.GetProcessRef().GetAddressByteSize() * 8)) - { - if (value_idx < 4) - { - // Arguments 1-4 are in r0-r3... - const RegisterInfo *arg_reg_info = nullptr; - // Search by generic ID first, then fall back to by name - uint32_t arg_reg_num = reg_ctx->ConvertRegisterKindToRegisterNumber (eRegisterKindGeneric, LLDB_REGNUM_GENERIC_ARG1 + value_idx); - if (arg_reg_num != LLDB_INVALID_REGNUM) - { - arg_reg_info = reg_ctx->GetRegisterInfoAtIndex(arg_reg_num); - } - else - { - switch (value_idx) - { - case 0: arg_reg_info = reg_ctx->GetRegisterInfoByName("r0"); break; - case 1: arg_reg_info = reg_ctx->GetRegisterInfoByName("r1"); break; - case 2: arg_reg_info = reg_ctx->GetRegisterInfoByName("r2"); break; - case 3: arg_reg_info = reg_ctx->GetRegisterInfoByName("r3"); break; - } - } - - if (arg_reg_info) - { - RegisterValue reg_value; - - if (reg_ctx->ReadRegister(arg_reg_info, reg_value)) - { - if (is_signed) - reg_value.SignExtend(bit_width); - if (!reg_value.GetScalarValue(value->GetScalar())) - return false; - continue; - } - } - return false; - } - else - { - if (sp == 0) - { - // Read the stack pointer if it already hasn't been read - sp = reg_ctx->GetSP(0); - if (sp == 0) - return false; - } - - // Arguments 5 on up are on the stack - const uint32_t arg_byte_size = (bit_width + (8-1)) / 8; - Error error; - if (!exe_ctx.GetProcessRef().ReadScalarIntegerFromMemory(sp, arg_byte_size, is_signed, value->GetScalar(), error)) - return false; - - sp += arg_byte_size; - } - } + } + return false; + } else { + if (sp == 0) { + // Read the stack pointer if it already hasn't been read + sp = reg_ctx->GetSP(0); + if (sp == 0) + return false; + } + + // Arguments 5 on up are on the stack + const uint32_t arg_byte_size = (bit_width + (8 - 1)) / 8; + Error error; + if (!exe_ctx.GetProcessRef().ReadScalarIntegerFromMemory( + sp, arg_byte_size, is_signed, value->GetScalar(), error)) + return false; + + sp += arg_byte_size; } + } } - return true; + } + return true; } -bool -ABIMacOSX_arm::IsArmv7kProcess (Thread *thread) const -{ - bool is_armv7k = false; - if (thread) - { - ProcessSP process_sp (thread->GetProcess()); - if (process_sp) - { - const ArchSpec &arch (process_sp->GetTarget().GetArchitecture()); - const ArchSpec::Core system_core = arch.GetCore(); - if (system_core == ArchSpec::eCore_arm_armv7k) - { - is_armv7k = true; - } - } +bool ABIMacOSX_arm::IsArmv7kProcess(Thread *thread) const { + bool is_armv7k = false; + if (thread) { + ProcessSP process_sp(thread->GetProcess()); + if (process_sp) { + const ArchSpec &arch(process_sp->GetTarget().GetArchitecture()); + const ArchSpec::Core system_core = arch.GetCore(); + if (system_core == ArchSpec::eCore_arm_armv7k) { + is_armv7k = true; + } } - return is_armv7k; + } + return is_armv7k; } -ValueObjectSP -ABIMacOSX_arm::GetReturnValueObjectImpl (Thread &thread, - lldb_private::CompilerType &compiler_type) const -{ - Value value; - ValueObjectSP return_valobj_sp; - - if (!compiler_type) - return return_valobj_sp; +ValueObjectSP ABIMacOSX_arm::GetReturnValueObjectImpl( + Thread &thread, lldb_private::CompilerType &compiler_type) const { + Value value; + ValueObjectSP return_valobj_sp; - value.SetCompilerType (compiler_type); - - RegisterContext *reg_ctx = thread.GetRegisterContext().get(); - if (!reg_ctx) - return return_valobj_sp; - - bool is_signed; - - // Get the pointer to the first stack argument so we have a place to start - // when reading data - - const RegisterInfo *r0_reg_info = reg_ctx->GetRegisterInfoByName("r0", 0); - if (compiler_type.IsIntegerOrEnumerationType (is_signed)) - { - size_t bit_width = compiler_type.GetBitSize(&thread); - - switch (bit_width) + if (!compiler_type) + return return_valobj_sp; + + value.SetCompilerType(compiler_type); + + RegisterContext *reg_ctx = thread.GetRegisterContext().get(); + if (!reg_ctx) + return return_valobj_sp; + + bool is_signed; + + // Get the pointer to the first stack argument so we have a place to start + // when reading data + + const RegisterInfo *r0_reg_info = reg_ctx->GetRegisterInfoByName("r0", 0); + if (compiler_type.IsIntegerOrEnumerationType(is_signed)) { + size_t bit_width = compiler_type.GetBitSize(&thread); + + switch (bit_width) { + default: + return return_valobj_sp; + case 128: + if (IsArmv7kProcess(&thread)) { + // "A composite type not larger than 16 bytes is returned in r0-r3. The + // format is + // as if the result had been stored in memory at a word-aligned address + // and then + // loaded into r0-r3 with an ldm instruction" { - default: - return return_valobj_sp; - case 128: - if (IsArmv7kProcess (&thread)) - { - // "A composite type not larger than 16 bytes is returned in r0-r3. The format is - // as if the result had been stored in memory at a word-aligned address and then - // loaded into r0-r3 with an ldm instruction" - { - const RegisterInfo *r1_reg_info = reg_ctx->GetRegisterInfoByName("r1", 0); - const RegisterInfo *r2_reg_info = reg_ctx->GetRegisterInfoByName("r2", 0); - const RegisterInfo *r3_reg_info = reg_ctx->GetRegisterInfoByName("r3", 0); - if (r1_reg_info && r2_reg_info && r3_reg_info) - { - const size_t byte_size = compiler_type.GetByteSize(&thread); - ProcessSP process_sp (thread.GetProcess()); - if (byte_size <= r0_reg_info->byte_size + r1_reg_info->byte_size + r2_reg_info->byte_size + r3_reg_info->byte_size - && process_sp) - { - std::unique_ptr<DataBufferHeap> heap_data_ap (new DataBufferHeap(byte_size, 0)); - const ByteOrder byte_order = process_sp->GetByteOrder(); - RegisterValue r0_reg_value; - RegisterValue r1_reg_value; - RegisterValue r2_reg_value; - RegisterValue r3_reg_value; - if (reg_ctx->ReadRegister(r0_reg_info, r0_reg_value) - && reg_ctx->ReadRegister(r1_reg_info, r1_reg_value) - && reg_ctx->ReadRegister(r2_reg_info, r2_reg_value) - && reg_ctx->ReadRegister(r3_reg_info, r3_reg_value)) - { - Error error; - if (r0_reg_value.GetAsMemoryData (r0_reg_info, heap_data_ap->GetBytes()+0, 4, byte_order, error) - && r1_reg_value.GetAsMemoryData (r1_reg_info, heap_data_ap->GetBytes()+4, 4, byte_order, error) - && r2_reg_value.GetAsMemoryData (r2_reg_info, heap_data_ap->GetBytes()+8, 4, byte_order, error) - && r3_reg_value.GetAsMemoryData (r3_reg_info, heap_data_ap->GetBytes()+12, 4, byte_order, error)) - { - DataExtractor data (DataBufferSP (heap_data_ap.release()), - byte_order, - process_sp->GetAddressByteSize()); - - return_valobj_sp = ValueObjectConstResult::Create (&thread, - compiler_type, - ConstString(""), - data); - return return_valobj_sp; - } - } - } - } - } - } - else - { - return return_valobj_sp; + const RegisterInfo *r1_reg_info = + reg_ctx->GetRegisterInfoByName("r1", 0); + const RegisterInfo *r2_reg_info = + reg_ctx->GetRegisterInfoByName("r2", 0); + const RegisterInfo *r3_reg_info = + reg_ctx->GetRegisterInfoByName("r3", 0); + if (r1_reg_info && r2_reg_info && r3_reg_info) { + const size_t byte_size = compiler_type.GetByteSize(&thread); + ProcessSP process_sp(thread.GetProcess()); + if (byte_size <= r0_reg_info->byte_size + r1_reg_info->byte_size + + r2_reg_info->byte_size + + r3_reg_info->byte_size && + process_sp) { + std::unique_ptr<DataBufferHeap> heap_data_ap( + new DataBufferHeap(byte_size, 0)); + const ByteOrder byte_order = process_sp->GetByteOrder(); + RegisterValue r0_reg_value; + RegisterValue r1_reg_value; + RegisterValue r2_reg_value; + RegisterValue r3_reg_value; + if (reg_ctx->ReadRegister(r0_reg_info, r0_reg_value) && + reg_ctx->ReadRegister(r1_reg_info, r1_reg_value) && + reg_ctx->ReadRegister(r2_reg_info, r2_reg_value) && + reg_ctx->ReadRegister(r3_reg_info, r3_reg_value)) { + Error error; + if (r0_reg_value.GetAsMemoryData(r0_reg_info, + heap_data_ap->GetBytes() + 0, + 4, byte_order, error) && + r1_reg_value.GetAsMemoryData(r1_reg_info, + heap_data_ap->GetBytes() + 4, + 4, byte_order, error) && + r2_reg_value.GetAsMemoryData(r2_reg_info, + heap_data_ap->GetBytes() + 8, + 4, byte_order, error) && + r3_reg_value.GetAsMemoryData(r3_reg_info, + heap_data_ap->GetBytes() + 12, + 4, byte_order, error)) { + DataExtractor data(DataBufferSP(heap_data_ap.release()), + byte_order, + process_sp->GetAddressByteSize()); + + return_valobj_sp = ValueObjectConstResult::Create( + &thread, compiler_type, ConstString(""), data); + return return_valobj_sp; } - break; - case 64: - { - const RegisterInfo *r1_reg_info = reg_ctx->GetRegisterInfoByName("r1", 0); - uint64_t raw_value; - raw_value = reg_ctx->ReadRegisterAsUnsigned(r0_reg_info, 0) & UINT32_MAX; - raw_value |= ((uint64_t)(reg_ctx->ReadRegisterAsUnsigned(r1_reg_info, 0) & UINT32_MAX)) << 32; - if (is_signed) - value.GetScalar() = (int64_t)raw_value; - else - value.GetScalar() = (uint64_t)raw_value; + } } - break; - case 32: - if (is_signed) - value.GetScalar() = (int32_t)(reg_ctx->ReadRegisterAsUnsigned(r0_reg_info, 0) & UINT32_MAX); - else - value.GetScalar() = (uint32_t)(reg_ctx->ReadRegisterAsUnsigned(r0_reg_info, 0) & UINT32_MAX); - break; - case 16: - if (is_signed) - value.GetScalar() = (int16_t)(reg_ctx->ReadRegisterAsUnsigned(r0_reg_info, 0) & UINT16_MAX); - else - value.GetScalar() = (uint16_t)(reg_ctx->ReadRegisterAsUnsigned(r0_reg_info, 0) & UINT16_MAX); - break; - case 8: - if (is_signed) - value.GetScalar() = (int8_t)(reg_ctx->ReadRegisterAsUnsigned(r0_reg_info, 0) & UINT8_MAX); - else - value.GetScalar() = (uint8_t)(reg_ctx->ReadRegisterAsUnsigned(r0_reg_info, 0) & UINT8_MAX); - break; + } } - } - else if (compiler_type.IsPointerType ()) - { - uint32_t ptr = thread.GetRegisterContext()->ReadRegisterAsUnsigned(r0_reg_info, 0) & UINT32_MAX; - value.GetScalar() = ptr; - } - else - { - // not handled yet + } else { return return_valobj_sp; + } + break; + case 64: { + const RegisterInfo *r1_reg_info = reg_ctx->GetRegisterInfoByName("r1", 0); + uint64_t raw_value; + raw_value = reg_ctx->ReadRegisterAsUnsigned(r0_reg_info, 0) & UINT32_MAX; + raw_value |= ((uint64_t)(reg_ctx->ReadRegisterAsUnsigned(r1_reg_info, 0) & + UINT32_MAX)) + << 32; + if (is_signed) + value.GetScalar() = (int64_t)raw_value; + else + value.GetScalar() = (uint64_t)raw_value; + } break; + case 32: + if (is_signed) + value.GetScalar() = (int32_t)( + reg_ctx->ReadRegisterAsUnsigned(r0_reg_info, 0) & UINT32_MAX); + else + value.GetScalar() = (uint32_t)( + reg_ctx->ReadRegisterAsUnsigned(r0_reg_info, 0) & UINT32_MAX); + break; + case 16: + if (is_signed) + value.GetScalar() = (int16_t)( + reg_ctx->ReadRegisterAsUnsigned(r0_reg_info, 0) & UINT16_MAX); + else + value.GetScalar() = (uint16_t)( + reg_ctx->ReadRegisterAsUnsigned(r0_reg_info, 0) & UINT16_MAX); + break; + case 8: + if (is_signed) + value.GetScalar() = (int8_t)( + reg_ctx->ReadRegisterAsUnsigned(r0_reg_info, 0) & UINT8_MAX); + else + value.GetScalar() = (uint8_t)( + reg_ctx->ReadRegisterAsUnsigned(r0_reg_info, 0) & UINT8_MAX); + break; } - - // If we get here, we have a valid Value, so make our ValueObject out of it: - - return_valobj_sp = ValueObjectConstResult::Create(thread.GetStackFrameAtIndex(0).get(), - value, - ConstString("")); + } else if (compiler_type.IsPointerType()) { + uint32_t ptr = + thread.GetRegisterContext()->ReadRegisterAsUnsigned(r0_reg_info, 0) & + UINT32_MAX; + value.GetScalar() = ptr; + } else { + // not handled yet return return_valobj_sp; + } + + // If we get here, we have a valid Value, so make our ValueObject out of it: + + return_valobj_sp = ValueObjectConstResult::Create( + thread.GetStackFrameAtIndex(0).get(), value, ConstString("")); + return return_valobj_sp; } -Error -ABIMacOSX_arm::SetReturnValueObject(lldb::StackFrameSP &frame_sp, lldb::ValueObjectSP &new_value_sp) -{ - Error error; - if (!new_value_sp) - { - error.SetErrorString("Empty value object for return value."); - return error; - } - - CompilerType compiler_type = new_value_sp->GetCompilerType(); - if (!compiler_type) - { - error.SetErrorString ("Null clang type for return value."); - return error; +Error ABIMacOSX_arm::SetReturnValueObject(lldb::StackFrameSP &frame_sp, + lldb::ValueObjectSP &new_value_sp) { + Error error; + if (!new_value_sp) { + error.SetErrorString("Empty value object for return value."); + return error; + } + + CompilerType compiler_type = new_value_sp->GetCompilerType(); + if (!compiler_type) { + error.SetErrorString("Null clang type for return value."); + return error; + } + + Thread *thread = frame_sp->GetThread().get(); + + bool is_signed; + uint32_t count; + bool is_complex; + + RegisterContext *reg_ctx = thread->GetRegisterContext().get(); + + bool set_it_simple = false; + if (compiler_type.IsIntegerOrEnumerationType(is_signed) || + compiler_type.IsPointerType()) { + DataExtractor data; + Error data_error; + size_t num_bytes = new_value_sp->GetData(data, data_error); + if (data_error.Fail()) { + error.SetErrorStringWithFormat( + "Couldn't convert return value to raw data: %s", + data_error.AsCString()); + return error; } - - Thread *thread = frame_sp->GetThread().get(); - - bool is_signed; - uint32_t count; - bool is_complex; - - RegisterContext *reg_ctx = thread->GetRegisterContext().get(); - - bool set_it_simple = false; - if (compiler_type.IsIntegerOrEnumerationType (is_signed) || compiler_type.IsPointerType()) - { - DataExtractor data; - Error data_error; - size_t num_bytes = new_value_sp->GetData(data, data_error); - if (data_error.Fail()) - { - error.SetErrorStringWithFormat("Couldn't convert return value to raw data: %s", data_error.AsCString()); - return error; - } - lldb::offset_t offset = 0; - if (num_bytes <= 8) - { - const RegisterInfo *r0_info = reg_ctx->GetRegisterInfoByName("r0", 0); - if (num_bytes <= 4) - { - uint32_t raw_value = data.GetMaxU32(&offset, num_bytes); - - if (reg_ctx->WriteRegisterFromUnsigned (r0_info, raw_value)) - set_it_simple = true; - } - else - { - uint32_t raw_value = data.GetMaxU32(&offset, 4); - - if (reg_ctx->WriteRegisterFromUnsigned (r0_info, raw_value)) - { - const RegisterInfo *r1_info = reg_ctx->GetRegisterInfoByName("r1", 0); - uint32_t raw_value = data.GetMaxU32(&offset, num_bytes - offset); - - if (reg_ctx->WriteRegisterFromUnsigned (r1_info, raw_value)) - set_it_simple = true; - } - } + lldb::offset_t offset = 0; + if (num_bytes <= 8) { + const RegisterInfo *r0_info = reg_ctx->GetRegisterInfoByName("r0", 0); + if (num_bytes <= 4) { + uint32_t raw_value = data.GetMaxU32(&offset, num_bytes); + + if (reg_ctx->WriteRegisterFromUnsigned(r0_info, raw_value)) + set_it_simple = true; + } else { + uint32_t raw_value = data.GetMaxU32(&offset, 4); + + if (reg_ctx->WriteRegisterFromUnsigned(r0_info, raw_value)) { + const RegisterInfo *r1_info = reg_ctx->GetRegisterInfoByName("r1", 0); + uint32_t raw_value = data.GetMaxU32(&offset, num_bytes - offset); + + if (reg_ctx->WriteRegisterFromUnsigned(r1_info, raw_value)) + set_it_simple = true; } - else if (num_bytes <= 16 && IsArmv7kProcess (frame_sp->GetThread().get())) - { - // "A composite type not larger than 16 bytes is returned in r0-r3. The format is - // as if the result had been stored in memory at a word-aligned address and then - // loaded into r0-r3 with an ldm instruction" - - const RegisterInfo *r0_info = reg_ctx->GetRegisterInfoByName("r0", 0); - const RegisterInfo *r1_info = reg_ctx->GetRegisterInfoByName("r1", 0); - const RegisterInfo *r2_info = reg_ctx->GetRegisterInfoByName("r2", 0); - const RegisterInfo *r3_info = reg_ctx->GetRegisterInfoByName("r3", 0); - lldb::offset_t offset = 0; - uint32_t bytes_written = 4; - uint32_t raw_value = data.GetMaxU64(&offset, 4); - if (reg_ctx->WriteRegisterFromUnsigned (r0_info, raw_value) && bytes_written <= num_bytes) - { - bytes_written += 4; - raw_value = data.GetMaxU64(&offset, 4); - if (bytes_written <= num_bytes && reg_ctx->WriteRegisterFromUnsigned (r1_info, raw_value)) - { - bytes_written += 4; - raw_value = data.GetMaxU64(&offset, 4); - if (bytes_written <= num_bytes && reg_ctx->WriteRegisterFromUnsigned (r2_info, raw_value)) - { - bytes_written += 4; - raw_value = data.GetMaxU64(&offset, 4); - if (bytes_written <= num_bytes && reg_ctx->WriteRegisterFromUnsigned (r3_info, raw_value)) - { - set_it_simple = true; - } - } - } + } + } else if (num_bytes <= 16 && + IsArmv7kProcess(frame_sp->GetThread().get())) { + // "A composite type not larger than 16 bytes is returned in r0-r3. The + // format is + // as if the result had been stored in memory at a word-aligned address + // and then + // loaded into r0-r3 with an ldm instruction" + + const RegisterInfo *r0_info = reg_ctx->GetRegisterInfoByName("r0", 0); + const RegisterInfo *r1_info = reg_ctx->GetRegisterInfoByName("r1", 0); + const RegisterInfo *r2_info = reg_ctx->GetRegisterInfoByName("r2", 0); + const RegisterInfo *r3_info = reg_ctx->GetRegisterInfoByName("r3", 0); + lldb::offset_t offset = 0; + uint32_t bytes_written = 4; + uint32_t raw_value = data.GetMaxU64(&offset, 4); + if (reg_ctx->WriteRegisterFromUnsigned(r0_info, raw_value) && + bytes_written <= num_bytes) { + bytes_written += 4; + raw_value = data.GetMaxU64(&offset, 4); + if (bytes_written <= num_bytes && + reg_ctx->WriteRegisterFromUnsigned(r1_info, raw_value)) { + bytes_written += 4; + raw_value = data.GetMaxU64(&offset, 4); + if (bytes_written <= num_bytes && + reg_ctx->WriteRegisterFromUnsigned(r2_info, raw_value)) { + bytes_written += 4; + raw_value = data.GetMaxU64(&offset, 4); + if (bytes_written <= num_bytes && + reg_ctx->WriteRegisterFromUnsigned(r3_info, raw_value)) { + set_it_simple = true; } + } } - else - { - error.SetErrorString("We don't support returning longer than 64 bit integer values at present."); - } - } - else if (compiler_type.IsFloatingPointType (count, is_complex)) - { - if (is_complex) - error.SetErrorString ("We don't support returning complex values at present"); - else - error.SetErrorString ("We don't support returning float values at present"); + } + } else { + error.SetErrorString("We don't support returning longer than 64 bit " + "integer values at present."); } - - if (!set_it_simple) - error.SetErrorString ("We only support setting simple integer return types at present."); - - return error; + } else if (compiler_type.IsFloatingPointType(count, is_complex)) { + if (is_complex) + error.SetErrorString( + "We don't support returning complex values at present"); + else + error.SetErrorString( + "We don't support returning float values at present"); + } + + if (!set_it_simple) + error.SetErrorString( + "We only support setting simple integer return types at present."); + + return error; } -bool -ABIMacOSX_arm::CreateFunctionEntryUnwindPlan (UnwindPlan &unwind_plan) -{ - unwind_plan.Clear(); - unwind_plan.SetRegisterKind (eRegisterKindDWARF); - - uint32_t lr_reg_num = dwarf_lr; - uint32_t sp_reg_num = dwarf_sp; - uint32_t pc_reg_num = dwarf_pc; - - UnwindPlan::RowSP row(new UnwindPlan::Row); - - // Our Call Frame Address is the stack pointer value - row->GetCFAValue().SetIsRegisterPlusOffset (sp_reg_num, 0); - - // The previous PC is in the LR - row->SetRegisterLocationToRegister(pc_reg_num, lr_reg_num, true); - unwind_plan.AppendRow (row); - - // All other registers are the same. - - unwind_plan.SetSourceName ("arm at-func-entry default"); - unwind_plan.SetSourcedFromCompiler (eLazyBoolNo); - - return true; +bool ABIMacOSX_arm::CreateFunctionEntryUnwindPlan(UnwindPlan &unwind_plan) { + unwind_plan.Clear(); + unwind_plan.SetRegisterKind(eRegisterKindDWARF); + + uint32_t lr_reg_num = dwarf_lr; + uint32_t sp_reg_num = dwarf_sp; + uint32_t pc_reg_num = dwarf_pc; + + UnwindPlan::RowSP row(new UnwindPlan::Row); + + // Our Call Frame Address is the stack pointer value + row->GetCFAValue().SetIsRegisterPlusOffset(sp_reg_num, 0); + + // The previous PC is in the LR + row->SetRegisterLocationToRegister(pc_reg_num, lr_reg_num, true); + unwind_plan.AppendRow(row); + + // All other registers are the same. + + unwind_plan.SetSourceName("arm at-func-entry default"); + unwind_plan.SetSourcedFromCompiler(eLazyBoolNo); + + return true; } -bool -ABIMacOSX_arm::CreateDefaultUnwindPlan (UnwindPlan &unwind_plan) -{ - unwind_plan.Clear (); - unwind_plan.SetRegisterKind (eRegisterKindDWARF); - - uint32_t fp_reg_num = dwarf_r7; // apple uses r7 for all frames. Normal arm uses r11 - uint32_t pc_reg_num = dwarf_pc; - - UnwindPlan::RowSP row(new UnwindPlan::Row); - const int32_t ptr_size = 4; - - row->GetCFAValue().SetIsRegisterPlusOffset (fp_reg_num, 2 * ptr_size); - row->SetOffset (0); - - row->SetRegisterLocationToAtCFAPlusOffset(fp_reg_num, ptr_size * -2, true); - row->SetRegisterLocationToAtCFAPlusOffset(pc_reg_num, ptr_size * -1, true); - - unwind_plan.AppendRow (row); - unwind_plan.SetSourceName ("arm-apple-ios default unwind plan"); - unwind_plan.SetSourcedFromCompiler (eLazyBoolNo); - unwind_plan.SetUnwindPlanValidAtAllInstructions (eLazyBoolNo); - - return true; +bool ABIMacOSX_arm::CreateDefaultUnwindPlan(UnwindPlan &unwind_plan) { + unwind_plan.Clear(); + unwind_plan.SetRegisterKind(eRegisterKindDWARF); + + uint32_t fp_reg_num = + dwarf_r7; // apple uses r7 for all frames. Normal arm uses r11 + uint32_t pc_reg_num = dwarf_pc; + + UnwindPlan::RowSP row(new UnwindPlan::Row); + const int32_t ptr_size = 4; + + row->GetCFAValue().SetIsRegisterPlusOffset(fp_reg_num, 2 * ptr_size); + row->SetOffset(0); + + row->SetRegisterLocationToAtCFAPlusOffset(fp_reg_num, ptr_size * -2, true); + row->SetRegisterLocationToAtCFAPlusOffset(pc_reg_num, ptr_size * -1, true); + + unwind_plan.AppendRow(row); + unwind_plan.SetSourceName("arm-apple-ios default unwind plan"); + unwind_plan.SetSourcedFromCompiler(eLazyBoolNo); + unwind_plan.SetUnwindPlanValidAtAllInstructions(eLazyBoolNo); + + return true; } // cf. "ARMv6 Function Calling Conventions" @@ -748,7 +1869,8 @@ ABIMacOSX_arm::CreateDefaultUnwindPlan (UnwindPlan &unwind_plan) // r4-r6 preserved // r7 preserved (frame pointer) // r8 preserved -// r9 not preserved (usable as volatile scratch register with iOS 3.x and later) +// r9 not preserved (usable as volatile scratch register with iOS 3.x and +// later) // r10-r11 preserved // r12 not presrved // r13 preserved (stack pointer) @@ -761,211 +1883,181 @@ ABIMacOSX_arm::CreateDefaultUnwindPlan (UnwindPlan &unwind_plan) // d8-d15 preserved (aka s16-s31, q4-q7) // d16-d31 not preserved (aka q8-q15) -bool -ABIMacOSX_arm::RegisterIsVolatile (const RegisterInfo *reg_info) -{ - if (reg_info) - { - // Volatile registers are: r0, r1, r2, r3, r9, r12, r13 (aka sp) - const char *name = reg_info->name; - if (name[0] == 'r') - { - switch (name[1]) - { - case '0': return name[2] == '\0'; // r0 - case '1': - switch (name[2]) - { - case '\0': - return true; // r1 - case '2': - case '3': - return name[3] == '\0'; // r12, r13 (sp) - default: - break; - } - break; - - case '2': return name[2] == '\0'; // r2 - case '3': return name[2] == '\0'; // r3 - case '9': return name[2] == '\0'; // r9 (apple-ios only...) - - break; - } +bool ABIMacOSX_arm::RegisterIsVolatile(const RegisterInfo *reg_info) { + if (reg_info) { + // Volatile registers are: r0, r1, r2, r3, r9, r12, r13 (aka sp) + const char *name = reg_info->name; + if (name[0] == 'r') { + switch (name[1]) { + case '0': + return name[2] == '\0'; // r0 + case '1': + switch (name[2]) { + case '\0': + return true; // r1 + case '2': + case '3': + return name[3] == '\0'; // r12, r13 (sp) + default: + break; } - else if (name[0] == 'd') - { - switch (name[1]) - { - case '0': - return name[2] == '\0'; // d0 is volatile - - case '1': - switch (name[2]) - { - case '\0': - return true; // d1 is volatile - case '6': - case '7': - case '8': - case '9': - return name[3] == '\0'; // d16 - d19 are volatile - default: - break; - } - break; - - case '2': - switch (name[2]) - { - case '\0': - return true; // d2 is volatile - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - return name[3] == '\0'; // d20 - d29 are volatile - default: - break; - } - break; - - case '3': - switch (name[2]) - { - case '\0': - return true; // d3 is volatile - case '0': - case '1': - return name[3] == '\0'; // d30 - d31 are volatile - default: - break; - } - break; - case '4': - case '5': - case '6': - case '7': - return name[2] == '\0'; // d4 - d7 are volatile - - default: - break; - } + break; + + case '2': + return name[2] == '\0'; // r2 + case '3': + return name[2] == '\0'; // r3 + case '9': + return name[2] == '\0'; // r9 (apple-ios only...) + + break; + } + } else if (name[0] == 'd') { + switch (name[1]) { + case '0': + return name[2] == '\0'; // d0 is volatile + + case '1': + switch (name[2]) { + case '\0': + return true; // d1 is volatile + case '6': + case '7': + case '8': + case '9': + return name[3] == '\0'; // d16 - d19 are volatile + default: + break; } - else if (name[0] == 's') - { - switch (name[1]) - { - case '0': - return name[2] == '\0'; // s0 is volatile - - case '1': - switch (name[2]) - { - case '\0': - return true; // s1 is volatile - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - return name[3] == '\0'; // s10 - s15 are volatile - default: - break; - } - break; - - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - return name[2] == '\0'; // s2 - s9 are volatile - - default: - break; - } + break; + + case '2': + switch (name[2]) { + case '\0': + return true; // d2 is volatile + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + return name[3] == '\0'; // d20 - d29 are volatile + default: + break; } - else if (name[0] == 'q') - { - switch (name[1]) - { - case '1': - switch (name[2]) - { - case '\0': - return true; // q1 is volatile - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - return true; // q10-q15 are volatile - default: - break; - }; - break; - case '0': - case '2': - case '3': - return name[2] == '\0'; // q0-q3 are volatile - case '8': - case '9': - return name[2] == '\0'; // q8-q9 are volatile - default: - break; - } + break; + + case '3': + switch (name[2]) { + case '\0': + return true; // d3 is volatile + case '0': + case '1': + return name[3] == '\0'; // d30 - d31 are volatile + default: + break; } - else if (name[0] == 's' && name[1] == 'p' && name[2] == '\0') - return true; - } - return false; + break; + case '4': + case '5': + case '6': + case '7': + return name[2] == '\0'; // d4 - d7 are volatile + + default: + break; + } + } else if (name[0] == 's') { + switch (name[1]) { + case '0': + return name[2] == '\0'; // s0 is volatile + + case '1': + switch (name[2]) { + case '\0': + return true; // s1 is volatile + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + return name[3] == '\0'; // s10 - s15 are volatile + default: + break; + } + break; + + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + return name[2] == '\0'; // s2 - s9 are volatile + + default: + break; + } + } else if (name[0] == 'q') { + switch (name[1]) { + case '1': + switch (name[2]) { + case '\0': + return true; // q1 is volatile + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + return true; // q10-q15 are volatile + default: + break; + }; + break; + case '0': + case '2': + case '3': + return name[2] == '\0'; // q0-q3 are volatile + case '8': + case '9': + return name[2] == '\0'; // q8-q9 are volatile + default: + break; + } + } else if (name[0] == 's' && name[1] == 'p' && name[2] == '\0') + return true; + } + return false; } -void -ABIMacOSX_arm::Initialize() -{ - PluginManager::RegisterPlugin (GetPluginNameStatic(), - "Mac OS X ABI for arm targets", - CreateInstance); +void ABIMacOSX_arm::Initialize() { + PluginManager::RegisterPlugin(GetPluginNameStatic(), + "Mac OS X ABI for arm targets", CreateInstance); } -void -ABIMacOSX_arm::Terminate() -{ - PluginManager::UnregisterPlugin (CreateInstance); +void ABIMacOSX_arm::Terminate() { + PluginManager::UnregisterPlugin(CreateInstance); } -lldb_private::ConstString -ABIMacOSX_arm::GetPluginNameStatic() -{ - static ConstString g_name("macosx-arm"); - return g_name; +lldb_private::ConstString ABIMacOSX_arm::GetPluginNameStatic() { + static ConstString g_name("macosx-arm"); + return g_name; } //------------------------------------------------------------------ // PluginInterface protocol //------------------------------------------------------------------ -lldb_private::ConstString -ABIMacOSX_arm::GetPluginName() -{ - return GetPluginNameStatic(); +lldb_private::ConstString ABIMacOSX_arm::GetPluginName() { + return GetPluginNameStatic(); } -uint32_t -ABIMacOSX_arm::GetPluginVersion() -{ - return 1; -} +uint32_t ABIMacOSX_arm::GetPluginVersion() { return 1; } diff --git a/source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.h b/source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.h index a4e9dead7794..39f57a0c5ee2 100644 --- a/source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.h +++ b/source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.h @@ -14,111 +14,89 @@ // C++ Includes // Other libraries and framework includes // Project includes -#include "lldb/lldb-private.h" #include "lldb/Target/ABI.h" +#include "lldb/lldb-private.h" -class ABIMacOSX_arm : public lldb_private::ABI -{ +class ABIMacOSX_arm : public lldb_private::ABI { public: - ~ABIMacOSX_arm() override = default; - - size_t - GetRedZoneSize() const override; - - bool - PrepareTrivialCall(lldb_private::Thread &thread, - lldb::addr_t sp, - lldb::addr_t func_addr, - lldb::addr_t returnAddress, - llvm::ArrayRef<lldb::addr_t> args) const override; - - bool - GetArgumentValues(lldb_private::Thread &thread, - lldb_private::ValueList &values) const override; - - lldb_private::Error - SetReturnValueObject(lldb::StackFrameSP &frame_sp, lldb::ValueObjectSP &new_value) override; - - bool - CreateFunctionEntryUnwindPlan(lldb_private::UnwindPlan &unwind_plan) override; - - bool - CreateDefaultUnwindPlan(lldb_private::UnwindPlan &unwind_plan) override; - - bool - RegisterIsVolatile(const lldb_private::RegisterInfo *reg_info) override; - - bool - CallFrameAddressIsValid(lldb::addr_t cfa) override - { - // Make sure the stack call frame addresses are are 4 byte aligned - if (cfa & (4ull - 1ull)) - return false; // Not 4 byte aligned - if (cfa == 0) - return false; // Zero is not a valid stack address - return true; - } - - bool - CodeAddressIsValid(lldb::addr_t pc) override - { - // Just make sure the address is a valid 32 bit address. Bit zero - // might be set due to Thumb function calls, so don't enforce 2 byte - // alignment - return pc <= UINT32_MAX; - } - - lldb::addr_t - FixCodeAddress(lldb::addr_t pc) override - { - // ARM uses bit zero to signify a code address is thumb, so we must - // strip bit zero in any code addresses. - return pc & ~(lldb::addr_t)1; - } - - const lldb_private::RegisterInfo * - GetRegisterInfoArray(uint32_t &count) override; - - bool - IsArmv7kProcess (lldb_private::Thread *thread) const; - - //------------------------------------------------------------------ - // Static Functions - //------------------------------------------------------------------ - - static void - Initialize(); - - static void - Terminate(); - - static lldb::ABISP - CreateInstance (const lldb_private::ArchSpec &arch); - - static lldb_private::ConstString - GetPluginNameStatic(); - - //------------------------------------------------------------------ - // PluginInterface protocol - //------------------------------------------------------------------ - - lldb_private::ConstString - GetPluginName() override; - - uint32_t - GetPluginVersion() override; - + ~ABIMacOSX_arm() override = default; + + size_t GetRedZoneSize() const override; + + bool PrepareTrivialCall(lldb_private::Thread &thread, lldb::addr_t sp, + lldb::addr_t func_addr, lldb::addr_t returnAddress, + llvm::ArrayRef<lldb::addr_t> args) const override; + + bool GetArgumentValues(lldb_private::Thread &thread, + lldb_private::ValueList &values) const override; + + lldb_private::Error + SetReturnValueObject(lldb::StackFrameSP &frame_sp, + lldb::ValueObjectSP &new_value) override; + + bool + CreateFunctionEntryUnwindPlan(lldb_private::UnwindPlan &unwind_plan) override; + + bool CreateDefaultUnwindPlan(lldb_private::UnwindPlan &unwind_plan) override; + + bool RegisterIsVolatile(const lldb_private::RegisterInfo *reg_info) override; + + bool CallFrameAddressIsValid(lldb::addr_t cfa) override { + // Make sure the stack call frame addresses are are 4 byte aligned + if (cfa & (4ull - 1ull)) + return false; // Not 4 byte aligned + if (cfa == 0) + return false; // Zero is not a valid stack address + return true; + } + + bool CodeAddressIsValid(lldb::addr_t pc) override { + // Just make sure the address is a valid 32 bit address. Bit zero + // might be set due to Thumb function calls, so don't enforce 2 byte + // alignment + return pc <= UINT32_MAX; + } + + lldb::addr_t FixCodeAddress(lldb::addr_t pc) override { + // ARM uses bit zero to signify a code address is thumb, so we must + // strip bit zero in any code addresses. + return pc & ~(lldb::addr_t)1; + } + + const lldb_private::RegisterInfo * + GetRegisterInfoArray(uint32_t &count) override; + + bool IsArmv7kProcess(lldb_private::Thread *thread) const; + + //------------------------------------------------------------------ + // Static Functions + //------------------------------------------------------------------ + + static void Initialize(); + + static void Terminate(); + + static lldb::ABISP CreateInstance(const lldb_private::ArchSpec &arch); + + static lldb_private::ConstString GetPluginNameStatic(); + + //------------------------------------------------------------------ + // PluginInterface protocol + //------------------------------------------------------------------ + + lldb_private::ConstString GetPluginName() override; + + uint32_t GetPluginVersion() override; + protected: - lldb::ValueObjectSP - GetReturnValueObjectImpl(lldb_private::Thread &thread, - lldb_private::CompilerType &ast_type) const override; + lldb::ValueObjectSP + GetReturnValueObjectImpl(lldb_private::Thread &thread, + lldb_private::CompilerType &ast_type) const override; private: - ABIMacOSX_arm() : - lldb_private::ABI() - { - // Call CreateInstance instead. - } + ABIMacOSX_arm() : lldb_private::ABI() { + // Call CreateInstance instead. + } }; #endif // liblldb_ABIMacOSX_arm_h_ diff --git a/source/Plugins/ABI/MacOSX-arm64/ABIMacOSX_arm64.cpp b/source/Plugins/ABI/MacOSX-arm64/ABIMacOSX_arm64.cpp index ad3d8cb03b86..ee27a7e8d9b3 100644 --- a/source/Plugins/ABI/MacOSX-arm64/ABIMacOSX_arm64.cpp +++ b/source/Plugins/ABI/MacOSX-arm64/ABIMacOSX_arm64.cpp @@ -40,1062 +40,2414 @@ using namespace lldb_private; static const char *pluginDesc = "Mac OS X ABI for arm64 targets"; -static RegisterInfo g_register_infos[] = -{ - // NAME ALT SZ OFF ENCODING FORMAT EH_FRAME DWARF GENERIC PROCESS PLUGIN LLDB NATIVE - // ========== ======= == === ============= =================== =================== ====================== =========================== ======================= ====================== - { "x0", nullptr, 8, 0, eEncodingUint , eFormatHex , { LLDB_INVALID_REGNUM, arm64_dwarf::x0, LLDB_REGNUM_GENERIC_ARG1, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "x1", nullptr, 8, 0, eEncodingUint , eFormatHex , { LLDB_INVALID_REGNUM, arm64_dwarf::x1, LLDB_REGNUM_GENERIC_ARG2, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "x2", nullptr, 8, 0, eEncodingUint , eFormatHex , { LLDB_INVALID_REGNUM, arm64_dwarf::x2, LLDB_REGNUM_GENERIC_ARG3, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "x3", nullptr, 8, 0, eEncodingUint , eFormatHex , { LLDB_INVALID_REGNUM, arm64_dwarf::x3, LLDB_REGNUM_GENERIC_ARG4, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "x4", nullptr, 8, 0, eEncodingUint , eFormatHex , { LLDB_INVALID_REGNUM, arm64_dwarf::x4, LLDB_REGNUM_GENERIC_ARG5, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "x5", nullptr, 8, 0, eEncodingUint , eFormatHex , { LLDB_INVALID_REGNUM, arm64_dwarf::x5, LLDB_REGNUM_GENERIC_ARG6, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "x6", nullptr, 8, 0, eEncodingUint , eFormatHex , { LLDB_INVALID_REGNUM, arm64_dwarf::x6, LLDB_REGNUM_GENERIC_ARG7, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "x7", nullptr, 8, 0, eEncodingUint , eFormatHex , { LLDB_INVALID_REGNUM, arm64_dwarf::x7, LLDB_REGNUM_GENERIC_ARG8, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "x8", nullptr, 8, 0, eEncodingUint , eFormatHex , { LLDB_INVALID_REGNUM, arm64_dwarf::x8, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "x9", nullptr, 8, 0, eEncodingUint , eFormatHex , { LLDB_INVALID_REGNUM, arm64_dwarf::x9, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "x10", nullptr, 8, 0, eEncodingUint , eFormatHex , { LLDB_INVALID_REGNUM, arm64_dwarf::x10, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "x11", nullptr, 8, 0, eEncodingUint , eFormatHex , { LLDB_INVALID_REGNUM, arm64_dwarf::x11, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "x12", nullptr, 8, 0, eEncodingUint , eFormatHex , { LLDB_INVALID_REGNUM, arm64_dwarf::x12, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "x13", nullptr, 8, 0, eEncodingUint , eFormatHex , { LLDB_INVALID_REGNUM, arm64_dwarf::x13, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "x14", nullptr, 8, 0, eEncodingUint , eFormatHex , { LLDB_INVALID_REGNUM, arm64_dwarf::x14, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "x15", nullptr, 8, 0, eEncodingUint , eFormatHex , { LLDB_INVALID_REGNUM, arm64_dwarf::x15, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "x16", nullptr, 8, 0, eEncodingUint , eFormatHex , { LLDB_INVALID_REGNUM, arm64_dwarf::x16, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "x17", nullptr, 8, 0, eEncodingUint , eFormatHex , { LLDB_INVALID_REGNUM, arm64_dwarf::x17, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "x18", nullptr, 8, 0, eEncodingUint , eFormatHex , { LLDB_INVALID_REGNUM, arm64_dwarf::x18, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "x19", nullptr, 8, 0, eEncodingUint , eFormatHex , { LLDB_INVALID_REGNUM, arm64_dwarf::x19, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "x20", nullptr, 8, 0, eEncodingUint , eFormatHex , { LLDB_INVALID_REGNUM, arm64_dwarf::x20, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "x21", nullptr, 8, 0, eEncodingUint , eFormatHex , { LLDB_INVALID_REGNUM, arm64_dwarf::x21, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "x22", nullptr, 8, 0, eEncodingUint , eFormatHex , { LLDB_INVALID_REGNUM, arm64_dwarf::x22, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "x23", nullptr, 8, 0, eEncodingUint , eFormatHex , { LLDB_INVALID_REGNUM, arm64_dwarf::x23, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "x24", nullptr, 8, 0, eEncodingUint , eFormatHex , { LLDB_INVALID_REGNUM, arm64_dwarf::x24, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "x25", nullptr, 8, 0, eEncodingUint , eFormatHex , { LLDB_INVALID_REGNUM, arm64_dwarf::x25, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "x26", nullptr, 8, 0, eEncodingUint , eFormatHex , { LLDB_INVALID_REGNUM, arm64_dwarf::x26, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "x27", nullptr, 8, 0, eEncodingUint , eFormatHex , { LLDB_INVALID_REGNUM, arm64_dwarf::x27, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "x28", nullptr, 8, 0, eEncodingUint , eFormatHex , { LLDB_INVALID_REGNUM, arm64_dwarf::x28, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "fp", "x29", 8, 0, eEncodingUint , eFormatHex , { LLDB_INVALID_REGNUM, arm64_dwarf::x29, LLDB_REGNUM_GENERIC_FP, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "lr", "x30", 8, 0, eEncodingUint , eFormatHex , { LLDB_INVALID_REGNUM, arm64_dwarf::x30, LLDB_REGNUM_GENERIC_RA, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "sp", "x31", 8, 0, eEncodingUint , eFormatHex , { LLDB_INVALID_REGNUM, arm64_dwarf::x31, LLDB_REGNUM_GENERIC_SP, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "pc", nullptr, 8, 0, eEncodingUint , eFormatHex , { LLDB_INVALID_REGNUM, arm64_dwarf::pc, LLDB_REGNUM_GENERIC_PC, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "cpsr", "psr", 4, 0, eEncodingUint , eFormatHex , { LLDB_INVALID_REGNUM, arm64_dwarf::cpsr, LLDB_REGNUM_GENERIC_FLAGS, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - - { "v0", nullptr, 16, 0, eEncodingVector , eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM, arm64_dwarf::v0, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "v1", nullptr, 16, 0, eEncodingVector , eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM, arm64_dwarf::v1, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "v2", nullptr, 16, 0, eEncodingVector , eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM, arm64_dwarf::v2, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "v3", nullptr, 16, 0, eEncodingVector , eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM, arm64_dwarf::v3, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "v4", nullptr, 16, 0, eEncodingVector , eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM, arm64_dwarf::v4, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "v5", nullptr, 16, 0, eEncodingVector , eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM, arm64_dwarf::v5, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "v6", nullptr, 16, 0, eEncodingVector , eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM, arm64_dwarf::v6, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "v7", nullptr, 16, 0, eEncodingVector , eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM, arm64_dwarf::v7, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "v8", nullptr, 16, 0, eEncodingVector , eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM, arm64_dwarf::v8, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "v9", nullptr, 16, 0, eEncodingVector , eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM, arm64_dwarf::v9, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "v10", nullptr, 16, 0, eEncodingVector , eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM, arm64_dwarf::v10, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "v11", nullptr, 16, 0, eEncodingVector , eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM, arm64_dwarf::v11, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "v12", nullptr, 16, 0, eEncodingVector , eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM, arm64_dwarf::v12, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "v13", nullptr, 16, 0, eEncodingVector , eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM, arm64_dwarf::v13, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "v14", nullptr, 16, 0, eEncodingVector , eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM, arm64_dwarf::v14, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "v15", nullptr, 16, 0, eEncodingVector , eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM, arm64_dwarf::v15, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "v16", nullptr, 16, 0, eEncodingVector , eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM, arm64_dwarf::v16, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "v17", nullptr, 16, 0, eEncodingVector , eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM, arm64_dwarf::v17, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "v18", nullptr, 16, 0, eEncodingVector , eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM, arm64_dwarf::v18, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "v19", nullptr, 16, 0, eEncodingVector , eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM, arm64_dwarf::v19, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "v20", nullptr, 16, 0, eEncodingVector , eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM, arm64_dwarf::v20, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "v21", nullptr, 16, 0, eEncodingVector , eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM, arm64_dwarf::v21, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "v22", nullptr, 16, 0, eEncodingVector , eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM, arm64_dwarf::v22, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "v23", nullptr, 16, 0, eEncodingVector , eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM, arm64_dwarf::v23, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "v24", nullptr, 16, 0, eEncodingVector , eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM, arm64_dwarf::v24, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "v25", nullptr, 16, 0, eEncodingVector , eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM, arm64_dwarf::v25, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "v26", nullptr, 16, 0, eEncodingVector , eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM, arm64_dwarf::v26, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "v27", nullptr, 16, 0, eEncodingVector , eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM, arm64_dwarf::v27, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "v28", nullptr, 16, 0, eEncodingVector , eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM, arm64_dwarf::v28, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "v29", nullptr, 16, 0, eEncodingVector , eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM, arm64_dwarf::v29, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "v30", nullptr, 16, 0, eEncodingVector , eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM, arm64_dwarf::v30, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "v31", nullptr, 16, 0, eEncodingVector , eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM, arm64_dwarf::v31, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - - { "fpsr", nullptr, 4, 0, eEncodingUint , eFormatHex , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "fpcr", nullptr, 4, 0, eEncodingUint , eFormatHex , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - - { "s0", nullptr, 4, 0, eEncodingIEEE754 , eFormatFloat , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "s1", nullptr, 4, 0, eEncodingIEEE754 , eFormatFloat , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "s2", nullptr, 4, 0, eEncodingIEEE754 , eFormatFloat , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "s3", nullptr, 4, 0, eEncodingIEEE754 , eFormatFloat , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "s4", nullptr, 4, 0, eEncodingIEEE754 , eFormatFloat , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "s5", nullptr, 4, 0, eEncodingIEEE754 , eFormatFloat , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "s6", nullptr, 4, 0, eEncodingIEEE754 , eFormatFloat , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "s7", nullptr, 4, 0, eEncodingIEEE754 , eFormatFloat , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "s8", nullptr, 4, 0, eEncodingIEEE754 , eFormatFloat , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "s9", nullptr, 4, 0, eEncodingIEEE754 , eFormatFloat , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "s10", nullptr, 4, 0, eEncodingIEEE754 , eFormatFloat , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "s11", nullptr, 4, 0, eEncodingIEEE754 , eFormatFloat , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "s12", nullptr, 4, 0, eEncodingIEEE754 , eFormatFloat , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "s13", nullptr, 4, 0, eEncodingIEEE754 , eFormatFloat , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "s14", nullptr, 4, 0, eEncodingIEEE754 , eFormatFloat , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "s15", nullptr, 4, 0, eEncodingIEEE754 , eFormatFloat , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "s16", nullptr, 4, 0, eEncodingIEEE754 , eFormatFloat , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "s17", nullptr, 4, 0, eEncodingIEEE754 , eFormatFloat , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "s18", nullptr, 4, 0, eEncodingIEEE754 , eFormatFloat , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "s19", nullptr, 4, 0, eEncodingIEEE754 , eFormatFloat , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "s20", nullptr, 4, 0, eEncodingIEEE754 , eFormatFloat , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "s21", nullptr, 4, 0, eEncodingIEEE754 , eFormatFloat , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "s22", nullptr, 4, 0, eEncodingIEEE754 , eFormatFloat , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "s23", nullptr, 4, 0, eEncodingIEEE754 , eFormatFloat , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "s24", nullptr, 4, 0, eEncodingIEEE754 , eFormatFloat , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "s25", nullptr, 4, 0, eEncodingIEEE754 , eFormatFloat , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "s26", nullptr, 4, 0, eEncodingIEEE754 , eFormatFloat , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "s27", nullptr, 4, 0, eEncodingIEEE754 , eFormatFloat , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "s28", nullptr, 4, 0, eEncodingIEEE754 , eFormatFloat , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "s29", nullptr, 4, 0, eEncodingIEEE754 , eFormatFloat , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "s30", nullptr, 4, 0, eEncodingIEEE754 , eFormatFloat , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "s31", nullptr, 4, 0, eEncodingIEEE754 , eFormatFloat , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - - { "d0", nullptr, 8, 0, eEncodingIEEE754 , eFormatFloat , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "d1", nullptr, 8, 0, eEncodingIEEE754 , eFormatFloat , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "d2", nullptr, 8, 0, eEncodingIEEE754 , eFormatFloat , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "d3", nullptr, 8, 0, eEncodingIEEE754 , eFormatFloat , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "d4", nullptr, 8, 0, eEncodingIEEE754 , eFormatFloat , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "d5", nullptr, 8, 0, eEncodingIEEE754 , eFormatFloat , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "d6", nullptr, 8, 0, eEncodingIEEE754 , eFormatFloat , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "d7", nullptr, 8, 0, eEncodingIEEE754 , eFormatFloat , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "d8", nullptr, 8, 0, eEncodingIEEE754 , eFormatFloat , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "d9", nullptr, 8, 0, eEncodingIEEE754 , eFormatFloat , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "d10", nullptr, 8, 0, eEncodingIEEE754 , eFormatFloat , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "d11", nullptr, 8, 0, eEncodingIEEE754 , eFormatFloat , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "d12", nullptr, 8, 0, eEncodingIEEE754 , eFormatFloat , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "d13", nullptr, 8, 0, eEncodingIEEE754 , eFormatFloat , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "d14", nullptr, 8, 0, eEncodingIEEE754 , eFormatFloat , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "d15", nullptr, 8, 0, eEncodingIEEE754 , eFormatFloat , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "d16", nullptr, 8, 0, eEncodingIEEE754 , eFormatFloat , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "d17", nullptr, 8, 0, eEncodingIEEE754 , eFormatFloat , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "d18", nullptr, 8, 0, eEncodingIEEE754 , eFormatFloat , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "d19", nullptr, 8, 0, eEncodingIEEE754 , eFormatFloat , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "d20", nullptr, 8, 0, eEncodingIEEE754 , eFormatFloat , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "d21", nullptr, 8, 0, eEncodingIEEE754 , eFormatFloat , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "d22", nullptr, 8, 0, eEncodingIEEE754 , eFormatFloat , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "d23", nullptr, 8, 0, eEncodingIEEE754 , eFormatFloat , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "d24", nullptr, 8, 0, eEncodingIEEE754 , eFormatFloat , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "d25", nullptr, 8, 0, eEncodingIEEE754 , eFormatFloat , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "d26", nullptr, 8, 0, eEncodingIEEE754 , eFormatFloat , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "d27", nullptr, 8, 0, eEncodingIEEE754 , eFormatFloat , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "d28", nullptr, 8, 0, eEncodingIEEE754 , eFormatFloat , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "d29", nullptr, 8, 0, eEncodingIEEE754 , eFormatFloat , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "d30", nullptr, 8, 0, eEncodingIEEE754 , eFormatFloat , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "d31", nullptr, 8, 0, eEncodingIEEE754 , eFormatFloat , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr } -}; - -static const uint32_t k_num_register_infos = llvm::array_lengthof(g_register_infos); +static RegisterInfo g_register_infos[] = { + // NAME ALT SZ OFF ENCODING FORMAT + // EH_FRAME DWARF GENERIC + // PROCESS PLUGIN LLDB NATIVE + // ========== ======= == === ============= =================== + // =================== ====================== =========================== + // ======================= ====================== + {"x0", + nullptr, + 8, + 0, + eEncodingUint, + eFormatHex, + {LLDB_INVALID_REGNUM, arm64_dwarf::x0, LLDB_REGNUM_GENERIC_ARG1, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"x1", + nullptr, + 8, + 0, + eEncodingUint, + eFormatHex, + {LLDB_INVALID_REGNUM, arm64_dwarf::x1, LLDB_REGNUM_GENERIC_ARG2, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"x2", + nullptr, + 8, + 0, + eEncodingUint, + eFormatHex, + {LLDB_INVALID_REGNUM, arm64_dwarf::x2, LLDB_REGNUM_GENERIC_ARG3, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"x3", + nullptr, + 8, + 0, + eEncodingUint, + eFormatHex, + {LLDB_INVALID_REGNUM, arm64_dwarf::x3, LLDB_REGNUM_GENERIC_ARG4, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"x4", + nullptr, + 8, + 0, + eEncodingUint, + eFormatHex, + {LLDB_INVALID_REGNUM, arm64_dwarf::x4, LLDB_REGNUM_GENERIC_ARG5, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"x5", + nullptr, + 8, + 0, + eEncodingUint, + eFormatHex, + {LLDB_INVALID_REGNUM, arm64_dwarf::x5, LLDB_REGNUM_GENERIC_ARG6, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"x6", + nullptr, + 8, + 0, + eEncodingUint, + eFormatHex, + {LLDB_INVALID_REGNUM, arm64_dwarf::x6, LLDB_REGNUM_GENERIC_ARG7, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"x7", + nullptr, + 8, + 0, + eEncodingUint, + eFormatHex, + {LLDB_INVALID_REGNUM, arm64_dwarf::x7, LLDB_REGNUM_GENERIC_ARG8, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"x8", + nullptr, + 8, + 0, + eEncodingUint, + eFormatHex, + {LLDB_INVALID_REGNUM, arm64_dwarf::x8, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"x9", + nullptr, + 8, + 0, + eEncodingUint, + eFormatHex, + {LLDB_INVALID_REGNUM, arm64_dwarf::x9, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"x10", + nullptr, + 8, + 0, + eEncodingUint, + eFormatHex, + {LLDB_INVALID_REGNUM, arm64_dwarf::x10, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"x11", + nullptr, + 8, + 0, + eEncodingUint, + eFormatHex, + {LLDB_INVALID_REGNUM, arm64_dwarf::x11, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"x12", + nullptr, + 8, + 0, + eEncodingUint, + eFormatHex, + {LLDB_INVALID_REGNUM, arm64_dwarf::x12, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"x13", + nullptr, + 8, + 0, + eEncodingUint, + eFormatHex, + {LLDB_INVALID_REGNUM, arm64_dwarf::x13, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"x14", + nullptr, + 8, + 0, + eEncodingUint, + eFormatHex, + {LLDB_INVALID_REGNUM, arm64_dwarf::x14, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"x15", + nullptr, + 8, + 0, + eEncodingUint, + eFormatHex, + {LLDB_INVALID_REGNUM, arm64_dwarf::x15, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"x16", + nullptr, + 8, + 0, + eEncodingUint, + eFormatHex, + {LLDB_INVALID_REGNUM, arm64_dwarf::x16, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"x17", + nullptr, + 8, + 0, + eEncodingUint, + eFormatHex, + {LLDB_INVALID_REGNUM, arm64_dwarf::x17, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"x18", + nullptr, + 8, + 0, + eEncodingUint, + eFormatHex, + {LLDB_INVALID_REGNUM, arm64_dwarf::x18, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"x19", + nullptr, + 8, + 0, + eEncodingUint, + eFormatHex, + {LLDB_INVALID_REGNUM, arm64_dwarf::x19, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"x20", + nullptr, + 8, + 0, + eEncodingUint, + eFormatHex, + {LLDB_INVALID_REGNUM, arm64_dwarf::x20, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"x21", + nullptr, + 8, + 0, + eEncodingUint, + eFormatHex, + {LLDB_INVALID_REGNUM, arm64_dwarf::x21, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"x22", + nullptr, + 8, + 0, + eEncodingUint, + eFormatHex, + {LLDB_INVALID_REGNUM, arm64_dwarf::x22, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"x23", + nullptr, + 8, + 0, + eEncodingUint, + eFormatHex, + {LLDB_INVALID_REGNUM, arm64_dwarf::x23, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"x24", + nullptr, + 8, + 0, + eEncodingUint, + eFormatHex, + {LLDB_INVALID_REGNUM, arm64_dwarf::x24, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"x25", + nullptr, + 8, + 0, + eEncodingUint, + eFormatHex, + {LLDB_INVALID_REGNUM, arm64_dwarf::x25, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"x26", + nullptr, + 8, + 0, + eEncodingUint, + eFormatHex, + {LLDB_INVALID_REGNUM, arm64_dwarf::x26, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"x27", + nullptr, + 8, + 0, + eEncodingUint, + eFormatHex, + {LLDB_INVALID_REGNUM, arm64_dwarf::x27, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"x28", + nullptr, + 8, + 0, + eEncodingUint, + eFormatHex, + {LLDB_INVALID_REGNUM, arm64_dwarf::x28, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"fp", + "x29", + 8, + 0, + eEncodingUint, + eFormatHex, + {LLDB_INVALID_REGNUM, arm64_dwarf::x29, LLDB_REGNUM_GENERIC_FP, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"lr", + "x30", + 8, + 0, + eEncodingUint, + eFormatHex, + {LLDB_INVALID_REGNUM, arm64_dwarf::x30, LLDB_REGNUM_GENERIC_RA, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"sp", + "x31", + 8, + 0, + eEncodingUint, + eFormatHex, + {LLDB_INVALID_REGNUM, arm64_dwarf::x31, LLDB_REGNUM_GENERIC_SP, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"pc", + nullptr, + 8, + 0, + eEncodingUint, + eFormatHex, + {LLDB_INVALID_REGNUM, arm64_dwarf::pc, LLDB_REGNUM_GENERIC_PC, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"cpsr", + "psr", + 4, + 0, + eEncodingUint, + eFormatHex, + {LLDB_INVALID_REGNUM, arm64_dwarf::cpsr, LLDB_REGNUM_GENERIC_FLAGS, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + + {"v0", + nullptr, + 16, + 0, + eEncodingVector, + eFormatVectorOfUInt8, + {LLDB_INVALID_REGNUM, arm64_dwarf::v0, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"v1", + nullptr, + 16, + 0, + eEncodingVector, + eFormatVectorOfUInt8, + {LLDB_INVALID_REGNUM, arm64_dwarf::v1, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"v2", + nullptr, + 16, + 0, + eEncodingVector, + eFormatVectorOfUInt8, + {LLDB_INVALID_REGNUM, arm64_dwarf::v2, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"v3", + nullptr, + 16, + 0, + eEncodingVector, + eFormatVectorOfUInt8, + {LLDB_INVALID_REGNUM, arm64_dwarf::v3, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"v4", + nullptr, + 16, + 0, + eEncodingVector, + eFormatVectorOfUInt8, + {LLDB_INVALID_REGNUM, arm64_dwarf::v4, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"v5", + nullptr, + 16, + 0, + eEncodingVector, + eFormatVectorOfUInt8, + {LLDB_INVALID_REGNUM, arm64_dwarf::v5, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"v6", + nullptr, + 16, + 0, + eEncodingVector, + eFormatVectorOfUInt8, + {LLDB_INVALID_REGNUM, arm64_dwarf::v6, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"v7", + nullptr, + 16, + 0, + eEncodingVector, + eFormatVectorOfUInt8, + {LLDB_INVALID_REGNUM, arm64_dwarf::v7, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"v8", + nullptr, + 16, + 0, + eEncodingVector, + eFormatVectorOfUInt8, + {LLDB_INVALID_REGNUM, arm64_dwarf::v8, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"v9", + nullptr, + 16, + 0, + eEncodingVector, + eFormatVectorOfUInt8, + {LLDB_INVALID_REGNUM, arm64_dwarf::v9, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"v10", + nullptr, + 16, + 0, + eEncodingVector, + eFormatVectorOfUInt8, + {LLDB_INVALID_REGNUM, arm64_dwarf::v10, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"v11", + nullptr, + 16, + 0, + eEncodingVector, + eFormatVectorOfUInt8, + {LLDB_INVALID_REGNUM, arm64_dwarf::v11, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"v12", + nullptr, + 16, + 0, + eEncodingVector, + eFormatVectorOfUInt8, + {LLDB_INVALID_REGNUM, arm64_dwarf::v12, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"v13", + nullptr, + 16, + 0, + eEncodingVector, + eFormatVectorOfUInt8, + {LLDB_INVALID_REGNUM, arm64_dwarf::v13, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"v14", + nullptr, + 16, + 0, + eEncodingVector, + eFormatVectorOfUInt8, + {LLDB_INVALID_REGNUM, arm64_dwarf::v14, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"v15", + nullptr, + 16, + 0, + eEncodingVector, + eFormatVectorOfUInt8, + {LLDB_INVALID_REGNUM, arm64_dwarf::v15, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"v16", + nullptr, + 16, + 0, + eEncodingVector, + eFormatVectorOfUInt8, + {LLDB_INVALID_REGNUM, arm64_dwarf::v16, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"v17", + nullptr, + 16, + 0, + eEncodingVector, + eFormatVectorOfUInt8, + {LLDB_INVALID_REGNUM, arm64_dwarf::v17, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"v18", + nullptr, + 16, + 0, + eEncodingVector, + eFormatVectorOfUInt8, + {LLDB_INVALID_REGNUM, arm64_dwarf::v18, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"v19", + nullptr, + 16, + 0, + eEncodingVector, + eFormatVectorOfUInt8, + {LLDB_INVALID_REGNUM, arm64_dwarf::v19, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"v20", + nullptr, + 16, + 0, + eEncodingVector, + eFormatVectorOfUInt8, + {LLDB_INVALID_REGNUM, arm64_dwarf::v20, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"v21", + nullptr, + 16, + 0, + eEncodingVector, + eFormatVectorOfUInt8, + {LLDB_INVALID_REGNUM, arm64_dwarf::v21, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"v22", + nullptr, + 16, + 0, + eEncodingVector, + eFormatVectorOfUInt8, + {LLDB_INVALID_REGNUM, arm64_dwarf::v22, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"v23", + nullptr, + 16, + 0, + eEncodingVector, + eFormatVectorOfUInt8, + {LLDB_INVALID_REGNUM, arm64_dwarf::v23, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"v24", + nullptr, + 16, + 0, + eEncodingVector, + eFormatVectorOfUInt8, + {LLDB_INVALID_REGNUM, arm64_dwarf::v24, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"v25", + nullptr, + 16, + 0, + eEncodingVector, + eFormatVectorOfUInt8, + {LLDB_INVALID_REGNUM, arm64_dwarf::v25, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"v26", + nullptr, + 16, + 0, + eEncodingVector, + eFormatVectorOfUInt8, + {LLDB_INVALID_REGNUM, arm64_dwarf::v26, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"v27", + nullptr, + 16, + 0, + eEncodingVector, + eFormatVectorOfUInt8, + {LLDB_INVALID_REGNUM, arm64_dwarf::v27, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"v28", + nullptr, + 16, + 0, + eEncodingVector, + eFormatVectorOfUInt8, + {LLDB_INVALID_REGNUM, arm64_dwarf::v28, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"v29", + nullptr, + 16, + 0, + eEncodingVector, + eFormatVectorOfUInt8, + {LLDB_INVALID_REGNUM, arm64_dwarf::v29, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"v30", + nullptr, + 16, + 0, + eEncodingVector, + eFormatVectorOfUInt8, + {LLDB_INVALID_REGNUM, arm64_dwarf::v30, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"v31", + nullptr, + 16, + 0, + eEncodingVector, + eFormatVectorOfUInt8, + {LLDB_INVALID_REGNUM, arm64_dwarf::v31, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + + {"fpsr", + nullptr, + 4, + 0, + eEncodingUint, + eFormatHex, + {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"fpcr", + nullptr, + 4, + 0, + eEncodingUint, + eFormatHex, + {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + + {"s0", + nullptr, + 4, + 0, + eEncodingIEEE754, + eFormatFloat, + {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"s1", + nullptr, + 4, + 0, + eEncodingIEEE754, + eFormatFloat, + {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"s2", + nullptr, + 4, + 0, + eEncodingIEEE754, + eFormatFloat, + {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"s3", + nullptr, + 4, + 0, + eEncodingIEEE754, + eFormatFloat, + {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"s4", + nullptr, + 4, + 0, + eEncodingIEEE754, + eFormatFloat, + {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"s5", + nullptr, + 4, + 0, + eEncodingIEEE754, + eFormatFloat, + {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"s6", + nullptr, + 4, + 0, + eEncodingIEEE754, + eFormatFloat, + {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"s7", + nullptr, + 4, + 0, + eEncodingIEEE754, + eFormatFloat, + {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"s8", + nullptr, + 4, + 0, + eEncodingIEEE754, + eFormatFloat, + {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"s9", + nullptr, + 4, + 0, + eEncodingIEEE754, + eFormatFloat, + {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"s10", + nullptr, + 4, + 0, + eEncodingIEEE754, + eFormatFloat, + {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"s11", + nullptr, + 4, + 0, + eEncodingIEEE754, + eFormatFloat, + {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"s12", + nullptr, + 4, + 0, + eEncodingIEEE754, + eFormatFloat, + {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"s13", + nullptr, + 4, + 0, + eEncodingIEEE754, + eFormatFloat, + {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"s14", + nullptr, + 4, + 0, + eEncodingIEEE754, + eFormatFloat, + {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"s15", + nullptr, + 4, + 0, + eEncodingIEEE754, + eFormatFloat, + {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"s16", + nullptr, + 4, + 0, + eEncodingIEEE754, + eFormatFloat, + {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"s17", + nullptr, + 4, + 0, + eEncodingIEEE754, + eFormatFloat, + {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"s18", + nullptr, + 4, + 0, + eEncodingIEEE754, + eFormatFloat, + {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"s19", + nullptr, + 4, + 0, + eEncodingIEEE754, + eFormatFloat, + {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"s20", + nullptr, + 4, + 0, + eEncodingIEEE754, + eFormatFloat, + {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"s21", + nullptr, + 4, + 0, + eEncodingIEEE754, + eFormatFloat, + {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"s22", + nullptr, + 4, + 0, + eEncodingIEEE754, + eFormatFloat, + {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"s23", + nullptr, + 4, + 0, + eEncodingIEEE754, + eFormatFloat, + {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"s24", + nullptr, + 4, + 0, + eEncodingIEEE754, + eFormatFloat, + {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"s25", + nullptr, + 4, + 0, + eEncodingIEEE754, + eFormatFloat, + {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"s26", + nullptr, + 4, + 0, + eEncodingIEEE754, + eFormatFloat, + {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"s27", + nullptr, + 4, + 0, + eEncodingIEEE754, + eFormatFloat, + {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"s28", + nullptr, + 4, + 0, + eEncodingIEEE754, + eFormatFloat, + {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"s29", + nullptr, + 4, + 0, + eEncodingIEEE754, + eFormatFloat, + {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"s30", + nullptr, + 4, + 0, + eEncodingIEEE754, + eFormatFloat, + {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"s31", + nullptr, + 4, + 0, + eEncodingIEEE754, + eFormatFloat, + {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + + {"d0", + nullptr, + 8, + 0, + eEncodingIEEE754, + eFormatFloat, + {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"d1", + nullptr, + 8, + 0, + eEncodingIEEE754, + eFormatFloat, + {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"d2", + nullptr, + 8, + 0, + eEncodingIEEE754, + eFormatFloat, + {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"d3", + nullptr, + 8, + 0, + eEncodingIEEE754, + eFormatFloat, + {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"d4", + nullptr, + 8, + 0, + eEncodingIEEE754, + eFormatFloat, + {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"d5", + nullptr, + 8, + 0, + eEncodingIEEE754, + eFormatFloat, + {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"d6", + nullptr, + 8, + 0, + eEncodingIEEE754, + eFormatFloat, + {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"d7", + nullptr, + 8, + 0, + eEncodingIEEE754, + eFormatFloat, + {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"d8", + nullptr, + 8, + 0, + eEncodingIEEE754, + eFormatFloat, + {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"d9", + nullptr, + 8, + 0, + eEncodingIEEE754, + eFormatFloat, + {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"d10", + nullptr, + 8, + 0, + eEncodingIEEE754, + eFormatFloat, + {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"d11", + nullptr, + 8, + 0, + eEncodingIEEE754, + eFormatFloat, + {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"d12", + nullptr, + 8, + 0, + eEncodingIEEE754, + eFormatFloat, + {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"d13", + nullptr, + 8, + 0, + eEncodingIEEE754, + eFormatFloat, + {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"d14", + nullptr, + 8, + 0, + eEncodingIEEE754, + eFormatFloat, + {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"d15", + nullptr, + 8, + 0, + eEncodingIEEE754, + eFormatFloat, + {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"d16", + nullptr, + 8, + 0, + eEncodingIEEE754, + eFormatFloat, + {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"d17", + nullptr, + 8, + 0, + eEncodingIEEE754, + eFormatFloat, + {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"d18", + nullptr, + 8, + 0, + eEncodingIEEE754, + eFormatFloat, + {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"d19", + nullptr, + 8, + 0, + eEncodingIEEE754, + eFormatFloat, + {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"d20", + nullptr, + 8, + 0, + eEncodingIEEE754, + eFormatFloat, + {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"d21", + nullptr, + 8, + 0, + eEncodingIEEE754, + eFormatFloat, + {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"d22", + nullptr, + 8, + 0, + eEncodingIEEE754, + eFormatFloat, + {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"d23", + nullptr, + 8, + 0, + eEncodingIEEE754, + eFormatFloat, + {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"d24", + nullptr, + 8, + 0, + eEncodingIEEE754, + eFormatFloat, + {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"d25", + nullptr, + 8, + 0, + eEncodingIEEE754, + eFormatFloat, + {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"d26", + nullptr, + 8, + 0, + eEncodingIEEE754, + eFormatFloat, + {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"d27", + nullptr, + 8, + 0, + eEncodingIEEE754, + eFormatFloat, + {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"d28", + nullptr, + 8, + 0, + eEncodingIEEE754, + eFormatFloat, + {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"d29", + nullptr, + 8, + 0, + eEncodingIEEE754, + eFormatFloat, + {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"d30", + nullptr, + 8, + 0, + eEncodingIEEE754, + eFormatFloat, + {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"d31", + nullptr, + 8, + 0, + eEncodingIEEE754, + eFormatFloat, + {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}}; + +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 * -ABIMacOSX_arm64::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(); - } +ABIMacOSX_arm64::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; + } + count = k_num_register_infos; + return g_register_infos; } -size_t -ABIMacOSX_arm64::GetRedZoneSize () const -{ - return 128; -} +size_t ABIMacOSX_arm64::GetRedZoneSize() const { return 128; } //------------------------------------------------------------------ // Static Functions //------------------------------------------------------------------ ABISP -ABIMacOSX_arm64::CreateInstance (const ArchSpec &arch) -{ - static ABISP g_abi_sp; - const llvm::Triple::ArchType arch_type = arch.GetTriple().getArch(); - const llvm::Triple::VendorType vendor_type = arch.GetTriple().getVendor(); - - if (vendor_type == llvm::Triple::Apple) - { - if (arch_type == llvm::Triple::aarch64) - { - if (!g_abi_sp) - g_abi_sp.reset (new ABIMacOSX_arm64); - return g_abi_sp; - } +ABIMacOSX_arm64::CreateInstance(const ArchSpec &arch) { + static ABISP g_abi_sp; + const llvm::Triple::ArchType arch_type = arch.GetTriple().getArch(); + const llvm::Triple::VendorType vendor_type = arch.GetTriple().getVendor(); + + if (vendor_type == llvm::Triple::Apple) { + if (arch_type == llvm::Triple::aarch64) { + if (!g_abi_sp) + g_abi_sp.reset(new ABIMacOSX_arm64); + return g_abi_sp; } + } - return ABISP(); + return ABISP(); } -bool -ABIMacOSX_arm64::PrepareTrivialCall (Thread &thread, - lldb::addr_t sp, - lldb::addr_t func_addr, - lldb::addr_t return_addr, - llvm::ArrayRef<lldb::addr_t> args) const -{ - RegisterContext *reg_ctx = thread.GetRegisterContext().get(); - if (!reg_ctx) - return false; +bool ABIMacOSX_arm64::PrepareTrivialCall( + Thread &thread, lldb::addr_t sp, lldb::addr_t func_addr, + lldb::addr_t return_addr, llvm::ArrayRef<lldb::addr_t> args) const { + RegisterContext *reg_ctx = thread.GetRegisterContext().get(); + if (!reg_ctx) + return false; + + Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS)); - Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS)); + if (log) { + StreamString s; + s.Printf("ABISysV_x86_64::PrepareTrivialCall (tid = 0x%" PRIx64 + ", sp = 0x%" PRIx64 ", func_addr = 0x%" PRIx64 + ", return_addr = 0x%" PRIx64, + thread.GetID(), (uint64_t)sp, (uint64_t)func_addr, + (uint64_t)return_addr); + for (size_t i = 0; i < args.size(); ++i) + s.Printf(", arg%d = 0x%" PRIx64, static_cast<int>(i + 1), args[i]); + s.PutCString(")"); + log->PutString(s.GetString()); + } + + const uint32_t pc_reg_num = reg_ctx->ConvertRegisterKindToRegisterNumber( + eRegisterKindGeneric, LLDB_REGNUM_GENERIC_PC); + const uint32_t sp_reg_num = reg_ctx->ConvertRegisterKindToRegisterNumber( + eRegisterKindGeneric, LLDB_REGNUM_GENERIC_SP); + const uint32_t ra_reg_num = reg_ctx->ConvertRegisterKindToRegisterNumber( + eRegisterKindGeneric, LLDB_REGNUM_GENERIC_RA); + + // x0 - x7 contain first 8 simple args + if (args.size() > 8) // TODO handle more than 6 arguments + return false; + + for (size_t i = 0; i < args.size(); ++i) { + const RegisterInfo *reg_info = reg_ctx->GetRegisterInfo( + eRegisterKindGeneric, LLDB_REGNUM_GENERIC_ARG1 + i); if (log) - { - StreamString s; - s.Printf("ABISysV_x86_64::PrepareTrivialCall (tid = 0x%" PRIx64 ", sp = 0x%" PRIx64 ", func_addr = 0x%" PRIx64 ", return_addr = 0x%" PRIx64, - thread.GetID(), - (uint64_t)sp, - (uint64_t)func_addr, - (uint64_t)return_addr); - - for (size_t i = 0; i < args.size(); ++i) - s.Printf (", arg%d = 0x%" PRIx64, static_cast<int>(i + 1), args[i]); - s.PutCString (")"); - log->PutCString(s.GetString().c_str()); - } + log->Printf("About to write arg%d (0x%" PRIx64 ") into %s", + static_cast<int>(i + 1), args[i], reg_info->name); + if (!reg_ctx->WriteRegisterFromUnsigned(reg_info, args[i])) + return false; + } + + // Set "lr" to the return address + if (!reg_ctx->WriteRegisterFromUnsigned( + reg_ctx->GetRegisterInfoAtIndex(ra_reg_num), return_addr)) + return false; + + // Set "sp" to the requested value + if (!reg_ctx->WriteRegisterFromUnsigned( + reg_ctx->GetRegisterInfoAtIndex(sp_reg_num), sp)) + return false; + + // Set "pc" to the address requested + if (!reg_ctx->WriteRegisterFromUnsigned( + reg_ctx->GetRegisterInfoAtIndex(pc_reg_num), func_addr)) + return false; + + return true; +} - const uint32_t pc_reg_num = reg_ctx->ConvertRegisterKindToRegisterNumber (eRegisterKindGeneric, LLDB_REGNUM_GENERIC_PC); - const uint32_t sp_reg_num = reg_ctx->ConvertRegisterKindToRegisterNumber (eRegisterKindGeneric, LLDB_REGNUM_GENERIC_SP); - const uint32_t ra_reg_num = reg_ctx->ConvertRegisterKindToRegisterNumber (eRegisterKindGeneric, LLDB_REGNUM_GENERIC_RA); +bool ABIMacOSX_arm64::GetArgumentValues(Thread &thread, + ValueList &values) const { + uint32_t num_values = values.GetSize(); - // x0 - x7 contain first 8 simple args - if (args.size() > 8) // TODO handle more than 6 arguments - return false; + ExecutionContext exe_ctx(thread.shared_from_this()); - for (size_t i = 0; i < args.size(); ++i) - { - const RegisterInfo *reg_info = reg_ctx->GetRegisterInfo(eRegisterKindGeneric, LLDB_REGNUM_GENERIC_ARG1 + i); - if (log) - log->Printf("About to write arg%d (0x%" PRIx64 ") into %s", - static_cast<int>(i + 1), args[i], reg_info->name); - if (!reg_ctx->WriteRegisterFromUnsigned(reg_info, args[i])) - return false; - } + // Extract the register context so we can read arguments from registers - // Set "lr" to the return address - if (!reg_ctx->WriteRegisterFromUnsigned (reg_ctx->GetRegisterInfoAtIndex (ra_reg_num), return_addr)) - return false; + RegisterContext *reg_ctx = thread.GetRegisterContext().get(); - // Set "sp" to the requested value - if (!reg_ctx->WriteRegisterFromUnsigned (reg_ctx->GetRegisterInfoAtIndex (sp_reg_num), sp)) - return false; + if (!reg_ctx) + return false; - // Set "pc" to the address requested - if (!reg_ctx->WriteRegisterFromUnsigned (reg_ctx->GetRegisterInfoAtIndex (pc_reg_num), func_addr)) - return false; + addr_t sp = 0; - return true; -} + for (uint32_t value_idx = 0; value_idx < num_values; ++value_idx) { + // We currently only support extracting values with Clang QualTypes. + // Do we care about others? + Value *value = values.GetValueAtIndex(value_idx); + + if (!value) + return false; -bool -ABIMacOSX_arm64::GetArgumentValues (Thread &thread, ValueList &values) const -{ - uint32_t num_values = values.GetSize(); - - ExecutionContext exe_ctx (thread.shared_from_this()); - - // Extract the register context so we can read arguments from registers - - RegisterContext *reg_ctx = thread.GetRegisterContext().get(); - - if (!reg_ctx) + CompilerType value_type = value->GetCompilerType(); + if (value_type) { + bool is_signed = false; + size_t bit_width = 0; + if (value_type.IsIntegerOrEnumerationType(is_signed)) { + bit_width = value_type.GetBitSize(&thread); + } else if (value_type.IsPointerOrReferenceType()) { + bit_width = value_type.GetBitSize(&thread); + } else { + // We only handle integer, pointer and reference types currently... return false; - - addr_t sp = 0; - - for (uint32_t value_idx = 0; value_idx < num_values; ++value_idx) - { - // We currently only support extracting values with Clang QualTypes. - // Do we care about others? - Value *value = values.GetValueAtIndex(value_idx); - - if (!value) - return false; - - CompilerType value_type = value->GetCompilerType(); - if (value_type) - { - bool is_signed = false; - size_t bit_width = 0; - if (value_type.IsIntegerOrEnumerationType (is_signed)) - { - bit_width = value_type.GetBitSize(&thread); - } - else if (value_type.IsPointerOrReferenceType ()) - { - bit_width = value_type.GetBitSize(&thread); + } + + if (bit_width <= (exe_ctx.GetProcessRef().GetAddressByteSize() * 8)) { + if (value_idx < 8) { + // Arguments 1-6 are in x0-x5... + const RegisterInfo *reg_info = nullptr; + // Search by generic ID first, then fall back to by name + uint32_t arg_reg_num = reg_ctx->ConvertRegisterKindToRegisterNumber( + eRegisterKindGeneric, LLDB_REGNUM_GENERIC_ARG1 + value_idx); + if (arg_reg_num != LLDB_INVALID_REGNUM) { + reg_info = reg_ctx->GetRegisterInfoAtIndex(arg_reg_num); + } else { + switch (value_idx) { + case 0: + reg_info = reg_ctx->GetRegisterInfoByName("x0"); + break; + case 1: + reg_info = reg_ctx->GetRegisterInfoByName("x1"); + break; + case 2: + reg_info = reg_ctx->GetRegisterInfoByName("x2"); + break; + case 3: + reg_info = reg_ctx->GetRegisterInfoByName("x3"); + break; + case 4: + reg_info = reg_ctx->GetRegisterInfoByName("x4"); + break; + case 5: + reg_info = reg_ctx->GetRegisterInfoByName("x5"); + break; + case 6: + reg_info = reg_ctx->GetRegisterInfoByName("x6"); + break; + case 7: + reg_info = reg_ctx->GetRegisterInfoByName("x7"); + break; } - else - { - // We only handle integer, pointer and reference types currently... + } + + if (reg_info) { + RegisterValue reg_value; + + if (reg_ctx->ReadRegister(reg_info, reg_value)) { + if (is_signed) + reg_value.SignExtend(bit_width); + if (!reg_value.GetScalarValue(value->GetScalar())) return false; + continue; } - - if (bit_width <= (exe_ctx.GetProcessRef().GetAddressByteSize() * 8)) - { - if (value_idx < 8) - { - // Arguments 1-6 are in x0-x5... - const RegisterInfo *reg_info = nullptr; - // Search by generic ID first, then fall back to by name - uint32_t arg_reg_num = reg_ctx->ConvertRegisterKindToRegisterNumber (eRegisterKindGeneric, LLDB_REGNUM_GENERIC_ARG1 + value_idx); - if (arg_reg_num != LLDB_INVALID_REGNUM) - { - reg_info = reg_ctx->GetRegisterInfoAtIndex(arg_reg_num); - } - else - { - switch (value_idx) - { - case 0: reg_info = reg_ctx->GetRegisterInfoByName("x0"); break; - case 1: reg_info = reg_ctx->GetRegisterInfoByName("x1"); break; - case 2: reg_info = reg_ctx->GetRegisterInfoByName("x2"); break; - case 3: reg_info = reg_ctx->GetRegisterInfoByName("x3"); break; - case 4: reg_info = reg_ctx->GetRegisterInfoByName("x4"); break; - case 5: reg_info = reg_ctx->GetRegisterInfoByName("x5"); break; - case 6: reg_info = reg_ctx->GetRegisterInfoByName("x6"); break; - case 7: reg_info = reg_ctx->GetRegisterInfoByName("x7"); break; - } - } - - if (reg_info) - { - RegisterValue reg_value; - - if (reg_ctx->ReadRegister(reg_info, reg_value)) - { - if (is_signed) - reg_value.SignExtend(bit_width); - if (!reg_value.GetScalarValue(value->GetScalar())) - return false; - continue; - } - } - return false; - } - else - { - if (sp == 0) - { - // Read the stack pointer if we already haven't read it - sp = reg_ctx->GetSP(0); - if (sp == 0) - return false; - } + } + return false; + } else { + if (sp == 0) { + // Read the stack pointer if we already haven't read it + sp = reg_ctx->GetSP(0); + if (sp == 0) + return false; + } + + // Arguments 5 on up are on the stack + const uint32_t arg_byte_size = (bit_width + (8 - 1)) / 8; + Error error; + if (!exe_ctx.GetProcessRef().ReadScalarIntegerFromMemory( + sp, arg_byte_size, is_signed, value->GetScalar(), error)) + return false; - // Arguments 5 on up are on the stack - const uint32_t arg_byte_size = (bit_width + (8-1)) / 8; - Error error; - if (!exe_ctx.GetProcessRef().ReadScalarIntegerFromMemory(sp, arg_byte_size, is_signed, value->GetScalar(), error)) - return false; - - sp += arg_byte_size; - // Align up to the next 8 byte boundary if needed - if (sp % 8) - { - sp >>= 3; - sp += 1; - sp <<= 3; - } - } - } + sp += arg_byte_size; + // Align up to the next 8 byte boundary if needed + if (sp % 8) { + sp >>= 3; + sp += 1; + sp <<= 3; + } } + } } - return true; + } + return true; } -Error -ABIMacOSX_arm64::SetReturnValueObject(lldb::StackFrameSP &frame_sp, lldb::ValueObjectSP &new_value_sp) -{ - Error error; - if (!new_value_sp) - { - error.SetErrorString("Empty value object for return value."); - return error; - } - - CompilerType return_value_type = new_value_sp->GetCompilerType(); - if (!return_value_type) - { - error.SetErrorString ("Null clang type for return value."); - return error; - } +Error ABIMacOSX_arm64::SetReturnValueObject(lldb::StackFrameSP &frame_sp, + lldb::ValueObjectSP &new_value_sp) { + Error error; + if (!new_value_sp) { + error.SetErrorString("Empty value object for return value."); + return error; + } - Thread *thread = frame_sp->GetThread().get(); - - RegisterContext *reg_ctx = thread->GetRegisterContext().get(); - - if (reg_ctx) - { - DataExtractor data; - Error data_error; - const uint64_t byte_size = new_value_sp->GetData(data, data_error); - if (data_error.Fail()) - { - error.SetErrorStringWithFormat("Couldn't convert return value to raw data: %s", data_error.AsCString()); - return error; - } + CompilerType return_value_type = new_value_sp->GetCompilerType(); + if (!return_value_type) { + error.SetErrorString("Null clang type for return value."); + return error; + } - const uint32_t type_flags = return_value_type.GetTypeInfo(nullptr); - if (type_flags & eTypeIsScalar || - type_flags & eTypeIsPointer) - { - if (type_flags & eTypeIsInteger || - type_flags & eTypeIsPointer ) - { - // Extract the register context so we can read arguments from registers - lldb::offset_t offset = 0; - if (byte_size <= 16) - { - const RegisterInfo *x0_info = reg_ctx->GetRegisterInfoByName("x0", 0); - if (byte_size <= 8) - { - uint64_t raw_value = data.GetMaxU64(&offset, byte_size); - - if (!reg_ctx->WriteRegisterFromUnsigned (x0_info, raw_value)) - error.SetErrorString ("failed to write register x0"); - } - else - { - uint64_t raw_value = data.GetMaxU64(&offset, 8); - - if (reg_ctx->WriteRegisterFromUnsigned (x0_info, raw_value)) - { - const RegisterInfo *x1_info = reg_ctx->GetRegisterInfoByName("x1", 0); - raw_value = data.GetMaxU64(&offset, byte_size - offset); - - if (!reg_ctx->WriteRegisterFromUnsigned (x1_info, raw_value)) - error.SetErrorString ("failed to write register x1"); - } - } - } - else - { - error.SetErrorString("We don't support returning longer than 128 bit integer values at present."); - } + Thread *thread = frame_sp->GetThread().get(); + + RegisterContext *reg_ctx = thread->GetRegisterContext().get(); + + if (reg_ctx) { + DataExtractor data; + Error data_error; + const uint64_t byte_size = new_value_sp->GetData(data, data_error); + if (data_error.Fail()) { + error.SetErrorStringWithFormat( + "Couldn't convert return value to raw data: %s", + data_error.AsCString()); + return error; + } + + const uint32_t type_flags = return_value_type.GetTypeInfo(nullptr); + if (type_flags & eTypeIsScalar || type_flags & eTypeIsPointer) { + if (type_flags & eTypeIsInteger || type_flags & eTypeIsPointer) { + // Extract the register context so we can read arguments from registers + lldb::offset_t offset = 0; + if (byte_size <= 16) { + const RegisterInfo *x0_info = reg_ctx->GetRegisterInfoByName("x0", 0); + if (byte_size <= 8) { + uint64_t raw_value = data.GetMaxU64(&offset, byte_size); + + if (!reg_ctx->WriteRegisterFromUnsigned(x0_info, raw_value)) + error.SetErrorString("failed to write register x0"); + } else { + uint64_t raw_value = data.GetMaxU64(&offset, 8); + + if (reg_ctx->WriteRegisterFromUnsigned(x0_info, raw_value)) { + const RegisterInfo *x1_info = + reg_ctx->GetRegisterInfoByName("x1", 0); + raw_value = data.GetMaxU64(&offset, byte_size - offset); + + if (!reg_ctx->WriteRegisterFromUnsigned(x1_info, raw_value)) + error.SetErrorString("failed to write register x1"); } - else if (type_flags & eTypeIsFloat) - { - if (type_flags & eTypeIsComplex) - { - // Don't handle complex yet. - error.SetErrorString ("returning complex float values are not supported"); - } - else - { - const RegisterInfo *v0_info = reg_ctx->GetRegisterInfoByName("v0", 0); - - if (v0_info) - { - if (byte_size <= 16) - { - if (byte_size <= RegisterValue::GetMaxByteSize()) - { - RegisterValue reg_value; - error = reg_value.SetValueFromData (v0_info, data, 0, true); - if (error.Success()) - { - if (!reg_ctx->WriteRegister (v0_info, reg_value)) - error.SetErrorString ("failed to write register v0"); - } - } - else - { - error.SetErrorStringWithFormat ("returning float values with a byte size of %" PRIu64 " are not supported", byte_size); - } - } - else - { - error.SetErrorString("returning float values longer than 128 bits are not supported"); - } - } - else - { - error.SetErrorString("v0 register is not available on this target"); - } + } + } else { + error.SetErrorString("We don't support returning longer than 128 bit " + "integer values at present."); + } + } else if (type_flags & eTypeIsFloat) { + if (type_flags & eTypeIsComplex) { + // Don't handle complex yet. + error.SetErrorString( + "returning complex float values are not supported"); + } else { + const RegisterInfo *v0_info = reg_ctx->GetRegisterInfoByName("v0", 0); + + if (v0_info) { + if (byte_size <= 16) { + if (byte_size <= RegisterValue::GetMaxByteSize()) { + RegisterValue reg_value; + error = reg_value.SetValueFromData(v0_info, data, 0, true); + if (error.Success()) { + if (!reg_ctx->WriteRegister(v0_info, reg_value)) + error.SetErrorString("failed to write register v0"); } + } else { + error.SetErrorStringWithFormat( + "returning float values with a byte size of %" PRIu64 + " are not supported", + byte_size); + } + } else { + error.SetErrorString("returning float values longer than 128 " + "bits are not supported"); } + } else { + error.SetErrorString("v0 register is not available on this target"); + } } - else if (type_flags & eTypeIsVector) - { - if (byte_size > 0) - { - const RegisterInfo *v0_info = reg_ctx->GetRegisterInfoByName("v0", 0); - - if (v0_info) - { - if (byte_size <= v0_info->byte_size) - { - RegisterValue reg_value; - error = reg_value.SetValueFromData (v0_info, data, 0, true); - if (error.Success()) - { - if (!reg_ctx->WriteRegister (v0_info, reg_value)) - error.SetErrorString ("failed to write register v0"); - } - } - } + } + } else if (type_flags & eTypeIsVector) { + if (byte_size > 0) { + const RegisterInfo *v0_info = reg_ctx->GetRegisterInfoByName("v0", 0); + + if (v0_info) { + if (byte_size <= v0_info->byte_size) { + RegisterValue reg_value; + error = reg_value.SetValueFromData(v0_info, data, 0, true); + if (error.Success()) { + if (!reg_ctx->WriteRegister(v0_info, reg_value)) + error.SetErrorString("failed to write register v0"); } + } } + } } - else - { - error.SetErrorString("no registers are available"); - } - - return error; + } else { + error.SetErrorString("no registers are available"); + } + + return error; } -bool -ABIMacOSX_arm64::CreateFunctionEntryUnwindPlan (UnwindPlan &unwind_plan) -{ - unwind_plan.Clear(); - unwind_plan.SetRegisterKind (eRegisterKindDWARF); - - uint32_t lr_reg_num = arm64_dwarf::lr; - uint32_t sp_reg_num = arm64_dwarf::sp; - uint32_t pc_reg_num = arm64_dwarf::pc; - - UnwindPlan::RowSP row(new UnwindPlan::Row); - - // Our previous Call Frame Address is the stack pointer - row->GetCFAValue().SetIsRegisterPlusOffset (sp_reg_num, 0); - - // Our previous PC is in the LR - row->SetRegisterLocationToRegister(pc_reg_num, lr_reg_num, true); - - unwind_plan.AppendRow (row); - - // All other registers are the same. - - unwind_plan.SetSourceName ("arm64 at-func-entry default"); - unwind_plan.SetSourcedFromCompiler (eLazyBoolNo); - - return true; +bool ABIMacOSX_arm64::CreateFunctionEntryUnwindPlan(UnwindPlan &unwind_plan) { + unwind_plan.Clear(); + unwind_plan.SetRegisterKind(eRegisterKindDWARF); + + uint32_t lr_reg_num = arm64_dwarf::lr; + uint32_t sp_reg_num = arm64_dwarf::sp; + uint32_t pc_reg_num = arm64_dwarf::pc; + + UnwindPlan::RowSP row(new UnwindPlan::Row); + + // Our previous Call Frame Address is the stack pointer + row->GetCFAValue().SetIsRegisterPlusOffset(sp_reg_num, 0); + + // Our previous PC is in the LR + row->SetRegisterLocationToRegister(pc_reg_num, lr_reg_num, true); + + unwind_plan.AppendRow(row); + + // All other registers are the same. + + unwind_plan.SetSourceName("arm64 at-func-entry default"); + unwind_plan.SetSourcedFromCompiler(eLazyBoolNo); + + return true; } -bool -ABIMacOSX_arm64::CreateDefaultUnwindPlan (UnwindPlan &unwind_plan) -{ - unwind_plan.Clear(); - unwind_plan.SetRegisterKind (eRegisterKindDWARF); - - uint32_t fp_reg_num = arm64_dwarf::fp; - uint32_t pc_reg_num = arm64_dwarf::pc; - - UnwindPlan::RowSP row(new UnwindPlan::Row); - const int32_t ptr_size = 8; - - row->GetCFAValue().SetIsRegisterPlusOffset (fp_reg_num, 2 * ptr_size); - row->SetOffset (0); - - row->SetRegisterLocationToAtCFAPlusOffset(fp_reg_num, ptr_size * -2, true); - row->SetRegisterLocationToAtCFAPlusOffset(pc_reg_num, ptr_size * -1, true); - - unwind_plan.AppendRow (row); - unwind_plan.SetSourceName ("arm64-apple-darwin default unwind plan"); - unwind_plan.SetSourcedFromCompiler (eLazyBoolNo); - unwind_plan.SetUnwindPlanValidAtAllInstructions (eLazyBoolNo); - return true; +bool ABIMacOSX_arm64::CreateDefaultUnwindPlan(UnwindPlan &unwind_plan) { + unwind_plan.Clear(); + unwind_plan.SetRegisterKind(eRegisterKindDWARF); + + uint32_t fp_reg_num = arm64_dwarf::fp; + uint32_t pc_reg_num = arm64_dwarf::pc; + + UnwindPlan::RowSP row(new UnwindPlan::Row); + const int32_t ptr_size = 8; + + row->GetCFAValue().SetIsRegisterPlusOffset(fp_reg_num, 2 * ptr_size); + row->SetOffset(0); + + row->SetRegisterLocationToAtCFAPlusOffset(fp_reg_num, ptr_size * -2, true); + row->SetRegisterLocationToAtCFAPlusOffset(pc_reg_num, ptr_size * -1, true); + + unwind_plan.AppendRow(row); + unwind_plan.SetSourceName("arm64-apple-darwin default unwind plan"); + unwind_plan.SetSourcedFromCompiler(eLazyBoolNo); + unwind_plan.SetUnwindPlanValidAtAllInstructions(eLazyBoolNo); + return true; } -// AAPCS64 (Procedure Call Standard for the ARM 64-bit Architecture) says -// registers x19 through x28 and sp are callee preserved. -// v8-v15 are non-volatile (and specifically only the lower 8 bytes of these regs), +// AAPCS64 (Procedure Call Standard for the ARM 64-bit Architecture) says +// registers x19 through x28 and sp are callee preserved. +// v8-v15 are non-volatile (and specifically only the lower 8 bytes of these +// regs), // the rest of the fp/SIMD registers are volatile. // We treat x29 as callee preserved also, else the unwinder won't try to // retrieve fp saves. -bool -ABIMacOSX_arm64::RegisterIsVolatile (const RegisterInfo *reg_info) -{ - if (reg_info) - { - const char *name = reg_info->name; - - // Sometimes we'll be called with the "alternate" name for these registers; - // recognize them as non-volatile. - - if (name[0] == 'p' && name[1] == 'c') // pc - return false; - if (name[0] == 'f' && name[1] == 'p') // fp - return false; - if (name[0] == 's' && name[1] == 'p') // sp - return false; - if (name[0] == 'l' && name[1] == 'r') // lr - return false; - - if (name[0] == 'x') - { - // Volatile registers: x0-x18, x30 (lr) - // Return false for the non-volatile gpr regs, true for everything else - switch (name[1]) - { - case '1': - switch (name[2]) - { - case '9': - return false; // x19 is non-volatile - default: - return true; - } - break; - case '2': - switch (name[2]) - { - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - return false; // x20 - 28 are non-volatile - case '9': - return false; // x29 aka fp treat as non-volatile on Darwin - default: - return true; - } - case '3': // x30 aka lr treat as non-volatile - if (name[2] == '0') - return false; - break; - default: - return true; - } +bool ABIMacOSX_arm64::RegisterIsVolatile(const RegisterInfo *reg_info) { + if (reg_info) { + const char *name = reg_info->name; + + // Sometimes we'll be called with the "alternate" name for these registers; + // recognize them as non-volatile. + + if (name[0] == 'p' && name[1] == 'c') // pc + return false; + if (name[0] == 'f' && name[1] == 'p') // fp + return false; + if (name[0] == 's' && name[1] == 'p') // sp + return false; + if (name[0] == 'l' && name[1] == 'r') // lr + return false; + + if (name[0] == 'x') { + // Volatile registers: x0-x18, x30 (lr) + // Return false for the non-volatile gpr regs, true for everything else + switch (name[1]) { + case '1': + switch (name[2]) { + case '9': + return false; // x19 is non-volatile + default: + return true; } - else if (name[0] == 'v' || name[0] == 's' || name[0] == 'd') - { - // Volatile registers: v0-7, v16-v31 - // Return false for non-volatile fp/SIMD regs, true for everything else - switch (name[1]) - { - case '8': - case '9': - return false; // v8-v9 are non-volatile - case '1': - switch (name[2]) - { - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - return false; // v10-v15 are non-volatile - default: - return true; - } - default: - return true; - } + break; + case '2': + switch (name[2]) { + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + return false; // x20 - 28 are non-volatile + case '9': + return false; // x29 aka fp treat as non-volatile on Darwin + default: + return true; + } + case '3': // x30 aka lr treat as non-volatile + if (name[2] == '0') + return false; + break; + default: + return true; + } + } else if (name[0] == 'v' || name[0] == 's' || name[0] == 'd') { + // Volatile registers: v0-7, v16-v31 + // Return false for non-volatile fp/SIMD regs, true for everything else + switch (name[1]) { + case '8': + case '9': + return false; // v8-v9 are non-volatile + case '1': + switch (name[2]) { + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + return false; // v10-v15 are non-volatile + default: + return true; } + default: + return true; + } } - return true; + } + return true; } -static bool -LoadValueFromConsecutiveGPRRegisters (ExecutionContext &exe_ctx, - RegisterContext *reg_ctx, - const CompilerType &value_type, - bool is_return_value, // false => parameter, true => return value - uint32_t &NGRN, // NGRN (see ABI documentation) - uint32_t &NSRN, // NSRN (see ABI documentation) - DataExtractor &data) -{ - const size_t byte_size = value_type.GetByteSize(nullptr); - - if (byte_size == 0) +static bool LoadValueFromConsecutiveGPRRegisters( + ExecutionContext &exe_ctx, RegisterContext *reg_ctx, + const CompilerType &value_type, + bool is_return_value, // false => parameter, true => return value + uint32_t &NGRN, // NGRN (see ABI documentation) + uint32_t &NSRN, // NSRN (see ABI documentation) + DataExtractor &data) { + const size_t byte_size = value_type.GetByteSize(nullptr); + + if (byte_size == 0) + return false; + + std::unique_ptr<DataBufferHeap> heap_data_ap( + new DataBufferHeap(byte_size, 0)); + const ByteOrder byte_order = exe_ctx.GetProcessRef().GetByteOrder(); + Error error; + + CompilerType base_type; + const uint32_t homogeneous_count = + value_type.IsHomogeneousAggregate(&base_type); + if (homogeneous_count > 0 && homogeneous_count <= 8) { + // Make sure we have enough registers + if (NSRN < 8 && (8 - NSRN) >= homogeneous_count) { + if (!base_type) return false; + const size_t base_byte_size = base_type.GetByteSize(nullptr); + uint32_t data_offset = 0; + + for (uint32_t i = 0; i < homogeneous_count; ++i) { + char v_name[8]; + ::snprintf(v_name, sizeof(v_name), "v%u", NSRN); + const RegisterInfo *reg_info = + reg_ctx->GetRegisterInfoByName(v_name, 0); + if (reg_info == nullptr) + return false; - std::unique_ptr<DataBufferHeap> heap_data_ap (new DataBufferHeap(byte_size, 0)); - const ByteOrder byte_order = exe_ctx.GetProcessRef().GetByteOrder(); - Error error; - - CompilerType base_type; - const uint32_t homogeneous_count = value_type.IsHomogeneousAggregate (&base_type); - if (homogeneous_count > 0 && homogeneous_count <= 8) - { - // Make sure we have enough registers - if (NSRN < 8 && (8-NSRN) >= homogeneous_count) - { - if (!base_type) - return false; - const size_t base_byte_size = base_type.GetByteSize(nullptr); - uint32_t data_offset = 0; + if (base_byte_size > reg_info->byte_size) + return false; - for (uint32_t i = 0; i < homogeneous_count; ++i) - { - char v_name[8]; - ::snprintf (v_name, sizeof(v_name), "v%u", NSRN); - const RegisterInfo *reg_info = reg_ctx->GetRegisterInfoByName(v_name, 0); - if (reg_info == nullptr) - return false; - - if (base_byte_size > reg_info->byte_size) - return false; - - RegisterValue reg_value; - - if (!reg_ctx->ReadRegister(reg_info, reg_value)) - return false; - - // Make sure we have enough room in "heap_data_ap" - if ((data_offset + base_byte_size) <= heap_data_ap->GetByteSize()) - { - const size_t bytes_copied = reg_value.GetAsMemoryData (reg_info, - heap_data_ap->GetBytes()+data_offset, - base_byte_size, - byte_order, - error); - if (bytes_copied != base_byte_size) - return false; - data_offset += bytes_copied; - ++NSRN; - } - else - return false; - } - data.SetByteOrder(byte_order); - data.SetAddressByteSize(exe_ctx.GetProcessRef().GetAddressByteSize()); - data.SetData(DataBufferSP (heap_data_ap.release())); - return true; - } + RegisterValue reg_value; + + if (!reg_ctx->ReadRegister(reg_info, reg_value)) + return false; + + // Make sure we have enough room in "heap_data_ap" + if ((data_offset + base_byte_size) <= heap_data_ap->GetByteSize()) { + const size_t bytes_copied = reg_value.GetAsMemoryData( + reg_info, heap_data_ap->GetBytes() + data_offset, base_byte_size, + byte_order, error); + if (bytes_copied != base_byte_size) + return false; + data_offset += bytes_copied; + ++NSRN; + } else + return false; + } + data.SetByteOrder(byte_order); + data.SetAddressByteSize(exe_ctx.GetProcessRef().GetAddressByteSize()); + data.SetData(DataBufferSP(heap_data_ap.release())); + return true; } + } + + const size_t max_reg_byte_size = 16; + if (byte_size <= max_reg_byte_size) { + size_t bytes_left = byte_size; + uint32_t data_offset = 0; + while (data_offset < byte_size) { + if (NGRN >= 8) + return false; - const size_t max_reg_byte_size = 16; - if (byte_size <= max_reg_byte_size) - { - size_t bytes_left = byte_size; - uint32_t data_offset = 0; - while (data_offset < byte_size) - { - if (NGRN >= 8) - return false; - - uint32_t reg_num = reg_ctx->ConvertRegisterKindToRegisterNumber (eRegisterKindGeneric, LLDB_REGNUM_GENERIC_ARG1 + NGRN); - if (reg_num == LLDB_INVALID_REGNUM) - return false; - - const RegisterInfo *reg_info = reg_ctx->GetRegisterInfoAtIndex(reg_num); - if (reg_info == nullptr) - return false; + uint32_t reg_num = reg_ctx->ConvertRegisterKindToRegisterNumber( + eRegisterKindGeneric, LLDB_REGNUM_GENERIC_ARG1 + NGRN); + if (reg_num == LLDB_INVALID_REGNUM) + return false; - RegisterValue reg_value; - - if (!reg_ctx->ReadRegister(reg_info, reg_value)) - return false; - - const size_t curr_byte_size = std::min<size_t>(8,bytes_left); - const size_t bytes_copied = reg_value.GetAsMemoryData (reg_info, heap_data_ap->GetBytes()+data_offset, curr_byte_size, byte_order, error); - if (bytes_copied == 0) - return false; - if (bytes_copied >= bytes_left) - break; - data_offset += bytes_copied; - bytes_left -= bytes_copied; - ++NGRN; - } + const RegisterInfo *reg_info = reg_ctx->GetRegisterInfoAtIndex(reg_num); + if (reg_info == nullptr) + return false; + + RegisterValue reg_value; + + if (!reg_ctx->ReadRegister(reg_info, reg_value)) + return false; + + const size_t curr_byte_size = std::min<size_t>(8, bytes_left); + const size_t bytes_copied = reg_value.GetAsMemoryData( + reg_info, heap_data_ap->GetBytes() + data_offset, curr_byte_size, + byte_order, error); + if (bytes_copied == 0) + return false; + if (bytes_copied >= bytes_left) + break; + data_offset += bytes_copied; + bytes_left -= bytes_copied; + ++NGRN; } - else - { - const RegisterInfo *reg_info = nullptr; - if (is_return_value) - { - // We are assuming we are decoding this immediately after returning - // from a function call and that the address of the structure is in x8 - reg_info = reg_ctx->GetRegisterInfoByName("x8", 0); - } - else - { - // We are assuming we are stopped at the first instruction in a function - // and that the ABI is being respected so all parameters appear where they - // should be (functions with no external linkage can legally violate the ABI). - if (NGRN >= 8) - return false; - - uint32_t reg_num = reg_ctx->ConvertRegisterKindToRegisterNumber (eRegisterKindGeneric, LLDB_REGNUM_GENERIC_ARG1 + NGRN); - if (reg_num == LLDB_INVALID_REGNUM) - return false; - reg_info = reg_ctx->GetRegisterInfoAtIndex(reg_num); - if (reg_info == nullptr) - return false; - ++NGRN; - } + } else { + const RegisterInfo *reg_info = nullptr; + if (is_return_value) { + // We are assuming we are decoding this immediately after returning + // from a function call and that the address of the structure is in x8 + reg_info = reg_ctx->GetRegisterInfoByName("x8", 0); + } else { + // We are assuming we are stopped at the first instruction in a function + // and that the ABI is being respected so all parameters appear where they + // should be (functions with no external linkage can legally violate the + // ABI). + if (NGRN >= 8) + return false; - if (reg_info == nullptr) - return false; + uint32_t reg_num = reg_ctx->ConvertRegisterKindToRegisterNumber( + eRegisterKindGeneric, LLDB_REGNUM_GENERIC_ARG1 + NGRN); + if (reg_num == LLDB_INVALID_REGNUM) + return false; + reg_info = reg_ctx->GetRegisterInfoAtIndex(reg_num); + if (reg_info == nullptr) + return false; + ++NGRN; + } - const lldb::addr_t value_addr = reg_ctx->ReadRegisterAsUnsigned(reg_info, LLDB_INVALID_ADDRESS); + if (reg_info == nullptr) + return false; - if (value_addr == LLDB_INVALID_ADDRESS) - return false; + const lldb::addr_t value_addr = + reg_ctx->ReadRegisterAsUnsigned(reg_info, LLDB_INVALID_ADDRESS); - if (exe_ctx.GetProcessRef().ReadMemory (value_addr, - heap_data_ap->GetBytes(), - heap_data_ap->GetByteSize(), - error) != heap_data_ap->GetByteSize()) - { - return false; - } + if (value_addr == LLDB_INVALID_ADDRESS) + return false; + + if (exe_ctx.GetProcessRef().ReadMemory( + value_addr, heap_data_ap->GetBytes(), heap_data_ap->GetByteSize(), + error) != heap_data_ap->GetByteSize()) { + return false; } + } - data.SetByteOrder(byte_order); - data.SetAddressByteSize(exe_ctx.GetProcessRef().GetAddressByteSize()); - data.SetData(DataBufferSP (heap_data_ap.release())); - return true; + data.SetByteOrder(byte_order); + data.SetAddressByteSize(exe_ctx.GetProcessRef().GetAddressByteSize()); + data.SetData(DataBufferSP(heap_data_ap.release())); + return true; } -ValueObjectSP -ABIMacOSX_arm64::GetReturnValueObjectImpl (Thread &thread, CompilerType &return_compiler_type) const -{ - ValueObjectSP return_valobj_sp; - Value value; - - ExecutionContext exe_ctx (thread.shared_from_this()); - if (exe_ctx.GetTargetPtr() == nullptr || exe_ctx.GetProcessPtr() == nullptr) - return return_valobj_sp; - - //value.SetContext (Value::eContextTypeClangType, return_compiler_type); - value.SetCompilerType(return_compiler_type); - - RegisterContext *reg_ctx = thread.GetRegisterContext().get(); - if (!reg_ctx) - return return_valobj_sp; - - const size_t byte_size = return_compiler_type.GetByteSize(nullptr); - - const uint32_t type_flags = return_compiler_type.GetTypeInfo(nullptr); - if (type_flags & eTypeIsScalar || - type_flags & eTypeIsPointer) - { - value.SetValueType(Value::eValueTypeScalar); - - bool success = false; - if (type_flags & eTypeIsInteger || - type_flags & eTypeIsPointer ) - { - // Extract the register context so we can read arguments from registers - if (byte_size <= 8) +ValueObjectSP ABIMacOSX_arm64::GetReturnValueObjectImpl( + Thread &thread, CompilerType &return_compiler_type) const { + ValueObjectSP return_valobj_sp; + Value value; + + ExecutionContext exe_ctx(thread.shared_from_this()); + if (exe_ctx.GetTargetPtr() == nullptr || exe_ctx.GetProcessPtr() == nullptr) + return return_valobj_sp; + + // value.SetContext (Value::eContextTypeClangType, return_compiler_type); + value.SetCompilerType(return_compiler_type); + + RegisterContext *reg_ctx = thread.GetRegisterContext().get(); + if (!reg_ctx) + return return_valobj_sp; + + const size_t byte_size = return_compiler_type.GetByteSize(nullptr); + + const uint32_t type_flags = return_compiler_type.GetTypeInfo(nullptr); + if (type_flags & eTypeIsScalar || type_flags & eTypeIsPointer) { + value.SetValueType(Value::eValueTypeScalar); + + bool success = false; + if (type_flags & eTypeIsInteger || type_flags & eTypeIsPointer) { + // Extract the register context so we can read arguments from registers + if (byte_size <= 8) { + const RegisterInfo *x0_reg_info = + reg_ctx->GetRegisterInfoByName("x0", 0); + if (x0_reg_info) { + uint64_t raw_value = + thread.GetRegisterContext()->ReadRegisterAsUnsigned(x0_reg_info, + 0); + const bool is_signed = (type_flags & eTypeIsSigned) != 0; + switch (byte_size) { + default: + break; + case 16: // uint128_t + // In register x0 and x1 { - const RegisterInfo *x0_reg_info = reg_ctx->GetRegisterInfoByName("x0", 0); - if (x0_reg_info) - { - uint64_t raw_value = thread.GetRegisterContext()->ReadRegisterAsUnsigned(x0_reg_info, 0); - const bool is_signed = (type_flags & eTypeIsSigned) != 0; - switch (byte_size) - { - default: - break; - case 16: // uint128_t - // In register x0 and x1 - { - const RegisterInfo *x1_reg_info = reg_ctx->GetRegisterInfoByName("x1", 0); - - if (x1_reg_info) - { - if (byte_size <= x0_reg_info->byte_size + x1_reg_info->byte_size) - { - std::unique_ptr<DataBufferHeap> heap_data_ap (new DataBufferHeap(byte_size, 0)); - const ByteOrder byte_order = exe_ctx.GetProcessRef().GetByteOrder(); - RegisterValue x0_reg_value; - RegisterValue x1_reg_value; - if (reg_ctx->ReadRegister(x0_reg_info, x0_reg_value) && - reg_ctx->ReadRegister(x1_reg_info, x1_reg_value)) - { - Error error; - if (x0_reg_value.GetAsMemoryData (x0_reg_info, heap_data_ap->GetBytes()+0, 8, byte_order, error) && - x1_reg_value.GetAsMemoryData (x1_reg_info, heap_data_ap->GetBytes()+8, 8, byte_order, error)) - { - DataExtractor data (DataBufferSP (heap_data_ap.release()), - byte_order, - exe_ctx.GetProcessRef().GetAddressByteSize()); - - return_valobj_sp = ValueObjectConstResult::Create (&thread, - return_compiler_type, - ConstString(""), - data); - return return_valobj_sp; - } - } - } - } - } - break; - case sizeof(uint64_t): - if (is_signed) - value.GetScalar() = (int64_t)(raw_value); - else - value.GetScalar() = (uint64_t)(raw_value); - success = true; - break; - - case sizeof(uint32_t): - if (is_signed) - value.GetScalar() = (int32_t)(raw_value & UINT32_MAX); - else - value.GetScalar() = (uint32_t)(raw_value & UINT32_MAX); - success = true; - break; - - case sizeof(uint16_t): - if (is_signed) - value.GetScalar() = (int16_t)(raw_value & UINT16_MAX); - else - value.GetScalar() = (uint16_t)(raw_value & UINT16_MAX); - success = true; - break; - - case sizeof(uint8_t): - if (is_signed) - value.GetScalar() = (int8_t)(raw_value & UINT8_MAX); - else - value.GetScalar() = (uint8_t)(raw_value & UINT8_MAX); - success = true; - break; + const RegisterInfo *x1_reg_info = + reg_ctx->GetRegisterInfoByName("x1", 0); + + if (x1_reg_info) { + if (byte_size <= + x0_reg_info->byte_size + x1_reg_info->byte_size) { + std::unique_ptr<DataBufferHeap> heap_data_ap( + new DataBufferHeap(byte_size, 0)); + const ByteOrder byte_order = + exe_ctx.GetProcessRef().GetByteOrder(); + RegisterValue x0_reg_value; + RegisterValue x1_reg_value; + if (reg_ctx->ReadRegister(x0_reg_info, x0_reg_value) && + reg_ctx->ReadRegister(x1_reg_info, x1_reg_value)) { + Error error; + if (x0_reg_value.GetAsMemoryData( + x0_reg_info, heap_data_ap->GetBytes() + 0, 8, + byte_order, error) && + x1_reg_value.GetAsMemoryData( + x1_reg_info, heap_data_ap->GetBytes() + 8, 8, + byte_order, error)) { + DataExtractor data( + DataBufferSP(heap_data_ap.release()), byte_order, + exe_ctx.GetProcessRef().GetAddressByteSize()); + + return_valobj_sp = ValueObjectConstResult::Create( + &thread, return_compiler_type, ConstString(""), data); + return return_valobj_sp; } + } } + } } - } - else if (type_flags & eTypeIsFloat) - { - if (type_flags & eTypeIsComplex) - { - // Don't handle complex yet. - } + break; + case sizeof(uint64_t): + if (is_signed) + value.GetScalar() = (int64_t)(raw_value); else - { - if (byte_size <= sizeof(long double)) - { - const RegisterInfo *v0_reg_info = reg_ctx->GetRegisterInfoByName("v0", 0); - RegisterValue v0_value; - if (reg_ctx->ReadRegister (v0_reg_info, v0_value)) - { - DataExtractor data; - if (v0_value.GetData(data)) - { - lldb::offset_t offset = 0; - if (byte_size == sizeof(float)) - { - value.GetScalar() = data.GetFloat(&offset); - success = true; - } - else if (byte_size == sizeof(double)) - { - value.GetScalar() = data.GetDouble(&offset); - success = true; - } - else if (byte_size == sizeof(long double)) - { - value.GetScalar() = data.GetLongDouble(&offset); - success = true; - } - } - } - } + value.GetScalar() = (uint64_t)(raw_value); + success = true; + break; + + case sizeof(uint32_t): + if (is_signed) + value.GetScalar() = (int32_t)(raw_value & UINT32_MAX); + else + value.GetScalar() = (uint32_t)(raw_value & UINT32_MAX); + success = true; + break; + + case sizeof(uint16_t): + if (is_signed) + value.GetScalar() = (int16_t)(raw_value & UINT16_MAX); + else + value.GetScalar() = (uint16_t)(raw_value & UINT16_MAX); + success = true; + break; + + case sizeof(uint8_t): + if (is_signed) + value.GetScalar() = (int8_t)(raw_value & UINT8_MAX); + else + value.GetScalar() = (uint8_t)(raw_value & UINT8_MAX); + success = true; + break; + } + } + } + } else if (type_flags & eTypeIsFloat) { + if (type_flags & eTypeIsComplex) { + // Don't handle complex yet. + } else { + if (byte_size <= sizeof(long double)) { + const RegisterInfo *v0_reg_info = + reg_ctx->GetRegisterInfoByName("v0", 0); + RegisterValue v0_value; + if (reg_ctx->ReadRegister(v0_reg_info, v0_value)) { + DataExtractor data; + if (v0_value.GetData(data)) { + lldb::offset_t offset = 0; + if (byte_size == sizeof(float)) { + value.GetScalar() = data.GetFloat(&offset); + success = true; + } else if (byte_size == sizeof(double)) { + value.GetScalar() = data.GetDouble(&offset); + success = true; + } else if (byte_size == sizeof(long double)) { + value.GetScalar() = data.GetLongDouble(&offset); + success = true; + } } + } } - - if (success) - return_valobj_sp = ValueObjectConstResult::Create (thread.GetStackFrameAtIndex(0).get(), - value, - ConstString("")); + } } - else if (type_flags & eTypeIsVector) - { - if (byte_size > 0) - { - - const RegisterInfo *v0_info = reg_ctx->GetRegisterInfoByName("v0", 0); - - if (v0_info) - { - if (byte_size <= v0_info->byte_size) - { - std::unique_ptr<DataBufferHeap> heap_data_ap (new DataBufferHeap(byte_size, 0)); - const ByteOrder byte_order = exe_ctx.GetProcessRef().GetByteOrder(); - RegisterValue reg_value; - if (reg_ctx->ReadRegister(v0_info, reg_value)) - { - Error error; - if (reg_value.GetAsMemoryData (v0_info, - heap_data_ap->GetBytes(), - heap_data_ap->GetByteSize(), - byte_order, - error)) - { - DataExtractor data (DataBufferSP (heap_data_ap.release()), - byte_order, - exe_ctx.GetProcessRef().GetAddressByteSize()); - return_valobj_sp = ValueObjectConstResult::Create (&thread, - return_compiler_type, - ConstString(""), - data); - } - } - } + + if (success) + return_valobj_sp = ValueObjectConstResult::Create( + thread.GetStackFrameAtIndex(0).get(), value, ConstString("")); + } else if (type_flags & eTypeIsVector) { + if (byte_size > 0) { + + const RegisterInfo *v0_info = reg_ctx->GetRegisterInfoByName("v0", 0); + + if (v0_info) { + if (byte_size <= v0_info->byte_size) { + std::unique_ptr<DataBufferHeap> heap_data_ap( + new DataBufferHeap(byte_size, 0)); + const ByteOrder byte_order = exe_ctx.GetProcessRef().GetByteOrder(); + RegisterValue reg_value; + if (reg_ctx->ReadRegister(v0_info, reg_value)) { + Error error; + if (reg_value.GetAsMemoryData(v0_info, heap_data_ap->GetBytes(), + heap_data_ap->GetByteSize(), + byte_order, error)) { + DataExtractor data(DataBufferSP(heap_data_ap.release()), + byte_order, + exe_ctx.GetProcessRef().GetAddressByteSize()); + return_valobj_sp = ValueObjectConstResult::Create( + &thread, return_compiler_type, ConstString(""), data); } + } } + } } - else if (type_flags & eTypeIsStructUnion || - type_flags & eTypeIsClass) - { - DataExtractor data; - - uint32_t NGRN = 0; // Search ABI docs for NGRN - uint32_t NSRN = 0; // Search ABI docs for NSRN - const bool is_return_value = true; - if (LoadValueFromConsecutiveGPRRegisters (exe_ctx, reg_ctx, return_compiler_type, is_return_value, NGRN, NSRN, data)) - { - return_valobj_sp = ValueObjectConstResult::Create (&thread, - return_compiler_type, - ConstString(""), - data); - } + } else if (type_flags & eTypeIsStructUnion || type_flags & eTypeIsClass) { + DataExtractor data; + + uint32_t NGRN = 0; // Search ABI docs for NGRN + uint32_t NSRN = 0; // Search ABI docs for NSRN + const bool is_return_value = true; + if (LoadValueFromConsecutiveGPRRegisters( + exe_ctx, reg_ctx, return_compiler_type, is_return_value, NGRN, NSRN, + data)) { + return_valobj_sp = ValueObjectConstResult::Create( + &thread, return_compiler_type, ConstString(""), data); } - return return_valobj_sp; + } + return return_valobj_sp; } -void -ABIMacOSX_arm64::Initialize() -{ - PluginManager::RegisterPlugin (GetPluginNameStatic(), - pluginDesc, - CreateInstance); +void ABIMacOSX_arm64::Initialize() { + PluginManager::RegisterPlugin(GetPluginNameStatic(), pluginDesc, + CreateInstance); } -void -ABIMacOSX_arm64::Terminate() -{ - PluginManager::UnregisterPlugin (CreateInstance); +void ABIMacOSX_arm64::Terminate() { + PluginManager::UnregisterPlugin(CreateInstance); } //------------------------------------------------------------------ // PluginInterface protocol //------------------------------------------------------------------ -ConstString -ABIMacOSX_arm64::GetPluginNameStatic() -{ - static ConstString g_plugin_name("ABIMacOSX_arm64"); - return g_plugin_name; +ConstString ABIMacOSX_arm64::GetPluginNameStatic() { + static ConstString g_plugin_name("ABIMacOSX_arm64"); + return g_plugin_name; } -uint32_t -ABIMacOSX_arm64::GetPluginVersion() -{ - return 1; -} +uint32_t ABIMacOSX_arm64::GetPluginVersion() { return 1; } diff --git a/source/Plugins/ABI/MacOSX-arm64/ABIMacOSX_arm64.h b/source/Plugins/ABI/MacOSX-arm64/ABIMacOSX_arm64.h index 1bc94f61c2f1..e0978116a730 100644 --- a/source/Plugins/ABI/MacOSX-arm64/ABIMacOSX_arm64.h +++ b/source/Plugins/ABI/MacOSX-arm64/ABIMacOSX_arm64.h @@ -14,116 +14,97 @@ // C++ Includes // Other libraries and framework includes // Project includes -#include "lldb/lldb-private.h" #include "lldb/Core/ConstString.h" #include "lldb/Target/ABI.h" +#include "lldb/lldb-private.h" -class ABIMacOSX_arm64 : - public lldb_private::ABI -{ +class ABIMacOSX_arm64 : public lldb_private::ABI { public: - ~ABIMacOSX_arm64() override = default; - - size_t - GetRedZoneSize() const override; - - bool - PrepareTrivialCall(lldb_private::Thread &thread, - lldb::addr_t sp, - lldb::addr_t functionAddress, - lldb::addr_t returnAddress, - llvm::ArrayRef<lldb::addr_t> args) const override; - - bool - GetArgumentValues(lldb_private::Thread &thread, - lldb_private::ValueList &values) const override; - - bool - CreateFunctionEntryUnwindPlan(lldb_private::UnwindPlan &unwind_plan) override; - - bool - CreateDefaultUnwindPlan(lldb_private::UnwindPlan &unwind_plan) override; - - bool - RegisterIsVolatile(const lldb_private::RegisterInfo *reg_info) override; - - // The arm64 ABI requires that stack frames be 16 byte aligned. - // When there is a trap handler on the stack, e.g. _sigtramp in userland - // code, we've seen that the stack pointer is often not aligned properly - // before the handler is invoked. This means that lldb will stop the unwind - // early -- before the function which caused the trap. - // - // To work around this, we relax that alignment to be just word-size (8-bytes). - // Whitelisting the trap handlers for user space would be easy (_sigtramp) but - // in other environments there can be a large number of different functions - // involved in async traps. - bool - CallFrameAddressIsValid(lldb::addr_t cfa) override - { - // Make sure the stack call frame addresses are are 8 byte aligned - if (cfa & (8ull - 1ull)) - return false; // Not 8 byte aligned - if (cfa == 0) - return false; // Zero is not a valid stack address - return true; - } - - bool - CodeAddressIsValid(lldb::addr_t pc) override - { - if (pc & (4ull - 1ull)) - return false; // Not 4 byte aligned - - // Anything else if fair game.. - return true; - } - - const lldb_private::RegisterInfo * - GetRegisterInfoArray(uint32_t &count) override; - - //------------------------------------------------------------------ - // Static Functions - //------------------------------------------------------------------ - - static void - Initialize(); - - static void - Terminate(); - - static lldb::ABISP - CreateInstance (const lldb_private::ArchSpec &arch); - - //------------------------------------------------------------------ - // PluginInterface protocol - //------------------------------------------------------------------ - - static lldb_private::ConstString - GetPluginNameStatic(); - - lldb_private::ConstString - GetPluginName() override - { - return GetPluginNameStatic(); - } - - uint32_t - GetPluginVersion() override; - - lldb_private::Error - SetReturnValueObject(lldb::StackFrameSP &frame_sp, lldb::ValueObjectSP &new_value) override; + ~ABIMacOSX_arm64() override = default; + + size_t GetRedZoneSize() const override; + + bool PrepareTrivialCall(lldb_private::Thread &thread, lldb::addr_t sp, + lldb::addr_t functionAddress, + lldb::addr_t returnAddress, + llvm::ArrayRef<lldb::addr_t> args) const override; + + bool GetArgumentValues(lldb_private::Thread &thread, + lldb_private::ValueList &values) const override; + + bool + CreateFunctionEntryUnwindPlan(lldb_private::UnwindPlan &unwind_plan) override; + + bool CreateDefaultUnwindPlan(lldb_private::UnwindPlan &unwind_plan) override; + + bool RegisterIsVolatile(const lldb_private::RegisterInfo *reg_info) override; + + // The arm64 ABI requires that stack frames be 16 byte aligned. + // When there is a trap handler on the stack, e.g. _sigtramp in userland + // code, we've seen that the stack pointer is often not aligned properly + // before the handler is invoked. This means that lldb will stop the unwind + // early -- before the function which caused the trap. + // + // To work around this, we relax that alignment to be just word-size + // (8-bytes). + // Whitelisting the trap handlers for user space would be easy (_sigtramp) but + // in other environments there can be a large number of different functions + // involved in async traps. + bool CallFrameAddressIsValid(lldb::addr_t cfa) override { + // Make sure the stack call frame addresses are are 8 byte aligned + if (cfa & (8ull - 1ull)) + return false; // Not 8 byte aligned + if (cfa == 0) + return false; // Zero is not a valid stack address + return true; + } + + bool CodeAddressIsValid(lldb::addr_t pc) override { + if (pc & (4ull - 1ull)) + return false; // Not 4 byte aligned + + // Anything else if fair game.. + return true; + } + + const lldb_private::RegisterInfo * + GetRegisterInfoArray(uint32_t &count) override; + + //------------------------------------------------------------------ + // Static Functions + //------------------------------------------------------------------ + + static void Initialize(); + + static void Terminate(); + + static lldb::ABISP CreateInstance(const lldb_private::ArchSpec &arch); + + //------------------------------------------------------------------ + // PluginInterface protocol + //------------------------------------------------------------------ + + static lldb_private::ConstString GetPluginNameStatic(); + + lldb_private::ConstString GetPluginName() override { + return GetPluginNameStatic(); + } + + uint32_t GetPluginVersion() override; + + lldb_private::Error + SetReturnValueObject(lldb::StackFrameSP &frame_sp, + lldb::ValueObjectSP &new_value) override; protected: - lldb::ValueObjectSP - GetReturnValueObjectImpl (lldb_private::Thread &thread, - lldb_private::CompilerType &ast_type) const override; + lldb::ValueObjectSP + GetReturnValueObjectImpl(lldb_private::Thread &thread, + lldb_private::CompilerType &ast_type) const override; private: - ABIMacOSX_arm64() : - lldb_private::ABI() - { - // Call CreateInstance instead. - } + ABIMacOSX_arm64() : lldb_private::ABI() { + // Call CreateInstance instead. + } }; #endif // liblldb_ABIMacOSX_arm64_h_ diff --git a/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.cpp b/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.cpp index 70c7adb8e5b5..6eead6f35e3b 100644 --- a/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.cpp +++ b/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.cpp @@ -34,491 +34,1010 @@ using namespace lldb; using namespace lldb_private; -enum -{ - ehframe_eax = 0, - ehframe_ecx, - ehframe_edx, - ehframe_ebx, - ehframe_ebp, // Different from DWARF the regnums - eh_frame esp/ebp had their regnums switched on i386 darwin - ehframe_esp, // Different from DWARF the regnums - eh_frame esp/ebp had their regnums switched on i386 darwin - ehframe_esi, - ehframe_edi, - ehframe_eip, - ehframe_eflags +enum { + ehframe_eax = 0, + ehframe_ecx, + ehframe_edx, + ehframe_ebx, + ehframe_ebp, // Different from DWARF the regnums - eh_frame esp/ebp had their + // regnums switched on i386 darwin + ehframe_esp, // Different from DWARF the regnums - eh_frame esp/ebp had their + // regnums switched on i386 darwin + ehframe_esi, + ehframe_edi, + ehframe_eip, + ehframe_eflags }; -enum -{ - dwarf_eax = 0, - dwarf_ecx, - dwarf_edx, - dwarf_ebx, - dwarf_esp, - dwarf_ebp, - dwarf_esi, - dwarf_edi, - dwarf_eip, - dwarf_eflags, - dwarf_stmm0 = 11, - dwarf_stmm1, - dwarf_stmm2, - dwarf_stmm3, - dwarf_stmm4, - dwarf_stmm5, - dwarf_stmm6, - dwarf_stmm7, - dwarf_xmm0 = 21, - dwarf_xmm1, - dwarf_xmm2, - dwarf_xmm3, - dwarf_xmm4, - dwarf_xmm5, - dwarf_xmm6, - dwarf_xmm7, - dwarf_ymm0 = dwarf_xmm0, - dwarf_ymm1 = dwarf_xmm1, - dwarf_ymm2 = dwarf_xmm2, - dwarf_ymm3 = dwarf_xmm3, - dwarf_ymm4 = dwarf_xmm4, - dwarf_ymm5 = dwarf_xmm5, - dwarf_ymm6 = dwarf_xmm6, - dwarf_ymm7 = dwarf_xmm7 +enum { + dwarf_eax = 0, + dwarf_ecx, + dwarf_edx, + dwarf_ebx, + dwarf_esp, + dwarf_ebp, + dwarf_esi, + dwarf_edi, + dwarf_eip, + dwarf_eflags, + dwarf_stmm0 = 11, + dwarf_stmm1, + dwarf_stmm2, + dwarf_stmm3, + dwarf_stmm4, + dwarf_stmm5, + dwarf_stmm6, + dwarf_stmm7, + dwarf_xmm0 = 21, + dwarf_xmm1, + dwarf_xmm2, + dwarf_xmm3, + dwarf_xmm4, + dwarf_xmm5, + dwarf_xmm6, + dwarf_xmm7, + dwarf_ymm0 = dwarf_xmm0, + dwarf_ymm1 = dwarf_xmm1, + dwarf_ymm2 = dwarf_xmm2, + dwarf_ymm3 = dwarf_xmm3, + dwarf_ymm4 = dwarf_xmm4, + dwarf_ymm5 = dwarf_xmm5, + dwarf_ymm6 = dwarf_xmm6, + dwarf_ymm7 = dwarf_xmm7 }; -static RegisterInfo g_register_infos[] = -{ - // NAME ALT SZ OFF ENCODING FORMAT EH_FRAME DWARF GENERIC PROCESS PLUGIN LLDB NATIVE VALUE REGS INVALIDATE REGS - // ====== ======= == === ============= ============ ===================== ===================== ============================ ==================== ====================== ========== =============== - { "eax", nullptr, 4, 0, eEncodingUint , eFormatHex , { ehframe_eax , dwarf_eax , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "ebx" , nullptr, 4, 0, eEncodingUint , eFormatHex , { ehframe_ebx , dwarf_ebx , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "ecx" , nullptr, 4, 0, eEncodingUint , eFormatHex , { ehframe_ecx , dwarf_ecx , LLDB_REGNUM_GENERIC_ARG4 , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "edx" , nullptr, 4, 0, eEncodingUint , eFormatHex , { ehframe_edx , dwarf_edx , LLDB_REGNUM_GENERIC_ARG3 , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "esi" , nullptr, 4, 0, eEncodingUint , eFormatHex , { ehframe_esi , dwarf_esi , LLDB_REGNUM_GENERIC_ARG2 , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "edi" , nullptr, 4, 0, eEncodingUint , eFormatHex , { ehframe_edi , dwarf_edi , LLDB_REGNUM_GENERIC_ARG1 , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "ebp" , "fp", 4, 0, eEncodingUint , eFormatHex , { ehframe_ebp , dwarf_ebp , LLDB_REGNUM_GENERIC_FP , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "esp" , "sp", 4, 0, eEncodingUint , eFormatHex , { ehframe_esp , dwarf_esp , LLDB_REGNUM_GENERIC_SP , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "eip" , "pc", 4, 0, eEncodingUint , eFormatHex , { ehframe_eip , dwarf_eip , LLDB_REGNUM_GENERIC_PC , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "eflags", nullptr, 4, 0, eEncodingUint , eFormatHex , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_REGNUM_GENERIC_FLAGS , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "cs" , nullptr, 4, 0, eEncodingUint , eFormatHex , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "ss" , nullptr, 4, 0, eEncodingUint , eFormatHex , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "ds" , nullptr, 4, 0, eEncodingUint , eFormatHex , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "es" , nullptr, 4, 0, eEncodingUint , eFormatHex , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "fs" , nullptr, 4, 0, eEncodingUint , eFormatHex , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "gs" , nullptr, 4, 0, eEncodingUint , eFormatHex , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "stmm0" , nullptr,10, 0, eEncodingVector, eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM , dwarf_stmm0 , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "stmm1" , nullptr,10, 0, eEncodingVector, eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM , dwarf_stmm1 , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "stmm2" , nullptr,10, 0, eEncodingVector, eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM , dwarf_stmm2 , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "stmm3" , nullptr,10, 0, eEncodingVector, eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM , dwarf_stmm3 , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "stmm4" , nullptr,10, 0, eEncodingVector, eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM , dwarf_stmm4 , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "stmm5" , nullptr,10, 0, eEncodingVector, eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM , dwarf_stmm5 , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "stmm6" , nullptr,10, 0, eEncodingVector, eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM , dwarf_stmm6 , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "stmm7" , nullptr,10, 0, eEncodingVector, eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM , dwarf_stmm7 , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "fctrl" , nullptr, 4, 0, eEncodingUint , eFormatHex , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "fstat" , nullptr, 4, 0, eEncodingUint , eFormatHex , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "ftag" , nullptr, 4, 0, eEncodingUint , eFormatHex , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "fiseg" , nullptr, 4, 0, eEncodingUint , eFormatHex , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "fioff" , nullptr, 4, 0, eEncodingUint , eFormatHex , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "foseg" , nullptr, 4, 0, eEncodingUint , eFormatHex , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "fooff" , nullptr, 4, 0, eEncodingUint , eFormatHex , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "fop" , nullptr, 4, 0, eEncodingUint , eFormatHex , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "xmm0" , nullptr,16, 0, eEncodingVector, eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM , dwarf_xmm0 , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "xmm1" , nullptr,16, 0, eEncodingVector, eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM , dwarf_xmm1 , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "xmm2" , nullptr,16, 0, eEncodingVector, eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM , dwarf_xmm2 , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "xmm3" , nullptr,16, 0, eEncodingVector, eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM , dwarf_xmm3 , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "xmm4" , nullptr,16, 0, eEncodingVector, eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM , dwarf_xmm4 , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "xmm5" , nullptr,16, 0, eEncodingVector, eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM , dwarf_xmm5 , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "xmm6" , nullptr,16, 0, eEncodingVector, eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM , dwarf_xmm6 , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "xmm7" , nullptr,16, 0, eEncodingVector, eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM , dwarf_xmm7 , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "mxcsr" , nullptr, 4, 0, eEncodingUint , eFormatHex , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "ymm0" , nullptr,32, 0, eEncodingVector, eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM , dwarf_ymm0 , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "ymm1" , nullptr,32, 0, eEncodingVector, eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM , dwarf_ymm1 , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "ymm2" , nullptr,32, 0, eEncodingVector, eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM , dwarf_ymm2 , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "ymm3" , nullptr,32, 0, eEncodingVector, eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM , dwarf_ymm3 , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "ymm4" , nullptr,32, 0, eEncodingVector, eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM , dwarf_ymm4 , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "ymm5" , nullptr,32, 0, eEncodingVector, eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM , dwarf_ymm5 , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "ymm6" , nullptr,32, 0, eEncodingVector, eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM , dwarf_ymm6 , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "ymm7" , nullptr,32, 0, eEncodingVector, eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM , dwarf_ymm7 , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr } -}; +static RegisterInfo g_register_infos[] = { + // NAME ALT SZ OFF ENCODING FORMAT + // EH_FRAME DWARF GENERIC + // PROCESS PLUGIN LLDB NATIVE + // ====== ======= == === ============= ============ + // ===================== ===================== ============================ + // ==================== ====================== + {"eax", + nullptr, + 4, + 0, + eEncodingUint, + eFormatHex, + {ehframe_eax, dwarf_eax, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"ebx", + nullptr, + 4, + 0, + eEncodingUint, + eFormatHex, + {ehframe_ebx, dwarf_ebx, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"ecx", + nullptr, + 4, + 0, + eEncodingUint, + eFormatHex, + {ehframe_ecx, dwarf_ecx, LLDB_REGNUM_GENERIC_ARG4, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"edx", + nullptr, + 4, + 0, + eEncodingUint, + eFormatHex, + {ehframe_edx, dwarf_edx, LLDB_REGNUM_GENERIC_ARG3, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"esi", + nullptr, + 4, + 0, + eEncodingUint, + eFormatHex, + {ehframe_esi, dwarf_esi, LLDB_REGNUM_GENERIC_ARG2, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"edi", + nullptr, + 4, + 0, + eEncodingUint, + eFormatHex, + {ehframe_edi, dwarf_edi, LLDB_REGNUM_GENERIC_ARG1, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"ebp", + "fp", + 4, + 0, + eEncodingUint, + eFormatHex, + {ehframe_ebp, dwarf_ebp, LLDB_REGNUM_GENERIC_FP, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"esp", + "sp", + 4, + 0, + eEncodingUint, + eFormatHex, + {ehframe_esp, dwarf_esp, LLDB_REGNUM_GENERIC_SP, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"eip", + "pc", + 4, + 0, + eEncodingUint, + eFormatHex, + {ehframe_eip, dwarf_eip, LLDB_REGNUM_GENERIC_PC, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"eflags", + 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, + {LLDB_INVALID_REGNUM, dwarf_stmm0, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"stmm1", + nullptr, + 10, + 0, + eEncodingVector, + eFormatVectorOfUInt8, + {LLDB_INVALID_REGNUM, dwarf_stmm1, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"stmm2", + nullptr, + 10, + 0, + eEncodingVector, + eFormatVectorOfUInt8, + {LLDB_INVALID_REGNUM, dwarf_stmm2, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"stmm3", + nullptr, + 10, + 0, + eEncodingVector, + eFormatVectorOfUInt8, + {LLDB_INVALID_REGNUM, dwarf_stmm3, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"stmm4", + nullptr, + 10, + 0, + eEncodingVector, + eFormatVectorOfUInt8, + {LLDB_INVALID_REGNUM, dwarf_stmm4, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"stmm5", + nullptr, + 10, + 0, + eEncodingVector, + eFormatVectorOfUInt8, + {LLDB_INVALID_REGNUM, dwarf_stmm5, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"stmm6", + nullptr, + 10, + 0, + eEncodingVector, + eFormatVectorOfUInt8, + {LLDB_INVALID_REGNUM, dwarf_stmm6, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"stmm7", + nullptr, + 10, + 0, + eEncodingVector, + eFormatVectorOfUInt8, + {LLDB_INVALID_REGNUM, 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, + {LLDB_INVALID_REGNUM, dwarf_xmm0, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"xmm1", + nullptr, + 16, + 0, + eEncodingVector, + eFormatVectorOfUInt8, + {LLDB_INVALID_REGNUM, dwarf_xmm1, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"xmm2", + nullptr, + 16, + 0, + eEncodingVector, + eFormatVectorOfUInt8, + {LLDB_INVALID_REGNUM, dwarf_xmm2, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"xmm3", + nullptr, + 16, + 0, + eEncodingVector, + eFormatVectorOfUInt8, + {LLDB_INVALID_REGNUM, dwarf_xmm3, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"xmm4", + nullptr, + 16, + 0, + eEncodingVector, + eFormatVectorOfUInt8, + {LLDB_INVALID_REGNUM, dwarf_xmm4, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"xmm5", + nullptr, + 16, + 0, + eEncodingVector, + eFormatVectorOfUInt8, + {LLDB_INVALID_REGNUM, dwarf_xmm5, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"xmm6", + nullptr, + 16, + 0, + eEncodingVector, + eFormatVectorOfUInt8, + {LLDB_INVALID_REGNUM, dwarf_xmm6, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"xmm7", + nullptr, + 16, + 0, + eEncodingVector, + eFormatVectorOfUInt8, + {LLDB_INVALID_REGNUM, dwarf_xmm7, 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, + {LLDB_INVALID_REGNUM, dwarf_ymm0, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"ymm1", + nullptr, + 32, + 0, + eEncodingVector, + eFormatVectorOfUInt8, + {LLDB_INVALID_REGNUM, dwarf_ymm1, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"ymm2", + nullptr, + 32, + 0, + eEncodingVector, + eFormatVectorOfUInt8, + {LLDB_INVALID_REGNUM, dwarf_ymm2, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"ymm3", + nullptr, + 32, + 0, + eEncodingVector, + eFormatVectorOfUInt8, + {LLDB_INVALID_REGNUM, dwarf_ymm3, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"ymm4", + nullptr, + 32, + 0, + eEncodingVector, + eFormatVectorOfUInt8, + {LLDB_INVALID_REGNUM, dwarf_ymm4, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"ymm5", + nullptr, + 32, + 0, + eEncodingVector, + eFormatVectorOfUInt8, + {LLDB_INVALID_REGNUM, dwarf_ymm5, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"ymm6", + nullptr, + 32, + 0, + eEncodingVector, + eFormatVectorOfUInt8, + {LLDB_INVALID_REGNUM, dwarf_ymm6, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"ymm7", + nullptr, + 32, + 0, + eEncodingVector, + eFormatVectorOfUInt8, + {LLDB_INVALID_REGNUM, dwarf_ymm7, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}}; -static const uint32_t k_num_register_infos = llvm::array_lengthof(g_register_infos); +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 * -ABIMacOSX_i386::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(); - } +ABIMacOSX_i386::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; + } + count = k_num_register_infos; + return g_register_infos; } -size_t -ABIMacOSX_i386::GetRedZoneSize () const -{ - return 0; -} +size_t ABIMacOSX_i386::GetRedZoneSize() const { return 0; } //------------------------------------------------------------------ // Static Functions //------------------------------------------------------------------ ABISP -ABIMacOSX_i386::CreateInstance (const ArchSpec &arch) -{ - static ABISP g_abi_sp; - if ((arch.GetTriple().getArch() == llvm::Triple::x86) && - (arch.GetTriple().isMacOSX() || arch.GetTriple().isiOS() || arch.GetTriple().isWatchOS())) - { - if (!g_abi_sp) - g_abi_sp.reset (new ABIMacOSX_i386); - return g_abi_sp; - } - return ABISP(); +ABIMacOSX_i386::CreateInstance(const ArchSpec &arch) { + static ABISP g_abi_sp; + if ((arch.GetTriple().getArch() == llvm::Triple::x86) && + (arch.GetTriple().isMacOSX() || arch.GetTriple().isiOS() || + arch.GetTriple().isWatchOS())) { + if (!g_abi_sp) + g_abi_sp.reset(new ABIMacOSX_i386); + return g_abi_sp; + } + return ABISP(); } -bool -ABIMacOSX_i386::PrepareTrivialCall (Thread &thread, - addr_t sp, - addr_t func_addr, - addr_t return_addr, - llvm::ArrayRef<addr_t> args) const -{ - RegisterContext *reg_ctx = thread.GetRegisterContext().get(); - if (!reg_ctx) - return false; - uint32_t pc_reg_num = reg_ctx->ConvertRegisterKindToRegisterNumber (eRegisterKindGeneric, LLDB_REGNUM_GENERIC_PC); - uint32_t sp_reg_num = reg_ctx->ConvertRegisterKindToRegisterNumber (eRegisterKindGeneric, LLDB_REGNUM_GENERIC_SP); - - // When writing a register value down to memory, the register info used - // to write memory just needs to have the correct size of a 32 bit register, - // the actual register it pertains to is not important, just the size needs - // to be correct. Here we use "eax"... - const RegisterInfo *reg_info_32 = reg_ctx->GetRegisterInfoByName("eax"); - if (!reg_info_32) - return false; // TODO this should actually never happen - - // Make room for the argument(s) on the stack - - Error error; - RegisterValue reg_value; - - // Write any arguments onto the stack - sp -= 4 * args.size(); - - // Align the SP - sp &= ~(16ull-1ull); // 16-byte alignment - - addr_t arg_pos = sp; - - for (addr_t arg : args) - { - reg_value.SetUInt32(arg); - error = reg_ctx->WriteRegisterValueToMemory (reg_info_32, - arg_pos, - reg_info_32->byte_size, - reg_value); - if (error.Fail()) - return false; - arg_pos += 4; - } - - // The return address is pushed onto the stack (yes after we just set the - // alignment above!). - sp -= 4; - reg_value.SetUInt32(return_addr); - error = reg_ctx->WriteRegisterValueToMemory (reg_info_32, - sp, - reg_info_32->byte_size, - reg_value); +bool ABIMacOSX_i386::PrepareTrivialCall(Thread &thread, addr_t sp, + addr_t func_addr, addr_t return_addr, + llvm::ArrayRef<addr_t> args) const { + RegisterContext *reg_ctx = thread.GetRegisterContext().get(); + if (!reg_ctx) + return false; + uint32_t pc_reg_num = reg_ctx->ConvertRegisterKindToRegisterNumber( + eRegisterKindGeneric, LLDB_REGNUM_GENERIC_PC); + uint32_t sp_reg_num = reg_ctx->ConvertRegisterKindToRegisterNumber( + eRegisterKindGeneric, LLDB_REGNUM_GENERIC_SP); + + // When writing a register value down to memory, the register info used + // to write memory just needs to have the correct size of a 32 bit register, + // the actual register it pertains to is not important, just the size needs + // to be correct. Here we use "eax"... + const RegisterInfo *reg_info_32 = reg_ctx->GetRegisterInfoByName("eax"); + if (!reg_info_32) + return false; // TODO this should actually never happen + + // Make room for the argument(s) on the stack + + Error error; + RegisterValue reg_value; + + // Write any arguments onto the stack + sp -= 4 * args.size(); + + // Align the SP + sp &= ~(16ull - 1ull); // 16-byte alignment + + addr_t arg_pos = sp; + + for (addr_t arg : args) { + reg_value.SetUInt32(arg); + error = reg_ctx->WriteRegisterValueToMemory( + reg_info_32, arg_pos, reg_info_32->byte_size, reg_value); if (error.Fail()) - return false; - - // %esp is set to the actual stack value. - - if (!reg_ctx->WriteRegisterFromUnsigned (sp_reg_num, sp)) - return false; - - // %eip is set to the address of the called function. - - if (!reg_ctx->WriteRegisterFromUnsigned (pc_reg_num, func_addr)) - return false; - - return true; -} + return false; + arg_pos += 4; + } -static bool -ReadIntegerArgument (Scalar &scalar, - unsigned int bit_width, - bool is_signed, - Process *process, - addr_t ¤t_stack_argument) -{ - - uint32_t byte_size = (bit_width + (8-1))/8; - Error error; - if (process->ReadScalarIntegerFromMemory(current_stack_argument, byte_size, is_signed, scalar, error)) - { - current_stack_argument += byte_size; - return true; - } + // The return address is pushed onto the stack (yes after we just set the + // alignment above!). + sp -= 4; + reg_value.SetUInt32(return_addr); + error = reg_ctx->WriteRegisterValueToMemory( + reg_info_32, sp, reg_info_32->byte_size, reg_value); + if (error.Fail()) + return false; + + // %esp is set to the actual stack value. + + if (!reg_ctx->WriteRegisterFromUnsigned(sp_reg_num, sp)) + return false; + + // %eip is set to the address of the called function. + + if (!reg_ctx->WriteRegisterFromUnsigned(pc_reg_num, func_addr)) return false; + + return true; } -bool -ABIMacOSX_i386::GetArgumentValues (Thread &thread, - ValueList &values) const -{ - unsigned int num_values = values.GetSize(); - unsigned int value_index; - - // Get the pointer to the first stack argument so we have a place to start - // when reading data - - RegisterContext *reg_ctx = thread.GetRegisterContext().get(); - - if (!reg_ctx) - return false; - - addr_t sp = reg_ctx->GetSP(0); - - if (!sp) - return false; - - addr_t current_stack_argument = sp + 4; // jump over return address - - for (value_index = 0; - value_index < num_values; - ++value_index) - { - Value *value = values.GetValueAtIndex(value_index); - - if (!value) - return false; - - // We currently only support extracting values with Clang QualTypes. - // Do we care about others? - CompilerType compiler_type (value->GetCompilerType()); - if (compiler_type) - { - bool is_signed; - - if (compiler_type.IsIntegerOrEnumerationType (is_signed)) - { - ReadIntegerArgument(value->GetScalar(), - compiler_type.GetBitSize(&thread), - is_signed, - thread.GetProcess().get(), - current_stack_argument); - } - else if (compiler_type.IsPointerType()) - { - ReadIntegerArgument(value->GetScalar(), - compiler_type.GetBitSize(&thread), - false, - thread.GetProcess().get(), - current_stack_argument); - } - } - } - +static bool ReadIntegerArgument(Scalar &scalar, unsigned int bit_width, + bool is_signed, Process *process, + addr_t ¤t_stack_argument) { + + uint32_t byte_size = (bit_width + (8 - 1)) / 8; + Error error; + if (process->ReadScalarIntegerFromMemory(current_stack_argument, byte_size, + is_signed, scalar, error)) { + current_stack_argument += byte_size; return true; + } + return false; } -Error -ABIMacOSX_i386::SetReturnValueObject(lldb::StackFrameSP &frame_sp, lldb::ValueObjectSP &new_value_sp) -{ - Error error; - if (!new_value_sp) - { - error.SetErrorString("Empty value object for return value."); - return error; +bool ABIMacOSX_i386::GetArgumentValues(Thread &thread, + ValueList &values) const { + unsigned int num_values = values.GetSize(); + unsigned int value_index; + + // Get the pointer to the first stack argument so we have a place to start + // when reading data + + RegisterContext *reg_ctx = thread.GetRegisterContext().get(); + + if (!reg_ctx) + return false; + + addr_t sp = reg_ctx->GetSP(0); + + if (!sp) + return false; + + addr_t current_stack_argument = sp + 4; // jump over return address + + for (value_index = 0; value_index < num_values; ++value_index) { + Value *value = values.GetValueAtIndex(value_index); + + if (!value) + return false; + + // We currently only support extracting values with Clang QualTypes. + // Do we care about others? + CompilerType compiler_type(value->GetCompilerType()); + if (compiler_type) { + bool is_signed; + + if (compiler_type.IsIntegerOrEnumerationType(is_signed)) { + ReadIntegerArgument(value->GetScalar(), + compiler_type.GetBitSize(&thread), is_signed, + thread.GetProcess().get(), current_stack_argument); + } else if (compiler_type.IsPointerType()) { + ReadIntegerArgument(value->GetScalar(), + compiler_type.GetBitSize(&thread), false, + thread.GetProcess().get(), current_stack_argument); + } } - - CompilerType compiler_type = new_value_sp->GetCompilerType(); - if (!compiler_type) - { - error.SetErrorString ("Null clang type for return value."); - return error; + } + + return true; +} + +Error ABIMacOSX_i386::SetReturnValueObject(lldb::StackFrameSP &frame_sp, + lldb::ValueObjectSP &new_value_sp) { + Error error; + if (!new_value_sp) { + error.SetErrorString("Empty value object for return value."); + return error; + } + + CompilerType compiler_type = new_value_sp->GetCompilerType(); + if (!compiler_type) { + error.SetErrorString("Null clang type for return value."); + return error; + } + + Thread *thread = frame_sp->GetThread().get(); + + bool is_signed; + uint32_t count; + bool is_complex; + + RegisterContext *reg_ctx = thread->GetRegisterContext().get(); + + bool set_it_simple = false; + if (compiler_type.IsIntegerOrEnumerationType(is_signed) || + compiler_type.IsPointerType()) { + DataExtractor data; + Error data_error; + size_t num_bytes = new_value_sp->GetData(data, data_error); + if (data_error.Fail()) { + error.SetErrorStringWithFormat( + "Couldn't convert return value to raw data: %s", + data_error.AsCString()); + return error; } - - Thread *thread = frame_sp->GetThread().get(); - - bool is_signed; - uint32_t count; - bool is_complex; - - RegisterContext *reg_ctx = thread->GetRegisterContext().get(); - - bool set_it_simple = false; - if (compiler_type.IsIntegerOrEnumerationType (is_signed) || compiler_type.IsPointerType()) - { - DataExtractor data; - Error data_error; - size_t num_bytes = new_value_sp->GetData(data, data_error); - if (data_error.Fail()) - { - error.SetErrorStringWithFormat("Couldn't convert return value to raw data: %s", data_error.AsCString()); - return error; - } - lldb::offset_t offset = 0; - if (num_bytes <= 8) - { - const RegisterInfo *eax_info = reg_ctx->GetRegisterInfoByName("eax", 0); - if (num_bytes <= 4) - { - uint32_t raw_value = data.GetMaxU32(&offset, num_bytes); - - if (reg_ctx->WriteRegisterFromUnsigned (eax_info, raw_value)) - set_it_simple = true; - } - else - { - uint32_t raw_value = data.GetMaxU32(&offset, 4); - - if (reg_ctx->WriteRegisterFromUnsigned (eax_info, raw_value)) - { - const RegisterInfo *edx_info = reg_ctx->GetRegisterInfoByName("edx", 0); - uint32_t raw_value = data.GetMaxU32(&offset, num_bytes - offset); - - if (reg_ctx->WriteRegisterFromUnsigned (edx_info, raw_value)) - set_it_simple = true; - } - } - } - else - { - error.SetErrorString("We don't support returning longer than 64 bit integer values at present."); + lldb::offset_t offset = 0; + if (num_bytes <= 8) { + const RegisterInfo *eax_info = reg_ctx->GetRegisterInfoByName("eax", 0); + if (num_bytes <= 4) { + uint32_t raw_value = data.GetMaxU32(&offset, num_bytes); + + if (reg_ctx->WriteRegisterFromUnsigned(eax_info, raw_value)) + set_it_simple = true; + } else { + uint32_t raw_value = data.GetMaxU32(&offset, 4); + + if (reg_ctx->WriteRegisterFromUnsigned(eax_info, raw_value)) { + const RegisterInfo *edx_info = + reg_ctx->GetRegisterInfoByName("edx", 0); + uint32_t raw_value = data.GetMaxU32(&offset, num_bytes - offset); + + if (reg_ctx->WriteRegisterFromUnsigned(edx_info, raw_value)) + set_it_simple = true; } + } + } else { + error.SetErrorString("We don't support returning longer than 64 bit " + "integer values at present."); } - else if (compiler_type.IsFloatingPointType (count, is_complex)) - { - if (is_complex) - error.SetErrorString ("We don't support returning complex values at present"); - else - error.SetErrorString ("We don't support returning float values at present"); - } - - if (!set_it_simple) - error.SetErrorString ("We only support setting simple integer return types at present."); - - return error; + } else if (compiler_type.IsFloatingPointType(count, is_complex)) { + if (is_complex) + error.SetErrorString( + "We don't support returning complex values at present"); + else + error.SetErrorString( + "We don't support returning float values at present"); + } + + if (!set_it_simple) + error.SetErrorString( + "We only support setting simple integer return types at present."); + + return error; } ValueObjectSP -ABIMacOSX_i386::GetReturnValueObjectImpl (Thread &thread, - CompilerType &compiler_type) const -{ - Value value; - ValueObjectSP return_valobj_sp; - - if (!compiler_type) - return return_valobj_sp; - - //value.SetContext (Value::eContextTypeClangType, compiler_type.GetOpaqueQualType()); - value.SetCompilerType (compiler_type); - - RegisterContext *reg_ctx = thread.GetRegisterContext().get(); - if (!reg_ctx) - return return_valobj_sp; - - bool is_signed; - - if (compiler_type.IsIntegerOrEnumerationType (is_signed)) - { - size_t bit_width = compiler_type.GetBitSize(&thread); - - unsigned eax_id = reg_ctx->GetRegisterInfoByName("eax", 0)->kinds[eRegisterKindLLDB]; - unsigned edx_id = reg_ctx->GetRegisterInfoByName("edx", 0)->kinds[eRegisterKindLLDB]; - - switch (bit_width) - { - default: - case 128: - // Scalar can't hold 128-bit literals, so we don't handle this - return return_valobj_sp; - case 64: - uint64_t raw_value; - raw_value = thread.GetRegisterContext()->ReadRegisterAsUnsigned(eax_id, 0) & 0xffffffff; - raw_value |= (thread.GetRegisterContext()->ReadRegisterAsUnsigned(edx_id, 0) & 0xffffffff) << 32; - if (is_signed) - value.GetScalar() = (int64_t)raw_value; - else - value.GetScalar() = (uint64_t)raw_value; - break; - case 32: - if (is_signed) - value.GetScalar() = (int32_t)(thread.GetRegisterContext()->ReadRegisterAsUnsigned(eax_id, 0) & 0xffffffff); - else - value.GetScalar() = (uint32_t)(thread.GetRegisterContext()->ReadRegisterAsUnsigned(eax_id, 0) & 0xffffffff); - break; - case 16: - if (is_signed) - value.GetScalar() = (int16_t)(thread.GetRegisterContext()->ReadRegisterAsUnsigned(eax_id, 0) & 0xffff); - else - value.GetScalar() = (uint16_t)(thread.GetRegisterContext()->ReadRegisterAsUnsigned(eax_id, 0) & 0xffff); - break; - case 8: - if (is_signed) - value.GetScalar() = (int8_t)(thread.GetRegisterContext()->ReadRegisterAsUnsigned(eax_id, 0) & 0xff); - else - value.GetScalar() = (uint8_t)(thread.GetRegisterContext()->ReadRegisterAsUnsigned(eax_id, 0) & 0xff); - break; - } - } - else if (compiler_type.IsPointerType ()) - { - unsigned eax_id = reg_ctx->GetRegisterInfoByName("eax", 0)->kinds[eRegisterKindLLDB]; - uint32_t ptr = thread.GetRegisterContext()->ReadRegisterAsUnsigned(eax_id, 0) & 0xffffffff; - value.GetScalar() = ptr; - } - else - { - // not handled yet - return return_valobj_sp; +ABIMacOSX_i386::GetReturnValueObjectImpl(Thread &thread, + CompilerType &compiler_type) const { + Value value; + ValueObjectSP return_valobj_sp; + + if (!compiler_type) + return return_valobj_sp; + + // value.SetContext (Value::eContextTypeClangType, + // compiler_type.GetOpaqueQualType()); + value.SetCompilerType(compiler_type); + + RegisterContext *reg_ctx = thread.GetRegisterContext().get(); + if (!reg_ctx) + return return_valobj_sp; + + bool is_signed; + + if (compiler_type.IsIntegerOrEnumerationType(is_signed)) { + size_t bit_width = compiler_type.GetBitSize(&thread); + + unsigned eax_id = + reg_ctx->GetRegisterInfoByName("eax", 0)->kinds[eRegisterKindLLDB]; + unsigned edx_id = + reg_ctx->GetRegisterInfoByName("edx", 0)->kinds[eRegisterKindLLDB]; + + switch (bit_width) { + default: + case 128: + // Scalar can't hold 128-bit literals, so we don't handle this + return return_valobj_sp; + case 64: + uint64_t raw_value; + raw_value = + thread.GetRegisterContext()->ReadRegisterAsUnsigned(eax_id, 0) & + 0xffffffff; + raw_value |= + (thread.GetRegisterContext()->ReadRegisterAsUnsigned(edx_id, 0) & + 0xffffffff) + << 32; + if (is_signed) + value.GetScalar() = (int64_t)raw_value; + else + value.GetScalar() = (uint64_t)raw_value; + break; + case 32: + if (is_signed) + value.GetScalar() = (int32_t)( + thread.GetRegisterContext()->ReadRegisterAsUnsigned(eax_id, 0) & + 0xffffffff); + else + value.GetScalar() = (uint32_t)( + thread.GetRegisterContext()->ReadRegisterAsUnsigned(eax_id, 0) & + 0xffffffff); + break; + case 16: + if (is_signed) + value.GetScalar() = (int16_t)( + thread.GetRegisterContext()->ReadRegisterAsUnsigned(eax_id, 0) & + 0xffff); + else + value.GetScalar() = (uint16_t)( + thread.GetRegisterContext()->ReadRegisterAsUnsigned(eax_id, 0) & + 0xffff); + break; + case 8: + if (is_signed) + value.GetScalar() = (int8_t)( + thread.GetRegisterContext()->ReadRegisterAsUnsigned(eax_id, 0) & + 0xff); + else + value.GetScalar() = (uint8_t)( + thread.GetRegisterContext()->ReadRegisterAsUnsigned(eax_id, 0) & + 0xff); + break; } - - // If we get here, we have a valid Value, so make our ValueObject out of it: - - return_valobj_sp = ValueObjectConstResult::Create(thread.GetStackFrameAtIndex(0).get(), - value, - ConstString("")); + } else if (compiler_type.IsPointerType()) { + unsigned eax_id = + reg_ctx->GetRegisterInfoByName("eax", 0)->kinds[eRegisterKindLLDB]; + uint32_t ptr = + thread.GetRegisterContext()->ReadRegisterAsUnsigned(eax_id, 0) & + 0xffffffff; + value.GetScalar() = ptr; + } else { + // not handled yet return return_valobj_sp; + } + + // If we get here, we have a valid Value, so make our ValueObject out of it: + + return_valobj_sp = ValueObjectConstResult::Create( + thread.GetStackFrameAtIndex(0).get(), value, ConstString("")); + return return_valobj_sp; } // This defines the CFA as esp+4 // the saved pc is at CFA-4 (i.e. esp+0) // The saved esp is CFA+0 -bool -ABIMacOSX_i386::CreateFunctionEntryUnwindPlan (UnwindPlan &unwind_plan) -{ - unwind_plan.Clear(); - unwind_plan.SetRegisterKind (eRegisterKindDWARF); - - uint32_t sp_reg_num = dwarf_esp; - uint32_t pc_reg_num = dwarf_eip; - - UnwindPlan::RowSP row(new UnwindPlan::Row); - row->GetCFAValue().SetIsRegisterPlusOffset (sp_reg_num, 4); - row->SetRegisterLocationToAtCFAPlusOffset(pc_reg_num, -4, false); - row->SetRegisterLocationToIsCFAPlusOffset(sp_reg_num, 0, true); - unwind_plan.AppendRow (row); - unwind_plan.SetSourceName ("i386 at-func-entry default"); - unwind_plan.SetSourcedFromCompiler (eLazyBoolNo); - return true; +bool ABIMacOSX_i386::CreateFunctionEntryUnwindPlan(UnwindPlan &unwind_plan) { + unwind_plan.Clear(); + unwind_plan.SetRegisterKind(eRegisterKindDWARF); + + uint32_t sp_reg_num = dwarf_esp; + uint32_t pc_reg_num = dwarf_eip; + + UnwindPlan::RowSP row(new UnwindPlan::Row); + row->GetCFAValue().SetIsRegisterPlusOffset(sp_reg_num, 4); + row->SetRegisterLocationToAtCFAPlusOffset(pc_reg_num, -4, false); + row->SetRegisterLocationToIsCFAPlusOffset(sp_reg_num, 0, true); + unwind_plan.AppendRow(row); + unwind_plan.SetSourceName("i386 at-func-entry default"); + unwind_plan.SetSourcedFromCompiler(eLazyBoolNo); + return true; } // This defines the CFA as ebp+8 @@ -526,119 +1045,99 @@ ABIMacOSX_i386::CreateFunctionEntryUnwindPlan (UnwindPlan &unwind_plan) // The saved ebp is at CFA-8 (i.e. ebp+0) // The saved esp is CFA+0 -bool -ABIMacOSX_i386::CreateDefaultUnwindPlan (UnwindPlan &unwind_plan) -{ - unwind_plan.Clear (); - unwind_plan.SetRegisterKind (eRegisterKindDWARF); - - uint32_t fp_reg_num = dwarf_ebp; - uint32_t sp_reg_num = dwarf_esp; - uint32_t pc_reg_num = dwarf_eip; - - UnwindPlan::RowSP row(new UnwindPlan::Row); - const int32_t ptr_size = 4; - - row->GetCFAValue().SetIsRegisterPlusOffset (fp_reg_num, 2 * ptr_size); - row->SetOffset (0); - - row->SetRegisterLocationToAtCFAPlusOffset(fp_reg_num, ptr_size * -2, true); - row->SetRegisterLocationToAtCFAPlusOffset(pc_reg_num, ptr_size * -1, true); - row->SetRegisterLocationToIsCFAPlusOffset(sp_reg_num, 0, true); - - unwind_plan.AppendRow (row); - unwind_plan.SetSourceName ("i386 default unwind plan"); - unwind_plan.SetSourcedFromCompiler (eLazyBoolNo); - unwind_plan.SetUnwindPlanValidAtAllInstructions (eLazyBoolNo); - return true; +bool ABIMacOSX_i386::CreateDefaultUnwindPlan(UnwindPlan &unwind_plan) { + unwind_plan.Clear(); + unwind_plan.SetRegisterKind(eRegisterKindDWARF); + + uint32_t fp_reg_num = dwarf_ebp; + uint32_t sp_reg_num = dwarf_esp; + uint32_t pc_reg_num = dwarf_eip; + + UnwindPlan::RowSP row(new UnwindPlan::Row); + const int32_t ptr_size = 4; + + row->GetCFAValue().SetIsRegisterPlusOffset(fp_reg_num, 2 * ptr_size); + row->SetOffset(0); + + row->SetRegisterLocationToAtCFAPlusOffset(fp_reg_num, ptr_size * -2, true); + row->SetRegisterLocationToAtCFAPlusOffset(pc_reg_num, ptr_size * -1, true); + row->SetRegisterLocationToIsCFAPlusOffset(sp_reg_num, 0, true); + + unwind_plan.AppendRow(row); + unwind_plan.SetSourceName("i386 default unwind plan"); + unwind_plan.SetSourcedFromCompiler(eLazyBoolNo); + unwind_plan.SetUnwindPlanValidAtAllInstructions(eLazyBoolNo); + return true; } -bool -ABIMacOSX_i386::RegisterIsVolatile (const RegisterInfo *reg_info) -{ - return !RegisterIsCalleeSaved (reg_info); +bool ABIMacOSX_i386::RegisterIsVolatile(const RegisterInfo *reg_info) { + return !RegisterIsCalleeSaved(reg_info); } -// v. http://developer.apple.com/library/mac/#documentation/developertools/Conceptual/LowLevelABI/130-IA-32_Function_Calling_Conventions/IA32.html#//apple_ref/doc/uid/TP40002492-SW4 +// v. +// http://developer.apple.com/library/mac/#documentation/developertools/Conceptual/LowLevelABI/130-IA-32_Function_Calling_Conventions/IA32.html#//apple_ref/doc/uid/TP40002492-SW4 +// +// This document ("OS X ABI Function Call Guide", chapter "IA-32 Function +// Calling Conventions") +// says that the following registers on i386 are preserved aka non-volatile aka +// callee-saved: // -// This document ("OS X ABI Function Call Guide", chapter "IA-32 Function Calling Conventions") -// says that the following registers on i386 are preserved aka non-volatile aka callee-saved: -// // ebx, ebp, esi, edi, esp -bool -ABIMacOSX_i386::RegisterIsCalleeSaved (const RegisterInfo *reg_info) -{ - if (reg_info) - { - // Saved registers are ebx, ebp, esi, edi, esp, eip - const char *name = reg_info->name; - if (name[0] == 'e') - { - switch (name[1]) - { - case 'b': - if (name[2] == 'x' || name[2] == 'p') - return name[3] == '\0'; - break; - case 'd': - if (name[2] == 'i') - return name[3] == '\0'; - break; - case 'i': - if (name[2] == 'p') - return name[3] == '\0'; - break; - case 's': - if (name[2] == 'i' || name[2] == 'p') - return name[3] == '\0'; - break; - } - } - if (name[0] == 's' && name[1] == 'p' && name[2] == '\0') // sp - return true; - if (name[0] == 'f' && name[1] == 'p' && name[2] == '\0') // fp - return true; - if (name[0] == 'p' && name[1] == 'c' && name[2] == '\0') // pc - return true; +bool ABIMacOSX_i386::RegisterIsCalleeSaved(const RegisterInfo *reg_info) { + if (reg_info) { + // Saved registers are ebx, ebp, esi, edi, esp, eip + const char *name = reg_info->name; + if (name[0] == 'e') { + switch (name[1]) { + case 'b': + if (name[2] == 'x' || name[2] == 'p') + return name[3] == '\0'; + break; + case 'd': + if (name[2] == 'i') + return name[3] == '\0'; + break; + case 'i': + if (name[2] == 'p') + return name[3] == '\0'; + break; + case 's': + if (name[2] == 'i' || name[2] == 'p') + return name[3] == '\0'; + break; + } } - return false; + if (name[0] == 's' && name[1] == 'p' && name[2] == '\0') // sp + return true; + if (name[0] == 'f' && name[1] == 'p' && name[2] == '\0') // fp + return true; + if (name[0] == 'p' && name[1] == 'c' && name[2] == '\0') // pc + return true; + } + return false; } -void -ABIMacOSX_i386::Initialize() -{ - PluginManager::RegisterPlugin (GetPluginNameStatic(), - "Mac OS X ABI for i386 targets", - CreateInstance); +void ABIMacOSX_i386::Initialize() { + PluginManager::RegisterPlugin( + GetPluginNameStatic(), "Mac OS X ABI for i386 targets", CreateInstance); } -void -ABIMacOSX_i386::Terminate() -{ - PluginManager::UnregisterPlugin (CreateInstance); +void ABIMacOSX_i386::Terminate() { + PluginManager::UnregisterPlugin(CreateInstance); } -lldb_private::ConstString -ABIMacOSX_i386::GetPluginNameStatic () -{ - static ConstString g_short_name("abi.macosx-i386"); - return g_short_name; - +lldb_private::ConstString ABIMacOSX_i386::GetPluginNameStatic() { + static ConstString g_short_name("abi.macosx-i386"); + return g_short_name; } //------------------------------------------------------------------ // PluginInterface protocol //------------------------------------------------------------------ -lldb_private::ConstString -ABIMacOSX_i386::GetPluginName() -{ - return GetPluginNameStatic(); +lldb_private::ConstString ABIMacOSX_i386::GetPluginName() { + return GetPluginNameStatic(); } -uint32_t -ABIMacOSX_i386::GetPluginVersion() -{ - return 1; -} +uint32_t ABIMacOSX_i386::GetPluginVersion() { return 1; } diff --git a/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.h b/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.h index 6a82fce35bf7..4a2555ac61a2 100644 --- a/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.h +++ b/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.h @@ -14,116 +14,96 @@ // C++ Includes // Other libraries and framework includes // Project includes -#include "lldb/lldb-private.h" -#include "lldb/Target/ABI.h" #include "lldb/Core/Value.h" - -class ABIMacOSX_i386 : - public lldb_private::ABI -{ +#include "lldb/Target/ABI.h" +#include "lldb/lldb-private.h" + +class ABIMacOSX_i386 : public lldb_private::ABI { public: - ~ABIMacOSX_i386() override = default; - - size_t - GetRedZoneSize() const override; - - bool - PrepareTrivialCall(lldb_private::Thread &thread, - lldb::addr_t sp, - lldb::addr_t func_addr, - lldb::addr_t return_addr, - llvm::ArrayRef<lldb::addr_t> args) const override; - - bool - GetArgumentValues(lldb_private::Thread &thread, - lldb_private::ValueList &values) const override; - - lldb_private::Error - SetReturnValueObject(lldb::StackFrameSP &frame_sp, lldb::ValueObjectSP &new_value) override; - - bool - CreateFunctionEntryUnwindPlan(lldb_private::UnwindPlan &unwind_plan) override; - - bool - CreateDefaultUnwindPlan(lldb_private::UnwindPlan &unwind_plan) override; - - bool - RegisterIsVolatile(const lldb_private::RegisterInfo *reg_info) override; - - // The Darwin i386 ABI requires that stack frames be 16 byte aligned. - // When there is a trap handler on the stack, e.g. _sigtramp in userland - // code, we've seen that the stack pointer is often not aligned properly - // before the handler is invoked. This means that lldb will stop the unwind - // early -- before the function which caused the trap. - // - // To work around this, we relax that alignment to be just word-size (4-bytes). - // Whitelisting the trap handlers for user space would be easy (_sigtramp) but - // in other environments there can be a large number of different functions - // involved in async traps. - // - // If we were to enforce 16-byte alignment, we also need to relax to 4-byte - // alignment for non-darwin i386 targets. - bool - CallFrameAddressIsValid(lldb::addr_t cfa) override - { - // Make sure the stack call frame addresses are are 4 byte aligned - if (cfa & (4ull - 1ull)) - return false; // Not 4 byte aligned - if (cfa == 0) - return false; // Zero is not a valid stack address - return true; - } - - bool - CodeAddressIsValid(lldb::addr_t pc) override - { - // Just make sure the address is a valid 32 bit address. - return pc <= UINT32_MAX; - } - - const lldb_private::RegisterInfo * - GetRegisterInfoArray(uint32_t &count) override; - - //------------------------------------------------------------------ - // Static Functions - //------------------------------------------------------------------ - - static void - Initialize(); - - static void - Terminate(); - - static lldb::ABISP - CreateInstance (const lldb_private::ArchSpec &arch); - - //------------------------------------------------------------------ - // PluginInterface protocol - //------------------------------------------------------------------ - - static lldb_private::ConstString - GetPluginNameStatic (); - - lldb_private::ConstString - GetPluginName() override; - - uint32_t - GetPluginVersion() override; - + ~ABIMacOSX_i386() override = default; + + size_t GetRedZoneSize() const override; + + bool PrepareTrivialCall(lldb_private::Thread &thread, lldb::addr_t sp, + lldb::addr_t func_addr, lldb::addr_t return_addr, + llvm::ArrayRef<lldb::addr_t> args) const override; + + bool GetArgumentValues(lldb_private::Thread &thread, + lldb_private::ValueList &values) const override; + + lldb_private::Error + SetReturnValueObject(lldb::StackFrameSP &frame_sp, + lldb::ValueObjectSP &new_value) override; + + bool + CreateFunctionEntryUnwindPlan(lldb_private::UnwindPlan &unwind_plan) override; + + bool CreateDefaultUnwindPlan(lldb_private::UnwindPlan &unwind_plan) override; + + bool RegisterIsVolatile(const lldb_private::RegisterInfo *reg_info) override; + + // The Darwin i386 ABI requires that stack frames be 16 byte aligned. + // When there is a trap handler on the stack, e.g. _sigtramp in userland + // code, we've seen that the stack pointer is often not aligned properly + // before the handler is invoked. This means that lldb will stop the unwind + // early -- before the function which caused the trap. + // + // To work around this, we relax that alignment to be just word-size + // (4-bytes). + // Whitelisting the trap handlers for user space would be easy (_sigtramp) but + // in other environments there can be a large number of different functions + // involved in async traps. + // + // If we were to enforce 16-byte alignment, we also need to relax to 4-byte + // alignment for non-darwin i386 targets. + bool CallFrameAddressIsValid(lldb::addr_t cfa) override { + // Make sure the stack call frame addresses are are 4 byte aligned + if (cfa & (4ull - 1ull)) + return false; // Not 4 byte aligned + if (cfa == 0) + return false; // Zero is not a valid stack address + return true; + } + + bool CodeAddressIsValid(lldb::addr_t pc) override { + // Just make sure the address is a valid 32 bit address. + return pc <= UINT32_MAX; + } + + const lldb_private::RegisterInfo * + GetRegisterInfoArray(uint32_t &count) override; + + //------------------------------------------------------------------ + // Static Functions + //------------------------------------------------------------------ + + static void Initialize(); + + static void Terminate(); + + static lldb::ABISP CreateInstance(const lldb_private::ArchSpec &arch); + + //------------------------------------------------------------------ + // PluginInterface protocol + //------------------------------------------------------------------ + + static lldb_private::ConstString GetPluginNameStatic(); + + lldb_private::ConstString GetPluginName() override; + + uint32_t GetPluginVersion() override; + protected: - lldb::ValueObjectSP - GetReturnValueObjectImpl(lldb_private::Thread &thread, - lldb_private::CompilerType &ast_type) const override; + lldb::ValueObjectSP + GetReturnValueObjectImpl(lldb_private::Thread &thread, + lldb_private::CompilerType &ast_type) const override; - bool - RegisterIsCalleeSaved (const lldb_private::RegisterInfo *reg_info); + bool RegisterIsCalleeSaved(const lldb_private::RegisterInfo *reg_info); private: - ABIMacOSX_i386() : - lldb_private::ABI() - { - // Call CreateInstance instead. - } + ABIMacOSX_i386() : lldb_private::ABI() { + // Call CreateInstance instead. + } }; #endif // liblldb_ABIMacOSX_i386_h_ diff --git a/source/Plugins/ABI/SysV-arm/ABISysV_arm.cpp b/source/Plugins/ABI/SysV-arm/ABISysV_arm.cpp index c23b41c11ccb..ebd0d17cf8ab 100644 --- a/source/Plugins/ABI/SysV-arm/ABISysV_arm.cpp +++ b/source/Plugins/ABI/SysV-arm/ABISysV_arm.cpp @@ -32,855 +32,1943 @@ #include "lldb/Target/Target.h" #include "lldb/Target/Thread.h" +#include "Plugins/Process/Utility/ARMDefines.h" #include "Utility/ARM_DWARF_Registers.h" #include "Utility/ARM_ehframe_Registers.h" -#include "Plugins/Process/Utility/ARMDefines.h" using namespace lldb; using namespace lldb_private; -static RegisterInfo g_register_infos[] = -{ - // NAME ALT SZ OFF ENCODING FORMAT EH_FRAME DWARF GENERIC PROCESS PLUGIN LLDB NATIVE VALUE REGS INVALIDATE REGS - // ========== ======= == === ============= ============ ======================= =================== =========================== ======================= ====================== ========== =============== - { "r0", "arg1", 4, 0, eEncodingUint , eFormatHex, { ehframe_r0, dwarf_r0, LLDB_REGNUM_GENERIC_ARG1, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "r1", "arg2", 4, 0, eEncodingUint , eFormatHex, { ehframe_r1, dwarf_r1, LLDB_REGNUM_GENERIC_ARG2, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "r2", "arg3", 4, 0, eEncodingUint , eFormatHex, { ehframe_r2, dwarf_r2, LLDB_REGNUM_GENERIC_ARG3, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "r3", "arg4", 4, 0, eEncodingUint , eFormatHex, { ehframe_r3, dwarf_r3, LLDB_REGNUM_GENERIC_ARG4, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "r4", nullptr, 4, 0, eEncodingUint , eFormatHex, { ehframe_r4, dwarf_r4, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "r5", nullptr, 4, 0, eEncodingUint , eFormatHex, { ehframe_r5, dwarf_r5, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "r6", nullptr, 4, 0, eEncodingUint , eFormatHex, { ehframe_r6, dwarf_r6, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "r7", nullptr, 4, 0, eEncodingUint , eFormatHex, { ehframe_r7, dwarf_r7, LLDB_REGNUM_GENERIC_FP, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "r8", nullptr, 4, 0, eEncodingUint , eFormatHex, { ehframe_r8, dwarf_r8, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "r9", nullptr, 4, 0, eEncodingUint , eFormatHex, { ehframe_r9, dwarf_r9, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "r10", nullptr, 4, 0, eEncodingUint , eFormatHex, { ehframe_r10, dwarf_r10, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "r11", nullptr, 4, 0, eEncodingUint , eFormatHex, { ehframe_r11, dwarf_r11, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "r12", nullptr, 4, 0, eEncodingUint , eFormatHex, { ehframe_r12, dwarf_r12, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "sp", "r13", 4, 0, eEncodingUint , eFormatHex, { ehframe_sp, dwarf_sp, LLDB_REGNUM_GENERIC_SP, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "lr", "r14", 4, 0, eEncodingUint , eFormatHex, { ehframe_lr, dwarf_lr, LLDB_REGNUM_GENERIC_RA, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "pc", "r15", 4, 0, eEncodingUint , eFormatHex, { ehframe_pc, dwarf_pc, LLDB_REGNUM_GENERIC_PC, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "cpsr", "psr", 4, 0, eEncodingUint , eFormatHex, { ehframe_cpsr, dwarf_cpsr, LLDB_REGNUM_GENERIC_FLAGS, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "s0", nullptr, 4, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s0, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "s1", nullptr, 4, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s1, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "s2", nullptr, 4, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s2, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "s3", nullptr, 4, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s3, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "s4", nullptr, 4, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s4, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "s5", nullptr, 4, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s5, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "s6", nullptr, 4, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s6, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "s7", nullptr, 4, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s7, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "s8", nullptr, 4, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s8, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "s9", nullptr, 4, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s9, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "s10", nullptr, 4, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s10, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "s11", nullptr, 4, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s11, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "s12", nullptr, 4, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s12, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "s13", nullptr, 4, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s13, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "s14", nullptr, 4, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s14, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "s15", nullptr, 4, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s15, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "s16", nullptr, 4, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s16, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "s17", nullptr, 4, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s17, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "s18", nullptr, 4, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s18, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "s19", nullptr, 4, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s19, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "s20", nullptr, 4, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s20, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "s21", nullptr, 4, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s21, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "s22", nullptr, 4, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s22, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "s23", nullptr, 4, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s23, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "s24", nullptr, 4, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s24, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "s25", nullptr, 4, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s25, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "s26", nullptr, 4, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s26, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "s27", nullptr, 4, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s27, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "s28", nullptr, 4, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s28, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "s29", nullptr, 4, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s29, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "s30", nullptr, 4, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s30, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "s31", nullptr, 4, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s31, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "fpscr", nullptr, 4, 0, eEncodingUint , eFormatHex , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "d0", nullptr, 8, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d0, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "d1", nullptr, 8, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d1, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "d2", nullptr, 8, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d2, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "d3", nullptr, 8, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d3, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "d4", nullptr, 8, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d4, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "d5", nullptr, 8, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d5, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "d6", nullptr, 8, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d6, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "d7", nullptr, 8, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d7, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "d8", nullptr, 8, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d8, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "d9", nullptr, 8, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d9, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "d10", nullptr, 8, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d10, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "d11", nullptr, 8, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d11, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "d12", nullptr, 8, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d12, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "d13", nullptr, 8, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d13, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "d14", nullptr, 8, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d14, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "d15", nullptr, 8, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d15, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "d16", nullptr, 8, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d16, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "d17", nullptr, 8, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d17, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "d18", nullptr, 8, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d18, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "d19", nullptr, 8, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d19, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "d20", nullptr, 8, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d20, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "d21", nullptr, 8, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d21, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "d22", nullptr, 8, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d22, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "d23", nullptr, 8, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d23, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "d24", nullptr, 8, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d24, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "d25", nullptr, 8, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d25, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "d26", nullptr, 8, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d26, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "d27", nullptr, 8, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d27, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "d28", nullptr, 8, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d28, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "d29", nullptr, 8, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d29, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "d30", nullptr, 8, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d30, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "d31", nullptr, 8, 0, eEncodingIEEE754 , eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d31, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "r8_usr", nullptr, 4, 0, eEncodingUint , eFormatHex, { LLDB_INVALID_REGNUM, dwarf_r8_usr, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "r9_usr", nullptr, 4, 0, eEncodingUint , eFormatHex, { LLDB_INVALID_REGNUM, dwarf_r9_usr, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "r10_usr", nullptr, 4, 0, eEncodingUint , eFormatHex, { LLDB_INVALID_REGNUM, dwarf_r10_usr, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "r11_usr", nullptr, 4, 0, eEncodingUint , eFormatHex, { LLDB_INVALID_REGNUM, dwarf_r11_usr, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "r12_usr", nullptr, 4, 0, eEncodingUint , eFormatHex, { LLDB_INVALID_REGNUM, dwarf_r12_usr, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "r13_usr", "sp_usr", 4, 0, eEncodingUint , eFormatHex, { LLDB_INVALID_REGNUM, dwarf_r13_usr, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "r14_usr", "lr_usr", 4, 0, eEncodingUint , eFormatHex, { LLDB_INVALID_REGNUM, dwarf_r14_usr, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "r8_fiq", nullptr, 4, 0, eEncodingUint , eFormatHex, { LLDB_INVALID_REGNUM, dwarf_r8_fiq, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "r9_fiq", nullptr, 4, 0, eEncodingUint , eFormatHex, { LLDB_INVALID_REGNUM, dwarf_r9_fiq, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "r10_fiq", nullptr, 4, 0, eEncodingUint , eFormatHex, { LLDB_INVALID_REGNUM, dwarf_r10_fiq, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "r11_fiq", nullptr, 4, 0, eEncodingUint , eFormatHex, { LLDB_INVALID_REGNUM, dwarf_r11_fiq, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "r12_fiq", nullptr, 4, 0, eEncodingUint , eFormatHex, { LLDB_INVALID_REGNUM, dwarf_r12_fiq, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "r13_fiq", "sp_fiq", 4, 0, eEncodingUint , eFormatHex, { LLDB_INVALID_REGNUM, dwarf_r13_fiq, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "r14_fiq", "lr_fiq", 4, 0, eEncodingUint , eFormatHex, { LLDB_INVALID_REGNUM, dwarf_r14_fiq, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "r13_irq", "sp_irq", 4, 0, eEncodingUint , eFormatHex, { LLDB_INVALID_REGNUM, dwarf_r13_irq, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "r14_irq", "lr_irq", 4, 0, eEncodingUint , eFormatHex, { LLDB_INVALID_REGNUM, dwarf_r14_irq, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "r13_abt", "sp_abt", 4, 0, eEncodingUint , eFormatHex, { LLDB_INVALID_REGNUM, dwarf_r13_abt, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "r14_abt", "lr_abt", 4, 0, eEncodingUint , eFormatHex, { LLDB_INVALID_REGNUM, dwarf_r14_abt, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "r13_und", "sp_und", 4, 0, eEncodingUint , eFormatHex, { LLDB_INVALID_REGNUM, dwarf_r13_und, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "r14_und", "lr_und", 4, 0, eEncodingUint , eFormatHex, { LLDB_INVALID_REGNUM, dwarf_r14_und, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "r13_svc", "sp_svc", 4, 0, eEncodingUint , eFormatHex, { LLDB_INVALID_REGNUM, dwarf_r13_svc, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "r14_svc", "lr_svc", 4, 0, eEncodingUint , eFormatHex, { LLDB_INVALID_REGNUM, dwarf_r14_svc, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr } -}; - -static const uint32_t k_num_register_infos = llvm::array_lengthof(g_register_infos); +static RegisterInfo g_register_infos[] = { + // NAME ALT SZ OFF ENCODING FORMAT EH_FRAME + // DWARF GENERIC PROCESS PLUGIN + // LLDB NATIVE VALUE REGS INVALIDATE REGS + // ========== ======= == === ============= ============ + // ======================= =================== =========================== + // ======================= ====================== ========== + // =============== + {"r0", + "arg1", + 4, + 0, + eEncodingUint, + eFormatHex, + {ehframe_r0, dwarf_r0, LLDB_REGNUM_GENERIC_ARG1, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"r1", + "arg2", + 4, + 0, + eEncodingUint, + eFormatHex, + {ehframe_r1, dwarf_r1, LLDB_REGNUM_GENERIC_ARG2, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"r2", + "arg3", + 4, + 0, + eEncodingUint, + eFormatHex, + {ehframe_r2, dwarf_r2, LLDB_REGNUM_GENERIC_ARG3, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"r3", + "arg4", + 4, + 0, + eEncodingUint, + eFormatHex, + {ehframe_r3, dwarf_r3, LLDB_REGNUM_GENERIC_ARG4, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"r4", + nullptr, + 4, + 0, + eEncodingUint, + eFormatHex, + {ehframe_r4, dwarf_r4, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"r5", + nullptr, + 4, + 0, + eEncodingUint, + eFormatHex, + {ehframe_r5, dwarf_r5, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"r6", + nullptr, + 4, + 0, + eEncodingUint, + eFormatHex, + {ehframe_r6, dwarf_r6, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"r7", + nullptr, + 4, + 0, + eEncodingUint, + eFormatHex, + {ehframe_r7, dwarf_r7, LLDB_REGNUM_GENERIC_FP, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"r8", + nullptr, + 4, + 0, + eEncodingUint, + eFormatHex, + {ehframe_r8, dwarf_r8, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"r9", + nullptr, + 4, + 0, + eEncodingUint, + eFormatHex, + {ehframe_r9, dwarf_r9, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"r10", + nullptr, + 4, + 0, + eEncodingUint, + eFormatHex, + {ehframe_r10, dwarf_r10, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"r11", + nullptr, + 4, + 0, + eEncodingUint, + eFormatHex, + {ehframe_r11, dwarf_r11, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"r12", + nullptr, + 4, + 0, + eEncodingUint, + eFormatHex, + {ehframe_r12, dwarf_r12, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"sp", + "r13", + 4, + 0, + eEncodingUint, + eFormatHex, + {ehframe_sp, dwarf_sp, LLDB_REGNUM_GENERIC_SP, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"lr", + "r14", + 4, + 0, + eEncodingUint, + eFormatHex, + {ehframe_lr, dwarf_lr, LLDB_REGNUM_GENERIC_RA, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"pc", + "r15", + 4, + 0, + eEncodingUint, + eFormatHex, + {ehframe_pc, dwarf_pc, LLDB_REGNUM_GENERIC_PC, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"cpsr", + "psr", + 4, + 0, + eEncodingUint, + eFormatHex, + {ehframe_cpsr, dwarf_cpsr, LLDB_REGNUM_GENERIC_FLAGS, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"s0", + nullptr, + 4, + 0, + eEncodingIEEE754, + eFormatFloat, + {LLDB_INVALID_REGNUM, dwarf_s0, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"s1", + nullptr, + 4, + 0, + eEncodingIEEE754, + eFormatFloat, + {LLDB_INVALID_REGNUM, dwarf_s1, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"s2", + nullptr, + 4, + 0, + eEncodingIEEE754, + eFormatFloat, + {LLDB_INVALID_REGNUM, dwarf_s2, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"s3", + nullptr, + 4, + 0, + eEncodingIEEE754, + eFormatFloat, + {LLDB_INVALID_REGNUM, dwarf_s3, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"s4", + nullptr, + 4, + 0, + eEncodingIEEE754, + eFormatFloat, + {LLDB_INVALID_REGNUM, dwarf_s4, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"s5", + nullptr, + 4, + 0, + eEncodingIEEE754, + eFormatFloat, + {LLDB_INVALID_REGNUM, dwarf_s5, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"s6", + nullptr, + 4, + 0, + eEncodingIEEE754, + eFormatFloat, + {LLDB_INVALID_REGNUM, dwarf_s6, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"s7", + nullptr, + 4, + 0, + eEncodingIEEE754, + eFormatFloat, + {LLDB_INVALID_REGNUM, dwarf_s7, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"s8", + nullptr, + 4, + 0, + eEncodingIEEE754, + eFormatFloat, + {LLDB_INVALID_REGNUM, dwarf_s8, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"s9", + nullptr, + 4, + 0, + eEncodingIEEE754, + eFormatFloat, + {LLDB_INVALID_REGNUM, dwarf_s9, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"s10", + nullptr, + 4, + 0, + eEncodingIEEE754, + eFormatFloat, + {LLDB_INVALID_REGNUM, dwarf_s10, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"s11", + nullptr, + 4, + 0, + eEncodingIEEE754, + eFormatFloat, + {LLDB_INVALID_REGNUM, dwarf_s11, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"s12", + nullptr, + 4, + 0, + eEncodingIEEE754, + eFormatFloat, + {LLDB_INVALID_REGNUM, dwarf_s12, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"s13", + nullptr, + 4, + 0, + eEncodingIEEE754, + eFormatFloat, + {LLDB_INVALID_REGNUM, dwarf_s13, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"s14", + nullptr, + 4, + 0, + eEncodingIEEE754, + eFormatFloat, + {LLDB_INVALID_REGNUM, dwarf_s14, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"s15", + nullptr, + 4, + 0, + eEncodingIEEE754, + eFormatFloat, + {LLDB_INVALID_REGNUM, dwarf_s15, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"s16", + nullptr, + 4, + 0, + eEncodingIEEE754, + eFormatFloat, + {LLDB_INVALID_REGNUM, dwarf_s16, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"s17", + nullptr, + 4, + 0, + eEncodingIEEE754, + eFormatFloat, + {LLDB_INVALID_REGNUM, dwarf_s17, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"s18", + nullptr, + 4, + 0, + eEncodingIEEE754, + eFormatFloat, + {LLDB_INVALID_REGNUM, dwarf_s18, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"s19", + nullptr, + 4, + 0, + eEncodingIEEE754, + eFormatFloat, + {LLDB_INVALID_REGNUM, dwarf_s19, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"s20", + nullptr, + 4, + 0, + eEncodingIEEE754, + eFormatFloat, + {LLDB_INVALID_REGNUM, dwarf_s20, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"s21", + nullptr, + 4, + 0, + eEncodingIEEE754, + eFormatFloat, + {LLDB_INVALID_REGNUM, dwarf_s21, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"s22", + nullptr, + 4, + 0, + eEncodingIEEE754, + eFormatFloat, + {LLDB_INVALID_REGNUM, dwarf_s22, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"s23", + nullptr, + 4, + 0, + eEncodingIEEE754, + eFormatFloat, + {LLDB_INVALID_REGNUM, dwarf_s23, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"s24", + nullptr, + 4, + 0, + eEncodingIEEE754, + eFormatFloat, + {LLDB_INVALID_REGNUM, dwarf_s24, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"s25", + nullptr, + 4, + 0, + eEncodingIEEE754, + eFormatFloat, + {LLDB_INVALID_REGNUM, dwarf_s25, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"s26", + nullptr, + 4, + 0, + eEncodingIEEE754, + eFormatFloat, + {LLDB_INVALID_REGNUM, dwarf_s26, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"s27", + nullptr, + 4, + 0, + eEncodingIEEE754, + eFormatFloat, + {LLDB_INVALID_REGNUM, dwarf_s27, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"s28", + nullptr, + 4, + 0, + eEncodingIEEE754, + eFormatFloat, + {LLDB_INVALID_REGNUM, dwarf_s28, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"s29", + nullptr, + 4, + 0, + eEncodingIEEE754, + eFormatFloat, + {LLDB_INVALID_REGNUM, dwarf_s29, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"s30", + nullptr, + 4, + 0, + eEncodingIEEE754, + eFormatFloat, + {LLDB_INVALID_REGNUM, dwarf_s30, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"s31", + nullptr, + 4, + 0, + eEncodingIEEE754, + eFormatFloat, + {LLDB_INVALID_REGNUM, dwarf_s31, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"fpscr", + nullptr, + 4, + 0, + eEncodingUint, + eFormatHex, + {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"d0", + nullptr, + 8, + 0, + eEncodingIEEE754, + eFormatFloat, + {LLDB_INVALID_REGNUM, dwarf_d0, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"d1", + nullptr, + 8, + 0, + eEncodingIEEE754, + eFormatFloat, + {LLDB_INVALID_REGNUM, dwarf_d1, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"d2", + nullptr, + 8, + 0, + eEncodingIEEE754, + eFormatFloat, + {LLDB_INVALID_REGNUM, dwarf_d2, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"d3", + nullptr, + 8, + 0, + eEncodingIEEE754, + eFormatFloat, + {LLDB_INVALID_REGNUM, dwarf_d3, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"d4", + nullptr, + 8, + 0, + eEncodingIEEE754, + eFormatFloat, + {LLDB_INVALID_REGNUM, dwarf_d4, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"d5", + nullptr, + 8, + 0, + eEncodingIEEE754, + eFormatFloat, + {LLDB_INVALID_REGNUM, dwarf_d5, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"d6", + nullptr, + 8, + 0, + eEncodingIEEE754, + eFormatFloat, + {LLDB_INVALID_REGNUM, dwarf_d6, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"d7", + nullptr, + 8, + 0, + eEncodingIEEE754, + eFormatFloat, + {LLDB_INVALID_REGNUM, dwarf_d7, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"d8", + nullptr, + 8, + 0, + eEncodingIEEE754, + eFormatFloat, + {LLDB_INVALID_REGNUM, dwarf_d8, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"d9", + nullptr, + 8, + 0, + eEncodingIEEE754, + eFormatFloat, + {LLDB_INVALID_REGNUM, dwarf_d9, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"d10", + nullptr, + 8, + 0, + eEncodingIEEE754, + eFormatFloat, + {LLDB_INVALID_REGNUM, dwarf_d10, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"d11", + nullptr, + 8, + 0, + eEncodingIEEE754, + eFormatFloat, + {LLDB_INVALID_REGNUM, dwarf_d11, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"d12", + nullptr, + 8, + 0, + eEncodingIEEE754, + eFormatFloat, + {LLDB_INVALID_REGNUM, dwarf_d12, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"d13", + nullptr, + 8, + 0, + eEncodingIEEE754, + eFormatFloat, + {LLDB_INVALID_REGNUM, dwarf_d13, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"d14", + nullptr, + 8, + 0, + eEncodingIEEE754, + eFormatFloat, + {LLDB_INVALID_REGNUM, dwarf_d14, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"d15", + nullptr, + 8, + 0, + eEncodingIEEE754, + eFormatFloat, + {LLDB_INVALID_REGNUM, dwarf_d15, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"d16", + nullptr, + 8, + 0, + eEncodingIEEE754, + eFormatFloat, + {LLDB_INVALID_REGNUM, dwarf_d16, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"d17", + nullptr, + 8, + 0, + eEncodingIEEE754, + eFormatFloat, + {LLDB_INVALID_REGNUM, dwarf_d17, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"d18", + nullptr, + 8, + 0, + eEncodingIEEE754, + eFormatFloat, + {LLDB_INVALID_REGNUM, dwarf_d18, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"d19", + nullptr, + 8, + 0, + eEncodingIEEE754, + eFormatFloat, + {LLDB_INVALID_REGNUM, dwarf_d19, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"d20", + nullptr, + 8, + 0, + eEncodingIEEE754, + eFormatFloat, + {LLDB_INVALID_REGNUM, dwarf_d20, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"d21", + nullptr, + 8, + 0, + eEncodingIEEE754, + eFormatFloat, + {LLDB_INVALID_REGNUM, dwarf_d21, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"d22", + nullptr, + 8, + 0, + eEncodingIEEE754, + eFormatFloat, + {LLDB_INVALID_REGNUM, dwarf_d22, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"d23", + nullptr, + 8, + 0, + eEncodingIEEE754, + eFormatFloat, + {LLDB_INVALID_REGNUM, dwarf_d23, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"d24", + nullptr, + 8, + 0, + eEncodingIEEE754, + eFormatFloat, + {LLDB_INVALID_REGNUM, dwarf_d24, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"d25", + nullptr, + 8, + 0, + eEncodingIEEE754, + eFormatFloat, + {LLDB_INVALID_REGNUM, dwarf_d25, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"d26", + nullptr, + 8, + 0, + eEncodingIEEE754, + eFormatFloat, + {LLDB_INVALID_REGNUM, dwarf_d26, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"d27", + nullptr, + 8, + 0, + eEncodingIEEE754, + eFormatFloat, + {LLDB_INVALID_REGNUM, dwarf_d27, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"d28", + nullptr, + 8, + 0, + eEncodingIEEE754, + eFormatFloat, + {LLDB_INVALID_REGNUM, dwarf_d28, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"d29", + nullptr, + 8, + 0, + eEncodingIEEE754, + eFormatFloat, + {LLDB_INVALID_REGNUM, dwarf_d29, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"d30", + nullptr, + 8, + 0, + eEncodingIEEE754, + eFormatFloat, + {LLDB_INVALID_REGNUM, dwarf_d30, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"d31", + nullptr, + 8, + 0, + eEncodingIEEE754, + eFormatFloat, + {LLDB_INVALID_REGNUM, dwarf_d31, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"r8_usr", + nullptr, + 4, + 0, + eEncodingUint, + eFormatHex, + {LLDB_INVALID_REGNUM, dwarf_r8_usr, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"r9_usr", + nullptr, + 4, + 0, + eEncodingUint, + eFormatHex, + {LLDB_INVALID_REGNUM, dwarf_r9_usr, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"r10_usr", + nullptr, + 4, + 0, + eEncodingUint, + eFormatHex, + {LLDB_INVALID_REGNUM, dwarf_r10_usr, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"r11_usr", + nullptr, + 4, + 0, + eEncodingUint, + eFormatHex, + {LLDB_INVALID_REGNUM, dwarf_r11_usr, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"r12_usr", + nullptr, + 4, + 0, + eEncodingUint, + eFormatHex, + {LLDB_INVALID_REGNUM, dwarf_r12_usr, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"r13_usr", + "sp_usr", + 4, + 0, + eEncodingUint, + eFormatHex, + {LLDB_INVALID_REGNUM, dwarf_r13_usr, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"r14_usr", + "lr_usr", + 4, + 0, + eEncodingUint, + eFormatHex, + {LLDB_INVALID_REGNUM, dwarf_r14_usr, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"r8_fiq", + nullptr, + 4, + 0, + eEncodingUint, + eFormatHex, + {LLDB_INVALID_REGNUM, dwarf_r8_fiq, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"r9_fiq", + nullptr, + 4, + 0, + eEncodingUint, + eFormatHex, + {LLDB_INVALID_REGNUM, dwarf_r9_fiq, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"r10_fiq", + nullptr, + 4, + 0, + eEncodingUint, + eFormatHex, + {LLDB_INVALID_REGNUM, dwarf_r10_fiq, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"r11_fiq", + nullptr, + 4, + 0, + eEncodingUint, + eFormatHex, + {LLDB_INVALID_REGNUM, dwarf_r11_fiq, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"r12_fiq", + nullptr, + 4, + 0, + eEncodingUint, + eFormatHex, + {LLDB_INVALID_REGNUM, dwarf_r12_fiq, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"r13_fiq", + "sp_fiq", + 4, + 0, + eEncodingUint, + eFormatHex, + {LLDB_INVALID_REGNUM, dwarf_r13_fiq, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"r14_fiq", + "lr_fiq", + 4, + 0, + eEncodingUint, + eFormatHex, + {LLDB_INVALID_REGNUM, dwarf_r14_fiq, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"r13_irq", + "sp_irq", + 4, + 0, + eEncodingUint, + eFormatHex, + {LLDB_INVALID_REGNUM, dwarf_r13_irq, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"r14_irq", + "lr_irq", + 4, + 0, + eEncodingUint, + eFormatHex, + {LLDB_INVALID_REGNUM, dwarf_r14_irq, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"r13_abt", + "sp_abt", + 4, + 0, + eEncodingUint, + eFormatHex, + {LLDB_INVALID_REGNUM, dwarf_r13_abt, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"r14_abt", + "lr_abt", + 4, + 0, + eEncodingUint, + eFormatHex, + {LLDB_INVALID_REGNUM, dwarf_r14_abt, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"r13_und", + "sp_und", + 4, + 0, + eEncodingUint, + eFormatHex, + {LLDB_INVALID_REGNUM, dwarf_r13_und, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"r14_und", + "lr_und", + 4, + 0, + eEncodingUint, + eFormatHex, + {LLDB_INVALID_REGNUM, dwarf_r14_und, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"r13_svc", + "sp_svc", + 4, + 0, + eEncodingUint, + eFormatHex, + {LLDB_INVALID_REGNUM, dwarf_r13_svc, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"r14_svc", + "lr_svc", + 4, + 0, + eEncodingUint, + eFormatHex, + {LLDB_INVALID_REGNUM, dwarf_r14_svc, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}}; + +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_arm::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(); - } +ABISysV_arm::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; + } + count = k_num_register_infos; + return g_register_infos; } -size_t -ABISysV_arm::GetRedZoneSize () const -{ - return 0; -} +size_t ABISysV_arm::GetRedZoneSize() const { return 0; } //------------------------------------------------------------------ // Static Functions //------------------------------------------------------------------ ABISP -ABISysV_arm::CreateInstance (const ArchSpec &arch) -{ - static ABISP g_abi_sp; - const llvm::Triple::ArchType arch_type = arch.GetTriple().getArch(); - const llvm::Triple::VendorType vendor_type = arch.GetTriple().getVendor(); - - if (vendor_type != llvm::Triple::Apple) - { - if ((arch_type == llvm::Triple::arm) || - (arch_type == llvm::Triple::thumb)) - { - if (!g_abi_sp) - g_abi_sp.reset (new ABISysV_arm); - return g_abi_sp; - } +ABISysV_arm::CreateInstance(const ArchSpec &arch) { + static ABISP g_abi_sp; + const llvm::Triple::ArchType arch_type = arch.GetTriple().getArch(); + const llvm::Triple::VendorType vendor_type = arch.GetTriple().getVendor(); + + if (vendor_type != llvm::Triple::Apple) { + if ((arch_type == llvm::Triple::arm) || + (arch_type == llvm::Triple::thumb)) { + if (!g_abi_sp) + g_abi_sp.reset(new ABISysV_arm); + return g_abi_sp; } + } - return ABISP(); + return ABISP(); } -bool -ABISysV_arm::PrepareTrivialCall (Thread &thread, - addr_t sp, - addr_t function_addr, - addr_t return_addr, - llvm::ArrayRef<addr_t> args) const -{ - RegisterContext *reg_ctx = thread.GetRegisterContext().get(); - if (!reg_ctx) - return false; - - const uint32_t pc_reg_num = reg_ctx->ConvertRegisterKindToRegisterNumber (eRegisterKindGeneric, LLDB_REGNUM_GENERIC_PC); - const uint32_t sp_reg_num = reg_ctx->ConvertRegisterKindToRegisterNumber (eRegisterKindGeneric, LLDB_REGNUM_GENERIC_SP); - const uint32_t ra_reg_num = reg_ctx->ConvertRegisterKindToRegisterNumber (eRegisterKindGeneric, LLDB_REGNUM_GENERIC_RA); - - RegisterValue reg_value; - - const uint8_t reg_names[] = { LLDB_REGNUM_GENERIC_ARG1, LLDB_REGNUM_GENERIC_ARG2, LLDB_REGNUM_GENERIC_ARG3, LLDB_REGNUM_GENERIC_ARG4 }; - - llvm::ArrayRef<addr_t>::iterator ai = args.begin(), ae = args.end(); - - for (size_t i = 0; i < llvm::array_lengthof(reg_names); ++i) - { - if (ai == ae) - break; - - reg_value.SetUInt32(*ai); - if (!reg_ctx->WriteRegister(reg_ctx->GetRegisterInfo(eRegisterKindGeneric, reg_names[i]), reg_value)) - return false; - - ++ai; - } - - if (ai != ae) - { - // Spill onto the stack - size_t num_stack_regs = ae - ai; - - sp -= (num_stack_regs * 4); - // Keep the stack 8 byte aligned, not that we need to - sp &= ~(8ull-1ull); - - // just using arg1 to get the right size - const RegisterInfo *reg_info = reg_ctx->GetRegisterInfo(eRegisterKindGeneric, LLDB_REGNUM_GENERIC_ARG1); - - addr_t arg_pos = sp; - - for (; ai != ae; ++ai) - { - reg_value.SetUInt32(*ai); - if (reg_ctx->WriteRegisterValueToMemory(reg_info, arg_pos, reg_info->byte_size, reg_value).Fail()) - return false; - arg_pos += reg_info->byte_size; - } - } - - TargetSP target_sp (thread.CalculateTarget()); - Address so_addr; - - // Figure out if our return address is ARM or Thumb by using the - // Address::GetCallableLoadAddress(Target*) which will figure out the ARM - // thumb-ness and set the correct address bits for us. - so_addr.SetLoadAddress (return_addr, target_sp.get()); - return_addr = so_addr.GetCallableLoadAddress (target_sp.get()); - - // Set "lr" to the return address - if (!reg_ctx->WriteRegisterFromUnsigned (ra_reg_num, return_addr)) - return false; +bool ABISysV_arm::PrepareTrivialCall(Thread &thread, addr_t sp, + addr_t function_addr, addr_t return_addr, + llvm::ArrayRef<addr_t> args) const { + RegisterContext *reg_ctx = thread.GetRegisterContext().get(); + if (!reg_ctx) + return false; - // Set "sp" to the requested value - if (!reg_ctx->WriteRegisterFromUnsigned (sp_reg_num, sp)) - return false; - - // If bit zero or 1 is set, this must be a thumb function, no need to figure - // this out from the symbols. - so_addr.SetLoadAddress (function_addr, target_sp.get()); - function_addr = so_addr.GetCallableLoadAddress (target_sp.get()); - - const RegisterInfo *cpsr_reg_info = reg_ctx->GetRegisterInfo(eRegisterKindGeneric, LLDB_REGNUM_GENERIC_FLAGS); - const uint32_t curr_cpsr = reg_ctx->ReadRegisterAsUnsigned(cpsr_reg_info, 0); - - // Make a new CPSR and mask out any Thumb IT (if/then) bits - uint32_t new_cpsr = curr_cpsr & ~MASK_CPSR_IT_MASK; - // If bit zero or 1 is set, this must be thumb... - if (function_addr & 1ull) - new_cpsr |= MASK_CPSR_T; // Set T bit in CPSR - else - new_cpsr &= ~MASK_CPSR_T; // Clear T bit in CPSR + const uint32_t pc_reg_num = reg_ctx->ConvertRegisterKindToRegisterNumber( + eRegisterKindGeneric, LLDB_REGNUM_GENERIC_PC); + const uint32_t sp_reg_num = reg_ctx->ConvertRegisterKindToRegisterNumber( + eRegisterKindGeneric, LLDB_REGNUM_GENERIC_SP); + const uint32_t ra_reg_num = reg_ctx->ConvertRegisterKindToRegisterNumber( + eRegisterKindGeneric, LLDB_REGNUM_GENERIC_RA); - if (new_cpsr != curr_cpsr) - { - if (!reg_ctx->WriteRegisterFromUnsigned (cpsr_reg_info, new_cpsr)) - return false; - } + RegisterValue reg_value; + + const uint8_t reg_names[] = { + LLDB_REGNUM_GENERIC_ARG1, LLDB_REGNUM_GENERIC_ARG2, + LLDB_REGNUM_GENERIC_ARG3, LLDB_REGNUM_GENERIC_ARG4}; + + llvm::ArrayRef<addr_t>::iterator ai = args.begin(), ae = args.end(); - function_addr &= ~1ull; // clear bit zero since the CPSR will take care of the mode for us - - // Set "pc" to the address requested - if (!reg_ctx->WriteRegisterFromUnsigned (pc_reg_num, function_addr)) + for (size_t i = 0; i < llvm::array_lengthof(reg_names); ++i) { + if (ai == ae) + break; + + reg_value.SetUInt32(*ai); + if (!reg_ctx->WriteRegister( + reg_ctx->GetRegisterInfo(eRegisterKindGeneric, reg_names[i]), + reg_value)) + return false; + + ++ai; + } + + if (ai != ae) { + // Spill onto the stack + size_t num_stack_regs = ae - ai; + + sp -= (num_stack_regs * 4); + // Keep the stack 8 byte aligned, not that we need to + sp &= ~(8ull - 1ull); + + // just using arg1 to get the right size + const RegisterInfo *reg_info = reg_ctx->GetRegisterInfo( + eRegisterKindGeneric, LLDB_REGNUM_GENERIC_ARG1); + + addr_t arg_pos = sp; + + for (; ai != ae; ++ai) { + reg_value.SetUInt32(*ai); + if (reg_ctx + ->WriteRegisterValueToMemory(reg_info, arg_pos, + reg_info->byte_size, reg_value) + .Fail()) return false; + arg_pos += reg_info->byte_size; + } + } + + TargetSP target_sp(thread.CalculateTarget()); + Address so_addr; - return true; + // Figure out if our return address is ARM or Thumb by using the + // Address::GetCallableLoadAddress(Target*) which will figure out the ARM + // thumb-ness and set the correct address bits for us. + so_addr.SetLoadAddress(return_addr, target_sp.get()); + return_addr = so_addr.GetCallableLoadAddress(target_sp.get()); + + // Set "lr" to the return address + if (!reg_ctx->WriteRegisterFromUnsigned(ra_reg_num, return_addr)) + return false; + + // Set "sp" to the requested value + if (!reg_ctx->WriteRegisterFromUnsigned(sp_reg_num, sp)) + return false; + + // If bit zero or 1 is set, this must be a thumb function, no need to figure + // this out from the symbols. + so_addr.SetLoadAddress(function_addr, target_sp.get()); + function_addr = so_addr.GetCallableLoadAddress(target_sp.get()); + + const RegisterInfo *cpsr_reg_info = + reg_ctx->GetRegisterInfo(eRegisterKindGeneric, LLDB_REGNUM_GENERIC_FLAGS); + const uint32_t curr_cpsr = reg_ctx->ReadRegisterAsUnsigned(cpsr_reg_info, 0); + + // Make a new CPSR and mask out any Thumb IT (if/then) bits + uint32_t new_cpsr = curr_cpsr & ~MASK_CPSR_IT_MASK; + // If bit zero or 1 is set, this must be thumb... + if (function_addr & 1ull) + new_cpsr |= MASK_CPSR_T; // Set T bit in CPSR + else + new_cpsr &= ~MASK_CPSR_T; // Clear T bit in CPSR + + if (new_cpsr != curr_cpsr) { + if (!reg_ctx->WriteRegisterFromUnsigned(cpsr_reg_info, new_cpsr)) + return false; + } + + function_addr &= + ~1ull; // clear bit zero since the CPSR will take care of the mode for us + + // Set "pc" to the address requested + if (!reg_ctx->WriteRegisterFromUnsigned(pc_reg_num, function_addr)) + return false; + + return true; } -bool -ABISysV_arm::GetArgumentValues (Thread &thread, - ValueList &values) const -{ - uint32_t num_values = values.GetSize(); - - ExecutionContext exe_ctx (thread.shared_from_this()); - // For now, assume that the types in the AST values come from the Target's - // scratch AST. - - // Extract the register context so we can read arguments from registers - - RegisterContext *reg_ctx = thread.GetRegisterContext().get(); - - if (!reg_ctx) +bool ABISysV_arm::GetArgumentValues(Thread &thread, ValueList &values) const { + uint32_t num_values = values.GetSize(); + + ExecutionContext exe_ctx(thread.shared_from_this()); + // For now, assume that the types in the AST values come from the Target's + // scratch AST. + + // Extract the register context so we can read arguments from registers + + RegisterContext *reg_ctx = thread.GetRegisterContext().get(); + + if (!reg_ctx) + return false; + + addr_t sp = 0; + + for (uint32_t value_idx = 0; value_idx < num_values; ++value_idx) { + // We currently only support extracting values with Clang QualTypes. + // Do we care about others? + Value *value = values.GetValueAtIndex(value_idx); + + if (!value) + return false; + + CompilerType compiler_type = value->GetCompilerType(); + if (compiler_type) { + bool is_signed = false; + size_t bit_width = 0; + if (compiler_type.IsIntegerOrEnumerationType(is_signed)) { + bit_width = compiler_type.GetBitSize(&thread); + } else if (compiler_type.IsPointerOrReferenceType()) { + bit_width = compiler_type.GetBitSize(&thread); + } else { + // We only handle integer, pointer and reference types currently... return false; - - addr_t sp = 0; - - for (uint32_t value_idx = 0; value_idx < num_values; ++value_idx) - { - // We currently only support extracting values with Clang QualTypes. - // Do we care about others? - Value *value = values.GetValueAtIndex(value_idx); - - if (!value) - return false; - - CompilerType compiler_type = value->GetCompilerType(); - if (compiler_type) - { - bool is_signed = false; - size_t bit_width = 0; - if (compiler_type.IsIntegerOrEnumerationType (is_signed)) - { - bit_width = compiler_type.GetBitSize(&thread); - } - else if (compiler_type.IsPointerOrReferenceType ()) - { - bit_width = compiler_type.GetBitSize(&thread); - } - else - { - // We only handle integer, pointer and reference types currently... + } + + if (bit_width <= (exe_ctx.GetProcessRef().GetAddressByteSize() * 8)) { + if (value_idx < 4) { + // Arguments 1-4 are in r0-r3... + const RegisterInfo *arg_reg_info = nullptr; + arg_reg_info = reg_ctx->GetRegisterInfo( + eRegisterKindGeneric, LLDB_REGNUM_GENERIC_ARG1 + value_idx); + if (arg_reg_info) { + RegisterValue reg_value; + + if (reg_ctx->ReadRegister(arg_reg_info, reg_value)) { + if (is_signed) + reg_value.SignExtend(bit_width); + if (!reg_value.GetScalarValue(value->GetScalar())) return false; + continue; } - - if (bit_width <= (exe_ctx.GetProcessRef().GetAddressByteSize() * 8)) - { - if (value_idx < 4) - { - // Arguments 1-4 are in r0-r3... - const RegisterInfo *arg_reg_info = nullptr; - arg_reg_info = reg_ctx->GetRegisterInfo(eRegisterKindGeneric, LLDB_REGNUM_GENERIC_ARG1 + value_idx); - if (arg_reg_info) - { - RegisterValue reg_value; - - if (reg_ctx->ReadRegister(arg_reg_info, reg_value)) - { - if (is_signed) - reg_value.SignExtend(bit_width); - if (!reg_value.GetScalarValue(value->GetScalar())) - return false; - continue; - } - } - return false; - } - else - { - if (sp == 0) - { - // Read the stack pointer if it already hasn't been read - sp = reg_ctx->GetSP(0); - if (sp == 0) - return false; - } - - // Arguments 5 on up are on the stack - const uint32_t arg_byte_size = (bit_width + (8-1)) / 8; - Error error; - if (!exe_ctx.GetProcessRef().ReadScalarIntegerFromMemory(sp, arg_byte_size, is_signed, value->GetScalar(), error)) - return false; - - sp += arg_byte_size; - } - } + } + return false; + } else { + if (sp == 0) { + // Read the stack pointer if it already hasn't been read + sp = reg_ctx->GetSP(0); + if (sp == 0) + return false; + } + + // Arguments 5 on up are on the stack + const uint32_t arg_byte_size = (bit_width + (8 - 1)) / 8; + Error error; + if (!exe_ctx.GetProcessRef().ReadScalarIntegerFromMemory( + sp, arg_byte_size, is_signed, value->GetScalar(), error)) + return false; + + sp += arg_byte_size; } + } } - return true; + } + return true; } -static bool -GetReturnValuePassedInMemory(Thread &thread, RegisterContext* reg_ctx, size_t byte_size, Value& value) -{ - Error error; - DataBufferHeap buffer(byte_size, 0); +static bool GetReturnValuePassedInMemory(Thread &thread, + RegisterContext *reg_ctx, + size_t byte_size, Value &value) { + Error error; + DataBufferHeap buffer(byte_size, 0); - const RegisterInfo *r0_reg_info = reg_ctx->GetRegisterInfo(eRegisterKindGeneric, LLDB_REGNUM_GENERIC_ARG1); - uint32_t address = reg_ctx->ReadRegisterAsUnsigned(r0_reg_info, 0) & UINT32_MAX; - thread.GetProcess()->ReadMemory(address, buffer.GetBytes(), buffer.GetByteSize(), error); + const RegisterInfo *r0_reg_info = + reg_ctx->GetRegisterInfo(eRegisterKindGeneric, LLDB_REGNUM_GENERIC_ARG1); + uint32_t address = + reg_ctx->ReadRegisterAsUnsigned(r0_reg_info, 0) & UINT32_MAX; + thread.GetProcess()->ReadMemory(address, buffer.GetBytes(), + buffer.GetByteSize(), error); - if (error.Fail()) - return false; + if (error.Fail()) + return false; - value.SetBytes(buffer.GetBytes(), buffer.GetByteSize()); - return true; + value.SetBytes(buffer.GetBytes(), buffer.GetByteSize()); + return true; } -bool -ABISysV_arm::IsArmHardFloat (Thread &thread) const -{ - ProcessSP process_sp (thread.GetProcess()); - if (process_sp) - { - const ArchSpec &arch (process_sp->GetTarget().GetArchitecture()); +bool ABISysV_arm::IsArmHardFloat(Thread &thread) const { + ProcessSP process_sp(thread.GetProcess()); + if (process_sp) { + const ArchSpec &arch(process_sp->GetTarget().GetArchitecture()); - return (arch.GetFlags() & ArchSpec::eARM_abi_hard_float) != 0; - } + return (arch.GetFlags() & ArchSpec::eARM_abi_hard_float) != 0; + } - return false; + return false; } -ValueObjectSP -ABISysV_arm::GetReturnValueObjectImpl (Thread &thread, - lldb_private::CompilerType &compiler_type) const -{ - Value value; - ValueObjectSP return_valobj_sp; - - if (!compiler_type) +ValueObjectSP ABISysV_arm::GetReturnValueObjectImpl( + Thread &thread, lldb_private::CompilerType &compiler_type) const { + Value value; + ValueObjectSP return_valobj_sp; + + if (!compiler_type) + return return_valobj_sp; + + // value.SetContext (Value::eContextTypeClangType, + // compiler_type.GetOpaqueQualType()); + value.SetCompilerType(compiler_type); + + RegisterContext *reg_ctx = thread.GetRegisterContext().get(); + if (!reg_ctx) + return return_valobj_sp; + + bool is_signed; + bool is_complex; + uint32_t float_count; + bool is_vfp_candidate = false; + uint8_t vfp_count = 0; + uint8_t vfp_byte_size = 0; + + // Get the pointer to the first stack argument so we have a place to start + // when reading data + + const RegisterInfo *r0_reg_info = + reg_ctx->GetRegisterInfo(eRegisterKindGeneric, LLDB_REGNUM_GENERIC_ARG1); + size_t bit_width = compiler_type.GetBitSize(&thread); + size_t byte_size = compiler_type.GetByteSize(&thread); + + if (compiler_type.IsIntegerOrEnumerationType(is_signed)) { + switch (bit_width) { + default: + return return_valobj_sp; + case 64: { + const RegisterInfo *r1_reg_info = reg_ctx->GetRegisterInfo( + eRegisterKindGeneric, LLDB_REGNUM_GENERIC_ARG2); + uint64_t raw_value; + raw_value = reg_ctx->ReadRegisterAsUnsigned(r0_reg_info, 0) & UINT32_MAX; + raw_value |= ((uint64_t)(reg_ctx->ReadRegisterAsUnsigned(r1_reg_info, 0) & + UINT32_MAX)) + << 32; + if (is_signed) + value.GetScalar() = (int64_t)raw_value; + else + value.GetScalar() = (uint64_t)raw_value; + } break; + case 32: + if (is_signed) + value.GetScalar() = (int32_t)( + reg_ctx->ReadRegisterAsUnsigned(r0_reg_info, 0) & UINT32_MAX); + else + value.GetScalar() = (uint32_t)( + reg_ctx->ReadRegisterAsUnsigned(r0_reg_info, 0) & UINT32_MAX); + break; + case 16: + if (is_signed) + value.GetScalar() = (int16_t)( + reg_ctx->ReadRegisterAsUnsigned(r0_reg_info, 0) & UINT16_MAX); + else + value.GetScalar() = (uint16_t)( + reg_ctx->ReadRegisterAsUnsigned(r0_reg_info, 0) & UINT16_MAX); + break; + case 8: + if (is_signed) + value.GetScalar() = (int8_t)( + reg_ctx->ReadRegisterAsUnsigned(r0_reg_info, 0) & UINT8_MAX); + else + value.GetScalar() = (uint8_t)( + reg_ctx->ReadRegisterAsUnsigned(r0_reg_info, 0) & UINT8_MAX); + break; + } + } else if (compiler_type.IsPointerType()) { + uint32_t ptr = + thread.GetRegisterContext()->ReadRegisterAsUnsigned(r0_reg_info, 0) & + UINT32_MAX; + value.GetScalar() = ptr; + } else if (compiler_type.IsVectorType(nullptr, nullptr)) { + if (IsArmHardFloat(thread) && (byte_size == 8 || byte_size == 16)) { + is_vfp_candidate = true; + vfp_byte_size = 8; + vfp_count = (byte_size == 8 ? 1 : 2); + } else if (byte_size <= 16) { + DataBufferHeap buffer(16, 0); + uint32_t *buffer_ptr = (uint32_t *)buffer.GetBytes(); + + for (uint32_t i = 0; 4 * i < byte_size; ++i) { + const RegisterInfo *reg_info = reg_ctx->GetRegisterInfo( + eRegisterKindGeneric, LLDB_REGNUM_GENERIC_ARG1 + i); + buffer_ptr[i] = + reg_ctx->ReadRegisterAsUnsigned(reg_info, 0) & UINT32_MAX; + } + value.SetBytes(buffer.GetBytes(), byte_size); + } else { + if (!GetReturnValuePassedInMemory(thread, reg_ctx, byte_size, value)) return return_valobj_sp; - - //value.SetContext (Value::eContextTypeClangType, compiler_type.GetOpaqueQualType()); - value.SetCompilerType (compiler_type); - - RegisterContext *reg_ctx = thread.GetRegisterContext().get(); - if (!reg_ctx) + } + } else if (compiler_type.IsFloatingPointType(float_count, is_complex)) { + if (float_count == 1 && !is_complex) { + switch (bit_width) { + default: return return_valobj_sp; - - bool is_signed; - bool is_complex; - uint32_t float_count; - bool is_vfp_candidate = false; - uint8_t vfp_count = 0; - uint8_t vfp_byte_size = 0; - - // Get the pointer to the first stack argument so we have a place to start - // when reading data - - const RegisterInfo *r0_reg_info = reg_ctx->GetRegisterInfo(eRegisterKindGeneric, LLDB_REGNUM_GENERIC_ARG1); - size_t bit_width = compiler_type.GetBitSize(&thread); - size_t byte_size = compiler_type.GetByteSize(&thread); - - if (compiler_type.IsIntegerOrEnumerationType (is_signed)) - { - switch (bit_width) - { - default: - return return_valobj_sp; - case 64: - { - const RegisterInfo *r1_reg_info = reg_ctx->GetRegisterInfo(eRegisterKindGeneric, LLDB_REGNUM_GENERIC_ARG2); - uint64_t raw_value; - raw_value = reg_ctx->ReadRegisterAsUnsigned(r0_reg_info, 0) & UINT32_MAX; - raw_value |= ((uint64_t)(reg_ctx->ReadRegisterAsUnsigned(r1_reg_info, 0) & UINT32_MAX)) << 32; - if (is_signed) - value.GetScalar() = (int64_t)raw_value; - else - value.GetScalar() = (uint64_t)raw_value; - } - break; - case 32: - if (is_signed) - value.GetScalar() = (int32_t)(reg_ctx->ReadRegisterAsUnsigned(r0_reg_info, 0) & UINT32_MAX); - else - value.GetScalar() = (uint32_t)(reg_ctx->ReadRegisterAsUnsigned(r0_reg_info, 0) & UINT32_MAX); - break; - case 16: - if (is_signed) - value.GetScalar() = (int16_t)(reg_ctx->ReadRegisterAsUnsigned(r0_reg_info, 0) & UINT16_MAX); - else - value.GetScalar() = (uint16_t)(reg_ctx->ReadRegisterAsUnsigned(r0_reg_info, 0) & UINT16_MAX); - break; - case 8: - if (is_signed) - value.GetScalar() = (int8_t)(reg_ctx->ReadRegisterAsUnsigned(r0_reg_info, 0) & UINT8_MAX); - else - value.GetScalar() = (uint8_t)(reg_ctx->ReadRegisterAsUnsigned(r0_reg_info, 0) & UINT8_MAX); - break; + case 64: { + static_assert(sizeof(double) == sizeof(uint64_t), ""); + + if (IsArmHardFloat(thread)) { + RegisterValue reg_value; + const RegisterInfo *d0_reg_info = + reg_ctx->GetRegisterInfoByName("d0", 0); + reg_ctx->ReadRegister(d0_reg_info, reg_value); + value.GetScalar() = reg_value.GetAsDouble(); + } else { + uint64_t raw_value; + const RegisterInfo *r1_reg_info = reg_ctx->GetRegisterInfo( + eRegisterKindGeneric, LLDB_REGNUM_GENERIC_ARG2); + raw_value = + reg_ctx->ReadRegisterAsUnsigned(r0_reg_info, 0) & UINT32_MAX; + raw_value |= + ((uint64_t)(reg_ctx->ReadRegisterAsUnsigned(r1_reg_info, 0) & + UINT32_MAX)) + << 32; + value.GetScalar() = *reinterpret_cast<double *>(&raw_value); } - } - else if (compiler_type.IsPointerType ()) - { - uint32_t ptr = thread.GetRegisterContext()->ReadRegisterAsUnsigned(r0_reg_info, 0) & UINT32_MAX; - value.GetScalar() = ptr; - } - else if (compiler_type.IsVectorType(nullptr, nullptr)) - { - if (IsArmHardFloat(thread) && (byte_size == 8 || byte_size == 16)) - { + break; + } + case 16: // Half precision returned after a conversion to single precision + case 32: { + static_assert(sizeof(float) == sizeof(uint32_t), ""); + + if (IsArmHardFloat(thread)) { + RegisterValue reg_value; + const RegisterInfo *s0_reg_info = + reg_ctx->GetRegisterInfoByName("s0", 0); + reg_ctx->ReadRegister(s0_reg_info, reg_value); + value.GetScalar() = reg_value.GetAsFloat(); + } else { + uint32_t raw_value; + raw_value = + reg_ctx->ReadRegisterAsUnsigned(r0_reg_info, 0) & UINT32_MAX; + value.GetScalar() = *reinterpret_cast<float *>(&raw_value); + } + break; + } + } + } else if (is_complex && float_count == 2) { + if (IsArmHardFloat(thread)) { + is_vfp_candidate = true; + vfp_byte_size = byte_size / 2; + vfp_count = 2; + } else if (!GetReturnValuePassedInMemory(thread, reg_ctx, bit_width / 8, + value)) + return return_valobj_sp; + } else + // not handled yet + return return_valobj_sp; + } else if (compiler_type.IsAggregateType()) { + if (IsArmHardFloat(thread)) { + CompilerType base_type; + const uint32_t homogeneous_count = + compiler_type.IsHomogeneousAggregate(&base_type); + + if (homogeneous_count > 0 && homogeneous_count <= 4) { + if (base_type.IsVectorType(nullptr, nullptr)) { + uint64_t base_byte_size = base_type.GetByteSize(nullptr); + if (base_byte_size == 8 || base_byte_size == 16) { is_vfp_candidate = true; vfp_byte_size = 8; - vfp_count = (byte_size == 8?1:2); - } - else if (byte_size <= 16) - { - DataBufferHeap buffer(16, 0); - uint32_t* buffer_ptr = (uint32_t*)buffer.GetBytes(); - - for (uint32_t i = 0; 4*i < byte_size; ++i) - { - const RegisterInfo *reg_info = reg_ctx->GetRegisterInfo(eRegisterKindGeneric, LLDB_REGNUM_GENERIC_ARG1 + i); - buffer_ptr[i] = reg_ctx->ReadRegisterAsUnsigned(reg_info, 0) & UINT32_MAX; - } - value.SetBytes(buffer.GetBytes(), byte_size); - } - else - { - if (!GetReturnValuePassedInMemory(thread, reg_ctx, byte_size, value)) - return return_valobj_sp; - } - } - else if (compiler_type.IsFloatingPointType(float_count, is_complex)) - { - if (float_count == 1 && !is_complex) - { - switch (bit_width) - { - default: - return return_valobj_sp; - case 64: - { - static_assert(sizeof(double) == sizeof(uint64_t), ""); - - if (IsArmHardFloat(thread)) - { - RegisterValue reg_value; - const RegisterInfo *d0_reg_info = reg_ctx->GetRegisterInfoByName("d0", 0); - reg_ctx->ReadRegister(d0_reg_info, reg_value); - value.GetScalar() = reg_value.GetAsDouble(); - } - else - { - uint64_t raw_value; - const RegisterInfo *r1_reg_info = reg_ctx->GetRegisterInfo(eRegisterKindGeneric, LLDB_REGNUM_GENERIC_ARG2); - raw_value = reg_ctx->ReadRegisterAsUnsigned(r0_reg_info, 0) & UINT32_MAX; - raw_value |= ((uint64_t)(reg_ctx->ReadRegisterAsUnsigned(r1_reg_info, 0) & UINT32_MAX)) << 32; - value.GetScalar() = *reinterpret_cast<double*>(&raw_value); - } - break; - } - case 16: // Half precision returned after a conversion to single precision - case 32: - { - static_assert(sizeof(float) == sizeof(uint32_t), ""); - - if (IsArmHardFloat(thread)) - { - RegisterValue reg_value; - const RegisterInfo *s0_reg_info = reg_ctx->GetRegisterInfoByName("s0", 0); - reg_ctx->ReadRegister(s0_reg_info, reg_value); - value.GetScalar() = reg_value.GetAsFloat(); - } - else - { - uint32_t raw_value; - raw_value = reg_ctx->ReadRegisterAsUnsigned(r0_reg_info, 0) & UINT32_MAX; - value.GetScalar() = *reinterpret_cast<float*>(&raw_value); - } - break; - } - } - } - else if (is_complex && float_count == 2) - { - if (IsArmHardFloat(thread)) - { - is_vfp_candidate = true; - vfp_byte_size = byte_size / 2; - vfp_count = 2; - } - else if (!GetReturnValuePassedInMemory(thread, reg_ctx, bit_width / 8, value)) - return return_valobj_sp; - } - else - // not handled yet - return return_valobj_sp; - } - else if (compiler_type.IsAggregateType()) - { - if (IsArmHardFloat(thread)) - { - CompilerType base_type; - const uint32_t homogeneous_count = compiler_type.IsHomogeneousAggregate (&base_type); - - if (homogeneous_count > 0 && homogeneous_count <= 4) - { - if (base_type.IsVectorType(nullptr, nullptr)) - { - uint64_t base_byte_size = base_type.GetByteSize(nullptr); - if (base_byte_size == 8 || base_byte_size == 16) - { - is_vfp_candidate = true; - vfp_byte_size = 8; - vfp_count = (base_type.GetByteSize(nullptr) == 8 ? homogeneous_count : homogeneous_count * 2); - } - } - else if (base_type.IsFloatingPointType(float_count, is_complex)) - { - if (float_count == 1 && !is_complex) - { - is_vfp_candidate = true; - vfp_byte_size = base_type.GetByteSize(nullptr); - vfp_count = homogeneous_count; - } - } - } - else if (homogeneous_count == 0) - { - const uint32_t num_children = compiler_type.GetNumFields (); - - if (num_children > 0 && num_children <=2) - { - uint32_t index = 0; - for (index = 0; index < num_children; index++) - { - std::string name; - base_type = compiler_type.GetFieldAtIndex (index, name, NULL, NULL, NULL); - - if (base_type.IsFloatingPointType(float_count, is_complex)) - { - if (float_count == 2 && is_complex) - { - if (index != 0 && vfp_byte_size != base_type.GetByteSize(nullptr)) - break; - else - vfp_byte_size = base_type.GetByteSize(nullptr); - } - else - break; - } - else - break; - } - - if (index == num_children) - { - is_vfp_candidate = true; - vfp_byte_size = (vfp_byte_size >> 1); - vfp_count = (num_children << 1); - } - } - } + vfp_count = + (base_type.GetByteSize(nullptr) == 8 ? homogeneous_count + : homogeneous_count * 2); + } + } else if (base_type.IsFloatingPointType(float_count, is_complex)) { + if (float_count == 1 && !is_complex) { + is_vfp_candidate = true; + vfp_byte_size = base_type.GetByteSize(nullptr); + vfp_count = homogeneous_count; + } } + } else if (homogeneous_count == 0) { + const uint32_t num_children = compiler_type.GetNumFields(); + + if (num_children > 0 && num_children <= 2) { + uint32_t index = 0; + for (index = 0; index < num_children; index++) { + std::string name; + base_type = + compiler_type.GetFieldAtIndex(index, name, NULL, NULL, NULL); + + if (base_type.IsFloatingPointType(float_count, is_complex)) { + if (float_count == 2 && is_complex) { + if (index != 0 && + vfp_byte_size != base_type.GetByteSize(nullptr)) + break; + else + vfp_byte_size = base_type.GetByteSize(nullptr); + } else + break; + } else + break; + } - if (byte_size <= 4) - { - RegisterValue r0_reg_value; - uint32_t raw_value = reg_ctx->ReadRegisterAsUnsigned(r0_reg_info, 0) & UINT32_MAX; - value.SetBytes(&raw_value, byte_size); - } - else if (!is_vfp_candidate) - { - if (!GetReturnValuePassedInMemory(thread, reg_ctx, byte_size, value)) - return return_valobj_sp; + if (index == num_children) { + is_vfp_candidate = true; + vfp_byte_size = (vfp_byte_size >> 1); + vfp_count = (num_children << 1); + } } + } } - else - { - // not handled yet + + if (byte_size <= 4) { + RegisterValue r0_reg_value; + uint32_t raw_value = + reg_ctx->ReadRegisterAsUnsigned(r0_reg_info, 0) & UINT32_MAX; + value.SetBytes(&raw_value, byte_size); + } else if (!is_vfp_candidate) { + if (!GetReturnValuePassedInMemory(thread, reg_ctx, byte_size, value)) return return_valobj_sp; } - - if (is_vfp_candidate) - { - ProcessSP process_sp (thread.GetProcess()); - ByteOrder byte_order = process_sp->GetByteOrder(); - - DataBufferSP data_sp (new DataBufferHeap(byte_size, 0)); - uint32_t data_offset = 0; - - for (uint32_t reg_index = 0; reg_index < vfp_count; reg_index++) - { - uint32_t regnum = 0; - - if (vfp_byte_size == 4) - regnum = dwarf_s0 + reg_index; - else if (vfp_byte_size == 8) - regnum = dwarf_d0 + reg_index; - else - break; - - const RegisterInfo *reg_info = reg_ctx->GetRegisterInfo (eRegisterKindDWARF, regnum); - if (reg_info == NULL) - break; - - RegisterValue reg_value; - if (!reg_ctx->ReadRegister(reg_info, reg_value)) - break; - - // Make sure we have enough room in "data_sp" - if ((data_offset + vfp_byte_size) <= data_sp->GetByteSize()) - { - Error error; - const size_t bytes_copied = reg_value.GetAsMemoryData (reg_info, - data_sp->GetBytes() + data_offset, - vfp_byte_size, - byte_order, - error); - if (bytes_copied != vfp_byte_size) - break; - - data_offset += bytes_copied; - } - } + } else { + // not handled yet + return return_valobj_sp; + } + + if (is_vfp_candidate) { + ProcessSP process_sp(thread.GetProcess()); + ByteOrder byte_order = process_sp->GetByteOrder(); + + DataBufferSP data_sp(new DataBufferHeap(byte_size, 0)); + uint32_t data_offset = 0; + + for (uint32_t reg_index = 0; reg_index < vfp_count; reg_index++) { + uint32_t regnum = 0; + + if (vfp_byte_size == 4) + regnum = dwarf_s0 + reg_index; + else if (vfp_byte_size == 8) + regnum = dwarf_d0 + reg_index; + else + break; + + const RegisterInfo *reg_info = + reg_ctx->GetRegisterInfo(eRegisterKindDWARF, regnum); + if (reg_info == NULL) + break; + + RegisterValue reg_value; + if (!reg_ctx->ReadRegister(reg_info, reg_value)) + break; + + // Make sure we have enough room in "data_sp" + if ((data_offset + vfp_byte_size) <= data_sp->GetByteSize()) { + Error error; + const size_t bytes_copied = reg_value.GetAsMemoryData( + reg_info, data_sp->GetBytes() + data_offset, vfp_byte_size, + byte_order, error); + if (bytes_copied != vfp_byte_size) + break; + + data_offset += bytes_copied; + } + } - if (data_offset == byte_size) - { - DataExtractor data; - data.SetByteOrder(byte_order); - data.SetAddressByteSize(process_sp->GetAddressByteSize()); - data.SetData(data_sp); + if (data_offset == byte_size) { + DataExtractor data; + data.SetByteOrder(byte_order); + data.SetAddressByteSize(process_sp->GetAddressByteSize()); + data.SetData(data_sp); - return ValueObjectConstResult::Create (&thread, compiler_type, ConstString(""), data); - } - else - { // Some error occurred while getting values from registers - return return_valobj_sp; - } + return ValueObjectConstResult::Create(&thread, compiler_type, + ConstString(""), data); + } else { // Some error occurred while getting values from registers + return return_valobj_sp; } + } - // If we get here, we have a valid Value, so make our ValueObject out of it: - - return_valobj_sp = ValueObjectConstResult::Create(thread.GetStackFrameAtIndex(0).get(), - value, - ConstString("")); - return return_valobj_sp; + // If we get here, we have a valid Value, so make our ValueObject out of it: + + return_valobj_sp = ValueObjectConstResult::Create( + thread.GetStackFrameAtIndex(0).get(), value, ConstString("")); + return return_valobj_sp; } -Error -ABISysV_arm::SetReturnValueObject(lldb::StackFrameSP &frame_sp, lldb::ValueObjectSP &new_value_sp) -{ - Error error; - if (!new_value_sp) - { - error.SetErrorString("Empty value object for return value."); - return error; - } - - CompilerType compiler_type = new_value_sp->GetCompilerType(); - if (!compiler_type) - { - error.SetErrorString ("Null clang type for return value."); - return error; +Error ABISysV_arm::SetReturnValueObject(lldb::StackFrameSP &frame_sp, + lldb::ValueObjectSP &new_value_sp) { + Error error; + if (!new_value_sp) { + error.SetErrorString("Empty value object for return value."); + return error; + } + + CompilerType compiler_type = new_value_sp->GetCompilerType(); + if (!compiler_type) { + error.SetErrorString("Null clang type for return value."); + return error; + } + + Thread *thread = frame_sp->GetThread().get(); + + bool is_signed; + uint32_t count; + bool is_complex; + + RegisterContext *reg_ctx = thread->GetRegisterContext().get(); + + bool set_it_simple = false; + if (compiler_type.IsIntegerOrEnumerationType(is_signed) || + compiler_type.IsPointerType()) { + DataExtractor data; + Error data_error; + size_t num_bytes = new_value_sp->GetData(data, data_error); + if (data_error.Fail()) { + error.SetErrorStringWithFormat( + "Couldn't convert return value to raw data: %s", + data_error.AsCString()); + return error; } - - Thread *thread = frame_sp->GetThread().get(); - - bool is_signed; - uint32_t count; - bool is_complex; - - RegisterContext *reg_ctx = thread->GetRegisterContext().get(); - - bool set_it_simple = false; - if (compiler_type.IsIntegerOrEnumerationType (is_signed) || compiler_type.IsPointerType()) - { - DataExtractor data; - Error data_error; - size_t num_bytes = new_value_sp->GetData(data, data_error); - if (data_error.Fail()) - { - error.SetErrorStringWithFormat("Couldn't convert return value to raw data: %s", data_error.AsCString()); - return error; + lldb::offset_t offset = 0; + if (num_bytes <= 8) { + const RegisterInfo *r0_info = reg_ctx->GetRegisterInfo( + eRegisterKindGeneric, LLDB_REGNUM_GENERIC_ARG1); + if (num_bytes <= 4) { + uint32_t raw_value = data.GetMaxU32(&offset, num_bytes); + + if (reg_ctx->WriteRegisterFromUnsigned(r0_info, raw_value)) + set_it_simple = true; + } else { + uint32_t raw_value = data.GetMaxU32(&offset, 4); + + if (reg_ctx->WriteRegisterFromUnsigned(r0_info, raw_value)) { + const RegisterInfo *r1_info = reg_ctx->GetRegisterInfo( + eRegisterKindGeneric, LLDB_REGNUM_GENERIC_ARG2); + uint32_t raw_value = data.GetMaxU32(&offset, num_bytes - offset); + + if (reg_ctx->WriteRegisterFromUnsigned(r1_info, raw_value)) + set_it_simple = true; } - lldb::offset_t offset = 0; - if (num_bytes <= 8) - { - const RegisterInfo *r0_info = reg_ctx->GetRegisterInfo(eRegisterKindGeneric, LLDB_REGNUM_GENERIC_ARG1); - if (num_bytes <= 4) - { - uint32_t raw_value = data.GetMaxU32(&offset, num_bytes); - - if (reg_ctx->WriteRegisterFromUnsigned (r0_info, raw_value)) - set_it_simple = true; - } - else - { - uint32_t raw_value = data.GetMaxU32(&offset, 4); - - if (reg_ctx->WriteRegisterFromUnsigned (r0_info, raw_value)) - { - const RegisterInfo *r1_info = reg_ctx->GetRegisterInfo(eRegisterKindGeneric, LLDB_REGNUM_GENERIC_ARG2); - uint32_t raw_value = data.GetMaxU32(&offset, num_bytes - offset); - - if (reg_ctx->WriteRegisterFromUnsigned (r1_info, raw_value)) - set_it_simple = true; - } - } - } - else - { - error.SetErrorString("We don't support returning longer than 64 bit integer values at present."); - } - } - else if (compiler_type.IsFloatingPointType (count, is_complex)) - { - if (is_complex) - error.SetErrorString ("We don't support returning complex values at present"); - else - error.SetErrorString ("We don't support returning float values at present"); + } + } else { + error.SetErrorString("We don't support returning longer than 64 bit " + "integer values at present."); } - - if (!set_it_simple) - error.SetErrorString ("We only support setting simple integer return types at present."); - - return error; + } else if (compiler_type.IsFloatingPointType(count, is_complex)) { + if (is_complex) + error.SetErrorString( + "We don't support returning complex values at present"); + else + error.SetErrorString( + "We don't support returning float values at present"); + } + + if (!set_it_simple) + error.SetErrorString( + "We only support setting simple integer return types at present."); + + return error; } -bool -ABISysV_arm::CreateFunctionEntryUnwindPlan (UnwindPlan &unwind_plan) -{ - unwind_plan.Clear(); - unwind_plan.SetRegisterKind (eRegisterKindDWARF); - - uint32_t lr_reg_num = dwarf_lr; - uint32_t sp_reg_num = dwarf_sp; - uint32_t pc_reg_num = dwarf_pc; - - UnwindPlan::RowSP row(new UnwindPlan::Row); - - // Our Call Frame Address is the stack pointer value - row->GetCFAValue().SetIsRegisterPlusOffset (sp_reg_num, 0); - - // The previous PC is in the LR - row->SetRegisterLocationToRegister(pc_reg_num, lr_reg_num, true); - unwind_plan.AppendRow (row); - - // All other registers are the same. - - unwind_plan.SetSourceName ("arm at-func-entry default"); - unwind_plan.SetSourcedFromCompiler (eLazyBoolNo); - - return true; +bool ABISysV_arm::CreateFunctionEntryUnwindPlan(UnwindPlan &unwind_plan) { + unwind_plan.Clear(); + unwind_plan.SetRegisterKind(eRegisterKindDWARF); + + uint32_t lr_reg_num = dwarf_lr; + uint32_t sp_reg_num = dwarf_sp; + uint32_t pc_reg_num = dwarf_pc; + + UnwindPlan::RowSP row(new UnwindPlan::Row); + + // Our Call Frame Address is the stack pointer value + row->GetCFAValue().SetIsRegisterPlusOffset(sp_reg_num, 0); + + // The previous PC is in the LR + row->SetRegisterLocationToRegister(pc_reg_num, lr_reg_num, true); + unwind_plan.AppendRow(row); + + // All other registers are the same. + + unwind_plan.SetSourceName("arm at-func-entry default"); + unwind_plan.SetSourcedFromCompiler(eLazyBoolNo); + + return true; } -bool -ABISysV_arm::CreateDefaultUnwindPlan (UnwindPlan &unwind_plan) -{ - unwind_plan.Clear (); - unwind_plan.SetRegisterKind (eRegisterKindDWARF); - - //TODO: Handle thumb - uint32_t fp_reg_num = dwarf_r11; - uint32_t pc_reg_num = dwarf_pc; - - UnwindPlan::RowSP row(new UnwindPlan::Row); - const int32_t ptr_size = 4; - - row->GetCFAValue().SetIsRegisterPlusOffset (fp_reg_num, 2 * ptr_size); - row->SetOffset (0); - - row->SetRegisterLocationToAtCFAPlusOffset(fp_reg_num, ptr_size * -2, true); - row->SetRegisterLocationToAtCFAPlusOffset(pc_reg_num, ptr_size * -1, true); - - unwind_plan.AppendRow (row); - unwind_plan.SetSourceName ("arm default unwind plan"); - unwind_plan.SetSourcedFromCompiler (eLazyBoolNo); - unwind_plan.SetUnwindPlanValidAtAllInstructions (eLazyBoolNo); - - return true; +bool ABISysV_arm::CreateDefaultUnwindPlan(UnwindPlan &unwind_plan) { + unwind_plan.Clear(); + unwind_plan.SetRegisterKind(eRegisterKindDWARF); + + // TODO: Handle thumb + uint32_t fp_reg_num = dwarf_r11; + uint32_t pc_reg_num = dwarf_pc; + + UnwindPlan::RowSP row(new UnwindPlan::Row); + const int32_t ptr_size = 4; + + row->GetCFAValue().SetIsRegisterPlusOffset(fp_reg_num, 2 * ptr_size); + row->SetOffset(0); + + row->SetRegisterLocationToAtCFAPlusOffset(fp_reg_num, ptr_size * -2, true); + row->SetRegisterLocationToAtCFAPlusOffset(pc_reg_num, ptr_size * -1, true); + + unwind_plan.AppendRow(row); + unwind_plan.SetSourceName("arm default unwind plan"); + unwind_plan.SetSourcedFromCompiler(eLazyBoolNo); + unwind_plan.SetUnwindPlanValidAtAllInstructions(eLazyBoolNo); + + return true; } // cf. "ARMv6 Function Calling Conventions" @@ -899,210 +1987,179 @@ ABISysV_arm::CreateDefaultUnwindPlan (UnwindPlan &unwind_plan) // d8-d15 preserved (aka s16-s31, q4-q7) // d16-d31 not preserved (aka q8-q15) -bool -ABISysV_arm::RegisterIsVolatile (const RegisterInfo *reg_info) -{ - if (reg_info) - { - // Volatile registers are: r0, r1, r2, r3, r9, r12, r13 (aka sp) - const char *name = reg_info->name; - if (name[0] == 'r') - { - switch (name[1]) - { - case '0': return name[2] == '\0'; // r0 - case '1': - switch (name[2]) - { - case '\0': - return true; // r1 - case '2': - return name[3] == '\0'; // r12 - default: - break; - } - break; - - case '2': return name[2] == '\0'; // r2 - case '3': return name[2] == '\0'; // r3 - default: - break; - } +bool ABISysV_arm::RegisterIsVolatile(const RegisterInfo *reg_info) { + if (reg_info) { + // Volatile registers are: r0, r1, r2, r3, r9, r12, r13 (aka sp) + const char *name = reg_info->name; + if (name[0] == 'r') { + switch (name[1]) { + case '0': + return name[2] == '\0'; // r0 + case '1': + switch (name[2]) { + case '\0': + return true; // r1 + case '2': + return name[3] == '\0'; // r12 + default: + break; } - else if (name[0] == 'd') - { - switch (name[1]) - { - case '0': - return name[2] == '\0'; // d0 is volatile - - case '1': - switch (name[2]) - { - case '\0': - return true; // d1 is volatile - case '6': - case '7': - case '8': - case '9': - return name[3] == '\0'; // d16 - d19 are volatile - default: - break; - } - break; - - case '2': - switch (name[2]) - { - case '\0': - return true; // d2 is volatile - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - return name[3] == '\0'; // d20 - d29 are volatile - default: - break; - } - break; - - case '3': - switch (name[2]) - { - case '\0': - return true; // d3 is volatile - case '0': - case '1': - return name[3] == '\0'; // d30 - d31 are volatile - default: - break; - } - break; - case '4': - case '5': - case '6': - case '7': - return name[2] == '\0'; // d4 - d7 are volatile - - default: - break; - } + break; + + case '2': + return name[2] == '\0'; // r2 + case '3': + return name[2] == '\0'; // r3 + default: + break; + } + } else if (name[0] == 'd') { + switch (name[1]) { + case '0': + return name[2] == '\0'; // d0 is volatile + + case '1': + switch (name[2]) { + case '\0': + return true; // d1 is volatile + case '6': + case '7': + case '8': + case '9': + return name[3] == '\0'; // d16 - d19 are volatile + default: + break; } - else if (name[0] == 's') - { - switch (name[1]) - { - case '0': - return name[2] == '\0'; // s0 is volatile - - case '1': - switch (name[2]) - { - case '\0': - return true; // s1 is volatile - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - return name[3] == '\0'; // s10 - s15 are volatile - default: - break; - } - break; - - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - return name[2] == '\0'; // s2 - s9 are volatile - - default: - break; - } + break; + + case '2': + switch (name[2]) { + case '\0': + return true; // d2 is volatile + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + return name[3] == '\0'; // d20 - d29 are volatile + default: + break; } - else if (name[0] == 'q') - { - switch (name[1]) - { - case '1': - switch (name[2]) - { - case '\0': - return true; // q1 is volatile - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - return true; // q10-q15 are volatile - default: - return false; - } - break; - - case '0': - case '2': - case '3': - return name[2] == '\0'; // q0-q3 are volatile - case '8': - case '9': - return name[2] == '\0'; // q8-q9 are volatile - default: - break; - } + break; + + case '3': + switch (name[2]) { + case '\0': + return true; // d3 is volatile + case '0': + case '1': + return name[3] == '\0'; // d30 - d31 are volatile + default: + break; } - else if (name[0] == 's' && name[1] == 'p' && name[2] == '\0') - return true; - } - return false; + break; + case '4': + case '5': + case '6': + case '7': + return name[2] == '\0'; // d4 - d7 are volatile + + default: + break; + } + } else if (name[0] == 's') { + switch (name[1]) { + case '0': + return name[2] == '\0'; // s0 is volatile + + case '1': + switch (name[2]) { + case '\0': + return true; // s1 is volatile + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + return name[3] == '\0'; // s10 - s15 are volatile + default: + break; + } + break; + + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + return name[2] == '\0'; // s2 - s9 are volatile + + default: + break; + } + } else if (name[0] == 'q') { + switch (name[1]) { + case '1': + switch (name[2]) { + case '\0': + return true; // q1 is volatile + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + return true; // q10-q15 are volatile + default: + return false; + } + break; + + case '0': + case '2': + case '3': + return name[2] == '\0'; // q0-q3 are volatile + case '8': + case '9': + return name[2] == '\0'; // q8-q9 are volatile + default: + break; + } + } else if (name[0] == 's' && name[1] == 'p' && name[2] == '\0') + return true; + } + return false; } -void -ABISysV_arm::Initialize() -{ - PluginManager::RegisterPlugin (GetPluginNameStatic(), - "SysV ABI for arm targets", - CreateInstance); +void ABISysV_arm::Initialize() { + PluginManager::RegisterPlugin(GetPluginNameStatic(), + "SysV ABI for arm targets", CreateInstance); } -void -ABISysV_arm::Terminate() -{ - PluginManager::UnregisterPlugin (CreateInstance); +void ABISysV_arm::Terminate() { + PluginManager::UnregisterPlugin(CreateInstance); } -lldb_private::ConstString -ABISysV_arm::GetPluginNameStatic() -{ - static ConstString g_name("SysV-arm"); - return g_name; +lldb_private::ConstString ABISysV_arm::GetPluginNameStatic() { + static ConstString g_name("SysV-arm"); + return g_name; } //------------------------------------------------------------------ // PluginInterface protocol //------------------------------------------------------------------ -lldb_private::ConstString -ABISysV_arm::GetPluginName() -{ - return GetPluginNameStatic(); +lldb_private::ConstString ABISysV_arm::GetPluginName() { + return GetPluginNameStatic(); } -uint32_t -ABISysV_arm::GetPluginVersion() -{ - return 1; -} +uint32_t ABISysV_arm::GetPluginVersion() { return 1; } diff --git a/source/Plugins/ABI/SysV-arm/ABISysV_arm.h b/source/Plugins/ABI/SysV-arm/ABISysV_arm.h index 11a2601501e4..d85b3dff0ca5 100644 --- a/source/Plugins/ABI/SysV-arm/ABISysV_arm.h +++ b/source/Plugins/ABI/SysV-arm/ABISysV_arm.h @@ -14,111 +14,89 @@ // C++ Includes // Other libraries and framework includes // Project includes -#include "lldb/lldb-private.h" #include "lldb/Target/ABI.h" +#include "lldb/lldb-private.h" -class ABISysV_arm : public lldb_private::ABI -{ +class ABISysV_arm : public lldb_private::ABI { public: - ~ABISysV_arm() override = default; - - size_t - GetRedZoneSize () const override; - - bool - PrepareTrivialCall (lldb_private::Thread &thread, - lldb::addr_t sp, - lldb::addr_t func_addr, - lldb::addr_t returnAddress, - llvm::ArrayRef<lldb::addr_t> args) const override; - - bool - GetArgumentValues (lldb_private::Thread &thread, - lldb_private::ValueList &values) const override; - - lldb_private::Error - SetReturnValueObject(lldb::StackFrameSP &frame_sp, lldb::ValueObjectSP &new_value) override; - - bool - CreateFunctionEntryUnwindPlan (lldb_private::UnwindPlan &unwind_plan) override; - - bool - CreateDefaultUnwindPlan (lldb_private::UnwindPlan &unwind_plan) override; - - bool - RegisterIsVolatile (const lldb_private::RegisterInfo *reg_info) override; - - bool - CallFrameAddressIsValid (lldb::addr_t cfa) override - { - // Make sure the stack call frame addresses are are 4 byte aligned - if (cfa & (4ull - 1ull)) - return false; // Not 4 byte aligned - if (cfa == 0) - return false; // Zero is not a valid stack address - return true; - } - - bool - CodeAddressIsValid (lldb::addr_t pc) override - { - // Just make sure the address is a valid 32 bit address. Bit zero - // might be set due to Thumb function calls, so don't enforce 2 byte - // alignment - return pc <= UINT32_MAX; - } - - lldb::addr_t - FixCodeAddress (lldb::addr_t pc) override - { - // ARM uses bit zero to signify a code address is thumb, so we must - // strip bit zero in any code addresses. - return pc & ~(lldb::addr_t)1; - } - - const lldb_private::RegisterInfo * - GetRegisterInfoArray (uint32_t &count) override; - - bool - IsArmHardFloat (lldb_private::Thread &thread) const; - - //------------------------------------------------------------------ - // Static Functions - //------------------------------------------------------------------ - - static void - Initialize(); - - static void - Terminate(); - - static lldb::ABISP - CreateInstance (const lldb_private::ArchSpec &arch); - - static lldb_private::ConstString - GetPluginNameStatic(); - - //------------------------------------------------------------------ - // PluginInterface protocol - //------------------------------------------------------------------ - - lldb_private::ConstString - GetPluginName() override; - - uint32_t - GetPluginVersion() override; - + ~ABISysV_arm() override = default; + + size_t GetRedZoneSize() const override; + + bool PrepareTrivialCall(lldb_private::Thread &thread, lldb::addr_t sp, + lldb::addr_t func_addr, lldb::addr_t returnAddress, + llvm::ArrayRef<lldb::addr_t> args) const override; + + bool GetArgumentValues(lldb_private::Thread &thread, + lldb_private::ValueList &values) const override; + + lldb_private::Error + SetReturnValueObject(lldb::StackFrameSP &frame_sp, + lldb::ValueObjectSP &new_value) override; + + bool + CreateFunctionEntryUnwindPlan(lldb_private::UnwindPlan &unwind_plan) override; + + bool CreateDefaultUnwindPlan(lldb_private::UnwindPlan &unwind_plan) override; + + bool RegisterIsVolatile(const lldb_private::RegisterInfo *reg_info) override; + + bool CallFrameAddressIsValid(lldb::addr_t cfa) override { + // Make sure the stack call frame addresses are are 4 byte aligned + if (cfa & (4ull - 1ull)) + return false; // Not 4 byte aligned + if (cfa == 0) + return false; // Zero is not a valid stack address + return true; + } + + bool CodeAddressIsValid(lldb::addr_t pc) override { + // Just make sure the address is a valid 32 bit address. Bit zero + // might be set due to Thumb function calls, so don't enforce 2 byte + // alignment + return pc <= UINT32_MAX; + } + + lldb::addr_t FixCodeAddress(lldb::addr_t pc) override { + // ARM uses bit zero to signify a code address is thumb, so we must + // strip bit zero in any code addresses. + return pc & ~(lldb::addr_t)1; + } + + const lldb_private::RegisterInfo * + GetRegisterInfoArray(uint32_t &count) override; + + bool IsArmHardFloat(lldb_private::Thread &thread) const; + + //------------------------------------------------------------------ + // Static Functions + //------------------------------------------------------------------ + + static void Initialize(); + + static void Terminate(); + + static lldb::ABISP CreateInstance(const lldb_private::ArchSpec &arch); + + static lldb_private::ConstString GetPluginNameStatic(); + + //------------------------------------------------------------------ + // PluginInterface protocol + //------------------------------------------------------------------ + + lldb_private::ConstString GetPluginName() override; + + uint32_t GetPluginVersion() override; + protected: - lldb::ValueObjectSP - GetReturnValueObjectImpl(lldb_private::Thread &thread, - lldb_private::CompilerType &ast_type) const override; + lldb::ValueObjectSP + GetReturnValueObjectImpl(lldb_private::Thread &thread, + lldb_private::CompilerType &ast_type) const override; private: - ABISysV_arm() : - lldb_private::ABI() - { - // Call CreateInstance instead. - } + ABISysV_arm() : lldb_private::ABI() { + // Call CreateInstance instead. + } }; #endif // liblldb_ABISysV_arm_h_ diff --git a/source/Plugins/ABI/SysV-arm64/ABISysV_arm64.cpp b/source/Plugins/ABI/SysV-arm64/ABISysV_arm64.cpp index e4ed523b9d0a..5e2179212be9 100644 --- a/source/Plugins/ABI/SysV-arm64/ABISysV_arm64.cpp +++ b/source/Plugins/ABI/SysV-arm64/ABISysV_arm64.cpp @@ -38,1045 +38,2389 @@ using namespace lldb; using namespace lldb_private; -static RegisterInfo g_register_infos[] = -{ - // NAME ALT SZ OFF ENCODING FORMAT EH_FRAME DWARF GENERIC PROCESS PLUGIN LLDB NATIVE - // ========== ======= == === ============= =================== =================== ====================== =========================== ======================= ====================== - { "x0", nullptr, 8, 0, eEncodingUint , eFormatHex , { LLDB_INVALID_REGNUM, arm64_dwarf::x0, LLDB_REGNUM_GENERIC_ARG1, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "x1", nullptr, 8, 0, eEncodingUint , eFormatHex , { LLDB_INVALID_REGNUM, arm64_dwarf::x1, LLDB_REGNUM_GENERIC_ARG2, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "x2", nullptr, 8, 0, eEncodingUint , eFormatHex , { LLDB_INVALID_REGNUM, arm64_dwarf::x2, LLDB_REGNUM_GENERIC_ARG3, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "x3", nullptr, 8, 0, eEncodingUint , eFormatHex , { LLDB_INVALID_REGNUM, arm64_dwarf::x3, LLDB_REGNUM_GENERIC_ARG4, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "x4", nullptr, 8, 0, eEncodingUint , eFormatHex , { LLDB_INVALID_REGNUM, arm64_dwarf::x4, LLDB_REGNUM_GENERIC_ARG5, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "x5", nullptr, 8, 0, eEncodingUint , eFormatHex , { LLDB_INVALID_REGNUM, arm64_dwarf::x5, LLDB_REGNUM_GENERIC_ARG6, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "x6", nullptr, 8, 0, eEncodingUint , eFormatHex , { LLDB_INVALID_REGNUM, arm64_dwarf::x6, LLDB_REGNUM_GENERIC_ARG7, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "x7", nullptr, 8, 0, eEncodingUint , eFormatHex , { LLDB_INVALID_REGNUM, arm64_dwarf::x7, LLDB_REGNUM_GENERIC_ARG8, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "x8", nullptr, 8, 0, eEncodingUint , eFormatHex , { LLDB_INVALID_REGNUM, arm64_dwarf::x8, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "x9", nullptr, 8, 0, eEncodingUint , eFormatHex , { LLDB_INVALID_REGNUM, arm64_dwarf::x9, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "x10", nullptr, 8, 0, eEncodingUint , eFormatHex , { LLDB_INVALID_REGNUM, arm64_dwarf::x10, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "x11", nullptr, 8, 0, eEncodingUint , eFormatHex , { LLDB_INVALID_REGNUM, arm64_dwarf::x11, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "x12", nullptr, 8, 0, eEncodingUint , eFormatHex , { LLDB_INVALID_REGNUM, arm64_dwarf::x12, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "x13", nullptr, 8, 0, eEncodingUint , eFormatHex , { LLDB_INVALID_REGNUM, arm64_dwarf::x13, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "x14", nullptr, 8, 0, eEncodingUint , eFormatHex , { LLDB_INVALID_REGNUM, arm64_dwarf::x14, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "x15", nullptr, 8, 0, eEncodingUint , eFormatHex , { LLDB_INVALID_REGNUM, arm64_dwarf::x15, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "x16", nullptr, 8, 0, eEncodingUint , eFormatHex , { LLDB_INVALID_REGNUM, arm64_dwarf::x16, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "x17", nullptr, 8, 0, eEncodingUint , eFormatHex , { LLDB_INVALID_REGNUM, arm64_dwarf::x17, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "x18", nullptr, 8, 0, eEncodingUint , eFormatHex , { LLDB_INVALID_REGNUM, arm64_dwarf::x18, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "x19", nullptr, 8, 0, eEncodingUint , eFormatHex , { LLDB_INVALID_REGNUM, arm64_dwarf::x19, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "x20", nullptr, 8, 0, eEncodingUint , eFormatHex , { LLDB_INVALID_REGNUM, arm64_dwarf::x20, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "x21", nullptr, 8, 0, eEncodingUint , eFormatHex , { LLDB_INVALID_REGNUM, arm64_dwarf::x21, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "x22", nullptr, 8, 0, eEncodingUint , eFormatHex , { LLDB_INVALID_REGNUM, arm64_dwarf::x22, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "x23", nullptr, 8, 0, eEncodingUint , eFormatHex , { LLDB_INVALID_REGNUM, arm64_dwarf::x23, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "x24", nullptr, 8, 0, eEncodingUint , eFormatHex , { LLDB_INVALID_REGNUM, arm64_dwarf::x24, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "x25", nullptr, 8, 0, eEncodingUint , eFormatHex , { LLDB_INVALID_REGNUM, arm64_dwarf::x25, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "x26", nullptr, 8, 0, eEncodingUint , eFormatHex , { LLDB_INVALID_REGNUM, arm64_dwarf::x26, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "x27", nullptr, 8, 0, eEncodingUint , eFormatHex , { LLDB_INVALID_REGNUM, arm64_dwarf::x27, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "x28", nullptr, 8, 0, eEncodingUint , eFormatHex , { LLDB_INVALID_REGNUM, arm64_dwarf::x28, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "fp", "x29", 8, 0, eEncodingUint , eFormatHex , { LLDB_INVALID_REGNUM, arm64_dwarf::x29, LLDB_REGNUM_GENERIC_FP, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "lr", "x30", 8, 0, eEncodingUint , eFormatHex , { LLDB_INVALID_REGNUM, arm64_dwarf::x30, LLDB_REGNUM_GENERIC_RA, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "sp", "x31", 8, 0, eEncodingUint , eFormatHex , { LLDB_INVALID_REGNUM, arm64_dwarf::x31, LLDB_REGNUM_GENERIC_SP, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "pc", nullptr, 8, 0, eEncodingUint , eFormatHex , { LLDB_INVALID_REGNUM, arm64_dwarf::pc, LLDB_REGNUM_GENERIC_PC, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "cpsr", "psr", 4, 0, eEncodingUint , eFormatHex , { LLDB_INVALID_REGNUM, arm64_dwarf::cpsr, LLDB_REGNUM_GENERIC_FLAGS, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - - { "v0", nullptr, 16, 0, eEncodingVector , eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM, arm64_dwarf::v0, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "v1", nullptr, 16, 0, eEncodingVector , eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM, arm64_dwarf::v1, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "v2", nullptr, 16, 0, eEncodingVector , eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM, arm64_dwarf::v2, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "v3", nullptr, 16, 0, eEncodingVector , eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM, arm64_dwarf::v3, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "v4", nullptr, 16, 0, eEncodingVector , eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM, arm64_dwarf::v4, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "v5", nullptr, 16, 0, eEncodingVector , eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM, arm64_dwarf::v5, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "v6", nullptr, 16, 0, eEncodingVector , eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM, arm64_dwarf::v6, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "v7", nullptr, 16, 0, eEncodingVector , eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM, arm64_dwarf::v7, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "v8", nullptr, 16, 0, eEncodingVector , eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM, arm64_dwarf::v8, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "v9", nullptr, 16, 0, eEncodingVector , eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM, arm64_dwarf::v9, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "v10", nullptr, 16, 0, eEncodingVector , eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM, arm64_dwarf::v10, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "v11", nullptr, 16, 0, eEncodingVector , eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM, arm64_dwarf::v11, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "v12", nullptr, 16, 0, eEncodingVector , eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM, arm64_dwarf::v12, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "v13", nullptr, 16, 0, eEncodingVector , eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM, arm64_dwarf::v13, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "v14", nullptr, 16, 0, eEncodingVector , eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM, arm64_dwarf::v14, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "v15", nullptr, 16, 0, eEncodingVector , eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM, arm64_dwarf::v15, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "v16", nullptr, 16, 0, eEncodingVector , eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM, arm64_dwarf::v16, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "v17", nullptr, 16, 0, eEncodingVector , eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM, arm64_dwarf::v17, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "v18", nullptr, 16, 0, eEncodingVector , eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM, arm64_dwarf::v18, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "v19", nullptr, 16, 0, eEncodingVector , eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM, arm64_dwarf::v19, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "v20", nullptr, 16, 0, eEncodingVector , eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM, arm64_dwarf::v20, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "v21", nullptr, 16, 0, eEncodingVector , eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM, arm64_dwarf::v21, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "v22", nullptr, 16, 0, eEncodingVector , eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM, arm64_dwarf::v22, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "v23", nullptr, 16, 0, eEncodingVector , eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM, arm64_dwarf::v23, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "v24", nullptr, 16, 0, eEncodingVector , eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM, arm64_dwarf::v24, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "v25", nullptr, 16, 0, eEncodingVector , eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM, arm64_dwarf::v25, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "v26", nullptr, 16, 0, eEncodingVector , eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM, arm64_dwarf::v26, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "v27", nullptr, 16, 0, eEncodingVector , eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM, arm64_dwarf::v27, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "v28", nullptr, 16, 0, eEncodingVector , eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM, arm64_dwarf::v28, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "v29", nullptr, 16, 0, eEncodingVector , eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM, arm64_dwarf::v29, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "v30", nullptr, 16, 0, eEncodingVector , eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM, arm64_dwarf::v30, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "v31", nullptr, 16, 0, eEncodingVector , eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM, arm64_dwarf::v31, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - - { "fpsr", nullptr, 4, 0, eEncodingUint , eFormatHex , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "fpcr", nullptr, 4, 0, eEncodingUint , eFormatHex , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - - { "s0", nullptr, 4, 0, eEncodingIEEE754 , eFormatFloat , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "s1", nullptr, 4, 0, eEncodingIEEE754 , eFormatFloat , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "s2", nullptr, 4, 0, eEncodingIEEE754 , eFormatFloat , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "s3", nullptr, 4, 0, eEncodingIEEE754 , eFormatFloat , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "s4", nullptr, 4, 0, eEncodingIEEE754 , eFormatFloat , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "s5", nullptr, 4, 0, eEncodingIEEE754 , eFormatFloat , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "s6", nullptr, 4, 0, eEncodingIEEE754 , eFormatFloat , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "s7", nullptr, 4, 0, eEncodingIEEE754 , eFormatFloat , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "s8", nullptr, 4, 0, eEncodingIEEE754 , eFormatFloat , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "s9", nullptr, 4, 0, eEncodingIEEE754 , eFormatFloat , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "s10", nullptr, 4, 0, eEncodingIEEE754 , eFormatFloat , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "s11", nullptr, 4, 0, eEncodingIEEE754 , eFormatFloat , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "s12", nullptr, 4, 0, eEncodingIEEE754 , eFormatFloat , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "s13", nullptr, 4, 0, eEncodingIEEE754 , eFormatFloat , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "s14", nullptr, 4, 0, eEncodingIEEE754 , eFormatFloat , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "s15", nullptr, 4, 0, eEncodingIEEE754 , eFormatFloat , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "s16", nullptr, 4, 0, eEncodingIEEE754 , eFormatFloat , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "s17", nullptr, 4, 0, eEncodingIEEE754 , eFormatFloat , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "s18", nullptr, 4, 0, eEncodingIEEE754 , eFormatFloat , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "s19", nullptr, 4, 0, eEncodingIEEE754 , eFormatFloat , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "s20", nullptr, 4, 0, eEncodingIEEE754 , eFormatFloat , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "s21", nullptr, 4, 0, eEncodingIEEE754 , eFormatFloat , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "s22", nullptr, 4, 0, eEncodingIEEE754 , eFormatFloat , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "s23", nullptr, 4, 0, eEncodingIEEE754 , eFormatFloat , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "s24", nullptr, 4, 0, eEncodingIEEE754 , eFormatFloat , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "s25", nullptr, 4, 0, eEncodingIEEE754 , eFormatFloat , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "s26", nullptr, 4, 0, eEncodingIEEE754 , eFormatFloat , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "s27", nullptr, 4, 0, eEncodingIEEE754 , eFormatFloat , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "s28", nullptr, 4, 0, eEncodingIEEE754 , eFormatFloat , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "s29", nullptr, 4, 0, eEncodingIEEE754 , eFormatFloat , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "s30", nullptr, 4, 0, eEncodingIEEE754 , eFormatFloat , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "s31", nullptr, 4, 0, eEncodingIEEE754 , eFormatFloat , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - - { "d0", nullptr, 8, 0, eEncodingIEEE754 , eFormatFloat , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "d1", nullptr, 8, 0, eEncodingIEEE754 , eFormatFloat , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "d2", nullptr, 8, 0, eEncodingIEEE754 , eFormatFloat , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "d3", nullptr, 8, 0, eEncodingIEEE754 , eFormatFloat , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "d4", nullptr, 8, 0, eEncodingIEEE754 , eFormatFloat , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "d5", nullptr, 8, 0, eEncodingIEEE754 , eFormatFloat , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "d6", nullptr, 8, 0, eEncodingIEEE754 , eFormatFloat , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "d7", nullptr, 8, 0, eEncodingIEEE754 , eFormatFloat , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "d8", nullptr, 8, 0, eEncodingIEEE754 , eFormatFloat , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "d9", nullptr, 8, 0, eEncodingIEEE754 , eFormatFloat , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "d10", nullptr, 8, 0, eEncodingIEEE754 , eFormatFloat , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "d11", nullptr, 8, 0, eEncodingIEEE754 , eFormatFloat , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "d12", nullptr, 8, 0, eEncodingIEEE754 , eFormatFloat , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "d13", nullptr, 8, 0, eEncodingIEEE754 , eFormatFloat , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "d14", nullptr, 8, 0, eEncodingIEEE754 , eFormatFloat , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "d15", nullptr, 8, 0, eEncodingIEEE754 , eFormatFloat , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "d16", nullptr, 8, 0, eEncodingIEEE754 , eFormatFloat , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "d17", nullptr, 8, 0, eEncodingIEEE754 , eFormatFloat , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "d18", nullptr, 8, 0, eEncodingIEEE754 , eFormatFloat , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "d19", nullptr, 8, 0, eEncodingIEEE754 , eFormatFloat , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "d20", nullptr, 8, 0, eEncodingIEEE754 , eFormatFloat , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "d21", nullptr, 8, 0, eEncodingIEEE754 , eFormatFloat , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "d22", nullptr, 8, 0, eEncodingIEEE754 , eFormatFloat , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "d23", nullptr, 8, 0, eEncodingIEEE754 , eFormatFloat , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "d24", nullptr, 8, 0, eEncodingIEEE754 , eFormatFloat , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "d25", nullptr, 8, 0, eEncodingIEEE754 , eFormatFloat , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "d26", nullptr, 8, 0, eEncodingIEEE754 , eFormatFloat , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "d27", nullptr, 8, 0, eEncodingIEEE754 , eFormatFloat , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "d28", nullptr, 8, 0, eEncodingIEEE754 , eFormatFloat , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "d29", nullptr, 8, 0, eEncodingIEEE754 , eFormatFloat , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "d30", nullptr, 8, 0, eEncodingIEEE754 , eFormatFloat , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "d31", nullptr, 8, 0, eEncodingIEEE754 , eFormatFloat , { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr } -}; - -static const uint32_t k_num_register_infos = llvm::array_lengthof(g_register_infos); +static RegisterInfo g_register_infos[] = { + // NAME ALT SZ OFF ENCODING FORMAT + // EH_FRAME DWARF GENERIC + // PROCESS PLUGIN LLDB NATIVE + // ========== ======= == === ============= =================== + // =================== ====================== =========================== + // ======================= ====================== + {"x0", + nullptr, + 8, + 0, + eEncodingUint, + eFormatHex, + {LLDB_INVALID_REGNUM, arm64_dwarf::x0, LLDB_REGNUM_GENERIC_ARG1, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"x1", + nullptr, + 8, + 0, + eEncodingUint, + eFormatHex, + {LLDB_INVALID_REGNUM, arm64_dwarf::x1, LLDB_REGNUM_GENERIC_ARG2, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"x2", + nullptr, + 8, + 0, + eEncodingUint, + eFormatHex, + {LLDB_INVALID_REGNUM, arm64_dwarf::x2, LLDB_REGNUM_GENERIC_ARG3, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"x3", + nullptr, + 8, + 0, + eEncodingUint, + eFormatHex, + {LLDB_INVALID_REGNUM, arm64_dwarf::x3, LLDB_REGNUM_GENERIC_ARG4, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"x4", + nullptr, + 8, + 0, + eEncodingUint, + eFormatHex, + {LLDB_INVALID_REGNUM, arm64_dwarf::x4, LLDB_REGNUM_GENERIC_ARG5, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"x5", + nullptr, + 8, + 0, + eEncodingUint, + eFormatHex, + {LLDB_INVALID_REGNUM, arm64_dwarf::x5, LLDB_REGNUM_GENERIC_ARG6, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"x6", + nullptr, + 8, + 0, + eEncodingUint, + eFormatHex, + {LLDB_INVALID_REGNUM, arm64_dwarf::x6, LLDB_REGNUM_GENERIC_ARG7, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"x7", + nullptr, + 8, + 0, + eEncodingUint, + eFormatHex, + {LLDB_INVALID_REGNUM, arm64_dwarf::x7, LLDB_REGNUM_GENERIC_ARG8, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"x8", + nullptr, + 8, + 0, + eEncodingUint, + eFormatHex, + {LLDB_INVALID_REGNUM, arm64_dwarf::x8, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"x9", + nullptr, + 8, + 0, + eEncodingUint, + eFormatHex, + {LLDB_INVALID_REGNUM, arm64_dwarf::x9, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"x10", + nullptr, + 8, + 0, + eEncodingUint, + eFormatHex, + {LLDB_INVALID_REGNUM, arm64_dwarf::x10, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"x11", + nullptr, + 8, + 0, + eEncodingUint, + eFormatHex, + {LLDB_INVALID_REGNUM, arm64_dwarf::x11, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"x12", + nullptr, + 8, + 0, + eEncodingUint, + eFormatHex, + {LLDB_INVALID_REGNUM, arm64_dwarf::x12, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"x13", + nullptr, + 8, + 0, + eEncodingUint, + eFormatHex, + {LLDB_INVALID_REGNUM, arm64_dwarf::x13, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"x14", + nullptr, + 8, + 0, + eEncodingUint, + eFormatHex, + {LLDB_INVALID_REGNUM, arm64_dwarf::x14, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"x15", + nullptr, + 8, + 0, + eEncodingUint, + eFormatHex, + {LLDB_INVALID_REGNUM, arm64_dwarf::x15, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"x16", + nullptr, + 8, + 0, + eEncodingUint, + eFormatHex, + {LLDB_INVALID_REGNUM, arm64_dwarf::x16, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"x17", + nullptr, + 8, + 0, + eEncodingUint, + eFormatHex, + {LLDB_INVALID_REGNUM, arm64_dwarf::x17, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"x18", + nullptr, + 8, + 0, + eEncodingUint, + eFormatHex, + {LLDB_INVALID_REGNUM, arm64_dwarf::x18, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"x19", + nullptr, + 8, + 0, + eEncodingUint, + eFormatHex, + {LLDB_INVALID_REGNUM, arm64_dwarf::x19, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"x20", + nullptr, + 8, + 0, + eEncodingUint, + eFormatHex, + {LLDB_INVALID_REGNUM, arm64_dwarf::x20, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"x21", + nullptr, + 8, + 0, + eEncodingUint, + eFormatHex, + {LLDB_INVALID_REGNUM, arm64_dwarf::x21, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"x22", + nullptr, + 8, + 0, + eEncodingUint, + eFormatHex, + {LLDB_INVALID_REGNUM, arm64_dwarf::x22, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"x23", + nullptr, + 8, + 0, + eEncodingUint, + eFormatHex, + {LLDB_INVALID_REGNUM, arm64_dwarf::x23, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"x24", + nullptr, + 8, + 0, + eEncodingUint, + eFormatHex, + {LLDB_INVALID_REGNUM, arm64_dwarf::x24, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"x25", + nullptr, + 8, + 0, + eEncodingUint, + eFormatHex, + {LLDB_INVALID_REGNUM, arm64_dwarf::x25, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"x26", + nullptr, + 8, + 0, + eEncodingUint, + eFormatHex, + {LLDB_INVALID_REGNUM, arm64_dwarf::x26, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"x27", + nullptr, + 8, + 0, + eEncodingUint, + eFormatHex, + {LLDB_INVALID_REGNUM, arm64_dwarf::x27, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"x28", + nullptr, + 8, + 0, + eEncodingUint, + eFormatHex, + {LLDB_INVALID_REGNUM, arm64_dwarf::x28, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"fp", + "x29", + 8, + 0, + eEncodingUint, + eFormatHex, + {LLDB_INVALID_REGNUM, arm64_dwarf::x29, LLDB_REGNUM_GENERIC_FP, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"lr", + "x30", + 8, + 0, + eEncodingUint, + eFormatHex, + {LLDB_INVALID_REGNUM, arm64_dwarf::x30, LLDB_REGNUM_GENERIC_RA, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"sp", + "x31", + 8, + 0, + eEncodingUint, + eFormatHex, + {LLDB_INVALID_REGNUM, arm64_dwarf::x31, LLDB_REGNUM_GENERIC_SP, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"pc", + nullptr, + 8, + 0, + eEncodingUint, + eFormatHex, + {LLDB_INVALID_REGNUM, arm64_dwarf::pc, LLDB_REGNUM_GENERIC_PC, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"cpsr", + "psr", + 4, + 0, + eEncodingUint, + eFormatHex, + {LLDB_INVALID_REGNUM, arm64_dwarf::cpsr, LLDB_REGNUM_GENERIC_FLAGS, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + + {"v0", + nullptr, + 16, + 0, + eEncodingVector, + eFormatVectorOfUInt8, + {LLDB_INVALID_REGNUM, arm64_dwarf::v0, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"v1", + nullptr, + 16, + 0, + eEncodingVector, + eFormatVectorOfUInt8, + {LLDB_INVALID_REGNUM, arm64_dwarf::v1, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"v2", + nullptr, + 16, + 0, + eEncodingVector, + eFormatVectorOfUInt8, + {LLDB_INVALID_REGNUM, arm64_dwarf::v2, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"v3", + nullptr, + 16, + 0, + eEncodingVector, + eFormatVectorOfUInt8, + {LLDB_INVALID_REGNUM, arm64_dwarf::v3, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"v4", + nullptr, + 16, + 0, + eEncodingVector, + eFormatVectorOfUInt8, + {LLDB_INVALID_REGNUM, arm64_dwarf::v4, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"v5", + nullptr, + 16, + 0, + eEncodingVector, + eFormatVectorOfUInt8, + {LLDB_INVALID_REGNUM, arm64_dwarf::v5, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"v6", + nullptr, + 16, + 0, + eEncodingVector, + eFormatVectorOfUInt8, + {LLDB_INVALID_REGNUM, arm64_dwarf::v6, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"v7", + nullptr, + 16, + 0, + eEncodingVector, + eFormatVectorOfUInt8, + {LLDB_INVALID_REGNUM, arm64_dwarf::v7, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"v8", + nullptr, + 16, + 0, + eEncodingVector, + eFormatVectorOfUInt8, + {LLDB_INVALID_REGNUM, arm64_dwarf::v8, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"v9", + nullptr, + 16, + 0, + eEncodingVector, + eFormatVectorOfUInt8, + {LLDB_INVALID_REGNUM, arm64_dwarf::v9, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"v10", + nullptr, + 16, + 0, + eEncodingVector, + eFormatVectorOfUInt8, + {LLDB_INVALID_REGNUM, arm64_dwarf::v10, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"v11", + nullptr, + 16, + 0, + eEncodingVector, + eFormatVectorOfUInt8, + {LLDB_INVALID_REGNUM, arm64_dwarf::v11, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"v12", + nullptr, + 16, + 0, + eEncodingVector, + eFormatVectorOfUInt8, + {LLDB_INVALID_REGNUM, arm64_dwarf::v12, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"v13", + nullptr, + 16, + 0, + eEncodingVector, + eFormatVectorOfUInt8, + {LLDB_INVALID_REGNUM, arm64_dwarf::v13, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"v14", + nullptr, + 16, + 0, + eEncodingVector, + eFormatVectorOfUInt8, + {LLDB_INVALID_REGNUM, arm64_dwarf::v14, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"v15", + nullptr, + 16, + 0, + eEncodingVector, + eFormatVectorOfUInt8, + {LLDB_INVALID_REGNUM, arm64_dwarf::v15, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"v16", + nullptr, + 16, + 0, + eEncodingVector, + eFormatVectorOfUInt8, + {LLDB_INVALID_REGNUM, arm64_dwarf::v16, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"v17", + nullptr, + 16, + 0, + eEncodingVector, + eFormatVectorOfUInt8, + {LLDB_INVALID_REGNUM, arm64_dwarf::v17, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"v18", + nullptr, + 16, + 0, + eEncodingVector, + eFormatVectorOfUInt8, + {LLDB_INVALID_REGNUM, arm64_dwarf::v18, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"v19", + nullptr, + 16, + 0, + eEncodingVector, + eFormatVectorOfUInt8, + {LLDB_INVALID_REGNUM, arm64_dwarf::v19, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"v20", + nullptr, + 16, + 0, + eEncodingVector, + eFormatVectorOfUInt8, + {LLDB_INVALID_REGNUM, arm64_dwarf::v20, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"v21", + nullptr, + 16, + 0, + eEncodingVector, + eFormatVectorOfUInt8, + {LLDB_INVALID_REGNUM, arm64_dwarf::v21, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"v22", + nullptr, + 16, + 0, + eEncodingVector, + eFormatVectorOfUInt8, + {LLDB_INVALID_REGNUM, arm64_dwarf::v22, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"v23", + nullptr, + 16, + 0, + eEncodingVector, + eFormatVectorOfUInt8, + {LLDB_INVALID_REGNUM, arm64_dwarf::v23, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"v24", + nullptr, + 16, + 0, + eEncodingVector, + eFormatVectorOfUInt8, + {LLDB_INVALID_REGNUM, arm64_dwarf::v24, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"v25", + nullptr, + 16, + 0, + eEncodingVector, + eFormatVectorOfUInt8, + {LLDB_INVALID_REGNUM, arm64_dwarf::v25, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"v26", + nullptr, + 16, + 0, + eEncodingVector, + eFormatVectorOfUInt8, + {LLDB_INVALID_REGNUM, arm64_dwarf::v26, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"v27", + nullptr, + 16, + 0, + eEncodingVector, + eFormatVectorOfUInt8, + {LLDB_INVALID_REGNUM, arm64_dwarf::v27, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"v28", + nullptr, + 16, + 0, + eEncodingVector, + eFormatVectorOfUInt8, + {LLDB_INVALID_REGNUM, arm64_dwarf::v28, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"v29", + nullptr, + 16, + 0, + eEncodingVector, + eFormatVectorOfUInt8, + {LLDB_INVALID_REGNUM, arm64_dwarf::v29, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"v30", + nullptr, + 16, + 0, + eEncodingVector, + eFormatVectorOfUInt8, + {LLDB_INVALID_REGNUM, arm64_dwarf::v30, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"v31", + nullptr, + 16, + 0, + eEncodingVector, + eFormatVectorOfUInt8, + {LLDB_INVALID_REGNUM, arm64_dwarf::v31, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + + {"fpsr", + nullptr, + 4, + 0, + eEncodingUint, + eFormatHex, + {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"fpcr", + nullptr, + 4, + 0, + eEncodingUint, + eFormatHex, + {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + + {"s0", + nullptr, + 4, + 0, + eEncodingIEEE754, + eFormatFloat, + {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"s1", + nullptr, + 4, + 0, + eEncodingIEEE754, + eFormatFloat, + {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"s2", + nullptr, + 4, + 0, + eEncodingIEEE754, + eFormatFloat, + {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"s3", + nullptr, + 4, + 0, + eEncodingIEEE754, + eFormatFloat, + {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"s4", + nullptr, + 4, + 0, + eEncodingIEEE754, + eFormatFloat, + {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"s5", + nullptr, + 4, + 0, + eEncodingIEEE754, + eFormatFloat, + {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"s6", + nullptr, + 4, + 0, + eEncodingIEEE754, + eFormatFloat, + {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"s7", + nullptr, + 4, + 0, + eEncodingIEEE754, + eFormatFloat, + {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"s8", + nullptr, + 4, + 0, + eEncodingIEEE754, + eFormatFloat, + {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"s9", + nullptr, + 4, + 0, + eEncodingIEEE754, + eFormatFloat, + {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"s10", + nullptr, + 4, + 0, + eEncodingIEEE754, + eFormatFloat, + {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"s11", + nullptr, + 4, + 0, + eEncodingIEEE754, + eFormatFloat, + {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"s12", + nullptr, + 4, + 0, + eEncodingIEEE754, + eFormatFloat, + {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"s13", + nullptr, + 4, + 0, + eEncodingIEEE754, + eFormatFloat, + {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"s14", + nullptr, + 4, + 0, + eEncodingIEEE754, + eFormatFloat, + {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"s15", + nullptr, + 4, + 0, + eEncodingIEEE754, + eFormatFloat, + {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"s16", + nullptr, + 4, + 0, + eEncodingIEEE754, + eFormatFloat, + {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"s17", + nullptr, + 4, + 0, + eEncodingIEEE754, + eFormatFloat, + {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"s18", + nullptr, + 4, + 0, + eEncodingIEEE754, + eFormatFloat, + {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"s19", + nullptr, + 4, + 0, + eEncodingIEEE754, + eFormatFloat, + {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"s20", + nullptr, + 4, + 0, + eEncodingIEEE754, + eFormatFloat, + {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"s21", + nullptr, + 4, + 0, + eEncodingIEEE754, + eFormatFloat, + {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"s22", + nullptr, + 4, + 0, + eEncodingIEEE754, + eFormatFloat, + {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"s23", + nullptr, + 4, + 0, + eEncodingIEEE754, + eFormatFloat, + {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"s24", + nullptr, + 4, + 0, + eEncodingIEEE754, + eFormatFloat, + {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"s25", + nullptr, + 4, + 0, + eEncodingIEEE754, + eFormatFloat, + {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"s26", + nullptr, + 4, + 0, + eEncodingIEEE754, + eFormatFloat, + {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"s27", + nullptr, + 4, + 0, + eEncodingIEEE754, + eFormatFloat, + {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"s28", + nullptr, + 4, + 0, + eEncodingIEEE754, + eFormatFloat, + {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"s29", + nullptr, + 4, + 0, + eEncodingIEEE754, + eFormatFloat, + {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"s30", + nullptr, + 4, + 0, + eEncodingIEEE754, + eFormatFloat, + {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"s31", + nullptr, + 4, + 0, + eEncodingIEEE754, + eFormatFloat, + {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + + {"d0", + nullptr, + 8, + 0, + eEncodingIEEE754, + eFormatFloat, + {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"d1", + nullptr, + 8, + 0, + eEncodingIEEE754, + eFormatFloat, + {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"d2", + nullptr, + 8, + 0, + eEncodingIEEE754, + eFormatFloat, + {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"d3", + nullptr, + 8, + 0, + eEncodingIEEE754, + eFormatFloat, + {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"d4", + nullptr, + 8, + 0, + eEncodingIEEE754, + eFormatFloat, + {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"d5", + nullptr, + 8, + 0, + eEncodingIEEE754, + eFormatFloat, + {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"d6", + nullptr, + 8, + 0, + eEncodingIEEE754, + eFormatFloat, + {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"d7", + nullptr, + 8, + 0, + eEncodingIEEE754, + eFormatFloat, + {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"d8", + nullptr, + 8, + 0, + eEncodingIEEE754, + eFormatFloat, + {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"d9", + nullptr, + 8, + 0, + eEncodingIEEE754, + eFormatFloat, + {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"d10", + nullptr, + 8, + 0, + eEncodingIEEE754, + eFormatFloat, + {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"d11", + nullptr, + 8, + 0, + eEncodingIEEE754, + eFormatFloat, + {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"d12", + nullptr, + 8, + 0, + eEncodingIEEE754, + eFormatFloat, + {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"d13", + nullptr, + 8, + 0, + eEncodingIEEE754, + eFormatFloat, + {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"d14", + nullptr, + 8, + 0, + eEncodingIEEE754, + eFormatFloat, + {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"d15", + nullptr, + 8, + 0, + eEncodingIEEE754, + eFormatFloat, + {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"d16", + nullptr, + 8, + 0, + eEncodingIEEE754, + eFormatFloat, + {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"d17", + nullptr, + 8, + 0, + eEncodingIEEE754, + eFormatFloat, + {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"d18", + nullptr, + 8, + 0, + eEncodingIEEE754, + eFormatFloat, + {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"d19", + nullptr, + 8, + 0, + eEncodingIEEE754, + eFormatFloat, + {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"d20", + nullptr, + 8, + 0, + eEncodingIEEE754, + eFormatFloat, + {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"d21", + nullptr, + 8, + 0, + eEncodingIEEE754, + eFormatFloat, + {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"d22", + nullptr, + 8, + 0, + eEncodingIEEE754, + eFormatFloat, + {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"d23", + nullptr, + 8, + 0, + eEncodingIEEE754, + eFormatFloat, + {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"d24", + nullptr, + 8, + 0, + eEncodingIEEE754, + eFormatFloat, + {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"d25", + nullptr, + 8, + 0, + eEncodingIEEE754, + eFormatFloat, + {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"d26", + nullptr, + 8, + 0, + eEncodingIEEE754, + eFormatFloat, + {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"d27", + nullptr, + 8, + 0, + eEncodingIEEE754, + eFormatFloat, + {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"d28", + nullptr, + 8, + 0, + eEncodingIEEE754, + eFormatFloat, + {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"d29", + nullptr, + 8, + 0, + eEncodingIEEE754, + eFormatFloat, + {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"d30", + nullptr, + 8, + 0, + eEncodingIEEE754, + eFormatFloat, + {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"d31", + nullptr, + 8, + 0, + eEncodingIEEE754, + eFormatFloat, + {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}}; + +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_arm64::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(); - } +ABISysV_arm64::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; + } + count = k_num_register_infos; + return g_register_infos; } -size_t -ABISysV_arm64::GetRedZoneSize () const -{ - return 128; +bool ABISysV_arm64::GetPointerReturnRegister(const char *&name) { + name = "x0"; + return true; } +size_t ABISysV_arm64::GetRedZoneSize() const { return 128; } + //------------------------------------------------------------------ // Static Functions //------------------------------------------------------------------ ABISP -ABISysV_arm64::CreateInstance (const ArchSpec &arch) -{ - static ABISP g_abi_sp; - const llvm::Triple::ArchType arch_type = arch.GetTriple().getArch(); - const llvm::Triple::VendorType vendor_type = arch.GetTriple().getVendor(); - - if (vendor_type != llvm::Triple::Apple) - { - if (arch_type == llvm::Triple::aarch64) - { - if (!g_abi_sp) - g_abi_sp.reset (new ABISysV_arm64); - return g_abi_sp; - } +ABISysV_arm64::CreateInstance(const ArchSpec &arch) { + static ABISP g_abi_sp; + const llvm::Triple::ArchType arch_type = arch.GetTriple().getArch(); + const llvm::Triple::VendorType vendor_type = arch.GetTriple().getVendor(); + + if (vendor_type != llvm::Triple::Apple) { + if (arch_type == llvm::Triple::aarch64) { + if (!g_abi_sp) + g_abi_sp.reset(new ABISysV_arm64); + return g_abi_sp; } + } - return ABISP(); + return ABISP(); } -bool -ABISysV_arm64::PrepareTrivialCall (Thread &thread, - addr_t sp, - addr_t func_addr, - addr_t return_addr, - llvm::ArrayRef<addr_t> args) const -{ - RegisterContext *reg_ctx = thread.GetRegisterContext().get(); - if (!reg_ctx) - return false; +bool ABISysV_arm64::PrepareTrivialCall(Thread &thread, addr_t sp, + addr_t func_addr, addr_t return_addr, + llvm::ArrayRef<addr_t> args) const { + RegisterContext *reg_ctx = thread.GetRegisterContext().get(); + if (!reg_ctx) + return false; + + Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS)); - Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS)); + if (log) { + StreamString s; + s.Printf("ABISysV_x86_64::PrepareTrivialCall (tid = 0x%" PRIx64 + ", sp = 0x%" PRIx64 ", func_addr = 0x%" PRIx64 + ", return_addr = 0x%" PRIx64, + thread.GetID(), (uint64_t)sp, (uint64_t)func_addr, + (uint64_t)return_addr); + for (size_t i = 0; i < args.size(); ++i) + s.Printf(", arg%d = 0x%" PRIx64, static_cast<int>(i + 1), args[i]); + s.PutCString(")"); + log->PutString(s.GetString()); + } + + // x0 - x7 contain first 8 simple args + if (args.size() > 8) + return false; + + for (size_t i = 0; i < args.size(); ++i) { + const RegisterInfo *reg_info = reg_ctx->GetRegisterInfo( + eRegisterKindGeneric, LLDB_REGNUM_GENERIC_ARG1 + i); if (log) - { - StreamString s; - s.Printf("ABISysV_x86_64::PrepareTrivialCall (tid = 0x%" PRIx64 ", sp = 0x%" PRIx64 ", func_addr = 0x%" PRIx64 ", return_addr = 0x%" PRIx64, - thread.GetID(), - (uint64_t)sp, - (uint64_t)func_addr, - (uint64_t)return_addr); - - for (size_t i = 0; i < args.size(); ++i) - s.Printf (", arg%d = 0x%" PRIx64, static_cast<int>(i + 1), args[i]); - s.PutCString (")"); - log->PutCString(s.GetString().c_str()); - } + log->Printf("About to write arg%d (0x%" PRIx64 ") into %s", + static_cast<int>(i + 1), args[i], reg_info->name); + if (!reg_ctx->WriteRegisterFromUnsigned(reg_info, args[i])) + return false; + } + + // Set "lr" to the return address + if (!reg_ctx->WriteRegisterFromUnsigned( + reg_ctx->GetRegisterInfo(eRegisterKindGeneric, + LLDB_REGNUM_GENERIC_RA), + return_addr)) + return false; + + // Set "sp" to the requested value + if (!reg_ctx->WriteRegisterFromUnsigned( + reg_ctx->GetRegisterInfo(eRegisterKindGeneric, + LLDB_REGNUM_GENERIC_SP), + sp)) + return false; + + // Set "pc" to the address requested + if (!reg_ctx->WriteRegisterFromUnsigned( + reg_ctx->GetRegisterInfo(eRegisterKindGeneric, + LLDB_REGNUM_GENERIC_PC), + func_addr)) + return false; + + return true; +} - // x0 - x7 contain first 8 simple args - if (args.size() > 8) - return false; +// TODO: We dont support fp/SIMD arguments in v0-v7 +bool ABISysV_arm64::GetArgumentValues(Thread &thread, ValueList &values) const { + uint32_t num_values = values.GetSize(); - for (size_t i = 0; i < args.size(); ++i) - { - const RegisterInfo *reg_info = reg_ctx->GetRegisterInfo(eRegisterKindGeneric, LLDB_REGNUM_GENERIC_ARG1 + i); - if (log) - log->Printf("About to write arg%d (0x%" PRIx64 ") into %s", - static_cast<int>(i + 1), args[i], reg_info->name); - if (!reg_ctx->WriteRegisterFromUnsigned(reg_info, args[i])) - return false; - } + ExecutionContext exe_ctx(thread.shared_from_this()); - // Set "lr" to the return address - if (!reg_ctx->WriteRegisterFromUnsigned (reg_ctx->GetRegisterInfo(eRegisterKindGeneric, LLDB_REGNUM_GENERIC_RA), return_addr)) - return false; + // Extract the register context so we can read arguments from registers - // Set "sp" to the requested value - if (!reg_ctx->WriteRegisterFromUnsigned (reg_ctx->GetRegisterInfo(eRegisterKindGeneric, LLDB_REGNUM_GENERIC_SP), sp)) - return false; + RegisterContext *reg_ctx = thread.GetRegisterContext().get(); - // Set "pc" to the address requested - if (!reg_ctx->WriteRegisterFromUnsigned (reg_ctx->GetRegisterInfo(eRegisterKindGeneric, LLDB_REGNUM_GENERIC_PC), func_addr)) - return false; + if (!reg_ctx) + return false; - return true; -} + addr_t sp = 0; + + for (uint32_t value_idx = 0; value_idx < num_values; ++value_idx) { + // We currently only support extracting values with Clang QualTypes. + // Do we care about others? + Value *value = values.GetValueAtIndex(value_idx); + + if (!value) + return false; -//TODO: We dont support fp/SIMD arguments in v0-v7 -bool -ABISysV_arm64::GetArgumentValues (Thread &thread, ValueList &values) const -{ - uint32_t num_values = values.GetSize(); - - ExecutionContext exe_ctx (thread.shared_from_this()); - - // Extract the register context so we can read arguments from registers - - RegisterContext *reg_ctx = thread.GetRegisterContext().get(); - - if (!reg_ctx) + CompilerType value_type = value->GetCompilerType(); + if (value_type) { + bool is_signed = false; + size_t bit_width = 0; + if (value_type.IsIntegerOrEnumerationType(is_signed)) { + bit_width = value_type.GetBitSize(&thread); + } else if (value_type.IsPointerOrReferenceType()) { + bit_width = value_type.GetBitSize(&thread); + } else { + // We only handle integer, pointer and reference types currently... return false; + } - addr_t sp = 0; + if (bit_width <= (exe_ctx.GetProcessRef().GetAddressByteSize() * 8)) { + if (value_idx < 8) { + // Arguments 1-8 are in x0-x7... + const RegisterInfo *reg_info = nullptr; + reg_info = reg_ctx->GetRegisterInfo( + eRegisterKindGeneric, LLDB_REGNUM_GENERIC_ARG1 + value_idx); - for (uint32_t value_idx = 0; value_idx < num_values; ++value_idx) - { - // We currently only support extracting values with Clang QualTypes. - // Do we care about others? - Value *value = values.GetValueAtIndex(value_idx); - - if (!value) - return false; - - CompilerType value_type = value->GetCompilerType(); - if (value_type) - { - bool is_signed = false; - size_t bit_width = 0; - if (value_type.IsIntegerOrEnumerationType (is_signed)) - { - bit_width = value_type.GetBitSize(&thread); - } - else if (value_type.IsPointerOrReferenceType ()) - { - bit_width = value_type.GetBitSize(&thread); - } - else - { - // We only handle integer, pointer and reference types currently... + if (reg_info) { + RegisterValue reg_value; + + if (reg_ctx->ReadRegister(reg_info, reg_value)) { + if (is_signed) + reg_value.SignExtend(bit_width); + if (!reg_value.GetScalarValue(value->GetScalar())) return false; + continue; } - - if (bit_width <= (exe_ctx.GetProcessRef().GetAddressByteSize() * 8)) - { - if (value_idx < 8) - { - // Arguments 1-8 are in x0-x7... - const RegisterInfo *reg_info = nullptr; - reg_info= reg_ctx->GetRegisterInfo (eRegisterKindGeneric, LLDB_REGNUM_GENERIC_ARG1 + value_idx); - - if (reg_info) - { - RegisterValue reg_value; - - if (reg_ctx->ReadRegister(reg_info, reg_value)) - { - if (is_signed) - reg_value.SignExtend(bit_width); - if (!reg_value.GetScalarValue(value->GetScalar())) - return false; - continue; - } - } - return false; - } - else - { - //TODO: Verify for stack layout for SysV - if (sp == 0) - { - // Read the stack pointer if we already haven't read it - sp = reg_ctx->GetSP(0); - if (sp == 0) - return false; - } + } + return false; + } else { + // TODO: Verify for stack layout for SysV + if (sp == 0) { + // Read the stack pointer if we already haven't read it + sp = reg_ctx->GetSP(0); + if (sp == 0) + return false; + } + + // Arguments 5 on up are on the stack + const uint32_t arg_byte_size = (bit_width + (8 - 1)) / 8; + Error error; + if (!exe_ctx.GetProcessRef().ReadScalarIntegerFromMemory( + sp, arg_byte_size, is_signed, value->GetScalar(), error)) + return false; - // Arguments 5 on up are on the stack - const uint32_t arg_byte_size = (bit_width + (8-1)) / 8; - Error error; - if (!exe_ctx.GetProcessRef().ReadScalarIntegerFromMemory(sp, arg_byte_size, is_signed, value->GetScalar(), error)) - return false; - - sp += arg_byte_size; - // Align up to the next 8 byte boundary if needed - if (sp % 8) - { - sp >>= 3; - sp += 1; - sp <<= 3; - } - } - } + sp += arg_byte_size; + // Align up to the next 8 byte boundary if needed + if (sp % 8) { + sp >>= 3; + sp += 1; + sp <<= 3; + } } + } } - return true; + } + return true; } -Error -ABISysV_arm64::SetReturnValueObject(lldb::StackFrameSP &frame_sp, lldb::ValueObjectSP &new_value_sp) -{ - Error error; - if (!new_value_sp) - { - error.SetErrorString("Empty value object for return value."); - return error; - } - - CompilerType return_value_type = new_value_sp->GetCompilerType(); - if (!return_value_type) - { - error.SetErrorString ("Null clang type for return value."); - return error; - } +Error ABISysV_arm64::SetReturnValueObject(lldb::StackFrameSP &frame_sp, + lldb::ValueObjectSP &new_value_sp) { + Error error; + if (!new_value_sp) { + error.SetErrorString("Empty value object for return value."); + return error; + } - Thread *thread = frame_sp->GetThread().get(); - - RegisterContext *reg_ctx = thread->GetRegisterContext().get(); - - if (reg_ctx) - { - DataExtractor data; - Error data_error; - const uint64_t byte_size = new_value_sp->GetData(data, data_error); - if (data_error.Fail()) - { - error.SetErrorStringWithFormat("Couldn't convert return value to raw data: %s", data_error.AsCString()); - return error; - } + CompilerType return_value_type = new_value_sp->GetCompilerType(); + if (!return_value_type) { + error.SetErrorString("Null clang type for return value."); + return error; + } - const uint32_t type_flags = return_value_type.GetTypeInfo(nullptr); - if (type_flags & eTypeIsScalar || - type_flags & eTypeIsPointer) - { - if (type_flags & eTypeIsInteger || - type_flags & eTypeIsPointer ) - { - // Extract the register context so we can read arguments from registers - lldb::offset_t offset = 0; - if (byte_size <= 16) - { - const RegisterInfo *x0_info = reg_ctx->GetRegisterInfo (eRegisterKindGeneric, LLDB_REGNUM_GENERIC_ARG1); - if (byte_size <= 8) - { - uint64_t raw_value = data.GetMaxU64(&offset, byte_size); - - if (!reg_ctx->WriteRegisterFromUnsigned (x0_info, raw_value)) - error.SetErrorString ("failed to write register x0"); - } - else - { - uint64_t raw_value = data.GetMaxU64(&offset, 8); - - if (reg_ctx->WriteRegisterFromUnsigned (x0_info, raw_value)) - { - const RegisterInfo *x1_info = reg_ctx->GetRegisterInfo (eRegisterKindGeneric, LLDB_REGNUM_GENERIC_ARG2); - raw_value = data.GetMaxU64(&offset, byte_size - offset); - - if (!reg_ctx->WriteRegisterFromUnsigned (x1_info, raw_value)) - error.SetErrorString ("failed to write register x1"); - } - } - } - else - { - error.SetErrorString("We don't support returning longer than 128 bit integer values at present."); - } + Thread *thread = frame_sp->GetThread().get(); + + RegisterContext *reg_ctx = thread->GetRegisterContext().get(); + + if (reg_ctx) { + DataExtractor data; + Error data_error; + const uint64_t byte_size = new_value_sp->GetData(data, data_error); + if (data_error.Fail()) { + error.SetErrorStringWithFormat( + "Couldn't convert return value to raw data: %s", + data_error.AsCString()); + return error; + } + + const uint32_t type_flags = return_value_type.GetTypeInfo(nullptr); + if (type_flags & eTypeIsScalar || type_flags & eTypeIsPointer) { + if (type_flags & eTypeIsInteger || type_flags & eTypeIsPointer) { + // Extract the register context so we can read arguments from registers + lldb::offset_t offset = 0; + if (byte_size <= 16) { + const RegisterInfo *x0_info = reg_ctx->GetRegisterInfo( + eRegisterKindGeneric, LLDB_REGNUM_GENERIC_ARG1); + if (byte_size <= 8) { + uint64_t raw_value = data.GetMaxU64(&offset, byte_size); + + if (!reg_ctx->WriteRegisterFromUnsigned(x0_info, raw_value)) + error.SetErrorString("failed to write register x0"); + } else { + uint64_t raw_value = data.GetMaxU64(&offset, 8); + + if (reg_ctx->WriteRegisterFromUnsigned(x0_info, raw_value)) { + const RegisterInfo *x1_info = reg_ctx->GetRegisterInfo( + eRegisterKindGeneric, LLDB_REGNUM_GENERIC_ARG2); + raw_value = data.GetMaxU64(&offset, byte_size - offset); + + if (!reg_ctx->WriteRegisterFromUnsigned(x1_info, raw_value)) + error.SetErrorString("failed to write register x1"); } - else if (type_flags & eTypeIsFloat) - { - if (type_flags & eTypeIsComplex) - { - // Don't handle complex yet. - error.SetErrorString ("returning complex float values are not supported"); - } - else - { - const RegisterInfo *v0_info = reg_ctx->GetRegisterInfoByName("v0", 0); - - if (v0_info) - { - if (byte_size <= 16) - { - if (byte_size <= RegisterValue::GetMaxByteSize()) - { - RegisterValue reg_value; - error = reg_value.SetValueFromData (v0_info, data, 0, true); - if (error.Success()) - { - if (!reg_ctx->WriteRegister (v0_info, reg_value)) - error.SetErrorString ("failed to write register v0"); - } - } - else - { - error.SetErrorStringWithFormat ("returning float values with a byte size of %" PRIu64 " are not supported", byte_size); - } - } - else - { - error.SetErrorString("returning float values longer than 128 bits are not supported"); - } - } - else - { - error.SetErrorString("v0 register is not available on this target"); - } + } + } else { + error.SetErrorString("We don't support returning longer than 128 bit " + "integer values at present."); + } + } else if (type_flags & eTypeIsFloat) { + if (type_flags & eTypeIsComplex) { + // Don't handle complex yet. + error.SetErrorString( + "returning complex float values are not supported"); + } else { + const RegisterInfo *v0_info = reg_ctx->GetRegisterInfoByName("v0", 0); + + if (v0_info) { + if (byte_size <= 16) { + if (byte_size <= RegisterValue::GetMaxByteSize()) { + RegisterValue reg_value; + error = reg_value.SetValueFromData(v0_info, data, 0, true); + if (error.Success()) { + if (!reg_ctx->WriteRegister(v0_info, reg_value)) + error.SetErrorString("failed to write register v0"); } + } else { + error.SetErrorStringWithFormat( + "returning float values with a byte size of %" PRIu64 + " are not supported", + byte_size); + } + } else { + error.SetErrorString("returning float values longer than 128 " + "bits are not supported"); } + } else { + error.SetErrorString("v0 register is not available on this target"); + } } - else if (type_flags & eTypeIsVector) - { - if (byte_size > 0) - { - const RegisterInfo *v0_info = reg_ctx->GetRegisterInfoByName("v0", 0); - - if (v0_info) - { - if (byte_size <= v0_info->byte_size) - { - RegisterValue reg_value; - error = reg_value.SetValueFromData (v0_info, data, 0, true); - if (error.Success()) - { - if (!reg_ctx->WriteRegister (v0_info, reg_value)) - error.SetErrorString ("failed to write register v0"); - } - } - } + } + } else if (type_flags & eTypeIsVector) { + if (byte_size > 0) { + const RegisterInfo *v0_info = reg_ctx->GetRegisterInfoByName("v0", 0); + + if (v0_info) { + if (byte_size <= v0_info->byte_size) { + RegisterValue reg_value; + error = reg_value.SetValueFromData(v0_info, data, 0, true); + if (error.Success()) { + if (!reg_ctx->WriteRegister(v0_info, reg_value)) + error.SetErrorString("failed to write register v0"); } + } } + } } - else - { - error.SetErrorString("no registers are available"); - } - - return error; + } else { + error.SetErrorString("no registers are available"); + } + + return error; } -bool -ABISysV_arm64::CreateFunctionEntryUnwindPlan (UnwindPlan &unwind_plan) -{ - unwind_plan.Clear(); - unwind_plan.SetRegisterKind (eRegisterKindDWARF); - - uint32_t lr_reg_num = arm64_dwarf::lr; - uint32_t sp_reg_num = arm64_dwarf::sp; - uint32_t pc_reg_num = arm64_dwarf::pc; - - UnwindPlan::RowSP row(new UnwindPlan::Row); - - // Our previous Call Frame Address is the stack pointer - row->GetCFAValue().SetIsRegisterPlusOffset (sp_reg_num, 0); - - // Our previous PC is in the LR - row->SetRegisterLocationToRegister(pc_reg_num, lr_reg_num, true); - - unwind_plan.AppendRow (row); - - // All other registers are the same. - - unwind_plan.SetSourceName ("arm64 at-func-entry default"); - unwind_plan.SetSourcedFromCompiler (eLazyBoolNo); - - return true; +bool ABISysV_arm64::CreateFunctionEntryUnwindPlan(UnwindPlan &unwind_plan) { + unwind_plan.Clear(); + unwind_plan.SetRegisterKind(eRegisterKindDWARF); + + uint32_t lr_reg_num = arm64_dwarf::lr; + uint32_t sp_reg_num = arm64_dwarf::sp; + uint32_t pc_reg_num = arm64_dwarf::pc; + + UnwindPlan::RowSP row(new UnwindPlan::Row); + + // Our previous Call Frame Address is the stack pointer + row->GetCFAValue().SetIsRegisterPlusOffset(sp_reg_num, 0); + + // Our previous PC is in the LR + row->SetRegisterLocationToRegister(pc_reg_num, lr_reg_num, true); + + unwind_plan.AppendRow(row); + + // All other registers are the same. + + unwind_plan.SetSourceName("arm64 at-func-entry default"); + unwind_plan.SetSourcedFromCompiler(eLazyBoolNo); + + return true; } -bool -ABISysV_arm64::CreateDefaultUnwindPlan (UnwindPlan &unwind_plan) -{ - unwind_plan.Clear(); - unwind_plan.SetRegisterKind (eRegisterKindDWARF); - - uint32_t fp_reg_num = arm64_dwarf::fp; - uint32_t pc_reg_num = arm64_dwarf::pc; - - UnwindPlan::RowSP row(new UnwindPlan::Row); - const int32_t ptr_size = 8; - - row->GetCFAValue().SetIsRegisterPlusOffset (fp_reg_num, 2 * ptr_size); - row->SetOffset (0); - - row->SetRegisterLocationToAtCFAPlusOffset(fp_reg_num, ptr_size * -2, true); - row->SetRegisterLocationToAtCFAPlusOffset(pc_reg_num, ptr_size * -1, true); - - unwind_plan.AppendRow (row); - unwind_plan.SetSourceName ("arm64 default unwind plan"); - unwind_plan.SetSourcedFromCompiler (eLazyBoolNo); - unwind_plan.SetUnwindPlanValidAtAllInstructions (eLazyBoolNo); - - return true; +bool ABISysV_arm64::CreateDefaultUnwindPlan(UnwindPlan &unwind_plan) { + unwind_plan.Clear(); + unwind_plan.SetRegisterKind(eRegisterKindDWARF); + + uint32_t fp_reg_num = arm64_dwarf::fp; + uint32_t pc_reg_num = arm64_dwarf::pc; + + UnwindPlan::RowSP row(new UnwindPlan::Row); + const int32_t ptr_size = 8; + + row->GetCFAValue().SetIsRegisterPlusOffset(fp_reg_num, 2 * ptr_size); + row->SetOffset(0); + + row->SetRegisterLocationToAtCFAPlusOffset(fp_reg_num, ptr_size * -2, true); + row->SetRegisterLocationToAtCFAPlusOffset(pc_reg_num, ptr_size * -1, true); + + unwind_plan.AppendRow(row); + unwind_plan.SetSourceName("arm64 default unwind plan"); + unwind_plan.SetSourcedFromCompiler(eLazyBoolNo); + unwind_plan.SetUnwindPlanValidAtAllInstructions(eLazyBoolNo); + + return true; } -// AAPCS64 (Procedure Call Standard for the ARM 64-bit Architecture) says -// registers x19 through x28 and sp are callee preserved. -// v8-v15 are non-volatile (and specifically only the lower 8 bytes of these regs), +// AAPCS64 (Procedure Call Standard for the ARM 64-bit Architecture) says +// registers x19 through x28 and sp are callee preserved. +// v8-v15 are non-volatile (and specifically only the lower 8 bytes of these +// regs), // the rest of the fp/SIMD registers are volatile. // We treat x29 as callee preserved also, else the unwinder won't try to // retrieve fp saves. -bool -ABISysV_arm64::RegisterIsVolatile (const RegisterInfo *reg_info) -{ - if (reg_info) - { - const char *name = reg_info->name; - - // Sometimes we'll be called with the "alternate" name for these registers; - // recognize them as non-volatile. - - if (name[0] == 'p' && name[1] == 'c') // pc - return false; - if (name[0] == 'f' && name[1] == 'p') // fp - return false; - if (name[0] == 's' && name[1] == 'p') // sp - return false; - if (name[0] == 'l' && name[1] == 'r') // lr - return false; - - if (name[0] == 'x') - { - // Volatile registers: x0-x18 - // Although documentation says only x19-28 + sp are callee saved - // We ll also have to treat x30 as non-volatile. - // Each dwarf frame has its own value of lr. - // Return false for the non-volatile gpr regs, true for everything else - switch (name[1]) - { - case '1': - switch (name[2]) - { - case '9': - return false; // x19 is non-volatile - default: - return true; - } - break; - case '2': - switch (name[2]) - { - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - return false; // x20 - 28 are non-volatile - case '9': - return false; // x29 aka fp treat as non-volatile - default: - return true; - } - case '3': // x30 (lr) and x31 (sp) treat as non-volatile - if (name[2] == '0' || name[2] == '1') - return false; - break; - default: - return true; // all volatile cases not handled above fall here. - } +bool ABISysV_arm64::RegisterIsVolatile(const RegisterInfo *reg_info) { + if (reg_info) { + const char *name = reg_info->name; + + // Sometimes we'll be called with the "alternate" name for these registers; + // recognize them as non-volatile. + + if (name[0] == 'p' && name[1] == 'c') // pc + return false; + if (name[0] == 'f' && name[1] == 'p') // fp + return false; + if (name[0] == 's' && name[1] == 'p') // sp + return false; + if (name[0] == 'l' && name[1] == 'r') // lr + return false; + + if (name[0] == 'x') { + // Volatile registers: x0-x18 + // Although documentation says only x19-28 + sp are callee saved + // We ll also have to treat x30 as non-volatile. + // Each dwarf frame has its own value of lr. + // Return false for the non-volatile gpr regs, true for everything else + switch (name[1]) { + case '1': + switch (name[2]) { + case '9': + return false; // x19 is non-volatile + default: + return true; } - else if (name[0] == 'v' || name[0] == 's' || name[0] == 'd') - { - // Volatile registers: v0-7, v16-v31 - // Return false for non-volatile fp/SIMD regs, true for everything else - switch (name[1]) - { - case '8': - case '9': - return false; // v8-v9 are non-volatile - case '1': - switch (name[2]) - { - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - return false; // v10-v15 are non-volatile - default: - return true; - } - default: - return true; - } + break; + case '2': + switch (name[2]) { + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + return false; // x20 - 28 are non-volatile + case '9': + return false; // x29 aka fp treat as non-volatile + default: + return true; + } + case '3': // x30 (lr) and x31 (sp) treat as non-volatile + if (name[2] == '0' || name[2] == '1') + return false; + break; + default: + return true; // all volatile cases not handled above fall here. + } + } else if (name[0] == 'v' || name[0] == 's' || name[0] == 'd') { + // Volatile registers: v0-7, v16-v31 + // Return false for non-volatile fp/SIMD regs, true for everything else + switch (name[1]) { + case '8': + case '9': + return false; // v8-v9 are non-volatile + case '1': + switch (name[2]) { + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + return false; // v10-v15 are non-volatile + default: + return true; } + default: + return true; + } } - return true; + } + return true; } -static bool -LoadValueFromConsecutiveGPRRegisters (ExecutionContext &exe_ctx, - RegisterContext *reg_ctx, - const CompilerType &value_type, - bool is_return_value, // false => parameter, true => return value - uint32_t &NGRN, // NGRN (see ABI documentation) - uint32_t &NSRN, // NSRN (see ABI documentation) - DataExtractor &data) -{ - const size_t byte_size = value_type.GetByteSize(nullptr); - - if (byte_size == 0) +static bool LoadValueFromConsecutiveGPRRegisters( + ExecutionContext &exe_ctx, RegisterContext *reg_ctx, + const CompilerType &value_type, + bool is_return_value, // false => parameter, true => return value + uint32_t &NGRN, // NGRN (see ABI documentation) + uint32_t &NSRN, // NSRN (see ABI documentation) + DataExtractor &data) { + const size_t byte_size = value_type.GetByteSize(nullptr); + + if (byte_size == 0) + return false; + + std::unique_ptr<DataBufferHeap> heap_data_ap( + new DataBufferHeap(byte_size, 0)); + const ByteOrder byte_order = exe_ctx.GetProcessRef().GetByteOrder(); + Error error; + + CompilerType base_type; + const uint32_t homogeneous_count = + value_type.IsHomogeneousAggregate(&base_type); + if (homogeneous_count > 0 && homogeneous_count <= 8) { + // Make sure we have enough registers + if (NSRN < 8 && (8 - NSRN) >= homogeneous_count) { + if (!base_type) return false; + const size_t base_byte_size = base_type.GetByteSize(nullptr); + uint32_t data_offset = 0; + + for (uint32_t i = 0; i < homogeneous_count; ++i) { + char v_name[8]; + ::snprintf(v_name, sizeof(v_name), "v%u", NSRN); + const RegisterInfo *reg_info = + reg_ctx->GetRegisterInfoByName(v_name, 0); + if (reg_info == nullptr) + return false; - std::unique_ptr<DataBufferHeap> heap_data_ap (new DataBufferHeap(byte_size, 0)); - const ByteOrder byte_order = exe_ctx.GetProcessRef().GetByteOrder(); - Error error; - - CompilerType base_type; - const uint32_t homogeneous_count = value_type.IsHomogeneousAggregate (&base_type); - if (homogeneous_count > 0 && homogeneous_count <= 8) - { - // Make sure we have enough registers - if (NSRN < 8 && (8-NSRN) >= homogeneous_count) - { - if (!base_type) - return false; - const size_t base_byte_size = base_type.GetByteSize(nullptr); - uint32_t data_offset = 0; + if (base_byte_size > reg_info->byte_size) + return false; - for (uint32_t i=0; i<homogeneous_count; ++i) - { - char v_name[8]; - ::snprintf (v_name, sizeof(v_name), "v%u", NSRN); - const RegisterInfo *reg_info = reg_ctx->GetRegisterInfoByName(v_name, 0); - if (reg_info == nullptr) - return false; - - if (base_byte_size > reg_info->byte_size) - return false; - - RegisterValue reg_value; - - if (!reg_ctx->ReadRegister(reg_info, reg_value)) - return false; - - // Make sure we have enough room in "heap_data_ap" - if ((data_offset + base_byte_size) <= heap_data_ap->GetByteSize()) - { - const size_t bytes_copied = reg_value.GetAsMemoryData (reg_info, - heap_data_ap->GetBytes()+data_offset, - base_byte_size, - byte_order, - error); - if (bytes_copied != base_byte_size) - return false; - data_offset += bytes_copied; - ++NSRN; - } - else - return false; - } - data.SetByteOrder(byte_order); - data.SetAddressByteSize(exe_ctx.GetProcessRef().GetAddressByteSize()); - data.SetData(DataBufferSP (heap_data_ap.release())); - return true; - } + RegisterValue reg_value; + + if (!reg_ctx->ReadRegister(reg_info, reg_value)) + return false; + + // Make sure we have enough room in "heap_data_ap" + if ((data_offset + base_byte_size) <= heap_data_ap->GetByteSize()) { + const size_t bytes_copied = reg_value.GetAsMemoryData( + reg_info, heap_data_ap->GetBytes() + data_offset, base_byte_size, + byte_order, error); + if (bytes_copied != base_byte_size) + return false; + data_offset += bytes_copied; + ++NSRN; + } else + return false; + } + data.SetByteOrder(byte_order); + data.SetAddressByteSize(exe_ctx.GetProcessRef().GetAddressByteSize()); + data.SetData(DataBufferSP(heap_data_ap.release())); + return true; } + } + + const size_t max_reg_byte_size = 16; + if (byte_size <= max_reg_byte_size) { + size_t bytes_left = byte_size; + uint32_t data_offset = 0; + while (data_offset < byte_size) { + if (NGRN >= 8) + return false; - const size_t max_reg_byte_size = 16; - if (byte_size <= max_reg_byte_size) - { - size_t bytes_left = byte_size; - uint32_t data_offset = 0; - while (data_offset < byte_size) - { - if (NGRN >= 8) - return false; + const RegisterInfo *reg_info = reg_ctx->GetRegisterInfo( + eRegisterKindGeneric, LLDB_REGNUM_GENERIC_ARG1 + NGRN); + if (reg_info == nullptr) + return false; - const RegisterInfo *reg_info = reg_ctx->GetRegisterInfo (eRegisterKindGeneric, LLDB_REGNUM_GENERIC_ARG1 + NGRN); - if (reg_info == nullptr) - return false; + RegisterValue reg_value; - RegisterValue reg_value; - - if (!reg_ctx->ReadRegister(reg_info, reg_value)) - return false; - - const size_t curr_byte_size = std::min<size_t>(8,bytes_left); - const size_t bytes_copied = reg_value.GetAsMemoryData (reg_info, heap_data_ap->GetBytes()+data_offset, curr_byte_size, byte_order, error); - if (bytes_copied == 0) - return false; - if (bytes_copied >= bytes_left) - break; - data_offset += bytes_copied; - bytes_left -= bytes_copied; - ++NGRN; - } + if (!reg_ctx->ReadRegister(reg_info, reg_value)) + return false; + + const size_t curr_byte_size = std::min<size_t>(8, bytes_left); + const size_t bytes_copied = reg_value.GetAsMemoryData( + reg_info, heap_data_ap->GetBytes() + data_offset, curr_byte_size, + byte_order, error); + if (bytes_copied == 0) + return false; + if (bytes_copied >= bytes_left) + break; + data_offset += bytes_copied; + bytes_left -= bytes_copied; + ++NGRN; } - else - { - const RegisterInfo *reg_info = nullptr; - if (is_return_value) - { - // We are assuming we are decoding this immediately after returning - // from a function call and that the address of the structure is in x8 - reg_info = reg_ctx->GetRegisterInfoByName("x8", 0); - } - else - { - // We are assuming we are stopped at the first instruction in a function - // and that the ABI is being respected so all parameters appear where they - // should be (functions with no external linkage can legally violate the ABI). - if (NGRN >= 8) - return false; - - reg_info = reg_ctx->GetRegisterInfo (eRegisterKindGeneric, LLDB_REGNUM_GENERIC_ARG1 + NGRN); - if (reg_info == nullptr) - return false; - ++NGRN; - } + } else { + const RegisterInfo *reg_info = nullptr; + if (is_return_value) { + // We are assuming we are decoding this immediately after returning + // from a function call and that the address of the structure is in x8 + reg_info = reg_ctx->GetRegisterInfoByName("x8", 0); + } else { + // We are assuming we are stopped at the first instruction in a function + // and that the ABI is being respected so all parameters appear where they + // should be (functions with no external linkage can legally violate the + // ABI). + if (NGRN >= 8) + return false; - if (reg_info == nullptr) - return false; + reg_info = reg_ctx->GetRegisterInfo(eRegisterKindGeneric, + LLDB_REGNUM_GENERIC_ARG1 + NGRN); + if (reg_info == nullptr) + return false; + ++NGRN; + } - const lldb::addr_t value_addr = reg_ctx->ReadRegisterAsUnsigned(reg_info, LLDB_INVALID_ADDRESS); + if (reg_info == nullptr) + return false; - if (value_addr == LLDB_INVALID_ADDRESS) - return false; + const lldb::addr_t value_addr = + reg_ctx->ReadRegisterAsUnsigned(reg_info, LLDB_INVALID_ADDRESS); - if (exe_ctx.GetProcessRef().ReadMemory (value_addr, - heap_data_ap->GetBytes(), - heap_data_ap->GetByteSize(), - error) != heap_data_ap->GetByteSize()) - { - return false; - } + if (value_addr == LLDB_INVALID_ADDRESS) + return false; + + if (exe_ctx.GetProcessRef().ReadMemory( + value_addr, heap_data_ap->GetBytes(), heap_data_ap->GetByteSize(), + error) != heap_data_ap->GetByteSize()) { + return false; } + } - data.SetByteOrder(byte_order); - data.SetAddressByteSize(exe_ctx.GetProcessRef().GetAddressByteSize()); - data.SetData(DataBufferSP (heap_data_ap.release())); - return true; + data.SetByteOrder(byte_order); + data.SetAddressByteSize(exe_ctx.GetProcessRef().GetAddressByteSize()); + data.SetData(DataBufferSP(heap_data_ap.release())); + return true; } -ValueObjectSP -ABISysV_arm64::GetReturnValueObjectImpl (Thread &thread, CompilerType &return_compiler_type) const -{ - ValueObjectSP return_valobj_sp; - Value value; - - ExecutionContext exe_ctx (thread.shared_from_this()); - if (exe_ctx.GetTargetPtr() == nullptr || exe_ctx.GetProcessPtr() == nullptr) - return return_valobj_sp; - - //value.SetContext (Value::eContextTypeClangType, return_compiler_type); - value.SetCompilerType(return_compiler_type); - - RegisterContext *reg_ctx = thread.GetRegisterContext().get(); - if (!reg_ctx) - return return_valobj_sp; - - const size_t byte_size = return_compiler_type.GetByteSize(nullptr); - - const uint32_t type_flags = return_compiler_type.GetTypeInfo(nullptr); - if (type_flags & eTypeIsScalar || - type_flags & eTypeIsPointer) - { - value.SetValueType(Value::eValueTypeScalar); - - bool success = false; - if (type_flags & eTypeIsInteger || - type_flags & eTypeIsPointer ) - { - // Extract the register context so we can read arguments from registers - if (byte_size <= 8) +ValueObjectSP ABISysV_arm64::GetReturnValueObjectImpl( + Thread &thread, CompilerType &return_compiler_type) const { + ValueObjectSP return_valobj_sp; + Value value; + + ExecutionContext exe_ctx(thread.shared_from_this()); + if (exe_ctx.GetTargetPtr() == nullptr || exe_ctx.GetProcessPtr() == nullptr) + return return_valobj_sp; + + // value.SetContext (Value::eContextTypeClangType, return_compiler_type); + value.SetCompilerType(return_compiler_type); + + RegisterContext *reg_ctx = thread.GetRegisterContext().get(); + if (!reg_ctx) + return return_valobj_sp; + + const size_t byte_size = return_compiler_type.GetByteSize(nullptr); + + const uint32_t type_flags = return_compiler_type.GetTypeInfo(nullptr); + if (type_flags & eTypeIsScalar || type_flags & eTypeIsPointer) { + value.SetValueType(Value::eValueTypeScalar); + + bool success = false; + if (type_flags & eTypeIsInteger || type_flags & eTypeIsPointer) { + // Extract the register context so we can read arguments from registers + if (byte_size <= 8) { + const RegisterInfo *x0_reg_info = nullptr; + x0_reg_info = reg_ctx->GetRegisterInfo(eRegisterKindGeneric, + LLDB_REGNUM_GENERIC_ARG1); + if (x0_reg_info) { + uint64_t raw_value = + thread.GetRegisterContext()->ReadRegisterAsUnsigned(x0_reg_info, + 0); + const bool is_signed = (type_flags & eTypeIsSigned) != 0; + switch (byte_size) { + default: + break; + case 16: // uint128_t + // In register x0 and x1 { - const RegisterInfo *x0_reg_info = nullptr; - x0_reg_info = reg_ctx->GetRegisterInfo (eRegisterKindGeneric, LLDB_REGNUM_GENERIC_ARG1); - if (x0_reg_info) - { - uint64_t raw_value = thread.GetRegisterContext()->ReadRegisterAsUnsigned(x0_reg_info, 0); - const bool is_signed = (type_flags & eTypeIsSigned) != 0; - switch (byte_size) - { - default: - break; - case 16: // uint128_t - // In register x0 and x1 - { - const RegisterInfo *x1_reg_info = nullptr; - x1_reg_info = reg_ctx->GetRegisterInfo (eRegisterKindGeneric, LLDB_REGNUM_GENERIC_ARG2); - - if (x1_reg_info) - { - if (byte_size <= x0_reg_info->byte_size + x1_reg_info->byte_size) - { - std::unique_ptr<DataBufferHeap> heap_data_ap (new DataBufferHeap(byte_size, 0)); - const ByteOrder byte_order = exe_ctx.GetProcessRef().GetByteOrder(); - RegisterValue x0_reg_value; - RegisterValue x1_reg_value; - if (reg_ctx->ReadRegister(x0_reg_info, x0_reg_value) && - reg_ctx->ReadRegister(x1_reg_info, x1_reg_value)) - { - Error error; - if (x0_reg_value.GetAsMemoryData (x0_reg_info, heap_data_ap->GetBytes()+0, 8, byte_order, error) && - x1_reg_value.GetAsMemoryData (x1_reg_info, heap_data_ap->GetBytes()+8, 8, byte_order, error)) - { - DataExtractor data (DataBufferSP (heap_data_ap.release()), - byte_order, - exe_ctx.GetProcessRef().GetAddressByteSize()); - - return_valobj_sp = ValueObjectConstResult::Create (&thread, - return_compiler_type, - ConstString(""), - data); - return return_valobj_sp; - } - } - } - } - } - break; - case sizeof(uint64_t): - if (is_signed) - value.GetScalar() = (int64_t)(raw_value); - else - value.GetScalar() = (uint64_t)(raw_value); - success = true; - break; - - case sizeof(uint32_t): - if (is_signed) - value.GetScalar() = (int32_t)(raw_value & UINT32_MAX); - else - value.GetScalar() = (uint32_t)(raw_value & UINT32_MAX); - success = true; - break; - - case sizeof(uint16_t): - if (is_signed) - value.GetScalar() = (int16_t)(raw_value & UINT16_MAX); - else - value.GetScalar() = (uint16_t)(raw_value & UINT16_MAX); - success = true; - break; - - case sizeof(uint8_t): - if (is_signed) - value.GetScalar() = (int8_t)(raw_value & UINT8_MAX); - else - value.GetScalar() = (uint8_t)(raw_value & UINT8_MAX); - success = true; - break; + const RegisterInfo *x1_reg_info = nullptr; + x1_reg_info = reg_ctx->GetRegisterInfo(eRegisterKindGeneric, + LLDB_REGNUM_GENERIC_ARG2); + + if (x1_reg_info) { + if (byte_size <= + x0_reg_info->byte_size + x1_reg_info->byte_size) { + std::unique_ptr<DataBufferHeap> heap_data_ap( + new DataBufferHeap(byte_size, 0)); + const ByteOrder byte_order = + exe_ctx.GetProcessRef().GetByteOrder(); + RegisterValue x0_reg_value; + RegisterValue x1_reg_value; + if (reg_ctx->ReadRegister(x0_reg_info, x0_reg_value) && + reg_ctx->ReadRegister(x1_reg_info, x1_reg_value)) { + Error error; + if (x0_reg_value.GetAsMemoryData( + x0_reg_info, heap_data_ap->GetBytes() + 0, 8, + byte_order, error) && + x1_reg_value.GetAsMemoryData( + x1_reg_info, heap_data_ap->GetBytes() + 8, 8, + byte_order, error)) { + DataExtractor data( + DataBufferSP(heap_data_ap.release()), byte_order, + exe_ctx.GetProcessRef().GetAddressByteSize()); + + return_valobj_sp = ValueObjectConstResult::Create( + &thread, return_compiler_type, ConstString(""), data); + return return_valobj_sp; } + } } + } } - } - else if (type_flags & eTypeIsFloat) - { - if (type_flags & eTypeIsComplex) - { - // Don't handle complex yet. - } + break; + case sizeof(uint64_t): + if (is_signed) + value.GetScalar() = (int64_t)(raw_value); else - { - if (byte_size <= sizeof(long double)) - { - const RegisterInfo *v0_reg_info = reg_ctx->GetRegisterInfoByName("v0", 0); - RegisterValue v0_value; - if (reg_ctx->ReadRegister (v0_reg_info, v0_value)) - { - DataExtractor data; - if (v0_value.GetData(data)) - { - lldb::offset_t offset = 0; - if (byte_size == sizeof(float)) - { - value.GetScalar() = data.GetFloat(&offset); - success = true; - } - else if (byte_size == sizeof(double)) - { - value.GetScalar() = data.GetDouble(&offset); - success = true; - } - else if (byte_size == sizeof(long double)) - { - value.GetScalar() = data.GetLongDouble(&offset); - success = true; - } - } - } - } + value.GetScalar() = (uint64_t)(raw_value); + success = true; + break; + + case sizeof(uint32_t): + if (is_signed) + value.GetScalar() = (int32_t)(raw_value & UINT32_MAX); + else + value.GetScalar() = (uint32_t)(raw_value & UINT32_MAX); + success = true; + break; + + case sizeof(uint16_t): + if (is_signed) + value.GetScalar() = (int16_t)(raw_value & UINT16_MAX); + else + value.GetScalar() = (uint16_t)(raw_value & UINT16_MAX); + success = true; + break; + + case sizeof(uint8_t): + if (is_signed) + value.GetScalar() = (int8_t)(raw_value & UINT8_MAX); + else + value.GetScalar() = (uint8_t)(raw_value & UINT8_MAX); + success = true; + break; + } + } + } + } else if (type_flags & eTypeIsFloat) { + if (type_flags & eTypeIsComplex) { + // Don't handle complex yet. + } else { + if (byte_size <= sizeof(long double)) { + const RegisterInfo *v0_reg_info = + reg_ctx->GetRegisterInfoByName("v0", 0); + RegisterValue v0_value; + if (reg_ctx->ReadRegister(v0_reg_info, v0_value)) { + DataExtractor data; + if (v0_value.GetData(data)) { + lldb::offset_t offset = 0; + if (byte_size == sizeof(float)) { + value.GetScalar() = data.GetFloat(&offset); + success = true; + } else if (byte_size == sizeof(double)) { + value.GetScalar() = data.GetDouble(&offset); + success = true; + } else if (byte_size == sizeof(long double)) { + value.GetScalar() = data.GetLongDouble(&offset); + success = true; + } } + } } - - if (success) - return_valobj_sp = ValueObjectConstResult::Create (thread.GetStackFrameAtIndex(0).get(), - value, - ConstString("")); + } } - else if (type_flags & eTypeIsVector) - { - if (byte_size > 0) - { - const RegisterInfo *v0_info = reg_ctx->GetRegisterInfoByName("v0", 0); - - if (v0_info) - { - if (byte_size <= v0_info->byte_size) - { - std::unique_ptr<DataBufferHeap> heap_data_ap (new DataBufferHeap(byte_size, 0)); - const ByteOrder byte_order = exe_ctx.GetProcessRef().GetByteOrder(); - RegisterValue reg_value; - if (reg_ctx->ReadRegister(v0_info, reg_value)) - { - Error error; - if (reg_value.GetAsMemoryData (v0_info, - heap_data_ap->GetBytes(), - heap_data_ap->GetByteSize(), - byte_order, - error)) - { - DataExtractor data (DataBufferSP (heap_data_ap.release()), - byte_order, - exe_ctx.GetProcessRef().GetAddressByteSize()); - return_valobj_sp = ValueObjectConstResult::Create (&thread, - return_compiler_type, - ConstString(""), - data); - } - } - } + + if (success) + return_valobj_sp = ValueObjectConstResult::Create( + thread.GetStackFrameAtIndex(0).get(), value, ConstString("")); + } else if (type_flags & eTypeIsVector) { + if (byte_size > 0) { + const RegisterInfo *v0_info = reg_ctx->GetRegisterInfoByName("v0", 0); + + if (v0_info) { + if (byte_size <= v0_info->byte_size) { + std::unique_ptr<DataBufferHeap> heap_data_ap( + new DataBufferHeap(byte_size, 0)); + const ByteOrder byte_order = exe_ctx.GetProcessRef().GetByteOrder(); + RegisterValue reg_value; + if (reg_ctx->ReadRegister(v0_info, reg_value)) { + Error error; + if (reg_value.GetAsMemoryData(v0_info, heap_data_ap->GetBytes(), + heap_data_ap->GetByteSize(), + byte_order, error)) { + DataExtractor data(DataBufferSP(heap_data_ap.release()), + byte_order, + exe_ctx.GetProcessRef().GetAddressByteSize()); + return_valobj_sp = ValueObjectConstResult::Create( + &thread, return_compiler_type, ConstString(""), data); } + } } + } } - else if (type_flags & eTypeIsStructUnion || - type_flags & eTypeIsClass) - { - DataExtractor data; - - uint32_t NGRN = 0; // Search ABI docs for NGRN - uint32_t NSRN = 0; // Search ABI docs for NSRN - const bool is_return_value = true; - if (LoadValueFromConsecutiveGPRRegisters (exe_ctx, reg_ctx, return_compiler_type, is_return_value, NGRN, NSRN, data)) - { - return_valobj_sp = ValueObjectConstResult::Create (&thread, - return_compiler_type, - ConstString(""), - data); - } + } else if (type_flags & eTypeIsStructUnion || type_flags & eTypeIsClass) { + DataExtractor data; + + uint32_t NGRN = 0; // Search ABI docs for NGRN + uint32_t NSRN = 0; // Search ABI docs for NSRN + const bool is_return_value = true; + if (LoadValueFromConsecutiveGPRRegisters( + exe_ctx, reg_ctx, return_compiler_type, is_return_value, NGRN, NSRN, + data)) { + return_valobj_sp = ValueObjectConstResult::Create( + &thread, return_compiler_type, ConstString(""), data); } - return return_valobj_sp; + } + return return_valobj_sp; } -void -ABISysV_arm64::Initialize() -{ - PluginManager::RegisterPlugin (GetPluginNameStatic(), - "SysV ABI for AArch64 targets", - CreateInstance); +void ABISysV_arm64::Initialize() { + PluginManager::RegisterPlugin(GetPluginNameStatic(), + "SysV ABI for AArch64 targets", CreateInstance); } -void -ABISysV_arm64::Terminate() -{ - PluginManager::UnregisterPlugin (CreateInstance); +void ABISysV_arm64::Terminate() { + PluginManager::UnregisterPlugin(CreateInstance); } -lldb_private::ConstString -ABISysV_arm64::GetPluginNameStatic() -{ - static ConstString g_name("SysV-arm64"); - return g_name; +lldb_private::ConstString ABISysV_arm64::GetPluginNameStatic() { + static ConstString g_name("SysV-arm64"); + return g_name; } //------------------------------------------------------------------ // PluginInterface protocol //------------------------------------------------------------------ -ConstString -ABISysV_arm64::GetPluginName() -{ - return GetPluginNameStatic(); -} +ConstString ABISysV_arm64::GetPluginName() { return GetPluginNameStatic(); } -uint32_t -ABISysV_arm64::GetPluginVersion() -{ - return 1; -} +uint32_t ABISysV_arm64::GetPluginVersion() { return 1; } diff --git a/source/Plugins/ABI/SysV-arm64/ABISysV_arm64.h b/source/Plugins/ABI/SysV-arm64/ABISysV_arm64.h index e36f87e744f4..68c300c0909d 100644 --- a/source/Plugins/ABI/SysV-arm64/ABISysV_arm64.h +++ b/source/Plugins/ABI/SysV-arm64/ABISysV_arm64.h @@ -14,111 +14,96 @@ // C++ Includes // Other libraries and framework includes // Project includes -#include "lldb/lldb-private.h" #include "lldb/Target/ABI.h" +#include "lldb/lldb-private.h" -class ABISysV_arm64 : public lldb_private::ABI -{ +class ABISysV_arm64 : public lldb_private::ABI { public: - ~ABISysV_arm64() override = default; - - size_t - GetRedZoneSize () const override; - - bool - PrepareTrivialCall (lldb_private::Thread &thread, - lldb::addr_t sp, - lldb::addr_t functionAddress, - lldb::addr_t returnAddress, - llvm::ArrayRef<lldb::addr_t> args) const override; - - bool - GetArgumentValues (lldb_private::Thread &thread, - lldb_private::ValueList &values) const override; - - lldb_private::Error - SetReturnValueObject(lldb::StackFrameSP &frame_sp, lldb::ValueObjectSP &new_value) override; - - bool - CreateFunctionEntryUnwindPlan (lldb_private::UnwindPlan &unwind_plan) override; - - bool - CreateDefaultUnwindPlan (lldb_private::UnwindPlan &unwind_plan) override; - - bool - RegisterIsVolatile (const lldb_private::RegisterInfo *reg_info) override; - - // The arm64 ABI requires that stack frames be 16 byte aligned. - // When there is a trap handler on the stack, e.g. _sigtramp in userland - // code, we've seen that the stack pointer is often not aligned properly - // before the handler is invoked. This means that lldb will stop the unwind - // early -- before the function which caused the trap. - // - // To work around this, we relax that alignment to be just word-size (8-bytes). - // Whitelisting the trap handlers for user space would be easy (_sigtramp) but - // in other environments there can be a large number of different functions - // involved in async traps. - bool - CallFrameAddressIsValid (lldb::addr_t cfa) override - { - // Make sure the stack call frame addresses are are 8 byte aligned - if (cfa & (8ull - 1ull)) - return false; // Not 8 byte aligned - if (cfa == 0) - return false; // Zero is not a valid stack address - return true; - } - - bool - CodeAddressIsValid (lldb::addr_t pc) override - { - if (pc & (4ull - 1ull)) - return false; // Not 4 byte aligned - - // Anything else if fair game.. - return true; - } - - const lldb_private::RegisterInfo * - GetRegisterInfoArray (uint32_t &count) override; - - //------------------------------------------------------------------ - // Static Functions - //------------------------------------------------------------------ - - static void - Initialize(); - - static void - Terminate(); - - static lldb::ABISP - CreateInstance (const lldb_private::ArchSpec &arch); - - static lldb_private::ConstString - GetPluginNameStatic(); - - //------------------------------------------------------------------ - // PluginInterface protocol - //------------------------------------------------------------------ - - lldb_private::ConstString - GetPluginName() override; - - uint32_t - GetPluginVersion() override; - + ~ABISysV_arm64() override = default; + + size_t GetRedZoneSize() const override; + + bool PrepareTrivialCall(lldb_private::Thread &thread, lldb::addr_t sp, + lldb::addr_t functionAddress, + lldb::addr_t returnAddress, + llvm::ArrayRef<lldb::addr_t> args) const override; + + bool GetArgumentValues(lldb_private::Thread &thread, + lldb_private::ValueList &values) const override; + + lldb_private::Error + SetReturnValueObject(lldb::StackFrameSP &frame_sp, + lldb::ValueObjectSP &new_value) override; + + bool + CreateFunctionEntryUnwindPlan(lldb_private::UnwindPlan &unwind_plan) override; + + bool CreateDefaultUnwindPlan(lldb_private::UnwindPlan &unwind_plan) override; + + bool RegisterIsVolatile(const lldb_private::RegisterInfo *reg_info) override; + + // The arm64 ABI requires that stack frames be 16 byte aligned. + // When there is a trap handler on the stack, e.g. _sigtramp in userland + // code, we've seen that the stack pointer is often not aligned properly + // before the handler is invoked. This means that lldb will stop the unwind + // early -- before the function which caused the trap. + // + // To work around this, we relax that alignment to be just word-size + // (8-bytes). + // Whitelisting the trap handlers for user space would be easy (_sigtramp) but + // in other environments there can be a large number of different functions + // involved in async traps. + bool CallFrameAddressIsValid(lldb::addr_t cfa) override { + // Make sure the stack call frame addresses are are 8 byte aligned + if (cfa & (8ull - 1ull)) + return false; // Not 8 byte aligned + if (cfa == 0) + return false; // Zero is not a valid stack address + return true; + } + + bool CodeAddressIsValid(lldb::addr_t pc) override { + if (pc & (4ull - 1ull)) + return false; // Not 4 byte aligned + + // Anything else if fair game.. + return true; + } + + const lldb_private::RegisterInfo * + GetRegisterInfoArray(uint32_t &count) override; + + bool GetPointerReturnRegister(const char *&name) override; + + //------------------------------------------------------------------ + // Static Functions + //------------------------------------------------------------------ + + static void Initialize(); + + static void Terminate(); + + static lldb::ABISP CreateInstance(const lldb_private::ArchSpec &arch); + + static lldb_private::ConstString GetPluginNameStatic(); + + //------------------------------------------------------------------ + // PluginInterface protocol + //------------------------------------------------------------------ + + lldb_private::ConstString GetPluginName() override; + + uint32_t GetPluginVersion() override; + protected: - lldb::ValueObjectSP - GetReturnValueObjectImpl(lldb_private::Thread &thread, - lldb_private::CompilerType &ast_type) const override; + lldb::ValueObjectSP + GetReturnValueObjectImpl(lldb_private::Thread &thread, + lldb_private::CompilerType &ast_type) const override; private: - ABISysV_arm64() : - lldb_private::ABI() - { - // Call CreateInstance instead. - } + ABISysV_arm64() : lldb_private::ABI() { + // Call CreateInstance instead. + } }; #endif // liblldb_ABISysV_arm64_h_ diff --git a/source/Plugins/ABI/SysV-hexagon/ABISysV_hexagon.cpp b/source/Plugins/ABI/SysV-hexagon/ABISysV_hexagon.cpp index 596f3dc1166a..649f19b0b831 100644 --- a/source/Plugins/ABI/SysV-hexagon/ABISysV_hexagon.cpp +++ b/source/Plugins/ABI/SysV-hexagon/ABISysV_hexagon.cpp @@ -25,190 +25,1023 @@ #include "lldb/Core/RegisterValue.h" #include "lldb/Core/Value.h" #include "lldb/Core/ValueObjectConstResult.h" -#include "lldb/Core/ValueObjectRegister.h" #include "lldb/Core/ValueObjectMemory.h" +#include "lldb/Core/ValueObjectRegister.h" #include "lldb/Symbol/UnwindPlan.h" -#include "lldb/Target/Target.h" #include "lldb/Target/Process.h" #include "lldb/Target/RegisterContext.h" #include "lldb/Target/StackFrame.h" +#include "lldb/Target/Target.h" #include "lldb/Target/Thread.h" using namespace lldb; using namespace lldb_private; -static RegisterInfo g_register_infos[] = -{ +static RegisterInfo g_register_infos[] = { // hexagon-core.xml - { "r00" , "", 4, 0, eEncodingUint, eFormatAddressInfo, { 0, 0, LLDB_INVALID_REGNUM, 0, 0 }, nullptr, nullptr }, - { "r01" , "", 4, 0, eEncodingUint, eFormatAddressInfo, { 1, 1, LLDB_INVALID_REGNUM, 1, 1 }, nullptr, nullptr }, - { "r02" , "", 4, 0, eEncodingUint, eFormatAddressInfo, { 2, 2, LLDB_INVALID_REGNUM, 2, 2 }, nullptr, nullptr }, - { "r03" , "", 4, 0, eEncodingUint, eFormatAddressInfo, { 3, 3, LLDB_INVALID_REGNUM, 3, 3 }, nullptr, nullptr }, - { "r04" , "", 4, 0, eEncodingUint, eFormatAddressInfo, { 4, 4, LLDB_INVALID_REGNUM, 4, 4 }, nullptr, nullptr }, - { "r05" , "", 4, 0, eEncodingUint, eFormatAddressInfo, { 5, 5, LLDB_INVALID_REGNUM, 5, 5 }, nullptr, nullptr }, - { "r06" , "", 4, 0, eEncodingUint, eFormatAddressInfo, { 6, 6, LLDB_INVALID_REGNUM, 6, 6 }, nullptr, nullptr }, - { "r07" , "", 4, 0, eEncodingUint, eFormatAddressInfo, { 7, 7, LLDB_INVALID_REGNUM, 7, 7 }, nullptr, nullptr }, - { "r08" , "", 4, 0, eEncodingUint, eFormatAddressInfo, { 8, 8, LLDB_INVALID_REGNUM, 8, 8 }, nullptr, nullptr }, - { "r09" , "", 4, 0, eEncodingUint, eFormatAddressInfo, { 9, 9, LLDB_INVALID_REGNUM, 9, 9 }, nullptr, nullptr }, - { "r10" , "", 4, 0, eEncodingUint, eFormatAddressInfo, { 10, 10, LLDB_INVALID_REGNUM, 10, 10 }, nullptr, nullptr }, - { "r11" , "", 4, 0, eEncodingUint, eFormatAddressInfo, { 11, 11, LLDB_INVALID_REGNUM, 11, 11 }, nullptr, nullptr }, - { "r12" , "", 4, 0, eEncodingUint, eFormatAddressInfo, { 12, 12, LLDB_INVALID_REGNUM, 12, 12 }, nullptr, nullptr }, - { "r13" , "", 4, 0, eEncodingUint, eFormatAddressInfo, { 13, 13, LLDB_INVALID_REGNUM, 13, 13 }, nullptr, nullptr }, - { "r14" , "", 4, 0, eEncodingUint, eFormatAddressInfo, { 14, 14, LLDB_INVALID_REGNUM, 14, 14 }, nullptr, nullptr }, - { "r15" , "", 4, 0, eEncodingUint, eFormatAddressInfo, { 15, 15, LLDB_INVALID_REGNUM, 15, 15 }, nullptr, nullptr }, - { "r16" , "", 4, 0, eEncodingUint, eFormatAddressInfo, { 16, 16, LLDB_INVALID_REGNUM, 16, 16 }, nullptr, nullptr }, - { "r17" , "", 4, 0, eEncodingUint, eFormatAddressInfo, { 17, 17, LLDB_INVALID_REGNUM, 17, 17 }, nullptr, nullptr }, - { "r18" , "", 4, 0, eEncodingUint, eFormatAddressInfo, { 18, 18, LLDB_INVALID_REGNUM, 18, 18 }, nullptr, nullptr }, - { "r19" , "", 4, 0, eEncodingUint, eFormatAddressInfo, { 19, 19, LLDB_INVALID_REGNUM, 19, 19 }, nullptr, nullptr }, - { "r20" , "", 4, 0, eEncodingUint, eFormatAddressInfo, { 20, 20, LLDB_INVALID_REGNUM, 20, 20 }, nullptr, nullptr }, - { "r21" , "", 4, 0, eEncodingUint, eFormatAddressInfo, { 21, 21, LLDB_INVALID_REGNUM, 21, 21 }, nullptr, nullptr }, - { "r22" , "", 4, 0, eEncodingUint, eFormatAddressInfo, { 22, 22, LLDB_INVALID_REGNUM, 22, 22 }, nullptr, nullptr }, - { "r23" , "", 4, 0, eEncodingUint, eFormatAddressInfo, { 23, 23, LLDB_INVALID_REGNUM, 23, 23 }, nullptr, nullptr }, - { "r24" , "", 4, 0, eEncodingUint, eFormatAddressInfo, { 24, 24, LLDB_INVALID_REGNUM, 24, 24 }, nullptr, nullptr }, - { "r25" , "", 4, 0, eEncodingUint, eFormatAddressInfo, { 25, 25, LLDB_INVALID_REGNUM, 25, 25 }, nullptr, nullptr }, - { "r26" , "", 4, 0, eEncodingUint, eFormatAddressInfo, { 26, 26, LLDB_INVALID_REGNUM, 26, 26 }, nullptr, nullptr }, - { "r27" , "", 4, 0, eEncodingUint, eFormatAddressInfo, { 27, 27, LLDB_INVALID_REGNUM, 27, 27 }, nullptr, nullptr }, - { "r28" , "", 4, 0, eEncodingUint, eFormatAddressInfo, { 28, 28, LLDB_INVALID_REGNUM, 28, 28 }, nullptr, nullptr }, - { "sp" ,"r29", 4, 0, eEncodingUint, eFormatAddressInfo, { 29, 29, LLDB_REGNUM_GENERIC_SP, 29, 29 }, nullptr, nullptr }, - { "fp" ,"r30", 4, 0, eEncodingUint, eFormatAddressInfo, { 30, 30, LLDB_REGNUM_GENERIC_FP, 30, 30 }, nullptr, nullptr }, - { "lr" ,"r31", 4, 0, eEncodingUint, eFormatAddressInfo, { 31, 31, LLDB_REGNUM_GENERIC_RA, 31, 31 }, nullptr, nullptr }, - { "sa0" , "", 4, 0, eEncodingUint, eFormatAddressInfo, { 32, 32, LLDB_INVALID_REGNUM, 32, 32 }, nullptr, nullptr }, - { "lc0" , "", 4, 0, eEncodingUint, eFormatAddressInfo, { 33, 33, LLDB_INVALID_REGNUM, 33, 33 }, nullptr, nullptr }, - { "sa1" , "", 4, 0, eEncodingUint, eFormatAddressInfo, { 34, 34, LLDB_INVALID_REGNUM, 34, 34 }, nullptr, nullptr }, - { "lc1" , "", 4, 0, eEncodingUint, eFormatAddressInfo, { 35, 35, LLDB_INVALID_REGNUM, 35, 35 }, nullptr, nullptr }, + {"r00", + "", + 4, + 0, + eEncodingUint, + eFormatAddressInfo, + {0, 0, LLDB_INVALID_REGNUM, 0, 0}, + nullptr, + nullptr, + nullptr, + 0}, + {"r01", + "", + 4, + 0, + eEncodingUint, + eFormatAddressInfo, + {1, 1, LLDB_INVALID_REGNUM, 1, 1}, + nullptr, + nullptr, + nullptr, + 0}, + {"r02", + "", + 4, + 0, + eEncodingUint, + eFormatAddressInfo, + {2, 2, LLDB_INVALID_REGNUM, 2, 2}, + nullptr, + nullptr, + nullptr, + 0}, + {"r03", + "", + 4, + 0, + eEncodingUint, + eFormatAddressInfo, + {3, 3, LLDB_INVALID_REGNUM, 3, 3}, + nullptr, + nullptr, + nullptr, + 0}, + {"r04", + "", + 4, + 0, + eEncodingUint, + eFormatAddressInfo, + {4, 4, LLDB_INVALID_REGNUM, 4, 4}, + nullptr, + nullptr, + nullptr, + 0}, + {"r05", + "", + 4, + 0, + eEncodingUint, + eFormatAddressInfo, + {5, 5, LLDB_INVALID_REGNUM, 5, 5}, + nullptr, + nullptr, + nullptr, + 0}, + {"r06", + "", + 4, + 0, + eEncodingUint, + eFormatAddressInfo, + {6, 6, LLDB_INVALID_REGNUM, 6, 6}, + nullptr, + nullptr, + nullptr, + 0}, + {"r07", + "", + 4, + 0, + eEncodingUint, + eFormatAddressInfo, + {7, 7, LLDB_INVALID_REGNUM, 7, 7}, + nullptr, + nullptr, + nullptr, + 0}, + {"r08", + "", + 4, + 0, + eEncodingUint, + eFormatAddressInfo, + {8, 8, LLDB_INVALID_REGNUM, 8, 8}, + nullptr, + nullptr, + nullptr, + 0}, + {"r09", + "", + 4, + 0, + eEncodingUint, + eFormatAddressInfo, + {9, 9, LLDB_INVALID_REGNUM, 9, 9}, + nullptr, + nullptr, + nullptr, + 0}, + {"r10", + "", + 4, + 0, + eEncodingUint, + eFormatAddressInfo, + {10, 10, LLDB_INVALID_REGNUM, 10, 10}, + nullptr, + nullptr, + nullptr, + 0}, + {"r11", + "", + 4, + 0, + eEncodingUint, + eFormatAddressInfo, + {11, 11, LLDB_INVALID_REGNUM, 11, 11}, + nullptr, + nullptr, + nullptr, + 0}, + {"r12", + "", + 4, + 0, + eEncodingUint, + eFormatAddressInfo, + {12, 12, LLDB_INVALID_REGNUM, 12, 12}, + nullptr, + nullptr, + nullptr, + 0}, + {"r13", + "", + 4, + 0, + eEncodingUint, + eFormatAddressInfo, + {13, 13, LLDB_INVALID_REGNUM, 13, 13}, + nullptr, + nullptr, + nullptr, + 0}, + {"r14", + "", + 4, + 0, + eEncodingUint, + eFormatAddressInfo, + {14, 14, LLDB_INVALID_REGNUM, 14, 14}, + nullptr, + nullptr, + nullptr, + 0}, + {"r15", + "", + 4, + 0, + eEncodingUint, + eFormatAddressInfo, + {15, 15, LLDB_INVALID_REGNUM, 15, 15}, + nullptr, + nullptr, + nullptr, + 0}, + {"r16", + "", + 4, + 0, + eEncodingUint, + eFormatAddressInfo, + {16, 16, LLDB_INVALID_REGNUM, 16, 16}, + nullptr, + nullptr, + nullptr, + 0}, + {"r17", + "", + 4, + 0, + eEncodingUint, + eFormatAddressInfo, + {17, 17, LLDB_INVALID_REGNUM, 17, 17}, + nullptr, + nullptr, + nullptr, + 0}, + {"r18", + "", + 4, + 0, + eEncodingUint, + eFormatAddressInfo, + {18, 18, LLDB_INVALID_REGNUM, 18, 18}, + nullptr, + nullptr, + nullptr, + 0}, + {"r19", + "", + 4, + 0, + eEncodingUint, + eFormatAddressInfo, + {19, 19, LLDB_INVALID_REGNUM, 19, 19}, + nullptr, + nullptr, + nullptr, + 0}, + {"r20", + "", + 4, + 0, + eEncodingUint, + eFormatAddressInfo, + {20, 20, LLDB_INVALID_REGNUM, 20, 20}, + nullptr, + nullptr, + nullptr, + 0}, + {"r21", + "", + 4, + 0, + eEncodingUint, + eFormatAddressInfo, + {21, 21, LLDB_INVALID_REGNUM, 21, 21}, + nullptr, + nullptr, + nullptr, + 0}, + {"r22", + "", + 4, + 0, + eEncodingUint, + eFormatAddressInfo, + {22, 22, LLDB_INVALID_REGNUM, 22, 22}, + nullptr, + nullptr, + nullptr, + 0}, + {"r23", + "", + 4, + 0, + eEncodingUint, + eFormatAddressInfo, + {23, 23, LLDB_INVALID_REGNUM, 23, 23}, + nullptr, + nullptr, + nullptr, + 0}, + {"r24", + "", + 4, + 0, + eEncodingUint, + eFormatAddressInfo, + {24, 24, LLDB_INVALID_REGNUM, 24, 24}, + nullptr, + nullptr, + nullptr, + 0}, + {"r25", + "", + 4, + 0, + eEncodingUint, + eFormatAddressInfo, + {25, 25, LLDB_INVALID_REGNUM, 25, 25}, + nullptr, + nullptr, + nullptr, + 0}, + {"r26", + "", + 4, + 0, + eEncodingUint, + eFormatAddressInfo, + {26, 26, LLDB_INVALID_REGNUM, 26, 26}, + nullptr, + nullptr, + nullptr, + 0}, + {"r27", + "", + 4, + 0, + eEncodingUint, + eFormatAddressInfo, + {27, 27, LLDB_INVALID_REGNUM, 27, 27}, + nullptr, + nullptr, + nullptr, + 0}, + {"r28", + "", + 4, + 0, + eEncodingUint, + eFormatAddressInfo, + {28, 28, LLDB_INVALID_REGNUM, 28, 28}, + nullptr, + nullptr, + nullptr, + 0}, + {"sp", + "r29", + 4, + 0, + eEncodingUint, + eFormatAddressInfo, + {29, 29, LLDB_REGNUM_GENERIC_SP, 29, 29}, + nullptr, + nullptr, + nullptr, + 0}, + {"fp", + "r30", + 4, + 0, + eEncodingUint, + eFormatAddressInfo, + {30, 30, LLDB_REGNUM_GENERIC_FP, 30, 30}, + nullptr, + nullptr, + nullptr, + 0}, + {"lr", + "r31", + 4, + 0, + eEncodingUint, + eFormatAddressInfo, + {31, 31, LLDB_REGNUM_GENERIC_RA, 31, 31}, + nullptr, + nullptr, + nullptr, + 0}, + {"sa0", + "", + 4, + 0, + eEncodingUint, + eFormatAddressInfo, + {32, 32, LLDB_INVALID_REGNUM, 32, 32}, + nullptr, + nullptr, + nullptr, + 0}, + {"lc0", + "", + 4, + 0, + eEncodingUint, + eFormatAddressInfo, + {33, 33, LLDB_INVALID_REGNUM, 33, 33}, + nullptr, + nullptr, + nullptr, + 0}, + {"sa1", + "", + 4, + 0, + eEncodingUint, + eFormatAddressInfo, + {34, 34, LLDB_INVALID_REGNUM, 34, 34}, + nullptr, + nullptr, + nullptr, + 0}, + {"lc1", + "", + 4, + 0, + eEncodingUint, + eFormatAddressInfo, + {35, 35, LLDB_INVALID_REGNUM, 35, 35}, + nullptr, + nullptr, + nullptr, + 0}, // --> hexagon-v4/5/55/56-sim.xml - { "p3_0" , "", 4, 0, eEncodingUint, eFormatAddressInfo, { 36, 36, LLDB_INVALID_REGNUM, 36, 36 }, nullptr, nullptr }, -// PADDING { - { "p00" , "", 4, 0, eEncodingInvalid, eFormatInvalid, { 37, 37, LLDB_INVALID_REGNUM, 37, 37 }, nullptr, nullptr }, -// } - { "m0" , "", 4, 0, eEncodingUint, eFormatAddressInfo, { 38, 38, LLDB_INVALID_REGNUM, 38, 38 }, nullptr, nullptr }, - { "m1" , "", 4, 0, eEncodingUint, eFormatAddressInfo, { 39, 39, LLDB_INVALID_REGNUM, 39, 39 }, nullptr, nullptr }, - { "usr" , "", 4, 0, eEncodingUint, eFormatAddressInfo, { 40, 40, LLDB_INVALID_REGNUM, 40, 40 }, nullptr, nullptr }, - { "pc" , "", 4, 0, eEncodingUint, eFormatAddressInfo, { 41, 41, LLDB_REGNUM_GENERIC_PC, 41, 41 }, nullptr, nullptr }, - { "ugp" , "", 4, 0, eEncodingUint, eFormatAddressInfo, { 42, 42, LLDB_INVALID_REGNUM, 42, 42 }, nullptr, nullptr }, - { "gp" , "", 4, 0, eEncodingUint, eFormatAddressInfo, { 43, 43, LLDB_INVALID_REGNUM, 43, 43 }, nullptr, nullptr }, - { "cs0" , "", 4, 0, eEncodingUint, eFormatAddressInfo, { 44, 44, LLDB_INVALID_REGNUM, 44, 44 }, nullptr, nullptr }, - { "cs1" , "", 4, 0, eEncodingUint, eFormatAddressInfo, { 45, 45, LLDB_INVALID_REGNUM, 45, 45 }, nullptr, nullptr }, -// PADDING { - { "p01" , "", 4, 0, eEncodingInvalid, eFormatInvalid, { 46, 46, LLDB_INVALID_REGNUM, 46, 46 }, nullptr, nullptr }, - { "p02" , "", 4, 0, eEncodingInvalid, eFormatInvalid, { 47, 47, LLDB_INVALID_REGNUM, 47, 47 }, nullptr, nullptr }, - { "p03" , "", 4, 0, eEncodingInvalid, eFormatInvalid, { 48, 48, LLDB_INVALID_REGNUM, 48, 48 }, nullptr, nullptr }, - { "p04" , "", 4, 0, eEncodingInvalid, eFormatInvalid, { 49, 49, LLDB_INVALID_REGNUM, 49, 49 }, nullptr, nullptr }, - { "p05" , "", 4, 0, eEncodingInvalid, eFormatInvalid, { 50, 50, LLDB_INVALID_REGNUM, 50, 50 }, nullptr, nullptr }, - { "p06" , "", 4, 0, eEncodingInvalid, eFormatInvalid, { 51, 51, LLDB_INVALID_REGNUM, 51, 51 }, nullptr, nullptr }, - { "p07" , "", 4, 0, eEncodingInvalid, eFormatInvalid, { 52, 52, LLDB_INVALID_REGNUM, 52, 52 }, nullptr, nullptr }, - { "p08" , "", 4, 0, eEncodingInvalid, eFormatInvalid, { 53, 53, LLDB_INVALID_REGNUM, 53, 53 }, nullptr, nullptr }, - { "p09" , "", 4, 0, eEncodingInvalid, eFormatInvalid, { 54, 54, LLDB_INVALID_REGNUM, 54, 54 }, nullptr, nullptr }, - { "p10" , "", 4, 0, eEncodingInvalid, eFormatInvalid, { 55, 55, LLDB_INVALID_REGNUM, 55, 55 }, nullptr, nullptr }, - { "p11" , "", 4, 0, eEncodingInvalid, eFormatInvalid, { 56, 56, LLDB_INVALID_REGNUM, 56, 56 }, nullptr, nullptr }, - { "p12" , "", 4, 0, eEncodingInvalid, eFormatInvalid, { 57, 57, LLDB_INVALID_REGNUM, 57, 57 }, nullptr, nullptr }, - { "p13" , "", 4, 0, eEncodingInvalid, eFormatInvalid, { 58, 58, LLDB_INVALID_REGNUM, 58, 58 }, nullptr, nullptr }, - { "p14" , "", 4, 0, eEncodingInvalid, eFormatInvalid, { 59, 59, LLDB_INVALID_REGNUM, 59, 59 }, nullptr, nullptr }, - { "p15" , "", 4, 0, eEncodingInvalid, eFormatInvalid, { 60, 60, LLDB_INVALID_REGNUM, 60, 60 }, nullptr, nullptr }, - { "p16" , "", 4, 0, eEncodingInvalid, eFormatInvalid, { 61, 61, LLDB_INVALID_REGNUM, 61, 61 }, nullptr, nullptr }, - { "p17" , "", 4, 0, eEncodingInvalid, eFormatInvalid, { 62, 62, LLDB_INVALID_REGNUM, 62, 62 }, nullptr, nullptr }, - { "p18" , "", 4, 0, eEncodingInvalid, eFormatInvalid, { 63, 63, LLDB_INVALID_REGNUM, 63, 63 }, nullptr, nullptr }, -// } - { "sgp0" , "", 4, 0, eEncodingUint, eFormatAddressInfo, { 64, 64, LLDB_INVALID_REGNUM, 64, 64 }, nullptr, nullptr }, -// PADDING { - { "p19" , "", 4, 0, eEncodingInvalid, eFormatInvalid, { 65, 65, LLDB_INVALID_REGNUM, 65, 65 }, nullptr, nullptr }, -// } - { "stid" , "", 4, 0, eEncodingUint, eFormatAddressInfo, { 66, 66, LLDB_INVALID_REGNUM, 66, 66 }, nullptr, nullptr }, - { "elr" , "", 4, 0, eEncodingUint, eFormatAddressInfo, { 67, 67, LLDB_INVALID_REGNUM, 67, 67 }, nullptr, nullptr }, - { "badva0", "", 4, 0, eEncodingUint, eFormatAddressInfo, { 68, 68, LLDB_INVALID_REGNUM, 68, 68 }, nullptr, nullptr }, - { "badva1", "", 4, 0, eEncodingUint, eFormatAddressInfo, { 69, 69, LLDB_INVALID_REGNUM, 69, 69 }, nullptr, nullptr }, - { "ssr" , "", 4, 0, eEncodingUint, eFormatAddressInfo, { 70, 70, LLDB_INVALID_REGNUM, 70, 70 }, nullptr, nullptr }, - { "ccr" , "", 4, 0, eEncodingUint, eFormatAddressInfo, { 71, 71, LLDB_INVALID_REGNUM, 71, 71 }, nullptr, nullptr }, - { "htid" , "", 4, 0, eEncodingUint, eFormatAddressInfo, { 72, 72, LLDB_INVALID_REGNUM, 72, 72 }, nullptr, nullptr }, -// PADDING { - { "p20" , "", 4, 0, eEncodingInvalid, eFormatInvalid, { 73, 73, LLDB_INVALID_REGNUM, 73, 73 }, nullptr, nullptr }, -// } - { "imask" , "", 4, 0, eEncodingUint, eFormatAddressInfo, { 74, 74, LLDB_INVALID_REGNUM, 74, 74 }, nullptr, nullptr }, -// PADDING { - { "p21" , "", 4, 0, eEncodingInvalid, eFormatInvalid, { 75, 75, LLDB_INVALID_REGNUM, 75, 75 }, nullptr, nullptr }, - { "p22" , "", 4, 0, eEncodingInvalid, eFormatInvalid, { 76, 76, LLDB_INVALID_REGNUM, 76, 76 }, nullptr, nullptr }, - { "p23" , "", 4, 0, eEncodingInvalid, eFormatInvalid, { 77, 77, LLDB_INVALID_REGNUM, 77, 77 }, nullptr, nullptr }, - { "p24" , "", 4, 0, eEncodingInvalid, eFormatInvalid, { 78, 78, LLDB_INVALID_REGNUM, 78, 78 }, nullptr, nullptr }, - { "p25" , "", 4, 0, eEncodingInvalid, eFormatInvalid, { 79, 79, LLDB_INVALID_REGNUM, 79, 79 }, nullptr, nullptr }, - // } - { "g0" , "", 4, 0, eEncodingUint, eFormatAddressInfo, { 80, 80, LLDB_INVALID_REGNUM, 80, 80 }, nullptr, nullptr }, - { "g1" , "", 4, 0, eEncodingUint, eFormatAddressInfo, { 81, 81, LLDB_INVALID_REGNUM, 81, 81 }, nullptr, nullptr }, - { "g2" , "", 4, 0, eEncodingUint, eFormatAddressInfo, { 82, 82, LLDB_INVALID_REGNUM, 82, 82 }, nullptr, nullptr }, - { "g3" , "", 4, 0, eEncodingUint, eFormatAddressInfo, { 83, 83, LLDB_INVALID_REGNUM, 83, 83 }, nullptr, nullptr } -}; - -static const uint32_t k_num_register_infos = sizeof(g_register_infos)/sizeof(RegisterInfo); + {"p3_0", + "", + 4, + 0, + eEncodingUint, + eFormatAddressInfo, + {36, 36, LLDB_INVALID_REGNUM, 36, 36}, + nullptr, + nullptr, + nullptr, + 0}, + // PADDING { + {"p00", + "", + 4, + 0, + eEncodingInvalid, + eFormatInvalid, + {37, 37, LLDB_INVALID_REGNUM, 37, 37}, + nullptr, + nullptr, + nullptr, + 0}, + // } + {"m0", + "", + 4, + 0, + eEncodingUint, + eFormatAddressInfo, + {38, 38, LLDB_INVALID_REGNUM, 38, 38}, + nullptr, + nullptr, + nullptr, + 0}, + {"m1", + "", + 4, + 0, + eEncodingUint, + eFormatAddressInfo, + {39, 39, LLDB_INVALID_REGNUM, 39, 39}, + nullptr, + nullptr, + nullptr, + 0}, + {"usr", + "", + 4, + 0, + eEncodingUint, + eFormatAddressInfo, + {40, 40, LLDB_INVALID_REGNUM, 40, 40}, + nullptr, + nullptr, + nullptr, + 0}, + {"pc", + "", + 4, + 0, + eEncodingUint, + eFormatAddressInfo, + {41, 41, LLDB_REGNUM_GENERIC_PC, 41, 41}, + nullptr, + nullptr, + nullptr, + 0}, + {"ugp", + "", + 4, + 0, + eEncodingUint, + eFormatAddressInfo, + {42, 42, LLDB_INVALID_REGNUM, 42, 42}, + nullptr, + nullptr, + nullptr, + 0}, + {"gp", + "", + 4, + 0, + eEncodingUint, + eFormatAddressInfo, + {43, 43, LLDB_INVALID_REGNUM, 43, 43}, + nullptr, + nullptr, + nullptr, + 0}, + {"cs0", + "", + 4, + 0, + eEncodingUint, + eFormatAddressInfo, + {44, 44, LLDB_INVALID_REGNUM, 44, 44}, + nullptr, + nullptr, + nullptr, + 0}, + {"cs1", + "", + 4, + 0, + eEncodingUint, + eFormatAddressInfo, + {45, 45, LLDB_INVALID_REGNUM, 45, 45}, + nullptr, + nullptr, + nullptr, + 0}, + // PADDING { + {"p01", + "", + 4, + 0, + eEncodingInvalid, + eFormatInvalid, + {46, 46, LLDB_INVALID_REGNUM, 46, 46}, + nullptr, + nullptr, + nullptr, + 0}, + {"p02", + "", + 4, + 0, + eEncodingInvalid, + eFormatInvalid, + {47, 47, LLDB_INVALID_REGNUM, 47, 47}, + nullptr, + nullptr, + nullptr, + 0}, + {"p03", + "", + 4, + 0, + eEncodingInvalid, + eFormatInvalid, + {48, 48, LLDB_INVALID_REGNUM, 48, 48}, + nullptr, + nullptr, + nullptr, + 0}, + {"p04", + "", + 4, + 0, + eEncodingInvalid, + eFormatInvalid, + {49, 49, LLDB_INVALID_REGNUM, 49, 49}, + nullptr, + nullptr, + nullptr, + 0}, + {"p05", + "", + 4, + 0, + eEncodingInvalid, + eFormatInvalid, + {50, 50, LLDB_INVALID_REGNUM, 50, 50}, + nullptr, + nullptr, + nullptr, + 0}, + {"p06", + "", + 4, + 0, + eEncodingInvalid, + eFormatInvalid, + {51, 51, LLDB_INVALID_REGNUM, 51, 51}, + nullptr, + nullptr, + nullptr, + 0}, + {"p07", + "", + 4, + 0, + eEncodingInvalid, + eFormatInvalid, + {52, 52, LLDB_INVALID_REGNUM, 52, 52}, + nullptr, + nullptr, + nullptr, + 0}, + {"p08", + "", + 4, + 0, + eEncodingInvalid, + eFormatInvalid, + {53, 53, LLDB_INVALID_REGNUM, 53, 53}, + nullptr, + nullptr, + nullptr, + 0}, + {"p09", + "", + 4, + 0, + eEncodingInvalid, + eFormatInvalid, + {54, 54, LLDB_INVALID_REGNUM, 54, 54}, + nullptr, + nullptr, + nullptr, + 0}, + {"p10", + "", + 4, + 0, + eEncodingInvalid, + eFormatInvalid, + {55, 55, LLDB_INVALID_REGNUM, 55, 55}, + nullptr, + nullptr, + nullptr, + 0}, + {"p11", + "", + 4, + 0, + eEncodingInvalid, + eFormatInvalid, + {56, 56, LLDB_INVALID_REGNUM, 56, 56}, + nullptr, + nullptr, + nullptr, + 0}, + {"p12", + "", + 4, + 0, + eEncodingInvalid, + eFormatInvalid, + {57, 57, LLDB_INVALID_REGNUM, 57, 57}, + nullptr, + nullptr, + nullptr, + 0}, + {"p13", + "", + 4, + 0, + eEncodingInvalid, + eFormatInvalid, + {58, 58, LLDB_INVALID_REGNUM, 58, 58}, + nullptr, + nullptr, + nullptr, + 0}, + {"p14", + "", + 4, + 0, + eEncodingInvalid, + eFormatInvalid, + {59, 59, LLDB_INVALID_REGNUM, 59, 59}, + nullptr, + nullptr, + nullptr, + 0}, + {"p15", + "", + 4, + 0, + eEncodingInvalid, + eFormatInvalid, + {60, 60, LLDB_INVALID_REGNUM, 60, 60}, + nullptr, + nullptr, + nullptr, + 0}, + {"p16", + "", + 4, + 0, + eEncodingInvalid, + eFormatInvalid, + {61, 61, LLDB_INVALID_REGNUM, 61, 61}, + nullptr, + nullptr, + nullptr, + 0}, + {"p17", + "", + 4, + 0, + eEncodingInvalid, + eFormatInvalid, + {62, 62, LLDB_INVALID_REGNUM, 62, 62}, + nullptr, + nullptr, + nullptr, + 0}, + {"p18", + "", + 4, + 0, + eEncodingInvalid, + eFormatInvalid, + {63, 63, LLDB_INVALID_REGNUM, 63, 63}, + nullptr, + nullptr, + nullptr, + 0}, + // } + {"sgp0", + "", + 4, + 0, + eEncodingUint, + eFormatAddressInfo, + {64, 64, LLDB_INVALID_REGNUM, 64, 64}, + nullptr, + nullptr, + nullptr, + 0}, + // PADDING { + {"p19", + "", + 4, + 0, + eEncodingInvalid, + eFormatInvalid, + {65, 65, LLDB_INVALID_REGNUM, 65, 65}, + nullptr, + nullptr, + nullptr, + 0}, + // } + {"stid", + "", + 4, + 0, + eEncodingUint, + eFormatAddressInfo, + {66, 66, LLDB_INVALID_REGNUM, 66, 66}, + nullptr, + nullptr, + nullptr, + 0}, + {"elr", + "", + 4, + 0, + eEncodingUint, + eFormatAddressInfo, + {67, 67, LLDB_INVALID_REGNUM, 67, 67}, + nullptr, + nullptr, + nullptr, + 0}, + {"badva0", + "", + 4, + 0, + eEncodingUint, + eFormatAddressInfo, + {68, 68, LLDB_INVALID_REGNUM, 68, 68}, + nullptr, + nullptr, + nullptr, + 0}, + {"badva1", + "", + 4, + 0, + eEncodingUint, + eFormatAddressInfo, + {69, 69, LLDB_INVALID_REGNUM, 69, 69}, + nullptr, + nullptr, + nullptr, + 0}, + {"ssr", + "", + 4, + 0, + eEncodingUint, + eFormatAddressInfo, + {70, 70, LLDB_INVALID_REGNUM, 70, 70}, + nullptr, + nullptr, + nullptr, + 0}, + {"ccr", + "", + 4, + 0, + eEncodingUint, + eFormatAddressInfo, + {71, 71, LLDB_INVALID_REGNUM, 71, 71}, + nullptr, + nullptr, + nullptr, + 0}, + {"htid", + "", + 4, + 0, + eEncodingUint, + eFormatAddressInfo, + {72, 72, LLDB_INVALID_REGNUM, 72, 72}, + nullptr, + nullptr, + nullptr, + 0}, + // PADDING { + {"p20", + "", + 4, + 0, + eEncodingInvalid, + eFormatInvalid, + {73, 73, LLDB_INVALID_REGNUM, 73, 73}, + nullptr, + nullptr, + nullptr, + 0}, + // } + {"imask", + "", + 4, + 0, + eEncodingUint, + eFormatAddressInfo, + {74, 74, LLDB_INVALID_REGNUM, 74, 74}, + nullptr, + nullptr, + nullptr, + 0}, + // PADDING { + {"p21", + "", + 4, + 0, + eEncodingInvalid, + eFormatInvalid, + {75, 75, LLDB_INVALID_REGNUM, 75, 75}, + nullptr, + nullptr, + nullptr, + 0}, + {"p22", + "", + 4, + 0, + eEncodingInvalid, + eFormatInvalid, + {76, 76, LLDB_INVALID_REGNUM, 76, 76}, + nullptr, + nullptr, + nullptr, + 0}, + {"p23", + "", + 4, + 0, + eEncodingInvalid, + eFormatInvalid, + {77, 77, LLDB_INVALID_REGNUM, 77, 77}, + nullptr, + nullptr, + nullptr, + 0}, + {"p24", + "", + 4, + 0, + eEncodingInvalid, + eFormatInvalid, + {78, 78, LLDB_INVALID_REGNUM, 78, 78}, + nullptr, + nullptr, + nullptr, + 0}, + {"p25", + "", + 4, + 0, + eEncodingInvalid, + eFormatInvalid, + {79, 79, LLDB_INVALID_REGNUM, 79, 79}, + nullptr, + nullptr, + nullptr, + 0}, + // } + {"g0", + "", + 4, + 0, + eEncodingUint, + eFormatAddressInfo, + {80, 80, LLDB_INVALID_REGNUM, 80, 80}, + nullptr, + nullptr, + nullptr, + 0}, + {"g1", + "", + 4, + 0, + eEncodingUint, + eFormatAddressInfo, + {81, 81, LLDB_INVALID_REGNUM, 81, 81}, + nullptr, + nullptr, + nullptr, + 0}, + {"g2", + "", + 4, + 0, + eEncodingUint, + eFormatAddressInfo, + {82, 82, LLDB_INVALID_REGNUM, 82, 82}, + nullptr, + nullptr, + nullptr, + 0}, + {"g3", + "", + 4, + 0, + eEncodingUint, + eFormatAddressInfo, + {83, 83, LLDB_INVALID_REGNUM, 83, 83}, + nullptr, + nullptr, + nullptr, + 0}}; + +static const uint32_t k_num_register_infos = + sizeof(g_register_infos) / sizeof(RegisterInfo); static bool g_register_info_names_constified = false; const lldb_private::RegisterInfo * -ABISysV_hexagon::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(); - } +ABISysV_hexagon::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; + } + count = k_num_register_infos; + return g_register_infos; } /* http://en.wikipedia.org/wiki/Red_zone_%28computing%29 - In computing, a red zone is a fixed size area in memory beyond the stack pointer that has not been - "allocated". This region of memory is not to be modified by interrupt/exception/signal handlers. - This allows the space to be used for temporary data without the extra overhead of modifying the - stack pointer. The x86-64 ABI mandates a 128 byte red zone.[1] The OpenRISC toolchain assumes a + In computing, a red zone is a fixed size area in memory beyond the stack + pointer that has not been + "allocated". This region of memory is not to be modified by + interrupt/exception/signal handlers. + This allows the space to be used for temporary data without the extra + overhead of modifying the + stack pointer. The x86-64 ABI mandates a 128 byte red zone.[1] The OpenRISC + toolchain assumes a 128 byte red zone though it is not documented. */ -size_t -ABISysV_hexagon::GetRedZoneSize () const -{ - return 0; -} +size_t ABISysV_hexagon::GetRedZoneSize() const { return 0; } //------------------------------------------------------------------ // Static Functions //------------------------------------------------------------------ ABISP -ABISysV_hexagon::CreateInstance ( const ArchSpec &arch ) -{ - static ABISP g_abi_sp; - if (arch.GetTriple().getArch() == llvm::Triple::hexagon) - { - if (!g_abi_sp) - g_abi_sp.reset (new ABISysV_hexagon); - return g_abi_sp; - } - return ABISP(); +ABISysV_hexagon::CreateInstance(const ArchSpec &arch) { + static ABISP g_abi_sp; + if (arch.GetTriple().getArch() == llvm::Triple::hexagon) { + if (!g_abi_sp) + g_abi_sp.reset(new ABISysV_hexagon); + return g_abi_sp; + } + return ABISP(); } -bool -ABISysV_hexagon::PrepareTrivialCall ( Thread &thread, - lldb::addr_t sp , - lldb::addr_t pc , - lldb::addr_t ra , - llvm::ArrayRef<addr_t> args ) const -{ - // we don't use the traditional trivial call specialized for jit - return false; +bool ABISysV_hexagon::PrepareTrivialCall(Thread &thread, lldb::addr_t sp, + lldb::addr_t pc, lldb::addr_t ra, + llvm::ArrayRef<addr_t> args) const { + // we don't use the traditional trivial call specialized for jit + return false; } /* // AD: // . safeguard the current stack -// . how can we know that the called function will create its own frame properly? +// . how can we know that the called function will create its own frame +properly? // . we could manually make a new stack first: // 2. push RA // 3. push FP @@ -216,11 +1049,15 @@ ABISysV_hexagon::PrepareTrivialCall ( Thread &thread, // 5. SP = SP ( since no locals in our temp frame ) // AD 6/05/2014 -// . variable argument list parameters are not passed via registers, they are passed on -// the stack. This presents us with a problem, since we need to know when the valist +// . variable argument list parameters are not passed via registers, they are +passed on +// the stack. This presents us with a problem, since we need to know when +the valist // starts. Currently I can find out if a function is varg, but not how many -// real parameters it takes. Thus I don't know when to start spilling the vargs. For -// the time being, to progress, I will assume that it takes on real parameter before +// real parameters it takes. Thus I don't know when to start spilling the +vargs. For +// the time being, to progress, I will assume that it takes on real parameter +before // the vargs list starts. // AD 06/05/2014 @@ -231,208 +1068,195 @@ ABISysV_hexagon::PrepareTrivialCall ( Thread &thread, */ #define HEX_ABI_DEBUG 0 -bool -ABISysV_hexagon::PrepareTrivialCall ( Thread &thread, - lldb::addr_t sp , - lldb::addr_t pc , - lldb::addr_t ra , - llvm::Type &prototype, - llvm::ArrayRef<ABI::CallArgument> args) const -{ - // default number of register passed arguments for varg functions - const int nVArgRegParams = 1; - Error error; - - // grab the process so we have access to the memory for spilling - lldb::ProcessSP proc = thread.GetProcess( ); - - // get the register context for modifying all of the registers - RegisterContext *reg_ctx = thread.GetRegisterContext().get(); - if (!reg_ctx) - return false; - - uint32_t pc_reg = reg_ctx->ConvertRegisterKindToRegisterNumber(eRegisterKindGeneric, LLDB_REGNUM_GENERIC_PC); - if (pc_reg == LLDB_INVALID_REGNUM) - return false; - - uint32_t ra_reg = reg_ctx->ConvertRegisterKindToRegisterNumber(eRegisterKindGeneric, LLDB_REGNUM_GENERIC_RA); - if (ra_reg == LLDB_INVALID_REGNUM) - return false; - - uint32_t sp_reg = reg_ctx->ConvertRegisterKindToRegisterNumber(eRegisterKindGeneric, LLDB_REGNUM_GENERIC_SP); - if (sp_reg == LLDB_INVALID_REGNUM) - return false; - - // push host data onto target - for ( size_t i = 0; i < args.size( ); i++ ) - { - const ABI::CallArgument &arg = args[i]; - // skip over target values - if ( arg.type == ABI::CallArgument::TargetValue ) - continue; - // round up to 8 byte multiple - size_t argSize = ( arg.size | 0x7 ) + 1; - - // create space on the stack for this data - sp -= argSize; - - // write this argument onto the stack of the host process - proc->WriteMemory( sp, arg.data_ap.get(), arg.size, error ); - if ( error.Fail( ) ) - return false; - - // update the argument with the target pointer - //XXX: This is a gross hack for getting around the const - *const_cast<lldb::addr_t*>(&arg.value) = sp; - } +bool ABISysV_hexagon::PrepareTrivialCall( + Thread &thread, lldb::addr_t sp, lldb::addr_t pc, lldb::addr_t ra, + llvm::Type &prototype, llvm::ArrayRef<ABI::CallArgument> args) const { + // default number of register passed arguments for varg functions + const int nVArgRegParams = 1; + Error error; + + // grab the process so we have access to the memory for spilling + lldb::ProcessSP proc = thread.GetProcess(); + + // get the register context for modifying all of the registers + RegisterContext *reg_ctx = thread.GetRegisterContext().get(); + if (!reg_ctx) + return false; -#if HEX_ABI_DEBUG - // print the original stack pointer - printf( "sp : %04" PRIx64 " \n", sp ); -#endif + uint32_t pc_reg = reg_ctx->ConvertRegisterKindToRegisterNumber( + eRegisterKindGeneric, LLDB_REGNUM_GENERIC_PC); + if (pc_reg == LLDB_INVALID_REGNUM) + return false; - // make sure number of parameters matches prototype - assert( prototype.getFunctionNumParams( ) == args.size( ) ); + uint32_t ra_reg = reg_ctx->ConvertRegisterKindToRegisterNumber( + eRegisterKindGeneric, LLDB_REGNUM_GENERIC_RA); + if (ra_reg == LLDB_INVALID_REGNUM) + return false; - // check if this is a variable argument function - bool isVArg = prototype.isFunctionVarArg(); + uint32_t sp_reg = reg_ctx->ConvertRegisterKindToRegisterNumber( + eRegisterKindGeneric, LLDB_REGNUM_GENERIC_SP); + if (sp_reg == LLDB_INVALID_REGNUM) + return false; - // number of arguments passed by register - int nRegArgs = nVArgRegParams; - if (! isVArg ) - { - // number of arguments is limited by [R0 : R5] space - nRegArgs = args.size( ); - if ( nRegArgs > 6 ) - nRegArgs = 6; - } + // push host data onto target + for (size_t i = 0; i < args.size(); i++) { + const ABI::CallArgument &arg = args[i]; + // skip over target values + if (arg.type == ABI::CallArgument::TargetValue) + continue; + // round up to 8 byte multiple + size_t argSize = (arg.size | 0x7) + 1; - // pass arguments that are passed via registers - for ( int i = 0; i < nRegArgs; i++ ) - { - // get the parameter as a u32 - uint32_t param = (uint32_t)args[i].value; - // write argument into register - if (!reg_ctx->WriteRegisterFromUnsigned( i, param )) - return false; - } + // create space on the stack for this data + sp -= argSize; - // number of arguments to spill onto stack - int nSpillArgs = args.size( ) - nRegArgs; - // make space on the stack for arguments - sp -= 4 * nSpillArgs; - // align stack on an 8 byte boundary - if ( sp & 7 ) - sp -= 4; - - // arguments that are passed on the stack - for ( size_t i = nRegArgs, offs=0; i < args.size( ); i++ ) - { - // get the parameter as a u32 - uint32_t param = (uint32_t)args[i].value; - // write argument to stack - proc->WriteMemory( sp + offs, (void*)¶m, sizeof( param ), error ); - if ( !error.Success( ) ) - return false; - // - offs += 4; - } + // write this argument onto the stack of the host process + proc->WriteMemory(sp, arg.data_ap.get(), arg.size, error); + if (error.Fail()) + return false; - // update registers with current function call state - reg_ctx->WriteRegisterFromUnsigned(pc_reg, pc); - reg_ctx->WriteRegisterFromUnsigned(ra_reg, ra); - reg_ctx->WriteRegisterFromUnsigned(sp_reg, sp); + // update the argument with the target pointer + // XXX: This is a gross hack for getting around the const + *const_cast<lldb::addr_t *>(&arg.value) = sp; + } #if HEX_ABI_DEBUG - // quick and dirty stack dumper for debugging - for ( int i = -8; i < 8; i++ ) - { - uint32_t data = 0; - lldb::addr_t addr = sp + i * 4; - proc->ReadMemory( addr, (void*)&data, sizeof( data ), error ); - printf( "\n0x%04" PRIx64 " 0x%08x ", addr, data ); - if ( i == 0 ) printf( "<<-- sp" ); - } - printf( "\n" ); -#endif - - return true; + // print the original stack pointer + printf("sp : %04" PRIx64 " \n", sp); +#endif + + // make sure number of parameters matches prototype + assert(prototype.getFunctionNumParams() == args.size()); + + // check if this is a variable argument function + bool isVArg = prototype.isFunctionVarArg(); + + // number of arguments passed by register + int nRegArgs = nVArgRegParams; + if (!isVArg) { + // number of arguments is limited by [R0 : R5] space + nRegArgs = args.size(); + if (nRegArgs > 6) + nRegArgs = 6; + } + + // pass arguments that are passed via registers + for (int i = 0; i < nRegArgs; i++) { + // get the parameter as a u32 + uint32_t param = (uint32_t)args[i].value; + // write argument into register + if (!reg_ctx->WriteRegisterFromUnsigned(i, param)) + return false; + } + + // number of arguments to spill onto stack + int nSpillArgs = args.size() - nRegArgs; + // make space on the stack for arguments + sp -= 4 * nSpillArgs; + // align stack on an 8 byte boundary + if (sp & 7) + sp -= 4; + + // arguments that are passed on the stack + for (size_t i = nRegArgs, offs = 0; i < args.size(); i++) { + // get the parameter as a u32 + uint32_t param = (uint32_t)args[i].value; + // write argument to stack + proc->WriteMemory(sp + offs, (void *)¶m, sizeof(param), error); + if (!error.Success()) + return false; + // + offs += 4; + } + + // update registers with current function call state + reg_ctx->WriteRegisterFromUnsigned(pc_reg, pc); + reg_ctx->WriteRegisterFromUnsigned(ra_reg, ra); + reg_ctx->WriteRegisterFromUnsigned(sp_reg, sp); + +#if HEX_ABI_DEBUG + // quick and dirty stack dumper for debugging + for (int i = -8; i < 8; i++) { + uint32_t data = 0; + lldb::addr_t addr = sp + i * 4; + proc->ReadMemory(addr, (void *)&data, sizeof(data), error); + printf("\n0x%04" PRIx64 " 0x%08x ", addr, data); + if (i == 0) + printf("<<-- sp"); + } + printf("\n"); +#endif + + return true; } -bool -ABISysV_hexagon::GetArgumentValues ( Thread &thread, ValueList &values ) const -{ - return false; +bool ABISysV_hexagon::GetArgumentValues(Thread &thread, + ValueList &values) const { + return false; } -Error -ABISysV_hexagon::SetReturnValueObject ( lldb::StackFrameSP &frame_sp, lldb::ValueObjectSP &new_value_sp ) -{ - Error error; - return error; +Error ABISysV_hexagon::SetReturnValueObject(lldb::StackFrameSP &frame_sp, + lldb::ValueObjectSP &new_value_sp) { + Error error; + return error; } -ValueObjectSP -ABISysV_hexagon::GetReturnValueObjectSimple ( Thread &thread, CompilerType &return_compiler_type ) const -{ - ValueObjectSP return_valobj_sp; - return return_valobj_sp; +ValueObjectSP ABISysV_hexagon::GetReturnValueObjectSimple( + Thread &thread, CompilerType &return_compiler_type) const { + ValueObjectSP return_valobj_sp; + return return_valobj_sp; } -ValueObjectSP -ABISysV_hexagon::GetReturnValueObjectImpl ( Thread &thread, CompilerType &return_compiler_type ) const -{ - ValueObjectSP return_valobj_sp; - return return_valobj_sp; +ValueObjectSP ABISysV_hexagon::GetReturnValueObjectImpl( + Thread &thread, CompilerType &return_compiler_type) const { + ValueObjectSP return_valobj_sp; + return return_valobj_sp; } // called when we are on the first instruction of a new function // for hexagon the return address is in RA (R31) -bool -ABISysV_hexagon::CreateFunctionEntryUnwindPlan ( UnwindPlan &unwind_plan ) -{ - unwind_plan.Clear(); - unwind_plan.SetRegisterKind(eRegisterKindGeneric); - unwind_plan.SetReturnAddressRegister(LLDB_REGNUM_GENERIC_RA); - - UnwindPlan::RowSP row(new UnwindPlan::Row); - - // Our Call Frame Address is the stack pointer value - row->GetCFAValue().SetIsRegisterPlusOffset (LLDB_REGNUM_GENERIC_SP, 4); - row->SetOffset(0); - - // The previous PC is in the LR - row->SetRegisterLocationToRegister(LLDB_REGNUM_GENERIC_PC, LLDB_REGNUM_GENERIC_RA, true); - unwind_plan.AppendRow(row); - - unwind_plan.SetSourceName("hexagon at-func-entry default"); - unwind_plan.SetSourcedFromCompiler(eLazyBoolNo); - return true; +bool ABISysV_hexagon::CreateFunctionEntryUnwindPlan(UnwindPlan &unwind_plan) { + unwind_plan.Clear(); + unwind_plan.SetRegisterKind(eRegisterKindGeneric); + unwind_plan.SetReturnAddressRegister(LLDB_REGNUM_GENERIC_RA); + + UnwindPlan::RowSP row(new UnwindPlan::Row); + + // Our Call Frame Address is the stack pointer value + row->GetCFAValue().SetIsRegisterPlusOffset(LLDB_REGNUM_GENERIC_SP, 4); + row->SetOffset(0); + + // The previous PC is in the LR + row->SetRegisterLocationToRegister(LLDB_REGNUM_GENERIC_PC, + LLDB_REGNUM_GENERIC_RA, true); + unwind_plan.AppendRow(row); + + unwind_plan.SetSourceName("hexagon at-func-entry default"); + unwind_plan.SetSourcedFromCompiler(eLazyBoolNo); + return true; } -bool -ABISysV_hexagon::CreateDefaultUnwindPlan ( UnwindPlan &unwind_plan ) -{ - unwind_plan.Clear(); - unwind_plan.SetRegisterKind(eRegisterKindGeneric); +bool ABISysV_hexagon::CreateDefaultUnwindPlan(UnwindPlan &unwind_plan) { + unwind_plan.Clear(); + unwind_plan.SetRegisterKind(eRegisterKindGeneric); - uint32_t fp_reg_num = LLDB_REGNUM_GENERIC_FP; - uint32_t sp_reg_num = LLDB_REGNUM_GENERIC_SP; - uint32_t pc_reg_num = LLDB_REGNUM_GENERIC_PC; + uint32_t fp_reg_num = LLDB_REGNUM_GENERIC_FP; + uint32_t sp_reg_num = LLDB_REGNUM_GENERIC_SP; + uint32_t pc_reg_num = LLDB_REGNUM_GENERIC_PC; - UnwindPlan::RowSP row(new UnwindPlan::Row); + UnwindPlan::RowSP row(new UnwindPlan::Row); - row->GetCFAValue().SetIsRegisterPlusOffset (LLDB_REGNUM_GENERIC_FP, 8); + row->GetCFAValue().SetIsRegisterPlusOffset(LLDB_REGNUM_GENERIC_FP, 8); - row->SetRegisterLocationToAtCFAPlusOffset(fp_reg_num,-8, true); - row->SetRegisterLocationToAtCFAPlusOffset(pc_reg_num,-4, true); - row->SetRegisterLocationToIsCFAPlusOffset(sp_reg_num, 0, true); + row->SetRegisterLocationToAtCFAPlusOffset(fp_reg_num, -8, true); + row->SetRegisterLocationToAtCFAPlusOffset(pc_reg_num, -4, true); + row->SetRegisterLocationToIsCFAPlusOffset(sp_reg_num, 0, true); - unwind_plan.AppendRow(row); - unwind_plan.SetSourceName("hexagon default unwind plan"); - unwind_plan.SetSourcedFromCompiler(eLazyBoolNo); - unwind_plan.SetUnwindPlanValidAtAllInstructions(eLazyBoolNo); - return true; + unwind_plan.AppendRow(row); + unwind_plan.SetSourceName("hexagon default unwind plan"); + unwind_plan.SetSourcedFromCompiler(eLazyBoolNo); + unwind_plan.SetUnwindPlanValidAtAllInstructions(eLazyBoolNo); + return true; } /* @@ -449,118 +1273,92 @@ ABISysV_hexagon::CreateDefaultUnwindPlan ( UnwindPlan &unwind_plan ) b = R14 - R15 and R28 are used by the procedure linkage table c = R29 - R31 are saved and restored by allocframe() and deallocframe() */ -bool -ABISysV_hexagon::RegisterIsVolatile ( const RegisterInfo *reg_info ) -{ - return !RegisterIsCalleeSaved( reg_info ); +bool ABISysV_hexagon::RegisterIsVolatile(const RegisterInfo *reg_info) { + return !RegisterIsCalleeSaved(reg_info); } -bool -ABISysV_hexagon::RegisterIsCalleeSaved ( const RegisterInfo *reg_info ) -{ - int reg = ((reg_info->byte_offset) / 4); +bool ABISysV_hexagon::RegisterIsCalleeSaved(const RegisterInfo *reg_info) { + int reg = ((reg_info->byte_offset) / 4); - bool save = (reg >= 16) && (reg <= 27); - save |= (reg >= 29) && (reg <= 32); + bool save = (reg >= 16) && (reg <= 27); + save |= (reg >= 29) && (reg <= 32); - return save; + return save; } -void -ABISysV_hexagon::Initialize() -{ - PluginManager::RegisterPlugin - ( - GetPluginNameStatic(), - "System V ABI for hexagon targets", - CreateInstance - ); +void ABISysV_hexagon::Initialize() { + PluginManager::RegisterPlugin(GetPluginNameStatic(), + "System V ABI for hexagon targets", + CreateInstance); } -void -ABISysV_hexagon::Terminate() -{ - PluginManager::UnregisterPlugin( CreateInstance ); +void ABISysV_hexagon::Terminate() { + PluginManager::UnregisterPlugin(CreateInstance); } -lldb_private::ConstString -ABISysV_hexagon::GetPluginNameStatic() -{ - static ConstString g_name( "sysv-hexagon" ); - return g_name; +lldb_private::ConstString ABISysV_hexagon::GetPluginNameStatic() { + static ConstString g_name("sysv-hexagon"); + return g_name; } //------------------------------------------------------------------ // PluginInterface protocol //------------------------------------------------------------------ -lldb_private::ConstString -ABISysV_hexagon::GetPluginName() -{ - return GetPluginNameStatic(); +lldb_private::ConstString ABISysV_hexagon::GetPluginName() { + return GetPluginNameStatic(); } -uint32_t -ABISysV_hexagon::GetPluginVersion() -{ - return 1; -} +uint32_t ABISysV_hexagon::GetPluginVersion() { return 1; } // get value object specialized to work with llvm IR types lldb::ValueObjectSP -ABISysV_hexagon::GetReturnValueObjectImpl( lldb_private::Thread &thread, llvm::Type &retType ) const -{ - Value value; - ValueObjectSP vObjSP; - - // get the current register context - RegisterContext *reg_ctx = thread.GetRegisterContext().get(); - if (!reg_ctx) - return vObjSP; - - // for now just pop R0 to find the return value - const lldb_private::RegisterInfo *r0_info = reg_ctx->GetRegisterInfoAtIndex( 0 ); - if ( r0_info == nullptr ) - return vObjSP; - - // void return type - if ( retType.isVoidTy( ) ) - { - value.GetScalar( ) = 0; - } - // integer / pointer return type - else - if ( retType.isIntegerTy( ) || retType.isPointerTy( ) ) - { - // read r0 register value - lldb_private::RegisterValue r0_value; - if ( !reg_ctx->ReadRegister( r0_info, r0_value ) ) - return vObjSP; - - // push r0 into value - uint32_t r0_u32 = r0_value.GetAsUInt32( ); - - // account for integer size - if ( retType.isIntegerTy() && retType.isSized() ) - { - uint64_t size = retType.getScalarSizeInBits( ); - uint64_t mask = ( 1ull << size ) - 1; - // mask out higher order bits then the type we expect - r0_u32 &= mask; - } - - value.GetScalar( ) = r0_u32; +ABISysV_hexagon::GetReturnValueObjectImpl(lldb_private::Thread &thread, + llvm::Type &retType) const { + Value value; + ValueObjectSP vObjSP; + + // get the current register context + RegisterContext *reg_ctx = thread.GetRegisterContext().get(); + if (!reg_ctx) + return vObjSP; + + // for now just pop R0 to find the return value + const lldb_private::RegisterInfo *r0_info = + reg_ctx->GetRegisterInfoAtIndex(0); + if (r0_info == nullptr) + return vObjSP; + + // void return type + if (retType.isVoidTy()) { + value.GetScalar() = 0; + } + // integer / pointer return type + else if (retType.isIntegerTy() || retType.isPointerTy()) { + // read r0 register value + lldb_private::RegisterValue r0_value; + if (!reg_ctx->ReadRegister(r0_info, r0_value)) + return vObjSP; + + // push r0 into value + uint32_t r0_u32 = r0_value.GetAsUInt32(); + + // account for integer size + if (retType.isIntegerTy() && retType.isSized()) { + uint64_t size = retType.getScalarSizeInBits(); + uint64_t mask = (1ull << size) - 1; + // mask out higher order bits then the type we expect + r0_u32 &= mask; } - // unsupported return type - else - return vObjSP; - - // pack the value into a ValueObjectSP - vObjSP = ValueObjectConstResult::Create - ( - thread.GetStackFrameAtIndex(0).get(), - value, - ConstString("") - ); + + value.GetScalar() = r0_u32; + } + // unsupported return type + else return vObjSP; + + // pack the value into a ValueObjectSP + vObjSP = ValueObjectConstResult::Create(thread.GetStackFrameAtIndex(0).get(), + value, ConstString("")); + return vObjSP; } diff --git a/source/Plugins/ABI/SysV-hexagon/ABISysV_hexagon.h b/source/Plugins/ABI/SysV-hexagon/ABISysV_hexagon.h index 337e3fdcf7b5..aed3dd71b69a 100644 --- a/source/Plugins/ABI/SysV-hexagon/ABISysV_hexagon.h +++ b/source/Plugins/ABI/SysV-hexagon/ABISysV_hexagon.h @@ -1,4 +1,5 @@ -//===-- ABISysV_hexagon.h ----------------------------------------*- C++ -*-===// +//===-- ABISysV_hexagon.h ----------------------------------------*- C++ +//-*-===// // // The LLVM Compiler Infrastructure // @@ -14,124 +15,100 @@ // C++ Includes // Other libraries and framework includes // Project includes -#include "lldb/lldb-private.h" #include "lldb/Target/ABI.h" +#include "lldb/lldb-private.h" -class ABISysV_hexagon : - public lldb_private::ABI -{ +class ABISysV_hexagon : public lldb_private::ABI { public: - ~ABISysV_hexagon() override = default; - - size_t - GetRedZoneSize() const override; - - bool - PrepareTrivialCall(lldb_private::Thread &thread, - lldb::addr_t sp, - lldb::addr_t functionAddress, - lldb::addr_t returnAddress, - llvm::ArrayRef<lldb::addr_t> args) const override; - - // special thread plan for GDB style non-jit function calls - bool - PrepareTrivialCall(lldb_private::Thread &thread, - lldb::addr_t sp, - lldb::addr_t functionAddress, - lldb::addr_t returnAddress, - llvm::Type &prototype, - llvm::ArrayRef<ABI::CallArgument> args) const override; - - bool - GetArgumentValues(lldb_private::Thread &thread, - lldb_private::ValueList &values) const override; - - lldb_private::Error - SetReturnValueObject(lldb::StackFrameSP &frame_sp, - lldb::ValueObjectSP &new_value) override; - - lldb::ValueObjectSP - GetReturnValueObjectImpl(lldb_private::Thread &thread, - lldb_private::CompilerType &type) const override; - - // specialized to work with llvm IR types - lldb::ValueObjectSP - GetReturnValueObjectImpl(lldb_private::Thread &thread, llvm::Type &type) const override; - - bool - CreateFunctionEntryUnwindPlan(lldb_private::UnwindPlan &unwind_plan) override; - - bool - CreateDefaultUnwindPlan(lldb_private::UnwindPlan &unwind_plan) override; - - bool - RegisterIsVolatile(const lldb_private::RegisterInfo *reg_info) override; - - bool - CallFrameAddressIsValid(lldb::addr_t cfa) override - { - // Make sure the stack call frame addresses are 8 byte aligned - if (cfa & 0x07) - return false; // Not 8 byte aligned - if (cfa == 0) - return false; // Zero is not a valid stack address - return true; - } - - bool - CodeAddressIsValid(lldb::addr_t pc) override - { - // We have a 64 bit address space, so anything is valid as opcodes - // aren't fixed width... - return true; - } - - const lldb_private::RegisterInfo * - GetRegisterInfoArray(uint32_t &count) override; - - //------------------------------------------------------------------ - // Static Functions - //------------------------------------------------------------------ - - static void - Initialize(); - - static void - Terminate(); - - static lldb::ABISP - CreateInstance ( const lldb_private::ArchSpec &arch ); - - static lldb_private::ConstString - GetPluginNameStatic(); - - //------------------------------------------------------------------ - // PluginInterface protocol - //------------------------------------------------------------------ - - lldb_private::ConstString - GetPluginName() override; - - uint32_t - GetPluginVersion() override; + ~ABISysV_hexagon() override = default; + + size_t GetRedZoneSize() const override; + + bool PrepareTrivialCall(lldb_private::Thread &thread, lldb::addr_t sp, + lldb::addr_t functionAddress, + lldb::addr_t returnAddress, + llvm::ArrayRef<lldb::addr_t> args) const override; + + // special thread plan for GDB style non-jit function calls + bool + PrepareTrivialCall(lldb_private::Thread &thread, lldb::addr_t sp, + lldb::addr_t functionAddress, lldb::addr_t returnAddress, + llvm::Type &prototype, + llvm::ArrayRef<ABI::CallArgument> args) const override; + + bool GetArgumentValues(lldb_private::Thread &thread, + lldb_private::ValueList &values) const override; + + lldb_private::Error + SetReturnValueObject(lldb::StackFrameSP &frame_sp, + lldb::ValueObjectSP &new_value) override; + + lldb::ValueObjectSP + GetReturnValueObjectImpl(lldb_private::Thread &thread, + lldb_private::CompilerType &type) const override; + + // specialized to work with llvm IR types + lldb::ValueObjectSP GetReturnValueObjectImpl(lldb_private::Thread &thread, + llvm::Type &type) const override; + + bool + CreateFunctionEntryUnwindPlan(lldb_private::UnwindPlan &unwind_plan) override; + + bool CreateDefaultUnwindPlan(lldb_private::UnwindPlan &unwind_plan) override; + + bool RegisterIsVolatile(const lldb_private::RegisterInfo *reg_info) override; + + bool CallFrameAddressIsValid(lldb::addr_t cfa) override { + // Make sure the stack call frame addresses are 8 byte aligned + if (cfa & 0x07) + return false; // Not 8 byte aligned + if (cfa == 0) + return false; // Zero is not a valid stack address + return true; + } + + bool CodeAddressIsValid(lldb::addr_t pc) override { + // We have a 64 bit address space, so anything is valid as opcodes + // aren't fixed width... + return true; + } + + const lldb_private::RegisterInfo * + GetRegisterInfoArray(uint32_t &count) override; + + //------------------------------------------------------------------ + // Static Functions + //------------------------------------------------------------------ + + static void Initialize(); + + static void Terminate(); + + static lldb::ABISP CreateInstance(const lldb_private::ArchSpec &arch); + + static lldb_private::ConstString GetPluginNameStatic(); + + //------------------------------------------------------------------ + // PluginInterface protocol + //------------------------------------------------------------------ + + lldb_private::ConstString GetPluginName() override; + + uint32_t GetPluginVersion() override; protected: - void - CreateRegisterMapIfNeeded(); + void CreateRegisterMapIfNeeded(); - lldb::ValueObjectSP - GetReturnValueObjectSimple(lldb_private::Thread &thread, - lldb_private::CompilerType &ast_type) const; + lldb::ValueObjectSP + GetReturnValueObjectSimple(lldb_private::Thread &thread, + lldb_private::CompilerType &ast_type) const; - bool - RegisterIsCalleeSaved (const lldb_private::RegisterInfo *reg_info); + bool RegisterIsCalleeSaved(const lldb_private::RegisterInfo *reg_info); private: - ABISysV_hexagon() : - lldb_private::ABI() - { - // Call CreateInstance instead. - } + ABISysV_hexagon() : lldb_private::ABI() { + // Call CreateInstance instead. + } }; #endif // liblldb_ABISysV_hexagon_h_ diff --git a/source/Plugins/ABI/SysV-i386/ABISysV_i386.cpp b/source/Plugins/ABI/SysV-i386/ABISysV_i386.cpp index d23afe9956ba..701db184dfce 100644 --- a/source/Plugins/ABI/SysV-i386/ABISysV_i386.cpp +++ b/source/Plugins/ABI/SysV-i386/ABISysV_i386.cpp @@ -2,7 +2,8 @@ // // The LLVM Compiler Infrastructure // -// This file is distributed under the University of Illinois Open Source License. +// This file is distributed under the University of Illinois Open Source +// License. // See LICENSE.TXT for details. //===----------------------------------------------------------------------===// @@ -24,13 +25,13 @@ #include "lldb/Core/RegisterValue.h" #include "lldb/Core/Value.h" #include "lldb/Core/ValueObjectConstResult.h" -#include "lldb/Core/ValueObjectRegister.h" #include "lldb/Core/ValueObjectMemory.h" +#include "lldb/Core/ValueObjectRegister.h" #include "lldb/Symbol/UnwindPlan.h" -#include "lldb/Target/Target.h" #include "lldb/Target/Process.h" #include "lldb/Target/RegisterContext.h" #include "lldb/Target/StackFrame.h" +#include "lldb/Target/Target.h" #include "lldb/Target/Thread.h" using namespace lldb; @@ -58,132 +59,143 @@ using namespace lldb_private; // Comment: Table 2.14 is followed till 'mm' entries. // After that, all entries are ignored here. -enum dwarf_regnums -{ - dwarf_eax = 0, - dwarf_ecx, - dwarf_edx, - dwarf_ebx, - dwarf_esp, - dwarf_ebp, - dwarf_esi, - dwarf_edi, - dwarf_eip, - dwarf_eflags, - - dwarf_st0 = 11, - dwarf_st1, - dwarf_st2, - dwarf_st3, - dwarf_st4, - dwarf_st5, - dwarf_st6, - dwarf_st7, - - dwarf_xmm0 = 21, - dwarf_xmm1, - dwarf_xmm2, - dwarf_xmm3, - dwarf_xmm4, - dwarf_xmm5, - dwarf_xmm6, - dwarf_xmm7, - dwarf_ymm0 = dwarf_xmm0, - dwarf_ymm1 = dwarf_xmm1, - dwarf_ymm2 = dwarf_xmm2, - dwarf_ymm3 = dwarf_xmm3, - dwarf_ymm4 = dwarf_xmm4, - dwarf_ymm5 = dwarf_xmm5, - dwarf_ymm6 = dwarf_xmm6, - dwarf_ymm7 = dwarf_xmm7, - - dwarf_mm0 = 29, - dwarf_mm1, - dwarf_mm2, - dwarf_mm3, - dwarf_mm4, - dwarf_mm5, - dwarf_mm6, - dwarf_mm7 +enum dwarf_regnums { + dwarf_eax = 0, + dwarf_ecx, + dwarf_edx, + dwarf_ebx, + dwarf_esp, + dwarf_ebp, + dwarf_esi, + dwarf_edi, + dwarf_eip, + dwarf_eflags, + + dwarf_st0 = 11, + dwarf_st1, + dwarf_st2, + dwarf_st3, + dwarf_st4, + dwarf_st5, + dwarf_st6, + dwarf_st7, + + dwarf_xmm0 = 21, + dwarf_xmm1, + dwarf_xmm2, + dwarf_xmm3, + dwarf_xmm4, + dwarf_xmm5, + dwarf_xmm6, + dwarf_xmm7, + dwarf_ymm0 = dwarf_xmm0, + dwarf_ymm1 = dwarf_xmm1, + dwarf_ymm2 = dwarf_xmm2, + dwarf_ymm3 = dwarf_xmm3, + dwarf_ymm4 = dwarf_xmm4, + dwarf_ymm5 = dwarf_xmm5, + dwarf_ymm6 = dwarf_xmm6, + dwarf_ymm7 = dwarf_xmm7, + + dwarf_mm0 = 29, + dwarf_mm1, + dwarf_mm2, + dwarf_mm3, + dwarf_mm4, + dwarf_mm5, + dwarf_mm6, + dwarf_mm7, + + dwarf_bnd0 = 101, + dwarf_bnd1, + dwarf_bnd2, + dwarf_bnd3 }; -static RegisterInfo g_register_infos[] = -{ - // NAME ALT SZ OFF ENCODING FORMAT EH_FRAME DWARF GENERIC PROCESS PLUGIN LLDB NATIVE VALUE REGS INVALIDATE REGS - // ====== ======= == === ============= ============ ===================== ===================== ============================ ==================== ====================== ========== =============== - { "eax", nullptr, 4, 0, eEncodingUint , eFormatHex , { dwarf_eax , dwarf_eax , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr}, - { "ebx" , nullptr, 4, 0, eEncodingUint , eFormatHex , { dwarf_ebx , dwarf_ebx , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr}, - { "ecx" , nullptr, 4, 0, eEncodingUint , eFormatHex , { dwarf_ecx , dwarf_ecx , LLDB_REGNUM_GENERIC_ARG4 , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr}, - { "edx" , nullptr, 4, 0, eEncodingUint , eFormatHex , { dwarf_edx , dwarf_edx , LLDB_REGNUM_GENERIC_ARG3 , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr}, - { "esi" , nullptr, 4, 0, eEncodingUint , eFormatHex , { dwarf_esi , dwarf_esi , LLDB_REGNUM_GENERIC_ARG2 , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr}, - { "edi" , nullptr, 4, 0, eEncodingUint , eFormatHex , { dwarf_edi , dwarf_edi , LLDB_REGNUM_GENERIC_ARG1 , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr}, - { "ebp" , "fp", 4, 0, eEncodingUint , eFormatHex , { dwarf_ebp , dwarf_ebp , LLDB_REGNUM_GENERIC_FP , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr}, - { "esp" , "sp", 4, 0, eEncodingUint , eFormatHex , { dwarf_esp , dwarf_esp , LLDB_REGNUM_GENERIC_SP , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr}, - { "eip" , "pc", 4, 0, eEncodingUint , eFormatHex , { dwarf_eip , dwarf_eip , LLDB_REGNUM_GENERIC_PC , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr}, - { "eflags", nullptr, 4, 0, eEncodingUint , eFormatHex , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_REGNUM_GENERIC_FLAGS , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr}, - { "cs" , nullptr, 4, 0, eEncodingUint , eFormatHex , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr}, - { "ss" , nullptr, 4, 0, eEncodingUint , eFormatHex , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr}, - { "ds" , nullptr, 4, 0, eEncodingUint , eFormatHex , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr}, - { "es" , nullptr, 4, 0, eEncodingUint , eFormatHex , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr}, - { "fs" , nullptr, 4, 0, eEncodingUint , eFormatHex , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr}, - { "gs" , nullptr, 4, 0, eEncodingUint , eFormatHex , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr}, - { "st0" , nullptr, 10, 0, eEncodingVector, eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM , dwarf_st0 , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr}, - { "st1" , nullptr, 10, 0, eEncodingVector, eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM , dwarf_st1 , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr}, - { "st2" , nullptr, 10, 0, eEncodingVector, eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM , dwarf_st2 , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr}, - { "st3" , nullptr, 10, 0, eEncodingVector, eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM , dwarf_st3 , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr}, - { "st4" , nullptr, 10, 0, eEncodingVector, eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM , dwarf_st4 , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr}, - { "st5" , nullptr, 10, 0, eEncodingVector, eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM , dwarf_st5 , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr}, - { "st6" , nullptr, 10, 0, eEncodingVector, eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM , dwarf_st6 , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr}, - { "st7" , nullptr, 10, 0, eEncodingVector, eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM , dwarf_st7 , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr}, - { "fctrl" , nullptr, 4, 0, eEncodingUint , eFormatHex , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr}, - { "fstat" , nullptr, 4, 0, eEncodingUint , eFormatHex , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr}, - { "ftag" , nullptr, 4, 0, eEncodingUint , eFormatHex , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr}, - { "fiseg" , nullptr, 4, 0, eEncodingUint , eFormatHex , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr}, - { "fioff" , nullptr, 4, 0, eEncodingUint , eFormatHex , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr}, - { "foseg" , nullptr, 4, 0, eEncodingUint , eFormatHex , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr}, - { "fooff" , nullptr, 4, 0, eEncodingUint , eFormatHex , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr}, - { "fop" , nullptr, 4, 0, eEncodingUint , eFormatHex , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr}, - { "xmm0" , nullptr, 16, 0, eEncodingVector, eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM , dwarf_xmm0 , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr}, - { "xmm1" , nullptr, 16, 0, eEncodingVector, eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM , dwarf_xmm1 , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr}, - { "xmm2" , nullptr, 16, 0, eEncodingVector, eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM , dwarf_xmm2 , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr}, - { "xmm3" , nullptr, 16, 0, eEncodingVector, eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM , dwarf_xmm3 , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr}, - { "xmm4" , nullptr, 16, 0, eEncodingVector, eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM , dwarf_xmm4 , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr}, - { "xmm5" , nullptr, 16, 0, eEncodingVector, eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM , dwarf_xmm5 , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr}, - { "xmm6" , nullptr, 16, 0, eEncodingVector, eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM , dwarf_xmm6 , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr}, - { "xmm7" , nullptr, 16, 0, eEncodingVector, eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM , dwarf_xmm7 , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr}, - { "mxcsr" , nullptr, 4, 0, eEncodingUint , eFormatHex , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr}, - { "ymm0" , nullptr, 32, 0, eEncodingVector, eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM , dwarf_ymm0 , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr}, - { "ymm1" , nullptr, 32, 0, eEncodingVector, eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM , dwarf_ymm1 , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr}, - { "ymm2" , nullptr, 32, 0, eEncodingVector, eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM , dwarf_ymm2 , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr}, - { "ymm3" , nullptr, 32, 0, eEncodingVector, eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM , dwarf_ymm3 , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr}, - { "ymm4" , nullptr, 32, 0, eEncodingVector, eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM , dwarf_ymm4 , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr}, - { "ymm5" , nullptr, 32, 0, eEncodingVector, eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM , dwarf_ymm5 , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr}, - { "ymm6" , nullptr, 32, 0, eEncodingVector, eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM , dwarf_ymm6 , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr}, - { "ymm7" , nullptr, 32, 0, eEncodingVector, eFormatVectorOfUInt8, { LLDB_INVALID_REGNUM , dwarf_ymm7 , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr} +static RegisterInfo g_register_infos[] = { + // clang-format off + //NAME ALT SZ OFF ENCODING FORMAT EH_FRAME DWARF GENERIC PROCESS PLUGIN LLDB NATIVE VALUE INVAL DYN EXPR SZ + //========== ======= == === ============= ==================== =================== =================== ========================= =================== =================== ======= ======= ======== == + {"eax", nullptr, 4, 0, eEncodingUint, eFormatHex, {dwarf_eax, dwarf_eax, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0}, + {"ebx", nullptr, 4, 0, eEncodingUint, eFormatHex, {dwarf_ebx, dwarf_ebx, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0}, + {"ecx", nullptr, 4, 0, eEncodingUint, eFormatHex, {dwarf_ecx, dwarf_ecx, LLDB_REGNUM_GENERIC_ARG4, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0}, + {"edx", nullptr, 4, 0, eEncodingUint, eFormatHex, {dwarf_edx, dwarf_edx, LLDB_REGNUM_GENERIC_ARG3, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0}, + {"esi", nullptr, 4, 0, eEncodingUint, eFormatHex, {dwarf_esi, dwarf_esi, LLDB_REGNUM_GENERIC_ARG2, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0}, + {"edi", nullptr, 4, 0, eEncodingUint, eFormatHex, {dwarf_edi, dwarf_edi, LLDB_REGNUM_GENERIC_ARG1, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0}, + {"ebp", "fp", 4, 0, eEncodingUint, eFormatHex, {dwarf_ebp, dwarf_ebp, LLDB_REGNUM_GENERIC_FP, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0}, + {"esp", "sp", 4, 0, eEncodingUint, eFormatHex, {dwarf_esp, dwarf_esp, LLDB_REGNUM_GENERIC_SP, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0}, + {"eip", "pc", 4, 0, eEncodingUint, eFormatHex, {dwarf_eip, dwarf_eip, LLDB_REGNUM_GENERIC_PC, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0}, + {"eflags", 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}, + {"st0", nullptr, 10, 0, eEncodingVector, eFormatVectorOfUInt8, {LLDB_INVALID_REGNUM, dwarf_st0, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0}, + {"st1", nullptr, 10, 0, eEncodingVector, eFormatVectorOfUInt8, {LLDB_INVALID_REGNUM, dwarf_st1, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0}, + {"st2", nullptr, 10, 0, eEncodingVector, eFormatVectorOfUInt8, {LLDB_INVALID_REGNUM, dwarf_st2, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0}, + {"st3", nullptr, 10, 0, eEncodingVector, eFormatVectorOfUInt8, {LLDB_INVALID_REGNUM, dwarf_st3, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0}, + {"st4", nullptr, 10, 0, eEncodingVector, eFormatVectorOfUInt8, {LLDB_INVALID_REGNUM, dwarf_st4, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0}, + {"st5", nullptr, 10, 0, eEncodingVector, eFormatVectorOfUInt8, {LLDB_INVALID_REGNUM, dwarf_st5, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0}, + {"st6", nullptr, 10, 0, eEncodingVector, eFormatVectorOfUInt8, {LLDB_INVALID_REGNUM, dwarf_st6, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0}, + {"st7", nullptr, 10, 0, eEncodingVector, eFormatVectorOfUInt8, {LLDB_INVALID_REGNUM, dwarf_st7, 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, {LLDB_INVALID_REGNUM, dwarf_xmm0, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0}, + {"xmm1", nullptr, 16, 0, eEncodingVector, eFormatVectorOfUInt8, {LLDB_INVALID_REGNUM, dwarf_xmm1, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0}, + {"xmm2", nullptr, 16, 0, eEncodingVector, eFormatVectorOfUInt8, {LLDB_INVALID_REGNUM, dwarf_xmm2, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0}, + {"xmm3", nullptr, 16, 0, eEncodingVector, eFormatVectorOfUInt8, {LLDB_INVALID_REGNUM, dwarf_xmm3, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0}, + {"xmm4", nullptr, 16, 0, eEncodingVector, eFormatVectorOfUInt8, {LLDB_INVALID_REGNUM, dwarf_xmm4, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0}, + {"xmm5", nullptr, 16, 0, eEncodingVector, eFormatVectorOfUInt8, {LLDB_INVALID_REGNUM, dwarf_xmm5, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0}, + {"xmm6", nullptr, 16, 0, eEncodingVector, eFormatVectorOfUInt8, {LLDB_INVALID_REGNUM, dwarf_xmm6, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0}, + {"xmm7", nullptr, 16, 0, eEncodingVector, eFormatVectorOfUInt8, {LLDB_INVALID_REGNUM, dwarf_xmm7, 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, {LLDB_INVALID_REGNUM, dwarf_ymm0, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0}, + {"ymm1", nullptr, 32, 0, eEncodingVector, eFormatVectorOfUInt8, {LLDB_INVALID_REGNUM, dwarf_ymm1, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0}, + {"ymm2", nullptr, 32, 0, eEncodingVector, eFormatVectorOfUInt8, {LLDB_INVALID_REGNUM, dwarf_ymm2, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0}, + {"ymm3", nullptr, 32, 0, eEncodingVector, eFormatVectorOfUInt8, {LLDB_INVALID_REGNUM, dwarf_ymm3, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0}, + {"ymm4", nullptr, 32, 0, eEncodingVector, eFormatVectorOfUInt8, {LLDB_INVALID_REGNUM, dwarf_ymm4, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0}, + {"ymm5", nullptr, 32, 0, eEncodingVector, eFormatVectorOfUInt8, {LLDB_INVALID_REGNUM, dwarf_ymm5, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0}, + {"ymm6", nullptr, 32, 0, eEncodingVector, eFormatVectorOfUInt8, {LLDB_INVALID_REGNUM, dwarf_ymm6, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0}, + {"ymm7", nullptr, 32, 0, eEncodingVector, eFormatVectorOfUInt8, {LLDB_INVALID_REGNUM, dwarf_ymm7, 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 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_i386::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(); - } +ABISysV_i386::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; + } + count = k_num_register_infos; + return g_register_infos; } //------------------------------------------------------------------ @@ -191,614 +203,567 @@ ABISysV_i386::GetRegisterInfoArray (uint32_t &count) //------------------------------------------------------------------ ABISP -ABISysV_i386::CreateInstance (const ArchSpec &arch) -{ - static ABISP g_abi_sp; - if ((arch.GetTriple().getArch() == llvm::Triple::x86) && - arch.GetTriple().isOSLinux()) - { - if (!g_abi_sp) - g_abi_sp.reset (new ABISysV_i386); - return g_abi_sp; - } - return ABISP(); +ABISysV_i386::CreateInstance(const ArchSpec &arch) { + static ABISP g_abi_sp; + if ((arch.GetTriple().getArch() == llvm::Triple::x86) && + arch.GetTriple().isOSLinux()) { + if (!g_abi_sp) + g_abi_sp.reset(new ABISysV_i386); + return g_abi_sp; + } + return ABISP(); } -bool -ABISysV_i386::PrepareTrivialCall (Thread &thread, - addr_t sp, - addr_t func_addr, - addr_t return_addr, - llvm::ArrayRef<addr_t> args) const -{ - RegisterContext *reg_ctx = thread.GetRegisterContext().get(); - - if (!reg_ctx) - return false; - - uint32_t pc_reg_num = reg_ctx->ConvertRegisterKindToRegisterNumber (eRegisterKindGeneric, LLDB_REGNUM_GENERIC_PC); - uint32_t sp_reg_num = reg_ctx->ConvertRegisterKindToRegisterNumber (eRegisterKindGeneric, LLDB_REGNUM_GENERIC_SP); - - // While using register info to write a register value to memory, the register info - // just needs to have the correct size of a 32 bit register, the actual register it - // pertains to is not important, just the size needs to be correct. - // "eax" is used here for this purpose. - const RegisterInfo *reg_info_32 = reg_ctx->GetRegisterInfoByName("eax"); - if (!reg_info_32) - return false; // TODO this should actually never happen - - Error error; - RegisterValue reg_value; - - // Make room for the argument(s) on the stack - sp -= 4 * args.size(); - - // SP Alignment - sp &= ~(16ull-1ull); // 16-byte alignment - - // Write arguments onto the stack - addr_t arg_pos = sp; - for (addr_t arg : args) - { - reg_value.SetUInt32(arg); - error = reg_ctx->WriteRegisterValueToMemory (reg_info_32, - arg_pos, - reg_info_32->byte_size, - reg_value); - if (error.Fail()) - return false; - arg_pos += 4; - } +bool ABISysV_i386::PrepareTrivialCall(Thread &thread, addr_t sp, + addr_t func_addr, addr_t return_addr, + llvm::ArrayRef<addr_t> args) const { + RegisterContext *reg_ctx = thread.GetRegisterContext().get(); - // The return address is pushed onto the stack - sp -= 4; - reg_value.SetUInt32(return_addr); - error = reg_ctx->WriteRegisterValueToMemory (reg_info_32, - sp, - reg_info_32->byte_size, - reg_value); + if (!reg_ctx) + return false; + + uint32_t pc_reg_num = reg_ctx->ConvertRegisterKindToRegisterNumber( + eRegisterKindGeneric, LLDB_REGNUM_GENERIC_PC); + uint32_t sp_reg_num = reg_ctx->ConvertRegisterKindToRegisterNumber( + eRegisterKindGeneric, LLDB_REGNUM_GENERIC_SP); + + // While using register info to write a register value to memory, the register + // info + // just needs to have the correct size of a 32 bit register, the actual + // register it + // pertains to is not important, just the size needs to be correct. + // "eax" is used here for this purpose. + const RegisterInfo *reg_info_32 = reg_ctx->GetRegisterInfoByName("eax"); + if (!reg_info_32) + return false; // TODO this should actually never happen + + Error error; + RegisterValue reg_value; + + // Make room for the argument(s) on the stack + sp -= 4 * args.size(); + + // SP Alignment + sp &= ~(16ull - 1ull); // 16-byte alignment + + // Write arguments onto the stack + addr_t arg_pos = sp; + for (addr_t arg : args) { + reg_value.SetUInt32(arg); + error = reg_ctx->WriteRegisterValueToMemory( + reg_info_32, arg_pos, reg_info_32->byte_size, reg_value); if (error.Fail()) - return false; + return false; + arg_pos += 4; + } + + // The return address is pushed onto the stack + sp -= 4; + reg_value.SetUInt32(return_addr); + error = reg_ctx->WriteRegisterValueToMemory( + reg_info_32, sp, reg_info_32->byte_size, reg_value); + if (error.Fail()) + return false; - // Setting %esp to the actual stack value. - if (!reg_ctx->WriteRegisterFromUnsigned (sp_reg_num, sp)) - return false; + // Setting %esp to the actual stack value. + if (!reg_ctx->WriteRegisterFromUnsigned(sp_reg_num, sp)) + return false; - // Setting %eip to the address of the called function. - if (!reg_ctx->WriteRegisterFromUnsigned (pc_reg_num, func_addr)) - return false; + // Setting %eip to the address of the called function. + if (!reg_ctx->WriteRegisterFromUnsigned(pc_reg_num, func_addr)) + return false; - return true; + return true; } -static bool -ReadIntegerArgument (Scalar &scalar, - unsigned int bit_width, - bool is_signed, - Process *process, - addr_t ¤t_stack_argument) -{ - uint32_t byte_size = (bit_width + (8-1))/8; - Error error; +static bool ReadIntegerArgument(Scalar &scalar, unsigned int bit_width, + bool is_signed, Process *process, + addr_t ¤t_stack_argument) { + uint32_t byte_size = (bit_width + (8 - 1)) / 8; + Error error; - if (!process) - return false; - - if (process->ReadScalarIntegerFromMemory(current_stack_argument, byte_size, is_signed, scalar, error)) - { - current_stack_argument += byte_size; - return true; - } + if (!process) return false; -} - -bool -ABISysV_i386::GetArgumentValues (Thread &thread, - ValueList &values) const -{ - unsigned int num_values = values.GetSize(); - unsigned int value_index; - RegisterContext *reg_ctx = thread.GetRegisterContext().get(); - - if (!reg_ctx) - return false; + if (process->ReadScalarIntegerFromMemory(current_stack_argument, byte_size, + is_signed, scalar, error)) { + current_stack_argument += byte_size; + return true; + } + return false; +} - // Get pointer to the first stack argument - addr_t sp = reg_ctx->GetSP(0); - if (!sp) - return false; +bool ABISysV_i386::GetArgumentValues(Thread &thread, ValueList &values) const { + unsigned int num_values = values.GetSize(); + unsigned int value_index; - addr_t current_stack_argument = sp + 4; // jump over return address + RegisterContext *reg_ctx = thread.GetRegisterContext().get(); - for (value_index = 0; - value_index < num_values; - ++value_index) - { - Value *value = values.GetValueAtIndex(value_index); + if (!reg_ctx) + return false; - if (!value) - return false; + // Get pointer to the first stack argument + addr_t sp = reg_ctx->GetSP(0); + if (!sp) + return false; - // Currently: Support for extracting values with Clang QualTypes only. - CompilerType compiler_type (value->GetCompilerType()); - if (compiler_type) - { - bool is_signed; - if (compiler_type.IsIntegerOrEnumerationType (is_signed)) - { - ReadIntegerArgument(value->GetScalar(), - compiler_type.GetBitSize(&thread), - is_signed, - thread.GetProcess().get(), - current_stack_argument); - } - else if (compiler_type.IsPointerType()) - { - ReadIntegerArgument(value->GetScalar(), - compiler_type.GetBitSize(&thread), - false, - thread.GetProcess().get(), - current_stack_argument); - } - } + addr_t current_stack_argument = sp + 4; // jump over return address + + for (value_index = 0; value_index < num_values; ++value_index) { + Value *value = values.GetValueAtIndex(value_index); + + if (!value) + return false; + + // Currently: Support for extracting values with Clang QualTypes only. + CompilerType compiler_type(value->GetCompilerType()); + if (compiler_type) { + bool is_signed; + if (compiler_type.IsIntegerOrEnumerationType(is_signed)) { + ReadIntegerArgument(value->GetScalar(), + compiler_type.GetBitSize(&thread), is_signed, + thread.GetProcess().get(), current_stack_argument); + } else if (compiler_type.IsPointerType()) { + ReadIntegerArgument(value->GetScalar(), + compiler_type.GetBitSize(&thread), false, + thread.GetProcess().get(), current_stack_argument); + } } - return true; + } + return true; } -Error -ABISysV_i386::SetReturnValueObject(lldb::StackFrameSP &frame_sp, lldb::ValueObjectSP &new_value_sp) -{ - Error error; - if (!new_value_sp) - { - error.SetErrorString("Empty value object for return value."); - return error; - } +Error ABISysV_i386::SetReturnValueObject(lldb::StackFrameSP &frame_sp, + lldb::ValueObjectSP &new_value_sp) { + Error error; + if (!new_value_sp) { + error.SetErrorString("Empty value object for return value."); + return error; + } - CompilerType compiler_type = new_value_sp->GetCompilerType(); - if (!compiler_type) - { - error.SetErrorString ("Null clang type for return value."); - return error; - } + CompilerType compiler_type = new_value_sp->GetCompilerType(); + if (!compiler_type) { + error.SetErrorString("Null clang type for return value."); + return error; + } + + const uint32_t type_flags = compiler_type.GetTypeInfo(); + Thread *thread = frame_sp->GetThread().get(); + RegisterContext *reg_ctx = thread->GetRegisterContext().get(); + DataExtractor data; + Error data_error; + size_t num_bytes = new_value_sp->GetData(data, data_error); + bool register_write_successful = true; + + if (data_error.Fail()) { + error.SetErrorStringWithFormat( + "Couldn't convert return value to raw data: %s", + data_error.AsCString()); + return error; + } - const uint32_t type_flags = compiler_type.GetTypeInfo (); - Thread *thread = frame_sp->GetThread().get(); - RegisterContext *reg_ctx = thread->GetRegisterContext().get(); - DataExtractor data; - Error data_error; - size_t num_bytes = new_value_sp->GetData(data, data_error); - bool register_write_successful = true; + // Following "IF ELSE" block categorizes various 'Fundamental Data Types'. + // The terminology 'Fundamental Data Types' used here is adopted from + // Table 2.1 of the reference document (specified on top of this file) - if (data_error.Fail()) - { - error.SetErrorStringWithFormat("Couldn't convert return value to raw data: %s", data_error.AsCString()); - return error; + if (type_flags & eTypeIsPointer) // 'Pointer' + { + if (num_bytes != sizeof(uint32_t)) { + error.SetErrorString("Pointer to be returned is not 4 bytes wide"); + return error; } - - // Following "IF ELSE" block categorizes various 'Fundamental Data Types'. - // The terminology 'Fundamental Data Types' used here is adopted from - // Table 2.1 of the reference document (specified on top of this file) - - if (type_flags & eTypeIsPointer) // 'Pointer' + lldb::offset_t offset = 0; + const RegisterInfo *eax_info = reg_ctx->GetRegisterInfoByName("eax", 0); + uint32_t raw_value = data.GetMaxU32(&offset, num_bytes); + register_write_successful = + reg_ctx->WriteRegisterFromUnsigned(eax_info, raw_value); + } else if ((type_flags & eTypeIsScalar) || + (type_flags & eTypeIsEnumeration)) //'Integral' + 'Floating Point' + { + lldb::offset_t offset = 0; + const RegisterInfo *eax_info = reg_ctx->GetRegisterInfoByName("eax", 0); + + if (type_flags & eTypeIsInteger) // 'Integral' except enum { - if(num_bytes != sizeof(uint32_t)) - { - error.SetErrorString("Pointer to be returned is not 4 bytes wide"); - return error; - } - lldb::offset_t offset = 0; - const RegisterInfo *eax_info = reg_ctx->GetRegisterInfoByName("eax", 0); + switch (num_bytes) { + default: + break; + case 16: + // For clang::BuiltinType::UInt128 & Int128 + // ToDo: Need to decide how to handle it + break; + case 8: { + uint32_t raw_value_low = data.GetMaxU32(&offset, 4); + const RegisterInfo *edx_info = reg_ctx->GetRegisterInfoByName("edx", 0); + uint32_t raw_value_high = data.GetMaxU32(&offset, num_bytes - offset); + register_write_successful = + (reg_ctx->WriteRegisterFromUnsigned(eax_info, raw_value_low) && + reg_ctx->WriteRegisterFromUnsigned(edx_info, raw_value_high)); + break; + } + case 4: + case 2: + case 1: { uint32_t raw_value = data.GetMaxU32(&offset, num_bytes); - register_write_successful = reg_ctx->WriteRegisterFromUnsigned (eax_info, raw_value); - } - else if ((type_flags & eTypeIsScalar) || (type_flags & eTypeIsEnumeration)) //'Integral' + 'Floating Point' + register_write_successful = + reg_ctx->WriteRegisterFromUnsigned(eax_info, raw_value); + break; + } + } + } else if (type_flags & eTypeIsEnumeration) // handles enum { - lldb::offset_t offset = 0; - const RegisterInfo *eax_info = reg_ctx->GetRegisterInfoByName("eax", 0); - - if (type_flags & eTypeIsInteger) // 'Integral' except enum - { - switch (num_bytes) - { - default: - break; - case 16: - // For clang::BuiltinType::UInt128 & Int128 - // ToDo: Need to decide how to handle it - break; - case 8: - { - uint32_t raw_value_low = data.GetMaxU32(&offset, 4); - const RegisterInfo *edx_info = reg_ctx->GetRegisterInfoByName("edx", 0); - uint32_t raw_value_high = data.GetMaxU32(&offset, num_bytes - offset); - register_write_successful = (reg_ctx->WriteRegisterFromUnsigned (eax_info, raw_value_low) && - reg_ctx->WriteRegisterFromUnsigned (edx_info, raw_value_high)); - break; - } - case 4: - case 2: - case 1: - { - uint32_t raw_value = data.GetMaxU32(&offset, num_bytes); - register_write_successful = reg_ctx->WriteRegisterFromUnsigned (eax_info, raw_value); - break; - } - } - } - else if (type_flags & eTypeIsEnumeration) // handles enum - { - uint32_t raw_value = data.GetMaxU32(&offset, num_bytes); - register_write_successful = reg_ctx->WriteRegisterFromUnsigned (eax_info, raw_value); - } - else if (type_flags & eTypeIsFloat) // 'Floating Point' - { - RegisterValue st0_value, fstat_value, ftag_value; - const RegisterInfo *st0_info = reg_ctx->GetRegisterInfoByName("st0", 0); - const RegisterInfo *fstat_info = reg_ctx->GetRegisterInfoByName("fstat", 0); - const RegisterInfo *ftag_info = reg_ctx->GetRegisterInfoByName("ftag", 0); - - /* According to Page 3-12 of document - System V Application Binary Interface, Intel386 Architecture Processor Supplement, Fourth Edition - To return Floating Point values, all st% registers except st0 should be empty after exiting from - a function. This requires setting fstat and ftag registers to specific values. - fstat: The TOP field of fstat should be set to a value [0,7]. ABI doesn't specify the specific - value of TOP in case of function return. Hence, we set the TOP field to 7 by our choice. */ - uint32_t value_fstat_u32 = 0x00003800; - - /* ftag: Implication of setting TOP to 7 and indicating all st% registers empty except st0 is to set - 7th bit of 4th byte of FXSAVE area to 1 and all other bits of this byte to 0. This is in accordance - with the document Intel 64 and IA-32 Architectures Software Developer's Manual, January 2015 */ - uint32_t value_ftag_u32 = 0x00000080; - - if (num_bytes <= 12) // handles float, double, long double, __float80 - { - long double value_long_dbl = 0.0; - if (num_bytes == 4) - value_long_dbl = data.GetFloat(&offset); - else if (num_bytes == 8) - value_long_dbl = data.GetDouble(&offset); - else if (num_bytes == 12) - value_long_dbl = data.GetLongDouble(&offset); - else - { - error.SetErrorString ("Invalid number of bytes for this return type"); - return error; - } - st0_value.SetLongDouble(value_long_dbl); - fstat_value.SetUInt32(value_fstat_u32); - ftag_value.SetUInt32(value_ftag_u32); - register_write_successful = reg_ctx->WriteRegister(st0_info, st0_value) && - reg_ctx->WriteRegister(fstat_info, fstat_value) && - reg_ctx->WriteRegister(ftag_info, ftag_value); - } - else if(num_bytes == 16) // handles __float128 - { - error.SetErrorString ("Implementation is missing for this clang type."); - } - } - else - { - // Neither 'Integral' nor 'Floating Point'. If flow reaches here - // then check type_flags. This type_flags is not a valid type. - error.SetErrorString ("Invalid clang type"); - } - } - else + uint32_t raw_value = data.GetMaxU32(&offset, num_bytes); + register_write_successful = + reg_ctx->WriteRegisterFromUnsigned(eax_info, raw_value); + } else if (type_flags & eTypeIsFloat) // 'Floating Point' { - /* 'Complex Floating Point', 'Packed', 'Decimal Floating Point' and 'Aggregate' data types - are yet to be implemented */ - error.SetErrorString ("Currently only Integral and Floating Point clang types are supported."); + RegisterValue st0_value, fstat_value, ftag_value; + const RegisterInfo *st0_info = reg_ctx->GetRegisterInfoByName("st0", 0); + const RegisterInfo *fstat_info = + reg_ctx->GetRegisterInfoByName("fstat", 0); + const RegisterInfo *ftag_info = reg_ctx->GetRegisterInfoByName("ftag", 0); + + /* According to Page 3-12 of document + System V Application Binary Interface, Intel386 Architecture Processor + Supplement, Fourth Edition + To return Floating Point values, all st% registers except st0 should be + empty after exiting from + a function. This requires setting fstat and ftag registers to specific + values. + fstat: The TOP field of fstat should be set to a value [0,7]. ABI doesn't + specify the specific + value of TOP in case of function return. Hence, we set the TOP field to 7 + by our choice. */ + uint32_t value_fstat_u32 = 0x00003800; + + /* ftag: Implication of setting TOP to 7 and indicating all st% registers + empty except st0 is to set + 7th bit of 4th byte of FXSAVE area to 1 and all other bits of this byte to + 0. This is in accordance + with the document Intel 64 and IA-32 Architectures Software Developer's + Manual, January 2015 */ + uint32_t value_ftag_u32 = 0x00000080; + + if (num_bytes <= 12) // handles float, double, long double, __float80 + { + long double value_long_dbl = 0.0; + if (num_bytes == 4) + value_long_dbl = data.GetFloat(&offset); + else if (num_bytes == 8) + value_long_dbl = data.GetDouble(&offset); + else if (num_bytes == 12) + value_long_dbl = data.GetLongDouble(&offset); + else { + error.SetErrorString("Invalid number of bytes for this return type"); + return error; + } + st0_value.SetLongDouble(value_long_dbl); + fstat_value.SetUInt32(value_fstat_u32); + ftag_value.SetUInt32(value_ftag_u32); + register_write_successful = + reg_ctx->WriteRegister(st0_info, st0_value) && + reg_ctx->WriteRegister(fstat_info, fstat_value) && + reg_ctx->WriteRegister(ftag_info, ftag_value); + } else if (num_bytes == 16) // handles __float128 + { + error.SetErrorString("Implementation is missing for this clang type."); + } + } else { + // Neither 'Integral' nor 'Floating Point'. If flow reaches here + // then check type_flags. This type_flags is not a valid type. + error.SetErrorString("Invalid clang type"); } - if (!register_write_successful) - error.SetErrorString ("Register writing failed"); - return error; + } else { + /* 'Complex Floating Point', 'Packed', 'Decimal Floating Point' and + 'Aggregate' data types + are yet to be implemented */ + error.SetErrorString("Currently only Integral and Floating Point clang " + "types are supported."); + } + if (!register_write_successful) + error.SetErrorString("Register writing failed"); + return error; } -ValueObjectSP -ABISysV_i386::GetReturnValueObjectSimple (Thread &thread, - CompilerType &return_compiler_type) const -{ - ValueObjectSP return_valobj_sp; - Value value; +ValueObjectSP ABISysV_i386::GetReturnValueObjectSimple( + Thread &thread, CompilerType &return_compiler_type) const { + ValueObjectSP return_valobj_sp; + Value value; - if (!return_compiler_type) - return return_valobj_sp; + if (!return_compiler_type) + return return_valobj_sp; - value.SetCompilerType (return_compiler_type); + value.SetCompilerType(return_compiler_type); - RegisterContext *reg_ctx = thread.GetRegisterContext().get(); - if (!reg_ctx) - return return_valobj_sp; + RegisterContext *reg_ctx = thread.GetRegisterContext().get(); + if (!reg_ctx) + return return_valobj_sp; - const uint32_t type_flags = return_compiler_type.GetTypeInfo (); + const uint32_t type_flags = return_compiler_type.GetTypeInfo(); + + unsigned eax_id = + reg_ctx->GetRegisterInfoByName("eax", 0)->kinds[eRegisterKindLLDB]; + unsigned edx_id = + reg_ctx->GetRegisterInfoByName("edx", 0)->kinds[eRegisterKindLLDB]; + + // Following "IF ELSE" block categorizes various 'Fundamental Data Types'. + // The terminology 'Fundamental Data Types' used here is adopted from + // Table 2.1 of the reference document (specified on top of this file) + + if (type_flags & eTypeIsPointer) // 'Pointer' + { + uint32_t ptr = + thread.GetRegisterContext()->ReadRegisterAsUnsigned(eax_id, 0) & + 0xffffffff; + value.SetValueType(Value::eValueTypeScalar); + value.GetScalar() = ptr; + return_valobj_sp = ValueObjectConstResult::Create( + thread.GetStackFrameAtIndex(0).get(), value, ConstString("")); + } else if ((type_flags & eTypeIsScalar) || + (type_flags & eTypeIsEnumeration)) //'Integral' + 'Floating Point' + { + value.SetValueType(Value::eValueTypeScalar); + const size_t byte_size = return_compiler_type.GetByteSize(nullptr); + bool success = false; + + if (type_flags & eTypeIsInteger) // 'Integral' except enum + { + const bool is_signed = ((type_flags & eTypeIsSigned) != 0); + uint64_t raw_value = + thread.GetRegisterContext()->ReadRegisterAsUnsigned(eax_id, 0) & + 0xffffffff; + raw_value |= + (thread.GetRegisterContext()->ReadRegisterAsUnsigned(edx_id, 0) & + 0xffffffff) + << 32; + + switch (byte_size) { + default: + break; + + case 16: + // For clang::BuiltinType::UInt128 & Int128 + // ToDo: Need to decide how to handle it + break; + + case 8: + if (is_signed) + value.GetScalar() = (int64_t)(raw_value); + else + value.GetScalar() = (uint64_t)(raw_value); + success = true; + break; - unsigned eax_id = reg_ctx->GetRegisterInfoByName("eax", 0)->kinds[eRegisterKindLLDB]; - unsigned edx_id = reg_ctx->GetRegisterInfoByName("edx", 0)->kinds[eRegisterKindLLDB]; + case 4: + if (is_signed) + value.GetScalar() = (int32_t)(raw_value & UINT32_MAX); + else + value.GetScalar() = (uint32_t)(raw_value & UINT32_MAX); + success = true; + break; - // Following "IF ELSE" block categorizes various 'Fundamental Data Types'. - // The terminology 'Fundamental Data Types' used here is adopted from - // Table 2.1 of the reference document (specified on top of this file) + case 2: + if (is_signed) + value.GetScalar() = (int16_t)(raw_value & UINT16_MAX); + else + value.GetScalar() = (uint16_t)(raw_value & UINT16_MAX); + success = true; + break; - if (type_flags & eTypeIsPointer) // 'Pointer' + case 1: + if (is_signed) + value.GetScalar() = (int8_t)(raw_value & UINT8_MAX); + else + value.GetScalar() = (uint8_t)(raw_value & UINT8_MAX); + success = true; + break; + } + + if (success) + return_valobj_sp = ValueObjectConstResult::Create( + thread.GetStackFrameAtIndex(0).get(), value, ConstString("")); + } else if (type_flags & eTypeIsEnumeration) // handles enum { - uint32_t ptr = thread.GetRegisterContext()->ReadRegisterAsUnsigned(eax_id, 0) & 0xffffffff; - value.SetValueType(Value::eValueTypeScalar); - value.GetScalar() = ptr; - return_valobj_sp = ValueObjectConstResult::Create (thread.GetStackFrameAtIndex(0).get(), - value, - ConstString("")); - } - else if ((type_flags & eTypeIsScalar) || (type_flags & eTypeIsEnumeration)) //'Integral' + 'Floating Point' + uint32_t enm = + thread.GetRegisterContext()->ReadRegisterAsUnsigned(eax_id, 0) & + 0xffffffff; + value.SetValueType(Value::eValueTypeScalar); + value.GetScalar() = enm; + return_valobj_sp = ValueObjectConstResult::Create( + thread.GetStackFrameAtIndex(0).get(), value, ConstString("")); + } else if (type_flags & eTypeIsFloat) // 'Floating Point' { - value.SetValueType(Value::eValueTypeScalar); - const size_t byte_size = return_compiler_type.GetByteSize(nullptr); - bool success = false; - - if (type_flags & eTypeIsInteger) // 'Integral' except enum - { - const bool is_signed = ((type_flags & eTypeIsSigned) != 0); - uint64_t raw_value = thread.GetRegisterContext()->ReadRegisterAsUnsigned(eax_id, 0) & 0xffffffff; - raw_value |= (thread.GetRegisterContext()->ReadRegisterAsUnsigned(edx_id, 0) & 0xffffffff) << 32; - - switch (byte_size) + if (byte_size <= 12) // handles float, double, long double, __float80 + { + const RegisterInfo *st0_info = reg_ctx->GetRegisterInfoByName("st0", 0); + RegisterValue st0_value; + + if (reg_ctx->ReadRegister(st0_info, st0_value)) { + DataExtractor data; + if (st0_value.GetData(data)) { + lldb::offset_t offset = 0; + long double value_long_double = data.GetLongDouble(&offset); + + if (byte_size == 4) // float is 4 bytes { - default: - break; - - case 16: - // For clang::BuiltinType::UInt128 & Int128 - // ToDo: Need to decide how to handle it - break; - - case 8: - if (is_signed) - value.GetScalar() = (int64_t)(raw_value); - else - value.GetScalar() = (uint64_t)(raw_value); - success = true; - break; - - case 4: - if (is_signed) - value.GetScalar() = (int32_t)(raw_value & UINT32_MAX); - else - value.GetScalar() = (uint32_t)(raw_value & UINT32_MAX); - success = true; - break; - - case 2: - if (is_signed) - value.GetScalar() = (int16_t)(raw_value & UINT16_MAX); - else - value.GetScalar() = (uint16_t)(raw_value & UINT16_MAX); - success = true; - break; - - case 1: - if (is_signed) - value.GetScalar() = (int8_t)(raw_value & UINT8_MAX); - else - value.GetScalar() = (uint8_t)(raw_value & UINT8_MAX); - success = true; - break; - } - - if (success) - return_valobj_sp = ValueObjectConstResult::Create (thread.GetStackFrameAtIndex(0).get(), - value, - ConstString("")); - } - else if (type_flags & eTypeIsEnumeration) // handles enum - { - uint32_t enm = thread.GetRegisterContext()->ReadRegisterAsUnsigned(eax_id, 0) & 0xffffffff; - value.SetValueType(Value::eValueTypeScalar); - value.GetScalar() = enm; - return_valobj_sp = ValueObjectConstResult::Create (thread.GetStackFrameAtIndex(0).get(), - value, - ConstString("")); - } - else if (type_flags & eTypeIsFloat) // 'Floating Point' - { - if (byte_size <= 12) // handles float, double, long double, __float80 + float value_float = (float)value_long_double; + value.GetScalar() = value_float; + success = true; + } else if (byte_size == 8) // double is 8 bytes { - const RegisterInfo *st0_info = reg_ctx->GetRegisterInfoByName("st0", 0); - RegisterValue st0_value; - - if (reg_ctx->ReadRegister (st0_info, st0_value)) - { - DataExtractor data; - if (st0_value.GetData(data)) - { - lldb::offset_t offset = 0; - long double value_long_double = data.GetLongDouble(&offset); - - if (byte_size == 4) // float is 4 bytes - { - float value_float = (float)value_long_double; - value.GetScalar() = value_float; - success = true; - } - else if (byte_size == 8) // double is 8 bytes - { - // On Android Platform: long double is also 8 bytes - // It will be handled here only. - double value_double = (double)value_long_double; - value.GetScalar() = value_double; - success = true; - } - else if (byte_size == 12) // long double and __float80 are 12 bytes on i386 - { - value.GetScalar() = value_long_double; - success = true; - } - } - } - - if (success) - return_valobj_sp = ValueObjectConstResult::Create (thread.GetStackFrameAtIndex(0).get(), - value, - ConstString("")); - } - else if(byte_size == 16) // handles __float128 + // On Android Platform: long double is also 8 bytes + // It will be handled here only. + double value_double = (double)value_long_double; + value.GetScalar() = value_double; + success = true; + } else if (byte_size == + 12) // long double and __float80 are 12 bytes on i386 { - lldb::addr_t storage_addr = (uint32_t)(thread.GetRegisterContext()->ReadRegisterAsUnsigned(eax_id, 0) & 0xffffffff); - return_valobj_sp = ValueObjectMemory::Create (&thread, - "", - Address (storage_addr, nullptr), - return_compiler_type); + value.GetScalar() = value_long_double; + success = true; } + } } - else // Neither 'Integral' nor 'Floating Point' - { - // If flow reaches here then check type_flags - // This type_flags is unhandled - } - } - else if (type_flags & eTypeIsComplex) // 'Complex Floating Point' + + if (success) + return_valobj_sp = ValueObjectConstResult::Create( + thread.GetStackFrameAtIndex(0).get(), value, ConstString("")); + } else if (byte_size == 16) // handles __float128 + { + lldb::addr_t storage_addr = (uint32_t)( + thread.GetRegisterContext()->ReadRegisterAsUnsigned(eax_id, 0) & + 0xffffffff); + return_valobj_sp = ValueObjectMemory::Create( + &thread, "", Address(storage_addr, nullptr), return_compiler_type); + } + } else // Neither 'Integral' nor 'Floating Point' { - // ToDo: Yet to be implemented + // If flow reaches here then check type_flags + // This type_flags is unhandled } - else if (type_flags & eTypeIsVector) // 'Packed' - { - const size_t byte_size = return_compiler_type.GetByteSize(nullptr); - if (byte_size > 0) - { - const RegisterInfo *vec_reg = reg_ctx->GetRegisterInfoByName("xmm0", 0); - if (vec_reg == nullptr) - vec_reg = reg_ctx->GetRegisterInfoByName("mm0", 0); - - if (vec_reg) - { - if (byte_size <= vec_reg->byte_size) - { - ProcessSP process_sp (thread.GetProcess()); - if (process_sp) - { - std::unique_ptr<DataBufferHeap> heap_data_ap (new DataBufferHeap(byte_size, 0)); - const ByteOrder byte_order = process_sp->GetByteOrder(); - RegisterValue reg_value; - if (reg_ctx->ReadRegister(vec_reg, reg_value)) - { - Error error; - if (reg_value.GetAsMemoryData (vec_reg, - heap_data_ap->GetBytes(), - heap_data_ap->GetByteSize(), - byte_order, - error)) - { - DataExtractor data (DataBufferSP (heap_data_ap.release()), - byte_order, - process_sp->GetTarget().GetArchitecture().GetAddressByteSize()); - return_valobj_sp = ValueObjectConstResult::Create (&thread, - return_compiler_type, - ConstString(""), - data); - } - } - } - } - else if (byte_size <= vec_reg->byte_size*2) - { - const RegisterInfo *vec_reg2 = reg_ctx->GetRegisterInfoByName("xmm1", 0); - if (vec_reg2) - { - ProcessSP process_sp (thread.GetProcess()); - if (process_sp) - { - std::unique_ptr<DataBufferHeap> heap_data_ap (new DataBufferHeap(byte_size, 0)); - const ByteOrder byte_order = process_sp->GetByteOrder(); - RegisterValue reg_value; - RegisterValue reg_value2; - if (reg_ctx->ReadRegister(vec_reg, reg_value) && reg_ctx->ReadRegister(vec_reg2, reg_value2)) - { - - Error error; - if (reg_value.GetAsMemoryData (vec_reg, - heap_data_ap->GetBytes(), - vec_reg->byte_size, - byte_order, - error) && - reg_value2.GetAsMemoryData (vec_reg2, - heap_data_ap->GetBytes() + vec_reg->byte_size, - heap_data_ap->GetByteSize() - vec_reg->byte_size, - byte_order, - error)) - { - DataExtractor data (DataBufferSP (heap_data_ap.release()), - byte_order, - process_sp->GetTarget().GetArchitecture().GetAddressByteSize()); - return_valobj_sp = ValueObjectConstResult::Create (&thread, - return_compiler_type, - ConstString(""), - data); - } - } - } - } + } else if (type_flags & eTypeIsComplex) // 'Complex Floating Point' + { + // ToDo: Yet to be implemented + } else if (type_flags & eTypeIsVector) // 'Packed' + { + const size_t byte_size = return_compiler_type.GetByteSize(nullptr); + if (byte_size > 0) { + const RegisterInfo *vec_reg = reg_ctx->GetRegisterInfoByName("xmm0", 0); + if (vec_reg == nullptr) + vec_reg = reg_ctx->GetRegisterInfoByName("mm0", 0); + + if (vec_reg) { + if (byte_size <= vec_reg->byte_size) { + ProcessSP process_sp(thread.GetProcess()); + if (process_sp) { + std::unique_ptr<DataBufferHeap> heap_data_ap( + new DataBufferHeap(byte_size, 0)); + const ByteOrder byte_order = process_sp->GetByteOrder(); + RegisterValue reg_value; + if (reg_ctx->ReadRegister(vec_reg, reg_value)) { + Error error; + if (reg_value.GetAsMemoryData(vec_reg, heap_data_ap->GetBytes(), + heap_data_ap->GetByteSize(), + byte_order, error)) { + DataExtractor data(DataBufferSP(heap_data_ap.release()), + byte_order, process_sp->GetTarget() + .GetArchitecture() + .GetAddressByteSize()); + return_valobj_sp = ValueObjectConstResult::Create( + &thread, return_compiler_type, ConstString(""), data); + } + } + } + } else if (byte_size <= vec_reg->byte_size * 2) { + const RegisterInfo *vec_reg2 = + reg_ctx->GetRegisterInfoByName("xmm1", 0); + if (vec_reg2) { + ProcessSP process_sp(thread.GetProcess()); + if (process_sp) { + std::unique_ptr<DataBufferHeap> heap_data_ap( + new DataBufferHeap(byte_size, 0)); + const ByteOrder byte_order = process_sp->GetByteOrder(); + RegisterValue reg_value; + RegisterValue reg_value2; + if (reg_ctx->ReadRegister(vec_reg, reg_value) && + reg_ctx->ReadRegister(vec_reg2, reg_value2)) { + + Error error; + if (reg_value.GetAsMemoryData(vec_reg, heap_data_ap->GetBytes(), + vec_reg->byte_size, byte_order, + error) && + reg_value2.GetAsMemoryData( + vec_reg2, heap_data_ap->GetBytes() + vec_reg->byte_size, + heap_data_ap->GetByteSize() - vec_reg->byte_size, + byte_order, error)) { + DataExtractor data(DataBufferSP(heap_data_ap.release()), + byte_order, process_sp->GetTarget() + .GetArchitecture() + .GetAddressByteSize()); + return_valobj_sp = ValueObjectConstResult::Create( + &thread, return_compiler_type, ConstString(""), data); } + } } + } } + } } - else // 'Decimal Floating Point' - { - //ToDo: Yet to be implemented - } - return return_valobj_sp; + } else // 'Decimal Floating Point' + { + // ToDo: Yet to be implemented + } + return return_valobj_sp; } -ValueObjectSP -ABISysV_i386::GetReturnValueObjectImpl (Thread &thread, CompilerType &return_compiler_type) const -{ - ValueObjectSP return_valobj_sp; - - if (!return_compiler_type) - return return_valobj_sp; +ValueObjectSP ABISysV_i386::GetReturnValueObjectImpl( + Thread &thread, CompilerType &return_compiler_type) const { + ValueObjectSP return_valobj_sp; - ExecutionContext exe_ctx (thread.shared_from_this()); - return_valobj_sp = GetReturnValueObjectSimple(thread, return_compiler_type); - if (return_valobj_sp) - return return_valobj_sp; - - RegisterContextSP reg_ctx_sp = thread.GetRegisterContext(); - if (!reg_ctx_sp) - return return_valobj_sp; + if (!return_compiler_type) + return return_valobj_sp; - if (return_compiler_type.IsAggregateType()) - { - unsigned eax_id = reg_ctx_sp->GetRegisterInfoByName("eax", 0)->kinds[eRegisterKindLLDB]; - lldb::addr_t storage_addr = (uint32_t)(thread.GetRegisterContext()->ReadRegisterAsUnsigned(eax_id, 0) & 0xffffffff); - return_valobj_sp = ValueObjectMemory::Create (&thread, - "", - Address (storage_addr, nullptr), - return_compiler_type); - } + ExecutionContext exe_ctx(thread.shared_from_this()); + return_valobj_sp = GetReturnValueObjectSimple(thread, return_compiler_type); + if (return_valobj_sp) + return return_valobj_sp; + RegisterContextSP reg_ctx_sp = thread.GetRegisterContext(); + if (!reg_ctx_sp) return return_valobj_sp; + + if (return_compiler_type.IsAggregateType()) { + unsigned eax_id = + reg_ctx_sp->GetRegisterInfoByName("eax", 0)->kinds[eRegisterKindLLDB]; + lldb::addr_t storage_addr = (uint32_t)( + thread.GetRegisterContext()->ReadRegisterAsUnsigned(eax_id, 0) & + 0xffffffff); + return_valobj_sp = ValueObjectMemory::Create( + &thread, "", Address(storage_addr, nullptr), return_compiler_type); + } + + return return_valobj_sp; } // This defines CFA as esp+4 // The saved pc is at CFA-4 (i.e. esp+0) // The saved esp is CFA+0 -bool -ABISysV_i386::CreateFunctionEntryUnwindPlan (UnwindPlan &unwind_plan) -{ - unwind_plan.Clear(); - unwind_plan.SetRegisterKind (eRegisterKindDWARF); - - uint32_t sp_reg_num = dwarf_esp; - uint32_t pc_reg_num = dwarf_eip; - - UnwindPlan::RowSP row(new UnwindPlan::Row); - row->GetCFAValue().SetIsRegisterPlusOffset(sp_reg_num, 4); - row->SetRegisterLocationToAtCFAPlusOffset(pc_reg_num, -4, false); - row->SetRegisterLocationToIsCFAPlusOffset(sp_reg_num, 0, true); - unwind_plan.AppendRow (row); - unwind_plan.SetSourceName ("i386 at-func-entry default"); - unwind_plan.SetSourcedFromCompiler (eLazyBoolNo); - return true; +bool ABISysV_i386::CreateFunctionEntryUnwindPlan(UnwindPlan &unwind_plan) { + unwind_plan.Clear(); + unwind_plan.SetRegisterKind(eRegisterKindDWARF); + + uint32_t sp_reg_num = dwarf_esp; + uint32_t pc_reg_num = dwarf_eip; + + UnwindPlan::RowSP row(new UnwindPlan::Row); + row->GetCFAValue().SetIsRegisterPlusOffset(sp_reg_num, 4); + row->SetRegisterLocationToAtCFAPlusOffset(pc_reg_num, -4, false); + row->SetRegisterLocationToIsCFAPlusOffset(sp_reg_num, 0, true); + unwind_plan.AppendRow(row); + unwind_plan.SetSourceName("i386 at-func-entry default"); + unwind_plan.SetSourcedFromCompiler(eLazyBoolNo); + return true; } // This defines CFA as ebp+8 @@ -806,104 +771,89 @@ ABISysV_i386::CreateFunctionEntryUnwindPlan (UnwindPlan &unwind_plan) // The saved ebp is at CFA-8 (i.e. ebp+0) // The saved esp is CFA+0 -bool -ABISysV_i386::CreateDefaultUnwindPlan (UnwindPlan &unwind_plan) -{ - unwind_plan.Clear(); - unwind_plan.SetRegisterKind (eRegisterKindDWARF); +bool ABISysV_i386::CreateDefaultUnwindPlan(UnwindPlan &unwind_plan) { + unwind_plan.Clear(); + unwind_plan.SetRegisterKind(eRegisterKindDWARF); - uint32_t fp_reg_num = dwarf_ebp; - uint32_t sp_reg_num = dwarf_esp; - uint32_t pc_reg_num = dwarf_eip; + uint32_t fp_reg_num = dwarf_ebp; + uint32_t sp_reg_num = dwarf_esp; + uint32_t pc_reg_num = dwarf_eip; - UnwindPlan::RowSP row(new UnwindPlan::Row); - const int32_t ptr_size = 4; + UnwindPlan::RowSP row(new UnwindPlan::Row); + const int32_t ptr_size = 4; - row->GetCFAValue().SetIsRegisterPlusOffset(fp_reg_num, 2 * ptr_size); - row->SetOffset (0); + row->GetCFAValue().SetIsRegisterPlusOffset(fp_reg_num, 2 * ptr_size); + row->SetOffset(0); - row->SetRegisterLocationToAtCFAPlusOffset(fp_reg_num, ptr_size * -2, true); - row->SetRegisterLocationToAtCFAPlusOffset(pc_reg_num, ptr_size * -1, true); - row->SetRegisterLocationToIsCFAPlusOffset(sp_reg_num, 0, true); + row->SetRegisterLocationToAtCFAPlusOffset(fp_reg_num, ptr_size * -2, true); + row->SetRegisterLocationToAtCFAPlusOffset(pc_reg_num, ptr_size * -1, true); + row->SetRegisterLocationToIsCFAPlusOffset(sp_reg_num, 0, true); - unwind_plan.AppendRow (row); - unwind_plan.SetSourceName ("i386 default unwind plan"); - unwind_plan.SetSourcedFromCompiler (eLazyBoolNo); - unwind_plan.SetUnwindPlanValidAtAllInstructions (eLazyBoolNo); - return true; + unwind_plan.AppendRow(row); + unwind_plan.SetSourceName("i386 default unwind plan"); + unwind_plan.SetSourcedFromCompiler(eLazyBoolNo); + unwind_plan.SetUnwindPlanValidAtAllInstructions(eLazyBoolNo); + return true; } // According to "Register Usage" in reference document (specified on top // of this source file) ebx, ebp, esi, edi and esp registers are preserved // i.e. non-volatile i.e. callee-saved on i386 -bool -ABISysV_i386::RegisterIsCalleeSaved (const RegisterInfo *reg_info) -{ - if (!reg_info) - return false; - - // Saved registers are ebx, ebp, esi, edi, esp, eip - const char *name = reg_info->name; - if (name[0] == 'e') - { - switch (name[1]) - { - case 'b': - if (name[2] == 'x' || name[2] == 'p') - return name[3] == '\0'; - break; - case 'd': - if (name[2] == 'i') - return name[3] == '\0'; - break; - case 'i': - if (name[2] == 'p') - return name[3] == '\0'; - break; - case 's': - if (name[2] == 'i' || name[2] == 'p') - return name[3] == '\0'; - break; - } +bool ABISysV_i386::RegisterIsCalleeSaved(const RegisterInfo *reg_info) { + if (!reg_info) + return false; + + // Saved registers are ebx, ebp, esi, edi, esp, eip + const char *name = reg_info->name; + if (name[0] == 'e') { + switch (name[1]) { + case 'b': + if (name[2] == 'x' || name[2] == 'p') + return name[3] == '\0'; + break; + case 'd': + if (name[2] == 'i') + return name[3] == '\0'; + break; + case 'i': + if (name[2] == 'p') + return name[3] == '\0'; + break; + case 's': + if (name[2] == 'i' || name[2] == 'p') + return name[3] == '\0'; + break; } + } - if (name[0] == 's' && name[1] == 'p' && name[2] == '\0') // sp - return true; - if (name[0] == 'f' && name[1] == 'p' && name[2] == '\0') // fp - return true; - if (name[0] == 'p' && name[1] == 'c' && name[2] == '\0') // pc - return true; + if (name[0] == 's' && name[1] == 'p' && name[2] == '\0') // sp + return true; + if (name[0] == 'f' && name[1] == 'p' && name[2] == '\0') // fp + return true; + if (name[0] == 'p' && name[1] == 'c' && name[2] == '\0') // pc + return true; - return false; + return false; } -void -ABISysV_i386::Initialize() -{ - PluginManager::RegisterPlugin (GetPluginNameStatic(), - "System V ABI for i386 targets", - CreateInstance); +void ABISysV_i386::Initialize() { + PluginManager::RegisterPlugin( + GetPluginNameStatic(), "System V ABI for i386 targets", CreateInstance); } -void -ABISysV_i386::Terminate() -{ - PluginManager::UnregisterPlugin (CreateInstance); +void ABISysV_i386::Terminate() { + PluginManager::UnregisterPlugin(CreateInstance); } //------------------------------------------------------------------ // PluginInterface protocol //------------------------------------------------------------------ -lldb_private::ConstString -ABISysV_i386::GetPluginNameStatic() -{ - static ConstString g_name("sysv-i386"); - return g_name; +lldb_private::ConstString ABISysV_i386::GetPluginNameStatic() { + static ConstString g_name("sysv-i386"); + return g_name; } -lldb_private::ConstString -ABISysV_i386::GetPluginName() -{ - return GetPluginNameStatic(); +lldb_private::ConstString ABISysV_i386::GetPluginName() { + return GetPluginNameStatic(); } diff --git a/source/Plugins/ABI/SysV-i386/ABISysV_i386.h b/source/Plugins/ABI/SysV-i386/ABISysV_i386.h index 2d0f097c328e..8d1d76b5dfd9 100644 --- a/source/Plugins/ABI/SysV-i386/ABISysV_i386.h +++ b/source/Plugins/ABI/SysV-i386/ABISysV_i386.h @@ -14,128 +14,104 @@ // C++ Includes // Other libraries and framework includes // Project includes -#include "lldb/lldb-private.h" #include "lldb/Target/ABI.h" +#include "lldb/lldb-private.h" -class ABISysV_i386 : - public lldb_private::ABI -{ +class ABISysV_i386 : public lldb_private::ABI { public: - ~ABISysV_i386() override = default; - - size_t - GetRedZoneSize () const override - { - return 0; // There is no red zone for i386 Architecture - } - - bool - PrepareTrivialCall (lldb_private::Thread &thread, - lldb::addr_t sp, - lldb::addr_t functionAddress, - lldb::addr_t returnAddress, - llvm::ArrayRef<lldb::addr_t> args) const override; - - bool - GetArgumentValues (lldb_private::Thread &thread, - lldb_private::ValueList &values) const override; - - lldb_private::Error - SetReturnValueObject(lldb::StackFrameSP &frame_sp, lldb::ValueObjectSP &new_value) override; - - lldb::ValueObjectSP - GetReturnValueObjectImpl (lldb_private::Thread &thread, - lldb_private::CompilerType &type) const override; - - bool - CreateFunctionEntryUnwindPlan (lldb_private::UnwindPlan &unwind_plan) override; - - bool - CreateDefaultUnwindPlan (lldb_private::UnwindPlan &unwind_plan) override; - - bool - RegisterIsVolatile (const lldb_private::RegisterInfo *reg_info) override - { - return !RegisterIsCalleeSaved (reg_info); - } - - // The SysV i386 ABI requires that stack frames be 16 byte aligned. - // When there is a trap handler on the stack, e.g. _sigtramp in userland - // code, we've seen that the stack pointer is often not aligned properly - // before the handler is invoked. This means that lldb will stop the unwind - // early -- before the function which caused the trap. - // - // To work around this, we relax that alignment to be just word-size (4-bytes). - // Whitelisting the trap handlers for user space would be easy (_sigtramp) but - // in other environments there can be a large number of different functions - // involved in async traps. - - // ToDo: When __m256 arguments are passed then stack frames should be - // 32 byte aligned. Decide what to do for 32 byte alignment checking - bool - CallFrameAddressIsValid (lldb::addr_t cfa) override - { - // Make sure the stack call frame addresses are 4 byte aligned - if (cfa & (4ull - 1ull)) - return false; // Not 4 byte aligned - if (cfa == 0) - return false; // Zero is not a valid stack address - return true; - } - - bool - CodeAddressIsValid (lldb::addr_t pc) override - { - // Check whether the address is a valid 32 bit address - return (pc <= UINT32_MAX); - } - - const lldb_private::RegisterInfo * - GetRegisterInfoArray (uint32_t &count) override; - - //------------------------------------------------------------------ - // Static Functions - //------------------------------------------------------------------ - - static void - Initialize(); - - static void - Terminate(); - - static lldb::ABISP - CreateInstance (const lldb_private::ArchSpec &arch); - - //------------------------------------------------------------------ - // PluginInterface protocol - //------------------------------------------------------------------ - - static lldb_private::ConstString - GetPluginNameStatic(); - - lldb_private::ConstString - GetPluginName() override; - - uint32_t - GetPluginVersion() override - { - return 1; - } + ~ABISysV_i386() override = default; + + size_t GetRedZoneSize() const override { + return 0; // There is no red zone for i386 Architecture + } + + bool PrepareTrivialCall(lldb_private::Thread &thread, lldb::addr_t sp, + lldb::addr_t functionAddress, + lldb::addr_t returnAddress, + llvm::ArrayRef<lldb::addr_t> args) const override; + + bool GetArgumentValues(lldb_private::Thread &thread, + lldb_private::ValueList &values) const override; + + lldb_private::Error + SetReturnValueObject(lldb::StackFrameSP &frame_sp, + lldb::ValueObjectSP &new_value) override; + + lldb::ValueObjectSP + GetReturnValueObjectImpl(lldb_private::Thread &thread, + lldb_private::CompilerType &type) const override; + + bool + CreateFunctionEntryUnwindPlan(lldb_private::UnwindPlan &unwind_plan) override; + + bool CreateDefaultUnwindPlan(lldb_private::UnwindPlan &unwind_plan) override; + + bool RegisterIsVolatile(const lldb_private::RegisterInfo *reg_info) override { + return !RegisterIsCalleeSaved(reg_info); + } + + // The SysV i386 ABI requires that stack frames be 16 byte aligned. + // When there is a trap handler on the stack, e.g. _sigtramp in userland + // code, we've seen that the stack pointer is often not aligned properly + // before the handler is invoked. This means that lldb will stop the unwind + // early -- before the function which caused the trap. + // + // To work around this, we relax that alignment to be just word-size + // (4-bytes). + // Whitelisting the trap handlers for user space would be easy (_sigtramp) but + // in other environments there can be a large number of different functions + // involved in async traps. + + // ToDo: When __m256 arguments are passed then stack frames should be + // 32 byte aligned. Decide what to do for 32 byte alignment checking + bool CallFrameAddressIsValid(lldb::addr_t cfa) override { + // Make sure the stack call frame addresses are 4 byte aligned + if (cfa & (4ull - 1ull)) + return false; // Not 4 byte aligned + if (cfa == 0) + return false; // Zero is not a valid stack address + return true; + } + + bool CodeAddressIsValid(lldb::addr_t pc) override { + // Check whether the address is a valid 32 bit address + return (pc <= UINT32_MAX); + } + + const lldb_private::RegisterInfo * + GetRegisterInfoArray(uint32_t &count) override; + + //------------------------------------------------------------------ + // Static Functions + //------------------------------------------------------------------ + + static void Initialize(); + + static void Terminate(); + + static lldb::ABISP CreateInstance(const lldb_private::ArchSpec &arch); + + //------------------------------------------------------------------ + // PluginInterface protocol + //------------------------------------------------------------------ + + static lldb_private::ConstString GetPluginNameStatic(); + + lldb_private::ConstString GetPluginName() override; + + uint32_t GetPluginVersion() override { return 1; } protected: - lldb::ValueObjectSP - GetReturnValueObjectSimple(lldb_private::Thread &thread, - lldb_private::CompilerType &ast_type) const; + lldb::ValueObjectSP + GetReturnValueObjectSimple(lldb_private::Thread &thread, + lldb_private::CompilerType &ast_type) const; - bool - RegisterIsCalleeSaved(const lldb_private::RegisterInfo *reg_info); + bool RegisterIsCalleeSaved(const lldb_private::RegisterInfo *reg_info); private: - ABISysV_i386() : - lldb_private::ABI() - { - // Call CreateInstance instead. - } + ABISysV_i386() : lldb_private::ABI() { + // Call CreateInstance instead. + } }; #endif // liblldb_ABISysV_i386_h_ diff --git a/source/Plugins/ABI/SysV-mips/ABISysV_mips.cpp b/source/Plugins/ABI/SysV-mips/ABISysV_mips.cpp index d6b57f9f3939..b97fffe3efa3 100644 --- a/source/Plugins/ABI/SysV-mips/ABISysV_mips.cpp +++ b/source/Plugins/ABI/SysV-mips/ABISysV_mips.cpp @@ -25,696 +25,1055 @@ #include "lldb/Core/RegisterValue.h" #include "lldb/Core/Value.h" #include "lldb/Core/ValueObjectConstResult.h" -#include "lldb/Core/ValueObjectRegister.h" #include "lldb/Core/ValueObjectMemory.h" +#include "lldb/Core/ValueObjectRegister.h" #include "lldb/Symbol/UnwindPlan.h" -#include "lldb/Target/Target.h" #include "lldb/Target/Process.h" #include "lldb/Target/RegisterContext.h" #include "lldb/Target/StackFrame.h" +#include "lldb/Target/Target.h" #include "lldb/Target/Thread.h" using namespace lldb; using namespace lldb_private; -enum dwarf_regnums -{ - dwarf_r0 = 0, - dwarf_r1, - dwarf_r2, - dwarf_r3, - dwarf_r4, - dwarf_r5, - dwarf_r6, - dwarf_r7, - dwarf_r8, - dwarf_r9, - dwarf_r10, - dwarf_r11, - dwarf_r12, - dwarf_r13, - dwarf_r14, - dwarf_r15, - dwarf_r16, - dwarf_r17, - dwarf_r18, - dwarf_r19, - dwarf_r20, - dwarf_r21, - dwarf_r22, - dwarf_r23, - dwarf_r24, - dwarf_r25, - dwarf_r26, - dwarf_r27, - dwarf_r28, - dwarf_r29, - dwarf_r30, - dwarf_r31, - dwarf_sr, - dwarf_lo, - dwarf_hi, - dwarf_bad, - dwarf_cause, - dwarf_pc +enum dwarf_regnums { + dwarf_r0 = 0, + dwarf_r1, + dwarf_r2, + dwarf_r3, + dwarf_r4, + dwarf_r5, + dwarf_r6, + dwarf_r7, + dwarf_r8, + dwarf_r9, + dwarf_r10, + dwarf_r11, + dwarf_r12, + dwarf_r13, + dwarf_r14, + dwarf_r15, + dwarf_r16, + dwarf_r17, + dwarf_r18, + dwarf_r19, + dwarf_r20, + dwarf_r21, + dwarf_r22, + dwarf_r23, + dwarf_r24, + dwarf_r25, + dwarf_r26, + dwarf_r27, + dwarf_r28, + dwarf_r29, + dwarf_r30, + dwarf_r31, + dwarf_sr, + dwarf_lo, + dwarf_hi, + dwarf_bad, + dwarf_cause, + dwarf_pc }; -static const RegisterInfo -g_register_infos[] = -{ - // NAME ALT SZ OFF ENCODING FORMAT EH_FRAME DWARF GENERIC PROCESS PLUGINS LLDB NATIVE VALUE REGS INVALIDATE REGS - // ======== ====== == === ============= =========== ============ ============== ============ ================= =================== ========== ================= - { "r0" , "zero", 4, 0, eEncodingUint, eFormatHex, { dwarf_r0, dwarf_r0, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "r1" , "AT", 4, 0, eEncodingUint, eFormatHex, { dwarf_r1, dwarf_r1, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "r2" , "v0", 4, 0, eEncodingUint, eFormatHex, { dwarf_r2, dwarf_r2, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "r3" , "v1", 4, 0, eEncodingUint, eFormatHex, { dwarf_r3, dwarf_r3, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "r4" , "arg1", 4, 0, eEncodingUint, eFormatHex, { dwarf_r4, dwarf_r4, LLDB_REGNUM_GENERIC_ARG1, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "r5" , "arg2", 4, 0, eEncodingUint, eFormatHex, { dwarf_r5, dwarf_r5, LLDB_REGNUM_GENERIC_ARG2, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "r6" , "arg3", 4, 0, eEncodingUint, eFormatHex, { dwarf_r6, dwarf_r6, LLDB_REGNUM_GENERIC_ARG3, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "r7" , "arg4", 4, 0, eEncodingUint, eFormatHex, { dwarf_r7, dwarf_r7, LLDB_REGNUM_GENERIC_ARG4, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "r8" , "arg5", 4, 0, eEncodingUint, eFormatHex, { dwarf_r8, dwarf_r8, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "r9" , "arg6", 4, 0, eEncodingUint, eFormatHex, { dwarf_r9, dwarf_r9, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "r10" , "arg7", 4, 0, eEncodingUint, eFormatHex, { dwarf_r10, dwarf_r10, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "r11" , "arg8", 4, 0, eEncodingUint, eFormatHex, { dwarf_r11, dwarf_r11, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "r12" , nullptr,4, 0, eEncodingUint, eFormatHex, { dwarf_r12, dwarf_r12, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "r13" , nullptr,4, 0, eEncodingUint, eFormatHex, { dwarf_r13, dwarf_r13, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "r14" , nullptr,4, 0, eEncodingUint, eFormatHex, { dwarf_r14, dwarf_r14, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "r15" , nullptr,4, 0, eEncodingUint, eFormatHex, { dwarf_r15, dwarf_r15, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "r16" , nullptr,4, 0, eEncodingUint, eFormatHex, { dwarf_r16, dwarf_r16, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "r17" , nullptr,4, 0, eEncodingUint, eFormatHex, { dwarf_r17, dwarf_r17, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "r18" , nullptr,4, 0, eEncodingUint, eFormatHex, { dwarf_r18, dwarf_r18, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "r19" , nullptr,4, 0, eEncodingUint, eFormatHex, { dwarf_r19, dwarf_r19, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "r20" , nullptr,4, 0, eEncodingUint, eFormatHex, { dwarf_r20, dwarf_r20, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "r21" , nullptr,4, 0, eEncodingUint, eFormatHex, { dwarf_r21, dwarf_r21, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "r22" , nullptr,4, 0, eEncodingUint, eFormatHex, { dwarf_r22, dwarf_r22, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "r23" , nullptr,4, 0, eEncodingUint, eFormatHex, { dwarf_r23, dwarf_r23, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "r24" , nullptr,4, 0, eEncodingUint, eFormatHex, { dwarf_r24, dwarf_r24, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "r25" , nullptr,4, 0, eEncodingUint, eFormatHex, { dwarf_r25, dwarf_r25, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "r26" , nullptr,4, 0, eEncodingUint, eFormatHex, { dwarf_r26, dwarf_r26, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "r27" , nullptr,4, 0, eEncodingUint, eFormatHex, { dwarf_r27, dwarf_r27, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "r28" , "gp", 4, 0, eEncodingUint, eFormatHex, { dwarf_r28, dwarf_r28, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "r29" , "sp", 4, 0, eEncodingUint, eFormatHex, { dwarf_r29, dwarf_r29, LLDB_REGNUM_GENERIC_SP, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "r30" , "fp", 4, 0, eEncodingUint, eFormatHex, { dwarf_r30, dwarf_r30, LLDB_REGNUM_GENERIC_FP, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "r31" , "ra", 4, 0, eEncodingUint, eFormatHex, { dwarf_r31, dwarf_r31, LLDB_REGNUM_GENERIC_RA, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "sr" , nullptr,4, 0, eEncodingUint, eFormatHex, { dwarf_sr, dwarf_sr, LLDB_REGNUM_GENERIC_FLAGS, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "lo" , nullptr,4, 0, eEncodingUint, eFormatHex, { dwarf_lo, dwarf_lo, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "hi" , nullptr,4, 0, eEncodingUint, eFormatHex, { dwarf_hi, dwarf_hi, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "bad" , nullptr,4, 0, eEncodingUint, eFormatHex, { dwarf_bad, dwarf_bad, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "cause" , nullptr,4, 0, eEncodingUint, eFormatHex, { dwarf_cause, dwarf_cause, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "pc" , nullptr,4, 0, eEncodingUint, eFormatHex, { dwarf_pc, dwarf_pc, LLDB_REGNUM_GENERIC_PC, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, +static const RegisterInfo g_register_infos[] = { + // NAME ALT SZ OFF ENCODING FORMAT EH_FRAME + // DWARF GENERIC PROCESS PLUGINS + // LLDB NATIVE VALUE REGS INVALIDATE REGS + // ======== ====== == === ============= =========== ============ + // ============== ============ ================= + // =================== ========== ================= + {"r0", + "zero", + 4, + 0, + eEncodingUint, + eFormatHex, + {dwarf_r0, dwarf_r0, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"r1", + "AT", + 4, + 0, + eEncodingUint, + eFormatHex, + {dwarf_r1, dwarf_r1, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"r2", + "v0", + 4, + 0, + eEncodingUint, + eFormatHex, + {dwarf_r2, dwarf_r2, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"r3", + "v1", + 4, + 0, + eEncodingUint, + eFormatHex, + {dwarf_r3, dwarf_r3, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"r4", + "arg1", + 4, + 0, + eEncodingUint, + eFormatHex, + {dwarf_r4, dwarf_r4, LLDB_REGNUM_GENERIC_ARG1, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"r5", + "arg2", + 4, + 0, + eEncodingUint, + eFormatHex, + {dwarf_r5, dwarf_r5, LLDB_REGNUM_GENERIC_ARG2, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"r6", + "arg3", + 4, + 0, + eEncodingUint, + eFormatHex, + {dwarf_r6, dwarf_r6, LLDB_REGNUM_GENERIC_ARG3, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"r7", + "arg4", + 4, + 0, + eEncodingUint, + eFormatHex, + {dwarf_r7, dwarf_r7, LLDB_REGNUM_GENERIC_ARG4, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"r8", + "arg5", + 4, + 0, + eEncodingUint, + eFormatHex, + {dwarf_r8, dwarf_r8, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"r9", + "arg6", + 4, + 0, + eEncodingUint, + eFormatHex, + {dwarf_r9, dwarf_r9, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"r10", + "arg7", + 4, + 0, + eEncodingUint, + eFormatHex, + {dwarf_r10, dwarf_r10, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"r11", + "arg8", + 4, + 0, + eEncodingUint, + eFormatHex, + {dwarf_r11, dwarf_r11, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"r12", + nullptr, + 4, + 0, + eEncodingUint, + eFormatHex, + {dwarf_r12, dwarf_r12, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"r13", + nullptr, + 4, + 0, + eEncodingUint, + eFormatHex, + {dwarf_r13, dwarf_r13, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"r14", + nullptr, + 4, + 0, + eEncodingUint, + eFormatHex, + {dwarf_r14, dwarf_r14, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"r15", + nullptr, + 4, + 0, + eEncodingUint, + eFormatHex, + {dwarf_r15, dwarf_r15, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"r16", + nullptr, + 4, + 0, + eEncodingUint, + eFormatHex, + {dwarf_r16, dwarf_r16, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"r17", + nullptr, + 4, + 0, + eEncodingUint, + eFormatHex, + {dwarf_r17, dwarf_r17, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"r18", + nullptr, + 4, + 0, + eEncodingUint, + eFormatHex, + {dwarf_r18, dwarf_r18, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"r19", + nullptr, + 4, + 0, + eEncodingUint, + eFormatHex, + {dwarf_r19, dwarf_r19, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"r20", + nullptr, + 4, + 0, + eEncodingUint, + eFormatHex, + {dwarf_r20, dwarf_r20, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"r21", + nullptr, + 4, + 0, + eEncodingUint, + eFormatHex, + {dwarf_r21, dwarf_r21, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"r22", + nullptr, + 4, + 0, + eEncodingUint, + eFormatHex, + {dwarf_r22, dwarf_r22, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"r23", + nullptr, + 4, + 0, + eEncodingUint, + eFormatHex, + {dwarf_r23, dwarf_r23, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"r24", + nullptr, + 4, + 0, + eEncodingUint, + eFormatHex, + {dwarf_r24, dwarf_r24, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"r25", + nullptr, + 4, + 0, + eEncodingUint, + eFormatHex, + {dwarf_r25, dwarf_r25, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"r26", + nullptr, + 4, + 0, + eEncodingUint, + eFormatHex, + {dwarf_r26, dwarf_r26, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"r27", + nullptr, + 4, + 0, + eEncodingUint, + eFormatHex, + {dwarf_r27, dwarf_r27, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"r28", + "gp", + 4, + 0, + eEncodingUint, + eFormatHex, + {dwarf_r28, dwarf_r28, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"r29", + "sp", + 4, + 0, + eEncodingUint, + eFormatHex, + {dwarf_r29, dwarf_r29, LLDB_REGNUM_GENERIC_SP, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"r30", + "fp", + 4, + 0, + eEncodingUint, + eFormatHex, + {dwarf_r30, dwarf_r30, LLDB_REGNUM_GENERIC_FP, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"r31", + "ra", + 4, + 0, + eEncodingUint, + eFormatHex, + {dwarf_r31, dwarf_r31, LLDB_REGNUM_GENERIC_RA, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"sr", + nullptr, + 4, + 0, + eEncodingUint, + eFormatHex, + {dwarf_sr, dwarf_sr, LLDB_REGNUM_GENERIC_FLAGS, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"lo", + nullptr, + 4, + 0, + eEncodingUint, + eFormatHex, + {dwarf_lo, dwarf_lo, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"hi", + nullptr, + 4, + 0, + eEncodingUint, + eFormatHex, + {dwarf_hi, dwarf_hi, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"bad", + nullptr, + 4, + 0, + eEncodingUint, + eFormatHex, + {dwarf_bad, dwarf_bad, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"cause", + nullptr, + 4, + 0, + eEncodingUint, + eFormatHex, + {dwarf_cause, dwarf_cause, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"pc", + nullptr, + 4, + 0, + eEncodingUint, + eFormatHex, + {dwarf_pc, dwarf_pc, LLDB_REGNUM_GENERIC_PC, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, }; -static const uint32_t k_num_register_infos = llvm::array_lengthof(g_register_infos); +static const uint32_t k_num_register_infos = + llvm::array_lengthof(g_register_infos); const lldb_private::RegisterInfo * -ABISysV_mips::GetRegisterInfoArray (uint32_t &count) -{ - count = k_num_register_infos; - return g_register_infos; +ABISysV_mips::GetRegisterInfoArray(uint32_t &count) { + count = k_num_register_infos; + return g_register_infos; } -size_t -ABISysV_mips::GetRedZoneSize () const -{ - return 0; -} +size_t ABISysV_mips::GetRedZoneSize() const { return 0; } //------------------------------------------------------------------ // Static Functions //------------------------------------------------------------------ ABISP -ABISysV_mips::CreateInstance (const ArchSpec &arch) -{ - static ABISP g_abi_sp; - const llvm::Triple::ArchType arch_type = arch.GetTriple().getArch(); - if ((arch_type == llvm::Triple::mips) || - (arch_type == llvm::Triple::mipsel)) - { - if (!g_abi_sp) - g_abi_sp.reset (new ABISysV_mips); - return g_abi_sp; - } - return ABISP(); +ABISysV_mips::CreateInstance(const ArchSpec &arch) { + static ABISP g_abi_sp; + const llvm::Triple::ArchType arch_type = arch.GetTriple().getArch(); + if ((arch_type == llvm::Triple::mips) || + (arch_type == llvm::Triple::mipsel)) { + if (!g_abi_sp) + g_abi_sp.reset(new ABISysV_mips); + return g_abi_sp; + } + return ABISP(); } -bool -ABISysV_mips::PrepareTrivialCall (Thread &thread, - addr_t sp, - addr_t func_addr, - addr_t return_addr, - llvm::ArrayRef<addr_t> args) const -{ - Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS)); +bool ABISysV_mips::PrepareTrivialCall(Thread &thread, addr_t sp, + addr_t func_addr, addr_t return_addr, + llvm::ArrayRef<addr_t> args) const { + Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS)); + + if (log) { + StreamString s; + s.Printf("ABISysV_mips::PrepareTrivialCall (tid = 0x%" PRIx64 + ", sp = 0x%" PRIx64 ", func_addr = 0x%" PRIx64 + ", return_addr = 0x%" PRIx64, + thread.GetID(), (uint64_t)sp, (uint64_t)func_addr, + (uint64_t)return_addr); + + for (size_t i = 0; i < args.size(); ++i) + s.Printf(", arg%zd = 0x%" PRIx64, i + 1, args[i]); + s.PutCString(")"); + log->PutString(s.GetString()); + } + + RegisterContext *reg_ctx = thread.GetRegisterContext().get(); + if (!reg_ctx) + return false; - if (log) - { - StreamString s; - s.Printf("ABISysV_mips::PrepareTrivialCall (tid = 0x%" PRIx64 ", sp = 0x%" PRIx64 ", func_addr = 0x%" PRIx64 ", return_addr = 0x%" PRIx64, - thread.GetID(), - (uint64_t)sp, - (uint64_t)func_addr, - (uint64_t)return_addr); - - for (size_t i = 0; i < args.size(); ++i) - s.Printf (", arg%zd = 0x%" PRIx64, i + 1, args[i]); - s.PutCString (")"); - log->PutCString(s.GetString().c_str()); - } + const RegisterInfo *reg_info = nullptr; - RegisterContext *reg_ctx = thread.GetRegisterContext().get(); - if (!reg_ctx) - return false; + RegisterValue reg_value; - const RegisterInfo *reg_info = nullptr; + // Argument registers + const char *reg_names[] = {"r4", "r5", "r6", "r7"}; - RegisterValue reg_value; + llvm::ArrayRef<addr_t>::iterator ai = args.begin(), ae = args.end(); - // Argument registers - const char *reg_names[] = { "r4", "r5", "r6", "r7" }; + // Write arguments to registers + for (size_t i = 0; i < llvm::array_lengthof(reg_names); ++i) { + if (ai == ae) + break; - llvm::ArrayRef<addr_t>::iterator ai = args.begin(), ae = args.end(); + reg_info = reg_ctx->GetRegisterInfo(eRegisterKindGeneric, + LLDB_REGNUM_GENERIC_ARG1 + i); + if (log) + log->Printf("About to write arg%zd (0x%" PRIx64 ") into %s", i + 1, + args[i], reg_info->name); - // Write arguments to registers - for (size_t i = 0; i < llvm::array_lengthof(reg_names); ++i) - { - if (ai == ae) - break; + if (!reg_ctx->WriteRegisterFromUnsigned(reg_info, args[i])) + return false; - reg_info = reg_ctx->GetRegisterInfo(eRegisterKindGeneric, LLDB_REGNUM_GENERIC_ARG1 + i); - if (log) - log->Printf("About to write arg%zd (0x%" PRIx64 ") into %s", i + 1, args[i], reg_info->name); + ++ai; + } - if (!reg_ctx->WriteRegisterFromUnsigned(reg_info, args[i])) - return false; + // If we have more than 4 arguments --Spill onto the stack + if (ai != ae) { + // No of arguments to go on stack + size_t num_stack_regs = args.size(); - ++ai; - } + // Allocate needed space for args on the stack + sp -= (num_stack_regs * 4); - // If we have more than 4 arguments --Spill onto the stack - if (ai != ae) - { - // No of arguments to go on stack - size_t num_stack_regs = args.size(); - - // Allocate needed space for args on the stack - sp -= (num_stack_regs * 4); - - // Keep the stack 8 byte aligned - sp &= ~(8ull-1ull); - - // just using arg1 to get the right size - const RegisterInfo *reg_info = reg_ctx->GetRegisterInfo(eRegisterKindGeneric, LLDB_REGNUM_GENERIC_ARG1); - - addr_t arg_pos = sp+16; - - size_t i = 4; - for (; ai != ae; ++ai) - { - reg_value.SetUInt32(*ai); - if (log) - log->Printf("About to write arg%zd (0x%" PRIx64 ") at 0x%" PRIx64 "", i+1, args[i], arg_pos); - - if (reg_ctx->WriteRegisterValueToMemory(reg_info, arg_pos, reg_info->byte_size, reg_value).Fail()) - return false; - arg_pos += reg_info->byte_size; - i++; - } - } + // Keep the stack 8 byte aligned + sp &= ~(8ull - 1ull); - Error error; - const RegisterInfo *pc_reg_info = reg_ctx->GetRegisterInfo (eRegisterKindGeneric, LLDB_REGNUM_GENERIC_PC); - const RegisterInfo *sp_reg_info = reg_ctx->GetRegisterInfo (eRegisterKindGeneric, LLDB_REGNUM_GENERIC_SP); - const RegisterInfo *ra_reg_info = reg_ctx->GetRegisterInfo (eRegisterKindGeneric, LLDB_REGNUM_GENERIC_RA); - const RegisterInfo *r25_info = reg_ctx->GetRegisterInfoByName("r25", 0); - const RegisterInfo *r0_info = reg_ctx->GetRegisterInfoByName("zero", 0); + // just using arg1 to get the right size + const RegisterInfo *reg_info = reg_ctx->GetRegisterInfo( + eRegisterKindGeneric, LLDB_REGNUM_GENERIC_ARG1); - if (log) - log->Printf("Writing R0: 0x%" PRIx64, (uint64_t)0); + addr_t arg_pos = sp + 16; + + size_t i = 4; + for (; ai != ae; ++ai) { + reg_value.SetUInt32(*ai); + if (log) + log->Printf("About to write arg%zd (0x%" PRIx64 ") at 0x%" PRIx64 "", + i + 1, args[i], arg_pos); - /* Write r0 with 0, in case we are stopped in syscall, - * such setting prevents automatic decrement of the PC. - * This clears the bug 23659 for MIPS. - */ - if (!reg_ctx->WriteRegisterFromUnsigned (r0_info, (uint64_t)0)) + if (reg_ctx + ->WriteRegisterValueToMemory(reg_info, arg_pos, + reg_info->byte_size, reg_value) + .Fail()) return false; + arg_pos += reg_info->byte_size; + i++; + } + } + + Error error; + const RegisterInfo *pc_reg_info = + reg_ctx->GetRegisterInfo(eRegisterKindGeneric, LLDB_REGNUM_GENERIC_PC); + const RegisterInfo *sp_reg_info = + reg_ctx->GetRegisterInfo(eRegisterKindGeneric, LLDB_REGNUM_GENERIC_SP); + const RegisterInfo *ra_reg_info = + reg_ctx->GetRegisterInfo(eRegisterKindGeneric, LLDB_REGNUM_GENERIC_RA); + const RegisterInfo *r25_info = reg_ctx->GetRegisterInfoByName("r25", 0); + const RegisterInfo *r0_info = reg_ctx->GetRegisterInfoByName("zero", 0); + + if (log) + log->Printf("Writing R0: 0x%" PRIx64, (uint64_t)0); + + /* Write r0 with 0, in case we are stopped in syscall, + * such setting prevents automatic decrement of the PC. + * This clears the bug 23659 for MIPS. + */ + if (!reg_ctx->WriteRegisterFromUnsigned(r0_info, (uint64_t)0)) + return false; - if (log) - log->Printf("Writing SP: 0x%" PRIx64, (uint64_t)sp); + if (log) + log->Printf("Writing SP: 0x%" PRIx64, (uint64_t)sp); - // Set "sp" to the requested value - if (!reg_ctx->WriteRegisterFromUnsigned (sp_reg_info, sp)) - return false; + // Set "sp" to the requested value + if (!reg_ctx->WriteRegisterFromUnsigned(sp_reg_info, sp)) + return false; - if (log) - log->Printf("Writing RA: 0x%" PRIx64, (uint64_t)return_addr); + if (log) + log->Printf("Writing RA: 0x%" PRIx64, (uint64_t)return_addr); - // Set "ra" to the return address - if (!reg_ctx->WriteRegisterFromUnsigned (ra_reg_info, return_addr)) - return false; + // Set "ra" to the return address + if (!reg_ctx->WriteRegisterFromUnsigned(ra_reg_info, return_addr)) + return false; - if (log) - log->Printf("Writing PC: 0x%" PRIx64, (uint64_t)func_addr); + if (log) + log->Printf("Writing PC: 0x%" PRIx64, (uint64_t)func_addr); - // Set pc to the address of the called function. - if (!reg_ctx->WriteRegisterFromUnsigned (pc_reg_info, func_addr)) - return false; - - if (log) - log->Printf("Writing r25: 0x%" PRIx64, (uint64_t)func_addr); - - // All callers of position independent functions must place the address of the called function in t9 (r25) - if (!reg_ctx->WriteRegisterFromUnsigned (r25_info, func_addr)) - return false; - - return true; -} + // Set pc to the address of the called function. + if (!reg_ctx->WriteRegisterFromUnsigned(pc_reg_info, func_addr)) + return false; + + if (log) + log->Printf("Writing r25: 0x%" PRIx64, (uint64_t)func_addr); -bool -ABISysV_mips::GetArgumentValues (Thread &thread, ValueList &values) const -{ + // All callers of position independent functions must place the address of the + // called function in t9 (r25) + if (!reg_ctx->WriteRegisterFromUnsigned(r25_info, func_addr)) return false; + + return true; } -Error -ABISysV_mips::SetReturnValueObject(lldb::StackFrameSP &frame_sp, lldb::ValueObjectSP &new_value_sp) -{ - Error error; - if (!new_value_sp) - { - error.SetErrorString("Empty value object for return value."); - return error; - } +bool ABISysV_mips::GetArgumentValues(Thread &thread, ValueList &values) const { + return false; +} - CompilerType compiler_type = new_value_sp->GetCompilerType(); - if (!compiler_type) - { - error.SetErrorString ("Null clang type for return value."); - return error; - } +Error ABISysV_mips::SetReturnValueObject(lldb::StackFrameSP &frame_sp, + lldb::ValueObjectSP &new_value_sp) { + Error error; + if (!new_value_sp) { + error.SetErrorString("Empty value object for return value."); + return error; + } - Thread *thread = frame_sp->GetThread().get(); + CompilerType compiler_type = new_value_sp->GetCompilerType(); + if (!compiler_type) { + error.SetErrorString("Null clang type for return value."); + return error; + } + + Thread *thread = frame_sp->GetThread().get(); + + bool is_signed; + uint32_t count; + bool is_complex; + + RegisterContext *reg_ctx = thread->GetRegisterContext().get(); + + bool set_it_simple = false; + if (compiler_type.IsIntegerOrEnumerationType(is_signed) || + compiler_type.IsPointerType()) { + DataExtractor data; + Error data_error; + size_t num_bytes = new_value_sp->GetData(data, data_error); + if (data_error.Fail()) { + error.SetErrorStringWithFormat( + "Couldn't convert return value to raw data: %s", + data_error.AsCString()); + return error; + } - bool is_signed; - uint32_t count; - bool is_complex; + lldb::offset_t offset = 0; + if (num_bytes <= 8) { + const RegisterInfo *r2_info = reg_ctx->GetRegisterInfoByName("r2", 0); + if (num_bytes <= 4) { + uint32_t raw_value = data.GetMaxU32(&offset, num_bytes); - RegisterContext *reg_ctx = thread->GetRegisterContext().get(); + if (reg_ctx->WriteRegisterFromUnsigned(r2_info, raw_value)) + set_it_simple = true; + } else { + uint32_t raw_value = data.GetMaxU32(&offset, 4); - bool set_it_simple = false; - if (compiler_type.IsIntegerOrEnumerationType (is_signed) || compiler_type.IsPointerType()) - { - DataExtractor data; - Error data_error; - size_t num_bytes = new_value_sp->GetData(data, data_error); - if (data_error.Fail()) - { - error.SetErrorStringWithFormat("Couldn't convert return value to raw data: %s", data_error.AsCString()); - return error; - } + if (reg_ctx->WriteRegisterFromUnsigned(r2_info, raw_value)) { + const RegisterInfo *r3_info = reg_ctx->GetRegisterInfoByName("r3", 0); + uint32_t raw_value = data.GetMaxU32(&offset, num_bytes - offset); - lldb::offset_t offset = 0; - if (num_bytes <= 8) - { - const RegisterInfo *r2_info = reg_ctx->GetRegisterInfoByName("r2", 0); - if (num_bytes <= 4) - { - uint32_t raw_value = data.GetMaxU32(&offset, num_bytes); - - if (reg_ctx->WriteRegisterFromUnsigned (r2_info, raw_value)) - set_it_simple = true; - } - else - { - uint32_t raw_value = data.GetMaxU32(&offset, 4); - - if (reg_ctx->WriteRegisterFromUnsigned (r2_info, raw_value)) - { - const RegisterInfo *r3_info = reg_ctx->GetRegisterInfoByName("r3", 0); - uint32_t raw_value = data.GetMaxU32(&offset, num_bytes - offset); - - if (reg_ctx->WriteRegisterFromUnsigned (r3_info, raw_value)) - set_it_simple = true; - } - } + if (reg_ctx->WriteRegisterFromUnsigned(r3_info, raw_value)) + set_it_simple = true; } - else - { - error.SetErrorString("We don't support returning longer than 64 bit integer values at present."); - } - } - else if (compiler_type.IsFloatingPointType (count, is_complex)) - { - if (is_complex) - error.SetErrorString ("We don't support returning complex values at present"); - else - error.SetErrorString ("We don't support returning float values at present"); + } + } else { + error.SetErrorString("We don't support returning longer than 64 bit " + "integer values at present."); } + } else if (compiler_type.IsFloatingPointType(count, is_complex)) { + if (is_complex) + error.SetErrorString( + "We don't support returning complex values at present"); + else + error.SetErrorString( + "We don't support returning float values at present"); + } - if (!set_it_simple) - error.SetErrorString ("We only support setting simple integer return types at present."); + if (!set_it_simple) + error.SetErrorString( + "We only support setting simple integer return types at present."); - return error; + return error; } -ValueObjectSP -ABISysV_mips::GetReturnValueObjectSimple (Thread &thread, CompilerType &return_compiler_type) const -{ - ValueObjectSP return_valobj_sp; - return return_valobj_sp; +ValueObjectSP ABISysV_mips::GetReturnValueObjectSimple( + Thread &thread, CompilerType &return_compiler_type) const { + ValueObjectSP return_valobj_sp; + return return_valobj_sp; } -ValueObjectSP -ABISysV_mips::GetReturnValueObjectImpl (Thread &thread, CompilerType &return_compiler_type) const -{ - ValueObjectSP return_valobj_sp; - Value value; +ValueObjectSP ABISysV_mips::GetReturnValueObjectImpl( + Thread &thread, CompilerType &return_compiler_type) const { + ValueObjectSP return_valobj_sp; + Value value; - if (!return_compiler_type) - return return_valobj_sp; + if (!return_compiler_type) + return return_valobj_sp; - ExecutionContext exe_ctx (thread.shared_from_this()); - if (exe_ctx.GetTargetPtr() == nullptr || exe_ctx.GetProcessPtr() == nullptr) - return return_valobj_sp; + ExecutionContext exe_ctx(thread.shared_from_this()); + if (exe_ctx.GetTargetPtr() == nullptr || exe_ctx.GetProcessPtr() == nullptr) + return return_valobj_sp; - Target *target = exe_ctx.GetTargetPtr(); - const ArchSpec target_arch = target->GetArchitecture(); - ByteOrder target_byte_order = target_arch.GetByteOrder(); - value.SetCompilerType(return_compiler_type); - uint32_t fp_flag = target_arch.GetFlags() & lldb_private::ArchSpec::eMIPS_ABI_FP_mask; + Target *target = exe_ctx.GetTargetPtr(); + const ArchSpec target_arch = target->GetArchitecture(); + ByteOrder target_byte_order = target_arch.GetByteOrder(); + value.SetCompilerType(return_compiler_type); + uint32_t fp_flag = + target_arch.GetFlags() & lldb_private::ArchSpec::eMIPS_ABI_FP_mask; - RegisterContext *reg_ctx = thread.GetRegisterContext().get(); - if (!reg_ctx) - return return_valobj_sp; - - bool is_signed = false; - bool is_complex = false; - uint32_t count = 0; - - // In MIPS register "r2" (v0) holds the integer function return values - const RegisterInfo *r2_reg_info = reg_ctx->GetRegisterInfoByName("r2", 0); - size_t bit_width = return_compiler_type.GetBitSize(&thread); - if (return_compiler_type.IsIntegerOrEnumerationType (is_signed)) - { - switch (bit_width) - { - default: - return return_valobj_sp; - case 64: - { - const RegisterInfo *r3_reg_info = reg_ctx->GetRegisterInfoByName("r3", 0); - uint64_t raw_value; - raw_value = reg_ctx->ReadRegisterAsUnsigned(r2_reg_info, 0) & UINT32_MAX; - raw_value |= ((uint64_t)(reg_ctx->ReadRegisterAsUnsigned(r3_reg_info, 0) & UINT32_MAX)) << 32; - if (is_signed) - value.GetScalar() = (int64_t)raw_value; - else - value.GetScalar() = (uint64_t)raw_value; - } - break; - case 32: - if (is_signed) - value.GetScalar() = (int32_t)(reg_ctx->ReadRegisterAsUnsigned(r2_reg_info, 0) & UINT32_MAX); - else - value.GetScalar() = (uint32_t)(reg_ctx->ReadRegisterAsUnsigned(r2_reg_info, 0) & UINT32_MAX); - break; - case 16: - if (is_signed) - value.GetScalar() = (int16_t)(reg_ctx->ReadRegisterAsUnsigned(r2_reg_info, 0) & UINT16_MAX); - else - value.GetScalar() = (uint16_t)(reg_ctx->ReadRegisterAsUnsigned(r2_reg_info, 0) & UINT16_MAX); - break; - case 8: - if (is_signed) - value.GetScalar() = (int8_t)(reg_ctx->ReadRegisterAsUnsigned(r2_reg_info, 0) & UINT8_MAX); - else - value.GetScalar() = (uint8_t)(reg_ctx->ReadRegisterAsUnsigned(r2_reg_info, 0) & UINT8_MAX); - break; - } - } - else if (return_compiler_type.IsPointerType ()) - { - uint32_t ptr = thread.GetRegisterContext()->ReadRegisterAsUnsigned(r2_reg_info, 0) & UINT32_MAX; - value.GetScalar() = ptr; + RegisterContext *reg_ctx = thread.GetRegisterContext().get(); + if (!reg_ctx) + return return_valobj_sp; + + bool is_signed = false; + bool is_complex = false; + uint32_t count = 0; + + // In MIPS register "r2" (v0) holds the integer function return values + const RegisterInfo *r2_reg_info = reg_ctx->GetRegisterInfoByName("r2", 0); + size_t bit_width = return_compiler_type.GetBitSize(&thread); + if (return_compiler_type.IsIntegerOrEnumerationType(is_signed)) { + switch (bit_width) { + default: + return return_valobj_sp; + case 64: { + const RegisterInfo *r3_reg_info = reg_ctx->GetRegisterInfoByName("r3", 0); + uint64_t raw_value; + raw_value = reg_ctx->ReadRegisterAsUnsigned(r2_reg_info, 0) & UINT32_MAX; + raw_value |= ((uint64_t)(reg_ctx->ReadRegisterAsUnsigned(r3_reg_info, 0) & + UINT32_MAX)) + << 32; + if (is_signed) + value.GetScalar() = (int64_t)raw_value; + else + value.GetScalar() = (uint64_t)raw_value; + } break; + case 32: + if (is_signed) + value.GetScalar() = (int32_t)( + reg_ctx->ReadRegisterAsUnsigned(r2_reg_info, 0) & UINT32_MAX); + else + value.GetScalar() = (uint32_t)( + reg_ctx->ReadRegisterAsUnsigned(r2_reg_info, 0) & UINT32_MAX); + break; + case 16: + if (is_signed) + value.GetScalar() = (int16_t)( + reg_ctx->ReadRegisterAsUnsigned(r2_reg_info, 0) & UINT16_MAX); + else + value.GetScalar() = (uint16_t)( + reg_ctx->ReadRegisterAsUnsigned(r2_reg_info, 0) & UINT16_MAX); + break; + case 8: + if (is_signed) + value.GetScalar() = (int8_t)( + reg_ctx->ReadRegisterAsUnsigned(r2_reg_info, 0) & UINT8_MAX); + else + value.GetScalar() = (uint8_t)( + reg_ctx->ReadRegisterAsUnsigned(r2_reg_info, 0) & UINT8_MAX); + break; } - else if (return_compiler_type.IsAggregateType ()) - { - // Structure/Vector is always passed in memory and pointer to that memory is passed in r2. - uint64_t mem_address = reg_ctx->ReadRegisterAsUnsigned(reg_ctx->GetRegisterInfoByName("r2", 0), 0); - // We have got the address. Create a memory object out of it - return_valobj_sp = ValueObjectMemory::Create(&thread, - "", - Address(mem_address, nullptr), - return_compiler_type); + } else if (return_compiler_type.IsPointerType()) { + uint32_t ptr = + thread.GetRegisterContext()->ReadRegisterAsUnsigned(r2_reg_info, 0) & + UINT32_MAX; + value.GetScalar() = ptr; + } else if (return_compiler_type.IsAggregateType()) { + // Structure/Vector is always passed in memory and pointer to that memory is + // passed in r2. + uint64_t mem_address = reg_ctx->ReadRegisterAsUnsigned( + reg_ctx->GetRegisterInfoByName("r2", 0), 0); + // We have got the address. Create a memory object out of it + return_valobj_sp = ValueObjectMemory::Create( + &thread, "", Address(mem_address, nullptr), return_compiler_type); + return return_valobj_sp; + } else if (return_compiler_type.IsFloatingPointType(count, is_complex)) { + if (IsSoftFloat(fp_flag)) { + uint64_t raw_value = reg_ctx->ReadRegisterAsUnsigned(r2_reg_info, 0); + if (count != 1 && is_complex) return return_valobj_sp; + switch (bit_width) { + default: + return return_valobj_sp; + case 32: + static_assert(sizeof(float) == sizeof(uint32_t), ""); + value.GetScalar() = *((float *)(&raw_value)); + break; + case 64: + static_assert(sizeof(double) == sizeof(uint64_t), ""); + const RegisterInfo *r3_reg_info = + reg_ctx->GetRegisterInfoByName("r3", 0); + if (target_byte_order == eByteOrderLittle) + raw_value = + ((reg_ctx->ReadRegisterAsUnsigned(r3_reg_info, 0)) << 32) | + raw_value; + else + raw_value = (raw_value << 32) | + reg_ctx->ReadRegisterAsUnsigned(r3_reg_info, 0); + value.GetScalar() = *((double *)(&raw_value)); + break; + } } - else if (return_compiler_type.IsFloatingPointType (count, is_complex)) - { - if (IsSoftFloat (fp_flag)) - { - uint64_t raw_value = reg_ctx->ReadRegisterAsUnsigned(r2_reg_info, 0); - if (count != 1 && is_complex) - return return_valobj_sp; - switch (bit_width) - { - default: - return return_valobj_sp; - case 32: - static_assert(sizeof(float) == sizeof(uint32_t), ""); - value.GetScalar() = *((float *)(&raw_value)); - break; - case 64: - static_assert(sizeof(double) == sizeof(uint64_t), ""); - const RegisterInfo *r3_reg_info = reg_ctx->GetRegisterInfoByName("r3", 0); - if (target_byte_order == eByteOrderLittle) - raw_value = ((reg_ctx->ReadRegisterAsUnsigned(r3_reg_info, 0)) << 32) | raw_value; - else - raw_value = (raw_value << 32) | reg_ctx->ReadRegisterAsUnsigned(r3_reg_info, 0); - value.GetScalar() = *((double *)(&raw_value)); - break; - } + + else { + const RegisterInfo *f0_info = reg_ctx->GetRegisterInfoByName("f0", 0); + RegisterValue f0_value; + DataExtractor f0_data; + reg_ctx->ReadRegister(f0_info, f0_value); + f0_value.GetData(f0_data); + lldb::offset_t offset = 0; + + if (count == 1 && !is_complex) { + switch (bit_width) { + default: + return return_valobj_sp; + case 64: { + static_assert(sizeof(double) == sizeof(uint64_t), ""); + const RegisterInfo *f1_info = reg_ctx->GetRegisterInfoByName("f1", 0); + RegisterValue f1_value; + DataExtractor f1_data; + reg_ctx->ReadRegister(f1_info, f1_value); + DataExtractor *copy_from_extractor = nullptr; + DataBufferSP data_sp(new DataBufferHeap(8, 0)); + DataExtractor return_ext( + data_sp, target_byte_order, + target->GetArchitecture().GetAddressByteSize()); + + if (target_byte_order == eByteOrderLittle) { + copy_from_extractor = &f0_data; + copy_from_extractor->CopyByteOrderedData( + offset, 4, data_sp->GetBytes(), 4, target_byte_order); + f1_value.GetData(f1_data); + copy_from_extractor = &f1_data; + copy_from_extractor->CopyByteOrderedData( + offset, 4, data_sp->GetBytes() + 4, 4, target_byte_order); + } else { + copy_from_extractor = &f0_data; + copy_from_extractor->CopyByteOrderedData( + offset, 4, data_sp->GetBytes() + 4, 4, target_byte_order); + f1_value.GetData(f1_data); + copy_from_extractor = &f1_data; + copy_from_extractor->CopyByteOrderedData( + offset, 4, data_sp->GetBytes(), 4, target_byte_order); + } + value.GetScalar() = (double)return_ext.GetDouble(&offset); + break; } - - else - { - const RegisterInfo *f0_info = reg_ctx->GetRegisterInfoByName("f0", 0); - RegisterValue f0_value; - DataExtractor f0_data; - reg_ctx->ReadRegister (f0_info, f0_value); - f0_value.GetData(f0_data); - lldb::offset_t offset = 0; - - if (count == 1 && !is_complex) - { - switch (bit_width) - { - default: - return return_valobj_sp; - case 64: - { - static_assert(sizeof(double) == sizeof(uint64_t), ""); - const RegisterInfo *f1_info = reg_ctx->GetRegisterInfoByName("f1", 0); - RegisterValue f1_value; - DataExtractor f1_data; - reg_ctx->ReadRegister (f1_info, f1_value); - DataExtractor *copy_from_extractor = nullptr; - DataBufferSP data_sp (new DataBufferHeap(8, 0)); - DataExtractor return_ext (data_sp, - target_byte_order, - target->GetArchitecture().GetAddressByteSize()); - - if (target_byte_order == eByteOrderLittle) - { - copy_from_extractor = &f0_data; - copy_from_extractor->CopyByteOrderedData (offset, - 4, - data_sp->GetBytes(), - 4, - target_byte_order); - f1_value.GetData(f1_data); - copy_from_extractor = &f1_data; - copy_from_extractor->CopyByteOrderedData (offset, - 4, - data_sp->GetBytes() + 4, - 4, - target_byte_order); - } - else - { - copy_from_extractor = &f0_data; - copy_from_extractor->CopyByteOrderedData (offset, - 4, - data_sp->GetBytes() + 4, - 4, - target_byte_order); - f1_value.GetData(f1_data); - copy_from_extractor = &f1_data; - copy_from_extractor->CopyByteOrderedData (offset, - 4, - data_sp->GetBytes(), - 4, - target_byte_order); - } - value.GetScalar() = (double) return_ext.GetDouble(&offset); - break; - } - case 32: - { - static_assert(sizeof(float) == sizeof(uint32_t), ""); - value.GetScalar() = (float) f0_data.GetFloat(&offset); - break; - } - } - } - else - { - // not handled yet - return return_valobj_sp; - } + case 32: { + static_assert(sizeof(float) == sizeof(uint32_t), ""); + value.GetScalar() = (float)f0_data.GetFloat(&offset); + break; } - } - else - { + } + } else { // not handled yet return return_valobj_sp; + } } - - // If we get here, we have a valid Value, so make our ValueObject out of it: - - return_valobj_sp = ValueObjectConstResult::Create(thread.GetStackFrameAtIndex(0).get(), - value, - ConstString("")); + } else { + // not handled yet return return_valobj_sp; + } + + // If we get here, we have a valid Value, so make our ValueObject out of it: + + return_valobj_sp = ValueObjectConstResult::Create( + thread.GetStackFrameAtIndex(0).get(), value, ConstString("")); + return return_valobj_sp; } -bool -ABISysV_mips::CreateFunctionEntryUnwindPlan (UnwindPlan &unwind_plan) -{ - unwind_plan.Clear(); - unwind_plan.SetRegisterKind (eRegisterKindDWARF); +bool ABISysV_mips::CreateFunctionEntryUnwindPlan(UnwindPlan &unwind_plan) { + unwind_plan.Clear(); + unwind_plan.SetRegisterKind(eRegisterKindDWARF); - UnwindPlan::RowSP row(new UnwindPlan::Row); + UnwindPlan::RowSP row(new UnwindPlan::Row); - // Our Call Frame Address is the stack pointer value - row->GetCFAValue().SetIsRegisterPlusOffset(dwarf_r29, 0); + // Our Call Frame Address is the stack pointer value + row->GetCFAValue().SetIsRegisterPlusOffset(dwarf_r29, 0); - // The previous PC is in the RA - row->SetRegisterLocationToRegister(dwarf_pc, dwarf_r31, true); - unwind_plan.AppendRow (row); + // The previous PC is in the RA + row->SetRegisterLocationToRegister(dwarf_pc, dwarf_r31, true); + unwind_plan.AppendRow(row); - // All other registers are the same. + // All other registers are the same. - unwind_plan.SetSourceName ("mips at-func-entry default"); - unwind_plan.SetSourcedFromCompiler (eLazyBoolNo); - unwind_plan.SetReturnAddressRegister(dwarf_r31); - return true; + unwind_plan.SetSourceName("mips at-func-entry default"); + unwind_plan.SetSourcedFromCompiler(eLazyBoolNo); + unwind_plan.SetReturnAddressRegister(dwarf_r31); + return true; } -bool -ABISysV_mips::CreateDefaultUnwindPlan (UnwindPlan &unwind_plan) -{ - unwind_plan.Clear(); - unwind_plan.SetRegisterKind (eRegisterKindDWARF); +bool ABISysV_mips::CreateDefaultUnwindPlan(UnwindPlan &unwind_plan) { + unwind_plan.Clear(); + unwind_plan.SetRegisterKind(eRegisterKindDWARF); - UnwindPlan::RowSP row(new UnwindPlan::Row); + UnwindPlan::RowSP row(new UnwindPlan::Row); - row->GetCFAValue().SetIsRegisterPlusOffset(dwarf_r29, 0); + row->GetCFAValue().SetIsRegisterPlusOffset(dwarf_r29, 0); - row->SetRegisterLocationToRegister(dwarf_pc, dwarf_r31, true); - - unwind_plan.AppendRow (row); - unwind_plan.SetSourceName ("mips default unwind plan"); - unwind_plan.SetSourcedFromCompiler (eLazyBoolNo); - unwind_plan.SetUnwindPlanValidAtAllInstructions (eLazyBoolNo); - return true; + row->SetRegisterLocationToRegister(dwarf_pc, dwarf_r31, true); + + unwind_plan.AppendRow(row); + unwind_plan.SetSourceName("mips default unwind plan"); + unwind_plan.SetSourcedFromCompiler(eLazyBoolNo); + unwind_plan.SetUnwindPlanValidAtAllInstructions(eLazyBoolNo); + return true; } -bool -ABISysV_mips::RegisterIsVolatile (const RegisterInfo *reg_info) -{ - return !RegisterIsCalleeSaved (reg_info); +bool ABISysV_mips::RegisterIsVolatile(const RegisterInfo *reg_info) { + return !RegisterIsCalleeSaved(reg_info); } -bool -ABISysV_mips::IsSoftFloat(uint32_t fp_flags) const -{ - return (fp_flags == lldb_private::ArchSpec::eMIPS_ABI_FP_SOFT); +bool ABISysV_mips::IsSoftFloat(uint32_t fp_flags) const { + return (fp_flags == lldb_private::ArchSpec::eMIPS_ABI_FP_SOFT); } -bool -ABISysV_mips::RegisterIsCalleeSaved (const RegisterInfo *reg_info) -{ - if (reg_info) - { - // Preserved registers are : - // r16-r23, r28, r29, r30, r31 - const char *name = reg_info->name; - - if (name[0] == 'r') - { - switch (name[1]) - { - case '1': - if (name[2] == '6' || name[2] == '7' || name[2] == '8' || name[2] == '9') // r16-r19 - return name[3] == '\0'; - break; - case '2': - if (name[2] == '0' || name[2] == '1' || name[2] == '2' || name[2] == '3' // r20-r23 - || name[2] == '8' || name[2] == '9') // r28 and r29 - return name[3] == '\0'; - break; - case '3': - if (name[2] == '0' || name[2] == '1') // r30 and r31 - return name[3] == '\0'; - break; - } - - if (name[0] == 'g' && name[1] == 'p' && name[2] == '\0') // gp (r28) - return true; - if (name[0] == 's' && name[1] == 'p' && name[2] == '\0') // sp (r29) - return true; - if (name[0] == 'f' && name[1] == 'p' && name[2] == '\0') // fp (r30) - return true; - if (name[0] == 'r' && name[1] == 'a' && name[2] == '\0') // ra (r31) - return true; - } +bool ABISysV_mips::RegisterIsCalleeSaved(const RegisterInfo *reg_info) { + if (reg_info) { + // Preserved registers are : + // r16-r23, r28, r29, r30, r31 + const char *name = reg_info->name; + + if (name[0] == 'r') { + switch (name[1]) { + case '1': + if (name[2] == '6' || name[2] == '7' || name[2] == '8' || + name[2] == '9') // r16-r19 + return name[3] == '\0'; + break; + case '2': + if (name[2] == '0' || name[2] == '1' || name[2] == '2' || + name[2] == '3' // r20-r23 + || name[2] == '8' || name[2] == '9') // r28 and r29 + return name[3] == '\0'; + break; + case '3': + if (name[2] == '0' || name[2] == '1') // r30 and r31 + return name[3] == '\0'; + break; + } + + if (name[0] == 'g' && name[1] == 'p' && name[2] == '\0') // gp (r28) + return true; + if (name[0] == 's' && name[1] == 'p' && name[2] == '\0') // sp (r29) + return true; + if (name[0] == 'f' && name[1] == 'p' && name[2] == '\0') // fp (r30) + return true; + if (name[0] == 'r' && name[1] == 'a' && name[2] == '\0') // ra (r31) + return true; } - return false; + } + return false; } -void -ABISysV_mips::Initialize() -{ - PluginManager::RegisterPlugin (GetPluginNameStatic(), - "System V ABI for mips targets", - CreateInstance); +void ABISysV_mips::Initialize() { + PluginManager::RegisterPlugin( + GetPluginNameStatic(), "System V ABI for mips targets", CreateInstance); } -void -ABISysV_mips::Terminate() -{ - PluginManager::UnregisterPlugin (CreateInstance); +void ABISysV_mips::Terminate() { + PluginManager::UnregisterPlugin(CreateInstance); } -lldb_private::ConstString -ABISysV_mips::GetPluginNameStatic() -{ - static ConstString g_name("sysv-mips"); - return g_name; +lldb_private::ConstString ABISysV_mips::GetPluginNameStatic() { + static ConstString g_name("sysv-mips"); + return g_name; } //------------------------------------------------------------------ // PluginInterface protocol //------------------------------------------------------------------ -lldb_private::ConstString -ABISysV_mips::GetPluginName() -{ - return GetPluginNameStatic(); +lldb_private::ConstString ABISysV_mips::GetPluginName() { + return GetPluginNameStatic(); } -uint32_t -ABISysV_mips::GetPluginVersion() -{ - return 1; -} +uint32_t ABISysV_mips::GetPluginVersion() { return 1; } diff --git a/source/Plugins/ABI/SysV-mips/ABISysV_mips.h b/source/Plugins/ABI/SysV-mips/ABISysV_mips.h index 388009d0fa00..7ac51463e6eb 100644 --- a/source/Plugins/ABI/SysV-mips/ABISysV_mips.h +++ b/source/Plugins/ABI/SysV-mips/ABISysV_mips.h @@ -14,113 +14,91 @@ // C++ Includes // Other libraries and framework includes // Project includes -#include "lldb/lldb-private.h" #include "lldb/Target/ABI.h" +#include "lldb/lldb-private.h" -class ABISysV_mips : - public lldb_private::ABI -{ +class ABISysV_mips : public lldb_private::ABI { public: - ~ABISysV_mips() override = default; + ~ABISysV_mips() override = default; + + size_t GetRedZoneSize() const override; - size_t - GetRedZoneSize() const override; + bool PrepareTrivialCall(lldb_private::Thread &thread, lldb::addr_t sp, + lldb::addr_t functionAddress, + lldb::addr_t returnAddress, + llvm::ArrayRef<lldb::addr_t> args) const override; - bool - PrepareTrivialCall(lldb_private::Thread &thread, - lldb::addr_t sp, - lldb::addr_t functionAddress, - lldb::addr_t returnAddress, - llvm::ArrayRef<lldb::addr_t> args) const override; + bool GetArgumentValues(lldb_private::Thread &thread, + lldb_private::ValueList &values) const override; - bool - GetArgumentValues(lldb_private::Thread &thread, - lldb_private::ValueList &values) const override; + lldb_private::Error + SetReturnValueObject(lldb::StackFrameSP &frame_sp, + lldb::ValueObjectSP &new_value) override; - lldb_private::Error - SetReturnValueObject(lldb::StackFrameSP &frame_sp, lldb::ValueObjectSP &new_value) override; + lldb::ValueObjectSP + GetReturnValueObjectImpl(lldb_private::Thread &thread, + lldb_private::CompilerType &type) const override; - lldb::ValueObjectSP - GetReturnValueObjectImpl(lldb_private::Thread &thread, - lldb_private::CompilerType &type) const override; + bool + CreateFunctionEntryUnwindPlan(lldb_private::UnwindPlan &unwind_plan) override; - bool - CreateFunctionEntryUnwindPlan(lldb_private::UnwindPlan &unwind_plan) override; + bool CreateDefaultUnwindPlan(lldb_private::UnwindPlan &unwind_plan) override; - bool - CreateDefaultUnwindPlan(lldb_private::UnwindPlan &unwind_plan) override; + bool RegisterIsVolatile(const lldb_private::RegisterInfo *reg_info) override; - bool - RegisterIsVolatile(const lldb_private::RegisterInfo *reg_info) override; + bool IsSoftFloat(uint32_t fp_flag) const; - bool - IsSoftFloat(uint32_t fp_flag) const; + bool CallFrameAddressIsValid(lldb::addr_t cfa) override { + // Make sure the stack call frame addresses are 8 byte aligned + if (cfa & (8ull - 1ull)) + return false; // Not 8 byte aligned + if (cfa == 0) + return false; // Zero is not a valid stack address + return true; + } - bool - CallFrameAddressIsValid(lldb::addr_t cfa) override - { - // Make sure the stack call frame addresses are 8 byte aligned - if (cfa & (8ull - 1ull)) - return false; // Not 8 byte aligned - if (cfa == 0) - return false; // Zero is not a valid stack address - return true; - } + bool CodeAddressIsValid(lldb::addr_t pc) override { + // Just make sure the address is a valid 32 bit address. Bit zero + // might be set due to MicroMIPS function calls, so don't enforce alignment. + return (pc <= UINT32_MAX); + } - bool - CodeAddressIsValid(lldb::addr_t pc) override - { - // Just make sure the address is a valid 32 bit address. Bit zero - // might be set due to MicroMIPS function calls, so don't enforce alignment. - return (pc <= UINT32_MAX); - } + const lldb_private::RegisterInfo * + GetRegisterInfoArray(uint32_t &count) override; - const lldb_private::RegisterInfo * - GetRegisterInfoArray(uint32_t &count) override; + //------------------------------------------------------------------ + // Static Functions + //------------------------------------------------------------------ - //------------------------------------------------------------------ - // Static Functions - //------------------------------------------------------------------ + static void Initialize(); - static void - Initialize(); + static void Terminate(); - static void - Terminate(); + static lldb::ABISP CreateInstance(const lldb_private::ArchSpec &arch); - static lldb::ABISP - CreateInstance (const lldb_private::ArchSpec &arch); + static lldb_private::ConstString GetPluginNameStatic(); - static lldb_private::ConstString - GetPluginNameStatic(); - - //------------------------------------------------------------------ - // PluginInterface protocol - //------------------------------------------------------------------ + //------------------------------------------------------------------ + // PluginInterface protocol + //------------------------------------------------------------------ - lldb_private::ConstString - GetPluginName() override; + lldb_private::ConstString GetPluginName() override; - uint32_t - GetPluginVersion() override; + uint32_t GetPluginVersion() override; protected: - void - CreateRegisterMapIfNeeded (); + void CreateRegisterMapIfNeeded(); - lldb::ValueObjectSP - GetReturnValueObjectSimple(lldb_private::Thread &thread, - lldb_private::CompilerType &ast_type) const; + lldb::ValueObjectSP + GetReturnValueObjectSimple(lldb_private::Thread &thread, + lldb_private::CompilerType &ast_type) const; - bool - RegisterIsCalleeSaved (const lldb_private::RegisterInfo *reg_info); + bool RegisterIsCalleeSaved(const lldb_private::RegisterInfo *reg_info); private: - ABISysV_mips() : - lldb_private::ABI() - { - // Call CreateInstance instead. - } + ABISysV_mips() : lldb_private::ABI() { + // Call CreateInstance instead. + } }; #endif // liblldb_ABISysV_mips_h_ diff --git a/source/Plugins/ABI/SysV-mips64/ABISysV_mips64.cpp b/source/Plugins/ABI/SysV-mips64/ABISysV_mips64.cpp index bf8ab3a658b3..bb83dec5d9df 100644 --- a/source/Plugins/ABI/SysV-mips64/ABISysV_mips64.cpp +++ b/source/Plugins/ABI/SysV-mips64/ABISysV_mips64.cpp @@ -25,899 +25,1204 @@ #include "lldb/Core/RegisterValue.h" #include "lldb/Core/Value.h" #include "lldb/Core/ValueObjectConstResult.h" -#include "lldb/Core/ValueObjectRegister.h" #include "lldb/Core/ValueObjectMemory.h" +#include "lldb/Core/ValueObjectRegister.h" #include "lldb/Symbol/UnwindPlan.h" -#include "lldb/Target/Target.h" #include "lldb/Target/Process.h" #include "lldb/Target/RegisterContext.h" #include "lldb/Target/StackFrame.h" +#include "lldb/Target/Target.h" #include "lldb/Target/Thread.h" using namespace lldb; using namespace lldb_private; -enum dwarf_regnums -{ - dwarf_r0 = 0, - dwarf_r1, - dwarf_r2, - dwarf_r3, - dwarf_r4, - dwarf_r5, - dwarf_r6, - dwarf_r7, - dwarf_r8, - dwarf_r9, - dwarf_r10, - dwarf_r11, - dwarf_r12, - dwarf_r13, - dwarf_r14, - dwarf_r15, - dwarf_r16, - dwarf_r17, - dwarf_r18, - dwarf_r19, - dwarf_r20, - dwarf_r21, - dwarf_r22, - dwarf_r23, - dwarf_r24, - dwarf_r25, - dwarf_r26, - dwarf_r27, - dwarf_r28, - dwarf_r29, - dwarf_r30, - dwarf_r31, - dwarf_sr, - dwarf_lo, - dwarf_hi, - dwarf_bad, - dwarf_cause, - dwarf_pc +enum dwarf_regnums { + dwarf_r0 = 0, + dwarf_r1, + dwarf_r2, + dwarf_r3, + dwarf_r4, + dwarf_r5, + dwarf_r6, + dwarf_r7, + dwarf_r8, + dwarf_r9, + dwarf_r10, + dwarf_r11, + dwarf_r12, + dwarf_r13, + dwarf_r14, + dwarf_r15, + dwarf_r16, + dwarf_r17, + dwarf_r18, + dwarf_r19, + dwarf_r20, + dwarf_r21, + dwarf_r22, + dwarf_r23, + dwarf_r24, + dwarf_r25, + dwarf_r26, + dwarf_r27, + dwarf_r28, + dwarf_r29, + dwarf_r30, + dwarf_r31, + dwarf_sr, + dwarf_lo, + dwarf_hi, + dwarf_bad, + dwarf_cause, + dwarf_pc }; -static const RegisterInfo -g_register_infos_mips64[] = -{ - // NAME ALT SZ OFF ENCODING FORMAT EH_FRAME DWARF GENERIC PROCESS PLUGIN LLDB NATIVE VALUE REGS INVALIDATE REGS - // ======== ====== == === ============= ========== ============= ================= ==================== ================= ==================== ========== =============== - { "r0" , "zero", 8, 0, eEncodingUint, eFormatHex, { dwarf_r0, dwarf_r0, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "r1" , "AT", 8, 0, eEncodingUint, eFormatHex, { dwarf_r1, dwarf_r1, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "r2" , "v0", 8, 0, eEncodingUint, eFormatHex, { dwarf_r2, dwarf_r2, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "r3" , "v1", 8, 0, eEncodingUint, eFormatHex, { dwarf_r3, dwarf_r3, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "r4" , "arg1", 8, 0, eEncodingUint, eFormatHex, { dwarf_r4, dwarf_r4, LLDB_REGNUM_GENERIC_ARG1, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "r5" , "arg2", 8, 0, eEncodingUint, eFormatHex, { dwarf_r5, dwarf_r5, LLDB_REGNUM_GENERIC_ARG2, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "r6" , "arg3", 8, 0, eEncodingUint, eFormatHex, { dwarf_r6, dwarf_r6, LLDB_REGNUM_GENERIC_ARG3, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "r7" , "arg4", 8, 0, eEncodingUint, eFormatHex, { dwarf_r7, dwarf_r7, LLDB_REGNUM_GENERIC_ARG4, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "r8" , "arg5", 8, 0, eEncodingUint, eFormatHex, { dwarf_r8, dwarf_r8, LLDB_REGNUM_GENERIC_ARG5, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "r9" , "arg6", 8, 0, eEncodingUint, eFormatHex, { dwarf_r9, dwarf_r9, LLDB_REGNUM_GENERIC_ARG6, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "r10" , "arg7", 8, 0, eEncodingUint, eFormatHex, { dwarf_r10, dwarf_r10, LLDB_REGNUM_GENERIC_ARG7, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "r11" , "arg8", 8, 0, eEncodingUint, eFormatHex, { dwarf_r11, dwarf_r11, LLDB_REGNUM_GENERIC_ARG8, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "r12" , nullptr,8, 0, eEncodingUint, eFormatHex, { dwarf_r12, dwarf_r12, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "r13" , nullptr,8, 0, eEncodingUint, eFormatHex, { dwarf_r13, dwarf_r13, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "r14" , nullptr,8, 0, eEncodingUint, eFormatHex, { dwarf_r14, dwarf_r14, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "r15" , nullptr,8, 0, eEncodingUint, eFormatHex, { dwarf_r15, dwarf_r15, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "r16" , nullptr,8, 0, eEncodingUint, eFormatHex, { dwarf_r16, dwarf_r16, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "r17" , nullptr,8, 0, eEncodingUint, eFormatHex, { dwarf_r17, dwarf_r17, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "r18" , nullptr,8, 0, eEncodingUint, eFormatHex, { dwarf_r18, dwarf_r18, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "r19" , nullptr,8, 0, eEncodingUint, eFormatHex, { dwarf_r19, dwarf_r19, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "r20" , nullptr,8, 0, eEncodingUint, eFormatHex, { dwarf_r20, dwarf_r20, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "r21" , nullptr,8, 0, eEncodingUint, eFormatHex, { dwarf_r21, dwarf_r21, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "r22" , nullptr,8, 0, eEncodingUint, eFormatHex, { dwarf_r22, dwarf_r22, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "r23" , nullptr,8, 0, eEncodingUint, eFormatHex, { dwarf_r23, dwarf_r23, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "r24" , nullptr,8, 0, eEncodingUint, eFormatHex, { dwarf_r24, dwarf_r24, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "r25" , nullptr,8, 0, eEncodingUint, eFormatHex, { dwarf_r25, dwarf_r25, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "r26" , nullptr,8, 0, eEncodingUint, eFormatHex, { dwarf_r26, dwarf_r26, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "r27" , nullptr,8, 0, eEncodingUint, eFormatHex, { dwarf_r27, dwarf_r27, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "r28" , "gp", 8, 0, eEncodingUint, eFormatHex, { dwarf_r28, dwarf_r28, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "r29" , "sp", 8, 0, eEncodingUint, eFormatHex, { dwarf_r29, dwarf_r29, LLDB_REGNUM_GENERIC_SP, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "r30" , "fp", 8, 0, eEncodingUint, eFormatHex, { dwarf_r30, dwarf_r30, LLDB_REGNUM_GENERIC_FP, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "r31" , "ra", 8, 0, eEncodingUint, eFormatHex, { dwarf_r31, dwarf_r31, LLDB_REGNUM_GENERIC_RA, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "sr" , nullptr,4, 0, eEncodingUint, eFormatHex, { dwarf_sr, dwarf_sr, LLDB_REGNUM_GENERIC_FLAGS, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "lo" , nullptr,8, 0, eEncodingUint, eFormatHex, { dwarf_lo, dwarf_lo, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "hi" , nullptr,8, 0, eEncodingUint, eFormatHex, { dwarf_hi, dwarf_hi, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "bad" , nullptr,8, 0, eEncodingUint, eFormatHex, { dwarf_bad, dwarf_bad, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "cause" , nullptr,8, 0, eEncodingUint, eFormatHex, { dwarf_cause, dwarf_cause, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "pc" , nullptr,8, 0, eEncodingUint, eFormatHex, { dwarf_pc, dwarf_pc, LLDB_REGNUM_GENERIC_PC, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, +static const RegisterInfo g_register_infos_mips64[] = { + // NAME ALT SZ OFF ENCODING FORMAT EH_FRAME + // DWARF GENERIC PROCESS PLUGIN + // LLDB NATIVE + // ======== ====== == === ============= ========== ============= + // ================= ==================== ================= + // ==================== + {"r0", + "zero", + 8, + 0, + eEncodingUint, + eFormatHex, + {dwarf_r0, dwarf_r0, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"r1", + "AT", + 8, + 0, + eEncodingUint, + eFormatHex, + {dwarf_r1, dwarf_r1, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"r2", + "v0", + 8, + 0, + eEncodingUint, + eFormatHex, + {dwarf_r2, dwarf_r2, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"r3", + "v1", + 8, + 0, + eEncodingUint, + eFormatHex, + {dwarf_r3, dwarf_r3, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"r4", + "arg1", + 8, + 0, + eEncodingUint, + eFormatHex, + {dwarf_r4, dwarf_r4, LLDB_REGNUM_GENERIC_ARG1, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"r5", + "arg2", + 8, + 0, + eEncodingUint, + eFormatHex, + {dwarf_r5, dwarf_r5, LLDB_REGNUM_GENERIC_ARG2, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"r6", + "arg3", + 8, + 0, + eEncodingUint, + eFormatHex, + {dwarf_r6, dwarf_r6, LLDB_REGNUM_GENERIC_ARG3, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"r7", + "arg4", + 8, + 0, + eEncodingUint, + eFormatHex, + {dwarf_r7, dwarf_r7, LLDB_REGNUM_GENERIC_ARG4, 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", + "arg7", + 8, + 0, + eEncodingUint, + eFormatHex, + {dwarf_r10, dwarf_r10, LLDB_REGNUM_GENERIC_ARG7, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"r11", + "arg8", + 8, + 0, + eEncodingUint, + eFormatHex, + {dwarf_r11, dwarf_r11, LLDB_REGNUM_GENERIC_ARG8, 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}, + {"r16", + nullptr, + 8, + 0, + eEncodingUint, + eFormatHex, + {dwarf_r16, dwarf_r16, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"r17", + nullptr, + 8, + 0, + eEncodingUint, + eFormatHex, + {dwarf_r17, dwarf_r17, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"r18", + nullptr, + 8, + 0, + eEncodingUint, + eFormatHex, + {dwarf_r18, dwarf_r18, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"r19", + nullptr, + 8, + 0, + eEncodingUint, + eFormatHex, + {dwarf_r19, dwarf_r19, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"r20", + nullptr, + 8, + 0, + eEncodingUint, + eFormatHex, + {dwarf_r20, dwarf_r20, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"r21", + nullptr, + 8, + 0, + eEncodingUint, + eFormatHex, + {dwarf_r21, dwarf_r21, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"r22", + nullptr, + 8, + 0, + eEncodingUint, + eFormatHex, + {dwarf_r22, dwarf_r22, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"r23", + nullptr, + 8, + 0, + eEncodingUint, + eFormatHex, + {dwarf_r23, dwarf_r23, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"r24", + nullptr, + 8, + 0, + eEncodingUint, + eFormatHex, + {dwarf_r24, dwarf_r24, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"r25", + nullptr, + 8, + 0, + eEncodingUint, + eFormatHex, + {dwarf_r25, dwarf_r25, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"r26", + nullptr, + 8, + 0, + eEncodingUint, + eFormatHex, + {dwarf_r26, dwarf_r26, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"r27", + nullptr, + 8, + 0, + eEncodingUint, + eFormatHex, + {dwarf_r27, dwarf_r27, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"r28", + "gp", + 8, + 0, + eEncodingUint, + eFormatHex, + {dwarf_r28, dwarf_r28, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"r29", + "sp", + 8, + 0, + eEncodingUint, + eFormatHex, + {dwarf_r29, dwarf_r29, LLDB_REGNUM_GENERIC_SP, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"r30", + "fp", + 8, + 0, + eEncodingUint, + eFormatHex, + {dwarf_r30, dwarf_r30, LLDB_REGNUM_GENERIC_FP, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"r31", + "ra", + 8, + 0, + eEncodingUint, + eFormatHex, + {dwarf_r31, dwarf_r31, LLDB_REGNUM_GENERIC_RA, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"sr", + nullptr, + 4, + 0, + eEncodingUint, + eFormatHex, + {dwarf_sr, dwarf_sr, LLDB_REGNUM_GENERIC_FLAGS, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"lo", + nullptr, + 8, + 0, + eEncodingUint, + eFormatHex, + {dwarf_lo, dwarf_lo, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"hi", + nullptr, + 8, + 0, + eEncodingUint, + eFormatHex, + {dwarf_hi, dwarf_hi, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"bad", + nullptr, + 8, + 0, + eEncodingUint, + eFormatHex, + {dwarf_bad, dwarf_bad, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"cause", + nullptr, + 8, + 0, + eEncodingUint, + eFormatHex, + {dwarf_cause, dwarf_cause, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, + {"pc", + nullptr, + 8, + 0, + eEncodingUint, + eFormatHex, + {dwarf_pc, dwarf_pc, LLDB_REGNUM_GENERIC_PC, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}, }; -static const uint32_t k_num_register_infos = llvm::array_lengthof(g_register_infos_mips64); +static const uint32_t k_num_register_infos = + llvm::array_lengthof(g_register_infos_mips64); const lldb_private::RegisterInfo * -ABISysV_mips64::GetRegisterInfoArray (uint32_t &count) -{ - count = k_num_register_infos; - return g_register_infos_mips64; +ABISysV_mips64::GetRegisterInfoArray(uint32_t &count) { + count = k_num_register_infos; + return g_register_infos_mips64; } -size_t -ABISysV_mips64::GetRedZoneSize () const -{ - return 0; -} +size_t ABISysV_mips64::GetRedZoneSize() const { return 0; } //------------------------------------------------------------------ // Static Functions //------------------------------------------------------------------ ABISP -ABISysV_mips64::CreateInstance (const ArchSpec &arch) -{ - static ABISP g_abi_sp; - const llvm::Triple::ArchType arch_type = arch.GetTriple().getArch(); - if ((arch_type == llvm::Triple::mips64) || - (arch_type == llvm::Triple::mips64el)) - { - if (!g_abi_sp) - g_abi_sp.reset (new ABISysV_mips64); - return g_abi_sp; - } - return ABISP(); +ABISysV_mips64::CreateInstance(const ArchSpec &arch) { + static ABISP g_abi_sp; + const llvm::Triple::ArchType arch_type = arch.GetTriple().getArch(); + if ((arch_type == llvm::Triple::mips64) || + (arch_type == llvm::Triple::mips64el)) { + if (!g_abi_sp) + g_abi_sp.reset(new ABISysV_mips64); + return g_abi_sp; + } + return ABISP(); } -bool -ABISysV_mips64::PrepareTrivialCall (Thread &thread, - addr_t sp, - addr_t func_addr, - addr_t return_addr, - llvm::ArrayRef<addr_t> args) const -{ - Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS)); - - if (log) - { - StreamString s; - s.Printf("ABISysV_mips64::PrepareTrivialCall (tid = 0x%" PRIx64 ", sp = 0x%" PRIx64 ", func_addr = 0x%" PRIx64 ", return_addr = 0x%" PRIx64, - thread.GetID(), - (uint64_t)sp, - (uint64_t)func_addr, - (uint64_t)return_addr); - - for (size_t i = 0; i < args.size(); ++i) - s.Printf (", arg%zd = 0x%" PRIx64, i + 1, args[i]); - s.PutCString (")"); - log->PutCString(s.GetString().c_str()); - } - - RegisterContext *reg_ctx = thread.GetRegisterContext().get(); - if (!reg_ctx) - return false; +bool ABISysV_mips64::PrepareTrivialCall(Thread &thread, addr_t sp, + addr_t func_addr, addr_t return_addr, + llvm::ArrayRef<addr_t> args) const { + Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS)); - const RegisterInfo *reg_info = nullptr; - - if (args.size() > 8) // TODO handle more than 8 arguments - return false; + if (log) { + StreamString s; + s.Printf("ABISysV_mips64::PrepareTrivialCall (tid = 0x%" PRIx64 + ", sp = 0x%" PRIx64 ", func_addr = 0x%" PRIx64 + ", return_addr = 0x%" PRIx64, + thread.GetID(), (uint64_t)sp, (uint64_t)func_addr, + (uint64_t)return_addr); for (size_t i = 0; i < args.size(); ++i) - { - reg_info = reg_ctx->GetRegisterInfo(eRegisterKindGeneric, LLDB_REGNUM_GENERIC_ARG1 + i); - if (log) - log->Printf("About to write arg%zd (0x%" PRIx64 ") into %s", i + 1, args[i], reg_info->name); - if (!reg_ctx->WriteRegisterFromUnsigned(reg_info, args[i])) - return false; - } - - // First, align the SP + s.Printf(", arg%zd = 0x%" PRIx64, i + 1, args[i]); + s.PutCString(")"); + log->PutString(s.GetString()); + } - if (log) - log->Printf("16-byte aligning SP: 0x%" PRIx64 " to 0x%" PRIx64, (uint64_t)sp, (uint64_t)(sp & ~0xfull)); + RegisterContext *reg_ctx = thread.GetRegisterContext().get(); + if (!reg_ctx) + return false; - sp &= ~(0xfull); // 16-byte alignment + const RegisterInfo *reg_info = nullptr; - Error error; - const RegisterInfo *pc_reg_info = reg_ctx->GetRegisterInfo (eRegisterKindGeneric, LLDB_REGNUM_GENERIC_PC); - const RegisterInfo *sp_reg_info = reg_ctx->GetRegisterInfo (eRegisterKindGeneric, LLDB_REGNUM_GENERIC_SP); - const RegisterInfo *ra_reg_info = reg_ctx->GetRegisterInfo (eRegisterKindGeneric, LLDB_REGNUM_GENERIC_RA); - const RegisterInfo *r25_info = reg_ctx->GetRegisterInfoByName("r25", 0); - const RegisterInfo *r0_info = reg_ctx->GetRegisterInfoByName("zero", 0); + if (args.size() > 8) // TODO handle more than 8 arguments + return false; + for (size_t i = 0; i < args.size(); ++i) { + reg_info = reg_ctx->GetRegisterInfo(eRegisterKindGeneric, + LLDB_REGNUM_GENERIC_ARG1 + i); if (log) - log->Printf("Writing R0: 0x%" PRIx64, (uint64_t)0); - - /* Write r0 with 0, in case we are stopped in syscall, - * such setting prevents automatic decrement of the PC. - * This clears the bug 23659 for MIPS. - */ - if (!reg_ctx->WriteRegisterFromUnsigned (r0_info, (uint64_t)0)) - return false; + log->Printf("About to write arg%zd (0x%" PRIx64 ") into %s", i + 1, + args[i], reg_info->name); + if (!reg_ctx->WriteRegisterFromUnsigned(reg_info, args[i])) + return false; + } + + // First, align the SP + + if (log) + log->Printf("16-byte aligning SP: 0x%" PRIx64 " to 0x%" PRIx64, + (uint64_t)sp, (uint64_t)(sp & ~0xfull)); + + sp &= ~(0xfull); // 16-byte alignment + + Error error; + const RegisterInfo *pc_reg_info = + reg_ctx->GetRegisterInfo(eRegisterKindGeneric, LLDB_REGNUM_GENERIC_PC); + const RegisterInfo *sp_reg_info = + reg_ctx->GetRegisterInfo(eRegisterKindGeneric, LLDB_REGNUM_GENERIC_SP); + const RegisterInfo *ra_reg_info = + reg_ctx->GetRegisterInfo(eRegisterKindGeneric, LLDB_REGNUM_GENERIC_RA); + const RegisterInfo *r25_info = reg_ctx->GetRegisterInfoByName("r25", 0); + const RegisterInfo *r0_info = reg_ctx->GetRegisterInfoByName("zero", 0); + + if (log) + log->Printf("Writing R0: 0x%" PRIx64, (uint64_t)0); + + /* Write r0 with 0, in case we are stopped in syscall, + * such setting prevents automatic decrement of the PC. + * This clears the bug 23659 for MIPS. + */ + if (!reg_ctx->WriteRegisterFromUnsigned(r0_info, (uint64_t)0)) + return false; - if (log) - log->Printf("Writing SP: 0x%" PRIx64, (uint64_t)sp); + if (log) + log->Printf("Writing SP: 0x%" PRIx64, (uint64_t)sp); - // Set "sp" to the requested value - if (!reg_ctx->WriteRegisterFromUnsigned (sp_reg_info, sp)) - return false; + // Set "sp" to the requested value + if (!reg_ctx->WriteRegisterFromUnsigned(sp_reg_info, sp)) + return false; - if (log) - log->Printf("Writing RA: 0x%" PRIx64, (uint64_t)return_addr); + if (log) + log->Printf("Writing RA: 0x%" PRIx64, (uint64_t)return_addr); - // Set "ra" to the return address - if (!reg_ctx->WriteRegisterFromUnsigned (ra_reg_info, return_addr)) - return false; + // Set "ra" to the return address + if (!reg_ctx->WriteRegisterFromUnsigned(ra_reg_info, return_addr)) + return false; - if (log) - log->Printf("Writing PC: 0x%" PRIx64, (uint64_t)func_addr); + if (log) + log->Printf("Writing PC: 0x%" PRIx64, (uint64_t)func_addr); - // Set pc to the address of the called function. - if (!reg_ctx->WriteRegisterFromUnsigned (pc_reg_info, func_addr)) - return false; + // Set pc to the address of the called function. + if (!reg_ctx->WriteRegisterFromUnsigned(pc_reg_info, func_addr)) + return false; - if (log) - log->Printf("Writing r25: 0x%" PRIx64, (uint64_t)func_addr); + if (log) + log->Printf("Writing r25: 0x%" PRIx64, (uint64_t)func_addr); - // All callers of position independent functions must place the address of the called function in t9 (r25) - if (!reg_ctx->WriteRegisterFromUnsigned (r25_info, func_addr)) - return false; + // All callers of position independent functions must place the address of the + // called function in t9 (r25) + if (!reg_ctx->WriteRegisterFromUnsigned(r25_info, func_addr)) + return false; - return true; + return true; } -bool -ABISysV_mips64::GetArgumentValues (Thread &thread, ValueList &values) const -{ - return false; +bool ABISysV_mips64::GetArgumentValues(Thread &thread, + ValueList &values) const { + return false; } -Error -ABISysV_mips64::SetReturnValueObject(lldb::StackFrameSP &frame_sp, lldb::ValueObjectSP &new_value_sp) -{ - Error error; - if (!new_value_sp) - { - error.SetErrorString("Empty value object for return value."); - return error; - } +Error ABISysV_mips64::SetReturnValueObject(lldb::StackFrameSP &frame_sp, + lldb::ValueObjectSP &new_value_sp) { + Error error; + if (!new_value_sp) { + error.SetErrorString("Empty value object for return value."); + return error; + } - CompilerType compiler_type = new_value_sp->GetCompilerType(); - if (!compiler_type) - { - error.SetErrorString ("Null clang type for return value."); - return error; - } + CompilerType compiler_type = new_value_sp->GetCompilerType(); + if (!compiler_type) { + error.SetErrorString("Null clang type for return value."); + return error; + } - Thread *thread = frame_sp->GetThread().get(); + Thread *thread = frame_sp->GetThread().get(); - RegisterContext *reg_ctx = thread->GetRegisterContext().get(); + RegisterContext *reg_ctx = thread->GetRegisterContext().get(); - if (!reg_ctx) - error.SetErrorString("no registers are available"); - - DataExtractor data; - Error data_error; - size_t num_bytes = new_value_sp->GetData(data, data_error); - if (data_error.Fail()) - { - error.SetErrorStringWithFormat("Couldn't convert return value to raw data: %s", data_error.AsCString()); - return error; - } + if (!reg_ctx) + error.SetErrorString("no registers are available"); - const uint32_t type_flags = compiler_type.GetTypeInfo(nullptr); - - if (type_flags & eTypeIsScalar || - type_flags & eTypeIsPointer) - { - if (type_flags & eTypeIsInteger || - type_flags & eTypeIsPointer ) - { - lldb::offset_t offset = 0; - - if (num_bytes <= 16) - { - const RegisterInfo *r2_info = reg_ctx->GetRegisterInfoByName("r2", 0); - if (num_bytes <= 8) - { - uint64_t raw_value = data.GetMaxU64(&offset, num_bytes); - - if (!reg_ctx->WriteRegisterFromUnsigned (r2_info, raw_value)) - error.SetErrorString ("failed to write register r2"); - } - else - { - uint64_t raw_value = data.GetMaxU64(&offset, 8); - if (reg_ctx->WriteRegisterFromUnsigned (r2_info, raw_value)) - { - const RegisterInfo *r3_info = reg_ctx->GetRegisterInfoByName("r3", 0); - raw_value = data.GetMaxU64(&offset, num_bytes - offset); - - if (!reg_ctx->WriteRegisterFromUnsigned (r3_info, raw_value)) - error.SetErrorString ("failed to write register r3"); - } - else - error.SetErrorString ("failed to write register r2"); - } - } - else - { - error.SetErrorString("We don't support returning longer than 128 bit integer values at present."); - } - } - else if (type_flags & eTypeIsFloat) - { - error.SetErrorString("TODO: Handle Float Types."); + DataExtractor data; + Error data_error; + size_t num_bytes = new_value_sp->GetData(data, data_error); + if (data_error.Fail()) { + error.SetErrorStringWithFormat( + "Couldn't convert return value to raw data: %s", + data_error.AsCString()); + return error; + } + + const uint32_t type_flags = compiler_type.GetTypeInfo(nullptr); + + if (type_flags & eTypeIsScalar || type_flags & eTypeIsPointer) { + if (type_flags & eTypeIsInteger || type_flags & eTypeIsPointer) { + lldb::offset_t offset = 0; + + if (num_bytes <= 16) { + const RegisterInfo *r2_info = reg_ctx->GetRegisterInfoByName("r2", 0); + if (num_bytes <= 8) { + uint64_t raw_value = data.GetMaxU64(&offset, num_bytes); + + if (!reg_ctx->WriteRegisterFromUnsigned(r2_info, raw_value)) + error.SetErrorString("failed to write register r2"); + } else { + uint64_t raw_value = data.GetMaxU64(&offset, 8); + if (reg_ctx->WriteRegisterFromUnsigned(r2_info, raw_value)) { + const RegisterInfo *r3_info = + reg_ctx->GetRegisterInfoByName("r3", 0); + raw_value = data.GetMaxU64(&offset, num_bytes - offset); + + if (!reg_ctx->WriteRegisterFromUnsigned(r3_info, raw_value)) + error.SetErrorString("failed to write register r3"); + } else + error.SetErrorString("failed to write register r2"); } + } else { + error.SetErrorString("We don't support returning longer than 128 bit " + "integer values at present."); + } + } else if (type_flags & eTypeIsFloat) { + error.SetErrorString("TODO: Handle Float Types."); } - else if (type_flags & eTypeIsVector) - { - error.SetErrorString("returning vector values are not supported"); - } + } else if (type_flags & eTypeIsVector) { + error.SetErrorString("returning vector values are not supported"); + } - return error; + return error; } -ValueObjectSP -ABISysV_mips64::GetReturnValueObjectSimple (Thread &thread, CompilerType &return_compiler_type) const -{ - ValueObjectSP return_valobj_sp; - return return_valobj_sp; +ValueObjectSP ABISysV_mips64::GetReturnValueObjectSimple( + Thread &thread, CompilerType &return_compiler_type) const { + ValueObjectSP return_valobj_sp; + return return_valobj_sp; } -ValueObjectSP -ABISysV_mips64::GetReturnValueObjectImpl (Thread &thread, CompilerType &return_compiler_type) const -{ - ValueObjectSP return_valobj_sp; - Value value; - Error error; - - ExecutionContext exe_ctx (thread.shared_from_this()); - if (exe_ctx.GetTargetPtr() == nullptr || exe_ctx.GetProcessPtr() == nullptr) - return return_valobj_sp; - - value.SetCompilerType(return_compiler_type); - - RegisterContext *reg_ctx = thread.GetRegisterContext().get(); - if (!reg_ctx) - return return_valobj_sp; - - Target *target = exe_ctx.GetTargetPtr(); - const ArchSpec target_arch = target->GetArchitecture(); - ByteOrder target_byte_order = target_arch.GetByteOrder(); - const size_t byte_size = return_compiler_type.GetByteSize(nullptr); - const uint32_t type_flags = return_compiler_type.GetTypeInfo(nullptr); - uint32_t fp_flag = target_arch.GetFlags () & lldb_private::ArchSpec::eMIPS_ABI_FP_mask; - - const RegisterInfo *r2_info = reg_ctx->GetRegisterInfoByName("r2", 0); - const RegisterInfo *r3_info = reg_ctx->GetRegisterInfoByName("r3", 0); - - if (type_flags & eTypeIsScalar || - type_flags & eTypeIsPointer) - { - value.SetValueType(Value::eValueTypeScalar); - - bool success = false; - if (type_flags & eTypeIsInteger || - type_flags & eTypeIsPointer) - { - // Extract the register context so we can read arguments from registers - // In MIPS register "r2" (v0) holds the integer function return values - - uint64_t raw_value = reg_ctx->ReadRegisterAsUnsigned(r2_info, 0); - - const bool is_signed = (type_flags & eTypeIsSigned) != 0; - switch (byte_size) - { - default: - break; - - case sizeof(uint64_t): - if (is_signed) - value.GetScalar() = (int64_t)(raw_value); - else - value.GetScalar() = (uint64_t)(raw_value); - success = true; - break; - - case sizeof(uint32_t): - if (is_signed) - value.GetScalar() = (int32_t)(raw_value & UINT32_MAX); - else - value.GetScalar() = (uint32_t)(raw_value & UINT32_MAX); - success = true; - break; - - case sizeof(uint16_t): - if (is_signed) - value.GetScalar() = (int16_t)(raw_value & UINT16_MAX); - else - value.GetScalar() = (uint16_t)(raw_value & UINT16_MAX); - success = true; - break; - - case sizeof(uint8_t): - if (is_signed) - value.GetScalar() = (int8_t)(raw_value & UINT8_MAX); - else - value.GetScalar() = (uint8_t)(raw_value & UINT8_MAX); - success = true; - break; - } +ValueObjectSP ABISysV_mips64::GetReturnValueObjectImpl( + Thread &thread, CompilerType &return_compiler_type) const { + ValueObjectSP return_valobj_sp; + Value value; + Error error; + + ExecutionContext exe_ctx(thread.shared_from_this()); + if (exe_ctx.GetTargetPtr() == nullptr || exe_ctx.GetProcessPtr() == nullptr) + return return_valobj_sp; + + value.SetCompilerType(return_compiler_type); + + RegisterContext *reg_ctx = thread.GetRegisterContext().get(); + if (!reg_ctx) + return return_valobj_sp; + + Target *target = exe_ctx.GetTargetPtr(); + const ArchSpec target_arch = target->GetArchitecture(); + ByteOrder target_byte_order = target_arch.GetByteOrder(); + const size_t byte_size = return_compiler_type.GetByteSize(nullptr); + const uint32_t type_flags = return_compiler_type.GetTypeInfo(nullptr); + uint32_t fp_flag = + target_arch.GetFlags() & lldb_private::ArchSpec::eMIPS_ABI_FP_mask; + + const RegisterInfo *r2_info = reg_ctx->GetRegisterInfoByName("r2", 0); + const RegisterInfo *r3_info = reg_ctx->GetRegisterInfoByName("r3", 0); + + if (type_flags & eTypeIsScalar || type_flags & eTypeIsPointer) { + value.SetValueType(Value::eValueTypeScalar); + + bool success = false; + if (type_flags & eTypeIsInteger || type_flags & eTypeIsPointer) { + // Extract the register context so we can read arguments from registers + // In MIPS register "r2" (v0) holds the integer function return values + + uint64_t raw_value = reg_ctx->ReadRegisterAsUnsigned(r2_info, 0); + + const bool is_signed = (type_flags & eTypeIsSigned) != 0; + switch (byte_size) { + default: + break; + + case sizeof(uint64_t): + if (is_signed) + value.GetScalar() = (int64_t)(raw_value); + else + value.GetScalar() = (uint64_t)(raw_value); + success = true; + break; + + case sizeof(uint32_t): + if (is_signed) + value.GetScalar() = (int32_t)(raw_value & UINT32_MAX); + else + value.GetScalar() = (uint32_t)(raw_value & UINT32_MAX); + success = true; + break; + + case sizeof(uint16_t): + if (is_signed) + value.GetScalar() = (int16_t)(raw_value & UINT16_MAX); + else + value.GetScalar() = (uint16_t)(raw_value & UINT16_MAX); + success = true; + break; + + case sizeof(uint8_t): + if (is_signed) + value.GetScalar() = (int8_t)(raw_value & UINT8_MAX); + else + value.GetScalar() = (uint8_t)(raw_value & UINT8_MAX); + success = true; + break; + } + } else if (type_flags & eTypeIsFloat) { + if (type_flags & eTypeIsComplex) { + // Don't handle complex yet. + } else if (IsSoftFloat(fp_flag)) { + uint64_t raw_value = reg_ctx->ReadRegisterAsUnsigned(r2_info, 0); + switch (byte_size) { + case 4: + value.GetScalar() = *((float *)(&raw_value)); + success = true; + break; + case 8: + value.GetScalar() = *((double *)(&raw_value)); + success = true; + break; + case 16: + uint64_t result[2]; + if (target_byte_order == eByteOrderLittle) { + result[0] = raw_value; + result[1] = reg_ctx->ReadRegisterAsUnsigned(r3_info, 0); + value.GetScalar() = *((long double *)(result)); + } else { + result[0] = reg_ctx->ReadRegisterAsUnsigned(r3_info, 0); + result[1] = raw_value; + value.GetScalar() = *((long double *)(result)); + } + success = true; + break; } - else if (type_flags & eTypeIsFloat) - { - if (type_flags & eTypeIsComplex) - { - // Don't handle complex yet. - } - else if (IsSoftFloat(fp_flag)) - { - uint64_t raw_value = reg_ctx->ReadRegisterAsUnsigned(r2_info, 0); - switch (byte_size) - { - case 4: - value.GetScalar() = *((float *)(&raw_value)); - success = true; - break; - case 8: - value.GetScalar() = *((double *)(&raw_value)); - success = true; - break; - case 16: - uint64_t result[2]; - if (target_byte_order == eByteOrderLittle) - { - result[0] = raw_value; - result[1] = reg_ctx->ReadRegisterAsUnsigned(r3_info, 0); - value.GetScalar() = *((long double *)(result)); - } - else - { - result[0] = reg_ctx->ReadRegisterAsUnsigned(r3_info, 0); - result[1] = raw_value; - value.GetScalar() = *((long double *)(result)); - } - success = true; - break; - } + } else { + if (byte_size <= sizeof(long double)) { + const RegisterInfo *f0_info = reg_ctx->GetRegisterInfoByName("f0", 0); + + RegisterValue f0_value; + DataExtractor f0_data; + + reg_ctx->ReadRegister(f0_info, f0_value); + + f0_value.GetData(f0_data); + + lldb::offset_t offset = 0; + if (byte_size == sizeof(float)) { + value.GetScalar() = (float)f0_data.GetFloat(&offset); + success = true; + } else if (byte_size == sizeof(double)) { + value.GetScalar() = (double)f0_data.GetDouble(&offset); + success = true; + } else if (byte_size == sizeof(long double)) { + const RegisterInfo *f2_info = + reg_ctx->GetRegisterInfoByName("f2", 0); + RegisterValue f2_value; + DataExtractor f2_data; + reg_ctx->ReadRegister(f2_info, f2_value); + DataExtractor *copy_from_extractor = nullptr; + DataBufferSP data_sp(new DataBufferHeap(16, 0)); + DataExtractor return_ext( + data_sp, target_byte_order, + target->GetArchitecture().GetAddressByteSize()); + + if (target_byte_order == eByteOrderLittle) { + copy_from_extractor = &f0_data; + copy_from_extractor->CopyByteOrderedData( + 0, 8, data_sp->GetBytes(), byte_size - 8, target_byte_order); + f2_value.GetData(f2_data); + copy_from_extractor = &f2_data; + copy_from_extractor->CopyByteOrderedData( + 0, 8, data_sp->GetBytes() + 8, byte_size - 8, + target_byte_order); + } else { + copy_from_extractor = &f0_data; + copy_from_extractor->CopyByteOrderedData( + 0, 8, data_sp->GetBytes() + 8, byte_size - 8, + target_byte_order); + f2_value.GetData(f2_data); + copy_from_extractor = &f2_data; + copy_from_extractor->CopyByteOrderedData( + 0, 8, data_sp->GetBytes(), byte_size - 8, target_byte_order); } - else - { - if (byte_size <= sizeof(long double)) - { - const RegisterInfo *f0_info = reg_ctx->GetRegisterInfoByName("f0", 0); - - RegisterValue f0_value; - DataExtractor f0_data; - - reg_ctx->ReadRegister (f0_info, f0_value); - - - f0_value.GetData(f0_data); - - - lldb::offset_t offset = 0; - if (byte_size == sizeof(float)) - { - value.GetScalar() = (float) f0_data.GetFloat(&offset); - success = true; - } - else if (byte_size == sizeof(double)) - { - value.GetScalar() = (double) f0_data.GetDouble(&offset); - success = true; - } - else if (byte_size == sizeof(long double)) - { - const RegisterInfo *f2_info = reg_ctx->GetRegisterInfoByName("f2", 0); - RegisterValue f2_value; - DataExtractor f2_data; - reg_ctx->ReadRegister (f2_info, f2_value); - DataExtractor *copy_from_extractor = nullptr; - DataBufferSP data_sp (new DataBufferHeap(16, 0)); - DataExtractor return_ext (data_sp, - target_byte_order, - target->GetArchitecture().GetAddressByteSize()); - - if (target_byte_order == eByteOrderLittle) - { - copy_from_extractor = &f0_data; - copy_from_extractor->CopyByteOrderedData (0, - 8, - data_sp->GetBytes(), - byte_size - 8, - target_byte_order); - f2_value.GetData(f2_data); - copy_from_extractor = &f2_data; - copy_from_extractor->CopyByteOrderedData (0, - 8, - data_sp->GetBytes() + 8, - byte_size - 8, - target_byte_order); - } - else - { - copy_from_extractor = &f0_data; - copy_from_extractor->CopyByteOrderedData (0, - 8, - data_sp->GetBytes() + 8, - byte_size - 8, - target_byte_order); - f2_value.GetData(f2_data); - copy_from_extractor = &f2_data; - copy_from_extractor->CopyByteOrderedData (0, - 8, - data_sp->GetBytes(), - byte_size - 8, - target_byte_order); - } - - return_valobj_sp = ValueObjectConstResult::Create (&thread, - return_compiler_type, - ConstString(""), - return_ext); - return return_valobj_sp; - } - } - } - } - if (success) - return_valobj_sp = ValueObjectConstResult::Create (thread.GetStackFrameAtIndex(0).get(), - value, - ConstString("")); + return_valobj_sp = ValueObjectConstResult::Create( + &thread, return_compiler_type, ConstString(""), return_ext); + return return_valobj_sp; + } + } + } } - else if (type_flags & eTypeIsStructUnion || - type_flags & eTypeIsClass || - type_flags & eTypeIsVector) - { - // Any structure of up to 16 bytes in size is returned in the registers. - if (byte_size <= 16) - { - DataBufferSP data_sp(new DataBufferHeap(16, 0)); - DataExtractor return_ext(data_sp, target_byte_order, - target->GetArchitecture().GetAddressByteSize()); - - RegisterValue r2_value, r3_value, f0_value, f1_value, f2_value; - // Tracks how much bytes of r2 and r3 registers we've consumed so far - uint32_t integer_bytes = 0; - - // True if return values are in FP return registers. - bool use_fp_regs = 0; - // True if we found any non floating point field in structure. - bool found_non_fp_field = 0; - // True if return values are in r2 register. - bool use_r2 = 0; - // True if return values are in r3 register. - bool use_r3 = 0; - // True if the result is copied into our data buffer - bool sucess = 0; - std::string name; - bool is_complex; - uint32_t count; - const uint32_t num_children = return_compiler_type.GetNumFields(); - - // A structure consisting of one or two FP values (and nothing else) will - // be returned in the two FP return-value registers i.e fp0 and fp2. - - if (num_children <= 2) - { - uint64_t field_bit_offset = 0; - - // Check if this structure contains only floating point fields - for (uint32_t idx = 0; idx < num_children; idx++) - { - CompilerType field_compiler_type = - return_compiler_type.GetFieldAtIndex(idx, name, &field_bit_offset, - nullptr, nullptr); - - if (field_compiler_type.IsFloatingPointType(count, is_complex)) - use_fp_regs = 1; - else - found_non_fp_field = 1; - } - - if (use_fp_regs && !found_non_fp_field) - { - // We have one or two FP-only values in this structure. Get it from - // f0/f2 registers. - DataExtractor f0_data, f1_data, f2_data; - const RegisterInfo *f0_info = reg_ctx->GetRegisterInfoByName("f0", 0); - const RegisterInfo *f1_info = reg_ctx->GetRegisterInfoByName("f1", 0); - const RegisterInfo *f2_info = reg_ctx->GetRegisterInfoByName("f2", 0); - - reg_ctx->ReadRegister(f0_info, f0_value); - reg_ctx->ReadRegister(f2_info, f2_value); - - f0_value.GetData(f0_data); - - - for (uint32_t idx = 0; idx < num_children; idx++) - { - CompilerType field_compiler_type = return_compiler_type.GetFieldAtIndex(idx, name, - &field_bit_offset, - nullptr, nullptr); - const size_t field_byte_width = field_compiler_type.GetByteSize(nullptr); - - DataExtractor *copy_from_extractor = nullptr; - uint64_t return_value[2]; - offset_t offset = 0; - - if (idx == 0) - { - // This case is for long double type. - if (field_byte_width == 16) - { - - // If structure contains long double type, then it is returned - // in fp0/fp1 registers. - - - - if (target_byte_order == eByteOrderLittle) - { - return_value[0] = f0_data.GetU64(&offset); - reg_ctx->ReadRegister(f1_info, f1_value); - f1_value.GetData(f1_data); - offset = 0; - return_value[1] = f1_data.GetU64(&offset); - } - else - { - return_value[1] = f0_data.GetU64(&offset); - reg_ctx->ReadRegister(f1_info, f1_value); - f1_value.GetData(f1_data); - offset = 0; - return_value[0] = f1_data.GetU64(&offset); - } - - f0_data.SetData(return_value, field_byte_width, - target_byte_order); - } - copy_from_extractor = &f0_data; // This is in f0, copy from + if (success) + return_valobj_sp = ValueObjectConstResult::Create( + thread.GetStackFrameAtIndex(0).get(), value, ConstString("")); + } else if (type_flags & eTypeIsStructUnion || type_flags & eTypeIsClass || + type_flags & eTypeIsVector) { + // Any structure of up to 16 bytes in size is returned in the registers. + if (byte_size <= 16) { + DataBufferSP data_sp(new DataBufferHeap(16, 0)); + DataExtractor return_ext(data_sp, target_byte_order, + target->GetArchitecture().GetAddressByteSize()); + + RegisterValue r2_value, r3_value, f0_value, f1_value, f2_value; + // Tracks how much bytes of r2 and r3 registers we've consumed so far + uint32_t integer_bytes = 0; + + // True if return values are in FP return registers. + bool use_fp_regs = 0; + // True if we found any non floating point field in structure. + bool found_non_fp_field = 0; + // True if return values are in r2 register. + bool use_r2 = 0; + // True if return values are in r3 register. + bool use_r3 = 0; + // True if the result is copied into our data buffer + bool sucess = 0; + std::string name; + bool is_complex; + uint32_t count; + const uint32_t num_children = return_compiler_type.GetNumFields(); + + // A structure consisting of one or two FP values (and nothing else) will + // be returned in the two FP return-value registers i.e fp0 and fp2. + if (num_children <= 2) { + uint64_t field_bit_offset = 0; + + // Check if this structure contains only floating point fields + for (uint32_t idx = 0; idx < num_children; idx++) { + CompilerType field_compiler_type = + return_compiler_type.GetFieldAtIndex(idx, name, &field_bit_offset, + nullptr, nullptr); + + if (field_compiler_type.IsFloatingPointType(count, is_complex)) + use_fp_regs = 1; + else + found_non_fp_field = 1; + } + + if (use_fp_regs && !found_non_fp_field) { + // We have one or two FP-only values in this structure. Get it from + // f0/f2 registers. + DataExtractor f0_data, f1_data, f2_data; + const RegisterInfo *f0_info = reg_ctx->GetRegisterInfoByName("f0", 0); + const RegisterInfo *f1_info = reg_ctx->GetRegisterInfoByName("f1", 0); + const RegisterInfo *f2_info = reg_ctx->GetRegisterInfoByName("f2", 0); + + reg_ctx->ReadRegister(f0_info, f0_value); + reg_ctx->ReadRegister(f2_info, f2_value); + + f0_value.GetData(f0_data); + + for (uint32_t idx = 0; idx < num_children; idx++) { + CompilerType field_compiler_type = + return_compiler_type.GetFieldAtIndex( + idx, name, &field_bit_offset, nullptr, nullptr); + const size_t field_byte_width = + field_compiler_type.GetByteSize(nullptr); + + DataExtractor *copy_from_extractor = nullptr; + uint64_t return_value[2]; + offset_t offset = 0; + + if (idx == 0) { + // This case is for long double type. + if (field_byte_width == 16) { + + // If structure contains long double type, then it is returned + // in fp0/fp1 registers. + if (target_byte_order == eByteOrderLittle) { + return_value[0] = f0_data.GetU64(&offset); + reg_ctx->ReadRegister(f1_info, f1_value); + f1_value.GetData(f1_data); + offset = 0; + return_value[1] = f1_data.GetU64(&offset); + } else { + return_value[1] = f0_data.GetU64(&offset); + reg_ctx->ReadRegister(f1_info, f1_value); + f1_value.GetData(f1_data); + offset = 0; + return_value[0] = f1_data.GetU64(&offset); + } + + f0_data.SetData(return_value, field_byte_width, + target_byte_order); + } + copy_from_extractor = &f0_data; // This is in f0, copy from // register to our result // structure - } - else - { - f2_value.GetData(f2_data); - // This is in f2, copy from register to our result structure - copy_from_extractor = &f2_data; - } - - // Sanity check to avoid crash - if (!copy_from_extractor || field_byte_width > copy_from_extractor->GetByteSize()) - return return_valobj_sp; - - // copy the register contents into our data buffer - copy_from_extractor->CopyByteOrderedData(0, field_byte_width,data_sp->GetBytes() + (field_bit_offset / 8), - field_byte_width, target_byte_order); - } - - // The result is in our data buffer. Create a variable object out of - // it - return_valobj_sp = ValueObjectConstResult::Create(&thread, return_compiler_type, ConstString(""), - return_ext); - - return return_valobj_sp; - } - } - - - // If we reach here, it means this structure either contains more than two fields or - // it contains at least one non floating point type. - // In that case, all fields are returned in GP return registers. - for (uint32_t idx = 0; idx < num_children; idx++) - { - uint64_t field_bit_offset = 0; - bool is_signed; - uint32_t padding; - - CompilerType field_compiler_type = return_compiler_type.GetFieldAtIndex(idx, name, &field_bit_offset, nullptr, nullptr); - const size_t field_byte_width = field_compiler_type.GetByteSize(nullptr); - - // if we don't know the size of the field (e.g. invalid type), just bail out - if (field_byte_width == 0) - break; - - uint32_t field_byte_offset = field_bit_offset/8; - - if (field_compiler_type.IsIntegerOrEnumerationType (is_signed) - || field_compiler_type.IsPointerType () - || field_compiler_type.IsFloatingPointType (count, is_complex)) - { - padding = field_byte_offset - integer_bytes; - - if (integer_bytes < 8) - { - // We have not yet consumed r2 completely. - if (integer_bytes + field_byte_width + padding <= 8) - { - // This field fits in r2, copy its value from r2 to our result structure - integer_bytes = integer_bytes + field_byte_width + padding; // Increase the consumed bytes. - use_r2 = 1; - } - else - { - // There isn't enough space left in r2 for this field, so this will be in r3. - integer_bytes = integer_bytes + field_byte_width + padding; // Increase the consumed bytes. - use_r3 = 1; - } - } - // We already have consumed at-least 8 bytes that means r2 is done, and this field will be in r3. - // Check if this field can fit in r3. - else if (integer_bytes + field_byte_width + padding <= 16) - { - integer_bytes = integer_bytes + field_byte_width + padding; - use_r3 = 1; - } - else - { - // There isn't any space left for this field, this should not happen as we have already checked - // the overall size is not greater than 16 bytes. For now, return a nullptr return value object. - return return_valobj_sp; - } - } - } - // Vector types upto 16 bytes are returned in GP return registers - if (type_flags & eTypeIsVector) - { - if (byte_size <= 8) - use_r2 = 1; - else - { - use_r2 = 1; - use_r3 = 1; - } + } else { + f2_value.GetData(f2_data); + // This is in f2, copy from register to our result structure + copy_from_extractor = &f2_data; } - if (use_r2) - { - reg_ctx->ReadRegister (r2_info, r2_value); - - const size_t bytes_copied = r2_value.GetAsMemoryData (r2_info, - data_sp->GetBytes(), - r2_info->byte_size, - target_byte_order, - error); - if (bytes_copied != r2_info->byte_size) - return return_valobj_sp; - sucess = 1; - } - if (use_r3) - { - reg_ctx->ReadRegister (r3_info, r3_value); - const size_t bytes_copied = r3_value.GetAsMemoryData (r3_info, - data_sp->GetBytes() + r2_info->byte_size, - r3_info->byte_size, - target_byte_order, - error); - - if (bytes_copied != r3_info->byte_size) - return return_valobj_sp; - sucess = 1; - } - if (sucess) - { - // The result is in our data buffer. Create a variable object out of it - return_valobj_sp = ValueObjectConstResult::Create (&thread, - return_compiler_type, - ConstString(""), - return_ext); + // Sanity check to avoid crash + if (!copy_from_extractor || + field_byte_width > copy_from_extractor->GetByteSize()) + return return_valobj_sp; + + // copy the register contents into our data buffer + copy_from_extractor->CopyByteOrderedData( + 0, field_byte_width, + data_sp->GetBytes() + (field_bit_offset / 8), field_byte_width, + target_byte_order); + } + + // The result is in our data buffer. Create a variable object out of + // it + return_valobj_sp = ValueObjectConstResult::Create( + &thread, return_compiler_type, ConstString(""), return_ext); + + return return_valobj_sp; + } + } + + // If we reach here, it means this structure either contains more than two + // fields or + // it contains at least one non floating point type. + // In that case, all fields are returned in GP return registers. + for (uint32_t idx = 0; idx < num_children; idx++) { + uint64_t field_bit_offset = 0; + bool is_signed; + uint32_t padding; + + CompilerType field_compiler_type = return_compiler_type.GetFieldAtIndex( + idx, name, &field_bit_offset, nullptr, nullptr); + const size_t field_byte_width = + field_compiler_type.GetByteSize(nullptr); + + // if we don't know the size of the field (e.g. invalid type), just bail + // out + if (field_byte_width == 0) + break; + + uint32_t field_byte_offset = field_bit_offset / 8; + + if (field_compiler_type.IsIntegerOrEnumerationType(is_signed) || + field_compiler_type.IsPointerType() || + field_compiler_type.IsFloatingPointType(count, is_complex)) { + padding = field_byte_offset - integer_bytes; + + if (integer_bytes < 8) { + // We have not yet consumed r2 completely. + if (integer_bytes + field_byte_width + padding <= 8) { + // This field fits in r2, copy its value from r2 to our result + // structure + integer_bytes = integer_bytes + field_byte_width + + padding; // Increase the consumed bytes. + use_r2 = 1; + } else { + // There isn't enough space left in r2 for this field, so this + // will be in r3. + integer_bytes = integer_bytes + field_byte_width + + padding; // Increase the consumed bytes. + use_r3 = 1; } + } + // We already have consumed at-least 8 bytes that means r2 is done, + // and this field will be in r3. + // Check if this field can fit in r3. + else if (integer_bytes + field_byte_width + padding <= 16) { + integer_bytes = integer_bytes + field_byte_width + padding; + use_r3 = 1; + } else { + // There isn't any space left for this field, this should not happen + // as we have already checked + // the overall size is not greater than 16 bytes. For now, return a + // nullptr return value object. return return_valobj_sp; + } + } + } + // Vector types up to 16 bytes are returned in GP return registers + if (type_flags & eTypeIsVector) { + if (byte_size <= 8) + use_r2 = 1; + else { + use_r2 = 1; + use_r3 = 1; } + } + + if (use_r2) { + reg_ctx->ReadRegister(r2_info, r2_value); + + const size_t bytes_copied = r2_value.GetAsMemoryData( + r2_info, data_sp->GetBytes(), r2_info->byte_size, target_byte_order, + error); + if (bytes_copied != r2_info->byte_size) + return return_valobj_sp; + sucess = 1; + } + if (use_r3) { + reg_ctx->ReadRegister(r3_info, r3_value); + const size_t bytes_copied = r3_value.GetAsMemoryData( + r3_info, data_sp->GetBytes() + r2_info->byte_size, + r3_info->byte_size, target_byte_order, error); + + if (bytes_copied != r3_info->byte_size) + return return_valobj_sp; + sucess = 1; + } + if (sucess) { + // The result is in our data buffer. Create a variable object out of it + return_valobj_sp = ValueObjectConstResult::Create( + &thread, return_compiler_type, ConstString(""), return_ext); + } + return return_valobj_sp; + } - // Any structure/vector greater than 16 bytes in size is returned in memory. - // The pointer to that memory is returned in r2. - uint64_t mem_address = reg_ctx->ReadRegisterAsUnsigned(reg_ctx->GetRegisterInfoByName("r2", 0), 0); + // Any structure/vector greater than 16 bytes in size is returned in memory. + // The pointer to that memory is returned in r2. + uint64_t mem_address = reg_ctx->ReadRegisterAsUnsigned( + reg_ctx->GetRegisterInfoByName("r2", 0), 0); - // We have got the address. Create a memory object out of it - return_valobj_sp = ValueObjectMemory::Create(&thread, - "", - Address(mem_address, nullptr), - return_compiler_type); - } - return return_valobj_sp; + // We have got the address. Create a memory object out of it + return_valobj_sp = ValueObjectMemory::Create( + &thread, "", Address(mem_address, nullptr), return_compiler_type); + } + return return_valobj_sp; } -bool -ABISysV_mips64::CreateFunctionEntryUnwindPlan (UnwindPlan &unwind_plan) -{ - unwind_plan.Clear(); - unwind_plan.SetRegisterKind (eRegisterKindDWARF); +bool ABISysV_mips64::CreateFunctionEntryUnwindPlan(UnwindPlan &unwind_plan) { + unwind_plan.Clear(); + unwind_plan.SetRegisterKind(eRegisterKindDWARF); - UnwindPlan::RowSP row(new UnwindPlan::Row); + UnwindPlan::RowSP row(new UnwindPlan::Row); - // Our Call Frame Address is the stack pointer value - row->GetCFAValue().SetIsRegisterPlusOffset(dwarf_r29, 0); + // Our Call Frame Address is the stack pointer value + row->GetCFAValue().SetIsRegisterPlusOffset(dwarf_r29, 0); - // The previous PC is in the RA - row->SetRegisterLocationToRegister(dwarf_pc, dwarf_r31, true); - unwind_plan.AppendRow (row); + // The previous PC is in the RA + row->SetRegisterLocationToRegister(dwarf_pc, dwarf_r31, true); + unwind_plan.AppendRow(row); - // All other registers are the same. + // All other registers are the same. - unwind_plan.SetSourceName ("mips64 at-func-entry default"); - unwind_plan.SetSourcedFromCompiler (eLazyBoolNo); - unwind_plan.SetReturnAddressRegister(dwarf_r31); - return true; + unwind_plan.SetSourceName("mips64 at-func-entry default"); + unwind_plan.SetSourcedFromCompiler(eLazyBoolNo); + unwind_plan.SetReturnAddressRegister(dwarf_r31); + return true; } -bool -ABISysV_mips64::CreateDefaultUnwindPlan (UnwindPlan &unwind_plan) -{ - unwind_plan.Clear(); - unwind_plan.SetRegisterKind (eRegisterKindDWARF); +bool ABISysV_mips64::CreateDefaultUnwindPlan(UnwindPlan &unwind_plan) { + unwind_plan.Clear(); + unwind_plan.SetRegisterKind(eRegisterKindDWARF); - UnwindPlan::RowSP row(new UnwindPlan::Row); + UnwindPlan::RowSP row(new UnwindPlan::Row); - row->GetCFAValue().SetIsRegisterPlusOffset(dwarf_r29, 0); + row->GetCFAValue().SetIsRegisterPlusOffset(dwarf_r29, 0); - row->SetRegisterLocationToRegister(dwarf_pc, dwarf_r31, true); + row->SetRegisterLocationToRegister(dwarf_pc, dwarf_r31, true); - unwind_plan.AppendRow (row); - unwind_plan.SetSourceName ("mips64 default unwind plan"); - unwind_plan.SetSourcedFromCompiler (eLazyBoolNo); - unwind_plan.SetUnwindPlanValidAtAllInstructions (eLazyBoolNo); - return true; + unwind_plan.AppendRow(row); + unwind_plan.SetSourceName("mips64 default unwind plan"); + unwind_plan.SetSourcedFromCompiler(eLazyBoolNo); + unwind_plan.SetUnwindPlanValidAtAllInstructions(eLazyBoolNo); + return true; } -bool -ABISysV_mips64::RegisterIsVolatile (const RegisterInfo *reg_info) -{ - return !RegisterIsCalleeSaved (reg_info); +bool ABISysV_mips64::RegisterIsVolatile(const RegisterInfo *reg_info) { + return !RegisterIsCalleeSaved(reg_info); } -bool -ABISysV_mips64::IsSoftFloat (uint32_t fp_flag) const -{ - return (fp_flag == lldb_private::ArchSpec::eMIPS_ABI_FP_SOFT); +bool ABISysV_mips64::IsSoftFloat(uint32_t fp_flag) const { + return (fp_flag == lldb_private::ArchSpec::eMIPS_ABI_FP_SOFT); } -bool -ABISysV_mips64::RegisterIsCalleeSaved (const RegisterInfo *reg_info) -{ - if (reg_info) - { - // Preserved registers are : - // r16-r23, r28, r29, r30, r31 +bool ABISysV_mips64::RegisterIsCalleeSaved(const RegisterInfo *reg_info) { + if (reg_info) { + // Preserved registers are : + // r16-r23, r28, r29, r30, r31 - int reg = ((reg_info->byte_offset) / 8); + int reg = ((reg_info->byte_offset) / 8); - bool save = (reg >= 16) && (reg <= 23); - save |= (reg >= 28) && (reg <= 31); + bool save = (reg >= 16) && (reg <= 23); + save |= (reg >= 28) && (reg <= 31); - return save; - } - return false; + return save; + } + return false; } -void -ABISysV_mips64::Initialize() -{ - PluginManager::RegisterPlugin (GetPluginNameStatic(), - "System V ABI for mips64 targets", - CreateInstance); +void ABISysV_mips64::Initialize() { + PluginManager::RegisterPlugin( + GetPluginNameStatic(), "System V ABI for mips64 targets", CreateInstance); } -void -ABISysV_mips64::Terminate() -{ - PluginManager::UnregisterPlugin (CreateInstance); +void ABISysV_mips64::Terminate() { + PluginManager::UnregisterPlugin(CreateInstance); } -lldb_private::ConstString -ABISysV_mips64::GetPluginNameStatic() -{ - static ConstString g_name("sysv-mips64"); - return g_name; +lldb_private::ConstString ABISysV_mips64::GetPluginNameStatic() { + static ConstString g_name("sysv-mips64"); + return g_name; } //------------------------------------------------------------------ // PluginInterface protocol //------------------------------------------------------------------ -lldb_private::ConstString -ABISysV_mips64::GetPluginName() -{ - return GetPluginNameStatic(); +lldb_private::ConstString ABISysV_mips64::GetPluginName() { + return GetPluginNameStatic(); } -uint32_t -ABISysV_mips64::GetPluginVersion() -{ - return 1; -} +uint32_t ABISysV_mips64::GetPluginVersion() { return 1; } diff --git a/source/Plugins/ABI/SysV-mips64/ABISysV_mips64.h b/source/Plugins/ABI/SysV-mips64/ABISysV_mips64.h index 9f1ea0922db3..672a43825625 100644 --- a/source/Plugins/ABI/SysV-mips64/ABISysV_mips64.h +++ b/source/Plugins/ABI/SysV-mips64/ABISysV_mips64.h @@ -14,125 +14,104 @@ // C++ Includes // Other libraries and framework includes // Project includes -#include "lldb/lldb-private.h" #include "lldb/Target/ABI.h" +#include "lldb/lldb-private.h" -class ABISysV_mips64 : - public lldb_private::ABI -{ +class ABISysV_mips64 : public lldb_private::ABI { public: - ~ABISysV_mips64() override = default; - - size_t - GetRedZoneSize() const override; - - bool - PrepareTrivialCall(lldb_private::Thread &thread, - lldb::addr_t sp, - lldb::addr_t functionAddress, - lldb::addr_t returnAddress, - llvm::ArrayRef<lldb::addr_t> args) const override; - - bool - GetArgumentValues(lldb_private::Thread &thread, - lldb_private::ValueList &values) const override; - - lldb_private::Error - SetReturnValueObject(lldb::StackFrameSP &frame_sp, lldb::ValueObjectSP &new_value) override; - - lldb::ValueObjectSP - GetReturnValueObjectImpl(lldb_private::Thread &thread, - lldb_private::CompilerType &type) const override; - - bool - CreateFunctionEntryUnwindPlan(lldb_private::UnwindPlan &unwind_plan) override; - - bool - CreateDefaultUnwindPlan(lldb_private::UnwindPlan &unwind_plan) override; - - bool - RegisterIsVolatile(const lldb_private::RegisterInfo *reg_info) override; - - bool - IsSoftFloat(uint32_t fp_flag) const; - - // The SysV mips ABI requires that stack frames be 16 byte aligned. - // When there is a trap handler on the stack, e.g. _sigtramp in userland - // code, we've seen that the stack pointer is often not aligned properly - // before the handler is invoked. This means that lldb will stop the unwind - // early -- before the function which caused the trap. - // - // To work around this, we relax that alignment to be just word-size (8-bytes). - // Whitelisting the trap handlers for user space would be easy (_sigtramp) but - // in other environments there can be a large number of different functions - // involved in async traps. - bool - CallFrameAddressIsValid(lldb::addr_t cfa) override - { - // Make sure the stack call frame addresses are 8 byte aligned - if (cfa & (8ull - 1ull)) - return false; // Not 8 byte aligned - if (cfa == 0) - return false; // Zero is not a valid stack address - return true; - } - - bool - CodeAddressIsValid(lldb::addr_t pc) override - { - if (pc & (4ull - 1ull)) - return false; // Not 4 byte aligned - - // Anything else if fair game.. - return true; - } - - const lldb_private::RegisterInfo * - GetRegisterInfoArray(uint32_t &count) override; - - //------------------------------------------------------------------ - // Static Functions - //------------------------------------------------------------------ - - static void - Initialize(); - - static void - Terminate(); - - static lldb::ABISP - CreateInstance (const lldb_private::ArchSpec &arch); - - static lldb_private::ConstString - GetPluginNameStatic(); - - //------------------------------------------------------------------ - // PluginInterface protocol - //------------------------------------------------------------------ - - lldb_private::ConstString - GetPluginName() override; - - uint32_t - GetPluginVersion() override; + ~ABISysV_mips64() override = default; + + size_t GetRedZoneSize() const override; + + bool PrepareTrivialCall(lldb_private::Thread &thread, lldb::addr_t sp, + lldb::addr_t functionAddress, + lldb::addr_t returnAddress, + llvm::ArrayRef<lldb::addr_t> args) const override; + + bool GetArgumentValues(lldb_private::Thread &thread, + lldb_private::ValueList &values) const override; + + lldb_private::Error + SetReturnValueObject(lldb::StackFrameSP &frame_sp, + lldb::ValueObjectSP &new_value) override; + + lldb::ValueObjectSP + GetReturnValueObjectImpl(lldb_private::Thread &thread, + lldb_private::CompilerType &type) const override; + + bool + CreateFunctionEntryUnwindPlan(lldb_private::UnwindPlan &unwind_plan) override; + + bool CreateDefaultUnwindPlan(lldb_private::UnwindPlan &unwind_plan) override; + + bool RegisterIsVolatile(const lldb_private::RegisterInfo *reg_info) override; + + bool IsSoftFloat(uint32_t fp_flag) const; + + // The SysV mips ABI requires that stack frames be 16 byte aligned. + // When there is a trap handler on the stack, e.g. _sigtramp in userland + // code, we've seen that the stack pointer is often not aligned properly + // before the handler is invoked. This means that lldb will stop the unwind + // early -- before the function which caused the trap. + // + // To work around this, we relax that alignment to be just word-size + // (8-bytes). + // Whitelisting the trap handlers for user space would be easy (_sigtramp) but + // in other environments there can be a large number of different functions + // involved in async traps. + bool CallFrameAddressIsValid(lldb::addr_t cfa) override { + // Make sure the stack call frame addresses are 8 byte aligned + if (cfa & (8ull - 1ull)) + return false; // Not 8 byte aligned + if (cfa == 0) + return false; // Zero is not a valid stack address + return true; + } + + bool CodeAddressIsValid(lldb::addr_t pc) override { + if (pc & (4ull - 1ull)) + return false; // Not 4 byte aligned + + // Anything else if fair game.. + return true; + } + + const lldb_private::RegisterInfo * + GetRegisterInfoArray(uint32_t &count) override; + + //------------------------------------------------------------------ + // Static Functions + //------------------------------------------------------------------ + + static void Initialize(); + + static void Terminate(); + + static lldb::ABISP CreateInstance(const lldb_private::ArchSpec &arch); + + static lldb_private::ConstString GetPluginNameStatic(); + + //------------------------------------------------------------------ + // PluginInterface protocol + //------------------------------------------------------------------ + + lldb_private::ConstString GetPluginName() override; + + uint32_t GetPluginVersion() override; protected: - void - CreateRegisterMapIfNeeded (); + void CreateRegisterMapIfNeeded(); - lldb::ValueObjectSP - GetReturnValueObjectSimple(lldb_private::Thread &thread, - lldb_private::CompilerType &ast_type) const; + lldb::ValueObjectSP + GetReturnValueObjectSimple(lldb_private::Thread &thread, + lldb_private::CompilerType &ast_type) const; - bool - RegisterIsCalleeSaved (const lldb_private::RegisterInfo *reg_info); + bool RegisterIsCalleeSaved(const lldb_private::RegisterInfo *reg_info); private: - ABISysV_mips64() : - lldb_private::ABI() - { - // Call CreateInstance instead. - } + ABISysV_mips64() : lldb_private::ABI() { + // Call CreateInstance instead. + } }; #endif // liblldb_ABISysV_mips64_h_ diff --git a/source/Plugins/ABI/SysV-ppc/ABISysV_ppc.cpp b/source/Plugins/ABI/SysV-ppc/ABISysV_ppc.cpp index 20ff17d0b763..3e563c2b5d9c 100644 --- a/source/Plugins/ABI/SysV-ppc/ABISysV_ppc.cpp +++ b/source/Plugins/ABI/SysV-ppc/ABISysV_ppc.cpp @@ -25,231 +25,271 @@ #include "lldb/Core/RegisterValue.h" #include "lldb/Core/Value.h" #include "lldb/Core/ValueObjectConstResult.h" -#include "lldb/Core/ValueObjectRegister.h" #include "lldb/Core/ValueObjectMemory.h" +#include "lldb/Core/ValueObjectRegister.h" #include "lldb/Symbol/UnwindPlan.h" -#include "lldb/Target/Target.h" #include "lldb/Target/Process.h" #include "lldb/Target/RegisterContext.h" #include "lldb/Target/StackFrame.h" +#include "lldb/Target/Target.h" #include "lldb/Target/Thread.h" using namespace lldb; using namespace lldb_private; -enum dwarf_regnums -{ - dwarf_r0 = 0, - dwarf_r1, - dwarf_r2, - dwarf_r3, - dwarf_r4, - dwarf_r5, - dwarf_r6, - dwarf_r7, - dwarf_r8, - dwarf_r9, - dwarf_r10, - dwarf_r11, - dwarf_r12, - dwarf_r13, - dwarf_r14, - dwarf_r15, - dwarf_r16, - dwarf_r17, - dwarf_r18, - dwarf_r19, - dwarf_r20, - dwarf_r21, - dwarf_r22, - dwarf_r23, - dwarf_r24, - dwarf_r25, - dwarf_r26, - dwarf_r27, - dwarf_r28, - dwarf_r29, - dwarf_r30, - dwarf_r31, - dwarf_f0, - dwarf_f1, - dwarf_f2, - dwarf_f3, - dwarf_f4, - dwarf_f5, - dwarf_f6, - dwarf_f7, - dwarf_f8, - dwarf_f9, - dwarf_f10, - dwarf_f11, - dwarf_f12, - dwarf_f13, - dwarf_f14, - dwarf_f15, - dwarf_f16, - dwarf_f17, - dwarf_f18, - dwarf_f19, - dwarf_f20, - dwarf_f21, - dwarf_f22, - dwarf_f23, - dwarf_f24, - dwarf_f25, - dwarf_f26, - dwarf_f27, - dwarf_f28, - dwarf_f29, - dwarf_f30, - dwarf_f31, - dwarf_cr, - dwarf_fpscr, - dwarf_xer = 101, - dwarf_lr = 108, - dwarf_ctr, - dwarf_pc, - dwarf_cfa, +enum dwarf_regnums { + dwarf_r0 = 0, + dwarf_r1, + dwarf_r2, + dwarf_r3, + dwarf_r4, + dwarf_r5, + dwarf_r6, + dwarf_r7, + dwarf_r8, + dwarf_r9, + dwarf_r10, + dwarf_r11, + dwarf_r12, + dwarf_r13, + dwarf_r14, + dwarf_r15, + dwarf_r16, + dwarf_r17, + dwarf_r18, + dwarf_r19, + dwarf_r20, + dwarf_r21, + dwarf_r22, + dwarf_r23, + dwarf_r24, + dwarf_r25, + dwarf_r26, + dwarf_r27, + dwarf_r28, + dwarf_r29, + dwarf_r30, + dwarf_r31, + dwarf_f0, + dwarf_f1, + dwarf_f2, + dwarf_f3, + dwarf_f4, + dwarf_f5, + dwarf_f6, + dwarf_f7, + dwarf_f8, + dwarf_f9, + dwarf_f10, + dwarf_f11, + dwarf_f12, + dwarf_f13, + dwarf_f14, + dwarf_f15, + dwarf_f16, + dwarf_f17, + dwarf_f18, + dwarf_f19, + dwarf_f20, + dwarf_f21, + dwarf_f22, + dwarf_f23, + dwarf_f24, + dwarf_f25, + dwarf_f26, + dwarf_f27, + dwarf_f28, + dwarf_f29, + dwarf_f30, + dwarf_f31, + dwarf_cr, + dwarf_fpscr, + dwarf_xer = 101, + dwarf_lr = 108, + dwarf_ctr, + dwarf_pc, + dwarf_cfa, }; // Note that the size and offset will be updated by platform-specific classes. -#define DEFINE_GPR(reg, alt, kind1, kind2, kind3, kind4) \ - { #reg, alt, 8, 0, eEncodingUint, \ - eFormatHex, { kind1, kind2, kind3, kind4}, nullptr, nullptr } - -static const RegisterInfo -g_register_infos[] = -{ - // General purpose registers. eh_frame, DWARF, Generic, Process Plugin - DEFINE_GPR(r0, nullptr, dwarf_r0, dwarf_r0, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM), - DEFINE_GPR(r1, "sp", dwarf_r1, dwarf_r1, LLDB_REGNUM_GENERIC_SP, LLDB_INVALID_REGNUM), - DEFINE_GPR(r2, nullptr, dwarf_r2, dwarf_r2, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM), - DEFINE_GPR(r3, "arg1", dwarf_r3, dwarf_r3, LLDB_REGNUM_GENERIC_ARG1, LLDB_INVALID_REGNUM), - DEFINE_GPR(r4, "arg2", dwarf_r4, dwarf_r4, LLDB_REGNUM_GENERIC_ARG2 ,LLDB_INVALID_REGNUM), - DEFINE_GPR(r5, "arg3", dwarf_r5, dwarf_r5, LLDB_REGNUM_GENERIC_ARG3, LLDB_INVALID_REGNUM), - DEFINE_GPR(r6, "arg4", dwarf_r6, dwarf_r6, LLDB_REGNUM_GENERIC_ARG4, LLDB_INVALID_REGNUM), - DEFINE_GPR(r7, "arg5", dwarf_r7, dwarf_r7, LLDB_REGNUM_GENERIC_ARG5, LLDB_INVALID_REGNUM), - DEFINE_GPR(r8, "arg6", dwarf_r8, dwarf_r8, LLDB_REGNUM_GENERIC_ARG6, LLDB_INVALID_REGNUM), - DEFINE_GPR(r9, "arg7", dwarf_r9, dwarf_r9, LLDB_REGNUM_GENERIC_ARG7, LLDB_INVALID_REGNUM), - DEFINE_GPR(r10, "arg8", dwarf_r10, dwarf_r10, LLDB_REGNUM_GENERIC_ARG8, LLDB_INVALID_REGNUM), - DEFINE_GPR(r11, nullptr, dwarf_r11, dwarf_r11, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM), - DEFINE_GPR(r12, nullptr, dwarf_r12, dwarf_r12, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM), - DEFINE_GPR(r13, nullptr, dwarf_r13, dwarf_r13, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM), - DEFINE_GPR(r14, nullptr, dwarf_r14, dwarf_r14, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM), - DEFINE_GPR(r15, nullptr, dwarf_r15, dwarf_r15, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM), - DEFINE_GPR(r16, nullptr, dwarf_r16, dwarf_r16, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM), - DEFINE_GPR(r17, nullptr, dwarf_r17, dwarf_r17, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM), - DEFINE_GPR(r18, nullptr, dwarf_r18, dwarf_r18, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM), - DEFINE_GPR(r19, nullptr, dwarf_r19, dwarf_r19, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM), - DEFINE_GPR(r20, nullptr, dwarf_r20, dwarf_r20, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM), - DEFINE_GPR(r21, nullptr, dwarf_r21, dwarf_r21, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM), - DEFINE_GPR(r22, nullptr, dwarf_r22, dwarf_r22, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM), - DEFINE_GPR(r23, nullptr, dwarf_r23, dwarf_r23, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM), - DEFINE_GPR(r24, nullptr, dwarf_r24, dwarf_r24, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM), - DEFINE_GPR(r25, nullptr, dwarf_r25, dwarf_r25, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM), - DEFINE_GPR(r26, nullptr, dwarf_r26, dwarf_r26, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM), - DEFINE_GPR(r27, nullptr, dwarf_r27, dwarf_r27, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM), - DEFINE_GPR(r28, nullptr, dwarf_r28, dwarf_r28, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM), - DEFINE_GPR(r29, nullptr, dwarf_r29, dwarf_r29, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM), - DEFINE_GPR(r30, nullptr, dwarf_r30, dwarf_r30, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM), - DEFINE_GPR(r31, nullptr, dwarf_r31, dwarf_r31, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM), - DEFINE_GPR(lr, "lr", dwarf_lr, dwarf_lr, LLDB_REGNUM_GENERIC_RA, LLDB_INVALID_REGNUM), - DEFINE_GPR(cr, "cr", dwarf_cr, dwarf_cr, LLDB_REGNUM_GENERIC_FLAGS, LLDB_INVALID_REGNUM), - DEFINE_GPR(xer, "xer", dwarf_xer, dwarf_xer, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM), - DEFINE_GPR(ctr, "ctr", dwarf_ctr, dwarf_ctr, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM), - DEFINE_GPR(pc, "pc", dwarf_pc, dwarf_pc, LLDB_REGNUM_GENERIC_PC, LLDB_INVALID_REGNUM), - { nullptr, nullptr, 8, 0, eEncodingUint, eFormatHex, { dwarf_cfa, dwarf_cfa, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr } -}; - -static const uint32_t k_num_register_infos = llvm::array_lengthof(g_register_infos); +#define DEFINE_GPR(reg, alt, kind1, kind2, kind3, kind4) \ + { \ + #reg, alt, 8, 0, eEncodingUint, eFormatHex, {kind1, kind2, kind3, kind4 }, \ + nullptr, nullptr, nullptr, 0 \ + } + +static const RegisterInfo g_register_infos[] = { + // General purpose registers. eh_frame, DWARF, + // Generic, Process Plugin + DEFINE_GPR(r0, nullptr, dwarf_r0, dwarf_r0, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM), + DEFINE_GPR(r1, "sp", dwarf_r1, dwarf_r1, LLDB_REGNUM_GENERIC_SP, + LLDB_INVALID_REGNUM), + DEFINE_GPR(r2, nullptr, dwarf_r2, dwarf_r2, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM), + DEFINE_GPR(r3, "arg1", dwarf_r3, dwarf_r3, LLDB_REGNUM_GENERIC_ARG1, + LLDB_INVALID_REGNUM), + DEFINE_GPR(r4, "arg2", dwarf_r4, dwarf_r4, LLDB_REGNUM_GENERIC_ARG2, + LLDB_INVALID_REGNUM), + DEFINE_GPR(r5, "arg3", dwarf_r5, dwarf_r5, LLDB_REGNUM_GENERIC_ARG3, + LLDB_INVALID_REGNUM), + DEFINE_GPR(r6, "arg4", dwarf_r6, dwarf_r6, LLDB_REGNUM_GENERIC_ARG4, + LLDB_INVALID_REGNUM), + DEFINE_GPR(r7, "arg5", dwarf_r7, dwarf_r7, LLDB_REGNUM_GENERIC_ARG5, + LLDB_INVALID_REGNUM), + DEFINE_GPR(r8, "arg6", dwarf_r8, dwarf_r8, LLDB_REGNUM_GENERIC_ARG6, + LLDB_INVALID_REGNUM), + DEFINE_GPR(r9, "arg7", dwarf_r9, dwarf_r9, LLDB_REGNUM_GENERIC_ARG7, + LLDB_INVALID_REGNUM), + DEFINE_GPR(r10, "arg8", dwarf_r10, dwarf_r10, LLDB_REGNUM_GENERIC_ARG8, + LLDB_INVALID_REGNUM), + DEFINE_GPR(r11, nullptr, dwarf_r11, dwarf_r11, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM), + DEFINE_GPR(r12, nullptr, dwarf_r12, dwarf_r12, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM), + DEFINE_GPR(r13, nullptr, dwarf_r13, dwarf_r13, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM), + DEFINE_GPR(r14, nullptr, dwarf_r14, dwarf_r14, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM), + DEFINE_GPR(r15, nullptr, dwarf_r15, dwarf_r15, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM), + DEFINE_GPR(r16, nullptr, dwarf_r16, dwarf_r16, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM), + DEFINE_GPR(r17, nullptr, dwarf_r17, dwarf_r17, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM), + DEFINE_GPR(r18, nullptr, dwarf_r18, dwarf_r18, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM), + DEFINE_GPR(r19, nullptr, dwarf_r19, dwarf_r19, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM), + DEFINE_GPR(r20, nullptr, dwarf_r20, dwarf_r20, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM), + DEFINE_GPR(r21, nullptr, dwarf_r21, dwarf_r21, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM), + DEFINE_GPR(r22, nullptr, dwarf_r22, dwarf_r22, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM), + DEFINE_GPR(r23, nullptr, dwarf_r23, dwarf_r23, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM), + DEFINE_GPR(r24, nullptr, dwarf_r24, dwarf_r24, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM), + DEFINE_GPR(r25, nullptr, dwarf_r25, dwarf_r25, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM), + DEFINE_GPR(r26, nullptr, dwarf_r26, dwarf_r26, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM), + DEFINE_GPR(r27, nullptr, dwarf_r27, dwarf_r27, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM), + DEFINE_GPR(r28, nullptr, dwarf_r28, dwarf_r28, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM), + DEFINE_GPR(r29, nullptr, dwarf_r29, dwarf_r29, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM), + DEFINE_GPR(r30, nullptr, dwarf_r30, dwarf_r30, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM), + DEFINE_GPR(r31, nullptr, dwarf_r31, dwarf_r31, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM), + DEFINE_GPR(lr, "lr", dwarf_lr, dwarf_lr, LLDB_REGNUM_GENERIC_RA, + LLDB_INVALID_REGNUM), + DEFINE_GPR(cr, "cr", dwarf_cr, dwarf_cr, LLDB_REGNUM_GENERIC_FLAGS, + LLDB_INVALID_REGNUM), + DEFINE_GPR(xer, "xer", dwarf_xer, dwarf_xer, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM), + DEFINE_GPR(ctr, "ctr", dwarf_ctr, dwarf_ctr, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM), + DEFINE_GPR(pc, "pc", dwarf_pc, dwarf_pc, LLDB_REGNUM_GENERIC_PC, + LLDB_INVALID_REGNUM), + {nullptr, + nullptr, + 8, + 0, + eEncodingUint, + eFormatHex, + {dwarf_cfa, dwarf_cfa, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}}; + +static const uint32_t k_num_register_infos = + llvm::array_lengthof(g_register_infos); const lldb_private::RegisterInfo * -ABISysV_ppc::GetRegisterInfoArray (uint32_t &count) -{ - count = k_num_register_infos; - return g_register_infos; +ABISysV_ppc::GetRegisterInfoArray(uint32_t &count) { + count = k_num_register_infos; + return g_register_infos; } -size_t -ABISysV_ppc::GetRedZoneSize () const -{ - return 224; -} +size_t ABISysV_ppc::GetRedZoneSize() const { return 224; } //------------------------------------------------------------------ // Static Functions //------------------------------------------------------------------ ABISP -ABISysV_ppc::CreateInstance (const ArchSpec &arch) -{ - static ABISP g_abi_sp; - if (arch.GetTriple().getArch() == llvm::Triple::ppc) - { - if (!g_abi_sp) - g_abi_sp.reset (new ABISysV_ppc); - return g_abi_sp; - } - return ABISP(); +ABISysV_ppc::CreateInstance(const ArchSpec &arch) { + static ABISP g_abi_sp; + if (arch.GetTriple().getArch() == llvm::Triple::ppc) { + if (!g_abi_sp) + g_abi_sp.reset(new ABISysV_ppc); + return g_abi_sp; + } + return ABISP(); } -bool -ABISysV_ppc::PrepareTrivialCall (Thread &thread, - addr_t sp, - addr_t func_addr, - addr_t return_addr, - llvm::ArrayRef<addr_t> args) const -{ - Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS)); +bool ABISysV_ppc::PrepareTrivialCall(Thread &thread, addr_t sp, + addr_t func_addr, addr_t return_addr, + llvm::ArrayRef<addr_t> args) const { + Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS)); - if (log) - { - StreamString s; - s.Printf("ABISysV_ppc::PrepareTrivialCall (tid = 0x%" PRIx64 ", sp = 0x%" PRIx64 ", func_addr = 0x%" PRIx64 ", return_addr = 0x%" PRIx64, - thread.GetID(), - (uint64_t)sp, - (uint64_t)func_addr, - (uint64_t)return_addr); - - for (size_t i = 0; i < args.size(); ++i) - s.Printf (", arg%" PRIu64 " = 0x%" PRIx64, static_cast<uint64_t>(i + 1), args[i]); - s.PutCString (")"); - log->PutCString(s.GetString().c_str()); - } + if (log) { + StreamString s; + s.Printf("ABISysV_ppc::PrepareTrivialCall (tid = 0x%" PRIx64 + ", sp = 0x%" PRIx64 ", func_addr = 0x%" PRIx64 + ", return_addr = 0x%" PRIx64, + thread.GetID(), (uint64_t)sp, (uint64_t)func_addr, + (uint64_t)return_addr); - RegisterContext *reg_ctx = thread.GetRegisterContext().get(); - if (!reg_ctx) - return false; + for (size_t i = 0; i < args.size(); ++i) + s.Printf(", arg%" PRIu64 " = 0x%" PRIx64, static_cast<uint64_t>(i + 1), + args[i]); + s.PutCString(")"); + log->PutString(s.GetString()); + } + + RegisterContext *reg_ctx = thread.GetRegisterContext().get(); + if (!reg_ctx) + return false; - const RegisterInfo *reg_info = nullptr; + const RegisterInfo *reg_info = nullptr; - if (args.size() > 8) // TODO handle more than 8 arguments - return false; + if (args.size() > 8) // TODO handle more than 8 arguments + return false; - for (size_t i = 0; i < args.size(); ++i) - { - reg_info = reg_ctx->GetRegisterInfo(eRegisterKindGeneric, LLDB_REGNUM_GENERIC_ARG1 + i); - if (log) - log->Printf("About to write arg%" PRIu64 " (0x%" PRIx64 ") into %s", static_cast<uint64_t>(i + 1), args[i], reg_info->name); - if (!reg_ctx->WriteRegisterFromUnsigned(reg_info, args[i])) - return false; - } + for (size_t i = 0; i < args.size(); ++i) { + reg_info = reg_ctx->GetRegisterInfo(eRegisterKindGeneric, + LLDB_REGNUM_GENERIC_ARG1 + i); + if (log) + log->Printf("About to write arg%" PRIu64 " (0x%" PRIx64 ") into %s", + static_cast<uint64_t>(i + 1), args[i], reg_info->name); + if (!reg_ctx->WriteRegisterFromUnsigned(reg_info, args[i])) + return false; + } - // First, align the SP + // First, align the SP - if (log) - log->Printf("16-byte aligning SP: 0x%" PRIx64 " to 0x%" PRIx64, (uint64_t)sp, (uint64_t)(sp & ~0xfull)); + if (log) + log->Printf("16-byte aligning SP: 0x%" PRIx64 " to 0x%" PRIx64, + (uint64_t)sp, (uint64_t)(sp & ~0xfull)); - sp &= ~(0xfull); // 16-byte alignment + sp &= ~(0xfull); // 16-byte alignment - sp -= 8; + sp -= 8; - Error error; - const RegisterInfo *pc_reg_info = reg_ctx->GetRegisterInfo (eRegisterKindGeneric, LLDB_REGNUM_GENERIC_PC); - const RegisterInfo *sp_reg_info = reg_ctx->GetRegisterInfo (eRegisterKindGeneric, LLDB_REGNUM_GENERIC_SP); - ProcessSP process_sp (thread.GetProcess()); + Error error; + const RegisterInfo *pc_reg_info = + reg_ctx->GetRegisterInfo(eRegisterKindGeneric, LLDB_REGNUM_GENERIC_PC); + const RegisterInfo *sp_reg_info = + reg_ctx->GetRegisterInfo(eRegisterKindGeneric, LLDB_REGNUM_GENERIC_SP); + ProcessSP process_sp(thread.GetProcess()); - RegisterValue reg_value; + RegisterValue reg_value; #if 0 // This code adds an extra frame so that we don't lose the function that we came from @@ -292,775 +332,692 @@ ABISysV_ppc::PrepareTrivialCall (Thread &thread, } #endif - if (log) - log->Printf("Pushing the return address onto the stack: 0x%" PRIx64 ": 0x%" PRIx64, (uint64_t)sp, (uint64_t)return_addr); + if (log) + log->Printf("Pushing the return address onto the stack: 0x%" PRIx64 + ": 0x%" PRIx64, + (uint64_t)sp, (uint64_t)return_addr); - // Save return address onto the stack - if (!process_sp->WritePointerToMemory(sp, return_addr, error)) - return false; + // Save return address onto the stack + if (!process_sp->WritePointerToMemory(sp, return_addr, error)) + return false; - // %r1 is set to the actual stack value. + // %r1 is set to the actual stack value. - if (log) - log->Printf("Writing SP: 0x%" PRIx64, (uint64_t)sp); + if (log) + log->Printf("Writing SP: 0x%" PRIx64, (uint64_t)sp); - if (!reg_ctx->WriteRegisterFromUnsigned (sp_reg_info, sp)) - return false; + if (!reg_ctx->WriteRegisterFromUnsigned(sp_reg_info, sp)) + return false; - // %pc is set to the address of the called function. + // %pc is set to the address of the called function. - if (log) - log->Printf("Writing IP: 0x%" PRIx64, (uint64_t)func_addr); + if (log) + log->Printf("Writing IP: 0x%" PRIx64, (uint64_t)func_addr); - if (!reg_ctx->WriteRegisterFromUnsigned (pc_reg_info, func_addr)) - return false; + if (!reg_ctx->WriteRegisterFromUnsigned(pc_reg_info, func_addr)) + return false; - return true; + return true; } -static bool ReadIntegerArgument(Scalar &scalar, - unsigned int bit_width, - bool is_signed, - Thread &thread, - uint32_t *argument_register_ids, - unsigned int ¤t_argument_register, - addr_t ¤t_stack_argument) -{ - if (bit_width > 64) - return false; // Scalar can't hold large integer arguments - - if (current_argument_register < 6) - { - scalar = thread.GetRegisterContext()->ReadRegisterAsUnsigned(argument_register_ids[current_argument_register], 0); - current_argument_register++; - if (is_signed) - scalar.SignExtend (bit_width); - } - else - { - uint32_t byte_size = (bit_width + (8-1))/8; - Error error; - if (thread.GetProcess()->ReadScalarIntegerFromMemory(current_stack_argument, byte_size, is_signed, scalar, error)) - { - current_stack_argument += byte_size; - return true; - } - return false; +static bool ReadIntegerArgument(Scalar &scalar, unsigned int bit_width, + bool is_signed, Thread &thread, + uint32_t *argument_register_ids, + unsigned int ¤t_argument_register, + addr_t ¤t_stack_argument) { + if (bit_width > 64) + return false; // Scalar can't hold large integer arguments + + if (current_argument_register < 6) { + scalar = thread.GetRegisterContext()->ReadRegisterAsUnsigned( + argument_register_ids[current_argument_register], 0); + current_argument_register++; + if (is_signed) + scalar.SignExtend(bit_width); + } else { + uint32_t byte_size = (bit_width + (8 - 1)) / 8; + Error error; + if (thread.GetProcess()->ReadScalarIntegerFromMemory( + current_stack_argument, byte_size, is_signed, scalar, error)) { + current_stack_argument += byte_size; + return true; } - return true; + return false; + } + return true; } -bool -ABISysV_ppc::GetArgumentValues (Thread &thread, - ValueList &values) const -{ - unsigned int num_values = values.GetSize(); - unsigned int value_index; - - // Extract the register context so we can read arguments from registers - - RegisterContext *reg_ctx = thread.GetRegisterContext().get(); - - if (!reg_ctx) - return false; - - // Get the pointer to the first stack argument so we have a place to start - // when reading data +bool ABISysV_ppc::GetArgumentValues(Thread &thread, ValueList &values) const { + unsigned int num_values = values.GetSize(); + unsigned int value_index; - addr_t sp = reg_ctx->GetSP(0); + // Extract the register context so we can read arguments from registers - if (!sp) - return false; + RegisterContext *reg_ctx = thread.GetRegisterContext().get(); - addr_t current_stack_argument = sp + 48; // jump over return address - - uint32_t argument_register_ids[8]; - - argument_register_ids[0] = reg_ctx->GetRegisterInfo (eRegisterKindGeneric, LLDB_REGNUM_GENERIC_ARG1)->kinds[eRegisterKindLLDB]; - argument_register_ids[1] = reg_ctx->GetRegisterInfo (eRegisterKindGeneric, LLDB_REGNUM_GENERIC_ARG2)->kinds[eRegisterKindLLDB]; - argument_register_ids[2] = reg_ctx->GetRegisterInfo (eRegisterKindGeneric, LLDB_REGNUM_GENERIC_ARG3)->kinds[eRegisterKindLLDB]; - argument_register_ids[3] = reg_ctx->GetRegisterInfo (eRegisterKindGeneric, LLDB_REGNUM_GENERIC_ARG4)->kinds[eRegisterKindLLDB]; - argument_register_ids[4] = reg_ctx->GetRegisterInfo (eRegisterKindGeneric, LLDB_REGNUM_GENERIC_ARG5)->kinds[eRegisterKindLLDB]; - argument_register_ids[5] = reg_ctx->GetRegisterInfo (eRegisterKindGeneric, LLDB_REGNUM_GENERIC_ARG6)->kinds[eRegisterKindLLDB]; - argument_register_ids[6] = reg_ctx->GetRegisterInfo (eRegisterKindGeneric, LLDB_REGNUM_GENERIC_ARG7)->kinds[eRegisterKindLLDB]; - argument_register_ids[7] = reg_ctx->GetRegisterInfo (eRegisterKindGeneric, LLDB_REGNUM_GENERIC_ARG8)->kinds[eRegisterKindLLDB]; + if (!reg_ctx) + return false; - unsigned int current_argument_register = 0; + // Get the pointer to the first stack argument so we have a place to start + // when reading data - for (value_index = 0; - value_index < num_values; - ++value_index) - { - Value *value = values.GetValueAtIndex(value_index); + addr_t sp = reg_ctx->GetSP(0); - if (!value) - return false; + if (!sp) + return false; - // We currently only support extracting values with Clang QualTypes. - // Do we care about others? - CompilerType compiler_type = value->GetCompilerType(); - if (!compiler_type) - return false; - bool is_signed; + addr_t current_stack_argument = sp + 48; // jump over return address + + uint32_t argument_register_ids[8]; + + argument_register_ids[0] = + reg_ctx->GetRegisterInfo(eRegisterKindGeneric, LLDB_REGNUM_GENERIC_ARG1) + ->kinds[eRegisterKindLLDB]; + argument_register_ids[1] = + reg_ctx->GetRegisterInfo(eRegisterKindGeneric, LLDB_REGNUM_GENERIC_ARG2) + ->kinds[eRegisterKindLLDB]; + argument_register_ids[2] = + reg_ctx->GetRegisterInfo(eRegisterKindGeneric, LLDB_REGNUM_GENERIC_ARG3) + ->kinds[eRegisterKindLLDB]; + argument_register_ids[3] = + reg_ctx->GetRegisterInfo(eRegisterKindGeneric, LLDB_REGNUM_GENERIC_ARG4) + ->kinds[eRegisterKindLLDB]; + argument_register_ids[4] = + reg_ctx->GetRegisterInfo(eRegisterKindGeneric, LLDB_REGNUM_GENERIC_ARG5) + ->kinds[eRegisterKindLLDB]; + argument_register_ids[5] = + reg_ctx->GetRegisterInfo(eRegisterKindGeneric, LLDB_REGNUM_GENERIC_ARG6) + ->kinds[eRegisterKindLLDB]; + argument_register_ids[6] = + reg_ctx->GetRegisterInfo(eRegisterKindGeneric, LLDB_REGNUM_GENERIC_ARG7) + ->kinds[eRegisterKindLLDB]; + argument_register_ids[7] = + reg_ctx->GetRegisterInfo(eRegisterKindGeneric, LLDB_REGNUM_GENERIC_ARG8) + ->kinds[eRegisterKindLLDB]; + + unsigned int current_argument_register = 0; + + for (value_index = 0; value_index < num_values; ++value_index) { + Value *value = values.GetValueAtIndex(value_index); + + if (!value) + return false; + + // We currently only support extracting values with Clang QualTypes. + // Do we care about others? + CompilerType compiler_type = value->GetCompilerType(); + if (!compiler_type) + return false; + bool is_signed; - if (compiler_type.IsIntegerOrEnumerationType (is_signed)) - { - ReadIntegerArgument(value->GetScalar(), - compiler_type.GetBitSize(&thread), - is_signed, - thread, - argument_register_ids, - current_argument_register, - current_stack_argument); - } - else if (compiler_type.IsPointerType ()) - { - ReadIntegerArgument(value->GetScalar(), - compiler_type.GetBitSize(&thread), - false, - thread, - argument_register_ids, - current_argument_register, - current_stack_argument); - } + if (compiler_type.IsIntegerOrEnumerationType(is_signed)) { + ReadIntegerArgument(value->GetScalar(), compiler_type.GetBitSize(&thread), + is_signed, thread, argument_register_ids, + current_argument_register, current_stack_argument); + } else if (compiler_type.IsPointerType()) { + ReadIntegerArgument(value->GetScalar(), compiler_type.GetBitSize(&thread), + false, thread, argument_register_ids, + current_argument_register, current_stack_argument); } + } - return true; + return true; } -Error -ABISysV_ppc::SetReturnValueObject(lldb::StackFrameSP &frame_sp, lldb::ValueObjectSP &new_value_sp) -{ - Error error; - if (!new_value_sp) - { - error.SetErrorString("Empty value object for return value."); - return error; - } +Error ABISysV_ppc::SetReturnValueObject(lldb::StackFrameSP &frame_sp, + lldb::ValueObjectSP &new_value_sp) { + Error error; + if (!new_value_sp) { + error.SetErrorString("Empty value object for return value."); + return error; + } - CompilerType compiler_type = new_value_sp->GetCompilerType(); - if (!compiler_type) - { - error.SetErrorString ("Null clang type for return value."); - return error; - } + CompilerType compiler_type = new_value_sp->GetCompilerType(); + if (!compiler_type) { + error.SetErrorString("Null clang type for return value."); + return error; + } - Thread *thread = frame_sp->GetThread().get(); + Thread *thread = frame_sp->GetThread().get(); - bool is_signed; - uint32_t count; - bool is_complex; + bool is_signed; + uint32_t count; + bool is_complex; - RegisterContext *reg_ctx = thread->GetRegisterContext().get(); + RegisterContext *reg_ctx = thread->GetRegisterContext().get(); - bool set_it_simple = false; - if (compiler_type.IsIntegerOrEnumerationType (is_signed) || compiler_type.IsPointerType()) - { - const RegisterInfo *reg_info = reg_ctx->GetRegisterInfoByName("r3", 0); + bool set_it_simple = false; + if (compiler_type.IsIntegerOrEnumerationType(is_signed) || + compiler_type.IsPointerType()) { + const RegisterInfo *reg_info = reg_ctx->GetRegisterInfoByName("r3", 0); + DataExtractor data; + Error data_error; + size_t num_bytes = new_value_sp->GetData(data, data_error); + if (data_error.Fail()) { + error.SetErrorStringWithFormat( + "Couldn't convert return value to raw data: %s", + data_error.AsCString()); + return error; + } + lldb::offset_t offset = 0; + if (num_bytes <= 8) { + uint64_t raw_value = data.GetMaxU64(&offset, num_bytes); + + if (reg_ctx->WriteRegisterFromUnsigned(reg_info, raw_value)) + set_it_simple = true; + } else { + error.SetErrorString("We don't support returning longer than 64 bit " + "integer values at present."); + } + } else if (compiler_type.IsFloatingPointType(count, is_complex)) { + if (is_complex) + error.SetErrorString( + "We don't support returning complex values at present"); + else { + size_t bit_width = compiler_type.GetBitSize(frame_sp.get()); + if (bit_width <= 64) { DataExtractor data; Error data_error; size_t num_bytes = new_value_sp->GetData(data, data_error); - if (data_error.Fail()) - { - error.SetErrorStringWithFormat("Couldn't convert return value to raw data: %s", data_error.AsCString()); - return error; + if (data_error.Fail()) { + error.SetErrorStringWithFormat( + "Couldn't convert return value to raw data: %s", + data_error.AsCString()); + return error; } - lldb::offset_t offset = 0; - if (num_bytes <= 8) - { - uint64_t raw_value = data.GetMaxU64(&offset, num_bytes); - if (reg_ctx->WriteRegisterFromUnsigned (reg_info, raw_value)) - set_it_simple = true; - } - else - { - error.SetErrorString("We don't support returning longer than 64 bit integer values at present."); - } - } - else if (compiler_type.IsFloatingPointType (count, is_complex)) - { - if (is_complex) - error.SetErrorString ("We don't support returning complex values at present"); - else - { - size_t bit_width = compiler_type.GetBitSize(frame_sp.get()); - if (bit_width <= 64) - { - DataExtractor data; - Error data_error; - size_t num_bytes = new_value_sp->GetData(data, data_error); - if (data_error.Fail()) - { - error.SetErrorStringWithFormat("Couldn't convert return value to raw data: %s", data_error.AsCString()); - return error; - } - - unsigned char buffer[16]; - ByteOrder byte_order = data.GetByteOrder(); + unsigned char buffer[16]; + ByteOrder byte_order = data.GetByteOrder(); - data.CopyByteOrderedData (0, num_bytes, buffer, 16, byte_order); - set_it_simple = true; - } - else - { - // FIXME - don't know how to do 80 bit long doubles yet. - error.SetErrorString ("We don't support returning float values > 64 bits at present"); - } - } + data.CopyByteOrderedData(0, num_bytes, buffer, 16, byte_order); + set_it_simple = true; + } else { + // FIXME - don't know how to do 80 bit long doubles yet. + error.SetErrorString( + "We don't support returning float values > 64 bits at present"); + } } + } - if (!set_it_simple) - { - // Okay we've got a structure or something that doesn't fit in a simple register. - // We should figure out where it really goes, but we don't support this yet. - error.SetErrorString ("We only support setting simple integer and float return types at present."); - } + if (!set_it_simple) { + // Okay we've got a structure or something that doesn't fit in a simple + // register. + // We should figure out where it really goes, but we don't support this yet. + error.SetErrorString("We only support setting simple integer and float " + "return types at present."); + } - return error; + return error; } -ValueObjectSP -ABISysV_ppc::GetReturnValueObjectSimple (Thread &thread, - CompilerType &return_compiler_type) const -{ - ValueObjectSP return_valobj_sp; - Value value; +ValueObjectSP ABISysV_ppc::GetReturnValueObjectSimple( + Thread &thread, CompilerType &return_compiler_type) const { + ValueObjectSP return_valobj_sp; + Value value; - if (!return_compiler_type) - return return_valobj_sp; + if (!return_compiler_type) + return return_valobj_sp; - //value.SetContext (Value::eContextTypeClangType, return_value_type); - value.SetCompilerType (return_compiler_type); + // value.SetContext (Value::eContextTypeClangType, return_value_type); + value.SetCompilerType(return_compiler_type); - RegisterContext *reg_ctx = thread.GetRegisterContext().get(); - if (!reg_ctx) - return return_valobj_sp; + RegisterContext *reg_ctx = thread.GetRegisterContext().get(); + if (!reg_ctx) + return return_valobj_sp; - const uint32_t type_flags = return_compiler_type.GetTypeInfo (); - if (type_flags & eTypeIsScalar) - { - value.SetValueType(Value::eValueTypeScalar); + const uint32_t type_flags = return_compiler_type.GetTypeInfo(); + if (type_flags & eTypeIsScalar) { + value.SetValueType(Value::eValueTypeScalar); - bool success = false; - if (type_flags & eTypeIsInteger) - { - // Extract the register context so we can read arguments from registers - - const size_t byte_size = return_compiler_type.GetByteSize(nullptr); - uint64_t raw_value = thread.GetRegisterContext()->ReadRegisterAsUnsigned(reg_ctx->GetRegisterInfoByName("r3", 0), 0); - const bool is_signed = (type_flags & eTypeIsSigned) != 0; - switch (byte_size) - { - default: - break; - - case sizeof(uint64_t): - if (is_signed) - value.GetScalar() = (int64_t)(raw_value); - else - value.GetScalar() = (uint64_t)(raw_value); - success = true; - break; + bool success = false; + if (type_flags & eTypeIsInteger) { + // Extract the register context so we can read arguments from registers - case sizeof(uint32_t): - if (is_signed) - value.GetScalar() = (int32_t)(raw_value & UINT32_MAX); - else - value.GetScalar() = (uint32_t)(raw_value & UINT32_MAX); - success = true; - break; + const size_t byte_size = return_compiler_type.GetByteSize(nullptr); + uint64_t raw_value = thread.GetRegisterContext()->ReadRegisterAsUnsigned( + reg_ctx->GetRegisterInfoByName("r3", 0), 0); + const bool is_signed = (type_flags & eTypeIsSigned) != 0; + switch (byte_size) { + default: + break; - case sizeof(uint16_t): - if (is_signed) - value.GetScalar() = (int16_t)(raw_value & UINT16_MAX); - else - value.GetScalar() = (uint16_t)(raw_value & UINT16_MAX); - success = true; - break; + case sizeof(uint64_t): + if (is_signed) + value.GetScalar() = (int64_t)(raw_value); + else + value.GetScalar() = (uint64_t)(raw_value); + success = true; + break; + + case sizeof(uint32_t): + if (is_signed) + value.GetScalar() = (int32_t)(raw_value & UINT32_MAX); + else + value.GetScalar() = (uint32_t)(raw_value & UINT32_MAX); + success = true; + break; + + case sizeof(uint16_t): + if (is_signed) + value.GetScalar() = (int16_t)(raw_value & UINT16_MAX); + else + value.GetScalar() = (uint16_t)(raw_value & UINT16_MAX); + success = true; + break; - case sizeof(uint8_t): - if (is_signed) - value.GetScalar() = (int8_t)(raw_value & UINT8_MAX); - else - value.GetScalar() = (uint8_t)(raw_value & UINT8_MAX); + case sizeof(uint8_t): + if (is_signed) + value.GetScalar() = (int8_t)(raw_value & UINT8_MAX); + else + value.GetScalar() = (uint8_t)(raw_value & UINT8_MAX); + success = true; + break; + } + } else if (type_flags & eTypeIsFloat) { + if (type_flags & eTypeIsComplex) { + // Don't handle complex yet. + } else { + const size_t byte_size = return_compiler_type.GetByteSize(nullptr); + if (byte_size <= sizeof(long double)) { + const RegisterInfo *f1_info = reg_ctx->GetRegisterInfoByName("f1", 0); + RegisterValue f1_value; + if (reg_ctx->ReadRegister(f1_info, f1_value)) { + DataExtractor data; + if (f1_value.GetData(data)) { + lldb::offset_t offset = 0; + if (byte_size == sizeof(float)) { + value.GetScalar() = (float)data.GetFloat(&offset); success = true; - break; - } - } - else if (type_flags & eTypeIsFloat) - { - if (type_flags & eTypeIsComplex) - { - // Don't handle complex yet. - } - else - { - const size_t byte_size = return_compiler_type.GetByteSize(nullptr); - if (byte_size <= sizeof(long double)) - { - const RegisterInfo *f1_info = reg_ctx->GetRegisterInfoByName("f1", 0); - RegisterValue f1_value; - if (reg_ctx->ReadRegister (f1_info, f1_value)) - { - DataExtractor data; - if (f1_value.GetData(data)) - { - lldb::offset_t offset = 0; - if (byte_size == sizeof(float)) - { - value.GetScalar() = (float) data.GetFloat(&offset); - success = true; - } - else if (byte_size == sizeof(double)) - { - value.GetScalar() = (double) data.GetDouble(&offset); - success = true; - } - } - } - } + } else if (byte_size == sizeof(double)) { + value.GetScalar() = (double)data.GetDouble(&offset); + success = true; + } } + } } - - if (success) - return_valobj_sp = ValueObjectConstResult::Create (thread.GetStackFrameAtIndex(0).get(), - value, - ConstString("")); + } } - else if (type_flags & eTypeIsPointer) - { - unsigned r3_id = reg_ctx->GetRegisterInfoByName("r3", 0)->kinds[eRegisterKindLLDB]; - value.GetScalar() = (uint64_t)thread.GetRegisterContext()->ReadRegisterAsUnsigned(r3_id, 0); - value.SetValueType(Value::eValueTypeScalar); - return_valobj_sp = ValueObjectConstResult::Create (thread.GetStackFrameAtIndex(0).get(), - value, - ConstString("")); - } - else if (type_flags & eTypeIsVector) - { - const size_t byte_size = return_compiler_type.GetByteSize(nullptr); - if (byte_size > 0) - { - const RegisterInfo *altivec_reg = reg_ctx->GetRegisterInfoByName("v2", 0); - if (altivec_reg) - { - if (byte_size <= altivec_reg->byte_size) - { - ProcessSP process_sp (thread.GetProcess()); - if (process_sp) - { - std::unique_ptr<DataBufferHeap> heap_data_ap (new DataBufferHeap(byte_size, 0)); - const ByteOrder byte_order = process_sp->GetByteOrder(); - RegisterValue reg_value; - if (reg_ctx->ReadRegister(altivec_reg, reg_value)) - { - Error error; - if (reg_value.GetAsMemoryData (altivec_reg, - heap_data_ap->GetBytes(), - heap_data_ap->GetByteSize(), - byte_order, - error)) - { - DataExtractor data (DataBufferSP (heap_data_ap.release()), - byte_order, - process_sp->GetTarget().GetArchitecture().GetAddressByteSize()); - return_valobj_sp = ValueObjectConstResult::Create (&thread, - return_compiler_type, - ConstString(""), - data); - } - } - } - } + + if (success) + return_valobj_sp = ValueObjectConstResult::Create( + thread.GetStackFrameAtIndex(0).get(), value, ConstString("")); + } else if (type_flags & eTypeIsPointer) { + unsigned r3_id = + reg_ctx->GetRegisterInfoByName("r3", 0)->kinds[eRegisterKindLLDB]; + value.GetScalar() = + (uint64_t)thread.GetRegisterContext()->ReadRegisterAsUnsigned(r3_id, 0); + value.SetValueType(Value::eValueTypeScalar); + return_valobj_sp = ValueObjectConstResult::Create( + thread.GetStackFrameAtIndex(0).get(), value, ConstString("")); + } else if (type_flags & eTypeIsVector) { + const size_t byte_size = return_compiler_type.GetByteSize(nullptr); + if (byte_size > 0) { + const RegisterInfo *altivec_reg = reg_ctx->GetRegisterInfoByName("v2", 0); + if (altivec_reg) { + if (byte_size <= altivec_reg->byte_size) { + ProcessSP process_sp(thread.GetProcess()); + if (process_sp) { + std::unique_ptr<DataBufferHeap> heap_data_ap( + new DataBufferHeap(byte_size, 0)); + const ByteOrder byte_order = process_sp->GetByteOrder(); + RegisterValue reg_value; + if (reg_ctx->ReadRegister(altivec_reg, reg_value)) { + Error error; + if (reg_value.GetAsMemoryData( + altivec_reg, heap_data_ap->GetBytes(), + heap_data_ap->GetByteSize(), byte_order, error)) { + DataExtractor data(DataBufferSP(heap_data_ap.release()), + byte_order, process_sp->GetTarget() + .GetArchitecture() + .GetAddressByteSize()); + return_valobj_sp = ValueObjectConstResult::Create( + &thread, return_compiler_type, ConstString(""), data); + } } + } } + } } + } - return return_valobj_sp; + return return_valobj_sp; } -ValueObjectSP -ABISysV_ppc::GetReturnValueObjectImpl (Thread &thread, CompilerType &return_compiler_type) const -{ - ValueObjectSP return_valobj_sp; +ValueObjectSP ABISysV_ppc::GetReturnValueObjectImpl( + Thread &thread, CompilerType &return_compiler_type) const { + ValueObjectSP return_valobj_sp; - if (!return_compiler_type) - return return_valobj_sp; + if (!return_compiler_type) + return return_valobj_sp; - ExecutionContext exe_ctx (thread.shared_from_this()); - return_valobj_sp = GetReturnValueObjectSimple(thread, return_compiler_type); - if (return_valobj_sp) - return return_valobj_sp; + ExecutionContext exe_ctx(thread.shared_from_this()); + return_valobj_sp = GetReturnValueObjectSimple(thread, return_compiler_type); + if (return_valobj_sp) + return return_valobj_sp; - RegisterContextSP reg_ctx_sp = thread.GetRegisterContext(); - if (!reg_ctx_sp) - return return_valobj_sp; + RegisterContextSP reg_ctx_sp = thread.GetRegisterContext(); + if (!reg_ctx_sp) + return return_valobj_sp; - const size_t bit_width = return_compiler_type.GetBitSize(&thread); - if (return_compiler_type.IsAggregateType()) - { - Target *target = exe_ctx.GetTargetPtr(); - bool is_memory = true; - if (bit_width <= 128) - { - ByteOrder target_byte_order = target->GetArchitecture().GetByteOrder(); - DataBufferSP data_sp (new DataBufferHeap(16, 0)); - DataExtractor return_ext (data_sp, - target_byte_order, - target->GetArchitecture().GetAddressByteSize()); + const size_t bit_width = return_compiler_type.GetBitSize(&thread); + if (return_compiler_type.IsAggregateType()) { + Target *target = exe_ctx.GetTargetPtr(); + bool is_memory = true; + if (bit_width <= 128) { + ByteOrder target_byte_order = target->GetArchitecture().GetByteOrder(); + DataBufferSP data_sp(new DataBufferHeap(16, 0)); + DataExtractor return_ext(data_sp, target_byte_order, + target->GetArchitecture().GetAddressByteSize()); - const RegisterInfo *r3_info = reg_ctx_sp->GetRegisterInfoByName("r3", 0); - const RegisterInfo *rdx_info = reg_ctx_sp->GetRegisterInfoByName("rdx", 0); + const RegisterInfo *r3_info = reg_ctx_sp->GetRegisterInfoByName("r3", 0); + const RegisterInfo *rdx_info = + reg_ctx_sp->GetRegisterInfoByName("rdx", 0); - RegisterValue r3_value, rdx_value; - reg_ctx_sp->ReadRegister (r3_info, r3_value); - reg_ctx_sp->ReadRegister (rdx_info, rdx_value); + RegisterValue r3_value, rdx_value; + reg_ctx_sp->ReadRegister(r3_info, r3_value); + reg_ctx_sp->ReadRegister(rdx_info, rdx_value); - DataExtractor r3_data, rdx_data; + DataExtractor r3_data, rdx_data; - r3_value.GetData(r3_data); - rdx_value.GetData(rdx_data); + r3_value.GetData(r3_data); + rdx_value.GetData(rdx_data); - uint32_t fp_bytes = 0; // Tracks how much of the xmm registers we've consumed so far - uint32_t integer_bytes = 0; // Tracks how much of the r3/rds registers we've consumed so far + uint32_t fp_bytes = + 0; // Tracks how much of the xmm registers we've consumed so far + uint32_t integer_bytes = + 0; // Tracks how much of the r3/rds registers we've consumed so far - const uint32_t num_children = return_compiler_type.GetNumFields (); + const uint32_t num_children = return_compiler_type.GetNumFields(); - // Since we are in the small struct regime, assume we are not in memory. - is_memory = false; + // Since we are in the small struct regime, assume we are not in memory. + is_memory = false; - for (uint32_t idx = 0; idx < num_children; idx++) - { - std::string name; - uint64_t field_bit_offset = 0; - bool is_signed; - bool is_complex; - uint32_t count; + for (uint32_t idx = 0; idx < num_children; idx++) { + std::string name; + uint64_t field_bit_offset = 0; + bool is_signed; + bool is_complex; + uint32_t count; - CompilerType field_compiler_type = return_compiler_type.GetFieldAtIndex(idx, name, &field_bit_offset, nullptr, nullptr); - const size_t field_bit_width = field_compiler_type.GetBitSize(&thread); + CompilerType field_compiler_type = return_compiler_type.GetFieldAtIndex( + idx, name, &field_bit_offset, nullptr, nullptr); + const size_t field_bit_width = field_compiler_type.GetBitSize(&thread); - // If there are any unaligned fields, this is stored in memory. - if (field_bit_offset % field_bit_width != 0) - { - is_memory = true; - break; - } + // If there are any unaligned fields, this is stored in memory. + if (field_bit_offset % field_bit_width != 0) { + is_memory = true; + break; + } - uint32_t field_byte_width = field_bit_width/8; - uint32_t field_byte_offset = field_bit_offset/8; - - DataExtractor *copy_from_extractor = nullptr; - uint32_t copy_from_offset = 0; - - if (field_compiler_type.IsIntegerOrEnumerationType (is_signed) || field_compiler_type.IsPointerType ()) - { - if (integer_bytes < 8) - { - if (integer_bytes + field_byte_width <= 8) - { - // This is in RAX, copy from register to our result structure: - copy_from_extractor = &r3_data; - copy_from_offset = integer_bytes; - integer_bytes += field_byte_width; - } - else - { - // The next field wouldn't fit in the remaining space, so we pushed it to rdx. - copy_from_extractor = &rdx_data; - copy_from_offset = 0; - integer_bytes = 8 + field_byte_width; - } - } - else if (integer_bytes + field_byte_width <= 16) - { - copy_from_extractor = &rdx_data; - copy_from_offset = integer_bytes - 8; - integer_bytes += field_byte_width; - } - else - { - // The last field didn't fit. I can't see how that would happen w/o the overall size being - // greater than 16 bytes. For now, return a nullptr return value object. - return return_valobj_sp; - } + uint32_t field_byte_width = field_bit_width / 8; + uint32_t field_byte_offset = field_bit_offset / 8; + + DataExtractor *copy_from_extractor = nullptr; + uint32_t copy_from_offset = 0; + + if (field_compiler_type.IsIntegerOrEnumerationType(is_signed) || + field_compiler_type.IsPointerType()) { + if (integer_bytes < 8) { + if (integer_bytes + field_byte_width <= 8) { + // This is in RAX, copy from register to our result structure: + copy_from_extractor = &r3_data; + copy_from_offset = integer_bytes; + integer_bytes += field_byte_width; + } else { + // The next field wouldn't fit in the remaining space, so we + // pushed it to rdx. + copy_from_extractor = &rdx_data; + copy_from_offset = 0; + integer_bytes = 8 + field_byte_width; + } + } else if (integer_bytes + field_byte_width <= 16) { + copy_from_extractor = &rdx_data; + copy_from_offset = integer_bytes - 8; + integer_bytes += field_byte_width; + } else { + // The last field didn't fit. I can't see how that would happen w/o + // the overall size being + // greater than 16 bytes. For now, return a nullptr return value + // object. + return return_valobj_sp; + } + } else if (field_compiler_type.IsFloatingPointType(count, is_complex)) { + // Structs with long doubles are always passed in memory. + if (field_bit_width == 128) { + is_memory = true; + break; + } else if (field_bit_width == 64) { + copy_from_offset = 0; + fp_bytes += field_byte_width; + } else if (field_bit_width == 32) { + // This one is kind of complicated. If we are in an "eightbyte" + // with another float, we'll + // be stuffed into an xmm register with it. If we are in an + // "eightbyte" with one or more ints, + // then we will be stuffed into the appropriate GPR with them. + bool in_gpr; + if (field_byte_offset % 8 == 0) { + // We are at the beginning of one of the eightbytes, so check the + // next element (if any) + if (idx == num_children - 1) + in_gpr = false; + else { + uint64_t next_field_bit_offset = 0; + CompilerType next_field_compiler_type = + return_compiler_type.GetFieldAtIndex(idx + 1, name, + &next_field_bit_offset, + nullptr, nullptr); + if (next_field_compiler_type.IsIntegerOrEnumerationType( + is_signed)) + in_gpr = true; + else { + copy_from_offset = 0; + in_gpr = false; } - else if (field_compiler_type.IsFloatingPointType (count, is_complex)) - { - // Structs with long doubles are always passed in memory. - if (field_bit_width == 128) - { - is_memory = true; - break; - } - else if (field_bit_width == 64) - { - copy_from_offset = 0; - fp_bytes += field_byte_width; - } - else if (field_bit_width == 32) - { - // This one is kind of complicated. If we are in an "eightbyte" with another float, we'll - // be stuffed into an xmm register with it. If we are in an "eightbyte" with one or more ints, - // then we will be stuffed into the appropriate GPR with them. - bool in_gpr; - if (field_byte_offset % 8 == 0) - { - // We are at the beginning of one of the eightbytes, so check the next element (if any) - if (idx == num_children - 1) - in_gpr = false; - else - { - uint64_t next_field_bit_offset = 0; - CompilerType next_field_compiler_type = return_compiler_type.GetFieldAtIndex (idx + 1, - name, - &next_field_bit_offset, - nullptr, - nullptr); - if (next_field_compiler_type.IsIntegerOrEnumerationType (is_signed)) - in_gpr = true; - else - { - copy_from_offset = 0; - in_gpr = false; - } - } - } - else if (field_byte_offset % 4 == 0) - { - // We are inside of an eightbyte, so see if the field before us is floating point: - // This could happen if somebody put padding in the structure. - if (idx == 0) - in_gpr = false; - else - { - uint64_t prev_field_bit_offset = 0; - CompilerType prev_field_compiler_type = return_compiler_type.GetFieldAtIndex (idx - 1, - name, - &prev_field_bit_offset, - nullptr, - nullptr); - if (prev_field_compiler_type.IsIntegerOrEnumerationType (is_signed)) - in_gpr = true; - else - { - copy_from_offset = 4; - in_gpr = false; - } - } - } - else - { - is_memory = true; - continue; - } - - // Okay, we've figured out whether we are in GPR or XMM, now figure out which one. - if (in_gpr) - { - if (integer_bytes < 8) - { - // This is in RAX, copy from register to our result structure: - copy_from_extractor = &r3_data; - copy_from_offset = integer_bytes; - integer_bytes += field_byte_width; - } - else - { - copy_from_extractor = &rdx_data; - copy_from_offset = integer_bytes - 8; - integer_bytes += field_byte_width; - } - } - else - { - fp_bytes += field_byte_width; - } - } + } + } else if (field_byte_offset % 4 == 0) { + // We are inside of an eightbyte, so see if the field before us is + // floating point: + // This could happen if somebody put padding in the structure. + if (idx == 0) + in_gpr = false; + else { + uint64_t prev_field_bit_offset = 0; + CompilerType prev_field_compiler_type = + return_compiler_type.GetFieldAtIndex(idx - 1, name, + &prev_field_bit_offset, + nullptr, nullptr); + if (prev_field_compiler_type.IsIntegerOrEnumerationType( + is_signed)) + in_gpr = true; + else { + copy_from_offset = 4; + in_gpr = false; } - - // These two tests are just sanity checks. If I somehow get the - // type calculation wrong above it is better to just return nothing - // than to assert or crash. - if (!copy_from_extractor) - return return_valobj_sp; - if (copy_from_offset + field_byte_width > copy_from_extractor->GetByteSize()) - return return_valobj_sp; - - copy_from_extractor->CopyByteOrderedData (copy_from_offset, - field_byte_width, - data_sp->GetBytes() + field_byte_offset, - field_byte_width, - target_byte_order); + } + } else { + is_memory = true; + continue; } - if (!is_memory) - { - // The result is in our data buffer. Let's make a variable object out of it: - return_valobj_sp = ValueObjectConstResult::Create (&thread, - return_compiler_type, - ConstString(""), - return_ext); + // Okay, we've figured out whether we are in GPR or XMM, now figure + // out which one. + if (in_gpr) { + if (integer_bytes < 8) { + // This is in RAX, copy from register to our result structure: + copy_from_extractor = &r3_data; + copy_from_offset = integer_bytes; + integer_bytes += field_byte_width; + } else { + copy_from_extractor = &rdx_data; + copy_from_offset = integer_bytes - 8; + integer_bytes += field_byte_width; + } + } else { + fp_bytes += field_byte_width; } + } } - // FIXME: This is just taking a guess, r3 may very well no longer hold the return storage location. - // If we are going to do this right, when we make a new frame we should check to see if it uses a memory - // return, and if we are at the first instruction and if so stash away the return location. Then we would - // only return the memory return value if we know it is valid. + // These two tests are just sanity checks. If I somehow get the + // type calculation wrong above it is better to just return nothing + // than to assert or crash. + if (!copy_from_extractor) + return return_valobj_sp; + if (copy_from_offset + field_byte_width > + copy_from_extractor->GetByteSize()) + return return_valobj_sp; + + copy_from_extractor->CopyByteOrderedData( + copy_from_offset, field_byte_width, + data_sp->GetBytes() + field_byte_offset, field_byte_width, + target_byte_order); + } + + if (!is_memory) { + // The result is in our data buffer. Let's make a variable object out + // of it: + return_valobj_sp = ValueObjectConstResult::Create( + &thread, return_compiler_type, ConstString(""), return_ext); + } + } - if (is_memory) - { - unsigned r3_id = reg_ctx_sp->GetRegisterInfoByName("r3", 0)->kinds[eRegisterKindLLDB]; - lldb::addr_t storage_addr = (uint64_t)thread.GetRegisterContext()->ReadRegisterAsUnsigned(r3_id, 0); - return_valobj_sp = ValueObjectMemory::Create(&thread, - "", - Address(storage_addr, nullptr), - return_compiler_type); - } + // FIXME: This is just taking a guess, r3 may very well no longer hold the + // return storage location. + // If we are going to do this right, when we make a new frame we should + // check to see if it uses a memory + // return, and if we are at the first instruction and if so stash away the + // return location. Then we would + // only return the memory return value if we know it is valid. + + if (is_memory) { + unsigned r3_id = + reg_ctx_sp->GetRegisterInfoByName("r3", 0)->kinds[eRegisterKindLLDB]; + lldb::addr_t storage_addr = + (uint64_t)thread.GetRegisterContext()->ReadRegisterAsUnsigned(r3_id, + 0); + return_valobj_sp = ValueObjectMemory::Create( + &thread, "", Address(storage_addr, nullptr), return_compiler_type); } + } - return return_valobj_sp; + return return_valobj_sp; } -bool -ABISysV_ppc::CreateFunctionEntryUnwindPlan (UnwindPlan &unwind_plan) -{ - unwind_plan.Clear(); - unwind_plan.SetRegisterKind (eRegisterKindDWARF); +bool ABISysV_ppc::CreateFunctionEntryUnwindPlan(UnwindPlan &unwind_plan) { + unwind_plan.Clear(); + unwind_plan.SetRegisterKind(eRegisterKindDWARF); - uint32_t lr_reg_num = dwarf_lr; - uint32_t sp_reg_num = dwarf_r1; - uint32_t pc_reg_num = dwarf_pc; + uint32_t lr_reg_num = dwarf_lr; + uint32_t sp_reg_num = dwarf_r1; + uint32_t pc_reg_num = dwarf_pc; - UnwindPlan::RowSP row(new UnwindPlan::Row); + UnwindPlan::RowSP row(new UnwindPlan::Row); - // Our Call Frame Address is the stack pointer value - row->GetCFAValue().SetIsRegisterPlusOffset (sp_reg_num, 0); + // Our Call Frame Address is the stack pointer value + row->GetCFAValue().SetIsRegisterPlusOffset(sp_reg_num, 0); - // The previous PC is in the LR - row->SetRegisterLocationToRegister(pc_reg_num, lr_reg_num, true); - unwind_plan.AppendRow (row); + // The previous PC is in the LR + row->SetRegisterLocationToRegister(pc_reg_num, lr_reg_num, true); + unwind_plan.AppendRow(row); - // All other registers are the same. + // All other registers are the same. - unwind_plan.SetSourceName ("ppc at-func-entry default"); - unwind_plan.SetSourcedFromCompiler (eLazyBoolNo); + unwind_plan.SetSourceName("ppc at-func-entry default"); + unwind_plan.SetSourcedFromCompiler(eLazyBoolNo); - return true; + return true; } -bool -ABISysV_ppc::CreateDefaultUnwindPlan (UnwindPlan &unwind_plan) -{ - unwind_plan.Clear(); - unwind_plan.SetRegisterKind (eRegisterKindDWARF); +bool ABISysV_ppc::CreateDefaultUnwindPlan(UnwindPlan &unwind_plan) { + unwind_plan.Clear(); + unwind_plan.SetRegisterKind(eRegisterKindDWARF); - uint32_t sp_reg_num = dwarf_r1; - uint32_t pc_reg_num = dwarf_lr; + uint32_t sp_reg_num = dwarf_r1; + uint32_t pc_reg_num = dwarf_lr; - UnwindPlan::RowSP row(new UnwindPlan::Row); + UnwindPlan::RowSP row(new UnwindPlan::Row); - const int32_t ptr_size = 4; - row->GetCFAValue().SetIsRegisterDereferenced (sp_reg_num); + const int32_t ptr_size = 4; + row->GetCFAValue().SetIsRegisterDereferenced(sp_reg_num); - row->SetRegisterLocationToAtCFAPlusOffset(pc_reg_num, ptr_size * 1, true); - row->SetRegisterLocationToIsCFAPlusOffset(sp_reg_num, 0, true); + row->SetRegisterLocationToAtCFAPlusOffset(pc_reg_num, ptr_size * 1, true); + row->SetRegisterLocationToIsCFAPlusOffset(sp_reg_num, 0, true); - unwind_plan.AppendRow (row); - unwind_plan.SetSourceName ("ppc default unwind plan"); - unwind_plan.SetSourcedFromCompiler (eLazyBoolNo); - unwind_plan.SetUnwindPlanValidAtAllInstructions (eLazyBoolNo); - unwind_plan.SetReturnAddressRegister(dwarf_lr); - return true; + unwind_plan.AppendRow(row); + unwind_plan.SetSourceName("ppc default unwind plan"); + unwind_plan.SetSourcedFromCompiler(eLazyBoolNo); + unwind_plan.SetUnwindPlanValidAtAllInstructions(eLazyBoolNo); + unwind_plan.SetReturnAddressRegister(dwarf_lr); + return true; } -bool -ABISysV_ppc::RegisterIsVolatile (const RegisterInfo *reg_info) -{ - return !RegisterIsCalleeSaved (reg_info); +bool ABISysV_ppc::RegisterIsVolatile(const RegisterInfo *reg_info) { + return !RegisterIsCalleeSaved(reg_info); } // See "Register Usage" in the // "System V Application Binary Interface" // "64-bit PowerPC ELF Application Binary Interface Supplement" -// current version is 1.9 released 2004 at http://refspecs.linuxfoundation.org/ELF/ppc/PPC-elf64abi-1.9.pdf - -bool -ABISysV_ppc::RegisterIsCalleeSaved (const RegisterInfo *reg_info) -{ - if (reg_info) - { - // Preserved registers are : - // r1,r2,r13-r31 - // f14-f31 (not yet) - // v20-v31 (not yet) - // vrsave (not yet) - - const char *name = reg_info->name; - if (name[0] == 'r') - { - if ((name[1] == '1' || name[1] == '2') && name[2] == '\0') - return true; - if (name[1] == '1' && name[2] > '2') - return true; - if ((name[1] == '2' || name[1] == '3') && name[2] != '\0') - return true; - } - - if (name[0] == 'f' && name[1] >= '0' && name[1] <= '9') - { - if (name[3] == '1' && name[4] >= '4') - return true; - if ((name[3] == '2' || name[3] == '3') && name[4] != '\0') - return true; - } +// current version is 1.9 released 2004 at +// http://refspecs.linuxfoundation.org/ELF/ppc/PPC-elf64abi-1.9.pdf + +bool ABISysV_ppc::RegisterIsCalleeSaved(const RegisterInfo *reg_info) { + if (reg_info) { + // Preserved registers are : + // r1,r2,r13-r31 + // f14-f31 (not yet) + // v20-v31 (not yet) + // vrsave (not yet) + + const char *name = reg_info->name; + if (name[0] == 'r') { + if ((name[1] == '1' || name[1] == '2') && name[2] == '\0') + return true; + if (name[1] == '1' && name[2] > '2') + return true; + if ((name[1] == '2' || name[1] == '3') && name[2] != '\0') + return true; + } - if (name[0] == 's' && name[1] == 'p' && name[2] == '\0') // sp - return true; - if (name[0] == 'f' && name[1] == 'p' && name[2] == '\0') // fp - return true; - if (name[0] == 'p' && name[1] == 'c' && name[2] == '\0') // pc - return true; + if (name[0] == 'f' && name[1] >= '0' && name[1] <= '9') { + if (name[3] == '1' && name[4] >= '4') + return true; + if ((name[3] == '2' || name[3] == '3') && name[4] != '\0') + return true; } - return false; + + if (name[0] == 's' && name[1] == 'p' && name[2] == '\0') // sp + return true; + if (name[0] == 'f' && name[1] == 'p' && name[2] == '\0') // fp + return true; + if (name[0] == 'p' && name[1] == 'c' && name[2] == '\0') // pc + return true; + } + return false; } -void -ABISysV_ppc::Initialize() -{ - PluginManager::RegisterPlugin (GetPluginNameStatic(), - "System V ABI for ppc targets", - CreateInstance); +void ABISysV_ppc::Initialize() { + PluginManager::RegisterPlugin(GetPluginNameStatic(), + "System V ABI for ppc targets", CreateInstance); } -void -ABISysV_ppc::Terminate() -{ - PluginManager::UnregisterPlugin (CreateInstance); +void ABISysV_ppc::Terminate() { + PluginManager::UnregisterPlugin(CreateInstance); } -lldb_private::ConstString -ABISysV_ppc::GetPluginNameStatic() -{ - static ConstString g_name("sysv-ppc"); - return g_name; +lldb_private::ConstString ABISysV_ppc::GetPluginNameStatic() { + static ConstString g_name("sysv-ppc"); + return g_name; } //------------------------------------------------------------------ // PluginInterface protocol //------------------------------------------------------------------ -lldb_private::ConstString -ABISysV_ppc::GetPluginName() -{ - return GetPluginNameStatic(); +lldb_private::ConstString ABISysV_ppc::GetPluginName() { + return GetPluginNameStatic(); } -uint32_t -ABISysV_ppc::GetPluginVersion() -{ - return 1; -} +uint32_t ABISysV_ppc::GetPluginVersion() { return 1; } diff --git a/source/Plugins/ABI/SysV-ppc/ABISysV_ppc.h b/source/Plugins/ABI/SysV-ppc/ABISysV_ppc.h index 99ee755631c2..c9c1c985f679 100644 --- a/source/Plugins/ABI/SysV-ppc/ABISysV_ppc.h +++ b/source/Plugins/ABI/SysV-ppc/ABISysV_ppc.h @@ -14,120 +14,100 @@ // C++ Includes // Other libraries and framework includes // Project includes -#include "lldb/lldb-private.h" #include "lldb/Target/ABI.h" +#include "lldb/lldb-private.h" -class ABISysV_ppc : - public lldb_private::ABI -{ +class ABISysV_ppc : public lldb_private::ABI { public: - ~ABISysV_ppc() override = default; - - size_t - GetRedZoneSize() const override; - - bool - PrepareTrivialCall(lldb_private::Thread &thread, - lldb::addr_t sp, - lldb::addr_t functionAddress, - lldb::addr_t returnAddress, - llvm::ArrayRef<lldb::addr_t> args) const override; - - bool - GetArgumentValues(lldb_private::Thread &thread, - lldb_private::ValueList &values) const override; - - lldb_private::Error - SetReturnValueObject(lldb::StackFrameSP &frame_sp, lldb::ValueObjectSP &new_value) override; - - lldb::ValueObjectSP - GetReturnValueObjectImpl(lldb_private::Thread &thread, - lldb_private::CompilerType &type) const override; - - bool - CreateFunctionEntryUnwindPlan(lldb_private::UnwindPlan &unwind_plan) override; - - bool - CreateDefaultUnwindPlan(lldb_private::UnwindPlan &unwind_plan) override; - - bool - RegisterIsVolatile(const lldb_private::RegisterInfo *reg_info) override; - - // The SysV ppc ABI requires that stack frames be 16 byte aligned. - // When there is a trap handler on the stack, e.g. _sigtramp in userland - // code, we've seen that the stack pointer is often not aligned properly - // before the handler is invoked. This means that lldb will stop the unwind - // early -- before the function which caused the trap. - // - // To work around this, we relax that alignment to be just word-size (8-bytes). - // Whitelisting the trap handlers for user space would be easy (_sigtramp) but - // in other environments there can be a large number of different functions - // involved in async traps. - bool - CallFrameAddressIsValid(lldb::addr_t cfa) override - { - // Make sure the stack call frame addresses are 8 byte aligned - if (cfa & (8ull - 1ull)) - return false; // Not 8 byte aligned - if (cfa == 0) - return false; // Zero is not a valid stack address - return true; - } - - bool - CodeAddressIsValid(lldb::addr_t pc) override - { - // We have a 64 bit address space, so anything is valid as opcodes - // aren't fixed width... - return true; - } - - const lldb_private::RegisterInfo * - GetRegisterInfoArray(uint32_t &count) override; - - //------------------------------------------------------------------ - // Static Functions - //------------------------------------------------------------------ - - static void - Initialize(); - - static void - Terminate(); - - static lldb::ABISP - CreateInstance (const lldb_private::ArchSpec &arch); - - static lldb_private::ConstString - GetPluginNameStatic(); - - //------------------------------------------------------------------ - // PluginInterface protocol - //------------------------------------------------------------------ - - lldb_private::ConstString - GetPluginName() override; - - uint32_t - GetPluginVersion() override; + ~ABISysV_ppc() override = default; + + size_t GetRedZoneSize() const override; + + bool PrepareTrivialCall(lldb_private::Thread &thread, lldb::addr_t sp, + lldb::addr_t functionAddress, + lldb::addr_t returnAddress, + llvm::ArrayRef<lldb::addr_t> args) const override; + + bool GetArgumentValues(lldb_private::Thread &thread, + lldb_private::ValueList &values) const override; + + lldb_private::Error + SetReturnValueObject(lldb::StackFrameSP &frame_sp, + lldb::ValueObjectSP &new_value) override; + + lldb::ValueObjectSP + GetReturnValueObjectImpl(lldb_private::Thread &thread, + lldb_private::CompilerType &type) const override; + + bool + CreateFunctionEntryUnwindPlan(lldb_private::UnwindPlan &unwind_plan) override; + + bool CreateDefaultUnwindPlan(lldb_private::UnwindPlan &unwind_plan) override; + + bool RegisterIsVolatile(const lldb_private::RegisterInfo *reg_info) override; + + // The SysV ppc ABI requires that stack frames be 16 byte aligned. + // When there is a trap handler on the stack, e.g. _sigtramp in userland + // code, we've seen that the stack pointer is often not aligned properly + // before the handler is invoked. This means that lldb will stop the unwind + // early -- before the function which caused the trap. + // + // To work around this, we relax that alignment to be just word-size + // (8-bytes). + // Whitelisting the trap handlers for user space would be easy (_sigtramp) but + // in other environments there can be a large number of different functions + // involved in async traps. + bool CallFrameAddressIsValid(lldb::addr_t cfa) override { + // Make sure the stack call frame addresses are 8 byte aligned + if (cfa & (8ull - 1ull)) + return false; // Not 8 byte aligned + if (cfa == 0) + return false; // Zero is not a valid stack address + return true; + } + + bool CodeAddressIsValid(lldb::addr_t pc) override { + // We have a 64 bit address space, so anything is valid as opcodes + // aren't fixed width... + return true; + } + + const lldb_private::RegisterInfo * + GetRegisterInfoArray(uint32_t &count) override; + + //------------------------------------------------------------------ + // Static Functions + //------------------------------------------------------------------ + + static void Initialize(); + + static void Terminate(); + + static lldb::ABISP CreateInstance(const lldb_private::ArchSpec &arch); + + static lldb_private::ConstString GetPluginNameStatic(); + + //------------------------------------------------------------------ + // PluginInterface protocol + //------------------------------------------------------------------ + + lldb_private::ConstString GetPluginName() override; + + uint32_t GetPluginVersion() override; protected: - void - CreateRegisterMapIfNeeded (); + void CreateRegisterMapIfNeeded(); - lldb::ValueObjectSP - GetReturnValueObjectSimple(lldb_private::Thread &thread, - lldb_private::CompilerType &ast_type) const; + lldb::ValueObjectSP + GetReturnValueObjectSimple(lldb_private::Thread &thread, + lldb_private::CompilerType &ast_type) const; - bool - RegisterIsCalleeSaved (const lldb_private::RegisterInfo *reg_info); + bool RegisterIsCalleeSaved(const lldb_private::RegisterInfo *reg_info); private: - ABISysV_ppc() : - lldb_private::ABI() - { - // Call CreateInstance instead. - } + ABISysV_ppc() : lldb_private::ABI() { + // Call CreateInstance instead. + } }; #endif // liblldb_ABISysV_ppc_h_ diff --git a/source/Plugins/ABI/SysV-ppc64/ABISysV_ppc64.cpp b/source/Plugins/ABI/SysV-ppc64/ABISysV_ppc64.cpp index fea847dd17ee..4ffcba377345 100644 --- a/source/Plugins/ABI/SysV-ppc64/ABISysV_ppc64.cpp +++ b/source/Plugins/ABI/SysV-ppc64/ABISysV_ppc64.cpp @@ -25,231 +25,271 @@ #include "lldb/Core/RegisterValue.h" #include "lldb/Core/Value.h" #include "lldb/Core/ValueObjectConstResult.h" -#include "lldb/Core/ValueObjectRegister.h" #include "lldb/Core/ValueObjectMemory.h" +#include "lldb/Core/ValueObjectRegister.h" #include "lldb/Symbol/UnwindPlan.h" -#include "lldb/Target/Target.h" #include "lldb/Target/Process.h" #include "lldb/Target/RegisterContext.h" #include "lldb/Target/StackFrame.h" +#include "lldb/Target/Target.h" #include "lldb/Target/Thread.h" using namespace lldb; using namespace lldb_private; -enum dwarf_regnums -{ - dwarf_r0 = 0, - dwarf_r1, - dwarf_r2, - dwarf_r3, - dwarf_r4, - dwarf_r5, - dwarf_r6, - dwarf_r7, - dwarf_r8, - dwarf_r9, - dwarf_r10, - dwarf_r11, - dwarf_r12, - dwarf_r13, - dwarf_r14, - dwarf_r15, - dwarf_r16, - dwarf_r17, - dwarf_r18, - dwarf_r19, - dwarf_r20, - dwarf_r21, - dwarf_r22, - dwarf_r23, - dwarf_r24, - dwarf_r25, - dwarf_r26, - dwarf_r27, - dwarf_r28, - dwarf_r29, - dwarf_r30, - dwarf_r31, - dwarf_f0, - dwarf_f1, - dwarf_f2, - dwarf_f3, - dwarf_f4, - dwarf_f5, - dwarf_f6, - dwarf_f7, - dwarf_f8, - dwarf_f9, - dwarf_f10, - dwarf_f11, - dwarf_f12, - dwarf_f13, - dwarf_f14, - dwarf_f15, - dwarf_f16, - dwarf_f17, - dwarf_f18, - dwarf_f19, - dwarf_f20, - dwarf_f21, - dwarf_f22, - dwarf_f23, - dwarf_f24, - dwarf_f25, - dwarf_f26, - dwarf_f27, - dwarf_f28, - dwarf_f29, - dwarf_f30, - dwarf_f31, - dwarf_cr, - dwarf_fpscr, - dwarf_xer = 101, - dwarf_lr = 108, - dwarf_ctr, - dwarf_pc, - dwarf_cfa, +enum dwarf_regnums { + dwarf_r0 = 0, + dwarf_r1, + dwarf_r2, + dwarf_r3, + dwarf_r4, + dwarf_r5, + dwarf_r6, + dwarf_r7, + dwarf_r8, + dwarf_r9, + dwarf_r10, + dwarf_r11, + dwarf_r12, + dwarf_r13, + dwarf_r14, + dwarf_r15, + dwarf_r16, + dwarf_r17, + dwarf_r18, + dwarf_r19, + dwarf_r20, + dwarf_r21, + dwarf_r22, + dwarf_r23, + dwarf_r24, + dwarf_r25, + dwarf_r26, + dwarf_r27, + dwarf_r28, + dwarf_r29, + dwarf_r30, + dwarf_r31, + dwarf_f0, + dwarf_f1, + dwarf_f2, + dwarf_f3, + dwarf_f4, + dwarf_f5, + dwarf_f6, + dwarf_f7, + dwarf_f8, + dwarf_f9, + dwarf_f10, + dwarf_f11, + dwarf_f12, + dwarf_f13, + dwarf_f14, + dwarf_f15, + dwarf_f16, + dwarf_f17, + dwarf_f18, + dwarf_f19, + dwarf_f20, + dwarf_f21, + dwarf_f22, + dwarf_f23, + dwarf_f24, + dwarf_f25, + dwarf_f26, + dwarf_f27, + dwarf_f28, + dwarf_f29, + dwarf_f30, + dwarf_f31, + dwarf_cr, + dwarf_fpscr, + dwarf_xer = 101, + dwarf_lr = 108, + dwarf_ctr, + dwarf_pc, + dwarf_cfa, }; // Note that the size and offset will be updated by platform-specific classes. -#define DEFINE_GPR(reg, alt, kind1, kind2, kind3, kind4) \ - { #reg, alt, 8, 0, eEncodingUint, \ - eFormatHex, { kind1, kind2, kind3, kind4}, nullptr, nullptr } - -static const RegisterInfo -g_register_infos[] = -{ - // General purpose registers. eh_frame, DWARF, Generic, Process Plugin - DEFINE_GPR(r0, nullptr, dwarf_r0, dwarf_r0, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM), - DEFINE_GPR(r1, "sp", dwarf_r1, dwarf_r1, LLDB_REGNUM_GENERIC_SP, LLDB_INVALID_REGNUM), - DEFINE_GPR(r2, nullptr, dwarf_r2, dwarf_r2, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM), - DEFINE_GPR(r3, "arg1", dwarf_r3, dwarf_r3, LLDB_REGNUM_GENERIC_ARG1, LLDB_INVALID_REGNUM), - DEFINE_GPR(r4, "arg2", dwarf_r4, dwarf_r4, LLDB_REGNUM_GENERIC_ARG2 ,LLDB_INVALID_REGNUM), - DEFINE_GPR(r5, "arg3", dwarf_r5, dwarf_r5, LLDB_REGNUM_GENERIC_ARG3, LLDB_INVALID_REGNUM), - DEFINE_GPR(r6, "arg4", dwarf_r6, dwarf_r6, LLDB_REGNUM_GENERIC_ARG4, LLDB_INVALID_REGNUM), - DEFINE_GPR(r7, "arg5", dwarf_r7, dwarf_r7, LLDB_REGNUM_GENERIC_ARG5, LLDB_INVALID_REGNUM), - DEFINE_GPR(r8, "arg6", dwarf_r8, dwarf_r8, LLDB_REGNUM_GENERIC_ARG6, LLDB_INVALID_REGNUM), - DEFINE_GPR(r9, "arg7", dwarf_r9, dwarf_r9, LLDB_REGNUM_GENERIC_ARG7, LLDB_INVALID_REGNUM), - DEFINE_GPR(r10, "arg8", dwarf_r10, dwarf_r10, LLDB_REGNUM_GENERIC_ARG8, LLDB_INVALID_REGNUM), - DEFINE_GPR(r11, nullptr, dwarf_r11, dwarf_r11, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM), - DEFINE_GPR(r12, nullptr, dwarf_r12, dwarf_r12, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM), - DEFINE_GPR(r13, nullptr, dwarf_r13, dwarf_r13, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM), - DEFINE_GPR(r14, nullptr, dwarf_r14, dwarf_r14, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM), - DEFINE_GPR(r15, nullptr, dwarf_r15, dwarf_r15, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM), - DEFINE_GPR(r16, nullptr, dwarf_r16, dwarf_r16, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM), - DEFINE_GPR(r17, nullptr, dwarf_r17, dwarf_r17, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM), - DEFINE_GPR(r18, nullptr, dwarf_r18, dwarf_r18, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM), - DEFINE_GPR(r19, nullptr, dwarf_r19, dwarf_r19, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM), - DEFINE_GPR(r20, nullptr, dwarf_r20, dwarf_r20, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM), - DEFINE_GPR(r21, nullptr, dwarf_r21, dwarf_r21, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM), - DEFINE_GPR(r22, nullptr, dwarf_r22, dwarf_r22, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM), - DEFINE_GPR(r23, nullptr, dwarf_r23, dwarf_r23, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM), - DEFINE_GPR(r24, nullptr, dwarf_r24, dwarf_r24, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM), - DEFINE_GPR(r25, nullptr, dwarf_r25, dwarf_r25, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM), - DEFINE_GPR(r26, nullptr, dwarf_r26, dwarf_r26, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM), - DEFINE_GPR(r27, nullptr, dwarf_r27, dwarf_r27, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM), - DEFINE_GPR(r28, nullptr, dwarf_r28, dwarf_r28, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM), - DEFINE_GPR(r29, nullptr, dwarf_r29, dwarf_r29, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM), - DEFINE_GPR(r30, nullptr, dwarf_r30, dwarf_r30, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM), - DEFINE_GPR(r31, nullptr, dwarf_r31, dwarf_r31, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM), - DEFINE_GPR(lr, "lr", dwarf_lr, dwarf_lr, LLDB_REGNUM_GENERIC_RA, LLDB_INVALID_REGNUM), - DEFINE_GPR(cr, "cr", dwarf_cr, dwarf_cr, LLDB_REGNUM_GENERIC_FLAGS, LLDB_INVALID_REGNUM), - DEFINE_GPR(xer, "xer", dwarf_xer, dwarf_xer, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM), - DEFINE_GPR(ctr, "ctr", dwarf_ctr, dwarf_ctr, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM), - DEFINE_GPR(pc, "pc", dwarf_pc, dwarf_pc, LLDB_REGNUM_GENERIC_PC, LLDB_INVALID_REGNUM), - { nullptr, nullptr, 8, 0, eEncodingUint, eFormatHex, { dwarf_cfa, dwarf_cfa, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr } -}; - -static const uint32_t k_num_register_infos = llvm::array_lengthof(g_register_infos); +#define DEFINE_GPR(reg, alt, kind1, kind2, kind3, kind4) \ + { \ + #reg, alt, 8, 0, eEncodingUint, eFormatHex, {kind1, kind2, kind3, kind4 }, \ + nullptr, nullptr, nullptr, 0 \ + } + +static const RegisterInfo g_register_infos[] = { + // General purpose registers. eh_frame, DWARF, + // Generic, Process Plugin + DEFINE_GPR(r0, nullptr, dwarf_r0, dwarf_r0, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM), + DEFINE_GPR(r1, "sp", dwarf_r1, dwarf_r1, LLDB_REGNUM_GENERIC_SP, + LLDB_INVALID_REGNUM), + DEFINE_GPR(r2, nullptr, dwarf_r2, dwarf_r2, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM), + DEFINE_GPR(r3, "arg1", dwarf_r3, dwarf_r3, LLDB_REGNUM_GENERIC_ARG1, + LLDB_INVALID_REGNUM), + DEFINE_GPR(r4, "arg2", dwarf_r4, dwarf_r4, LLDB_REGNUM_GENERIC_ARG2, + LLDB_INVALID_REGNUM), + DEFINE_GPR(r5, "arg3", dwarf_r5, dwarf_r5, LLDB_REGNUM_GENERIC_ARG3, + LLDB_INVALID_REGNUM), + DEFINE_GPR(r6, "arg4", dwarf_r6, dwarf_r6, LLDB_REGNUM_GENERIC_ARG4, + LLDB_INVALID_REGNUM), + DEFINE_GPR(r7, "arg5", dwarf_r7, dwarf_r7, LLDB_REGNUM_GENERIC_ARG5, + LLDB_INVALID_REGNUM), + DEFINE_GPR(r8, "arg6", dwarf_r8, dwarf_r8, LLDB_REGNUM_GENERIC_ARG6, + LLDB_INVALID_REGNUM), + DEFINE_GPR(r9, "arg7", dwarf_r9, dwarf_r9, LLDB_REGNUM_GENERIC_ARG7, + LLDB_INVALID_REGNUM), + DEFINE_GPR(r10, "arg8", dwarf_r10, dwarf_r10, LLDB_REGNUM_GENERIC_ARG8, + LLDB_INVALID_REGNUM), + DEFINE_GPR(r11, nullptr, dwarf_r11, dwarf_r11, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM), + DEFINE_GPR(r12, nullptr, dwarf_r12, dwarf_r12, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM), + DEFINE_GPR(r13, nullptr, dwarf_r13, dwarf_r13, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM), + DEFINE_GPR(r14, nullptr, dwarf_r14, dwarf_r14, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM), + DEFINE_GPR(r15, nullptr, dwarf_r15, dwarf_r15, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM), + DEFINE_GPR(r16, nullptr, dwarf_r16, dwarf_r16, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM), + DEFINE_GPR(r17, nullptr, dwarf_r17, dwarf_r17, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM), + DEFINE_GPR(r18, nullptr, dwarf_r18, dwarf_r18, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM), + DEFINE_GPR(r19, nullptr, dwarf_r19, dwarf_r19, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM), + DEFINE_GPR(r20, nullptr, dwarf_r20, dwarf_r20, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM), + DEFINE_GPR(r21, nullptr, dwarf_r21, dwarf_r21, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM), + DEFINE_GPR(r22, nullptr, dwarf_r22, dwarf_r22, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM), + DEFINE_GPR(r23, nullptr, dwarf_r23, dwarf_r23, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM), + DEFINE_GPR(r24, nullptr, dwarf_r24, dwarf_r24, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM), + DEFINE_GPR(r25, nullptr, dwarf_r25, dwarf_r25, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM), + DEFINE_GPR(r26, nullptr, dwarf_r26, dwarf_r26, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM), + DEFINE_GPR(r27, nullptr, dwarf_r27, dwarf_r27, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM), + DEFINE_GPR(r28, nullptr, dwarf_r28, dwarf_r28, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM), + DEFINE_GPR(r29, nullptr, dwarf_r29, dwarf_r29, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM), + DEFINE_GPR(r30, nullptr, dwarf_r30, dwarf_r30, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM), + DEFINE_GPR(r31, nullptr, dwarf_r31, dwarf_r31, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM), + DEFINE_GPR(lr, "lr", dwarf_lr, dwarf_lr, LLDB_REGNUM_GENERIC_RA, + LLDB_INVALID_REGNUM), + DEFINE_GPR(cr, "cr", dwarf_cr, dwarf_cr, LLDB_REGNUM_GENERIC_FLAGS, + LLDB_INVALID_REGNUM), + DEFINE_GPR(xer, "xer", dwarf_xer, dwarf_xer, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM), + DEFINE_GPR(ctr, "ctr", dwarf_ctr, dwarf_ctr, LLDB_INVALID_REGNUM, + LLDB_INVALID_REGNUM), + DEFINE_GPR(pc, "pc", dwarf_pc, dwarf_pc, LLDB_REGNUM_GENERIC_PC, + LLDB_INVALID_REGNUM), + {nullptr, + nullptr, + 8, + 0, + eEncodingUint, + eFormatHex, + {dwarf_cfa, dwarf_cfa, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, + nullptr, + nullptr, + nullptr, + 0}}; + +static const uint32_t k_num_register_infos = + llvm::array_lengthof(g_register_infos); const lldb_private::RegisterInfo * -ABISysV_ppc64::GetRegisterInfoArray (uint32_t &count) -{ - count = k_num_register_infos; - return g_register_infos; +ABISysV_ppc64::GetRegisterInfoArray(uint32_t &count) { + count = k_num_register_infos; + return g_register_infos; } -size_t -ABISysV_ppc64::GetRedZoneSize () const -{ - return 224; -} +size_t ABISysV_ppc64::GetRedZoneSize() const { return 224; } //------------------------------------------------------------------ // Static Functions //------------------------------------------------------------------ ABISP -ABISysV_ppc64::CreateInstance (const ArchSpec &arch) -{ - static ABISP g_abi_sp; - if (arch.GetTriple().getArch() == llvm::Triple::ppc64) - { - if (!g_abi_sp) - g_abi_sp.reset (new ABISysV_ppc64); - return g_abi_sp; - } - return ABISP(); +ABISysV_ppc64::CreateInstance(const ArchSpec &arch) { + static ABISP g_abi_sp; + if (arch.GetTriple().getArch() == llvm::Triple::ppc64) { + if (!g_abi_sp) + g_abi_sp.reset(new ABISysV_ppc64); + return g_abi_sp; + } + return ABISP(); } -bool -ABISysV_ppc64::PrepareTrivialCall (Thread &thread, - addr_t sp, - addr_t func_addr, - addr_t return_addr, - llvm::ArrayRef<addr_t> args) const -{ - Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS)); +bool ABISysV_ppc64::PrepareTrivialCall(Thread &thread, addr_t sp, + addr_t func_addr, addr_t return_addr, + llvm::ArrayRef<addr_t> args) const { + Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS)); - if (log) - { - StreamString s; - s.Printf("ABISysV_ppc64::PrepareTrivialCall (tid = 0x%" PRIx64 ", sp = 0x%" PRIx64 ", func_addr = 0x%" PRIx64 ", return_addr = 0x%" PRIx64, - thread.GetID(), - (uint64_t)sp, - (uint64_t)func_addr, - (uint64_t)return_addr); - - for (size_t i = 0; i < args.size(); ++i) - s.Printf (", arg%" PRIu64 " = 0x%" PRIx64, static_cast<uint64_t>(i + 1), args[i]); - s.PutCString (")"); - log->PutCString(s.GetString().c_str()); - } + if (log) { + StreamString s; + s.Printf("ABISysV_ppc64::PrepareTrivialCall (tid = 0x%" PRIx64 + ", sp = 0x%" PRIx64 ", func_addr = 0x%" PRIx64 + ", return_addr = 0x%" PRIx64, + thread.GetID(), (uint64_t)sp, (uint64_t)func_addr, + (uint64_t)return_addr); - RegisterContext *reg_ctx = thread.GetRegisterContext().get(); - if (!reg_ctx) - return false; + for (size_t i = 0; i < args.size(); ++i) + s.Printf(", arg%" PRIu64 " = 0x%" PRIx64, static_cast<uint64_t>(i + 1), + args[i]); + s.PutCString(")"); + log->PutString(s.GetString()); + } + + RegisterContext *reg_ctx = thread.GetRegisterContext().get(); + if (!reg_ctx) + return false; - const RegisterInfo *reg_info = nullptr; + const RegisterInfo *reg_info = nullptr; - if (args.size() > 8) // TODO handle more than 8 arguments - return false; + if (args.size() > 8) // TODO handle more than 8 arguments + return false; - for (size_t i = 0; i < args.size(); ++i) - { - reg_info = reg_ctx->GetRegisterInfo(eRegisterKindGeneric, LLDB_REGNUM_GENERIC_ARG1 + i); - if (log) - log->Printf("About to write arg%" PRIu64 " (0x%" PRIx64 ") into %s", static_cast<uint64_t>(i + 1), args[i], reg_info->name); - if (!reg_ctx->WriteRegisterFromUnsigned(reg_info, args[i])) - return false; - } + for (size_t i = 0; i < args.size(); ++i) { + reg_info = reg_ctx->GetRegisterInfo(eRegisterKindGeneric, + LLDB_REGNUM_GENERIC_ARG1 + i); + if (log) + log->Printf("About to write arg%" PRIu64 " (0x%" PRIx64 ") into %s", + static_cast<uint64_t>(i + 1), args[i], reg_info->name); + if (!reg_ctx->WriteRegisterFromUnsigned(reg_info, args[i])) + return false; + } - // First, align the SP + // First, align the SP - if (log) - log->Printf("16-byte aligning SP: 0x%" PRIx64 " to 0x%" PRIx64, (uint64_t)sp, (uint64_t)(sp & ~0xfull)); + if (log) + log->Printf("16-byte aligning SP: 0x%" PRIx64 " to 0x%" PRIx64, + (uint64_t)sp, (uint64_t)(sp & ~0xfull)); - sp &= ~(0xfull); // 16-byte alignment + sp &= ~(0xfull); // 16-byte alignment - sp -= 8; + sp -= 8; - Error error; - const RegisterInfo *pc_reg_info = reg_ctx->GetRegisterInfo (eRegisterKindGeneric, LLDB_REGNUM_GENERIC_PC); - const RegisterInfo *sp_reg_info = reg_ctx->GetRegisterInfo (eRegisterKindGeneric, LLDB_REGNUM_GENERIC_SP); - ProcessSP process_sp (thread.GetProcess()); + Error error; + const RegisterInfo *pc_reg_info = + reg_ctx->GetRegisterInfo(eRegisterKindGeneric, LLDB_REGNUM_GENERIC_PC); + const RegisterInfo *sp_reg_info = + reg_ctx->GetRegisterInfo(eRegisterKindGeneric, LLDB_REGNUM_GENERIC_SP); + ProcessSP process_sp(thread.GetProcess()); - RegisterValue reg_value; + RegisterValue reg_value; #if 0 // This code adds an extra frame so that we don't lose the function that we came from @@ -292,780 +332,696 @@ ABISysV_ppc64::PrepareTrivialCall (Thread &thread, } #endif - if (log) - log->Printf("Pushing the return address onto the stack: 0x%" PRIx64 ": 0x%" PRIx64, (uint64_t)sp, (uint64_t)return_addr); + if (log) + log->Printf("Pushing the return address onto the stack: 0x%" PRIx64 + ": 0x%" PRIx64, + (uint64_t)sp, (uint64_t)return_addr); - // Save return address onto the stack - if (!process_sp->WritePointerToMemory(sp, return_addr, error)) - return false; + // Save return address onto the stack + if (!process_sp->WritePointerToMemory(sp, return_addr, error)) + return false; - // %r1 is set to the actual stack value. + // %r1 is set to the actual stack value. - if (log) - log->Printf("Writing SP: 0x%" PRIx64, (uint64_t)sp); + if (log) + log->Printf("Writing SP: 0x%" PRIx64, (uint64_t)sp); - if (!reg_ctx->WriteRegisterFromUnsigned (sp_reg_info, sp)) - return false; + if (!reg_ctx->WriteRegisterFromUnsigned(sp_reg_info, sp)) + return false; - // %pc is set to the address of the called function. + // %pc is set to the address of the called function. - if (log) - log->Printf("Writing IP: 0x%" PRIx64, (uint64_t)func_addr); + if (log) + log->Printf("Writing IP: 0x%" PRIx64, (uint64_t)func_addr); - if (!reg_ctx->WriteRegisterFromUnsigned (pc_reg_info, func_addr)) - return false; + if (!reg_ctx->WriteRegisterFromUnsigned(pc_reg_info, func_addr)) + return false; - return true; + return true; } -static bool ReadIntegerArgument(Scalar &scalar, - unsigned int bit_width, - bool is_signed, - Thread &thread, - uint32_t *argument_register_ids, - unsigned int ¤t_argument_register, - addr_t ¤t_stack_argument) -{ - if (bit_width > 64) - return false; // Scalar can't hold large integer arguments - - if (current_argument_register < 6) - { - scalar = thread.GetRegisterContext()->ReadRegisterAsUnsigned(argument_register_ids[current_argument_register], 0); - current_argument_register++; - if (is_signed) - scalar.SignExtend (bit_width); - } - else - { - uint32_t byte_size = (bit_width + (8-1))/8; - Error error; - if (thread.GetProcess()->ReadScalarIntegerFromMemory(current_stack_argument, byte_size, is_signed, scalar, error)) - { - current_stack_argument += byte_size; - return true; - } - return false; +static bool ReadIntegerArgument(Scalar &scalar, unsigned int bit_width, + bool is_signed, Thread &thread, + uint32_t *argument_register_ids, + unsigned int ¤t_argument_register, + addr_t ¤t_stack_argument) { + if (bit_width > 64) + return false; // Scalar can't hold large integer arguments + + if (current_argument_register < 6) { + scalar = thread.GetRegisterContext()->ReadRegisterAsUnsigned( + argument_register_ids[current_argument_register], 0); + current_argument_register++; + if (is_signed) + scalar.SignExtend(bit_width); + } else { + uint32_t byte_size = (bit_width + (8 - 1)) / 8; + Error error; + if (thread.GetProcess()->ReadScalarIntegerFromMemory( + current_stack_argument, byte_size, is_signed, scalar, error)) { + current_stack_argument += byte_size; + return true; } - return true; + return false; + } + return true; } -bool -ABISysV_ppc64::GetArgumentValues (Thread &thread, - ValueList &values) const -{ - unsigned int num_values = values.GetSize(); - unsigned int value_index; - - // Extract the register context so we can read arguments from registers +bool ABISysV_ppc64::GetArgumentValues(Thread &thread, ValueList &values) const { + unsigned int num_values = values.GetSize(); + unsigned int value_index; - RegisterContext *reg_ctx = thread.GetRegisterContext().get(); + // Extract the register context so we can read arguments from registers - if (!reg_ctx) - return false; - - // Get the pointer to the first stack argument so we have a place to start - // when reading data - - addr_t sp = reg_ctx->GetSP(0); - - if (!sp) - return false; + RegisterContext *reg_ctx = thread.GetRegisterContext().get(); - addr_t current_stack_argument = sp + 48; // jump over return address - - uint32_t argument_register_ids[8]; + if (!reg_ctx) + return false; - argument_register_ids[0] = reg_ctx->GetRegisterInfo (eRegisterKindGeneric, LLDB_REGNUM_GENERIC_ARG1)->kinds[eRegisterKindLLDB]; - argument_register_ids[1] = reg_ctx->GetRegisterInfo (eRegisterKindGeneric, LLDB_REGNUM_GENERIC_ARG2)->kinds[eRegisterKindLLDB]; - argument_register_ids[2] = reg_ctx->GetRegisterInfo (eRegisterKindGeneric, LLDB_REGNUM_GENERIC_ARG3)->kinds[eRegisterKindLLDB]; - argument_register_ids[3] = reg_ctx->GetRegisterInfo (eRegisterKindGeneric, LLDB_REGNUM_GENERIC_ARG4)->kinds[eRegisterKindLLDB]; - argument_register_ids[4] = reg_ctx->GetRegisterInfo (eRegisterKindGeneric, LLDB_REGNUM_GENERIC_ARG5)->kinds[eRegisterKindLLDB]; - argument_register_ids[5] = reg_ctx->GetRegisterInfo (eRegisterKindGeneric, LLDB_REGNUM_GENERIC_ARG6)->kinds[eRegisterKindLLDB]; - argument_register_ids[6] = reg_ctx->GetRegisterInfo (eRegisterKindGeneric, LLDB_REGNUM_GENERIC_ARG7)->kinds[eRegisterKindLLDB]; - argument_register_ids[7] = reg_ctx->GetRegisterInfo (eRegisterKindGeneric, LLDB_REGNUM_GENERIC_ARG8)->kinds[eRegisterKindLLDB]; + // Get the pointer to the first stack argument so we have a place to start + // when reading data - unsigned int current_argument_register = 0; + addr_t sp = reg_ctx->GetSP(0); - for (value_index = 0; - value_index < num_values; - ++value_index) - { - Value *value = values.GetValueAtIndex(value_index); - - if (!value) - return false; + if (!sp) + return false; - // We currently only support extracting values with Clang QualTypes. - // Do we care about others? - CompilerType compiler_type = value->GetCompilerType(); - if (!compiler_type) - return false; - bool is_signed; + addr_t current_stack_argument = sp + 48; // jump over return address + + uint32_t argument_register_ids[8]; + + argument_register_ids[0] = + reg_ctx->GetRegisterInfo(eRegisterKindGeneric, LLDB_REGNUM_GENERIC_ARG1) + ->kinds[eRegisterKindLLDB]; + argument_register_ids[1] = + reg_ctx->GetRegisterInfo(eRegisterKindGeneric, LLDB_REGNUM_GENERIC_ARG2) + ->kinds[eRegisterKindLLDB]; + argument_register_ids[2] = + reg_ctx->GetRegisterInfo(eRegisterKindGeneric, LLDB_REGNUM_GENERIC_ARG3) + ->kinds[eRegisterKindLLDB]; + argument_register_ids[3] = + reg_ctx->GetRegisterInfo(eRegisterKindGeneric, LLDB_REGNUM_GENERIC_ARG4) + ->kinds[eRegisterKindLLDB]; + argument_register_ids[4] = + reg_ctx->GetRegisterInfo(eRegisterKindGeneric, LLDB_REGNUM_GENERIC_ARG5) + ->kinds[eRegisterKindLLDB]; + argument_register_ids[5] = + reg_ctx->GetRegisterInfo(eRegisterKindGeneric, LLDB_REGNUM_GENERIC_ARG6) + ->kinds[eRegisterKindLLDB]; + argument_register_ids[6] = + reg_ctx->GetRegisterInfo(eRegisterKindGeneric, LLDB_REGNUM_GENERIC_ARG7) + ->kinds[eRegisterKindLLDB]; + argument_register_ids[7] = + reg_ctx->GetRegisterInfo(eRegisterKindGeneric, LLDB_REGNUM_GENERIC_ARG8) + ->kinds[eRegisterKindLLDB]; + + unsigned int current_argument_register = 0; + + for (value_index = 0; value_index < num_values; ++value_index) { + Value *value = values.GetValueAtIndex(value_index); + + if (!value) + return false; + + // We currently only support extracting values with Clang QualTypes. + // Do we care about others? + CompilerType compiler_type = value->GetCompilerType(); + if (!compiler_type) + return false; + bool is_signed; - if (compiler_type.IsIntegerOrEnumerationType (is_signed)) - { - ReadIntegerArgument(value->GetScalar(), - compiler_type.GetBitSize(&thread), - is_signed, - thread, - argument_register_ids, - current_argument_register, - current_stack_argument); - } - else if (compiler_type.IsPointerType ()) - { - ReadIntegerArgument(value->GetScalar(), - compiler_type.GetBitSize(&thread), - false, - thread, - argument_register_ids, - current_argument_register, - current_stack_argument); - } + if (compiler_type.IsIntegerOrEnumerationType(is_signed)) { + ReadIntegerArgument(value->GetScalar(), compiler_type.GetBitSize(&thread), + is_signed, thread, argument_register_ids, + current_argument_register, current_stack_argument); + } else if (compiler_type.IsPointerType()) { + ReadIntegerArgument(value->GetScalar(), compiler_type.GetBitSize(&thread), + false, thread, argument_register_ids, + current_argument_register, current_stack_argument); } + } - return true; + return true; } -Error -ABISysV_ppc64::SetReturnValueObject(lldb::StackFrameSP &frame_sp, lldb::ValueObjectSP &new_value_sp) -{ - Error error; - if (!new_value_sp) - { - error.SetErrorString("Empty value object for return value."); - return error; - } +Error ABISysV_ppc64::SetReturnValueObject(lldb::StackFrameSP &frame_sp, + lldb::ValueObjectSP &new_value_sp) { + Error error; + if (!new_value_sp) { + error.SetErrorString("Empty value object for return value."); + return error; + } - CompilerType compiler_type = new_value_sp->GetCompilerType(); - if (!compiler_type) - { - error.SetErrorString ("Null clang type for return value."); - return error; - } + CompilerType compiler_type = new_value_sp->GetCompilerType(); + if (!compiler_type) { + error.SetErrorString("Null clang type for return value."); + return error; + } - Thread *thread = frame_sp->GetThread().get(); + Thread *thread = frame_sp->GetThread().get(); - bool is_signed; - uint32_t count; - bool is_complex; + bool is_signed; + uint32_t count; + bool is_complex; - RegisterContext *reg_ctx = thread->GetRegisterContext().get(); + RegisterContext *reg_ctx = thread->GetRegisterContext().get(); - bool set_it_simple = false; - if (compiler_type.IsIntegerOrEnumerationType (is_signed) || compiler_type.IsPointerType()) - { - const RegisterInfo *reg_info = reg_ctx->GetRegisterInfoByName("r3", 0); + bool set_it_simple = false; + if (compiler_type.IsIntegerOrEnumerationType(is_signed) || + compiler_type.IsPointerType()) { + const RegisterInfo *reg_info = reg_ctx->GetRegisterInfoByName("r3", 0); + DataExtractor data; + Error data_error; + size_t num_bytes = new_value_sp->GetData(data, data_error); + if (data_error.Fail()) { + error.SetErrorStringWithFormat( + "Couldn't convert return value to raw data: %s", + data_error.AsCString()); + return error; + } + lldb::offset_t offset = 0; + if (num_bytes <= 8) { + uint64_t raw_value = data.GetMaxU64(&offset, num_bytes); + + if (reg_ctx->WriteRegisterFromUnsigned(reg_info, raw_value)) + set_it_simple = true; + } else { + error.SetErrorString("We don't support returning longer than 64 bit " + "integer values at present."); + } + } else if (compiler_type.IsFloatingPointType(count, is_complex)) { + if (is_complex) + error.SetErrorString( + "We don't support returning complex values at present"); + else { + size_t bit_width = compiler_type.GetBitSize(frame_sp.get()); + if (bit_width <= 64) { DataExtractor data; Error data_error; size_t num_bytes = new_value_sp->GetData(data, data_error); - if (data_error.Fail()) - { - error.SetErrorStringWithFormat("Couldn't convert return value to raw data: %s", data_error.AsCString()); - return error; + if (data_error.Fail()) { + error.SetErrorStringWithFormat( + "Couldn't convert return value to raw data: %s", + data_error.AsCString()); + return error; } - lldb::offset_t offset = 0; - if (num_bytes <= 8) - { - uint64_t raw_value = data.GetMaxU64(&offset, num_bytes); - if (reg_ctx->WriteRegisterFromUnsigned (reg_info, raw_value)) - set_it_simple = true; - } - else - { - error.SetErrorString("We don't support returning longer than 64 bit integer values at present."); - } - } - else if (compiler_type.IsFloatingPointType (count, is_complex)) - { - if (is_complex) - error.SetErrorString ("We don't support returning complex values at present"); - else - { - size_t bit_width = compiler_type.GetBitSize(frame_sp.get()); - if (bit_width <= 64) - { - DataExtractor data; - Error data_error; - size_t num_bytes = new_value_sp->GetData(data, data_error); - if (data_error.Fail()) - { - error.SetErrorStringWithFormat("Couldn't convert return value to raw data: %s", data_error.AsCString()); - return error; - } - - unsigned char buffer[16]; - ByteOrder byte_order = data.GetByteOrder(); + unsigned char buffer[16]; + ByteOrder byte_order = data.GetByteOrder(); - data.CopyByteOrderedData (0, num_bytes, buffer, 16, byte_order); - set_it_simple = true; - } - else - { - // FIXME - don't know how to do 80 bit long doubles yet. - error.SetErrorString ("We don't support returning float values > 64 bits at present"); - } - } + data.CopyByteOrderedData(0, num_bytes, buffer, 16, byte_order); + set_it_simple = true; + } else { + // FIXME - don't know how to do 80 bit long doubles yet. + error.SetErrorString( + "We don't support returning float values > 64 bits at present"); + } } + } - if (!set_it_simple) - { - // Okay we've got a structure or something that doesn't fit in a simple register. - // We should figure out where it really goes, but we don't support this yet. - error.SetErrorString ("We only support setting simple integer and float return types at present."); - } + if (!set_it_simple) { + // Okay we've got a structure or something that doesn't fit in a simple + // register. + // We should figure out where it really goes, but we don't support this yet. + error.SetErrorString("We only support setting simple integer and float " + "return types at present."); + } - return error; + return error; } -ValueObjectSP -ABISysV_ppc64::GetReturnValueObjectSimple (Thread &thread, - CompilerType &return_compiler_type) const -{ - ValueObjectSP return_valobj_sp; - Value value; +ValueObjectSP ABISysV_ppc64::GetReturnValueObjectSimple( + Thread &thread, CompilerType &return_compiler_type) const { + ValueObjectSP return_valobj_sp; + Value value; - if (!return_compiler_type) - return return_valobj_sp; + if (!return_compiler_type) + return return_valobj_sp; - //value.SetContext (Value::eContextTypeClangType, return_value_type); - value.SetCompilerType (return_compiler_type); + // value.SetContext (Value::eContextTypeClangType, return_value_type); + value.SetCompilerType(return_compiler_type); - RegisterContext *reg_ctx = thread.GetRegisterContext().get(); - if (!reg_ctx) - return return_valobj_sp; + RegisterContext *reg_ctx = thread.GetRegisterContext().get(); + if (!reg_ctx) + return return_valobj_sp; - const uint32_t type_flags = return_compiler_type.GetTypeInfo (); - if (type_flags & eTypeIsScalar) - { - value.SetValueType(Value::eValueTypeScalar); + const uint32_t type_flags = return_compiler_type.GetTypeInfo(); + if (type_flags & eTypeIsScalar) { + value.SetValueType(Value::eValueTypeScalar); - bool success = false; - if (type_flags & eTypeIsInteger) - { - // Extract the register context so we can read arguments from registers - - const size_t byte_size = return_compiler_type.GetByteSize(nullptr); - uint64_t raw_value = thread.GetRegisterContext()->ReadRegisterAsUnsigned(reg_ctx->GetRegisterInfoByName("r3", 0), 0); - const bool is_signed = (type_flags & eTypeIsSigned) != 0; - switch (byte_size) - { - default: - break; - - case sizeof(uint64_t): - if (is_signed) - value.GetScalar() = (int64_t)(raw_value); - else - value.GetScalar() = (uint64_t)(raw_value); - success = true; - break; + bool success = false; + if (type_flags & eTypeIsInteger) { + // Extract the register context so we can read arguments from registers - case sizeof(uint32_t): - if (is_signed) - value.GetScalar() = (int32_t)(raw_value & UINT32_MAX); - else - value.GetScalar() = (uint32_t)(raw_value & UINT32_MAX); - success = true; - break; + const size_t byte_size = return_compiler_type.GetByteSize(nullptr); + uint64_t raw_value = thread.GetRegisterContext()->ReadRegisterAsUnsigned( + reg_ctx->GetRegisterInfoByName("r3", 0), 0); + const bool is_signed = (type_flags & eTypeIsSigned) != 0; + switch (byte_size) { + default: + break; - case sizeof(uint16_t): - if (is_signed) - value.GetScalar() = (int16_t)(raw_value & UINT16_MAX); - else - value.GetScalar() = (uint16_t)(raw_value & UINT16_MAX); - success = true; - break; + case sizeof(uint64_t): + if (is_signed) + value.GetScalar() = (int64_t)(raw_value); + else + value.GetScalar() = (uint64_t)(raw_value); + success = true; + break; - case sizeof(uint8_t): - if (is_signed) - value.GetScalar() = (int8_t)(raw_value & UINT8_MAX); - else - value.GetScalar() = (uint8_t)(raw_value & UINT8_MAX); + case sizeof(uint32_t): + if (is_signed) + value.GetScalar() = (int32_t)(raw_value & UINT32_MAX); + else + value.GetScalar() = (uint32_t)(raw_value & UINT32_MAX); + success = true; + break; + + case sizeof(uint16_t): + if (is_signed) + value.GetScalar() = (int16_t)(raw_value & UINT16_MAX); + else + value.GetScalar() = (uint16_t)(raw_value & UINT16_MAX); + success = true; + break; + + case sizeof(uint8_t): + if (is_signed) + value.GetScalar() = (int8_t)(raw_value & UINT8_MAX); + else + value.GetScalar() = (uint8_t)(raw_value & UINT8_MAX); + success = true; + break; + } + } else if (type_flags & eTypeIsFloat) { + if (type_flags & eTypeIsComplex) { + // Don't handle complex yet. + } else { + const size_t byte_size = return_compiler_type.GetByteSize(nullptr); + if (byte_size <= sizeof(long double)) { + const RegisterInfo *f1_info = reg_ctx->GetRegisterInfoByName("f1", 0); + RegisterValue f1_value; + if (reg_ctx->ReadRegister(f1_info, f1_value)) { + DataExtractor data; + if (f1_value.GetData(data)) { + lldb::offset_t offset = 0; + if (byte_size == sizeof(float)) { + value.GetScalar() = (float)data.GetFloat(&offset); success = true; - break; - } - } - else if (type_flags & eTypeIsFloat) - { - if (type_flags & eTypeIsComplex) - { - // Don't handle complex yet. - } - else - { - const size_t byte_size = return_compiler_type.GetByteSize(nullptr); - if (byte_size <= sizeof(long double)) - { - const RegisterInfo *f1_info = reg_ctx->GetRegisterInfoByName("f1", 0); - RegisterValue f1_value; - if (reg_ctx->ReadRegister (f1_info, f1_value)) - { - DataExtractor data; - if (f1_value.GetData(data)) - { - lldb::offset_t offset = 0; - if (byte_size == sizeof(float)) - { - value.GetScalar() = (float) data.GetFloat(&offset); - success = true; - } - else if (byte_size == sizeof(double)) - { - value.GetScalar() = (double) data.GetDouble(&offset); - success = true; - } - } - } - } + } else if (byte_size == sizeof(double)) { + value.GetScalar() = (double)data.GetDouble(&offset); + success = true; + } } + } } - - if (success) - return_valobj_sp = ValueObjectConstResult::Create (thread.GetStackFrameAtIndex(0).get(), - value, - ConstString("")); - } - else if (type_flags & eTypeIsPointer) - { - unsigned r3_id = reg_ctx->GetRegisterInfoByName("r3", 0)->kinds[eRegisterKindLLDB]; - value.GetScalar() = (uint64_t)thread.GetRegisterContext()->ReadRegisterAsUnsigned(r3_id, 0); - value.SetValueType(Value::eValueTypeScalar); - return_valobj_sp = ValueObjectConstResult::Create (thread.GetStackFrameAtIndex(0).get(), - value, - ConstString("")); + } } - else if (type_flags & eTypeIsVector) - { - const size_t byte_size = return_compiler_type.GetByteSize(nullptr); - if (byte_size > 0) - { - const RegisterInfo *altivec_reg = reg_ctx->GetRegisterInfoByName("v2", 0); - if (altivec_reg) - { - if (byte_size <= altivec_reg->byte_size) - { - ProcessSP process_sp (thread.GetProcess()); - if (process_sp) - { - std::unique_ptr<DataBufferHeap> heap_data_ap (new DataBufferHeap(byte_size, 0)); - const ByteOrder byte_order = process_sp->GetByteOrder(); - RegisterValue reg_value; - if (reg_ctx->ReadRegister(altivec_reg, reg_value)) - { - Error error; - if (reg_value.GetAsMemoryData (altivec_reg, - heap_data_ap->GetBytes(), - heap_data_ap->GetByteSize(), - byte_order, - error)) - { - DataExtractor data (DataBufferSP (heap_data_ap.release()), - byte_order, - process_sp->GetTarget().GetArchitecture().GetAddressByteSize()); - return_valobj_sp = ValueObjectConstResult::Create (&thread, - return_compiler_type, - ConstString(""), - data); - } - } - } - } + + if (success) + return_valobj_sp = ValueObjectConstResult::Create( + thread.GetStackFrameAtIndex(0).get(), value, ConstString("")); + } else if (type_flags & eTypeIsPointer) { + unsigned r3_id = + reg_ctx->GetRegisterInfoByName("r3", 0)->kinds[eRegisterKindLLDB]; + value.GetScalar() = + (uint64_t)thread.GetRegisterContext()->ReadRegisterAsUnsigned(r3_id, 0); + value.SetValueType(Value::eValueTypeScalar); + return_valobj_sp = ValueObjectConstResult::Create( + thread.GetStackFrameAtIndex(0).get(), value, ConstString("")); + } else if (type_flags & eTypeIsVector) { + const size_t byte_size = return_compiler_type.GetByteSize(nullptr); + if (byte_size > 0) { + const RegisterInfo *altivec_reg = reg_ctx->GetRegisterInfoByName("v2", 0); + if (altivec_reg) { + if (byte_size <= altivec_reg->byte_size) { + ProcessSP process_sp(thread.GetProcess()); + if (process_sp) { + std::unique_ptr<DataBufferHeap> heap_data_ap( + new DataBufferHeap(byte_size, 0)); + const ByteOrder byte_order = process_sp->GetByteOrder(); + RegisterValue reg_value; + if (reg_ctx->ReadRegister(altivec_reg, reg_value)) { + Error error; + if (reg_value.GetAsMemoryData( + altivec_reg, heap_data_ap->GetBytes(), + heap_data_ap->GetByteSize(), byte_order, error)) { + DataExtractor data(DataBufferSP(heap_data_ap.release()), + byte_order, process_sp->GetTarget() + .GetArchitecture() + .GetAddressByteSize()); + return_valobj_sp = ValueObjectConstResult::Create( + &thread, return_compiler_type, ConstString(""), data); + } } + } } + } } + } - return return_valobj_sp; + return return_valobj_sp; } -ValueObjectSP -ABISysV_ppc64::GetReturnValueObjectImpl (Thread &thread, CompilerType &return_compiler_type) const -{ - ValueObjectSP return_valobj_sp; +ValueObjectSP ABISysV_ppc64::GetReturnValueObjectImpl( + Thread &thread, CompilerType &return_compiler_type) const { + ValueObjectSP return_valobj_sp; - if (!return_compiler_type) - return return_valobj_sp; + if (!return_compiler_type) + return return_valobj_sp; - ExecutionContext exe_ctx (thread.shared_from_this()); - return_valobj_sp = GetReturnValueObjectSimple(thread, return_compiler_type); - if (return_valobj_sp) - return return_valobj_sp; + ExecutionContext exe_ctx(thread.shared_from_this()); + return_valobj_sp = GetReturnValueObjectSimple(thread, return_compiler_type); + if (return_valobj_sp) + return return_valobj_sp; - RegisterContextSP reg_ctx_sp = thread.GetRegisterContext(); - if (!reg_ctx_sp) - return return_valobj_sp; + RegisterContextSP reg_ctx_sp = thread.GetRegisterContext(); + if (!reg_ctx_sp) + return return_valobj_sp; - const size_t bit_width = return_compiler_type.GetBitSize(&thread); - if (return_compiler_type.IsAggregateType()) - { - Target *target = exe_ctx.GetTargetPtr(); - bool is_memory = true; - if (bit_width <= 128) - { - ByteOrder target_byte_order = target->GetArchitecture().GetByteOrder(); - DataBufferSP data_sp (new DataBufferHeap(16, 0)); - DataExtractor return_ext (data_sp, - target_byte_order, - target->GetArchitecture().GetAddressByteSize()); + const size_t bit_width = return_compiler_type.GetBitSize(&thread); + if (return_compiler_type.IsAggregateType()) { + Target *target = exe_ctx.GetTargetPtr(); + bool is_memory = true; + if (bit_width <= 128) { + ByteOrder target_byte_order = target->GetArchitecture().GetByteOrder(); + DataBufferSP data_sp(new DataBufferHeap(16, 0)); + DataExtractor return_ext(data_sp, target_byte_order, + target->GetArchitecture().GetAddressByteSize()); - const RegisterInfo *r3_info = reg_ctx_sp->GetRegisterInfoByName("r3", 0); - const RegisterInfo *rdx_info = reg_ctx_sp->GetRegisterInfoByName("rdx", 0); + const RegisterInfo *r3_info = reg_ctx_sp->GetRegisterInfoByName("r3", 0); + const RegisterInfo *rdx_info = + reg_ctx_sp->GetRegisterInfoByName("rdx", 0); - RegisterValue r3_value, rdx_value; - reg_ctx_sp->ReadRegister (r3_info, r3_value); - reg_ctx_sp->ReadRegister (rdx_info, rdx_value); + RegisterValue r3_value, rdx_value; + reg_ctx_sp->ReadRegister(r3_info, r3_value); + reg_ctx_sp->ReadRegister(rdx_info, rdx_value); - DataExtractor r3_data, rdx_data; + DataExtractor r3_data, rdx_data; - r3_value.GetData(r3_data); - rdx_value.GetData(rdx_data); + r3_value.GetData(r3_data); + rdx_value.GetData(rdx_data); - uint32_t fp_bytes = 0; // Tracks how much of the xmm registers we've consumed so far - uint32_t integer_bytes = 0; // Tracks how much of the r3/rds registers we've consumed so far + uint32_t fp_bytes = + 0; // Tracks how much of the xmm registers we've consumed so far + uint32_t integer_bytes = + 0; // Tracks how much of the r3/rds registers we've consumed so far - const uint32_t num_children = return_compiler_type.GetNumFields (); + const uint32_t num_children = return_compiler_type.GetNumFields(); - // Since we are in the small struct regime, assume we are not in memory. - is_memory = false; + // Since we are in the small struct regime, assume we are not in memory. + is_memory = false; - for (uint32_t idx = 0; idx < num_children; idx++) - { - std::string name; - uint64_t field_bit_offset = 0; - bool is_signed; - bool is_complex; - uint32_t count; + for (uint32_t idx = 0; idx < num_children; idx++) { + std::string name; + uint64_t field_bit_offset = 0; + bool is_signed; + bool is_complex; + uint32_t count; - CompilerType field_compiler_type = return_compiler_type.GetFieldAtIndex(idx, name, &field_bit_offset, nullptr, nullptr); - const size_t field_bit_width = field_compiler_type.GetBitSize(&thread); + CompilerType field_compiler_type = return_compiler_type.GetFieldAtIndex( + idx, name, &field_bit_offset, nullptr, nullptr); + const size_t field_bit_width = field_compiler_type.GetBitSize(&thread); - // If there are any unaligned fields, this is stored in memory. - if (field_bit_offset % field_bit_width != 0) - { - is_memory = true; - break; - } + // If there are any unaligned fields, this is stored in memory. + if (field_bit_offset % field_bit_width != 0) { + is_memory = true; + break; + } - uint32_t field_byte_width = field_bit_width/8; - uint32_t field_byte_offset = field_bit_offset/8; - - DataExtractor *copy_from_extractor = nullptr; - uint32_t copy_from_offset = 0; - - if (field_compiler_type.IsIntegerOrEnumerationType (is_signed) || field_compiler_type.IsPointerType ()) - { - if (integer_bytes < 8) - { - if (integer_bytes + field_byte_width <= 8) - { - // This is in RAX, copy from register to our result structure: - copy_from_extractor = &r3_data; - copy_from_offset = integer_bytes; - integer_bytes += field_byte_width; - } - else - { - // The next field wouldn't fit in the remaining space, so we pushed it to rdx. - copy_from_extractor = &rdx_data; - copy_from_offset = 0; - integer_bytes = 8 + field_byte_width; - - } - } - else if (integer_bytes + field_byte_width <= 16) - { - copy_from_extractor = &rdx_data; - copy_from_offset = integer_bytes - 8; - integer_bytes += field_byte_width; - } - else - { - // The last field didn't fit. I can't see how that would happen w/o the overall size being - // greater than 16 bytes. For now, return a nullptr return value object. - return return_valobj_sp; - } + uint32_t field_byte_width = field_bit_width / 8; + uint32_t field_byte_offset = field_bit_offset / 8; + + DataExtractor *copy_from_extractor = nullptr; + uint32_t copy_from_offset = 0; + + if (field_compiler_type.IsIntegerOrEnumerationType(is_signed) || + field_compiler_type.IsPointerType()) { + if (integer_bytes < 8) { + if (integer_bytes + field_byte_width <= 8) { + // This is in RAX, copy from register to our result structure: + copy_from_extractor = &r3_data; + copy_from_offset = integer_bytes; + integer_bytes += field_byte_width; + } else { + // The next field wouldn't fit in the remaining space, so we + // pushed it to rdx. + copy_from_extractor = &rdx_data; + copy_from_offset = 0; + integer_bytes = 8 + field_byte_width; + } + } else if (integer_bytes + field_byte_width <= 16) { + copy_from_extractor = &rdx_data; + copy_from_offset = integer_bytes - 8; + integer_bytes += field_byte_width; + } else { + // The last field didn't fit. I can't see how that would happen w/o + // the overall size being + // greater than 16 bytes. For now, return a nullptr return value + // object. + return return_valobj_sp; + } + } else if (field_compiler_type.IsFloatingPointType(count, is_complex)) { + // Structs with long doubles are always passed in memory. + if (field_bit_width == 128) { + is_memory = true; + break; + } else if (field_bit_width == 64) { + copy_from_offset = 0; + fp_bytes += field_byte_width; + } else if (field_bit_width == 32) { + // This one is kind of complicated. If we are in an "eightbyte" + // with another float, we'll + // be stuffed into an xmm register with it. If we are in an + // "eightbyte" with one or more ints, + // then we will be stuffed into the appropriate GPR with them. + bool in_gpr; + if (field_byte_offset % 8 == 0) { + // We are at the beginning of one of the eightbytes, so check the + // next element (if any) + if (idx == num_children - 1) + in_gpr = false; + else { + uint64_t next_field_bit_offset = 0; + CompilerType next_field_compiler_type = + return_compiler_type.GetFieldAtIndex(idx + 1, name, + &next_field_bit_offset, + nullptr, nullptr); + if (next_field_compiler_type.IsIntegerOrEnumerationType( + is_signed)) + in_gpr = true; + else { + copy_from_offset = 0; + in_gpr = false; } - else if (field_compiler_type.IsFloatingPointType (count, is_complex)) - { - // Structs with long doubles are always passed in memory. - if (field_bit_width == 128) - { - is_memory = true; - break; - } - else if (field_bit_width == 64) - { - copy_from_offset = 0; - fp_bytes += field_byte_width; - } - else if (field_bit_width == 32) - { - // This one is kind of complicated. If we are in an "eightbyte" with another float, we'll - // be stuffed into an xmm register with it. If we are in an "eightbyte" with one or more ints, - // then we will be stuffed into the appropriate GPR with them. - bool in_gpr; - if (field_byte_offset % 8 == 0) - { - // We are at the beginning of one of the eightbytes, so check the next element (if any) - if (idx == num_children - 1) - in_gpr = false; - else - { - uint64_t next_field_bit_offset = 0; - CompilerType next_field_compiler_type = return_compiler_type.GetFieldAtIndex (idx + 1, - name, - &next_field_bit_offset, - nullptr, - nullptr); - if (next_field_compiler_type.IsIntegerOrEnumerationType (is_signed)) - in_gpr = true; - else - { - copy_from_offset = 0; - in_gpr = false; - } - } - } - else if (field_byte_offset % 4 == 0) - { - // We are inside of an eightbyte, so see if the field before us is floating point: - // This could happen if somebody put padding in the structure. - if (idx == 0) - in_gpr = false; - else - { - uint64_t prev_field_bit_offset = 0; - CompilerType prev_field_compiler_type = return_compiler_type.GetFieldAtIndex (idx - 1, - name, - &prev_field_bit_offset, - nullptr, - nullptr); - if (prev_field_compiler_type.IsIntegerOrEnumerationType (is_signed)) - in_gpr = true; - else - { - copy_from_offset = 4; - in_gpr = false; - } - } - } - else - { - is_memory = true; - continue; - } - - // Okay, we've figured out whether we are in GPR or XMM, now figure out which one. - if (in_gpr) - { - if (integer_bytes < 8) - { - // This is in RAX, copy from register to our result structure: - copy_from_extractor = &r3_data; - copy_from_offset = integer_bytes; - integer_bytes += field_byte_width; - } - else - { - copy_from_extractor = &rdx_data; - copy_from_offset = integer_bytes - 8; - integer_bytes += field_byte_width; - } - } - else - { - fp_bytes += field_byte_width; - } - } + } + } else if (field_byte_offset % 4 == 0) { + // We are inside of an eightbyte, so see if the field before us is + // floating point: + // This could happen if somebody put padding in the structure. + if (idx == 0) + in_gpr = false; + else { + uint64_t prev_field_bit_offset = 0; + CompilerType prev_field_compiler_type = + return_compiler_type.GetFieldAtIndex(idx - 1, name, + &prev_field_bit_offset, + nullptr, nullptr); + if (prev_field_compiler_type.IsIntegerOrEnumerationType( + is_signed)) + in_gpr = true; + else { + copy_from_offset = 4; + in_gpr = false; } - - // These two tests are just sanity checks. If I somehow get the - // type calculation wrong above it is better to just return nothing - // than to assert or crash. - if (!copy_from_extractor) - return return_valobj_sp; - if (copy_from_offset + field_byte_width > copy_from_extractor->GetByteSize()) - return return_valobj_sp; - - copy_from_extractor->CopyByteOrderedData (copy_from_offset, - field_byte_width, - data_sp->GetBytes() + field_byte_offset, - field_byte_width, - target_byte_order); + } + } else { + is_memory = true; + continue; } - if (!is_memory) - { - // The result is in our data buffer. Let's make a variable object out of it: - return_valobj_sp = ValueObjectConstResult::Create (&thread, - return_compiler_type, - ConstString(""), - return_ext); + // Okay, we've figured out whether we are in GPR or XMM, now figure + // out which one. + if (in_gpr) { + if (integer_bytes < 8) { + // This is in RAX, copy from register to our result structure: + copy_from_extractor = &r3_data; + copy_from_offset = integer_bytes; + integer_bytes += field_byte_width; + } else { + copy_from_extractor = &rdx_data; + copy_from_offset = integer_bytes - 8; + integer_bytes += field_byte_width; + } + } else { + fp_bytes += field_byte_width; } + } } - // FIXME: This is just taking a guess, r3 may very well no longer hold the return storage location. - // If we are going to do this right, when we make a new frame we should check to see if it uses a memory - // return, and if we are at the first instruction and if so stash away the return location. Then we would - // only return the memory return value if we know it is valid. + // These two tests are just sanity checks. If I somehow get the + // type calculation wrong above it is better to just return nothing + // than to assert or crash. + if (!copy_from_extractor) + return return_valobj_sp; + if (copy_from_offset + field_byte_width > + copy_from_extractor->GetByteSize()) + return return_valobj_sp; + + copy_from_extractor->CopyByteOrderedData( + copy_from_offset, field_byte_width, + data_sp->GetBytes() + field_byte_offset, field_byte_width, + target_byte_order); + } + + if (!is_memory) { + // The result is in our data buffer. Let's make a variable object out + // of it: + return_valobj_sp = ValueObjectConstResult::Create( + &thread, return_compiler_type, ConstString(""), return_ext); + } + } - if (is_memory) - { - unsigned r3_id = reg_ctx_sp->GetRegisterInfoByName("r3", 0)->kinds[eRegisterKindLLDB]; - lldb::addr_t storage_addr = (uint64_t)thread.GetRegisterContext()->ReadRegisterAsUnsigned(r3_id, 0); - return_valobj_sp = ValueObjectMemory::Create(&thread, - "", - Address(storage_addr, nullptr), - return_compiler_type); - } + // FIXME: This is just taking a guess, r3 may very well no longer hold the + // return storage location. + // If we are going to do this right, when we make a new frame we should + // check to see if it uses a memory + // return, and if we are at the first instruction and if so stash away the + // return location. Then we would + // only return the memory return value if we know it is valid. + + if (is_memory) { + unsigned r3_id = + reg_ctx_sp->GetRegisterInfoByName("r3", 0)->kinds[eRegisterKindLLDB]; + lldb::addr_t storage_addr = + (uint64_t)thread.GetRegisterContext()->ReadRegisterAsUnsigned(r3_id, + 0); + return_valobj_sp = ValueObjectMemory::Create( + &thread, "", Address(storage_addr, nullptr), return_compiler_type); } + } - return return_valobj_sp; + return return_valobj_sp; } -bool -ABISysV_ppc64::CreateFunctionEntryUnwindPlan (UnwindPlan &unwind_plan) -{ - unwind_plan.Clear(); - unwind_plan.SetRegisterKind (eRegisterKindDWARF); +bool ABISysV_ppc64::CreateFunctionEntryUnwindPlan(UnwindPlan &unwind_plan) { + unwind_plan.Clear(); + unwind_plan.SetRegisterKind(eRegisterKindDWARF); - uint32_t lr_reg_num = dwarf_lr; - uint32_t sp_reg_num = dwarf_r1; - uint32_t pc_reg_num = dwarf_pc; + uint32_t lr_reg_num = dwarf_lr; + uint32_t sp_reg_num = dwarf_r1; + uint32_t pc_reg_num = dwarf_pc; - UnwindPlan::RowSP row(new UnwindPlan::Row); + UnwindPlan::RowSP row(new UnwindPlan::Row); - // Our Call Frame Address is the stack pointer value - row->GetCFAValue().SetIsRegisterPlusOffset(sp_reg_num, 0); + // Our Call Frame Address is the stack pointer value + row->GetCFAValue().SetIsRegisterPlusOffset(sp_reg_num, 0); - // The previous PC is in the LR - row->SetRegisterLocationToRegister(pc_reg_num, lr_reg_num, true); - unwind_plan.AppendRow (row); + // The previous PC is in the LR + row->SetRegisterLocationToRegister(pc_reg_num, lr_reg_num, true); + unwind_plan.AppendRow(row); - // All other registers are the same. + // All other registers are the same. - unwind_plan.SetSourceName ("ppc64 at-func-entry default"); - unwind_plan.SetSourcedFromCompiler (eLazyBoolNo); + unwind_plan.SetSourceName("ppc64 at-func-entry default"); + unwind_plan.SetSourcedFromCompiler(eLazyBoolNo); - return true; + return true; } -bool -ABISysV_ppc64::CreateDefaultUnwindPlan (UnwindPlan &unwind_plan) -{ - unwind_plan.Clear(); - unwind_plan.SetRegisterKind (eRegisterKindDWARF); +bool ABISysV_ppc64::CreateDefaultUnwindPlan(UnwindPlan &unwind_plan) { + unwind_plan.Clear(); + unwind_plan.SetRegisterKind(eRegisterKindDWARF); - uint32_t sp_reg_num = dwarf_r1; - uint32_t pc_reg_num = dwarf_lr; + uint32_t sp_reg_num = dwarf_r1; + uint32_t pc_reg_num = dwarf_lr; - UnwindPlan::RowSP row(new UnwindPlan::Row); + UnwindPlan::RowSP row(new UnwindPlan::Row); - const int32_t ptr_size = 8; - row->GetCFAValue().SetIsRegisterDereferenced(sp_reg_num); + const int32_t ptr_size = 8; + row->GetCFAValue().SetIsRegisterDereferenced(sp_reg_num); - row->SetRegisterLocationToAtCFAPlusOffset(pc_reg_num, ptr_size * 2, true); - row->SetRegisterLocationToIsCFAPlusOffset(sp_reg_num, 0, true); - row->SetRegisterLocationToAtCFAPlusOffset(dwarf_cr, ptr_size, true); + row->SetRegisterLocationToAtCFAPlusOffset(pc_reg_num, ptr_size * 2, true); + row->SetRegisterLocationToIsCFAPlusOffset(sp_reg_num, 0, true); + row->SetRegisterLocationToAtCFAPlusOffset(dwarf_cr, ptr_size, true); - unwind_plan.AppendRow (row); - unwind_plan.SetSourceName ("ppc64 default unwind plan"); - unwind_plan.SetSourcedFromCompiler (eLazyBoolNo); - unwind_plan.SetUnwindPlanValidAtAllInstructions (eLazyBoolNo); - unwind_plan.SetReturnAddressRegister(dwarf_lr); - return true; + unwind_plan.AppendRow(row); + unwind_plan.SetSourceName("ppc64 default unwind plan"); + unwind_plan.SetSourcedFromCompiler(eLazyBoolNo); + unwind_plan.SetUnwindPlanValidAtAllInstructions(eLazyBoolNo); + unwind_plan.SetReturnAddressRegister(dwarf_lr); + return true; } -bool -ABISysV_ppc64::RegisterIsVolatile (const RegisterInfo *reg_info) -{ - return !RegisterIsCalleeSaved (reg_info); +bool ABISysV_ppc64::RegisterIsVolatile(const RegisterInfo *reg_info) { + return !RegisterIsCalleeSaved(reg_info); } // See "Register Usage" in the // "System V Application Binary Interface" // "64-bit PowerPC ELF Application Binary Interface Supplement" -// current version is 1.9 released 2004 at http://refspecs.linuxfoundation.org/ELF/ppc64/PPC-elf64abi-1.9.pdf - -bool -ABISysV_ppc64::RegisterIsCalleeSaved (const RegisterInfo *reg_info) -{ - if (reg_info) - { - // Preserved registers are : - // r1,r2,r13-r31 - // cr2-cr4 (partially preserved) - // f14-f31 (not yet) - // v20-v31 (not yet) - // vrsave (not yet) - - const char *name = reg_info->name; - if (name[0] == 'r') - { - if ((name[1] == '1' || name[1] == '2') && name[2] == '\0') - return true; - if (name[1] == '1' && name[2] > '2') - return true; - if ((name[1] == '2' || name[1] == '3') && name[2] != '\0') - return true; - } - - if (name[0] == 'f' && name[1] >= '0' && name[2] <= '9') - { - if (name[2] == '\0') - return false; - if (name[1] == '1' && name[2] >= '4') - return true; - if ((name[1] == '2' || name[1] == '3') && name[2] != '\0') - return true; - } +// current version is 1.9 released 2004 at +// http://refspecs.linuxfoundation.org/ELF/ppc64/PPC-elf64abi-1.9.pdf + +bool ABISysV_ppc64::RegisterIsCalleeSaved(const RegisterInfo *reg_info) { + if (reg_info) { + // Preserved registers are : + // r1,r2,r13-r31 + // cr2-cr4 (partially preserved) + // f14-f31 (not yet) + // v20-v31 (not yet) + // vrsave (not yet) + + const char *name = reg_info->name; + if (name[0] == 'r') { + if ((name[1] == '1' || name[1] == '2') && name[2] == '\0') + return true; + if (name[1] == '1' && name[2] > '2') + return true; + if ((name[1] == '2' || name[1] == '3') && name[2] != '\0') + return true; + } - if (name[0] == 's' && name[1] == 'p' && name[2] == '\0') // sp - return true; - if (name[0] == 'f' && name[1] == 'p' && name[2] == '\0') // fp - return true; - if (name[0] == 'p' && name[1] == 'c' && name[2] == '\0') // pc - return true; + if (name[0] == 'f' && name[1] >= '0' && name[2] <= '9') { + if (name[2] == '\0') + return false; + if (name[1] == '1' && name[2] >= '4') + return true; + if ((name[1] == '2' || name[1] == '3') && name[2] != '\0') + return true; } - return false; + + if (name[0] == 's' && name[1] == 'p' && name[2] == '\0') // sp + return true; + if (name[0] == 'f' && name[1] == 'p' && name[2] == '\0') // fp + return true; + if (name[0] == 'p' && name[1] == 'c' && name[2] == '\0') // pc + return true; + } + return false; } -void -ABISysV_ppc64::Initialize() -{ - PluginManager::RegisterPlugin (GetPluginNameStatic(), - "System V ABI for ppc64 targets", - CreateInstance); +void ABISysV_ppc64::Initialize() { + PluginManager::RegisterPlugin( + GetPluginNameStatic(), "System V ABI for ppc64 targets", CreateInstance); } -void -ABISysV_ppc64::Terminate() -{ - PluginManager::UnregisterPlugin (CreateInstance); +void ABISysV_ppc64::Terminate() { + PluginManager::UnregisterPlugin(CreateInstance); } -lldb_private::ConstString -ABISysV_ppc64::GetPluginNameStatic() -{ - static ConstString g_name("sysv-ppc64"); - return g_name; +lldb_private::ConstString ABISysV_ppc64::GetPluginNameStatic() { + static ConstString g_name("sysv-ppc64"); + return g_name; } //------------------------------------------------------------------ // PluginInterface protocol //------------------------------------------------------------------ -lldb_private::ConstString -ABISysV_ppc64::GetPluginName() -{ - return GetPluginNameStatic(); +lldb_private::ConstString ABISysV_ppc64::GetPluginName() { + return GetPluginNameStatic(); } -uint32_t -ABISysV_ppc64::GetPluginVersion() -{ - return 1; -} +uint32_t ABISysV_ppc64::GetPluginVersion() { return 1; } diff --git a/source/Plugins/ABI/SysV-ppc64/ABISysV_ppc64.h b/source/Plugins/ABI/SysV-ppc64/ABISysV_ppc64.h index b87f7938d544..7f321dff49c1 100644 --- a/source/Plugins/ABI/SysV-ppc64/ABISysV_ppc64.h +++ b/source/Plugins/ABI/SysV-ppc64/ABISysV_ppc64.h @@ -14,120 +14,100 @@ // C++ Includes // Other libraries and framework includes // Project includes -#include "lldb/lldb-private.h" #include "lldb/Target/ABI.h" +#include "lldb/lldb-private.h" -class ABISysV_ppc64 : - public lldb_private::ABI -{ +class ABISysV_ppc64 : public lldb_private::ABI { public: - ~ABISysV_ppc64() override = default; - - size_t - GetRedZoneSize() const override; - - bool - PrepareTrivialCall(lldb_private::Thread &thread, - lldb::addr_t sp, - lldb::addr_t functionAddress, - lldb::addr_t returnAddress, - llvm::ArrayRef<lldb::addr_t> args) const override; - - bool - GetArgumentValues(lldb_private::Thread &thread, - lldb_private::ValueList &values) const override; - - lldb_private::Error - SetReturnValueObject(lldb::StackFrameSP &frame_sp, lldb::ValueObjectSP &new_value) override; - - lldb::ValueObjectSP - GetReturnValueObjectImpl(lldb_private::Thread &thread, - lldb_private::CompilerType &type) const override; - - bool - CreateFunctionEntryUnwindPlan(lldb_private::UnwindPlan &unwind_plan) override; - - bool - CreateDefaultUnwindPlan(lldb_private::UnwindPlan &unwind_plan) override; - - bool - RegisterIsVolatile(const lldb_private::RegisterInfo *reg_info) override; - - // The SysV ppc64 ABI requires that stack frames be 16 byte aligned. - // When there is a trap handler on the stack, e.g. _sigtramp in userland - // code, we've seen that the stack pointer is often not aligned properly - // before the handler is invoked. This means that lldb will stop the unwind - // early -- before the function which caused the trap. - // - // To work around this, we relax that alignment to be just word-size (8-bytes). - // Whitelisting the trap handlers for user space would be easy (_sigtramp) but - // in other environments there can be a large number of different functions - // involved in async traps. - bool - CallFrameAddressIsValid(lldb::addr_t cfa) override - { - // Make sure the stack call frame addresses are 8 byte aligned - if (cfa & (8ull - 1ull)) - return false; // Not 8 byte aligned - if (cfa == 0) - return false; // Zero is not a valid stack address - return true; - } - - bool - CodeAddressIsValid(lldb::addr_t pc) override - { - // We have a 64 bit address space, so anything is valid as opcodes - // aren't fixed width... - return true; - } - - const lldb_private::RegisterInfo * - GetRegisterInfoArray(uint32_t &count) override; - - //------------------------------------------------------------------ - // Static Functions - //------------------------------------------------------------------ - - static void - Initialize(); - - static void - Terminate(); - - static lldb::ABISP - CreateInstance (const lldb_private::ArchSpec &arch); - - static lldb_private::ConstString - GetPluginNameStatic(); - - //------------------------------------------------------------------ - // PluginInterface protocol - //------------------------------------------------------------------ - - lldb_private::ConstString - GetPluginName() override; - - uint32_t - GetPluginVersion() override; + ~ABISysV_ppc64() override = default; + + size_t GetRedZoneSize() const override; + + bool PrepareTrivialCall(lldb_private::Thread &thread, lldb::addr_t sp, + lldb::addr_t functionAddress, + lldb::addr_t returnAddress, + llvm::ArrayRef<lldb::addr_t> args) const override; + + bool GetArgumentValues(lldb_private::Thread &thread, + lldb_private::ValueList &values) const override; + + lldb_private::Error + SetReturnValueObject(lldb::StackFrameSP &frame_sp, + lldb::ValueObjectSP &new_value) override; + + lldb::ValueObjectSP + GetReturnValueObjectImpl(lldb_private::Thread &thread, + lldb_private::CompilerType &type) const override; + + bool + CreateFunctionEntryUnwindPlan(lldb_private::UnwindPlan &unwind_plan) override; + + bool CreateDefaultUnwindPlan(lldb_private::UnwindPlan &unwind_plan) override; + + bool RegisterIsVolatile(const lldb_private::RegisterInfo *reg_info) override; + + // The SysV ppc64 ABI requires that stack frames be 16 byte aligned. + // When there is a trap handler on the stack, e.g. _sigtramp in userland + // code, we've seen that the stack pointer is often not aligned properly + // before the handler is invoked. This means that lldb will stop the unwind + // early -- before the function which caused the trap. + // + // To work around this, we relax that alignment to be just word-size + // (8-bytes). + // Whitelisting the trap handlers for user space would be easy (_sigtramp) but + // in other environments there can be a large number of different functions + // involved in async traps. + bool CallFrameAddressIsValid(lldb::addr_t cfa) override { + // Make sure the stack call frame addresses are 8 byte aligned + if (cfa & (8ull - 1ull)) + return false; // Not 8 byte aligned + if (cfa == 0) + return false; // Zero is not a valid stack address + return true; + } + + bool CodeAddressIsValid(lldb::addr_t pc) override { + // We have a 64 bit address space, so anything is valid as opcodes + // aren't fixed width... + return true; + } + + const lldb_private::RegisterInfo * + GetRegisterInfoArray(uint32_t &count) override; + + //------------------------------------------------------------------ + // Static Functions + //------------------------------------------------------------------ + + static void Initialize(); + + static void Terminate(); + + static lldb::ABISP CreateInstance(const lldb_private::ArchSpec &arch); + + static lldb_private::ConstString GetPluginNameStatic(); + + //------------------------------------------------------------------ + // PluginInterface protocol + //------------------------------------------------------------------ + + lldb_private::ConstString GetPluginName() override; + + uint32_t GetPluginVersion() override; protected: - void - CreateRegisterMapIfNeeded (); + void CreateRegisterMapIfNeeded(); + + lldb::ValueObjectSP + GetReturnValueObjectSimple(lldb_private::Thread &thread, + lldb_private::CompilerType &ast_type) const; - lldb::ValueObjectSP - GetReturnValueObjectSimple(lldb_private::Thread &thread, - lldb_private::CompilerType &ast_type) const; - - bool - RegisterIsCalleeSaved (const lldb_private::RegisterInfo *reg_info); + bool RegisterIsCalleeSaved(const lldb_private::RegisterInfo *reg_info); private: - ABISysV_ppc64() : - lldb_private::ABI() - { - // Call CreateInstance instead. - } + ABISysV_ppc64() : lldb_private::ABI() { + // Call CreateInstance instead. + } }; #endif // liblldb_ABISysV_ppc64_h_ diff --git a/source/Plugins/ABI/SysV-s390x/ABISysV_s390x.cpp b/source/Plugins/ABI/SysV-s390x/ABISysV_s390x.cpp index 055905523f81..7e6506bb1f44 100644 --- a/source/Plugins/ABI/SysV-s390x/ABISysV_s390x.cpp +++ b/source/Plugins/ABI/SysV-s390x/ABISysV_s390x.cpp @@ -37,92 +37,91 @@ using namespace lldb; using namespace lldb_private; -enum dwarf_regnums -{ - // General Purpose Registers - dwarf_r0_s390x = 0, - dwarf_r1_s390x, - dwarf_r2_s390x, - dwarf_r3_s390x, - dwarf_r4_s390x, - dwarf_r5_s390x, - dwarf_r6_s390x, - dwarf_r7_s390x, - dwarf_r8_s390x, - dwarf_r9_s390x, - dwarf_r10_s390x, - dwarf_r11_s390x, - dwarf_r12_s390x, - dwarf_r13_s390x, - dwarf_r14_s390x, - dwarf_r15_s390x, - // Floating Point Registers / Vector Registers 0-15 - dwarf_f0_s390x = 16, - dwarf_f2_s390x, - dwarf_f4_s390x, - dwarf_f6_s390x, - dwarf_f1_s390x, - dwarf_f3_s390x, - dwarf_f5_s390x, - dwarf_f7_s390x, - dwarf_f8_s390x, - dwarf_f10_s390x, - dwarf_f12_s390x, - dwarf_f14_s390x, - dwarf_f9_s390x, - dwarf_f11_s390x, - dwarf_f13_s390x, - dwarf_f15_s390x, - // Access Registers - dwarf_acr0_s390x = 48, - dwarf_acr1_s390x, - dwarf_acr2_s390x, - dwarf_acr3_s390x, - dwarf_acr4_s390x, - dwarf_acr5_s390x, - dwarf_acr6_s390x, - dwarf_acr7_s390x, - dwarf_acr8_s390x, - dwarf_acr9_s390x, - dwarf_acr10_s390x, - dwarf_acr11_s390x, - dwarf_acr12_s390x, - dwarf_acr13_s390x, - dwarf_acr14_s390x, - dwarf_acr15_s390x, - // Program Status Word - dwarf_pswm_s390x = 64, - dwarf_pswa_s390x, - // Vector Registers 16-31 - dwarf_v16_s390x = 68, - dwarf_v18_s390x, - dwarf_v20_s390x, - dwarf_v22_s390x, - dwarf_v17_s390x, - dwarf_v19_s390x, - dwarf_v21_s390x, - dwarf_v23_s390x, - dwarf_v24_s390x, - dwarf_v26_s390x, - dwarf_v28_s390x, - dwarf_v30_s390x, - dwarf_v25_s390x, - dwarf_v27_s390x, - dwarf_v29_s390x, - dwarf_v31_s390x, +enum dwarf_regnums { + // General Purpose Registers + dwarf_r0_s390x = 0, + dwarf_r1_s390x, + dwarf_r2_s390x, + dwarf_r3_s390x, + dwarf_r4_s390x, + dwarf_r5_s390x, + dwarf_r6_s390x, + dwarf_r7_s390x, + dwarf_r8_s390x, + dwarf_r9_s390x, + dwarf_r10_s390x, + dwarf_r11_s390x, + dwarf_r12_s390x, + dwarf_r13_s390x, + dwarf_r14_s390x, + dwarf_r15_s390x, + // Floating Point Registers / Vector Registers 0-15 + dwarf_f0_s390x = 16, + dwarf_f2_s390x, + dwarf_f4_s390x, + dwarf_f6_s390x, + dwarf_f1_s390x, + dwarf_f3_s390x, + dwarf_f5_s390x, + dwarf_f7_s390x, + dwarf_f8_s390x, + dwarf_f10_s390x, + dwarf_f12_s390x, + dwarf_f14_s390x, + dwarf_f9_s390x, + dwarf_f11_s390x, + dwarf_f13_s390x, + dwarf_f15_s390x, + // Access Registers + dwarf_acr0_s390x = 48, + dwarf_acr1_s390x, + dwarf_acr2_s390x, + dwarf_acr3_s390x, + dwarf_acr4_s390x, + dwarf_acr5_s390x, + dwarf_acr6_s390x, + dwarf_acr7_s390x, + dwarf_acr8_s390x, + dwarf_acr9_s390x, + dwarf_acr10_s390x, + dwarf_acr11_s390x, + dwarf_acr12_s390x, + dwarf_acr13_s390x, + dwarf_acr14_s390x, + dwarf_acr15_s390x, + // Program Status Word + dwarf_pswm_s390x = 64, + dwarf_pswa_s390x, + // Vector Registers 16-31 + dwarf_v16_s390x = 68, + dwarf_v18_s390x, + dwarf_v20_s390x, + dwarf_v22_s390x, + dwarf_v17_s390x, + dwarf_v19_s390x, + dwarf_v21_s390x, + dwarf_v23_s390x, + dwarf_v24_s390x, + dwarf_v26_s390x, + dwarf_v28_s390x, + dwarf_v30_s390x, + dwarf_v25_s390x, + dwarf_v27_s390x, + dwarf_v29_s390x, + dwarf_v31_s390x, }; // RegisterKind: EHFrame, DWARF, Generic, Process Plugin, LLDB -#define DEFINE_REG(name, size, alt, generic) \ - { \ - #name, alt, size, 0, eEncodingUint, eFormatHex, \ - { dwarf_##name##_s390x, dwarf_##name##_s390x, generic, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, \ - NULL, NULL, \ - } +#define DEFINE_REG(name, size, alt, generic) \ + { \ + #name, alt, size, 0, eEncodingUint, eFormatHex, \ + {dwarf_##name##_s390x, dwarf_##name##_s390x, generic, \ + LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, \ + nullptr, nullptr, nullptr, 0 \ + } -static RegisterInfo g_register_infos[] = -{ +static RegisterInfo g_register_infos[] = { DEFINE_REG(r0, 8, nullptr, LLDB_INVALID_REGNUM), DEFINE_REG(r1, 8, nullptr, LLDB_INVALID_REGNUM), DEFINE_REG(r2, 8, "arg1", LLDB_REGNUM_GENERIC_ARG1), @@ -175,633 +174,580 @@ static RegisterInfo g_register_infos[] = DEFINE_REG(f15, 8, nullptr, LLDB_INVALID_REGNUM), }; -static const uint32_t k_num_register_infos = llvm::array_lengthof(g_register_infos); +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_s390x::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(); - } +ABISysV_s390x::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; + } + count = k_num_register_infos; + return g_register_infos; } -size_t -ABISysV_s390x::GetRedZoneSize() const -{ - return 0; -} +size_t ABISysV_s390x::GetRedZoneSize() const { return 0; } //------------------------------------------------------------------ // Static Functions //------------------------------------------------------------------ ABISP -ABISysV_s390x::CreateInstance(const ArchSpec &arch) -{ - static ABISP g_abi_sp; - if (arch.GetTriple().getArch() == llvm::Triple::systemz) - { - if (!g_abi_sp) - g_abi_sp.reset(new ABISysV_s390x); - return g_abi_sp; - } - return ABISP(); +ABISysV_s390x::CreateInstance(const ArchSpec &arch) { + static ABISP g_abi_sp; + if (arch.GetTriple().getArch() == llvm::Triple::systemz) { + if (!g_abi_sp) + g_abi_sp.reset(new ABISysV_s390x); + return g_abi_sp; + } + return ABISP(); } -bool -ABISysV_s390x::PrepareTrivialCall(Thread &thread, addr_t sp, addr_t func_addr, addr_t return_addr, - llvm::ArrayRef<addr_t> args) const -{ - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS)); - - if (log) - { - StreamString s; - s.Printf("ABISysV_s390x::PrepareTrivialCall (tid = 0x%" PRIx64 ", sp = 0x%" PRIx64 - ", func_addr = 0x%" PRIx64 ", return_addr = 0x%" PRIx64, - thread.GetID(), (uint64_t)sp, (uint64_t)func_addr, (uint64_t)return_addr); - - for (size_t i = 0; i < args.size(); ++i) - s.Printf(", arg%" PRIu64 " = 0x%" PRIx64, static_cast<uint64_t>(i + 1), args[i]); - s.PutCString(")"); - log->PutCString(s.GetString().c_str()); - } - - RegisterContext *reg_ctx = thread.GetRegisterContext().get(); - if (!reg_ctx) - return false; - - const RegisterInfo *pc_reg_info = reg_ctx->GetRegisterInfo(eRegisterKindGeneric, LLDB_REGNUM_GENERIC_PC); - const RegisterInfo *sp_reg_info = reg_ctx->GetRegisterInfo(eRegisterKindGeneric, LLDB_REGNUM_GENERIC_SP); - const RegisterInfo *ra_reg_info = reg_ctx->GetRegisterInfoByName("r14", 0); - ProcessSP process_sp(thread.GetProcess()); - - // Allocate a new stack frame and space for stack arguments if necessary - - addr_t arg_pos = 0; - if (args.size() > 5) - { - sp -= 8 * (args.size() - 5); - arg_pos = sp; - } +bool ABISysV_s390x::PrepareTrivialCall(Thread &thread, addr_t sp, + addr_t func_addr, addr_t return_addr, + llvm::ArrayRef<addr_t> args) const { + Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS)); - sp -= 160; - - // Process arguments + if (log) { + StreamString s; + s.Printf("ABISysV_s390x::PrepareTrivialCall (tid = 0x%" PRIx64 + ", sp = 0x%" PRIx64 ", func_addr = 0x%" PRIx64 + ", return_addr = 0x%" PRIx64, + thread.GetID(), (uint64_t)sp, (uint64_t)func_addr, + (uint64_t)return_addr); for (size_t i = 0; i < args.size(); ++i) - { - if (i < 5) - { - const RegisterInfo *reg_info = reg_ctx->GetRegisterInfo(eRegisterKindGeneric, LLDB_REGNUM_GENERIC_ARG1 + i); - if (log) - log->Printf("About to write arg%" PRIu64 " (0x%" PRIx64 ") into %s", static_cast<uint64_t>(i + 1), - args[i], reg_info->name); - if (!reg_ctx->WriteRegisterFromUnsigned(reg_info, args[i])) - return false; - } - else - { - Error error; - if (log) - log->Printf("About to write arg%" PRIu64 " (0x%" PRIx64 ") onto stack", static_cast<uint64_t>(i + 1), - args[i]); - if (!process_sp->WritePointerToMemory(arg_pos, args[i], error)) - return false; - arg_pos += 8; - } + s.Printf(", arg%" PRIu64 " = 0x%" PRIx64, static_cast<uint64_t>(i + 1), + args[i]); + s.PutCString(")"); + log->PutString(s.GetString()); + } + + RegisterContext *reg_ctx = thread.GetRegisterContext().get(); + if (!reg_ctx) + return false; + + const RegisterInfo *pc_reg_info = + reg_ctx->GetRegisterInfo(eRegisterKindGeneric, LLDB_REGNUM_GENERIC_PC); + const RegisterInfo *sp_reg_info = + reg_ctx->GetRegisterInfo(eRegisterKindGeneric, LLDB_REGNUM_GENERIC_SP); + const RegisterInfo *ra_reg_info = reg_ctx->GetRegisterInfoByName("r14", 0); + ProcessSP process_sp(thread.GetProcess()); + + // Allocate a new stack frame and space for stack arguments if necessary + + addr_t arg_pos = 0; + if (args.size() > 5) { + sp -= 8 * (args.size() - 5); + arg_pos = sp; + } + + sp -= 160; + + // Process arguments + + for (size_t i = 0; i < args.size(); ++i) { + if (i < 5) { + const RegisterInfo *reg_info = reg_ctx->GetRegisterInfo( + eRegisterKindGeneric, LLDB_REGNUM_GENERIC_ARG1 + i); + if (log) + log->Printf("About to write arg%" PRIu64 " (0x%" PRIx64 ") into %s", + static_cast<uint64_t>(i + 1), args[i], reg_info->name); + if (!reg_ctx->WriteRegisterFromUnsigned(reg_info, args[i])) + return false; + } else { + Error error; + if (log) + log->Printf("About to write arg%" PRIu64 " (0x%" PRIx64 ") onto stack", + static_cast<uint64_t>(i + 1), args[i]); + if (!process_sp->WritePointerToMemory(arg_pos, args[i], error)) + return false; + arg_pos += 8; } + } - // %r14 is set to the return address + // %r14 is set to the return address - if (log) - log->Printf("Writing RA: 0x%" PRIx64, (uint64_t)return_addr); + if (log) + log->Printf("Writing RA: 0x%" PRIx64, (uint64_t)return_addr); - if (!reg_ctx->WriteRegisterFromUnsigned(ra_reg_info, return_addr)) - return false; + if (!reg_ctx->WriteRegisterFromUnsigned(ra_reg_info, return_addr)) + return false; - // %r15 is set to the actual stack value. + // %r15 is set to the actual stack value. - if (log) - log->Printf("Writing SP: 0x%" PRIx64, (uint64_t)sp); + if (log) + log->Printf("Writing SP: 0x%" PRIx64, (uint64_t)sp); - if (!reg_ctx->WriteRegisterFromUnsigned(sp_reg_info, sp)) - return false; + if (!reg_ctx->WriteRegisterFromUnsigned(sp_reg_info, sp)) + return false; - // %pc is set to the address of the called function. + // %pc is set to the address of the called function. - if (log) - log->Printf("Writing PC: 0x%" PRIx64, (uint64_t)func_addr); + if (log) + log->Printf("Writing PC: 0x%" PRIx64, (uint64_t)func_addr); - if (!reg_ctx->WriteRegisterFromUnsigned(pc_reg_info, func_addr)) - return false; + if (!reg_ctx->WriteRegisterFromUnsigned(pc_reg_info, func_addr)) + return false; - return true; + return true; } -static bool -ReadIntegerArgument(Scalar &scalar, unsigned int bit_width, bool is_signed, Thread &thread, - uint32_t *argument_register_ids, unsigned int ¤t_argument_register, - addr_t ¤t_stack_argument) -{ - if (bit_width > 64) - return false; // Scalar can't hold large integer arguments - - if (current_argument_register < 5) - { - scalar = - thread.GetRegisterContext()->ReadRegisterAsUnsigned(argument_register_ids[current_argument_register], 0); - current_argument_register++; - if (is_signed) - scalar.SignExtend(bit_width); - } - else - { - uint32_t byte_size = (bit_width + (8 - 1)) / 8; - Error error; - if (thread.GetProcess()->ReadScalarIntegerFromMemory(current_stack_argument + 8 - byte_size, byte_size, - is_signed, scalar, error)) - { - current_stack_argument += 8; - return true; - } - return false; +static bool ReadIntegerArgument(Scalar &scalar, unsigned int bit_width, + bool is_signed, Thread &thread, + uint32_t *argument_register_ids, + unsigned int ¤t_argument_register, + addr_t ¤t_stack_argument) { + if (bit_width > 64) + return false; // Scalar can't hold large integer arguments + + if (current_argument_register < 5) { + scalar = thread.GetRegisterContext()->ReadRegisterAsUnsigned( + argument_register_ids[current_argument_register], 0); + current_argument_register++; + if (is_signed) + scalar.SignExtend(bit_width); + } else { + uint32_t byte_size = (bit_width + (8 - 1)) / 8; + Error error; + if (thread.GetProcess()->ReadScalarIntegerFromMemory( + current_stack_argument + 8 - byte_size, byte_size, is_signed, + scalar, error)) { + current_stack_argument += 8; + return true; } - return true; + return false; + } + return true; } -bool -ABISysV_s390x::GetArgumentValues(Thread &thread, ValueList &values) const -{ - unsigned int num_values = values.GetSize(); - unsigned int value_index; +bool ABISysV_s390x::GetArgumentValues(Thread &thread, ValueList &values) const { + unsigned int num_values = values.GetSize(); + unsigned int value_index; - // Extract the register context so we can read arguments from registers + // Extract the register context so we can read arguments from registers - RegisterContext *reg_ctx = thread.GetRegisterContext().get(); + RegisterContext *reg_ctx = thread.GetRegisterContext().get(); - if (!reg_ctx) - return false; + if (!reg_ctx) + return false; - // Get the pointer to the first stack argument so we have a place to start - // when reading data + // Get the pointer to the first stack argument so we have a place to start + // when reading data - addr_t sp = reg_ctx->GetSP(0); + addr_t sp = reg_ctx->GetSP(0); - if (!sp) - return false; + if (!sp) + return false; - addr_t current_stack_argument = sp + 160; - - uint32_t argument_register_ids[5]; - - argument_register_ids[0] = - reg_ctx->GetRegisterInfo(eRegisterKindGeneric, LLDB_REGNUM_GENERIC_ARG1)->kinds[eRegisterKindLLDB]; - argument_register_ids[1] = - reg_ctx->GetRegisterInfo(eRegisterKindGeneric, LLDB_REGNUM_GENERIC_ARG2)->kinds[eRegisterKindLLDB]; - argument_register_ids[2] = - reg_ctx->GetRegisterInfo(eRegisterKindGeneric, LLDB_REGNUM_GENERIC_ARG3)->kinds[eRegisterKindLLDB]; - argument_register_ids[3] = - reg_ctx->GetRegisterInfo(eRegisterKindGeneric, LLDB_REGNUM_GENERIC_ARG4)->kinds[eRegisterKindLLDB]; - argument_register_ids[4] = - reg_ctx->GetRegisterInfo(eRegisterKindGeneric, LLDB_REGNUM_GENERIC_ARG5)->kinds[eRegisterKindLLDB]; - - unsigned int current_argument_register = 0; - - for (value_index = 0; value_index < num_values; ++value_index) - { - Value *value = values.GetValueAtIndex(value_index); - - if (!value) - return false; - - // We currently only support extracting values with Clang QualTypes. - // Do we care about others? - CompilerType compiler_type = value->GetCompilerType(); - if (!compiler_type) - return false; - bool is_signed; - - if (compiler_type.IsIntegerOrEnumerationType(is_signed)) - { - ReadIntegerArgument(value->GetScalar(), compiler_type.GetBitSize(&thread), is_signed, thread, - argument_register_ids, current_argument_register, current_stack_argument); - } - else if (compiler_type.IsPointerType()) - { - ReadIntegerArgument(value->GetScalar(), compiler_type.GetBitSize(&thread), false, thread, - argument_register_ids, current_argument_register, current_stack_argument); - } + addr_t current_stack_argument = sp + 160; + + uint32_t argument_register_ids[5]; + + argument_register_ids[0] = + reg_ctx->GetRegisterInfo(eRegisterKindGeneric, LLDB_REGNUM_GENERIC_ARG1) + ->kinds[eRegisterKindLLDB]; + argument_register_ids[1] = + reg_ctx->GetRegisterInfo(eRegisterKindGeneric, LLDB_REGNUM_GENERIC_ARG2) + ->kinds[eRegisterKindLLDB]; + argument_register_ids[2] = + reg_ctx->GetRegisterInfo(eRegisterKindGeneric, LLDB_REGNUM_GENERIC_ARG3) + ->kinds[eRegisterKindLLDB]; + argument_register_ids[3] = + reg_ctx->GetRegisterInfo(eRegisterKindGeneric, LLDB_REGNUM_GENERIC_ARG4) + ->kinds[eRegisterKindLLDB]; + argument_register_ids[4] = + reg_ctx->GetRegisterInfo(eRegisterKindGeneric, LLDB_REGNUM_GENERIC_ARG5) + ->kinds[eRegisterKindLLDB]; + + unsigned int current_argument_register = 0; + + for (value_index = 0; value_index < num_values; ++value_index) { + Value *value = values.GetValueAtIndex(value_index); + + if (!value) + return false; + + // We currently only support extracting values with Clang QualTypes. + // Do we care about others? + CompilerType compiler_type = value->GetCompilerType(); + if (!compiler_type) + return false; + bool is_signed; + + if (compiler_type.IsIntegerOrEnumerationType(is_signed)) { + ReadIntegerArgument(value->GetScalar(), compiler_type.GetBitSize(&thread), + is_signed, thread, argument_register_ids, + current_argument_register, current_stack_argument); + } else if (compiler_type.IsPointerType()) { + ReadIntegerArgument(value->GetScalar(), compiler_type.GetBitSize(&thread), + false, thread, argument_register_ids, + current_argument_register, current_stack_argument); } + } - return true; + return true; } -Error -ABISysV_s390x::SetReturnValueObject(lldb::StackFrameSP &frame_sp, lldb::ValueObjectSP &new_value_sp) -{ - Error error; - if (!new_value_sp) - { - error.SetErrorString("Empty value object for return value."); - return error; - } +Error ABISysV_s390x::SetReturnValueObject(lldb::StackFrameSP &frame_sp, + lldb::ValueObjectSP &new_value_sp) { + Error error; + if (!new_value_sp) { + error.SetErrorString("Empty value object for return value."); + return error; + } - CompilerType compiler_type = new_value_sp->GetCompilerType(); - if (!compiler_type) - { - error.SetErrorString("Null clang type for return value."); - return error; - } + CompilerType compiler_type = new_value_sp->GetCompilerType(); + if (!compiler_type) { + error.SetErrorString("Null clang type for return value."); + return error; + } - Thread *thread = frame_sp->GetThread().get(); + Thread *thread = frame_sp->GetThread().get(); - bool is_signed; - uint32_t count; - bool is_complex; + bool is_signed; + uint32_t count; + bool is_complex; - RegisterContext *reg_ctx = thread->GetRegisterContext().get(); + RegisterContext *reg_ctx = thread->GetRegisterContext().get(); - bool set_it_simple = false; - if (compiler_type.IsIntegerOrEnumerationType(is_signed) || compiler_type.IsPointerType()) - { - const RegisterInfo *reg_info = reg_ctx->GetRegisterInfoByName("r2", 0); + bool set_it_simple = false; + if (compiler_type.IsIntegerOrEnumerationType(is_signed) || + compiler_type.IsPointerType()) { + const RegisterInfo *reg_info = reg_ctx->GetRegisterInfoByName("r2", 0); + DataExtractor data; + Error data_error; + size_t num_bytes = new_value_sp->GetData(data, data_error); + if (data_error.Fail()) { + error.SetErrorStringWithFormat( + "Couldn't convert return value to raw data: %s", + data_error.AsCString()); + return error; + } + lldb::offset_t offset = 0; + if (num_bytes <= 8) { + uint64_t raw_value = data.GetMaxU64(&offset, num_bytes); + + if (reg_ctx->WriteRegisterFromUnsigned(reg_info, raw_value)) + set_it_simple = true; + } else { + error.SetErrorString("We don't support returning longer than 64 bit " + "integer values at present."); + } + } else if (compiler_type.IsFloatingPointType(count, is_complex)) { + if (is_complex) + error.SetErrorString( + "We don't support returning complex values at present"); + else { + size_t bit_width = compiler_type.GetBitSize(frame_sp.get()); + if (bit_width <= 64) { + const RegisterInfo *f0_info = reg_ctx->GetRegisterInfoByName("f0", 0); + RegisterValue f0_value; DataExtractor data; Error data_error; size_t num_bytes = new_value_sp->GetData(data, data_error); - if (data_error.Fail()) - { - error.SetErrorStringWithFormat("Couldn't convert return value to raw data: %s", data_error.AsCString()); - return error; + if (data_error.Fail()) { + error.SetErrorStringWithFormat( + "Couldn't convert return value to raw data: %s", + data_error.AsCString()); + return error; } - lldb::offset_t offset = 0; - if (num_bytes <= 8) - { - uint64_t raw_value = data.GetMaxU64(&offset, num_bytes); - if (reg_ctx->WriteRegisterFromUnsigned(reg_info, raw_value)) - set_it_simple = true; - } - else - { - error.SetErrorString("We don't support returning longer than 64 bit integer values at present."); - } - } - else if (compiler_type.IsFloatingPointType(count, is_complex)) - { - if (is_complex) - error.SetErrorString("We don't support returning complex values at present"); - else - { - size_t bit_width = compiler_type.GetBitSize(frame_sp.get()); - if (bit_width <= 64) - { - const RegisterInfo *f0_info = reg_ctx->GetRegisterInfoByName("f0", 0); - RegisterValue f0_value; - DataExtractor data; - Error data_error; - size_t num_bytes = new_value_sp->GetData(data, data_error); - if (data_error.Fail()) - { - error.SetErrorStringWithFormat("Couldn't convert return value to raw data: %s", - data_error.AsCString()); - return error; - } - - unsigned char buffer[8]; - ByteOrder byte_order = data.GetByteOrder(); - - data.CopyByteOrderedData(0, num_bytes, buffer, 8, byte_order); - f0_value.SetBytes(buffer, 8, byte_order); - reg_ctx->WriteRegister(f0_info, f0_value); - set_it_simple = true; - } - else - { - // FIXME - don't know how to do long doubles yet. - error.SetErrorString("We don't support returning float values > 64 bits at present"); - } - } + unsigned char buffer[8]; + ByteOrder byte_order = data.GetByteOrder(); + + data.CopyByteOrderedData(0, num_bytes, buffer, 8, byte_order); + f0_value.SetBytes(buffer, 8, byte_order); + reg_ctx->WriteRegister(f0_info, f0_value); + set_it_simple = true; + } else { + // FIXME - don't know how to do long doubles yet. + error.SetErrorString( + "We don't support returning float values > 64 bits at present"); + } } + } - if (!set_it_simple) - { - // Okay we've got a structure or something that doesn't fit in a simple register. - // We should figure out where it really goes, but we don't support this yet. - error.SetErrorString("We only support setting simple integer and float return types at present."); - } + if (!set_it_simple) { + // Okay we've got a structure or something that doesn't fit in a simple + // register. + // We should figure out where it really goes, but we don't support this yet. + error.SetErrorString("We only support setting simple integer and float " + "return types at present."); + } - return error; + return error; } -ValueObjectSP -ABISysV_s390x::GetReturnValueObjectSimple(Thread &thread, CompilerType &return_compiler_type) const -{ - ValueObjectSP return_valobj_sp; - Value value; - - if (!return_compiler_type) - return return_valobj_sp; - - // value.SetContext (Value::eContextTypeClangType, return_value_type); - value.SetCompilerType(return_compiler_type); - - RegisterContext *reg_ctx = thread.GetRegisterContext().get(); - if (!reg_ctx) - return return_valobj_sp; - - const uint32_t type_flags = return_compiler_type.GetTypeInfo(); - if (type_flags & eTypeIsScalar) - { - value.SetValueType(Value::eValueTypeScalar); - - bool success = false; - if (type_flags & eTypeIsInteger) - { - // Extract the register context so we can read arguments from registers - - const size_t byte_size = return_compiler_type.GetByteSize(nullptr); - uint64_t raw_value = - thread.GetRegisterContext()->ReadRegisterAsUnsigned(reg_ctx->GetRegisterInfoByName("r2", 0), 0); - const bool is_signed = (type_flags & eTypeIsSigned) != 0; - switch (byte_size) - { - default: - break; - - case sizeof(uint64_t): - if (is_signed) - value.GetScalar() = (int64_t)(raw_value); - else - value.GetScalar() = (uint64_t)(raw_value); - success = true; - break; - - case sizeof(uint32_t): - if (is_signed) - value.GetScalar() = (int32_t)(raw_value & UINT32_MAX); - else - value.GetScalar() = (uint32_t)(raw_value & UINT32_MAX); - success = true; - break; - - case sizeof(uint16_t): - if (is_signed) - value.GetScalar() = (int16_t)(raw_value & UINT16_MAX); - else - value.GetScalar() = (uint16_t)(raw_value & UINT16_MAX); - success = true; - break; - - case sizeof(uint8_t): - if (is_signed) - value.GetScalar() = (int8_t)(raw_value & UINT8_MAX); - else - value.GetScalar() = (uint8_t)(raw_value & UINT8_MAX); - success = true; - break; - } - } - else if (type_flags & eTypeIsFloat) - { - if (type_flags & eTypeIsComplex) - { - // Don't handle complex yet. - } - else - { - const size_t byte_size = return_compiler_type.GetByteSize(nullptr); - if (byte_size <= sizeof(long double)) - { - const RegisterInfo *f0_info = reg_ctx->GetRegisterInfoByName("f0", 0); - RegisterValue f0_value; - if (reg_ctx->ReadRegister(f0_info, f0_value)) - { - DataExtractor data; - if (f0_value.GetData(data)) - { - lldb::offset_t offset = 0; - if (byte_size == sizeof(float)) - { - value.GetScalar() = (float)data.GetFloat(&offset); - success = true; - } - else if (byte_size == sizeof(double)) - { - value.GetScalar() = (double)data.GetDouble(&offset); - success = true; - } - else if (byte_size == sizeof(long double)) - { - // Don't handle long double yet. - } - } - } - } +ValueObjectSP ABISysV_s390x::GetReturnValueObjectSimple( + Thread &thread, CompilerType &return_compiler_type) const { + ValueObjectSP return_valobj_sp; + Value value; + + if (!return_compiler_type) + return return_valobj_sp; + + // value.SetContext (Value::eContextTypeClangType, return_value_type); + value.SetCompilerType(return_compiler_type); + + RegisterContext *reg_ctx = thread.GetRegisterContext().get(); + if (!reg_ctx) + return return_valobj_sp; + + const uint32_t type_flags = return_compiler_type.GetTypeInfo(); + if (type_flags & eTypeIsScalar) { + value.SetValueType(Value::eValueTypeScalar); + + bool success = false; + if (type_flags & eTypeIsInteger) { + // Extract the register context so we can read arguments from registers + + const size_t byte_size = return_compiler_type.GetByteSize(nullptr); + uint64_t raw_value = thread.GetRegisterContext()->ReadRegisterAsUnsigned( + reg_ctx->GetRegisterInfoByName("r2", 0), 0); + const bool is_signed = (type_flags & eTypeIsSigned) != 0; + switch (byte_size) { + default: + break; + + case sizeof(uint64_t): + if (is_signed) + value.GetScalar() = (int64_t)(raw_value); + else + value.GetScalar() = (uint64_t)(raw_value); + success = true; + break; + + case sizeof(uint32_t): + if (is_signed) + value.GetScalar() = (int32_t)(raw_value & UINT32_MAX); + else + value.GetScalar() = (uint32_t)(raw_value & UINT32_MAX); + success = true; + break; + + case sizeof(uint16_t): + if (is_signed) + value.GetScalar() = (int16_t)(raw_value & UINT16_MAX); + else + value.GetScalar() = (uint16_t)(raw_value & UINT16_MAX); + success = true; + break; + + case sizeof(uint8_t): + if (is_signed) + value.GetScalar() = (int8_t)(raw_value & UINT8_MAX); + else + value.GetScalar() = (uint8_t)(raw_value & UINT8_MAX); + success = true; + break; + } + } else if (type_flags & eTypeIsFloat) { + if (type_flags & eTypeIsComplex) { + // Don't handle complex yet. + } else { + const size_t byte_size = return_compiler_type.GetByteSize(nullptr); + if (byte_size <= sizeof(long double)) { + const RegisterInfo *f0_info = reg_ctx->GetRegisterInfoByName("f0", 0); + RegisterValue f0_value; + if (reg_ctx->ReadRegister(f0_info, f0_value)) { + DataExtractor data; + if (f0_value.GetData(data)) { + lldb::offset_t offset = 0; + if (byte_size == sizeof(float)) { + value.GetScalar() = (float)data.GetFloat(&offset); + success = true; + } else if (byte_size == sizeof(double)) { + value.GetScalar() = (double)data.GetDouble(&offset); + success = true; + } else if (byte_size == sizeof(long double)) { + // Don't handle long double yet. + } } + } } - - if (success) - return_valobj_sp = - ValueObjectConstResult::Create(thread.GetStackFrameAtIndex(0).get(), value, ConstString("")); - } - else if (type_flags & eTypeIsPointer) - { - unsigned r2_id = reg_ctx->GetRegisterInfoByName("r2", 0)->kinds[eRegisterKindLLDB]; - value.GetScalar() = (uint64_t)thread.GetRegisterContext()->ReadRegisterAsUnsigned(r2_id, 0); - value.SetValueType(Value::eValueTypeScalar); - return_valobj_sp = ValueObjectConstResult::Create(thread.GetStackFrameAtIndex(0).get(), value, ConstString("")); + } } - return return_valobj_sp; + if (success) + return_valobj_sp = ValueObjectConstResult::Create( + thread.GetStackFrameAtIndex(0).get(), value, ConstString("")); + } else if (type_flags & eTypeIsPointer) { + unsigned r2_id = + reg_ctx->GetRegisterInfoByName("r2", 0)->kinds[eRegisterKindLLDB]; + value.GetScalar() = + (uint64_t)thread.GetRegisterContext()->ReadRegisterAsUnsigned(r2_id, 0); + value.SetValueType(Value::eValueTypeScalar); + return_valobj_sp = ValueObjectConstResult::Create( + thread.GetStackFrameAtIndex(0).get(), value, ConstString("")); + } + + return return_valobj_sp; } -ValueObjectSP -ABISysV_s390x::GetReturnValueObjectImpl(Thread &thread, CompilerType &return_compiler_type) const -{ - ValueObjectSP return_valobj_sp; - - if (!return_compiler_type) - return return_valobj_sp; - - ExecutionContext exe_ctx(thread.shared_from_this()); - return_valobj_sp = GetReturnValueObjectSimple(thread, return_compiler_type); - if (return_valobj_sp) - return return_valobj_sp; - - RegisterContextSP reg_ctx_sp = thread.GetRegisterContext(); - if (!reg_ctx_sp) - return return_valobj_sp; - - if (return_compiler_type.IsAggregateType()) - { - // FIXME: This is just taking a guess, r2 may very well no longer hold the return storage location. - // If we are going to do this right, when we make a new frame we should check to see if it uses a memory - // return, and if we are at the first instruction and if so stash away the return location. Then we would - // only return the memory return value if we know it is valid. - - unsigned r2_id = reg_ctx_sp->GetRegisterInfoByName("r2", 0)->kinds[eRegisterKindLLDB]; - lldb::addr_t storage_addr = (uint64_t)thread.GetRegisterContext()->ReadRegisterAsUnsigned(r2_id, 0); - return_valobj_sp = ValueObjectMemory::Create(&thread, "", Address(storage_addr, nullptr), return_compiler_type); - } +ValueObjectSP ABISysV_s390x::GetReturnValueObjectImpl( + Thread &thread, CompilerType &return_compiler_type) const { + ValueObjectSP return_valobj_sp; + + if (!return_compiler_type) + return return_valobj_sp; + ExecutionContext exe_ctx(thread.shared_from_this()); + return_valobj_sp = GetReturnValueObjectSimple(thread, return_compiler_type); + if (return_valobj_sp) return return_valobj_sp; + + RegisterContextSP reg_ctx_sp = thread.GetRegisterContext(); + if (!reg_ctx_sp) + return return_valobj_sp; + + if (return_compiler_type.IsAggregateType()) { + // FIXME: This is just taking a guess, r2 may very well no longer hold the + // return storage location. + // If we are going to do this right, when we make a new frame we should + // check to see if it uses a memory + // return, and if we are at the first instruction and if so stash away the + // return location. Then we would + // only return the memory return value if we know it is valid. + + unsigned r2_id = + reg_ctx_sp->GetRegisterInfoByName("r2", 0)->kinds[eRegisterKindLLDB]; + lldb::addr_t storage_addr = + (uint64_t)thread.GetRegisterContext()->ReadRegisterAsUnsigned(r2_id, 0); + return_valobj_sp = ValueObjectMemory::Create( + &thread, "", Address(storage_addr, nullptr), return_compiler_type); + } + + return return_valobj_sp; } -bool -ABISysV_s390x::CreateFunctionEntryUnwindPlan(UnwindPlan &unwind_plan) -{ - unwind_plan.Clear(); - unwind_plan.SetRegisterKind(eRegisterKindDWARF); +bool ABISysV_s390x::CreateFunctionEntryUnwindPlan(UnwindPlan &unwind_plan) { + unwind_plan.Clear(); + unwind_plan.SetRegisterKind(eRegisterKindDWARF); - UnwindPlan::RowSP row(new UnwindPlan::Row); + UnwindPlan::RowSP row(new UnwindPlan::Row); - // Our Call Frame Address is the stack pointer value + 160 - row->GetCFAValue().SetIsRegisterPlusOffset(dwarf_r15_s390x, 160); + // Our Call Frame Address is the stack pointer value + 160 + row->GetCFAValue().SetIsRegisterPlusOffset(dwarf_r15_s390x, 160); - // The previous PC is in r14 - row->SetRegisterLocationToRegister(dwarf_pswa_s390x, dwarf_r14_s390x, true); + // The previous PC is in r14 + row->SetRegisterLocationToRegister(dwarf_pswa_s390x, dwarf_r14_s390x, true); - // All other registers are the same. - unwind_plan.AppendRow(row); - unwind_plan.SetSourceName("s390x at-func-entry default"); - unwind_plan.SetSourcedFromCompiler(eLazyBoolNo); - return true; + // All other registers are the same. + unwind_plan.AppendRow(row); + unwind_plan.SetSourceName("s390x at-func-entry default"); + unwind_plan.SetSourcedFromCompiler(eLazyBoolNo); + return true; } -bool -ABISysV_s390x::CreateDefaultUnwindPlan(UnwindPlan &unwind_plan) -{ - // There's really no default way to unwind on s390x. - // Trust the .eh_frame CFI, which should always be good. - return false; +bool ABISysV_s390x::CreateDefaultUnwindPlan(UnwindPlan &unwind_plan) { + // There's really no default way to unwind on s390x. + // Trust the .eh_frame CFI, which should always be good. + return false; } -bool -ABISysV_s390x::GetFallbackRegisterLocation (const RegisterInfo *reg_info, - UnwindPlan::Row::RegisterLocation &unwind_regloc) -{ - // If a volatile register is being requested, we don't want to forward the next frame's register contents - // up the stack -- the register is not retrievable at this frame. - if (RegisterIsVolatile(reg_info)) - { - unwind_regloc.SetUndefined(); - return true; - } +bool ABISysV_s390x::GetFallbackRegisterLocation( + const RegisterInfo *reg_info, + UnwindPlan::Row::RegisterLocation &unwind_regloc) { + // If a volatile register is being requested, we don't want to forward the + // next frame's register contents + // up the stack -- the register is not retrievable at this frame. + if (RegisterIsVolatile(reg_info)) { + unwind_regloc.SetUndefined(); + return true; + } - return false; + return false; } -bool -ABISysV_s390x::RegisterIsVolatile(const RegisterInfo *reg_info) -{ - return !RegisterIsCalleeSaved(reg_info); +bool ABISysV_s390x::RegisterIsVolatile(const RegisterInfo *reg_info) { + return !RegisterIsCalleeSaved(reg_info); } -bool -ABISysV_s390x::RegisterIsCalleeSaved(const RegisterInfo *reg_info) -{ - if (reg_info) - { - // Preserved registers are : - // r6-r13, r15 - // f8-f15 - - const char *name = reg_info->name; - if (name[0] == 'r') - { - switch (name[1]) - { - case '6': // r6 - case '7': // r7 - case '8': // r8 - case '9': // r9 - return name[2] == '\0'; - - case '1': // r10, r11, r12, r13, r15 - if ((name[2] >= '0' && name[2] <= '3') || name[2] == '5') - return name[3] == '\0'; - break; - - default: - break; - } - } - if (name[0] == 'f') - { - switch (name[1]) - { - case '8': // r8 - case '9': // r9 - return name[2] == '\0'; - - case '1': // r10, r11, r12, r13, r14, r15 - if (name[2] >= '0' && name[2] <= '5') - return name[3] == '\0'; - break; - - default: - break; - } - } - - // Accept shorter-variant versions - if (name[0] == 's' && name[1] == 'p' && name[2] == '\0') // sp - return true; - if (name[0] == 'f' && name[1] == 'p' && name[2] == '\0') // fp - return true; - if (name[0] == 'p' && name[1] == 'c' && name[2] == '\0') // pc - return true; +bool ABISysV_s390x::RegisterIsCalleeSaved(const RegisterInfo *reg_info) { + if (reg_info) { + // Preserved registers are : + // r6-r13, r15 + // f8-f15 + + const char *name = reg_info->name; + if (name[0] == 'r') { + switch (name[1]) { + case '6': // r6 + case '7': // r7 + case '8': // r8 + case '9': // r9 + return name[2] == '\0'; + + case '1': // r10, r11, r12, r13, r15 + if ((name[2] >= '0' && name[2] <= '3') || name[2] == '5') + return name[3] == '\0'; + break; + + default: + break; + } } - return false; + if (name[0] == 'f') { + switch (name[1]) { + case '8': // r8 + case '9': // r9 + return name[2] == '\0'; + + case '1': // r10, r11, r12, r13, r14, r15 + if (name[2] >= '0' && name[2] <= '5') + return name[3] == '\0'; + break; + + default: + break; + } + } + + // Accept shorter-variant versions + if (name[0] == 's' && name[1] == 'p' && name[2] == '\0') // sp + return true; + if (name[0] == 'f' && name[1] == 'p' && name[2] == '\0') // fp + return true; + if (name[0] == 'p' && name[1] == 'c' && name[2] == '\0') // pc + return true; + } + return false; } -void -ABISysV_s390x::Initialize() -{ - PluginManager::RegisterPlugin(GetPluginNameStatic(), "System V ABI for s390x targets", CreateInstance); +void ABISysV_s390x::Initialize() { + PluginManager::RegisterPlugin( + GetPluginNameStatic(), "System V ABI for s390x targets", CreateInstance); } -void -ABISysV_s390x::Terminate() -{ - PluginManager::UnregisterPlugin(CreateInstance); +void ABISysV_s390x::Terminate() { + PluginManager::UnregisterPlugin(CreateInstance); } -lldb_private::ConstString -ABISysV_s390x::GetPluginNameStatic() -{ - static ConstString g_name("sysv-s390x"); - return g_name; +lldb_private::ConstString ABISysV_s390x::GetPluginNameStatic() { + static ConstString g_name("sysv-s390x"); + return g_name; } //------------------------------------------------------------------ // PluginInterface protocol //------------------------------------------------------------------ -lldb_private::ConstString -ABISysV_s390x::GetPluginName() -{ - return GetPluginNameStatic(); +lldb_private::ConstString ABISysV_s390x::GetPluginName() { + return GetPluginNameStatic(); } -uint32_t -ABISysV_s390x::GetPluginVersion() -{ - return 1; -} +uint32_t ABISysV_s390x::GetPluginVersion() { return 1; } diff --git a/source/Plugins/ABI/SysV-s390x/ABISysV_s390x.h b/source/Plugins/ABI/SysV-s390x/ABISysV_s390x.h index 3aba9c1917c6..6ccabd6f75ec 100644 --- a/source/Plugins/ABI/SysV-s390x/ABISysV_s390x.h +++ b/source/Plugins/ABI/SysV-s390x/ABISysV_s390x.h @@ -14,107 +14,94 @@ // C++ Includes // Other libraries and framework includes // Project includes -#include "lldb/lldb-private.h" #include "lldb/Target/ABI.h" +#include "lldb/lldb-private.h" -class ABISysV_s390x : public lldb_private::ABI -{ +class ABISysV_s390x : public lldb_private::ABI { public: - ~ABISysV_s390x() override = default; + ~ABISysV_s390x() override = default; - size_t - GetRedZoneSize() const override; + size_t GetRedZoneSize() const override; - bool - PrepareTrivialCall(lldb_private::Thread &thread, lldb::addr_t sp, lldb::addr_t functionAddress, - lldb::addr_t returnAddress, llvm::ArrayRef<lldb::addr_t> args) const override; + bool PrepareTrivialCall(lldb_private::Thread &thread, lldb::addr_t sp, + lldb::addr_t functionAddress, + lldb::addr_t returnAddress, + llvm::ArrayRef<lldb::addr_t> args) const override; - bool - GetArgumentValues(lldb_private::Thread &thread, lldb_private::ValueList &values) const override; + bool GetArgumentValues(lldb_private::Thread &thread, + lldb_private::ValueList &values) const override; - lldb_private::Error - SetReturnValueObject(lldb::StackFrameSP &frame_sp, lldb::ValueObjectSP &new_value) override; + lldb_private::Error + SetReturnValueObject(lldb::StackFrameSP &frame_sp, + lldb::ValueObjectSP &new_value) override; - lldb::ValueObjectSP - GetReturnValueObjectImpl(lldb_private::Thread &thread, lldb_private::CompilerType &type) const override; + lldb::ValueObjectSP + GetReturnValueObjectImpl(lldb_private::Thread &thread, + lldb_private::CompilerType &type) const override; - bool - CreateFunctionEntryUnwindPlan(lldb_private::UnwindPlan &unwind_plan) override; + bool + CreateFunctionEntryUnwindPlan(lldb_private::UnwindPlan &unwind_plan) override; - bool - CreateDefaultUnwindPlan(lldb_private::UnwindPlan &unwind_plan) override; + bool CreateDefaultUnwindPlan(lldb_private::UnwindPlan &unwind_plan) override; - bool - RegisterIsVolatile(const lldb_private::RegisterInfo *reg_info) override; + bool RegisterIsVolatile(const lldb_private::RegisterInfo *reg_info) override; - bool - GetFallbackRegisterLocation (const lldb_private::RegisterInfo *reg_info, - lldb_private::UnwindPlan::Row::RegisterLocation &unwind_regloc) override; + bool GetFallbackRegisterLocation( + const lldb_private::RegisterInfo *reg_info, + lldb_private::UnwindPlan::Row::RegisterLocation &unwind_regloc) override; - bool - CallFrameAddressIsValid(lldb::addr_t cfa) override - { - // Make sure the stack call frame addresses are 8 byte aligned - if (cfa & (8ull - 1ull)) - return false; // Not 8 byte aligned - if (cfa == 0) - return false; // Zero is not a valid stack address - return true; - } + bool CallFrameAddressIsValid(lldb::addr_t cfa) override { + // Make sure the stack call frame addresses are 8 byte aligned + if (cfa & (8ull - 1ull)) + return false; // Not 8 byte aligned + if (cfa == 0) + return false; // Zero is not a valid stack address + return true; + } - bool - CodeAddressIsValid(lldb::addr_t pc) override - { - // Code addressed must be 2 byte aligned - if (pc & 1ull) - return false; - return true; - } + bool CodeAddressIsValid(lldb::addr_t pc) override { + // Code addressed must be 2 byte aligned + if (pc & 1ull) + return false; + return true; + } - const lldb_private::RegisterInfo * - GetRegisterInfoArray(uint32_t &count) override; + const lldb_private::RegisterInfo * + GetRegisterInfoArray(uint32_t &count) override; - //------------------------------------------------------------------ - // Static Functions - //------------------------------------------------------------------ + //------------------------------------------------------------------ + // Static Functions + //------------------------------------------------------------------ - static void - Initialize(); + static void Initialize(); - static void - Terminate(); + static void Terminate(); - static lldb::ABISP - CreateInstance(const lldb_private::ArchSpec &arch); + static lldb::ABISP CreateInstance(const lldb_private::ArchSpec &arch); - static lldb_private::ConstString - GetPluginNameStatic(); + static lldb_private::ConstString GetPluginNameStatic(); - //------------------------------------------------------------------ - // PluginInterface protocol - //------------------------------------------------------------------ + //------------------------------------------------------------------ + // PluginInterface protocol + //------------------------------------------------------------------ - lldb_private::ConstString - GetPluginName() override; + lldb_private::ConstString GetPluginName() override; - uint32_t - GetPluginVersion() override; + uint32_t GetPluginVersion() override; protected: - void - CreateRegisterMapIfNeeded(); + void CreateRegisterMapIfNeeded(); - lldb::ValueObjectSP - GetReturnValueObjectSimple(lldb_private::Thread &thread, lldb_private::CompilerType &ast_type) const; + lldb::ValueObjectSP + GetReturnValueObjectSimple(lldb_private::Thread &thread, + lldb_private::CompilerType &ast_type) const; - bool - RegisterIsCalleeSaved(const lldb_private::RegisterInfo *reg_info); + bool RegisterIsCalleeSaved(const lldb_private::RegisterInfo *reg_info); private: - ABISysV_s390x() : lldb_private::ABI() - { - // Call CreateInstance instead. - } + ABISysV_s390x() : lldb_private::ABI() { + // Call CreateInstance instead. + } }; #endif // liblldb_ABISysV_s390x_h_ diff --git a/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.cpp b/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.cpp index 136f46a1d259..2019db2bfd17 100644 --- a/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.cpp +++ b/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.cpp @@ -25,262 +25,1141 @@ #include "lldb/Core/RegisterValue.h" #include "lldb/Core/Value.h" #include "lldb/Core/ValueObjectConstResult.h" -#include "lldb/Core/ValueObjectRegister.h" #include "lldb/Core/ValueObjectMemory.h" +#include "lldb/Core/ValueObjectRegister.h" #include "lldb/Symbol/UnwindPlan.h" -#include "lldb/Target/Target.h" #include "lldb/Target/Process.h" #include "lldb/Target/RegisterContext.h" #include "lldb/Target/StackFrame.h" +#include "lldb/Target/Target.h" #include "lldb/Target/Thread.h" using namespace lldb; using namespace lldb_private; -enum dwarf_regnums -{ - dwarf_rax = 0, - dwarf_rdx, - dwarf_rcx, - dwarf_rbx, - dwarf_rsi, - dwarf_rdi, - dwarf_rbp, - dwarf_rsp, - dwarf_r8, - dwarf_r9, - dwarf_r10, - dwarf_r11, - dwarf_r12, - dwarf_r13, - 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 +enum dwarf_regnums { + dwarf_rax = 0, + dwarf_rdx, + dwarf_rcx, + dwarf_rbx, + dwarf_rsi, + dwarf_rdi, + dwarf_rbp, + dwarf_rsp, + dwarf_r8, + dwarf_r9, + dwarf_r10, + dwarf_r11, + dwarf_r12, + dwarf_r13, + 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[] = -{ - // NAME ALT SZ OFF ENCODING FORMAT EH_FRAME DWARF GENERIC PROCESS PLUGIN LLDB NATIVE VALUE REGS INVALIDATE REGS - // ======== ======= == === ============= =================== ======================= ===================== =========================== ===================== ====================== ========== =============== - { "rax" , nullptr, 8, 0, eEncodingUint , eFormatHex , { dwarf_rax , dwarf_rax , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "rbx" , nullptr, 8, 0, eEncodingUint , eFormatHex , { dwarf_rbx , dwarf_rbx , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "rcx" , "arg4", 8, 0, eEncodingUint , eFormatHex , { dwarf_rcx , dwarf_rcx , LLDB_REGNUM_GENERIC_ARG4 , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "rdx" , "arg3", 8, 0, eEncodingUint , eFormatHex , { dwarf_rdx , dwarf_rdx , LLDB_REGNUM_GENERIC_ARG3 , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "rsi" , "arg2", 8, 0, eEncodingUint , eFormatHex , { dwarf_rsi , dwarf_rsi , LLDB_REGNUM_GENERIC_ARG2 , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "rdi" , "arg1", 8, 0, eEncodingUint , eFormatHex , { dwarf_rdi , dwarf_rdi , LLDB_REGNUM_GENERIC_ARG1 , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "rbp" , "fp", 8, 0, eEncodingUint , eFormatHex , { dwarf_rbp , dwarf_rbp , LLDB_REGNUM_GENERIC_FP , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "rsp" , "sp", 8, 0, eEncodingUint , eFormatHex , { dwarf_rsp , dwarf_rsp , LLDB_REGNUM_GENERIC_SP , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "r8" , "arg5", 8, 0, eEncodingUint , eFormatHex , { dwarf_r8 , dwarf_r8 , LLDB_REGNUM_GENERIC_ARG5 , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "r9" , "arg6", 8, 0, eEncodingUint , eFormatHex , { dwarf_r9 , dwarf_r9 , LLDB_REGNUM_GENERIC_ARG6 , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "r10" , nullptr, 8, 0, eEncodingUint , eFormatHex , { dwarf_r10 , dwarf_r10 , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "r11" , nullptr, 8, 0, eEncodingUint , eFormatHex , { dwarf_r11 , dwarf_r11 , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "r12" , nullptr, 8, 0, eEncodingUint , eFormatHex , { dwarf_r12 , dwarf_r12 , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "r13" , nullptr, 8, 0, eEncodingUint , eFormatHex , { dwarf_r13 , dwarf_r13 , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "r14" , nullptr, 8, 0, eEncodingUint , eFormatHex , { dwarf_r14 , dwarf_r14 , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "r15" , nullptr, 8, 0, eEncodingUint , eFormatHex , { dwarf_r15 , dwarf_r15 , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "rip" , "pc", 8, 0, eEncodingUint , eFormatHex , { dwarf_rip , dwarf_rip , LLDB_REGNUM_GENERIC_PC , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "rflags", nullptr, 4, 0, eEncodingUint , eFormatHex , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_REGNUM_GENERIC_FLAGS , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "cs" , nullptr, 4, 0, eEncodingUint , eFormatHex , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "ss" , nullptr, 4, 0, eEncodingUint , eFormatHex , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "ds" , nullptr, 4, 0, eEncodingUint , eFormatHex , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "es" , nullptr, 4, 0, eEncodingUint , eFormatHex , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "fs" , nullptr, 4, 0, eEncodingUint , eFormatHex , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "gs" , nullptr, 4, 0, eEncodingUint , eFormatHex , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "stmm0" , nullptr,10, 0, eEncodingVector, eFormatVectorOfUInt8, { dwarf_stmm0 , dwarf_stmm0 , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "stmm1" , nullptr,10, 0, eEncodingVector, eFormatVectorOfUInt8, { dwarf_stmm1 , dwarf_stmm1 , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "stmm2" , nullptr,10, 0, eEncodingVector, eFormatVectorOfUInt8, { dwarf_stmm2 , dwarf_stmm2 , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "stmm3" , nullptr,10, 0, eEncodingVector, eFormatVectorOfUInt8, { dwarf_stmm3 , dwarf_stmm3 , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "stmm4" , nullptr,10, 0, eEncodingVector, eFormatVectorOfUInt8, { dwarf_stmm4 , dwarf_stmm4 , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "stmm5" , nullptr,10, 0, eEncodingVector, eFormatVectorOfUInt8, { dwarf_stmm5 , dwarf_stmm5 , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "stmm6" , nullptr,10, 0, eEncodingVector, eFormatVectorOfUInt8, { dwarf_stmm6 , dwarf_stmm6 , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "stmm7" , nullptr,10, 0, eEncodingVector, eFormatVectorOfUInt8, { dwarf_stmm7 , dwarf_stmm7 , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "fctrl" , nullptr, 4, 0, eEncodingUint , eFormatHex , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "fstat" , nullptr, 4, 0, eEncodingUint , eFormatHex , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "ftag" , nullptr, 4, 0, eEncodingUint , eFormatHex , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "fiseg" , nullptr, 4, 0, eEncodingUint , eFormatHex , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "fioff" , nullptr, 4, 0, eEncodingUint , eFormatHex , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "foseg" , nullptr, 4, 0, eEncodingUint , eFormatHex , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "fooff" , nullptr, 4, 0, eEncodingUint , eFormatHex , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "fop" , nullptr, 4, 0, eEncodingUint , eFormatHex , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "xmm0" , nullptr,16, 0, eEncodingVector, eFormatVectorOfUInt8, { dwarf_xmm0 , dwarf_xmm0 , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "xmm1" , nullptr,16, 0, eEncodingVector, eFormatVectorOfUInt8, { dwarf_xmm1 , dwarf_xmm1 , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "xmm2" , nullptr,16, 0, eEncodingVector, eFormatVectorOfUInt8, { dwarf_xmm2 , dwarf_xmm2 , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "xmm3" , nullptr,16, 0, eEncodingVector, eFormatVectorOfUInt8, { dwarf_xmm3 , dwarf_xmm3 , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "xmm4" , nullptr,16, 0, eEncodingVector, eFormatVectorOfUInt8, { dwarf_xmm4 , dwarf_xmm4 , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "xmm5" , nullptr,16, 0, eEncodingVector, eFormatVectorOfUInt8, { dwarf_xmm5 , dwarf_xmm5 , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "xmm6" , nullptr,16, 0, eEncodingVector, eFormatVectorOfUInt8, { dwarf_xmm6 , dwarf_xmm6 , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "xmm7" , nullptr,16, 0, eEncodingVector, eFormatVectorOfUInt8, { dwarf_xmm7 , dwarf_xmm7 , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "xmm8" , nullptr,16, 0, eEncodingVector, eFormatVectorOfUInt8, { dwarf_xmm8 , dwarf_xmm8 , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "xmm9" , nullptr,16, 0, eEncodingVector, eFormatVectorOfUInt8, { dwarf_xmm9 , dwarf_xmm9 , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "xmm10" , nullptr,16, 0, eEncodingVector, eFormatVectorOfUInt8, { dwarf_xmm10 , dwarf_xmm10 , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "xmm11" , nullptr,16, 0, eEncodingVector, eFormatVectorOfUInt8, { dwarf_xmm11 , dwarf_xmm11 , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "xmm12" , nullptr,16, 0, eEncodingVector, eFormatVectorOfUInt8, { dwarf_xmm12 , dwarf_xmm12 , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "xmm13" , nullptr,16, 0, eEncodingVector, eFormatVectorOfUInt8, { dwarf_xmm13 , dwarf_xmm13 , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "xmm14" , nullptr,16, 0, eEncodingVector, eFormatVectorOfUInt8, { dwarf_xmm14 , dwarf_xmm14 , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "xmm15" , nullptr,16, 0, eEncodingVector, eFormatVectorOfUInt8, { dwarf_xmm15 , dwarf_xmm15 , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "mxcsr" , nullptr, 4, 0, eEncodingUint , eFormatHex , { LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "ymm0" , nullptr,32, 0, eEncodingVector, eFormatVectorOfUInt8, { dwarf_ymm0 , dwarf_ymm0 , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "ymm1" , nullptr,32, 0, eEncodingVector, eFormatVectorOfUInt8, { dwarf_ymm1 , dwarf_ymm1 , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "ymm2" , nullptr,32, 0, eEncodingVector, eFormatVectorOfUInt8, { dwarf_ymm2 , dwarf_ymm2 , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "ymm3" , nullptr,32, 0, eEncodingVector, eFormatVectorOfUInt8, { dwarf_ymm3 , dwarf_ymm3 , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "ymm4" , nullptr,32, 0, eEncodingVector, eFormatVectorOfUInt8, { dwarf_ymm4 , dwarf_ymm4 , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "ymm5" , nullptr,32, 0, eEncodingVector, eFormatVectorOfUInt8, { dwarf_ymm5 , dwarf_ymm5 , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "ymm6" , nullptr,32, 0, eEncodingVector, eFormatVectorOfUInt8, { dwarf_ymm6 , dwarf_ymm6 , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "ymm7" , nullptr,32, 0, eEncodingVector, eFormatVectorOfUInt8, { dwarf_ymm7 , dwarf_ymm7 , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "ymm8" , nullptr,32, 0, eEncodingVector, eFormatVectorOfUInt8, { dwarf_ymm8 , dwarf_ymm8 , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "ymm9" , nullptr,32, 0, eEncodingVector, eFormatVectorOfUInt8, { dwarf_ymm9 , dwarf_ymm9 , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "ymm10" , nullptr,32, 0, eEncodingVector, eFormatVectorOfUInt8, { dwarf_ymm10 , dwarf_ymm10 , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "ymm11" , nullptr,32, 0, eEncodingVector, eFormatVectorOfUInt8, { dwarf_ymm11 , dwarf_ymm11 , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "ymm12" , nullptr,32, 0, eEncodingVector, eFormatVectorOfUInt8, { dwarf_ymm12 , dwarf_ymm12 , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "ymm13" , nullptr,32, 0, eEncodingVector, eFormatVectorOfUInt8, { dwarf_ymm13 , dwarf_ymm13 , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "ymm14" , nullptr,32, 0, eEncodingVector, eFormatVectorOfUInt8, { dwarf_ymm14 , dwarf_ymm14 , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr }, - { "ymm15" , nullptr,32, 0, eEncodingVector, eFormatVectorOfUInt8, { dwarf_ymm15 , dwarf_ymm15 , LLDB_INVALID_REGNUM , LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, nullptr, nullptr } -}; - -static const uint32_t k_num_register_infos = llvm::array_lengthof(g_register_infos); +static RegisterInfo g_register_infos[] = { + // NAME ALT SZ OFF ENCODING FORMAT EH_FRAME + // DWARF GENERIC PROCESS PLUGIN + // 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}}; + +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(); - } +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; + } + count = k_num_register_infos; + return g_register_infos; } -size_t -ABISysV_x86_64::GetRedZoneSize () const -{ - return 128; +bool ABISysV_x86_64::GetPointerReturnRegister(const char *&name) { + name = "rax"; + return true; } +size_t ABISysV_x86_64::GetRedZoneSize() const { return 128; } + //------------------------------------------------------------------ // Static Functions //------------------------------------------------------------------ ABISP -ABISysV_x86_64::CreateInstance (const ArchSpec &arch) -{ - static ABISP g_abi_sp; - if (arch.GetTriple().getArch() == llvm::Triple::x86_64) - { - if (!g_abi_sp) - g_abi_sp.reset (new ABISysV_x86_64); - return g_abi_sp; - } - return ABISP(); +ABISysV_x86_64::CreateInstance(const ArchSpec &arch) { + static ABISP g_abi_sp; + if (arch.GetTriple().getArch() == llvm::Triple::x86_64) { + if (!g_abi_sp) + g_abi_sp.reset(new ABISysV_x86_64); + return g_abi_sp; + } + return ABISP(); } -bool -ABISysV_x86_64::PrepareTrivialCall (Thread &thread, - addr_t sp, - addr_t func_addr, - addr_t return_addr, - llvm::ArrayRef<addr_t> args) const -{ - Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS)); - - if (log) - { - StreamString s; - s.Printf("ABISysV_x86_64::PrepareTrivialCall (tid = 0x%" PRIx64 ", sp = 0x%" PRIx64 ", func_addr = 0x%" PRIx64 ", return_addr = 0x%" PRIx64, - thread.GetID(), - (uint64_t)sp, - (uint64_t)func_addr, - (uint64_t)return_addr); - - for (size_t i = 0; i < args.size(); ++i) - s.Printf (", arg%" PRIu64 " = 0x%" PRIx64, static_cast<uint64_t>(i + 1), args[i]); - s.PutCString (")"); - log->PutCString(s.GetString().c_str()); - } - - RegisterContext *reg_ctx = thread.GetRegisterContext().get(); - if (!reg_ctx) - return false; - - const RegisterInfo *reg_info = nullptr; - - if (args.size() > 6) // TODO handle more than 6 arguments - return false; - +bool ABISysV_x86_64::PrepareTrivialCall(Thread &thread, addr_t sp, + addr_t func_addr, addr_t return_addr, + llvm::ArrayRef<addr_t> args) const { + Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS)); + + if (log) { + StreamString s; + s.Printf("ABISysV_x86_64::PrepareTrivialCall (tid = 0x%" PRIx64 + ", sp = 0x%" PRIx64 ", func_addr = 0x%" PRIx64 + ", return_addr = 0x%" PRIx64, + thread.GetID(), (uint64_t)sp, (uint64_t)func_addr, + (uint64_t)return_addr); + for (size_t i = 0; i < args.size(); ++i) - { - reg_info = reg_ctx->GetRegisterInfo(eRegisterKindGeneric, LLDB_REGNUM_GENERIC_ARG1 + i); - if (log) - log->Printf("About to write arg%" PRIu64 " (0x%" PRIx64 ") into %s", static_cast<uint64_t>(i + 1), args[i], reg_info->name); - if (!reg_ctx->WriteRegisterFromUnsigned(reg_info, args[i])) - return false; - } + s.Printf(", arg%" PRIu64 " = 0x%" PRIx64, static_cast<uint64_t>(i + 1), + args[i]); + s.PutCString(")"); + log->PutString(s.GetString()); + } + + RegisterContext *reg_ctx = thread.GetRegisterContext().get(); + if (!reg_ctx) + return false; - // First, align the SP + const RegisterInfo *reg_info = nullptr; + if (args.size() > 6) // TODO handle more than 6 arguments + return false; + + for (size_t i = 0; i < args.size(); ++i) { + reg_info = reg_ctx->GetRegisterInfo(eRegisterKindGeneric, + LLDB_REGNUM_GENERIC_ARG1 + i); if (log) - log->Printf("16-byte aligning SP: 0x%" PRIx64 " to 0x%" PRIx64, (uint64_t)sp, (uint64_t)(sp & ~0xfull)); + log->Printf("About to write arg%" PRIu64 " (0x%" PRIx64 ") into %s", + static_cast<uint64_t>(i + 1), args[i], reg_info->name); + if (!reg_ctx->WriteRegisterFromUnsigned(reg_info, args[i])) + return false; + } - sp &= ~(0xfull); // 16-byte alignment + // First, align the SP - sp -= 8; + if (log) + log->Printf("16-byte aligning SP: 0x%" PRIx64 " to 0x%" PRIx64, + (uint64_t)sp, (uint64_t)(sp & ~0xfull)); - Error error; - const RegisterInfo *pc_reg_info = reg_ctx->GetRegisterInfo (eRegisterKindGeneric, LLDB_REGNUM_GENERIC_PC); - const RegisterInfo *sp_reg_info = reg_ctx->GetRegisterInfo (eRegisterKindGeneric, LLDB_REGNUM_GENERIC_SP); - ProcessSP process_sp (thread.GetProcess()); + sp &= ~(0xfull); // 16-byte alignment - RegisterValue reg_value; + sp -= 8; + + Error error; + const RegisterInfo *pc_reg_info = + reg_ctx->GetRegisterInfo(eRegisterKindGeneric, LLDB_REGNUM_GENERIC_PC); + const RegisterInfo *sp_reg_info = + reg_ctx->GetRegisterInfo(eRegisterKindGeneric, LLDB_REGNUM_GENERIC_SP); + ProcessSP process_sp(thread.GetProcess()); + + RegisterValue reg_value; #if 0 // This code adds an extra frame so that we don't lose the function that we came from @@ -321,731 +1200,667 @@ ABISysV_x86_64::PrepareTrivialCall (Thread &thread, sp -= 8; } -#endif - - if (log) - log->Printf("Pushing the return address onto the stack: 0x%" PRIx64 ": 0x%" PRIx64, (uint64_t)sp, (uint64_t)return_addr); +#endif - // Save return address onto the stack - if (!process_sp->WritePointerToMemory(sp, return_addr, error)) - return false; + if (log) + log->Printf("Pushing the return address onto the stack: 0x%" PRIx64 + ": 0x%" PRIx64, + (uint64_t)sp, (uint64_t)return_addr); - // %rsp is set to the actual stack value. + // Save return address onto the stack + if (!process_sp->WritePointerToMemory(sp, return_addr, error)) + return false; - if (log) - log->Printf("Writing SP: 0x%" PRIx64, (uint64_t)sp); - - if (!reg_ctx->WriteRegisterFromUnsigned (sp_reg_info, sp)) - return false; + // %rsp is set to the actual stack value. - // %rip is set to the address of the called function. - - if (log) - log->Printf("Writing IP: 0x%" PRIx64, (uint64_t)func_addr); + if (log) + log->Printf("Writing SP: 0x%" PRIx64, (uint64_t)sp); - if (!reg_ctx->WriteRegisterFromUnsigned (pc_reg_info, func_addr)) - return false; + if (!reg_ctx->WriteRegisterFromUnsigned(sp_reg_info, sp)) + return false; - return true; -} + // %rip is set to the address of the called function. -static bool ReadIntegerArgument(Scalar &scalar, - unsigned int bit_width, - bool is_signed, - Thread &thread, - uint32_t *argument_register_ids, - unsigned int ¤t_argument_register, - addr_t ¤t_stack_argument) -{ - if (bit_width > 64) - return false; // Scalar can't hold large integer arguments - - if (current_argument_register < 6) - { - scalar = thread.GetRegisterContext()->ReadRegisterAsUnsigned(argument_register_ids[current_argument_register], 0); - current_argument_register++; - if (is_signed) - scalar.SignExtend (bit_width); - } - else - { - uint32_t byte_size = (bit_width + (8-1))/8; - Error error; - if (thread.GetProcess()->ReadScalarIntegerFromMemory(current_stack_argument, byte_size, is_signed, scalar, error)) - { - current_stack_argument += byte_size; - return true; - } - return false; - } - return true; -} + if (log) + log->Printf("Writing IP: 0x%" PRIx64, (uint64_t)func_addr); -bool -ABISysV_x86_64::GetArgumentValues (Thread &thread, - ValueList &values) const -{ - unsigned int num_values = values.GetSize(); - unsigned int value_index; - - // Extract the register context so we can read arguments from registers - - RegisterContext *reg_ctx = thread.GetRegisterContext().get(); - - if (!reg_ctx) - return false; - - // Get the pointer to the first stack argument so we have a place to start - // when reading data - - addr_t sp = reg_ctx->GetSP(0); - - if (!sp) - return false; - - addr_t current_stack_argument = sp + 8; // jump over return address - - uint32_t argument_register_ids[6]; - - argument_register_ids[0] = reg_ctx->GetRegisterInfo (eRegisterKindGeneric, LLDB_REGNUM_GENERIC_ARG1)->kinds[eRegisterKindLLDB]; - argument_register_ids[1] = reg_ctx->GetRegisterInfo (eRegisterKindGeneric, LLDB_REGNUM_GENERIC_ARG2)->kinds[eRegisterKindLLDB]; - argument_register_ids[2] = reg_ctx->GetRegisterInfo (eRegisterKindGeneric, LLDB_REGNUM_GENERIC_ARG3)->kinds[eRegisterKindLLDB]; - argument_register_ids[3] = reg_ctx->GetRegisterInfo (eRegisterKindGeneric, LLDB_REGNUM_GENERIC_ARG4)->kinds[eRegisterKindLLDB]; - argument_register_ids[4] = reg_ctx->GetRegisterInfo (eRegisterKindGeneric, LLDB_REGNUM_GENERIC_ARG5)->kinds[eRegisterKindLLDB]; - argument_register_ids[5] = reg_ctx->GetRegisterInfo (eRegisterKindGeneric, LLDB_REGNUM_GENERIC_ARG6)->kinds[eRegisterKindLLDB]; - - unsigned int current_argument_register = 0; - - for (value_index = 0; - value_index < num_values; - ++value_index) - { - Value *value = values.GetValueAtIndex(value_index); - - if (!value) - return false; - - // We currently only support extracting values with Clang QualTypes. - // Do we care about others? - CompilerType compiler_type = value->GetCompilerType(); - if (!compiler_type) - return false; - bool is_signed; - - if (compiler_type.IsIntegerOrEnumerationType (is_signed)) - { - ReadIntegerArgument(value->GetScalar(), - compiler_type.GetBitSize(&thread), - is_signed, - thread, - argument_register_ids, - current_argument_register, - current_stack_argument); - } - else if (compiler_type.IsPointerType ()) - { - ReadIntegerArgument(value->GetScalar(), - compiler_type.GetBitSize(&thread), - false, - thread, - argument_register_ids, - current_argument_register, - current_stack_argument); - } - } - - return true; + if (!reg_ctx->WriteRegisterFromUnsigned(pc_reg_info, func_addr)) + return false; + + return true; } -Error -ABISysV_x86_64::SetReturnValueObject(lldb::StackFrameSP &frame_sp, lldb::ValueObjectSP &new_value_sp) -{ +static bool ReadIntegerArgument(Scalar &scalar, unsigned int bit_width, + bool is_signed, Thread &thread, + uint32_t *argument_register_ids, + unsigned int ¤t_argument_register, + addr_t ¤t_stack_argument) { + if (bit_width > 64) + return false; // Scalar can't hold large integer arguments + + if (current_argument_register < 6) { + scalar = thread.GetRegisterContext()->ReadRegisterAsUnsigned( + argument_register_ids[current_argument_register], 0); + current_argument_register++; + if (is_signed) + scalar.SignExtend(bit_width); + } else { + uint32_t byte_size = (bit_width + (8 - 1)) / 8; Error error; - if (!new_value_sp) - { - error.SetErrorString("Empty value object for return value."); - return error; + if (thread.GetProcess()->ReadScalarIntegerFromMemory( + current_stack_argument, byte_size, is_signed, scalar, error)) { + current_stack_argument += byte_size; + return true; } - - CompilerType compiler_type = new_value_sp->GetCompilerType(); + return false; + } + return true; +} + +bool ABISysV_x86_64::GetArgumentValues(Thread &thread, + ValueList &values) const { + unsigned int num_values = values.GetSize(); + unsigned int value_index; + + // Extract the register context so we can read arguments from registers + + RegisterContext *reg_ctx = thread.GetRegisterContext().get(); + + if (!reg_ctx) + return false; + + // Get the pointer to the first stack argument so we have a place to start + // when reading data + + addr_t sp = reg_ctx->GetSP(0); + + if (!sp) + return false; + + addr_t current_stack_argument = sp + 8; // jump over return address + + uint32_t argument_register_ids[6]; + + argument_register_ids[0] = + reg_ctx->GetRegisterInfo(eRegisterKindGeneric, LLDB_REGNUM_GENERIC_ARG1) + ->kinds[eRegisterKindLLDB]; + argument_register_ids[1] = + reg_ctx->GetRegisterInfo(eRegisterKindGeneric, LLDB_REGNUM_GENERIC_ARG2) + ->kinds[eRegisterKindLLDB]; + argument_register_ids[2] = + reg_ctx->GetRegisterInfo(eRegisterKindGeneric, LLDB_REGNUM_GENERIC_ARG3) + ->kinds[eRegisterKindLLDB]; + argument_register_ids[3] = + reg_ctx->GetRegisterInfo(eRegisterKindGeneric, LLDB_REGNUM_GENERIC_ARG4) + ->kinds[eRegisterKindLLDB]; + argument_register_ids[4] = + reg_ctx->GetRegisterInfo(eRegisterKindGeneric, LLDB_REGNUM_GENERIC_ARG5) + ->kinds[eRegisterKindLLDB]; + argument_register_ids[5] = + reg_ctx->GetRegisterInfo(eRegisterKindGeneric, LLDB_REGNUM_GENERIC_ARG6) + ->kinds[eRegisterKindLLDB]; + + unsigned int current_argument_register = 0; + + for (value_index = 0; value_index < num_values; ++value_index) { + Value *value = values.GetValueAtIndex(value_index); + + if (!value) + return false; + + // We currently only support extracting values with Clang QualTypes. + // Do we care about others? + CompilerType compiler_type = value->GetCompilerType(); if (!compiler_type) - { - error.SetErrorString ("Null clang type for return value."); - return error; - } - - Thread *thread = frame_sp->GetThread().get(); - + return false; bool is_signed; - uint32_t count; - bool is_complex; - - RegisterContext *reg_ctx = thread->GetRegisterContext().get(); - bool set_it_simple = false; - if (compiler_type.IsIntegerOrEnumerationType (is_signed) || compiler_type.IsPointerType()) - { - const RegisterInfo *reg_info = reg_ctx->GetRegisterInfoByName("rax", 0); + if (compiler_type.IsIntegerOrEnumerationType(is_signed)) { + ReadIntegerArgument(value->GetScalar(), compiler_type.GetBitSize(&thread), + is_signed, thread, argument_register_ids, + current_argument_register, current_stack_argument); + } else if (compiler_type.IsPointerType()) { + ReadIntegerArgument(value->GetScalar(), compiler_type.GetBitSize(&thread), + false, thread, argument_register_ids, + current_argument_register, current_stack_argument); + } + } + + return true; +} + +Error ABISysV_x86_64::SetReturnValueObject(lldb::StackFrameSP &frame_sp, + lldb::ValueObjectSP &new_value_sp) { + Error error; + if (!new_value_sp) { + error.SetErrorString("Empty value object for return value."); + return error; + } + + CompilerType compiler_type = new_value_sp->GetCompilerType(); + if (!compiler_type) { + error.SetErrorString("Null clang type for return value."); + return error; + } + + Thread *thread = frame_sp->GetThread().get(); + bool is_signed; + uint32_t count; + bool is_complex; + + RegisterContext *reg_ctx = thread->GetRegisterContext().get(); + + bool set_it_simple = false; + if (compiler_type.IsIntegerOrEnumerationType(is_signed) || + compiler_type.IsPointerType()) { + const RegisterInfo *reg_info = reg_ctx->GetRegisterInfoByName("rax", 0); + + DataExtractor data; + Error data_error; + size_t num_bytes = new_value_sp->GetData(data, data_error); + if (data_error.Fail()) { + error.SetErrorStringWithFormat( + "Couldn't convert return value to raw data: %s", + data_error.AsCString()); + return error; + } + lldb::offset_t offset = 0; + if (num_bytes <= 8) { + uint64_t raw_value = data.GetMaxU64(&offset, num_bytes); + + if (reg_ctx->WriteRegisterFromUnsigned(reg_info, raw_value)) + set_it_simple = true; + } else { + error.SetErrorString("We don't support returning longer than 64 bit " + "integer values at present."); + } + } else if (compiler_type.IsFloatingPointType(count, is_complex)) { + if (is_complex) + error.SetErrorString( + "We don't support returning complex values at present"); + else { + size_t bit_width = compiler_type.GetBitSize(frame_sp.get()); + if (bit_width <= 64) { + const RegisterInfo *xmm0_info = + reg_ctx->GetRegisterInfoByName("xmm0", 0); + RegisterValue xmm0_value; DataExtractor data; Error data_error; size_t num_bytes = new_value_sp->GetData(data, data_error); - if (data_error.Fail()) - { - error.SetErrorStringWithFormat("Couldn't convert return value to raw data: %s", data_error.AsCString()); - return error; - } - lldb::offset_t offset = 0; - if (num_bytes <= 8) - { - uint64_t raw_value = data.GetMaxU64(&offset, num_bytes); - - if (reg_ctx->WriteRegisterFromUnsigned (reg_info, raw_value)) - set_it_simple = true; - } - else - { - error.SetErrorString("We don't support returning longer than 64 bit integer values at present."); - } - } - else if (compiler_type.IsFloatingPointType (count, is_complex)) - { - if (is_complex) - error.SetErrorString ("We don't support returning complex values at present"); - else - { - size_t bit_width = compiler_type.GetBitSize(frame_sp.get()); - if (bit_width <= 64) - { - const RegisterInfo *xmm0_info = reg_ctx->GetRegisterInfoByName("xmm0", 0); - RegisterValue xmm0_value; - DataExtractor data; - Error data_error; - size_t num_bytes = new_value_sp->GetData(data, data_error); - if (data_error.Fail()) - { - error.SetErrorStringWithFormat("Couldn't convert return value to raw data: %s", data_error.AsCString()); - return error; - } - - unsigned char buffer[16]; - ByteOrder byte_order = data.GetByteOrder(); - - data.CopyByteOrderedData (0, num_bytes, buffer, 16, byte_order); - xmm0_value.SetBytes(buffer, 16, byte_order); - reg_ctx->WriteRegister(xmm0_info, xmm0_value); - set_it_simple = true; - } - else - { - // FIXME - don't know how to do 80 bit long doubles yet. - error.SetErrorString ("We don't support returning float values > 64 bits at present"); - } + if (data_error.Fail()) { + error.SetErrorStringWithFormat( + "Couldn't convert return value to raw data: %s", + data_error.AsCString()); + return error; } + + unsigned char buffer[16]; + ByteOrder byte_order = data.GetByteOrder(); + + data.CopyByteOrderedData(0, num_bytes, buffer, 16, byte_order); + xmm0_value.SetBytes(buffer, 16, byte_order); + reg_ctx->WriteRegister(xmm0_info, xmm0_value); + set_it_simple = true; + } else { + // FIXME - don't know how to do 80 bit long doubles yet. + error.SetErrorString( + "We don't support returning float values > 64 bits at present"); + } } - - if (!set_it_simple) - { - // Okay we've got a structure or something that doesn't fit in a simple register. - // We should figure out where it really goes, but we don't support this yet. - error.SetErrorString ("We only support setting simple integer and float return types at present."); - } - - return error; + } + + if (!set_it_simple) { + // Okay we've got a structure or something that doesn't fit in a simple + // register. + // We should figure out where it really goes, but we don't support this yet. + error.SetErrorString("We only support setting simple integer and float " + "return types at present."); + } + + return error; } -ValueObjectSP -ABISysV_x86_64::GetReturnValueObjectSimple (Thread &thread, - CompilerType &return_compiler_type) const -{ - ValueObjectSP return_valobj_sp; - Value value; - - if (!return_compiler_type) - return return_valobj_sp; - - //value.SetContext (Value::eContextTypeClangType, return_value_type); - value.SetCompilerType (return_compiler_type); - - RegisterContext *reg_ctx = thread.GetRegisterContext().get(); - if (!reg_ctx) - return return_valobj_sp; - - const uint32_t type_flags = return_compiler_type.GetTypeInfo (); - if (type_flags & eTypeIsScalar) - { - value.SetValueType(Value::eValueTypeScalar); +ValueObjectSP ABISysV_x86_64::GetReturnValueObjectSimple( + Thread &thread, CompilerType &return_compiler_type) const { + ValueObjectSP return_valobj_sp; + Value value; - bool success = false; - if (type_flags & eTypeIsInteger) - { - // Extract the register context so we can read arguments from registers - - const size_t byte_size = return_compiler_type.GetByteSize(nullptr); - uint64_t raw_value = thread.GetRegisterContext()->ReadRegisterAsUnsigned(reg_ctx->GetRegisterInfoByName("rax", 0), 0); - const bool is_signed = (type_flags & eTypeIsSigned) != 0; - switch (byte_size) - { - default: - break; - - case sizeof(uint64_t): - if (is_signed) - value.GetScalar() = (int64_t)(raw_value); - else - value.GetScalar() = (uint64_t)(raw_value); - success = true; - break; + if (!return_compiler_type) + return return_valobj_sp; - case sizeof(uint32_t): - if (is_signed) - value.GetScalar() = (int32_t)(raw_value & UINT32_MAX); - else - value.GetScalar() = (uint32_t)(raw_value & UINT32_MAX); - success = true; - break; + // value.SetContext (Value::eContextTypeClangType, return_value_type); + value.SetCompilerType(return_compiler_type); - case sizeof(uint16_t): - if (is_signed) - value.GetScalar() = (int16_t)(raw_value & UINT16_MAX); - else - value.GetScalar() = (uint16_t)(raw_value & UINT16_MAX); - success = true; - break; + RegisterContext *reg_ctx = thread.GetRegisterContext().get(); + if (!reg_ctx) + return return_valobj_sp; + + const uint32_t type_flags = return_compiler_type.GetTypeInfo(); + if (type_flags & eTypeIsScalar) { + value.SetValueType(Value::eValueTypeScalar); + + bool success = false; + if (type_flags & eTypeIsInteger) { + // Extract the register context so we can read arguments from registers - case sizeof(uint8_t): - if (is_signed) - value.GetScalar() = (int8_t)(raw_value & UINT8_MAX); - else - value.GetScalar() = (uint8_t)(raw_value & UINT8_MAX); + const size_t byte_size = return_compiler_type.GetByteSize(nullptr); + uint64_t raw_value = thread.GetRegisterContext()->ReadRegisterAsUnsigned( + reg_ctx->GetRegisterInfoByName("rax", 0), 0); + const bool is_signed = (type_flags & eTypeIsSigned) != 0; + switch (byte_size) { + default: + break; + + case sizeof(uint64_t): + if (is_signed) + value.GetScalar() = (int64_t)(raw_value); + else + value.GetScalar() = (uint64_t)(raw_value); + success = true; + break; + + case sizeof(uint32_t): + if (is_signed) + value.GetScalar() = (int32_t)(raw_value & UINT32_MAX); + else + value.GetScalar() = (uint32_t)(raw_value & UINT32_MAX); + success = true; + break; + + case sizeof(uint16_t): + if (is_signed) + value.GetScalar() = (int16_t)(raw_value & UINT16_MAX); + else + value.GetScalar() = (uint16_t)(raw_value & UINT16_MAX); + success = true; + break; + + case sizeof(uint8_t): + if (is_signed) + value.GetScalar() = (int8_t)(raw_value & UINT8_MAX); + else + value.GetScalar() = (uint8_t)(raw_value & UINT8_MAX); + success = true; + break; + } + } else if (type_flags & eTypeIsFloat) { + if (type_flags & eTypeIsComplex) { + // Don't handle complex yet. + } else { + const size_t byte_size = return_compiler_type.GetByteSize(nullptr); + if (byte_size <= sizeof(long double)) { + const RegisterInfo *xmm0_info = + reg_ctx->GetRegisterInfoByName("xmm0", 0); + RegisterValue xmm0_value; + if (reg_ctx->ReadRegister(xmm0_info, xmm0_value)) { + DataExtractor data; + if (xmm0_value.GetData(data)) { + lldb::offset_t offset = 0; + if (byte_size == sizeof(float)) { + value.GetScalar() = (float)data.GetFloat(&offset); success = true; - break; - } - } - else if (type_flags & eTypeIsFloat) - { - if (type_flags & eTypeIsComplex) - { - // Don't handle complex yet. - } - else - { - const size_t byte_size = return_compiler_type.GetByteSize(nullptr); - if (byte_size <= sizeof(long double)) - { - const RegisterInfo *xmm0_info = reg_ctx->GetRegisterInfoByName("xmm0", 0); - RegisterValue xmm0_value; - if (reg_ctx->ReadRegister (xmm0_info, xmm0_value)) - { - DataExtractor data; - if (xmm0_value.GetData(data)) - { - lldb::offset_t offset = 0; - if (byte_size == sizeof(float)) - { - value.GetScalar() = (float) data.GetFloat(&offset); - success = true; - } - else if (byte_size == sizeof(double)) - { - value.GetScalar() = (double) data.GetDouble(&offset); - success = true; - } - else if (byte_size == sizeof(long double)) - { - // Don't handle long double since that can be encoded as 80 bit floats... - } - } - } - } + } else if (byte_size == sizeof(double)) { + value.GetScalar() = (double)data.GetDouble(&offset); + success = true; + } else if (byte_size == sizeof(long double)) { + // Don't handle long double since that can be encoded as 80 bit + // floats... + } } + } } - - if (success) - return_valobj_sp = ValueObjectConstResult::Create (thread.GetStackFrameAtIndex(0).get(), - value, - ConstString("")); + } } - else if (type_flags & eTypeIsPointer) - { - unsigned rax_id = reg_ctx->GetRegisterInfoByName("rax", 0)->kinds[eRegisterKindLLDB]; - value.GetScalar() = (uint64_t)thread.GetRegisterContext()->ReadRegisterAsUnsigned(rax_id, 0); - value.SetValueType(Value::eValueTypeScalar); - return_valobj_sp = ValueObjectConstResult::Create (thread.GetStackFrameAtIndex(0).get(), - value, - ConstString("")); - } - else if (type_flags & eTypeIsVector) - { - const size_t byte_size = return_compiler_type.GetByteSize(nullptr); - if (byte_size > 0) - { - const RegisterInfo *altivec_reg = reg_ctx->GetRegisterInfoByName("xmm0", 0); - if (altivec_reg == nullptr) - altivec_reg = reg_ctx->GetRegisterInfoByName("mm0", 0); - - if (altivec_reg) - { - if (byte_size <= altivec_reg->byte_size) - { - ProcessSP process_sp (thread.GetProcess()); - if (process_sp) - { - std::unique_ptr<DataBufferHeap> heap_data_ap (new DataBufferHeap(byte_size, 0)); - const ByteOrder byte_order = process_sp->GetByteOrder(); - RegisterValue reg_value; - if (reg_ctx->ReadRegister(altivec_reg, reg_value)) - { - Error error; - if (reg_value.GetAsMemoryData (altivec_reg, - heap_data_ap->GetBytes(), - heap_data_ap->GetByteSize(), - byte_order, - error)) - { - DataExtractor data (DataBufferSP (heap_data_ap.release()), - byte_order, - process_sp->GetTarget().GetArchitecture().GetAddressByteSize()); - return_valobj_sp = ValueObjectConstResult::Create (&thread, - return_compiler_type, - ConstString(""), - data); - } - } - } - } - else if (byte_size <= altivec_reg->byte_size*2) - { - const RegisterInfo *altivec_reg2 = reg_ctx->GetRegisterInfoByName("xmm1", 0); - if (altivec_reg2) - { - ProcessSP process_sp (thread.GetProcess()); - if (process_sp) - { - std::unique_ptr<DataBufferHeap> heap_data_ap (new DataBufferHeap(byte_size, 0)); - const ByteOrder byte_order = process_sp->GetByteOrder(); - RegisterValue reg_value; - RegisterValue reg_value2; - if (reg_ctx->ReadRegister(altivec_reg, reg_value) && reg_ctx->ReadRegister(altivec_reg2, reg_value2)) - { - - Error error; - if (reg_value.GetAsMemoryData (altivec_reg, - heap_data_ap->GetBytes(), - altivec_reg->byte_size, - byte_order, - error) && - reg_value2.GetAsMemoryData (altivec_reg2, - heap_data_ap->GetBytes() + altivec_reg->byte_size, - heap_data_ap->GetByteSize() - altivec_reg->byte_size, - byte_order, - error)) - { - DataExtractor data (DataBufferSP (heap_data_ap.release()), - byte_order, - process_sp->GetTarget().GetArchitecture().GetAddressByteSize()); - return_valobj_sp = ValueObjectConstResult::Create (&thread, - return_compiler_type, - ConstString(""), - data); - } - } - } - } + + if (success) + return_valobj_sp = ValueObjectConstResult::Create( + thread.GetStackFrameAtIndex(0).get(), value, ConstString("")); + } else if (type_flags & eTypeIsPointer) { + unsigned rax_id = + reg_ctx->GetRegisterInfoByName("rax", 0)->kinds[eRegisterKindLLDB]; + value.GetScalar() = + (uint64_t)thread.GetRegisterContext()->ReadRegisterAsUnsigned(rax_id, + 0); + value.SetValueType(Value::eValueTypeScalar); + return_valobj_sp = ValueObjectConstResult::Create( + thread.GetStackFrameAtIndex(0).get(), value, ConstString("")); + } else if (type_flags & eTypeIsVector) { + const size_t byte_size = return_compiler_type.GetByteSize(nullptr); + if (byte_size > 0) { + const RegisterInfo *altivec_reg = + reg_ctx->GetRegisterInfoByName("xmm0", 0); + if (altivec_reg == nullptr) + altivec_reg = reg_ctx->GetRegisterInfoByName("mm0", 0); + + if (altivec_reg) { + if (byte_size <= altivec_reg->byte_size) { + ProcessSP process_sp(thread.GetProcess()); + if (process_sp) { + std::unique_ptr<DataBufferHeap> heap_data_ap( + new DataBufferHeap(byte_size, 0)); + const ByteOrder byte_order = process_sp->GetByteOrder(); + RegisterValue reg_value; + if (reg_ctx->ReadRegister(altivec_reg, reg_value)) { + Error error; + if (reg_value.GetAsMemoryData( + altivec_reg, heap_data_ap->GetBytes(), + heap_data_ap->GetByteSize(), byte_order, error)) { + DataExtractor data(DataBufferSP(heap_data_ap.release()), + byte_order, process_sp->GetTarget() + .GetArchitecture() + .GetAddressByteSize()); + return_valobj_sp = ValueObjectConstResult::Create( + &thread, return_compiler_type, ConstString(""), data); + } + } + } + } else if (byte_size <= altivec_reg->byte_size * 2) { + const RegisterInfo *altivec_reg2 = + reg_ctx->GetRegisterInfoByName("xmm1", 0); + if (altivec_reg2) { + ProcessSP process_sp(thread.GetProcess()); + if (process_sp) { + std::unique_ptr<DataBufferHeap> heap_data_ap( + new DataBufferHeap(byte_size, 0)); + const ByteOrder byte_order = process_sp->GetByteOrder(); + RegisterValue reg_value; + RegisterValue reg_value2; + if (reg_ctx->ReadRegister(altivec_reg, reg_value) && + reg_ctx->ReadRegister(altivec_reg2, reg_value2)) { + + Error error; + if (reg_value.GetAsMemoryData( + altivec_reg, heap_data_ap->GetBytes(), + altivec_reg->byte_size, byte_order, error) && + reg_value2.GetAsMemoryData( + altivec_reg2, + heap_data_ap->GetBytes() + altivec_reg->byte_size, + heap_data_ap->GetByteSize() - altivec_reg->byte_size, + byte_order, error)) { + DataExtractor data(DataBufferSP(heap_data_ap.release()), + byte_order, process_sp->GetTarget() + .GetArchitecture() + .GetAddressByteSize()); + return_valobj_sp = ValueObjectConstResult::Create( + &thread, return_compiler_type, ConstString(""), data); } + } } + } } + } } - - return return_valobj_sp; + } + + return return_valobj_sp; } -ValueObjectSP -ABISysV_x86_64::GetReturnValueObjectImpl (Thread &thread, CompilerType &return_compiler_type) const -{ - ValueObjectSP return_valobj_sp; - - if (!return_compiler_type) - return return_valobj_sp; - - ExecutionContext exe_ctx (thread.shared_from_this()); - return_valobj_sp = GetReturnValueObjectSimple(thread, return_compiler_type); - if (return_valobj_sp) - return return_valobj_sp; - - RegisterContextSP reg_ctx_sp = thread.GetRegisterContext(); - if (!reg_ctx_sp) - return return_valobj_sp; - - const size_t bit_width = return_compiler_type.GetBitSize(&thread); - if (return_compiler_type.IsAggregateType()) - { - Target *target = exe_ctx.GetTargetPtr(); - bool is_memory = true; - if (bit_width <= 128) - { - ByteOrder target_byte_order = target->GetArchitecture().GetByteOrder(); - DataBufferSP data_sp (new DataBufferHeap(16, 0)); - DataExtractor return_ext (data_sp, - target_byte_order, - target->GetArchitecture().GetAddressByteSize()); - - const RegisterInfo *rax_info = reg_ctx_sp->GetRegisterInfoByName("rax", 0); - const RegisterInfo *rdx_info = reg_ctx_sp->GetRegisterInfoByName("rdx", 0); - const RegisterInfo *xmm0_info = reg_ctx_sp->GetRegisterInfoByName("xmm0", 0); - const RegisterInfo *xmm1_info = reg_ctx_sp->GetRegisterInfoByName("xmm1", 0); - - RegisterValue rax_value, rdx_value, xmm0_value, xmm1_value; - reg_ctx_sp->ReadRegister (rax_info, rax_value); - reg_ctx_sp->ReadRegister (rdx_info, rdx_value); - reg_ctx_sp->ReadRegister (xmm0_info, xmm0_value); - reg_ctx_sp->ReadRegister (xmm1_info, xmm1_value); +ValueObjectSP ABISysV_x86_64::GetReturnValueObjectImpl( + Thread &thread, CompilerType &return_compiler_type) const { + ValueObjectSP return_valobj_sp; - DataExtractor rax_data, rdx_data, xmm0_data, xmm1_data; - - rax_value.GetData(rax_data); - rdx_value.GetData(rdx_data); - xmm0_value.GetData(xmm0_data); - xmm1_value.GetData(xmm1_data); - - uint32_t fp_bytes = 0; // Tracks how much of the xmm registers we've consumed so far - uint32_t integer_bytes = 0; // Tracks how much of the rax/rds registers we've consumed so far - - const uint32_t num_children = return_compiler_type.GetNumFields (); - - // Since we are in the small struct regime, assume we are not in memory. - is_memory = false; - - for (uint32_t idx = 0; idx < num_children; idx++) - { - std::string name; - uint64_t field_bit_offset = 0; - bool is_signed; - bool is_complex; - uint32_t count; - - CompilerType field_compiler_type = return_compiler_type.GetFieldAtIndex(idx, name, &field_bit_offset, nullptr, nullptr); - const size_t field_bit_width = field_compiler_type.GetBitSize(&thread); - - // if we don't know the size of the field (e.g. invalid type), just bail out - if (field_bit_width == 0) - break; - - // If there are any unaligned fields, this is stored in memory. - if (field_bit_offset % field_bit_width != 0) - { - is_memory = true; - break; - } - - uint32_t field_byte_width = field_bit_width/8; - uint32_t field_byte_offset = field_bit_offset/8; - - DataExtractor *copy_from_extractor = nullptr; - uint32_t copy_from_offset = 0; - - if (field_compiler_type.IsIntegerOrEnumerationType (is_signed) || field_compiler_type.IsPointerType ()) - { - if (integer_bytes < 8) - { - if (integer_bytes + field_byte_width <= 8) - { - // This is in RAX, copy from register to our result structure: - copy_from_extractor = &rax_data; - copy_from_offset = integer_bytes; - integer_bytes += field_byte_width; - } - else - { - // The next field wouldn't fit in the remaining space, so we pushed it to rdx. - copy_from_extractor = &rdx_data; - copy_from_offset = 0; - integer_bytes = 8 + field_byte_width; - } - } - else if (integer_bytes + field_byte_width <= 16) - { - copy_from_extractor = &rdx_data; - copy_from_offset = integer_bytes - 8; - integer_bytes += field_byte_width; - } - else - { - // The last field didn't fit. I can't see how that would happen w/o the overall size being - // greater than 16 bytes. For now, return a nullptr return value object. - return return_valobj_sp; - } + if (!return_compiler_type) + return return_valobj_sp; + + ExecutionContext exe_ctx(thread.shared_from_this()); + return_valobj_sp = GetReturnValueObjectSimple(thread, return_compiler_type); + if (return_valobj_sp) + return return_valobj_sp; + + RegisterContextSP reg_ctx_sp = thread.GetRegisterContext(); + if (!reg_ctx_sp) + return return_valobj_sp; + + const size_t bit_width = return_compiler_type.GetBitSize(&thread); + if (return_compiler_type.IsAggregateType()) { + Target *target = exe_ctx.GetTargetPtr(); + bool is_memory = true; + if (bit_width <= 128) { + ByteOrder target_byte_order = target->GetArchitecture().GetByteOrder(); + DataBufferSP data_sp(new DataBufferHeap(16, 0)); + DataExtractor return_ext(data_sp, target_byte_order, + target->GetArchitecture().GetAddressByteSize()); + + const RegisterInfo *rax_info = + reg_ctx_sp->GetRegisterInfoByName("rax", 0); + const RegisterInfo *rdx_info = + reg_ctx_sp->GetRegisterInfoByName("rdx", 0); + const RegisterInfo *xmm0_info = + reg_ctx_sp->GetRegisterInfoByName("xmm0", 0); + const RegisterInfo *xmm1_info = + reg_ctx_sp->GetRegisterInfoByName("xmm1", 0); + + RegisterValue rax_value, rdx_value, xmm0_value, xmm1_value; + reg_ctx_sp->ReadRegister(rax_info, rax_value); + reg_ctx_sp->ReadRegister(rdx_info, rdx_value); + reg_ctx_sp->ReadRegister(xmm0_info, xmm0_value); + reg_ctx_sp->ReadRegister(xmm1_info, xmm1_value); + + DataExtractor rax_data, rdx_data, xmm0_data, xmm1_data; + + rax_value.GetData(rax_data); + rdx_value.GetData(rdx_data); + xmm0_value.GetData(xmm0_data); + xmm1_value.GetData(xmm1_data); + + uint32_t fp_bytes = + 0; // Tracks how much of the xmm registers we've consumed so far + uint32_t integer_bytes = + 0; // Tracks how much of the rax/rds registers we've consumed so far + + const uint32_t num_children = return_compiler_type.GetNumFields(); + + // Since we are in the small struct regime, assume we are not in memory. + is_memory = false; + + for (uint32_t idx = 0; idx < num_children; idx++) { + std::string name; + uint64_t field_bit_offset = 0; + bool is_signed; + bool is_complex; + uint32_t count; + + CompilerType field_compiler_type = return_compiler_type.GetFieldAtIndex( + idx, name, &field_bit_offset, nullptr, nullptr); + const size_t field_bit_width = field_compiler_type.GetBitSize(&thread); + + // if we don't know the size of the field (e.g. invalid type), just bail + // out + if (field_bit_width == 0) + break; + + // If there are any unaligned fields, this is stored in memory. + if (field_bit_offset % field_bit_width != 0) { + is_memory = true; + break; + } + + uint32_t field_byte_width = field_bit_width / 8; + uint32_t field_byte_offset = field_bit_offset / 8; + + DataExtractor *copy_from_extractor = nullptr; + uint32_t copy_from_offset = 0; + + if (field_compiler_type.IsIntegerOrEnumerationType(is_signed) || + field_compiler_type.IsPointerType()) { + if (integer_bytes < 8) { + if (integer_bytes + field_byte_width <= 8) { + // This is in RAX, copy from register to our result structure: + copy_from_extractor = &rax_data; + copy_from_offset = integer_bytes; + integer_bytes += field_byte_width; + } else { + // The next field wouldn't fit in the remaining space, so we + // pushed it to rdx. + copy_from_extractor = &rdx_data; + copy_from_offset = 0; + integer_bytes = 8 + field_byte_width; + } + } else if (integer_bytes + field_byte_width <= 16) { + copy_from_extractor = &rdx_data; + copy_from_offset = integer_bytes - 8; + integer_bytes += field_byte_width; + } else { + // The last field didn't fit. I can't see how that would happen w/o + // the overall size being + // greater than 16 bytes. For now, return a nullptr return value + // object. + return return_valobj_sp; + } + } else if (field_compiler_type.IsFloatingPointType(count, is_complex)) { + // Structs with long doubles are always passed in memory. + if (field_bit_width == 128) { + is_memory = true; + break; + } else if (field_bit_width == 64) { + // These have to be in a single xmm register. + if (fp_bytes == 0) + copy_from_extractor = &xmm0_data; + else + copy_from_extractor = &xmm1_data; + + copy_from_offset = 0; + fp_bytes += field_byte_width; + } else if (field_bit_width == 32) { + // This one is kind of complicated. If we are in an "eightbyte" + // with another float, we'll + // be stuffed into an xmm register with it. If we are in an + // "eightbyte" with one or more ints, + // then we will be stuffed into the appropriate GPR with them. + bool in_gpr; + if (field_byte_offset % 8 == 0) { + // We are at the beginning of one of the eightbytes, so check the + // next element (if any) + if (idx == num_children - 1) + in_gpr = false; + else { + uint64_t next_field_bit_offset = 0; + CompilerType next_field_compiler_type = + return_compiler_type.GetFieldAtIndex(idx + 1, name, + &next_field_bit_offset, + nullptr, nullptr); + if (next_field_compiler_type.IsIntegerOrEnumerationType( + is_signed)) + in_gpr = true; + else { + copy_from_offset = 0; + in_gpr = false; } - else if (field_compiler_type.IsFloatingPointType (count, is_complex)) - { - // Structs with long doubles are always passed in memory. - if (field_bit_width == 128) - { - is_memory = true; - break; - } - else if (field_bit_width == 64) - { - // These have to be in a single xmm register. - if (fp_bytes == 0) - copy_from_extractor = &xmm0_data; - else - copy_from_extractor = &xmm1_data; - - copy_from_offset = 0; - fp_bytes += field_byte_width; - } - else if (field_bit_width == 32) - { - // This one is kind of complicated. If we are in an "eightbyte" with another float, we'll - // be stuffed into an xmm register with it. If we are in an "eightbyte" with one or more ints, - // then we will be stuffed into the appropriate GPR with them. - bool in_gpr; - if (field_byte_offset % 8 == 0) - { - // We are at the beginning of one of the eightbytes, so check the next element (if any) - if (idx == num_children - 1) - in_gpr = false; - else - { - uint64_t next_field_bit_offset = 0; - CompilerType next_field_compiler_type = return_compiler_type.GetFieldAtIndex (idx + 1, - name, - &next_field_bit_offset, - nullptr, - nullptr); - if (next_field_compiler_type.IsIntegerOrEnumerationType (is_signed)) - in_gpr = true; - else - { - copy_from_offset = 0; - in_gpr = false; - } - } - } - else if (field_byte_offset % 4 == 0) - { - // We are inside of an eightbyte, so see if the field before us is floating point: - // This could happen if somebody put padding in the structure. - if (idx == 0) - in_gpr = false; - else - { - uint64_t prev_field_bit_offset = 0; - CompilerType prev_field_compiler_type = return_compiler_type.GetFieldAtIndex (idx - 1, - name, - &prev_field_bit_offset, - nullptr, - nullptr); - if (prev_field_compiler_type.IsIntegerOrEnumerationType (is_signed)) - in_gpr = true; - else - { - copy_from_offset = 4; - in_gpr = false; - } - } - } - else - { - is_memory = true; - continue; - } - - // Okay, we've figured out whether we are in GPR or XMM, now figure out which one. - if (in_gpr) - { - if (integer_bytes < 8) - { - // This is in RAX, copy from register to our result structure: - copy_from_extractor = &rax_data; - copy_from_offset = integer_bytes; - integer_bytes += field_byte_width; - } - else - { - copy_from_extractor = &rdx_data; - copy_from_offset = integer_bytes - 8; - integer_bytes += field_byte_width; - } - } - else - { - if (fp_bytes < 8) - copy_from_extractor = &xmm0_data; - else - copy_from_extractor = &xmm1_data; - - fp_bytes += field_byte_width; - } - } + } + } else if (field_byte_offset % 4 == 0) { + // We are inside of an eightbyte, so see if the field before us is + // floating point: + // This could happen if somebody put padding in the structure. + if (idx == 0) + in_gpr = false; + else { + uint64_t prev_field_bit_offset = 0; + CompilerType prev_field_compiler_type = + return_compiler_type.GetFieldAtIndex(idx - 1, name, + &prev_field_bit_offset, + nullptr, nullptr); + if (prev_field_compiler_type.IsIntegerOrEnumerationType( + is_signed)) + in_gpr = true; + else { + copy_from_offset = 4; + in_gpr = false; } - - // These two tests are just sanity checks. If I somehow get the - // type calculation wrong above it is better to just return nothing - // than to assert or crash. - if (!copy_from_extractor) - return return_valobj_sp; - if (copy_from_offset + field_byte_width > copy_from_extractor->GetByteSize()) - return return_valobj_sp; - - copy_from_extractor->CopyByteOrderedData (copy_from_offset, - field_byte_width, - data_sp->GetBytes() + field_byte_offset, - field_byte_width, - target_byte_order); + } + } else { + is_memory = true; + continue; } - - if (!is_memory) - { - // The result is in our data buffer. Let's make a variable object out of it: - return_valobj_sp = ValueObjectConstResult::Create (&thread, - return_compiler_type, - ConstString(""), - return_ext); + + // Okay, we've figured out whether we are in GPR or XMM, now figure + // out which one. + if (in_gpr) { + if (integer_bytes < 8) { + // This is in RAX, copy from register to our result structure: + copy_from_extractor = &rax_data; + copy_from_offset = integer_bytes; + integer_bytes += field_byte_width; + } else { + copy_from_extractor = &rdx_data; + copy_from_offset = integer_bytes - 8; + integer_bytes += field_byte_width; + } + } else { + if (fp_bytes < 8) + copy_from_extractor = &xmm0_data; + else + copy_from_extractor = &xmm1_data; + + fp_bytes += field_byte_width; } + } } - // FIXME: This is just taking a guess, rax may very well no longer hold the return storage location. - // If we are going to do this right, when we make a new frame we should check to see if it uses a memory - // return, and if we are at the first instruction and if so stash away the return location. Then we would - // only return the memory return value if we know it is valid. - - if (is_memory) - { - unsigned rax_id = reg_ctx_sp->GetRegisterInfoByName("rax", 0)->kinds[eRegisterKindLLDB]; - lldb::addr_t storage_addr = (uint64_t)thread.GetRegisterContext()->ReadRegisterAsUnsigned(rax_id, 0); - return_valobj_sp = ValueObjectMemory::Create(&thread, - "", - Address(storage_addr, nullptr), - return_compiler_type); - } + // These two tests are just sanity checks. If I somehow get the + // type calculation wrong above it is better to just return nothing + // than to assert or crash. + if (!copy_from_extractor) + return return_valobj_sp; + if (copy_from_offset + field_byte_width > + copy_from_extractor->GetByteSize()) + return return_valobj_sp; + + copy_from_extractor->CopyByteOrderedData( + copy_from_offset, field_byte_width, + data_sp->GetBytes() + field_byte_offset, field_byte_width, + target_byte_order); + } + + if (!is_memory) { + // The result is in our data buffer. Let's make a variable object out + // of it: + return_valobj_sp = ValueObjectConstResult::Create( + &thread, return_compiler_type, ConstString(""), return_ext); + } } - - return return_valobj_sp; + + // FIXME: This is just taking a guess, rax may very well no longer hold the + // return storage location. + // If we are going to do this right, when we make a new frame we should + // check to see if it uses a memory + // return, and if we are at the first instruction and if so stash away the + // return location. Then we would + // only return the memory return value if we know it is valid. + + if (is_memory) { + unsigned rax_id = + reg_ctx_sp->GetRegisterInfoByName("rax", 0)->kinds[eRegisterKindLLDB]; + lldb::addr_t storage_addr = + (uint64_t)thread.GetRegisterContext()->ReadRegisterAsUnsigned(rax_id, + 0); + return_valobj_sp = ValueObjectMemory::Create( + &thread, "", Address(storage_addr, nullptr), return_compiler_type); + } + } + + return return_valobj_sp; } // This defines the CFA as rsp+8 // the saved pc is at CFA-8 (i.e. rsp+0) // The saved rsp is CFA+0 -bool -ABISysV_x86_64::CreateFunctionEntryUnwindPlan (UnwindPlan &unwind_plan) -{ - unwind_plan.Clear(); - unwind_plan.SetRegisterKind (eRegisterKindDWARF); - - uint32_t sp_reg_num = dwarf_rsp; - uint32_t pc_reg_num = dwarf_rip; - - UnwindPlan::RowSP row(new UnwindPlan::Row); - row->GetCFAValue().SetIsRegisterPlusOffset(sp_reg_num, 8); - row->SetRegisterLocationToAtCFAPlusOffset(pc_reg_num, -8, false); - row->SetRegisterLocationToIsCFAPlusOffset(sp_reg_num, 0, true); - unwind_plan.AppendRow (row); - unwind_plan.SetSourceName ("x86_64 at-func-entry default"); - unwind_plan.SetSourcedFromCompiler (eLazyBoolNo); - return true; +bool ABISysV_x86_64::CreateFunctionEntryUnwindPlan(UnwindPlan &unwind_plan) { + unwind_plan.Clear(); + unwind_plan.SetRegisterKind(eRegisterKindDWARF); + + uint32_t sp_reg_num = dwarf_rsp; + uint32_t pc_reg_num = dwarf_rip; + + UnwindPlan::RowSP row(new UnwindPlan::Row); + row->GetCFAValue().SetIsRegisterPlusOffset(sp_reg_num, 8); + row->SetRegisterLocationToAtCFAPlusOffset(pc_reg_num, -8, false); + row->SetRegisterLocationToIsCFAPlusOffset(sp_reg_num, 0, true); + unwind_plan.AppendRow(row); + unwind_plan.SetSourceName("x86_64 at-func-entry default"); + unwind_plan.SetSourcedFromCompiler(eLazyBoolNo); + return true; } // This defines the CFA as rbp+16 @@ -1053,137 +1868,114 @@ ABISysV_x86_64::CreateFunctionEntryUnwindPlan (UnwindPlan &unwind_plan) // The saved rbp is at CFA-16 (i.e. rbp+0) // The saved rsp is CFA+0 -bool -ABISysV_x86_64::CreateDefaultUnwindPlan (UnwindPlan &unwind_plan) -{ - unwind_plan.Clear(); - unwind_plan.SetRegisterKind (eRegisterKindDWARF); - - uint32_t fp_reg_num = dwarf_rbp; - uint32_t sp_reg_num = dwarf_rsp; - uint32_t pc_reg_num = dwarf_rip; - - UnwindPlan::RowSP row(new UnwindPlan::Row); - - const int32_t ptr_size = 8; - row->GetCFAValue().SetIsRegisterPlusOffset(dwarf_rbp, 2 * ptr_size); - row->SetOffset (0); - - row->SetRegisterLocationToAtCFAPlusOffset(fp_reg_num, ptr_size * -2, true); - row->SetRegisterLocationToAtCFAPlusOffset(pc_reg_num, ptr_size * -1, true); - row->SetRegisterLocationToIsCFAPlusOffset(sp_reg_num, 0, true); - - unwind_plan.AppendRow (row); - unwind_plan.SetSourceName ("x86_64 default unwind plan"); - unwind_plan.SetSourcedFromCompiler (eLazyBoolNo); - unwind_plan.SetUnwindPlanValidAtAllInstructions (eLazyBoolNo); - return true; +bool ABISysV_x86_64::CreateDefaultUnwindPlan(UnwindPlan &unwind_plan) { + unwind_plan.Clear(); + unwind_plan.SetRegisterKind(eRegisterKindDWARF); + + uint32_t fp_reg_num = dwarf_rbp; + uint32_t sp_reg_num = dwarf_rsp; + uint32_t pc_reg_num = dwarf_rip; + + UnwindPlan::RowSP row(new UnwindPlan::Row); + + const int32_t ptr_size = 8; + row->GetCFAValue().SetIsRegisterPlusOffset(dwarf_rbp, 2 * ptr_size); + row->SetOffset(0); + + row->SetRegisterLocationToAtCFAPlusOffset(fp_reg_num, ptr_size * -2, true); + row->SetRegisterLocationToAtCFAPlusOffset(pc_reg_num, ptr_size * -1, true); + row->SetRegisterLocationToIsCFAPlusOffset(sp_reg_num, 0, true); + + unwind_plan.AppendRow(row); + unwind_plan.SetSourceName("x86_64 default unwind plan"); + unwind_plan.SetSourcedFromCompiler(eLazyBoolNo); + unwind_plan.SetUnwindPlanValidAtAllInstructions(eLazyBoolNo); + return true; } -bool -ABISysV_x86_64::RegisterIsVolatile (const RegisterInfo *reg_info) -{ - return !RegisterIsCalleeSaved (reg_info); +bool ABISysV_x86_64::RegisterIsVolatile(const RegisterInfo *reg_info) { + return !RegisterIsCalleeSaved(reg_info); } -// See "Register Usage" in the +// See "Register Usage" in the // "System V Application Binary Interface" -// "AMD64 Architecture Processor Supplement" +// "AMD64 Architecture Processor Supplement" // (or "x86-64(tm) Architecture Processor Supplement" in earlier revisions) // (this doc is also commonly referred to as the x86-64/AMD64 psABI) // Edited by Michael Matz, Jan Hubicka, Andreas Jaeger, and Mark Mitchell -// current version is 0.99.6 released 2012-07-02 at http://refspecs.linuxfoundation.org/elf/x86-64-abi-0.99.pdf +// current version is 0.99.6 released 2012-07-02 at +// http://refspecs.linuxfoundation.org/elf/x86-64-abi-0.99.pdf // It's being revised & updated at https://github.com/hjl-tools/x86-psABI/ -bool -ABISysV_x86_64::RegisterIsCalleeSaved (const RegisterInfo *reg_info) -{ - if (reg_info) - { - // Preserved registers are : - // rbx, rsp, rbp, r12, r13, r14, r15 - // mxcsr (partially preserved) - // x87 control word - - const char *name = reg_info->name; - if (name[0] == 'r') - { - switch (name[1]) - { - case '1': // r12, r13, r14, r15 - if (name[2] >= '2' && name[2] <= '5') - return name[3] == '\0'; - break; - - default: - break; - } - } +bool ABISysV_x86_64::RegisterIsCalleeSaved(const RegisterInfo *reg_info) { + if (reg_info) { + // Preserved registers are : + // rbx, rsp, rbp, r12, r13, r14, r15 + // mxcsr (partially preserved) + // x87 control word + + const char *name = reg_info->name; + if (name[0] == 'r') { + switch (name[1]) { + case '1': // r12, r13, r14, r15 + if (name[2] >= '2' && name[2] <= '5') + return name[3] == '\0'; + break; + + default: + break; + } + } - // Accept shorter-variant versions, rbx/ebx, rip/ eip, etc. - if (name[0] == 'r' || name[0] == 'e') - { - switch (name[1]) - { - case 'b': // rbp, rbx - if (name[2] == 'p' || name[2] == 'x') - return name[3] == '\0'; - break; - - case 'i': // rip - if (name[2] == 'p') - return name[3] == '\0'; - break; - - case 's': // rsp - if (name[2] == 'p') - return name[3] == '\0'; - break; - } - } - if (name[0] == 's' && name[1] == 'p' && name[2] == '\0') // sp - return true; - if (name[0] == 'f' && name[1] == 'p' && name[2] == '\0') // fp - return true; - if (name[0] == 'p' && name[1] == 'c' && name[2] == '\0') // pc - return true; + // Accept shorter-variant versions, rbx/ebx, rip/ eip, etc. + if (name[0] == 'r' || name[0] == 'e') { + switch (name[1]) { + case 'b': // rbp, rbx + if (name[2] == 'p' || name[2] == 'x') + return name[3] == '\0'; + break; + + case 'i': // rip + if (name[2] == 'p') + return name[3] == '\0'; + break; + + case 's': // rsp + if (name[2] == 'p') + return name[3] == '\0'; + break; + } } - return false; + if (name[0] == 's' && name[1] == 'p' && name[2] == '\0') // sp + return true; + if (name[0] == 'f' && name[1] == 'p' && name[2] == '\0') // fp + return true; + if (name[0] == 'p' && name[1] == 'c' && name[2] == '\0') // pc + return true; + } + return false; } -void -ABISysV_x86_64::Initialize() -{ - PluginManager::RegisterPlugin (GetPluginNameStatic(), - "System V ABI for x86_64 targets", - CreateInstance); +void ABISysV_x86_64::Initialize() { + PluginManager::RegisterPlugin( + GetPluginNameStatic(), "System V ABI for x86_64 targets", CreateInstance); } -void -ABISysV_x86_64::Terminate() -{ - PluginManager::UnregisterPlugin (CreateInstance); +void ABISysV_x86_64::Terminate() { + PluginManager::UnregisterPlugin(CreateInstance); } -lldb_private::ConstString -ABISysV_x86_64::GetPluginNameStatic() -{ - static ConstString g_name("sysv-x86_64"); - return g_name; +lldb_private::ConstString ABISysV_x86_64::GetPluginNameStatic() { + static ConstString g_name("sysv-x86_64"); + return g_name; } //------------------------------------------------------------------ // PluginInterface protocol //------------------------------------------------------------------ -lldb_private::ConstString -ABISysV_x86_64::GetPluginName() -{ - return GetPluginNameStatic(); +lldb_private::ConstString ABISysV_x86_64::GetPluginName() { + return GetPluginNameStatic(); } -uint32_t -ABISysV_x86_64::GetPluginVersion() -{ - return 1; -} +uint32_t ABISysV_x86_64::GetPluginVersion() { return 1; } diff --git a/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.h b/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.h index 07b57abaf57c..29f2ce133d42 100644 --- a/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.h +++ b/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.h @@ -14,120 +14,102 @@ // C++ Includes // Other libraries and framework includes // Project includes -#include "lldb/lldb-private.h" #include "lldb/Target/ABI.h" +#include "lldb/lldb-private.h" -class ABISysV_x86_64 : - public lldb_private::ABI -{ +class ABISysV_x86_64 : public lldb_private::ABI { public: - ~ABISysV_x86_64() override = default; - - size_t - GetRedZoneSize() const override; - - bool - PrepareTrivialCall(lldb_private::Thread &thread, - lldb::addr_t sp, - lldb::addr_t functionAddress, - lldb::addr_t returnAddress, - llvm::ArrayRef<lldb::addr_t> args) const override; - - bool - GetArgumentValues(lldb_private::Thread &thread, - lldb_private::ValueList &values) const override; - - lldb_private::Error - SetReturnValueObject(lldb::StackFrameSP &frame_sp, lldb::ValueObjectSP &new_value) override; - - lldb::ValueObjectSP - GetReturnValueObjectImpl(lldb_private::Thread &thread, - lldb_private::CompilerType &type) const override; - - bool - CreateFunctionEntryUnwindPlan(lldb_private::UnwindPlan &unwind_plan) override; - - bool - CreateDefaultUnwindPlan(lldb_private::UnwindPlan &unwind_plan) override; - - bool - RegisterIsVolatile(const lldb_private::RegisterInfo *reg_info) override; - - // The SysV x86_64 ABI requires that stack frames be 16 byte aligned. - // When there is a trap handler on the stack, e.g. _sigtramp in userland - // code, we've seen that the stack pointer is often not aligned properly - // before the handler is invoked. This means that lldb will stop the unwind - // early -- before the function which caused the trap. - // - // To work around this, we relax that alignment to be just word-size (8-bytes). - // Whitelisting the trap handlers for user space would be easy (_sigtramp) but - // in other environments there can be a large number of different functions - // involved in async traps. - bool - CallFrameAddressIsValid(lldb::addr_t cfa) override - { - // Make sure the stack call frame addresses are 8 byte aligned - if (cfa & (8ull - 1ull)) - return false; // Not 8 byte aligned - if (cfa == 0) - return false; // Zero is not a valid stack address - return true; - } - - bool - CodeAddressIsValid(lldb::addr_t pc) override - { - // We have a 64 bit address space, so anything is valid as opcodes - // aren't fixed width... - return true; - } - - const lldb_private::RegisterInfo * - GetRegisterInfoArray(uint32_t &count) override; - - //------------------------------------------------------------------ - // Static Functions - //------------------------------------------------------------------ - - static void - Initialize(); - - static void - Terminate(); - - static lldb::ABISP - CreateInstance (const lldb_private::ArchSpec &arch); - - static lldb_private::ConstString - GetPluginNameStatic(); - - //------------------------------------------------------------------ - // PluginInterface protocol - //------------------------------------------------------------------ - - lldb_private::ConstString - GetPluginName() override; - - uint32_t - GetPluginVersion() override; + ~ABISysV_x86_64() override = default; + + size_t GetRedZoneSize() const override; + + bool PrepareTrivialCall(lldb_private::Thread &thread, lldb::addr_t sp, + lldb::addr_t functionAddress, + lldb::addr_t returnAddress, + llvm::ArrayRef<lldb::addr_t> args) const override; + + bool GetArgumentValues(lldb_private::Thread &thread, + lldb_private::ValueList &values) const override; + + lldb_private::Error + SetReturnValueObject(lldb::StackFrameSP &frame_sp, + lldb::ValueObjectSP &new_value) override; + + lldb::ValueObjectSP + GetReturnValueObjectImpl(lldb_private::Thread &thread, + lldb_private::CompilerType &type) const override; + + bool + CreateFunctionEntryUnwindPlan(lldb_private::UnwindPlan &unwind_plan) override; + + bool CreateDefaultUnwindPlan(lldb_private::UnwindPlan &unwind_plan) override; + + bool RegisterIsVolatile(const lldb_private::RegisterInfo *reg_info) override; + + // The SysV x86_64 ABI requires that stack frames be 16 byte aligned. + // When there is a trap handler on the stack, e.g. _sigtramp in userland + // code, we've seen that the stack pointer is often not aligned properly + // before the handler is invoked. This means that lldb will stop the unwind + // early -- before the function which caused the trap. + // + // To work around this, we relax that alignment to be just word-size + // (8-bytes). + // Whitelisting the trap handlers for user space would be easy (_sigtramp) but + // in other environments there can be a large number of different functions + // involved in async traps. + bool CallFrameAddressIsValid(lldb::addr_t cfa) override { + // Make sure the stack call frame addresses are 8 byte aligned + if (cfa & (8ull - 1ull)) + return false; // Not 8 byte aligned + if (cfa == 0) + return false; // Zero is not a valid stack address + return true; + } + + bool CodeAddressIsValid(lldb::addr_t pc) override { + // We have a 64 bit address space, so anything is valid as opcodes + // aren't fixed width... + return true; + } + + const lldb_private::RegisterInfo * + GetRegisterInfoArray(uint32_t &count) override; + + bool GetPointerReturnRegister(const char *&name) override; + + //------------------------------------------------------------------ + // Static Functions + //------------------------------------------------------------------ + + static void Initialize(); + + static void Terminate(); + + static lldb::ABISP CreateInstance(const lldb_private::ArchSpec &arch); + + static lldb_private::ConstString GetPluginNameStatic(); + + //------------------------------------------------------------------ + // PluginInterface protocol + //------------------------------------------------------------------ + + lldb_private::ConstString GetPluginName() override; + + uint32_t GetPluginVersion() override; protected: - void - CreateRegisterMapIfNeeded (); + void CreateRegisterMapIfNeeded(); - lldb::ValueObjectSP - GetReturnValueObjectSimple(lldb_private::Thread &thread, - lldb_private::CompilerType &ast_type) const; + lldb::ValueObjectSP + GetReturnValueObjectSimple(lldb_private::Thread &thread, + lldb_private::CompilerType &ast_type) const; - bool - RegisterIsCalleeSaved (const lldb_private::RegisterInfo *reg_info); + bool RegisterIsCalleeSaved(const lldb_private::RegisterInfo *reg_info); private: - ABISysV_x86_64() : - lldb_private::ABI() - { - // Call CreateInstance instead. - } + ABISysV_x86_64() : lldb_private::ABI() { + // Call CreateInstance instead. + } }; #endif // liblldb_ABISysV_x86_64_h_ |