diff options
7 files changed, 43 insertions, 36 deletions
diff --git a/lldb/include/lldb/lldb-defines.h b/lldb/include/lldb/lldb-defines.h index ef15b0f360e..1cfbe4ed028 100644 --- a/lldb/include/lldb/lldb-defines.h +++ b/lldb/include/lldb/lldb-defines.h @@ -87,6 +87,7 @@ #define LLDB_INVALID_INDEX32 UINT32_MAX #define LLDB_INVALID_IVAR_OFFSET UINT32_MAX #define LLDB_INVALID_IMAGE_TOKEN UINT32_MAX +#define LLDB_INVALID_MODULE_VERSION UINT32_MAX #define LLDB_INVALID_REGNUM UINT32_MAX #define LLDB_INVALID_UID UINT64_MAX #define LLDB_INVALID_PROCESS_ID 0 diff --git a/lldb/source/Core/Module.cpp b/lldb/source/Core/Module.cpp index e6f2daa76e7..0cc1bc8b777 100644 --- a/lldb/source/Core/Module.cpp +++ b/lldb/source/Core/Module.cpp @@ -1646,7 +1646,7 @@ Module::GetVersion (uint32_t *versions, uint32_t num_versions) if (versions && num_versions) { for (uint32_t i=0; i<num_versions; ++i) - versions[i] = UINT32_MAX; + versions[i] = LLDB_INVALID_MODULE_VERSION; } return 0; } diff --git a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp index 2d2e4058159..2c8f3489d81 100644 --- a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp +++ b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp @@ -251,6 +251,32 @@ AppleObjCRuntime::AppleIsModuleObjCLibrary (const ModuleSP &module_sp) return false; } +// we use the version of Foundation to make assumptions about the ObjC runtime on a target +uint32_t +AppleObjCRuntime::GetFoundationVersion () +{ + if (!m_Foundation_major.hasValue()) + { + const ModuleList& modules = m_process->GetTarget().GetImages(); + uint32_t major = UINT32_MAX; + for (uint32_t idx = 0; idx < modules.GetSize(); idx++) + { + lldb::ModuleSP module_sp = modules.GetModuleAtIndex(idx); + if (!module_sp) + continue; + if (strcmp(module_sp->GetFileSpec().GetFilename().AsCString(""),"Foundation") == 0) + { + module_sp->GetVersion(&major,1); + m_Foundation_major = major; + return major; + } + } + return LLDB_INVALID_MODULE_VERSION; + } + else + return m_Foundation_major.getValue(); +} + bool AppleObjCRuntime::IsModuleObjCLibrary (const ModuleSP &module_sp) { diff --git a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.h b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.h index 96e98740e1d..f9e00540cb7 100644 --- a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.h +++ b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.h @@ -13,6 +13,9 @@ // C Includes // C++ Includes // Other libraries and framework includes + +#include "llvm/ADT/Optional.h" + // Project includes #include "lldb/lldb-private.h" #include "lldb/Target/LanguageRuntime.h" @@ -103,6 +106,9 @@ public: virtual lldb::SearchFilterSP CreateExceptionSearchFilter (); + uint32_t + GetFoundationVersion (); + protected: Address * GetPrintForDebuggerAddr(); @@ -112,11 +118,14 @@ protected: std::unique_ptr<lldb_private::AppleObjCTrampolineHandler> m_objc_trampoline_handler_ap; lldb::BreakpointSP m_objc_exception_bp_sp; lldb::ModuleWP m_objc_module_wp; + + llvm::Optional<uint32_t> m_Foundation_major; AppleObjCRuntime(Process *process) : lldb_private::ObjCLanguageRuntime(process), m_read_objc_library (false), - m_objc_trampoline_handler_ap () + m_objc_trampoline_handler_ap (), + m_Foundation_major() { // Call CreateInstance instead. } diff --git a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp index acf415c33cf..921b0ab3ad7 100644 --- a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp +++ b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp @@ -2472,45 +2472,22 @@ AppleObjCRuntimeV2::TaggedPointerVendorLegacy::IsPossibleTaggedPointer (lldb::ad return (ptr & 1); } -// we use the version of Foundation to make assumptions about the ObjC runtime on a target -uint32_t -AppleObjCRuntimeV2::TaggedPointerVendorLegacy::GetFoundationVersion (Target &target) -{ - const ModuleList& modules = target.GetImages(); - uint32_t major = UINT32_MAX; - for (uint32_t idx = 0; idx < modules.GetSize(); idx++) - { - lldb::ModuleSP module_sp = modules.GetModuleAtIndex(idx); - if (!module_sp) - continue; - if (strcmp(module_sp->GetFileSpec().GetFilename().AsCString(""),"Foundation") == 0) - { - module_sp->GetVersion(&major,1); - break; - } - } - return major; -} - ObjCLanguageRuntime::ClassDescriptorSP AppleObjCRuntimeV2::TaggedPointerVendorLegacy::GetClassDescriptor (lldb::addr_t ptr) { if (!IsPossibleTaggedPointer(ptr)) return ObjCLanguageRuntime::ClassDescriptorSP(); - Process* process(m_runtime.GetProcess()); - - if (m_Foundation_version == 0) - m_Foundation_version = GetFoundationVersion(process->GetTarget()); + uint32_t foundation_version = m_runtime.GetFoundationVersion(); - if (m_Foundation_version == UINT32_MAX) + if (foundation_version == LLDB_INVALID_MODULE_VERSION) return ObjCLanguageRuntime::ClassDescriptorSP(); uint64_t class_bits = (ptr & 0xE) >> 1; ConstString name; // TODO: make a table - if (m_Foundation_version >= 900) + if (foundation_version >= 900) { switch (class_bits) { diff --git a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.h b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.h index 5ee73400f7e..c6addc624a5 100644 --- a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.h +++ b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.h @@ -226,16 +226,10 @@ private: GetClassDescriptor (lldb::addr_t ptr); protected: TaggedPointerVendorLegacy (AppleObjCRuntimeV2& runtime) : - TaggedPointerVendor (runtime), - m_Foundation_version(0) + TaggedPointerVendor (runtime) { } - static uint32_t - GetFoundationVersion (Target& target); - - uint32_t m_Foundation_version; - friend class AppleObjCRuntimeV2::TaggedPointerVendor; DISALLOW_COPY_AND_ASSIGN(TaggedPointerVendorLegacy); diff --git a/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp b/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp index 9aad296c47f..e4de46e24a1 100644 --- a/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp +++ b/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp @@ -526,7 +526,7 @@ ObjectFileELF::GetModuleSpecifications (const lldb_private::FileSpec& file, for (ProgramHeaderCollConstIter I = program_headers.begin(); I != program_headers.end(); ++I) { - segment_data_end = std::max (I->p_offset + I->p_filesz, segment_data_end); + segment_data_end = std::max<unsigned long long> (I->p_offset + I->p_filesz, segment_data_end); } if (segment_data_end > data_sp->GetByteSize()) |