From 7b3e1df40ac9ce8daaa5d38c3a682c2da612b045 Mon Sep 17 00:00:00 2001 From: emaste Date: Sat, 24 Aug 2013 10:06:51 +0000 Subject: [PATCH] Revert lldb changes due to post-3.3 clang and llvm API changes Revisions: svn git 183929 99447a6 183862 15c1774 source/Host/common/FileSpec.cpp 184954 007e7bc 184948 4dc3761 source/Expression/ClangExpressionParser.cpp 182099 b31044e 181387 779e6ac include/lldb/Expression/IRExecutionUnit.h source/Expression/IRExecutionUnit.cpp 184177 0b2934b 182650 f2dcf35 181703 7bef4e2 source/Plugins/Disassembler/llvm/DisassemblerLLVMC.cpp 182683 0d91b80 source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp Sponsored by: DARPA, AFRL --- .../include/lldb/Expression/IRExecutionUnit.h | 40 +++++++++++++++---- .../Expression/ClangExpressionParser.cpp | 23 ++++++----- .../source/Expression/IRExecutionUnit.cpp | 22 ++++++++++ .../lldb/source/Host/common/FileSpec.cpp | 5 ++- .../Disassembler/llvm/DisassemblerLLVMC.cpp | 23 ++++------- .../Instruction/ARM/EmulateInstructionARM.cpp | 4 +- 6 files changed, 80 insertions(+), 37 deletions(-) diff --git a/contrib/llvm/tools/lldb/include/lldb/Expression/IRExecutionUnit.h b/contrib/llvm/tools/lldb/include/lldb/Expression/IRExecutionUnit.h index 885b6516b0c6..9bc55920474a 100644 --- a/contrib/llvm/tools/lldb/include/lldb/Expression/IRExecutionUnit.h +++ b/contrib/llvm/tools/lldb/include/lldb/Expression/IRExecutionUnit.h @@ -336,19 +336,45 @@ private: /// @return /// True in case of failure, false in case of success. //------------------------------------------------------------------ - virtual bool finalizeMemory(std::string *ErrMsg) { - // TODO: Ensure that the instruction cache is flushed because - // relocations are updated by dy-load. See: - // sys::Memory::InvalidateInstructionCache - // llvm::SectionMemoryManager - return false; - } + bool applyPermissions(std::string *ErrMsg) { return false; } //------------------------------------------------------------------ /// Passthrough interface stub //------------------------------------------------------------------ virtual void deallocateFunctionBody(void *Body); + //------------------------------------------------------------------ + /// Passthrough interface stub + //------------------------------------------------------------------ + virtual uint8_t* startExceptionTable(const llvm::Function* F, + uintptr_t &ActualSize); + + //------------------------------------------------------------------ + /// Complete the exception table for a function, and add it to the + /// m_exception_tables map + /// + /// @param[in] F + /// The function whose exception table is being written. + /// + /// @param[in] TableStart + /// The first byte of the exception table. + /// + /// @param[in] TableEnd + /// The last byte of the exception table. + /// + /// @param[in] FrameRegister + /// I don't know what this does, but it's passed through. + //------------------------------------------------------------------ + virtual void endExceptionTable(const llvm::Function *F, + uint8_t *TableStart, + uint8_t *TableEnd, + uint8_t* FrameRegister); + + //------------------------------------------------------------------ + /// Passthrough interface stub + //------------------------------------------------------------------ + virtual void deallocateExceptionTable(void *ET); + //------------------------------------------------------------------ /// Passthrough interface stub //------------------------------------------------------------------ diff --git a/contrib/llvm/tools/lldb/source/Expression/ClangExpressionParser.cpp b/contrib/llvm/tools/lldb/source/Expression/ClangExpressionParser.cpp index 98c0bfdca874..d026f2f3c120 100644 --- a/contrib/llvm/tools/lldb/source/Expression/ClangExpressionParser.cpp +++ b/contrib/llvm/tools/lldb/source/Expression/ClangExpressionParser.cpp @@ -52,7 +52,7 @@ #include "llvm/ADT/StringRef.h" #include "llvm/ExecutionEngine/ExecutionEngine.h" #include "llvm/Support/Debug.h" -#include "llvm/Support/FileSystem.h" +#include "llvm/Support/PathV1.h" #include "llvm/Support/TargetSelect.h" #if defined(__FreeBSD__) @@ -81,16 +81,19 @@ using namespace lldb_private; //===----------------------------------------------------------------------===// std::string GetBuiltinIncludePath(const char *Argv0) { - SmallString<128> P(llvm::sys::fs::getMainExecutable( - Argv0, (void *)(intptr_t) GetBuiltinIncludePath)); - - if (!P.empty()) { - llvm::sys::path::remove_filename(P); // Remove /clang from foo/bin/clang - llvm::sys::path::remove_filename(P); // Remove /bin from foo/bin - + llvm::sys::Path P = + llvm::sys::Path::GetMainExecutable(Argv0, + (void*)(intptr_t) GetBuiltinIncludePath); + + if (!P.isEmpty()) { + P.eraseComponent(); // Remove /clang from foo/bin/clang + P.eraseComponent(); // Remove /bin from foo/bin + // Get foo/lib/clang//include - llvm::sys::path::append(P, "lib", "clang", CLANG_VERSION_STRING, - "include"); + P.appendComponent("lib"); + P.appendComponent("clang"); + P.appendComponent(CLANG_VERSION_STRING); + P.appendComponent("include"); } return P.str(); diff --git a/contrib/llvm/tools/lldb/source/Expression/IRExecutionUnit.cpp b/contrib/llvm/tools/lldb/source/Expression/IRExecutionUnit.cpp index 16ef6e5d54e1..a2b25948a582 100644 --- a/contrib/llvm/tools/lldb/source/Expression/IRExecutionUnit.cpp +++ b/contrib/llvm/tools/lldb/source/Expression/IRExecutionUnit.cpp @@ -563,6 +563,28 @@ IRExecutionUnit::MemoryManager::deallocateFunctionBody(void *Body) m_default_mm_ap->deallocateFunctionBody(Body); } +uint8_t* +IRExecutionUnit::MemoryManager::startExceptionTable(const llvm::Function* F, + uintptr_t &ActualSize) +{ + return m_default_mm_ap->startExceptionTable(F, ActualSize); +} + +void +IRExecutionUnit::MemoryManager::endExceptionTable(const llvm::Function *F, + uint8_t *TableStart, + uint8_t *TableEnd, + uint8_t* FrameRegister) +{ + m_default_mm_ap->endExceptionTable(F, TableStart, TableEnd, FrameRegister); +} + +void +IRExecutionUnit::MemoryManager::deallocateExceptionTable(void *ET) +{ + m_default_mm_ap->deallocateExceptionTable (ET); +} + lldb::addr_t IRExecutionUnit::GetRemoteAddressForLocal (lldb::addr_t local_address) { diff --git a/contrib/llvm/tools/lldb/source/Host/common/FileSpec.cpp b/contrib/llvm/tools/lldb/source/Host/common/FileSpec.cpp index 08d626e836a1..025cf6f4330e 100644 --- a/contrib/llvm/tools/lldb/source/Host/common/FileSpec.cpp +++ b/contrib/llvm/tools/lldb/source/Host/common/FileSpec.cpp @@ -553,8 +553,9 @@ FileSpec::ResolveExecutableLocation () if (file_cstr) { const std::string file_str (file_cstr); - std::string path = llvm::sys::FindProgramByName (file_str); - llvm::StringRef dir_ref = llvm::sys::path::parent_path(path); + llvm::sys::Path path = llvm::sys::Program::FindProgramByName (file_str); + const std::string &path_str = path.str(); + llvm::StringRef dir_ref = llvm::sys::path::parent_path(path_str); //llvm::StringRef dir_ref = path.getDirname(); if (! dir_ref.empty()) { diff --git a/contrib/llvm/tools/lldb/source/Plugins/Disassembler/llvm/DisassemblerLLVMC.cpp b/contrib/llvm/tools/lldb/source/Plugins/Disassembler/llvm/DisassemblerLLVMC.cpp index e920d70cd596..b281f2b4bfcc 100644 --- a/contrib/llvm/tools/lldb/source/Plugins/Disassembler/llvm/DisassemblerLLVMC.cpp +++ b/contrib/llvm/tools/lldb/source/Plugins/Disassembler/llvm/DisassemblerLLVMC.cpp @@ -10,7 +10,6 @@ #include "DisassemblerLLVMC.h" #include "llvm-c/Disassembler.h" -#include "llvm/ADT/OwningPtr.h" #include "llvm/MC/MCAsmInfo.h" #include "llvm/MC/MCContext.h" #include "llvm/MC/MCDisassembler.h" @@ -18,7 +17,6 @@ #include "llvm/MC/MCInstPrinter.h" #include "llvm/MC/MCInstrInfo.h" #include "llvm/MC/MCRegisterInfo.h" -#include "llvm/MC/MCRelocationInfo.h" #include "llvm/MC/MCSubtargetInfo.h" #include "llvm/Support/ErrorHandling.h" #include "llvm/Support/MemoryObject.h" @@ -442,30 +440,23 @@ DisassemblerLLVMC::LLVMCDisassembler::LLVMCDisassembler (const char *triple, uns m_subtarget_info_ap.reset(curr_target->createMCSubtargetInfo(triple, "", features_str)); - m_asm_info_ap.reset(curr_target->createMCAsmInfo(*curr_target->createMCRegInfo(triple), triple)); - + m_asm_info_ap.reset(curr_target->createMCAsmInfo(triple)); + if (m_instr_info_ap.get() == NULL || m_reg_info_ap.get() == NULL || m_subtarget_info_ap.get() == NULL || m_asm_info_ap.get() == NULL) { m_is_valid = false; return; } - m_context_ap.reset(new llvm::MCContext(m_asm_info_ap.get(), m_reg_info_ap.get(), 0)); + m_context_ap.reset(new llvm::MCContext(*m_asm_info_ap.get(), *(m_reg_info_ap.get()), 0)); m_disasm_ap.reset(curr_target->createMCDisassembler(*m_subtarget_info_ap.get())); - if (m_disasm_ap.get() && m_context_ap.get()) + if (m_disasm_ap.get()) { - llvm::OwningPtr RelInfo(curr_target->createMCRelocationInfo(triple, *m_context_ap.get())); - if (!RelInfo) - { - m_is_valid = false; - return; - } m_disasm_ap->setupForSymbolicDisassembly(NULL, - DisassemblerLLVMC::SymbolLookupCallback, - (void *) &owner, - m_context_ap.get(), - RelInfo); + DisassemblerLLVMC::SymbolLookupCallback, + (void *) &owner, + m_context_ap.get()); unsigned asm_printer_variant; if (flavor == ~0U) diff --git a/contrib/llvm/tools/lldb/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp b/contrib/llvm/tools/lldb/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp index 2dd04dd8733d..52a7fb0e8ee1 100644 --- a/contrib/llvm/tools/lldb/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp +++ b/contrib/llvm/tools/lldb/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp @@ -25,7 +25,7 @@ #include "Utility/ARM_DWARF_Registers.h" #include "llvm/Support/MathExtras.h" // for SignExtend32 template function - // and countTrailingZeros function + // and CountTrailingZeros_32 function using namespace lldb; using namespace lldb_private; @@ -47,7 +47,7 @@ using namespace lldb_private; static uint32_t CountITSize (uint32_t ITMask) { // First count the trailing zeros of the IT mask. - uint32_t TZ = llvm::countTrailingZeros(ITMask); + uint32_t TZ = llvm::CountTrailingZeros_32(ITMask); if (TZ > 3) { #ifdef LLDB_CONFIGURATION_DEBUG