[Lldb-commits] [lldb] r209494 - Fixed the Symbol code to resolve the callable address
Sean Callanan
scallanan at apple.com
Thu May 22 19:30:49 PDT 2014
Author: spyffe
Date: Thu May 22 21:30:48 2014
New Revision: 209494
URL: http://llvm.org/viewvc/llvm-project?rev=209494&view=rev
Log:
Fixed the Symbol code to resolve the callable address
of the symbol itself rather than forcing clients to do
it. This simplifies the logic for the expression
parser a great deal.
<rdar://problem/16935324>
Modified:
lldb/trunk/include/lldb/Symbol/Symbol.h
lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp
lldb/trunk/source/Symbol/Symbol.cpp
Modified: lldb/trunk/include/lldb/Symbol/Symbol.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/Symbol.h?rev=209494&r1=209493&r2=209494&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Symbol/Symbol.h (original)
+++ lldb/trunk/include/lldb/Symbol/Symbol.h Thu May 22 21:30:48 2014
@@ -92,6 +92,9 @@ public:
return m_addr_range.GetBaseAddress();
}
+ lldb::addr_t
+ ResolveCallableAddress(Target &target) const;
+
const ConstString &
GetName () const
{
@@ -135,7 +138,7 @@ public:
SetReExportedSymbolSharedLibrary (const FileSpec &fspec);
Symbol *
- ResolveReExportedSymbol (Target &target);
+ ResolveReExportedSymbol (Target &target) const;
uint32_t
GetSiblingIndex () const;
@@ -310,7 +313,7 @@ protected:
ResolveReExportedSymbolInModuleSpec (Target &target,
ConstString &reexport_name,
lldb_private::ModuleSpec &module_spec,
- lldb_private::ModuleList &seen_modules);
+ lldb_private::ModuleList &seen_modules) const;
uint32_t m_uid; // User ID (usually the original symbol table index)
uint16_t m_type_data; // data specific to m_type
Modified: lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp?rev=209494&r1=209493&r2=209494&view=diff
==============================================================================
--- lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp (original)
+++ lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp Thu May 22 21:30:48 2014
@@ -573,37 +573,27 @@ ClangExpressionDeclMap::GetFunctionAddre
SymbolContext sym_ctx;
sc_list.GetContextAtIndex(i, sym_ctx);
- const Address *func_so_addr = NULL;
bool is_indirect_function = false;
+
+ lldb::addr_t callable_load_addr = LLDB_INVALID_ADDRESS;
+
if (sym_ctx.function)
- func_so_addr = &sym_ctx.function->GetAddressRange().GetBaseAddress();
- else if (sym_ctx.symbol)
{
- if (sym_ctx.symbol->GetType() == eSymbolTypeReExported)
- {
- Symbol *reexported_symbol = sym_ctx.symbol->ResolveReExportedSymbol(*target);
- if (reexported_symbol)
- {
- func_so_addr = &reexported_symbol->GetAddress();
- is_indirect_function = reexported_symbol->IsIndirect();
- }
- }
- else
+ const Address func_so_addr = sym_ctx.function->GetAddressRange().GetBaseAddress();
+ if (func_so_addr.IsValid())
{
- func_so_addr = &sym_ctx.symbol->GetAddress();
- is_indirect_function = sym_ctx.symbol->IsIndirect();
+ callable_load_addr = func_so_addr.GetCallableLoadAddress(target, false);
}
}
+ else if (sym_ctx.symbol)
+ {
+ callable_load_addr = sym_ctx.symbol->ResolveCallableAddress(*target);
+ }
- if (func_so_addr && func_so_addr->IsValid())
+ if (callable_load_addr != LLDB_INVALID_ADDRESS)
{
- lldb::addr_t load_addr = func_so_addr->GetCallableLoadAddress (target, is_indirect_function);
-
- if (load_addr != LLDB_INVALID_ADDRESS)
- {
- func_addr = load_addr;
- return true;
- }
+ func_addr = callable_load_addr;
+ return true;
}
}
return false;
Modified: lldb/trunk/source/Symbol/Symbol.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/Symbol.cpp?rev=209494&r1=209493&r2=209494&view=diff
==============================================================================
--- lldb/trunk/source/Symbol/Symbol.cpp (original)
+++ lldb/trunk/source/Symbol/Symbol.cpp Thu May 22 21:30:48 2014
@@ -541,7 +541,7 @@ Symbol *
Symbol::ResolveReExportedSymbolInModuleSpec (Target &target,
ConstString &reexport_name,
ModuleSpec &module_spec,
- ModuleList &seen_modules)
+ ModuleList &seen_modules) const
{
ModuleSP module_sp;
if (module_spec.GetFileSpec())
@@ -602,7 +602,7 @@ Symbol::ResolveReExportedSymbolInModuleS
}
Symbol *
-Symbol::ResolveReExportedSymbol (Target &target)
+Symbol::ResolveReExportedSymbol (Target &target) const
{
ConstString reexport_name (GetReExportedSymbolName());
if (reexport_name)
@@ -618,6 +618,49 @@ Symbol::ResolveReExportedSymbol (Target
return nullptr;
}
+lldb::addr_t
+Symbol::ResolveCallableAddress(Target &target) const
+{
+ if (GetType() == lldb::eSymbolTypeUndefined)
+ return LLDB_INVALID_ADDRESS;
+
+ Address func_so_addr;
+
+ bool is_indirect;
+ if (GetType() == eSymbolTypeReExported)
+ {
+ Symbol *reexported_symbol = ResolveReExportedSymbol(target);
+ if (reexported_symbol)
+ {
+ func_so_addr = reexported_symbol->GetAddress();
+ is_indirect = reexported_symbol->IsIndirect();
+ }
+ }
+ else
+ {
+ func_so_addr = GetAddress();
+ is_indirect = IsIndirect();
+ }
+
+ if (func_so_addr.IsValid())
+ {
+ if (!target.GetProcessSP() && is_indirect)
+ {
+ // can't resolve indirect symbols without calling a function...
+ return LLDB_INVALID_ADDRESS;
+ }
+
+ lldb::addr_t load_addr = func_so_addr.GetCallableLoadAddress (&target, is_indirect);
+
+ if (load_addr != LLDB_INVALID_ADDRESS)
+ {
+ return load_addr;
+ }
+ }
+
+ return LLDB_INVALID_ADDRESS;
+}
+
lldb::DisassemblerSP
Symbol::GetInstructions (const ExecutionContext &exe_ctx,
More information about the lldb-commits
mailing list