diff options
author | Sean Callanan <scallanan@apple.com> | 2010-07-27 02:07:53 +0000 |
---|---|---|
committer | Sean Callanan <scallanan@apple.com> | 2010-07-27 02:07:53 +0000 |
commit | 4edba2d130ad9217a6ba85870224cf6a84cc8770 (patch) | |
tree | f9a04c75ed9cea65c5bcb444b07b742abd5c7773 /lldb/source | |
parent | 0ff1ef650bac208b337059c2829880db5b4e4487 (diff) | |
download | bcm5719-llvm-4edba2d130ad9217a6ba85870224cf6a84cc8770.tar.gz bcm5719-llvm-4edba2d130ad9217a6ba85870224cf6a84cc8770.zip |
Added support for locating a function that is
referenced in the IR. We don't yet support updating
the call to that function.
llvm-svn: 109483
Diffstat (limited to 'lldb/source')
-rw-r--r-- | lldb/source/Expression/ClangExpressionDeclMap.cpp | 18 | ||||
-rw-r--r-- | lldb/source/Expression/IRForTarget.cpp | 58 |
2 files changed, 66 insertions, 10 deletions
diff --git a/lldb/source/Expression/ClangExpressionDeclMap.cpp b/lldb/source/Expression/ClangExpressionDeclMap.cpp index d5d381d64a2..c26b77d75e6 100644 --- a/lldb/source/Expression/ClangExpressionDeclMap.cpp +++ b/lldb/source/Expression/ClangExpressionDeclMap.cpp @@ -182,6 +182,24 @@ ClangExpressionDeclMap::GetStructElement (const clang::NamedDecl *&decl, return true; } +uint64_t +ClangExpressionDeclMap::GetFunctionAddress (const clang::NamedDecl *decl) +{ + TupleIterator iter; + + for (iter = m_tuples.begin(); + iter != m_tuples.end(); + ++iter) + { + if (decl == iter->m_decl) + { + return iter->m_value->GetScalar().ULongLong(); + } + } + + return 0; +} + // Interface for DwarfExpression lldb_private::Value *ClangExpressionDeclMap::GetValueForIndex (uint32_t index) diff --git a/lldb/source/Expression/IRForTarget.cpp b/lldb/source/Expression/IRForTarget.cpp index ce28a8f362c..4f5d44c70a1 100644 --- a/lldb/source/Expression/IRForTarget.cpp +++ b/lldb/source/Expression/IRForTarget.cpp @@ -82,7 +82,6 @@ DeclForGlobalValue(llvm::Module &module, bool IRForTarget::MaybeHandleVariable(Module &M, - lldb_private::ClangExpressionDeclMap *DM, llvm::Value *V, bool Store) { @@ -110,13 +109,13 @@ IRForTarget::MaybeHandleVariable(Module &M, size_t value_size = m_target_data->getTypeStoreSize(value_type); off_t value_alignment = m_target_data->getPrefTypeAlignment(value_type); - if (named_decl && !DM->AddValueToStruct(V, - named_decl, - name, - qual_type, - ast_context, - value_size, - value_alignment)) + if (named_decl && !m_decl_map->AddValueToStruct(V, + named_decl, + name, + qual_type, + ast_context, + value_size, + value_alignment)) return false; } @@ -124,6 +123,41 @@ IRForTarget::MaybeHandleVariable(Module &M, } bool +IRForTarget::MaybeHandleCall(Module &M, + CallInst *C) +{ + lldb_private::Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS); + + llvm::Function *fun = C->getCalledFunction(); + + if (fun == NULL) + return true; + + clang::NamedDecl *fun_decl = DeclForGlobalValue(M, fun); + + if (!fun_decl) + { + if (log) + log->Printf("Function %s wasn't in the metadata", fun->getName().str().c_str()); + return false; + } + + uint64_t fun_addr = m_decl_map->GetFunctionAddress(fun_decl); + + if (fun_addr == 0) + { + if (log) + log->Printf("Function %s had no address", fun_decl->getNameAsCString()); + return false; + } + + if (log) + log->Printf("Found %s at %llx", fun_decl->getNameAsCString(), fun_addr); + + return true; +} + +bool IRForTarget::runOnBasicBlock(Module &M, BasicBlock &BB) { ///////////////////////////////////////////////////////////////////////// @@ -139,11 +173,15 @@ IRForTarget::runOnBasicBlock(Module &M, BasicBlock &BB) Instruction &inst = *ii; if (LoadInst *load = dyn_cast<LoadInst>(&inst)) - if (!MaybeHandleVariable(M, m_decl_map, load->getPointerOperand(), false)) + if (!MaybeHandleVariable(M, load->getPointerOperand(), false)) return false; if (StoreInst *store = dyn_cast<StoreInst>(&inst)) - if (!MaybeHandleVariable(M, m_decl_map, store->getPointerOperand(), false)) + if (!MaybeHandleVariable(M, store->getPointerOperand(), true)) + return false; + + if (CallInst *call = dyn_cast<CallInst>(&inst)) + if (!MaybeHandleCall(M, call)) return false; } |