aboutsummaryrefslogtreecommitdiff
path: root/lldb/source/Target/ABI.cpp
diff options
context:
space:
mode:
authorKate Stone <katherine.stone@apple.com>2016-09-06 20:57:50 +0000
committerKate Stone <katherine.stone@apple.com>2016-09-06 20:57:50 +0000
commitb9c1b51e45b845debb76d8658edabca70ca56079 (patch)
treedfcb5a13ef2b014202340f47036da383eaee74aa /lldb/source/Target/ABI.cpp
parentd5aa73376966339caad04013510626ec2e42c760 (diff)
downloadllvm-b9c1b51e45b845debb76d8658edabca70ca56079.zip
llvm-b9c1b51e45b845debb76d8658edabca70ca56079.tar.gz
llvm-b9c1b51e45b845debb76d8658edabca70ca56079.tar.bz2
*** This commit represents a complete reformatting of the LLDB source code
*** to conform to clang-format’s LLVM style. This kind of mass change has *** two obvious implications: Firstly, merging this particular commit into a downstream fork may be a huge effort. Alternatively, it may be worth merging all changes up to this commit, performing the same reformatting operation locally, and then discarding the merge for this particular commit. The commands used to accomplish this reformatting were as follows (with current working directory as the root of the repository): find . \( -iname "*.c" -or -iname "*.cpp" -or -iname "*.h" -or -iname "*.mm" \) -exec clang-format -i {} + find . -iname "*.py" -exec autopep8 --in-place --aggressive --aggressive {} + ; The version of clang-format used was 3.9.0, and autopep8 was 1.2.4. Secondly, “blame” style tools will generally point to this commit instead of a meaningful prior commit. There are alternatives available that will attempt to look through this change and find the appropriate prior commit. YMMV. llvm-svn: 280751
Diffstat (limited to 'lldb/source/Target/ABI.cpp')
-rw-r--r--lldb/source/Target/ABI.cpp340
1 files changed, 163 insertions, 177 deletions
diff --git a/lldb/source/Target/ABI.cpp b/lldb/source/Target/ABI.cpp
index f5fd594..de4f685 100644
--- a/lldb/source/Target/ABI.cpp
+++ b/lldb/source/Target/ABI.cpp
@@ -12,10 +12,10 @@
// Other libraries and framework includes
// Project includes
#include "lldb/Target/ABI.h"
+#include "Plugins/ExpressionParser/Clang/ClangPersistentVariables.h"
#include "lldb/Core/PluginManager.h"
#include "lldb/Core/Value.h"
#include "lldb/Core/ValueObjectConstResult.h"
-#include "Plugins/ExpressionParser/Clang/ClangPersistentVariables.h"
#include "lldb/Symbol/CompilerType.h"
#include "lldb/Symbol/TypeSystem.h"
#include "lldb/Target/Target.h"
@@ -25,207 +25,193 @@ using namespace lldb;
using namespace lldb_private;
ABISP
-ABI::FindPlugin (const ArchSpec &arch)
-{
- ABISP abi_sp;
- ABICreateInstance create_callback;
-
- for (uint32_t idx = 0;
- (create_callback = PluginManager::GetABICreateCallbackAtIndex(idx)) != nullptr;
- ++idx)
- {
- abi_sp = create_callback(arch);
-
- if (abi_sp)
- return abi_sp;
- }
- abi_sp.reset();
- return abi_sp;
+ABI::FindPlugin(const ArchSpec &arch) {
+ ABISP abi_sp;
+ ABICreateInstance create_callback;
+
+ for (uint32_t idx = 0;
+ (create_callback = PluginManager::GetABICreateCallbackAtIndex(idx)) !=
+ nullptr;
+ ++idx) {
+ abi_sp = create_callback(arch);
+
+ if (abi_sp)
+ return abi_sp;
+ }
+ abi_sp.reset();
+ return abi_sp;
}
ABI::ABI() = default;
ABI::~ABI() = default;
-bool
-ABI::GetRegisterInfoByName (const ConstString &name, RegisterInfo &info)
-{
- uint32_t count = 0;
- const RegisterInfo *register_info_array = GetRegisterInfoArray (count);
- if (register_info_array)
- {
- const char *unique_name_cstr = name.GetCString();
- uint32_t i;
- for (i = 0; i < count; ++i)
- {
- if (register_info_array[i].name == unique_name_cstr)
- {
- info = register_info_array[i];
- return true;
- }
- }
- for (i = 0; i < count; ++i)
- {
- if (register_info_array[i].alt_name == unique_name_cstr)
- {
- info = register_info_array[i];
- return true;
- }
- }
+bool ABI::GetRegisterInfoByName(const ConstString &name, RegisterInfo &info) {
+ uint32_t count = 0;
+ const RegisterInfo *register_info_array = GetRegisterInfoArray(count);
+ if (register_info_array) {
+ const char *unique_name_cstr = name.GetCString();
+ uint32_t i;
+ for (i = 0; i < count; ++i) {
+ if (register_info_array[i].name == unique_name_cstr) {
+ info = register_info_array[i];
+ return true;
+ }
}
- return false;
+ for (i = 0; i < count; ++i) {
+ if (register_info_array[i].alt_name == unique_name_cstr) {
+ info = register_info_array[i];
+ return true;
+ }
+ }
+ }
+ return false;
}
-bool
-ABI::GetRegisterInfoByKind (RegisterKind reg_kind, uint32_t reg_num, RegisterInfo &info)
-{
- if (reg_kind < eRegisterKindEHFrame || reg_kind >= kNumRegisterKinds)
- return false;
-
- uint32_t count = 0;
- const RegisterInfo *register_info_array = GetRegisterInfoArray (count);
- if (register_info_array)
- {
- for (uint32_t i = 0; i < count; ++i)
- {
- if (register_info_array[i].kinds[reg_kind] == reg_num)
- {
- info = register_info_array[i];
- return true;
- }
- }
- }
+bool ABI::GetRegisterInfoByKind(RegisterKind reg_kind, uint32_t reg_num,
+ RegisterInfo &info) {
+ if (reg_kind < eRegisterKindEHFrame || reg_kind >= kNumRegisterKinds)
return false;
-}
-ValueObjectSP
-ABI::GetReturnValueObject (Thread &thread,
- CompilerType &ast_type,
- bool persistent) const
-{
- if (!ast_type.IsValid())
- return ValueObjectSP();
-
- ValueObjectSP return_valobj_sp;
-
- return_valobj_sp = GetReturnValueObjectImpl(thread, ast_type);
- if (!return_valobj_sp)
- return return_valobj_sp;
-
- // Now turn this into a persistent variable.
- // FIXME: This code is duplicated from Target::EvaluateExpression, and it is used in similar form in a couple
- // of other places. Figure out the correct Create function to do all this work.
-
- if (persistent)
- {
- PersistentExpressionState *persistent_expression_state = thread.CalculateTarget()->GetPersistentExpressionStateForLanguage(ast_type.GetMinimumLanguage());
-
- if (!persistent_expression_state)
- return ValueObjectSP();
-
- ConstString persistent_variable_name (persistent_expression_state->GetNextPersistentVariableName());
-
- lldb::ValueObjectSP const_valobj_sp;
-
- // Check in case our value is already a constant value
- if (return_valobj_sp->GetIsConstant())
- {
- const_valobj_sp = return_valobj_sp;
- const_valobj_sp->SetName (persistent_variable_name);
- }
- else
- const_valobj_sp = return_valobj_sp->CreateConstantValue (persistent_variable_name);
-
- lldb::ValueObjectSP live_valobj_sp = return_valobj_sp;
-
- return_valobj_sp = const_valobj_sp;
-
- ExpressionVariableSP clang_expr_variable_sp(persistent_expression_state->CreatePersistentVariable(return_valobj_sp));
-
- assert (clang_expr_variable_sp);
-
- // Set flags and live data as appropriate
-
- const Value &result_value = live_valobj_sp->GetValue();
-
- switch (result_value.GetValueType())
- {
- case Value::eValueTypeHostAddress:
- case Value::eValueTypeFileAddress:
- // we don't do anything with these for now
- break;
- case Value::eValueTypeScalar:
- case Value::eValueTypeVector:
- clang_expr_variable_sp->m_flags |= ClangExpressionVariable::EVIsFreezeDried;
- clang_expr_variable_sp->m_flags |= ClangExpressionVariable::EVIsLLDBAllocated;
- clang_expr_variable_sp->m_flags |= ClangExpressionVariable::EVNeedsAllocation;
- break;
- case Value::eValueTypeLoadAddress:
- clang_expr_variable_sp->m_live_sp = live_valobj_sp;
- clang_expr_variable_sp->m_flags |= ClangExpressionVariable::EVIsProgramReference;
- break;
- }
-
- return_valobj_sp = clang_expr_variable_sp->GetValueObject();
+ uint32_t count = 0;
+ const RegisterInfo *register_info_array = GetRegisterInfoArray(count);
+ if (register_info_array) {
+ for (uint32_t i = 0; i < count; ++i) {
+ if (register_info_array[i].kinds[reg_kind] == reg_num) {
+ info = register_info_array[i];
+ return true;
+ }
}
- return return_valobj_sp;
+ }
+ return false;
}
-ValueObjectSP
-ABI::GetReturnValueObject(Thread &thread, llvm::Type &ast_type, bool persistent) const
-{
- ValueObjectSP return_valobj_sp;
- return_valobj_sp = GetReturnValueObjectImpl( thread, ast_type );
+ValueObjectSP ABI::GetReturnValueObject(Thread &thread, CompilerType &ast_type,
+ bool persistent) const {
+ if (!ast_type.IsValid())
+ return ValueObjectSP();
+
+ ValueObjectSP return_valobj_sp;
+
+ return_valobj_sp = GetReturnValueObjectImpl(thread, ast_type);
+ if (!return_valobj_sp)
return return_valobj_sp;
+
+ // Now turn this into a persistent variable.
+ // FIXME: This code is duplicated from Target::EvaluateExpression, and it is
+ // used in similar form in a couple
+ // of other places. Figure out the correct Create function to do all this
+ // work.
+
+ if (persistent) {
+ PersistentExpressionState *persistent_expression_state =
+ thread.CalculateTarget()->GetPersistentExpressionStateForLanguage(
+ ast_type.GetMinimumLanguage());
+
+ if (!persistent_expression_state)
+ return ValueObjectSP();
+
+ ConstString persistent_variable_name(
+ persistent_expression_state->GetNextPersistentVariableName());
+
+ lldb::ValueObjectSP const_valobj_sp;
+
+ // Check in case our value is already a constant value
+ if (return_valobj_sp->GetIsConstant()) {
+ const_valobj_sp = return_valobj_sp;
+ const_valobj_sp->SetName(persistent_variable_name);
+ } else
+ const_valobj_sp =
+ return_valobj_sp->CreateConstantValue(persistent_variable_name);
+
+ lldb::ValueObjectSP live_valobj_sp = return_valobj_sp;
+
+ return_valobj_sp = const_valobj_sp;
+
+ ExpressionVariableSP clang_expr_variable_sp(
+ persistent_expression_state->CreatePersistentVariable(
+ return_valobj_sp));
+
+ assert(clang_expr_variable_sp);
+
+ // Set flags and live data as appropriate
+
+ const Value &result_value = live_valobj_sp->GetValue();
+
+ switch (result_value.GetValueType()) {
+ case Value::eValueTypeHostAddress:
+ case Value::eValueTypeFileAddress:
+ // we don't do anything with these for now
+ break;
+ case Value::eValueTypeScalar:
+ case Value::eValueTypeVector:
+ clang_expr_variable_sp->m_flags |=
+ ClangExpressionVariable::EVIsFreezeDried;
+ clang_expr_variable_sp->m_flags |=
+ ClangExpressionVariable::EVIsLLDBAllocated;
+ clang_expr_variable_sp->m_flags |=
+ ClangExpressionVariable::EVNeedsAllocation;
+ break;
+ case Value::eValueTypeLoadAddress:
+ clang_expr_variable_sp->m_live_sp = live_valobj_sp;
+ clang_expr_variable_sp->m_flags |=
+ ClangExpressionVariable::EVIsProgramReference;
+ break;
+ }
+
+ return_valobj_sp = clang_expr_variable_sp->GetValueObject();
+ }
+ return return_valobj_sp;
+}
+
+ValueObjectSP ABI::GetReturnValueObject(Thread &thread, llvm::Type &ast_type,
+ bool persistent) const {
+ ValueObjectSP return_valobj_sp;
+ return_valobj_sp = GetReturnValueObjectImpl(thread, ast_type);
+ return return_valobj_sp;
}
// specialized to work with llvm IR types
//
// for now we will specify a default implementation so that we don't need to
// modify other ABIs
-lldb::ValueObjectSP
-ABI::GetReturnValueObjectImpl( Thread &thread, llvm::Type &ir_type ) const
-{
- ValueObjectSP return_valobj_sp;
+lldb::ValueObjectSP ABI::GetReturnValueObjectImpl(Thread &thread,
+ llvm::Type &ir_type) const {
+ ValueObjectSP return_valobj_sp;
- /* this is a dummy and will only be called if an ABI does not override this */
+ /* this is a dummy and will only be called if an ABI does not override this */
- return return_valobj_sp;
+ return return_valobj_sp;
}
-bool
-ABI::PrepareTrivialCall (Thread &thread,
- lldb::addr_t sp,
- lldb::addr_t functionAddress,
- lldb::addr_t returnAddress,
- llvm::Type &returntype,
- llvm::ArrayRef<ABI::CallArgument> args) const
-{
- // dummy prepare trivial call
- assert( !"Should never get here!" );
- return false;
+bool ABI::PrepareTrivialCall(Thread &thread, lldb::addr_t sp,
+ lldb::addr_t functionAddress,
+ lldb::addr_t returnAddress, llvm::Type &returntype,
+ llvm::ArrayRef<ABI::CallArgument> args) const {
+ // dummy prepare trivial call
+ assert(!"Should never get here!");
+ return false;
}
-bool
-ABI::GetFallbackRegisterLocation (const RegisterInfo *reg_info,
- UnwindPlan::Row::RegisterLocation &unwind_regloc)
-{
- // Did the UnwindPlan fail to give us the caller's stack pointer?
- // The stack pointer is defined to be the same as THIS frame's CFA, so return the CFA value as
- // the caller's stack pointer. This is true on x86-32/x86-64 at least.
- if (reg_info->kinds[eRegisterKindGeneric] == LLDB_REGNUM_GENERIC_SP)
- {
- unwind_regloc.SetIsCFAPlusOffset(0);
- return true;
- }
-
- // 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;
+bool ABI::GetFallbackRegisterLocation(
+ const RegisterInfo *reg_info,
+ UnwindPlan::Row::RegisterLocation &unwind_regloc) {
+ // Did the UnwindPlan fail to give us the caller's stack pointer?
+ // The stack pointer is defined to be the same as THIS frame's CFA, so return
+ // the CFA value as
+ // the caller's stack pointer. This is true on x86-32/x86-64 at least.
+ if (reg_info->kinds[eRegisterKindGeneric] == LLDB_REGNUM_GENERIC_SP) {
+ unwind_regloc.SetIsCFAPlusOffset(0);
+ return true;
+ }
+
+ // 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;
}