Added a function to lldb_private::Address:
addr_t
Address::GetCallableLoadAddress (Target *target) const;
This will resolve the load address in the Address object and optionally
decorate the address up to be able to be called. For all non ARM targets, this
just essentially returns the result of "Address::GetLoadAddress (target)". But
for ARM targets, it checks if the address is Thumb, and if so, it returns
an address with bit zero set to indicate a mode switch to Thumb. This is how
we need function pointers to be for return addresses and when resolving
function addresses for the JIT. It is also nice to centralize this in one spot
to avoid having multiple copies of this code.
git-svn-id: https://llvm.org/svn/llvm-project/llvdb/trunk@131588 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/source/Expression/ClangExpressionDeclMap.cpp b/source/Expression/ClangExpressionDeclMap.cpp
index 3f80c1d..7131abf 100644
--- a/source/Expression/ClangExpressionDeclMap.cpp
+++ b/source/Expression/ClangExpressionDeclMap.cpp
@@ -495,7 +495,7 @@
ClangExpressionDeclMap::GetFunctionAddress
(
const ConstString &name,
- uint64_t &ptr
+ uint64_t &func_addr
)
{
assert (m_parser_vars.get());
@@ -543,17 +543,17 @@
SymbolContext sym_ctx;
sc_list.GetContextAtIndex(0, sym_ctx);
- const Address *fun_address;
+ const Address *func_so_addr = NULL;
if (sym_ctx.function)
- fun_address = &sym_ctx.function->GetAddressRange().GetBaseAddress();
+ func_so_addr = &sym_ctx.function->GetAddressRange().GetBaseAddress();
else if (sym_ctx.symbol)
- fun_address = &sym_ctx.symbol->GetAddressRangeRef().GetBaseAddress();
+ func_so_addr = &sym_ctx.symbol->GetAddressRangeRef().GetBaseAddress();
else
return false;
- ptr = fun_address->GetLoadAddress (m_parser_vars->m_exe_ctx->target);
-
+ func_addr = func_so_addr->GetCallableLoadAddress (m_parser_vars->m_exe_ctx->target);
+
return true;
}
@@ -577,7 +577,7 @@
const Address *sym_address = &sym_ctx.symbol->GetAddressRangeRef().GetBaseAddress();
- ptr = sym_address->GetLoadAddress(&target);
+ ptr = sym_address->GetCallableLoadAddress(&target);
return true;
}
@@ -2294,9 +2294,9 @@
}
void
-ClangExpressionDeclMap::AddOneFunction(NameSearchContext &context,
- Function* fun,
- Symbol* symbol)
+ClangExpressionDeclMap::AddOneFunction (NameSearchContext &context,
+ Function* fun,
+ Symbol* symbol)
{
assert (m_parser_vars.get());
@@ -2350,7 +2350,7 @@
return;
}
- lldb::addr_t load_addr = fun_address->GetLoadAddress(m_parser_vars->m_exe_ctx->target);
+ lldb::addr_t load_addr = fun_address->GetCallableLoadAddress(m_parser_vars->m_exe_ctx->target);
fun_location->SetValueType(Value::eValueTypeLoadAddress);
fun_location->GetScalar() = load_addr;