[Lldb-commits] [lldb] r133684 - in /lldb/trunk: include/lldb/Expression/ClangExpressionDeclMap.h source/Expression/ClangExpressionDeclMap.cpp source/Expression/IRForTarget.cpp
Greg Clayton
gclayton at apple.com
Wed Jun 22 21:25:29 PDT 2011
Author: gclayton
Date: Wed Jun 22 23:25:29 2011
New Revision: 133684
URL: http://llvm.org/viewvc/llvm-project?rev=133684&view=rev
Log:
Fixed an issue for ARM where data symbols would alway return invalid addresses.
Modified:
lldb/trunk/include/lldb/Expression/ClangExpressionDeclMap.h
lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp
lldb/trunk/source/Expression/IRForTarget.cpp
Modified: lldb/trunk/include/lldb/Expression/ClangExpressionDeclMap.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Expression/ClangExpressionDeclMap.h?rev=133684&r1=133683&r2=133684&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Expression/ClangExpressionDeclMap.h (original)
+++ lldb/trunk/include/lldb/Expression/ClangExpressionDeclMap.h Wed Jun 22 23:25:29 2011
@@ -333,20 +333,15 @@
/// @param[in] name
/// The name of the symbol.
///
- /// @param[out] ptr
- /// The absolute address of the function in the target.
- ///
/// @return
- /// True if the address could be retrieved; false otherwise.
+ /// Valid load address for the symbol
//------------------------------------------------------------------
- bool
+ lldb::addr_t
GetSymbolAddress (Target &target,
- const ConstString &name,
- uint64_t &ptr);
+ const ConstString &name);
- bool
- GetSymbolAddress (const ConstString &name,
- uint64_t &ptr);
+ lldb::addr_t
+ GetSymbolAddress (const ConstString &name);
//------------------------------------------------------------------
/// [Used by CommandObjectExpression] Materialize the entire struct
Modified: lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp?rev=133684&r1=133683&r2=133684&view=diff
==============================================================================
--- lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp (original)
+++ lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp Wed Jun 22 23:25:29 2011
@@ -557,37 +557,65 @@
return true;
}
-bool
-ClangExpressionDeclMap::GetSymbolAddress
-(
- Target &target,
- const ConstString &name,
- uint64_t &ptr
-)
+addr_t
+ClangExpressionDeclMap::GetSymbolAddress (Target &target, const ConstString &name)
{
SymbolContextList sc_list;
target.GetImages().FindSymbolsWithNameAndType(name, eSymbolTypeAny, sc_list);
- if (!sc_list.GetSize())
- return false;
-
- SymbolContext sym_ctx;
- sc_list.GetContextAtIndex(0, sym_ctx);
-
- const Address *sym_address = &sym_ctx.symbol->GetAddressRangeRef().GetBaseAddress();
+ const uint32_t num_matches = sc_list.GetSize();
+ addr_t symbol_load_addr = LLDB_INVALID_ADDRESS;
+
+ for (uint32_t i=0; i<num_matches && symbol_load_addr == LLDB_INVALID_ADDRESS; i++)
+ {
+ SymbolContext sym_ctx;
+ sc_list.GetContextAtIndex(i, sym_ctx);
- ptr = sym_address->GetCallableLoadAddress(&target);
+ const Address *sym_address = &sym_ctx.symbol->GetAddressRangeRef().GetBaseAddress();
+ if (sym_address)
+ {
+ switch (sym_ctx.symbol->GetType())
+ {
+ case eSymbolTypeCode:
+ case eSymbolTypeTrampoline:
+ symbol_load_addr = sym_address->GetCallableLoadAddress (&target);
+ break;
+
+ case eSymbolTypeData:
+ case eSymbolTypeRuntime:
+ case eSymbolTypeVariable:
+ case eSymbolTypeLocal:
+ case eSymbolTypeParam:
+ case eSymbolTypeInvalid:
+ case eSymbolTypeAbsolute:
+ case eSymbolTypeExtern:
+ case eSymbolTypeException:
+ case eSymbolTypeSourceFile:
+ case eSymbolTypeHeaderFile:
+ case eSymbolTypeObjectFile:
+ case eSymbolTypeCommonBlock:
+ case eSymbolTypeBlock:
+ case eSymbolTypeVariableType:
+ case eSymbolTypeLineEntry:
+ case eSymbolTypeLineHeader:
+ case eSymbolTypeScopeBegin:
+ case eSymbolTypeScopeEnd:
+ case eSymbolTypeAdditional:
+ case eSymbolTypeCompiler:
+ case eSymbolTypeInstrumentation:
+ case eSymbolTypeUndefined:
+ symbol_load_addr = sym_address->GetLoadAddress (&target);
+ break;
+ }
+ }
+ }
- return true;
+ return symbol_load_addr;
}
-bool
-ClangExpressionDeclMap::GetSymbolAddress
-(
- const ConstString &name,
- uint64_t &ptr
-)
+addr_t
+ClangExpressionDeclMap::GetSymbolAddress (const ConstString &name)
{
assert (m_parser_vars.get());
@@ -595,9 +623,7 @@
!m_parser_vars->m_exe_ctx->target)
return false;
- return GetSymbolAddress(*m_parser_vars->m_exe_ctx->target,
- name,
- ptr);
+ return GetSymbolAddress(*m_parser_vars->m_exe_ctx->target, name);
}
// Interface for CommandObjectExpression
@@ -1238,9 +1264,9 @@
{
location_value.reset(new Value);
- uint64_t location_load_addr;
+ addr_t location_load_addr = GetSymbolAddress(*exe_ctx.target, name);
- if (!GetSymbolAddress(*exe_ctx.target, name, location_load_addr))
+ if (location_load_addr == LLDB_INVALID_ADDRESS)
{
if (log)
err.SetErrorStringWithFormat ("Couldn't find value for global symbol %s",
Modified: lldb/trunk/source/Expression/IRForTarget.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/IRForTarget.cpp?rev=133684&r1=133683&r2=133684&view=diff
==============================================================================
--- lldb/trunk/source/Expression/IRForTarget.cpp (original)
+++ lldb/trunk/source/Expression/IRForTarget.cpp Wed Jun 22 23:25:29 2011
@@ -1327,9 +1327,9 @@
lldb_private::ConstString name(symbol->getName().str().c_str());
- uint64_t symbol_addr;
+ lldb::addr_t symbol_addr = m_decl_map->GetSymbolAddress (name);
- if (!m_decl_map->GetSymbolAddress (name, symbol_addr))
+ if (symbol_addr == LLDB_INVALID_ADDRESS)
{
if (log)
log->Printf ("Symbol \"%s\" had no address", name.GetCString());
More information about the lldb-commits
mailing list