aboutsummaryrefslogtreecommitdiffstats
path: root/source/Plugins/ABI
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2017-12-18 20:12:36 +0000
committerDimitry Andric <dim@FreeBSD.org>2017-12-18 20:12:36 +0000
commitef5d0b5e97ec8e6fa395d377b09aa7755e345b4f (patch)
tree27916256fdeeb57d10d2f3d6948be5d71a703215 /source/Plugins/ABI
parent76e0736e7fcfeb179779e49c05604464b1ccd704 (diff)
downloadsrc-ef5d0b5e97ec8e6fa395d377b09aa7755e345b4f.tar.gz
src-ef5d0b5e97ec8e6fa395d377b09aa7755e345b4f.zip
Vendor import of lldb trunk r321017:vendor/lldb/lldb-trunk-r321017
Notes
Notes: svn path=/vendor/lldb/dist/; revision=326949 svn path=/vendor/lldb/lldb-trunk-r321017/; revision=326950; tag=vendor/lldb/lldb-trunk-r321017
Diffstat (limited to 'source/Plugins/ABI')
-rw-r--r--source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.cpp9
-rw-r--r--source/Plugins/ABI/SysV-arm64/ABISysV_arm64.cpp2
-rw-r--r--source/Plugins/ABI/SysV-i386/ABISysV_i386.cpp11
-rw-r--r--source/Plugins/ABI/SysV-ppc/ABISysV_ppc.cpp41
-rw-r--r--source/Plugins/ABI/SysV-ppc64/ABISysV_ppc64.cpp41
-rw-r--r--source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.cpp99
6 files changed, 23 insertions, 180 deletions
diff --git a/source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.cpp b/source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.cpp
index fd5ee6ede4c3..1bd1c1bf8dd4 100644
--- a/source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.cpp
+++ b/source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.cpp
@@ -1413,10 +1413,6 @@ bool ABIMacOSX_arm::PrepareTrivialCall(Thread &thread, addr_t sp,
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());
@@ -1441,6 +1437,11 @@ bool ABIMacOSX_arm::PrepareTrivialCall(Thread &thread, addr_t sp,
function_addr &=
~1ull; // clear bit zero since the CPSR will take care of the mode for us
+ // Update the sp - stack pointer - to be aligned to 16-bytes
+ sp &= ~(0xfull);
+ if (!reg_ctx->WriteRegisterFromUnsigned(sp_reg_num, sp))
+ return false;
+
// Set "pc" to the address requested
if (!reg_ctx->WriteRegisterFromUnsigned(pc_reg_num, function_addr))
return false;
diff --git a/source/Plugins/ABI/SysV-arm64/ABISysV_arm64.cpp b/source/Plugins/ABI/SysV-arm64/ABISysV_arm64.cpp
index f91ed851a3e5..dbe333c4649e 100644
--- a/source/Plugins/ABI/SysV-arm64/ABISysV_arm64.cpp
+++ b/source/Plugins/ABI/SysV-arm64/ABISysV_arm64.cpp
@@ -2018,7 +2018,7 @@ bool ABISysV_arm64::RegisterIsVolatile(const RegisterInfo *reg_info) {
if (name[0] == 'l' && name[1] == 'r') // lr
return false;
- if (name[0] == 'x') {
+ if (name[0] == 'x' || name[0] == 'r') {
// Volatile registers: x0-x18
// Although documentation says only x19-28 + sp are callee saved
// We ll also have to treat x30 as non-volatile.
diff --git a/source/Plugins/ABI/SysV-i386/ABISysV_i386.cpp b/source/Plugins/ABI/SysV-i386/ABISysV_i386.cpp
index 63da5a77b48f..d799c587dd07 100644
--- a/source/Plugins/ABI/SysV-i386/ABISysV_i386.cpp
+++ b/source/Plugins/ABI/SysV-i386/ABISysV_i386.cpp
@@ -205,11 +205,12 @@ ABISysV_i386::GetRegisterInfoArray(uint32_t &count) {
ABISP
ABISysV_i386::CreateInstance(lldb::ProcessSP process_sp, 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(process_sp));
- return g_abi_sp;
+ if (arch.GetTriple().getVendor() != llvm::Triple::Apple) {
+ if (arch.GetTriple().getArch() == llvm::Triple::x86) {
+ if (!g_abi_sp)
+ g_abi_sp.reset(new ABISysV_i386(process_sp));
+ return g_abi_sp;
+ }
}
return ABISP();
}
diff --git a/source/Plugins/ABI/SysV-ppc/ABISysV_ppc.cpp b/source/Plugins/ABI/SysV-ppc/ABISysV_ppc.cpp
index 06a8ce932fda..2fee176739f3 100644
--- a/source/Plugins/ABI/SysV-ppc/ABISysV_ppc.cpp
+++ b/source/Plugins/ABI/SysV-ppc/ABISysV_ppc.cpp
@@ -291,47 +291,6 @@ bool ABISysV_ppc::PrepareTrivialCall(Thread &thread, addr_t sp,
RegisterValue reg_value;
-#if 0
- // This code adds an extra frame so that we don't lose the function that we came from
- // by pushing the PC and the FP and then writing the current FP to point to the FP value
- // we just pushed. It is disabled for now until the stack backtracing code can be debugged.
-
- // Save current PC
- const RegisterInfo *fp_reg_info = reg_ctx->GetRegisterInfo (eRegisterKindGeneric, LLDB_REGNUM_GENERIC_FP);
- if (reg_ctx->ReadRegister(pc_reg_info, reg_value))
- {
- if (log)
- log->Printf("Pushing the current PC onto the stack: 0x%" PRIx64 ": 0x%" PRIx64, (uint64_t)sp, reg_value.GetAsUInt64());
-
- if (!process_sp->WritePointerToMemory(sp, reg_value.GetAsUInt64(), error))
- return false;
-
- sp -= 8;
-
- // Save current FP
- if (reg_ctx->ReadRegister(fp_reg_info, reg_value))
- {
- if (log)
- log->Printf("Pushing the current FP onto the stack: 0x%" PRIx64 ": 0x%" PRIx64, (uint64_t)sp, reg_value.GetAsUInt64());
-
- if (!process_sp->WritePointerToMemory(sp, reg_value.GetAsUInt64(), error))
- return false;
- }
- // Setup FP backchain
- reg_value.SetUInt64 (sp);
-
- if (log)
- log->Printf("Writing FP: 0x%" PRIx64 " (for FP backchain)", reg_value.GetAsUInt64());
-
- if (!reg_ctx->WriteRegister(fp_reg_info, reg_value))
- {
- return false;
- }
-
- sp -= 8;
- }
-#endif
-
if (log)
log->Printf("Pushing the return address onto the stack: 0x%" PRIx64
": 0x%" PRIx64,
diff --git a/source/Plugins/ABI/SysV-ppc64/ABISysV_ppc64.cpp b/source/Plugins/ABI/SysV-ppc64/ABISysV_ppc64.cpp
index c090f01ccb1c..0348853c7fa0 100644
--- a/source/Plugins/ABI/SysV-ppc64/ABISysV_ppc64.cpp
+++ b/source/Plugins/ABI/SysV-ppc64/ABISysV_ppc64.cpp
@@ -291,47 +291,6 @@ bool ABISysV_ppc64::PrepareTrivialCall(Thread &thread, addr_t sp,
RegisterValue reg_value;
-#if 0
- // This code adds an extra frame so that we don't lose the function that we came from
- // by pushing the PC and the FP and then writing the current FP to point to the FP value
- // we just pushed. It is disabled for now until the stack backtracing code can be debugged.
-
- // Save current PC
- const RegisterInfo *fp_reg_info = reg_ctx->GetRegisterInfo (eRegisterKindGeneric, LLDB_REGNUM_GENERIC_FP);
- if (reg_ctx->ReadRegister(pc_reg_info, reg_value))
- {
- if (log)
- log->Printf("Pushing the current PC onto the stack: 0x%" PRIx64 ": 0x%" PRIx64, (uint64_t)sp, reg_value.GetAsUInt64());
-
- if (!process_sp->WritePointerToMemory(sp, reg_value.GetAsUInt64(), error))
- return false;
-
- sp -= 8;
-
- // Save current FP
- if (reg_ctx->ReadRegister(fp_reg_info, reg_value))
- {
- if (log)
- log->Printf("Pushing the current FP onto the stack: 0x%" PRIx64 ": 0x%" PRIx64, (uint64_t)sp, reg_value.GetAsUInt64());
-
- if (!process_sp->WritePointerToMemory(sp, reg_value.GetAsUInt64(), error))
- return false;
- }
- // Setup FP backchain
- reg_value.SetUInt64 (sp);
-
- if (log)
- log->Printf("Writing FP: 0x%" PRIx64 " (for FP backchain)", reg_value.GetAsUInt64());
-
- if (!reg_ctx->WriteRegister(fp_reg_info, reg_value))
- {
- return false;
- }
-
- sp -= 8;
- }
-#endif
-
if (log)
log->Printf("Pushing the return address onto the stack: 0x%" PRIx64
": 0x%" PRIx64,
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 10bbae566491..41d146f24526 100644
--- a/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.cpp
+++ b/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.cpp
@@ -13,6 +13,7 @@
// C++ Includes
// Other libraries and framework includes
#include "llvm/ADT/STLExtras.h"
+#include "llvm/ADT/StringSwitch.h"
#include "llvm/ADT/Triple.h"
// Project includes
@@ -1160,48 +1161,6 @@ bool ABISysV_x86_64::PrepareTrivialCall(Thread &thread, addr_t 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
- // by pushing the PC and the FP and then writing the current FP to point to the FP value
- // we just pushed. It is disabled for now until the stack backtracing code can be debugged.
-
- // Save current PC
- const RegisterInfo *fp_reg_info = reg_ctx->GetRegisterInfo (eRegisterKindGeneric, LLDB_REGNUM_GENERIC_FP);
- if (reg_ctx->ReadRegister(pc_reg_info, reg_value))
- {
- if (log)
- log->Printf("Pushing the current PC onto the stack: 0x%" PRIx64 ": 0x%" PRIx64, (uint64_t)sp, reg_value.GetAsUInt64());
-
- if (!process_sp->WritePointerToMemory(sp, reg_value.GetAsUInt64(), error))
- return false;
-
- sp -= 8;
-
- // Save current FP
- if (reg_ctx->ReadRegister(fp_reg_info, reg_value))
- {
- if (log)
- log->Printf("Pushing the current FP onto the stack: 0x%" PRIx64 ": 0x%" PRIx64, (uint64_t)sp, reg_value.GetAsUInt64());
-
- if (!process_sp->WritePointerToMemory(sp, reg_value.GetAsUInt64(), error))
- return false;
- }
- // Setup FP backchain
- reg_value.SetUInt64 (sp);
-
- if (log)
- log->Printf("Writing FP: 0x%" PRIx64 " (for FP backchain)", reg_value.GetAsUInt64());
-
- if (!reg_ctx->WriteRegister(fp_reg_info, reg_value))
- {
- return false;
- }
-
- sp -= 8;
- }
-#endif
-
if (log)
log->Printf("Pushing the return address onto the stack: 0x%" PRIx64
": 0x%" PRIx64,
@@ -1908,52 +1867,16 @@ bool ABISysV_x86_64::RegisterIsVolatile(const RegisterInfo *reg_info) {
// 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;
- }
- }
-
- // 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;
- }
- return false;
+ if (!reg_info)
+ return false;
+ assert(reg_info->name != nullptr && "unnamed register?");
+ std::string Name = std::string(reg_info->name);
+ bool IsCalleeSaved =
+ llvm::StringSwitch<bool>(Name)
+ .Cases("r12", "r13", "r14", "r15", "rbp", "ebp", "rbx", "ebx", true)
+ .Cases("rip", "eip", "rsp", "esp", "sp", "fp", "pc", true)
+ .Default(false);
+ return IsCalleeSaved;
}
void ABISysV_x86_64::Initialize() {