From 74a1fc6f8723873bbbdf9ac62cb8a3a2cff7b8d0 Mon Sep 17 00:00:00 2001 From: Chaoren Lin Date: Wed, 24 Feb 2016 03:15:21 +0000 Subject: [PATCH] Fix TestCStrings for Linux with i386 inferiors. Summary: Temporarily revert part of r261704. Reviewers: spyffe Subscribers: lldb-commits Differential Revision: http://reviews.llvm.org/D17557 llvm-svn: 261718 --- lldb/source/Expression/IRExecutionUnit.cpp | 91 ++++++++++------------ 1 file changed, 43 insertions(+), 48 deletions(-) diff --git a/lldb/source/Expression/IRExecutionUnit.cpp b/lldb/source/Expression/IRExecutionUnit.cpp index a209dd19429a..9c01b313fdda 100644 --- a/lldb/source/Expression/IRExecutionUnit.cpp +++ b/lldb/source/Expression/IRExecutionUnit.cpp @@ -213,7 +213,7 @@ IRExecutionUnit::DisassembleFunction (Stream &stream, InstructionList &instruction_list = disassembler_sp->GetInstructionList(); instruction_list.Dump(&stream, true, true, &exe_ctx); - + // FIXME: The DisassemblerLLVMC has a reference cycle and won't go away if it has any active instructions. // I'll fix that but for now, just clear the list and it will go away nicely. disassembler_sp->GetInstructionList().Clear(); @@ -297,7 +297,7 @@ IRExecutionUnit::GetRunnableInfo(Error &error, { relocModel = llvm::Reloc::PIC_; } - + // This will be small for 32-bit and large for 64-bit. codeModel = llvm::CodeModel::JITDefault; @@ -325,7 +325,7 @@ IRExecutionUnit::GetRunnableInfo(Error &error, mAttrs); m_execution_engine_ap.reset(builder.create(target_machine)); - + m_strip_underscore = (m_execution_engine_ap->getDataLayout().getGlobalPrefix() == '_'); if (!m_execution_engine_ap.get()) @@ -373,11 +373,11 @@ IRExecutionUnit::GetRunnableInfo(Error &error, if (m_failed_lookups.size()) { StreamString ss; - + ss.PutCString("Couldn't lookup symbols:\n"); - + bool emitNewLine = false; - + for (const ConstString &failed_lookup : m_failed_lookups) { if (emitNewLine) @@ -386,14 +386,14 @@ IRExecutionUnit::GetRunnableInfo(Error &error, ss.PutCString(" "); ss.PutCString(Mangled(failed_lookup).GetDemangledName(lldb::eLanguageTypeObjC_plus_plus).AsCString()); } - + m_failed_lookups.clear(); - + error.SetErrorString(ss.GetData()); - + return; } - + m_function_load_addr = LLDB_INVALID_ADDRESS; m_function_end_load_addr = LLDB_INVALID_ADDRESS; @@ -446,7 +446,7 @@ IRExecutionUnit::GetRunnableInfo(Error &error, else { record.dump(log); - + DataExtractor my_extractor ((const void*)record.m_host_address, record.m_size, lldb::eByteOrderBig, 8); my_extractor.PutToLog(log, 0, record.m_size, record.m_host_address, 16, DataExtractor::TypeUInt8); } @@ -731,20 +731,20 @@ IRExecutionUnit::CollectCandidateCPlusPlusNames(std::vector &s const bool is_external = (candidate_sc.function) || (candidate_sc.symbol && candidate_sc.symbol->IsExternal()); - AddressRange range; + load_address = candidate_sc.symbol->ResolveCallableAddress(*target); - if (candidate_sc.GetAddressRange(lldb::eSymbolContextFunction | lldb::eSymbolContextSymbol, - 0, - false, - range)) + if (load_address == LLDB_INVALID_ADDRESS) + load_address = candidate_sc.symbol->GetAddress().GetLoadAddress(target); + + if (load_address != LLDB_INVALID_ADDRESS) { - load_address = range.GetBaseAddress().GetCallableLoadAddress(target); - - if (load_address != LLDB_INVALID_ADDRESS) + if (is_external) { - if (is_external) - { - return true; - } - else if (best_internal_load_address == LLDB_INVALID_ADDRESS) - { - best_internal_load_address = load_address; - load_address = LLDB_INVALID_ADDRESS; - } + return true; + } + else if (best_internal_load_address == LLDB_INVALID_ADDRESS) + { + best_internal_load_address = load_address; + load_address = LLDB_INVALID_ADDRESS; } } } return false; }; - + if (sc.module_sp) { sc.module_sp->FindFunctions(spec.name, @@ -847,7 +842,7 @@ IRExecutionUnit::FindInSymbols(const std::vector &s { sc_list.Clear(); } - + if (sc_list.GetSize() == 0 && sc.target_sp) { sc.target_sp->GetImages().FindFunctions(spec.name, @@ -857,7 +852,7 @@ IRExecutionUnit::FindInSymbols(const std::vector &s true, // append sc_list); } - + if (get_external_load_address(load_address, sc_list, sc)) { return load_address; @@ -883,7 +878,7 @@ IRExecutionUnit::FindInSymbols(const std::vector &s return best_internal_load_address; } } - + return LLDB_INVALID_ADDRESS; } @@ -891,14 +886,14 @@ lldb::addr_t IRExecutionUnit::FindInRuntimes(const std::vector &specs, const lldb_private::SymbolContext &sc) { lldb::TargetSP target_sp = sc.target_sp; - + if (!target_sp) { return LLDB_INVALID_ADDRESS; } - + lldb::ProcessSP process_sp = sc.target_sp->GetProcessSP(); - + if (!process_sp) { return LLDB_INVALID_ADDRESS; @@ -911,12 +906,12 @@ IRExecutionUnit::FindInRuntimes(const std::vector &specs, const lldb for (const SearchSpec &spec : specs) { lldb::addr_t symbol_load_addr = runtime->LookupRuntimeSymbol(spec.name); - + if (symbol_load_addr != LLDB_INVALID_ADDRESS) return symbol_load_addr; } } - + return LLDB_INVALID_ADDRESS; } @@ -925,19 +920,19 @@ IRExecutionUnit::FindSymbol(const lldb_private::ConstString &name) { std::vector candidate_C_names; std::vector candidate_CPlusPlus_names; - + CollectCandidateCNames(candidate_C_names, name); lldb::addr_t ret = FindInSymbols(candidate_C_names, m_sym_ctx); if (ret == LLDB_INVALID_ADDRESS) ret = FindInRuntimes(candidate_C_names, m_sym_ctx); - + if (ret == LLDB_INVALID_ADDRESS) { CollectCandidateCPlusPlusNames(candidate_CPlusPlus_names, candidate_C_names, m_sym_ctx); ret = FindInSymbols(candidate_CPlusPlus_names, m_sym_ctx); } - + return ret; } @@ -947,9 +942,9 @@ IRExecutionUnit::MemoryManager::getSymbolAddress(const std::string &Name) Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS)); ConstString name_cs(Name.c_str()); - + lldb::addr_t ret = m_parent.FindSymbol(name_cs); - + if (ret == LLDB_INVALID_ADDRESS) { if (log) @@ -973,7 +968,7 @@ void * IRExecutionUnit::MemoryManager::getPointerToNamedFunction(const std::string &Name, bool AbortOnFailure) { assert (sizeof(void *) == 8); - + return (void*)getSymbolAddress(Name); }