13 #include "llvm/ADT/STLExtras.h"
14 #include "llvm/ADT/Triple.h"
1195 const lldb_private::RegisterInfo *
1207 const llvm::Triple::ArchType arch_type = arch.
GetTriple().getArch();
1208 const llvm::Triple::VendorType vendor_type = arch.
GetTriple().getVendor();
1210 if (vendor_type != llvm::Triple::Apple) {
1211 if ((arch_type == llvm::Triple::arm) ||
1212 (arch_type == llvm::Triple::thumb)) {
1214 new ABISysV_arm(std::move(process_sp), MakeMCRegisterInfo(arch)));
1223 llvm::ArrayRef<addr_t> args)
const {
1237 const uint8_t reg_names[] = {
1241 llvm::ArrayRef<addr_t>::iterator ai = args.begin(), ae = args.end();
1243 for (
size_t i = 0; i < llvm::array_lengthof(reg_names); ++i) {
1258 size_t num_stack_regs = ae - ai;
1260 sp -= (num_stack_regs * 4);
1262 sp &= ~(8ull - 1ull);
1270 for (; ai != ae; ++ai) {
1273 ->WriteRegisterValueToMemory(reg_info, arg_pos,
1274 reg_info->byte_size, reg_value)
1277 arg_pos += reg_info->byte_size;
1303 const RegisterInfo *cpsr_reg_info =
1310 if (function_addr & 1ull)
1315 if (new_cpsr != curr_cpsr) {
1343 for (
uint32_t value_idx = 0; value_idx < num_values; ++value_idx) {
1352 if (compiler_type) {
1353 bool is_signed =
false;
1354 size_t bit_width = 0;
1357 if (llvm::Optional<uint64_t> size = compiler_type.
GetBitSize(&thread))
1365 if (value_idx < 4) {
1367 const RegisterInfo *arg_reg_info =
nullptr;
1391 const uint32_t arg_byte_size = (bit_width + (8 - 1)) / 8;
1397 sp += arg_byte_size;
1407 size_t byte_size,
Value &value) {
1411 const RegisterInfo *r0_reg_info =
1415 thread.
GetProcess()->ReadMemory(address, buffer.GetBytes(),
1428 const ArchSpec &arch(process_sp->GetTarget().GetArchitecture());
1430 return (arch.
GetFlags() & ArchSpec::eARM_abi_hard_float) != 0;
1439 ValueObjectSP return_valobj_sp;
1442 return return_valobj_sp;
1450 return return_valobj_sp;
1455 bool is_vfp_candidate =
false;
1456 uint8_t vfp_count = 0;
1457 uint8_t vfp_byte_size = 0;
1462 const RegisterInfo *r0_reg_info =
1464 llvm::Optional<uint64_t> bit_width = compiler_type.
GetBitSize(&thread);
1465 llvm::Optional<uint64_t> byte_size = compiler_type.
GetByteSize(&thread);
1466 if (!bit_width || !byte_size)
1467 return return_valobj_sp;
1470 switch (*bit_width) {
1472 return return_valobj_sp;
1484 value.
GetScalar() = (uint64_t)raw_value;
1517 if (IsArmHardFloat(thread) && (*byte_size == 8 || *byte_size == 16)) {
1518 is_vfp_candidate =
true;
1520 vfp_count = (*byte_size == 8 ? 1 : 2);
1521 }
else if (*byte_size <= 16) {
1525 for (
uint32_t i = 0; 4 * i < *byte_size; ++i) {
1531 value.
SetBytes(buffer.GetBytes(), *byte_size);
1534 return return_valobj_sp;
1537 if (float_count == 1 && !is_complex) {
1538 switch (*bit_width) {
1540 return return_valobj_sp;
1542 static_assert(
sizeof(
double) ==
sizeof(uint64_t),
"");
1544 if (IsArmHardFloat(thread)) {
1546 const RegisterInfo *d0_reg_info =
1560 value.
GetScalar() = *
reinterpret_cast<double *
>(&raw_value);
1566 static_assert(
sizeof(
float) ==
sizeof(
uint32_t),
"");
1568 if (IsArmHardFloat(thread)) {
1570 const RegisterInfo *s0_reg_info =
1578 value.
GetScalar() = *
reinterpret_cast<float *
>(&raw_value);
1583 }
else if (is_complex && float_count == 2) {
1584 if (IsArmHardFloat(thread)) {
1585 is_vfp_candidate =
true;
1586 vfp_byte_size = *byte_size / 2;
1590 return return_valobj_sp;
1593 return return_valobj_sp;
1595 if (IsArmHardFloat(thread)) {
1600 if (homogeneous_count > 0 && homogeneous_count <= 4) {
1601 llvm::Optional<uint64_t> base_byte_size =
1604 if (base_byte_size &&
1605 (*base_byte_size == 8 || *base_byte_size == 16)) {
1606 is_vfp_candidate =
true;
1608 vfp_count = (*base_byte_size == 8 ? homogeneous_count
1609 : homogeneous_count * 2);
1612 if (float_count == 1 && !is_complex) {
1613 is_vfp_candidate =
true;
1615 vfp_byte_size = *base_byte_size;
1616 vfp_count = homogeneous_count;
1619 }
else if (homogeneous_count == 0) {
1622 if (num_children > 0 && num_children <= 2) {
1624 for (index = 0; index < num_children; index++) {
1630 llvm::Optional<uint64_t> base_byte_size =
1632 if (float_count == 2 && is_complex) {
1633 if (index != 0 && base_byte_size &&
1634 vfp_byte_size != *base_byte_size)
1636 else if (base_byte_size)
1637 vfp_byte_size = *base_byte_size;
1644 if (index == num_children) {
1645 is_vfp_candidate =
true;
1646 vfp_byte_size = (vfp_byte_size >> 1);
1647 vfp_count = (num_children << 1);
1653 if (*byte_size <= 4) {
1657 value.
SetBytes(&raw_value, *byte_size);
1658 }
else if (!is_vfp_candidate) {
1660 return return_valobj_sp;
1664 return return_valobj_sp;
1667 if (is_vfp_candidate) {
1669 ByteOrder byte_order = process_sp->GetByteOrder();
1674 for (
uint32_t reg_index = 0; reg_index < vfp_count; reg_index++) {
1677 if (vfp_byte_size == 4)
1679 else if (vfp_byte_size == 8)
1684 const RegisterInfo *reg_info =
1686 if (reg_info ==
nullptr)
1694 if ((data_offset + vfp_byte_size) <= data_sp->GetByteSize()) {
1697 reg_info, data_sp->GetBytes() + data_offset, vfp_byte_size,
1699 if (bytes_copied != vfp_byte_size)
1702 data_offset += bytes_copied;
1706 if (data_offset == *byte_size) {
1712 return ValueObjectConstResult::Create(&thread, compiler_type,
1715 return return_valobj_sp;
1721 return_valobj_sp = ValueObjectConstResult::Create(
1723 return return_valobj_sp;
1727 lldb::ValueObjectSP &new_value_sp) {
1729 if (!new_value_sp) {
1730 error.SetErrorString(
"Empty value object for return value.");
1734 CompilerType compiler_type = new_value_sp->GetCompilerType();
1735 if (!compiler_type) {
1736 error.SetErrorString(
"Null clang type for return value.");
1740 Thread *thread = frame_sp->GetThread().get();
1748 bool set_it_simple =
false;
1753 size_t num_bytes = new_value_sp->GetData(data, data_error);
1754 if (data_error.
Fail()) {
1755 error.SetErrorStringWithFormat(
1756 "Couldn't convert return value to raw data: %s",
1761 if (num_bytes <= 8) {
1764 if (num_bytes <= 4) {
1768 set_it_simple =
true;
1778 set_it_simple =
true;
1782 error.SetErrorString(
"We don't support returning longer than 64 bit "
1783 "integer values at present.");
1787 error.SetErrorString(
1788 "We don't support returning complex values at present");
1790 error.SetErrorString(
1791 "We don't support returning float values at present");
1795 error.SetErrorString(
1796 "We only support setting simple integer return types at present.");
1802 unwind_plan.
Clear();
1812 row->GetCFAValue().SetIsRegisterPlusOffset(sp_reg_num, 0);
1815 row->SetRegisterLocationToRegister(pc_reg_num, lr_reg_num,
true);
1827 unwind_plan.
Clear();
1835 const int32_t ptr_size = 4;
1837 row->GetCFAValue().SetIsRegisterPlusOffset(fp_reg_num, 2 * ptr_size);
1839 row->SetUnspecifiedRegistersAreUndefined(
true);
1841 row->SetRegisterLocationToAtCFAPlusOffset(fp_reg_num, ptr_size * -2,
true);
1842 row->SetRegisterLocationToAtCFAPlusOffset(pc_reg_num, ptr_size * -1,
true);
1872 const char *name = reg_info->name;
1873 if (name[0] ==
'r') {
1876 return name[2] ==
'\0';
1882 return name[3] ==
'\0';
1889 return name[2] ==
'\0';
1891 return name[2] ==
'\0';
1895 }
else if (name[0] ==
'd') {
1898 return name[2] ==
'\0';
1908 return name[3] ==
'\0';
1928 return name[3] ==
'\0';
1940 return name[3] ==
'\0';
1949 return name[2] ==
'\0';
1954 }
else if (name[0] ==
's') {
1957 return name[2] ==
'\0';
1969 return name[3] ==
'\0';
1983 return name[2] ==
'\0';
1988 }
else if (name[0] ==
'q') {
2009 return name[2] ==
'\0';
2012 return name[2] ==
'\0';
2016 }
else if (name[0] ==
's' && name[1] ==
'p' && name[2] ==
'\0')
2023 PluginManager::RegisterPlugin(GetPluginNameStatic(),
2024 "SysV ABI for arm targets", CreateInstance);
2028 PluginManager::UnregisterPlugin(CreateInstance);