From 747bcb03d25144951e24d957fc667bb497c88ed9 Mon Sep 17 00:00:00 2001 From: Greg Clayton <gclayton@apple.com> Date: Sat, 17 Sep 2011 06:21:20 +0000 Subject: [PATCH] Convert lldb::ModuleSP to use an instrusive ref counted pointer. We had some cases where getting the shared pointer for a module from the global module list was causing a performance issue when debugging with DWARF in .o files. Now that the module uses intrusive ref counts, we can easily convert any pointer to a shared pointer. llvm-svn: 139983 --- lldb/include/lldb/Core/Module.h | 1 + lldb/include/lldb/Symbol/SymbolContext.h | 11 +- lldb/include/lldb/Utility/SharingPtr.h | 277 +++++++++++++++++- lldb/include/lldb/lldb-forward-rtti.h | 2 +- lldb/include/lldb/lldb-forward.h | 2 + lldb/include/lldb/lldb-types.h | 6 + .../xcshareddata/xcschemes/lldb-tool.xcscheme | 6 + lldb/source/Commands/CommandCompletions.cpp | 2 +- lldb/source/Core/Module.cpp | 3 +- lldb/source/Expression/ClangASTSource.cpp | 1 + .../ObjC/AppleObjCRuntime/AppleObjCRuntime.h | 2 +- .../AppleObjCRuntime/AppleObjCRuntimeV1.h | 4 - .../AppleObjCRuntime/AppleObjCRuntimeV2.cpp | 19 +- .../AppleObjCRuntime/AppleObjCRuntimeV2.h | 23 +- .../AppleObjCTrampolineHandler.cpp | 22 +- .../AppleObjCTrampolineHandler.h | 28 +- ...pleThreadPlanStepThroughObjCTrampoline.cpp | 2 + ...AppleThreadPlanStepThroughObjCTrampoline.h | 6 +- lldb/source/Symbol/SymbolContext.cpp | 24 +- lldb/source/Utility/SharingPtr.cpp | 64 ++-- .../source/MacOSX/i386/DNBArchImplI386.cpp | 3 +- .../MacOSX/x86_64/DNBArchImplX86_64.cpp | 2 +- 22 files changed, 415 insertions(+), 95 deletions(-) diff --git a/lldb/include/lldb/Core/Module.h b/lldb/include/lldb/Core/Module.h index 631172f5304f..670ffe68a909 100644 --- a/lldb/include/lldb/Core/Module.h +++ b/lldb/include/lldb/Core/Module.h @@ -44,6 +44,7 @@ namespace lldb_private { class Module : + public ReferenceCountedBaseVirtual<Module>, public SymbolContextScope { public: diff --git a/lldb/include/lldb/Symbol/SymbolContext.h b/lldb/include/lldb/Symbol/SymbolContext.h index c653486c6b62..8f6eb23352db 100644 --- a/lldb/include/lldb/Symbol/SymbolContext.h +++ b/lldb/include/lldb/Symbol/SymbolContext.h @@ -97,6 +97,7 @@ public: LineEntry *line_entry = NULL, Symbol *symbol = NULL); + ~SymbolContext (); //------------------------------------------------------------------ /// Copy constructor /// @@ -294,13 +295,9 @@ public: } SpecificationType; // This one produces a specifier that matches everything... - SymbolContextSpecifier (lldb::TargetSP target_sp) : - m_start_line(0), - m_end_line(0) - { - m_target_sp = target_sp; - m_type = eNothingSpecified; - } + SymbolContextSpecifier (const lldb::TargetSP& target_sp); + + ~SymbolContextSpecifier(); bool AddSpecification (const char *spec_string, SpecificationType type); diff --git a/lldb/include/lldb/Utility/SharingPtr.h b/lldb/include/lldb/Utility/SharingPtr.h index f52df47c1508..87c1b2f7ea0e 100644 --- a/lldb/include/lldb/Utility/SharingPtr.h +++ b/lldb/include/lldb/Utility/SharingPtr.h @@ -531,7 +531,282 @@ public: baton_ = 0; } }; + + +template <class T> +class IntrusiveSharingPtr; -} // namespace lldb +template <class T> +class ReferenceCountedBase +{ +public: + explicit ReferenceCountedBase(long refs = 0) + : shared_owners_(refs) + { + } + + void + add_shared() + { + __sync_add_and_fetch(&shared_owners_, 1); + } + void + release_shared() + { + if (__sync_add_and_fetch(&shared_owners_, -1) == -1) + delete static_cast<T*>(this); + } + + long + use_count() const + { + return shared_owners_ + 1; + } + +protected: + long shared_owners_; + + friend class IntrusiveSharingPtr<T>; + +private: + ReferenceCountedBase(const ReferenceCountedBase&); + ReferenceCountedBase& operator=(const ReferenceCountedBase&); +}; + + +//template <class T> +//class ReferenceCountedBaseVirtual +//{ +//public: +// explicit ReferenceCountedBaseVirtual(long refs = 0) : +// shared_owners_(refs) +// { +// } +// +// void +// add_shared(); +// +// void +// release_shared(); +// +// long +// use_count() const +// { +// return shared_owners_ + 1; +// } +// +//protected: +// long shared_owners_; +// +// virtual ~ReferenceCountedBaseVirtual() {} +// +// friend class IntrusiveSharingPtr<T>; +// +//private: +// ReferenceCountedBaseVirtual(const ReferenceCountedBaseVirtual&); +// ReferenceCountedBaseVirtual& operator=(const ReferenceCountedBaseVirtual&); +//}; +// +//template <class T> +//void +//ReferenceCountedBaseVirtual<T>::add_shared() +//{ +// __sync_add_and_fetch(&shared_owners_, 1); +//} +// +//template <class T> +//void +//ReferenceCountedBaseVirtual<T>::release_shared() +//{ +// if (__sync_add_and_fetch(&shared_owners_, -1) == -1) +// delete this; +//} + + +template <class T> +class ReferenceCountedBaseVirtual : public imp::shared_count +{ +public: + explicit ReferenceCountedBaseVirtual () : + imp::shared_count(-1) + { + } + + virtual + ~ReferenceCountedBaseVirtual () + { + } + + virtual void on_zero_shared (); + +}; + +template <class T> +void +ReferenceCountedBaseVirtual<T>::on_zero_shared() +{ +} + +template <typename T> +class IntrusiveSharingPtr +{ +public: + typedef T element_type; + + explicit + IntrusiveSharingPtr () : + ptr_(0) + { + } + + explicit + IntrusiveSharingPtr (T* ptr) : + ptr_(ptr) + { + add_shared(); + } + + IntrusiveSharingPtr (const IntrusiveSharingPtr& rhs) : + ptr_(rhs.ptr_) + { + add_shared(); + } + + template <class X> + IntrusiveSharingPtr (const IntrusiveSharingPtr<X>& rhs) + : ptr_(rhs.get()) + { + add_shared(); + } + + IntrusiveSharingPtr& + operator= (const IntrusiveSharingPtr& rhs) + { + reset(rhs.get()); + return *this; + } + + template <class X> IntrusiveSharingPtr& + operator= (const IntrusiveSharingPtr<X>& rhs) + { + reset(rhs.get()); + return *this; + } + + IntrusiveSharingPtr& + operator= (T *ptr) + { + reset(ptr); + return *this; + } + + ~IntrusiveSharingPtr() + { + release_shared(); + } + + T& + operator*() const + { + return *ptr_; + } + + T* + operator->() const + { + return ptr_; + } + + T* + get() const + { + return ptr_; + } + + operator bool() const + { + return ptr_ != 0; + } + + void + swap (IntrusiveSharingPtr& rhs) + { + std::swap(ptr_, rhs.ptr_); + } + + void + reset(T* ptr = NULL) + { + IntrusiveSharingPtr(ptr).swap(*this); + } + + long + use_count () const + { + if (ptr_) + return ptr_->use_count(); + return 0; + } + + bool + unique () const + { + return use_count () == 1; + } + +private: + element_type *ptr_; + + void + add_shared() + { + if (ptr_) + ptr_->add_shared(); + } + void + release_shared() + { + if (ptr_) + ptr_->release_shared(); + } +}; + +template<class T, class U> +inline bool operator== (const IntrusiveSharingPtr<T>& lhs, const IntrusiveSharingPtr<U>& rhs) +{ + return lhs.get() == rhs.get(); +} + +template<class T, class U> +inline bool operator!= (const IntrusiveSharingPtr<T>& lhs, const IntrusiveSharingPtr<U>& rhs) +{ + return lhs.get() != rhs.get(); +} + +template<class T, class U> +inline bool operator== (const IntrusiveSharingPtr<T>& lhs, U* rhs) +{ + return lhs.get() == rhs; +} + +template<class T, class U> +inline bool operator!= (const IntrusiveSharingPtr<T>& lhs, U* rhs) +{ + return lhs.get() != rhs; +} + +template<class T, class U> +inline bool operator== (T* lhs, const IntrusiveSharingPtr<U>& rhs) +{ + return lhs == rhs.get(); +} + +template<class T, class U> +inline bool operator!= (T* lhs, const IntrusiveSharingPtr<U>& rhs) +{ + return lhs != rhs.get(); +} + +} // namespace lldb_private #endif // utility_SharingPtr_h_ diff --git a/lldb/include/lldb/lldb-forward-rtti.h b/lldb/include/lldb/lldb-forward-rtti.h index 95f8a84188d0..7a83f672d987 100644 --- a/lldb/include/lldb/lldb-forward-rtti.h +++ b/lldb/include/lldb/lldb-forward-rtti.h @@ -50,7 +50,7 @@ namespace lldb { typedef SharedPtr<lldb_private::Listener>::Type ListenerSP; typedef SharedPtr<lldb_private::Log>::Type LogSP; typedef SharedPtr<lldb_private::LogChannel>::Type LogChannelSP; - typedef SharedPtr<lldb_private::Module>::Type ModuleSP; + typedef IntrusiveSharedPtr<lldb_private::Module>::Type ModuleSP; typedef SharedPtr<lldb_private::OptionValue>::Type OptionValueSP; typedef SharedPtr<lldb_private::Platform>::Type PlatformSP; typedef SharedPtr<lldb_private::Process>::Type ProcessSP; diff --git a/lldb/include/lldb/lldb-forward.h b/lldb/include/lldb/lldb-forward.h index ac155ff7798d..9bf9d6b7481f 100644 --- a/lldb/include/lldb/lldb-forward.h +++ b/lldb/include/lldb/lldb-forward.h @@ -48,8 +48,10 @@ class ClangExpressionVariable; class ClangExpressionVariableList; class ClangExpressionVariableList; class ClangExpressionVariables; +class ClangFunction; class ClangPersistentVariables; class ClangUserExpression; +class ClangUtilityFunction; class CommandInterpreter; class CommandObject; class CommandReturnObject; diff --git a/lldb/include/lldb/lldb-types.h b/lldb/include/lldb/lldb-types.h index 2981a781ebea..e6997ad8c234 100644 --- a/lldb/include/lldb/lldb-types.h +++ b/lldb/include/lldb/lldb-types.h @@ -69,6 +69,12 @@ namespace lldb { { typedef lldb_private::LoggingSharingPtr<_Tp> Type; }; + + template <typename _Tp> + struct IntrusiveSharedPtr + { + typedef lldb_private::IntrusiveSharingPtr<_Tp> Type; + }; } // namespace lldb diff --git a/lldb/lldb.xcodeproj/xcshareddata/xcschemes/lldb-tool.xcscheme b/lldb/lldb.xcodeproj/xcshareddata/xcschemes/lldb-tool.xcscheme index 6e12c06c956d..b75591c9809b 100644 --- a/lldb/lldb.xcodeproj/xcshareddata/xcschemes/lldb-tool.xcscheme +++ b/lldb/lldb.xcodeproj/xcshareddata/xcschemes/lldb-tool.xcscheme @@ -99,6 +99,12 @@ ReferencedContainer = "container:lldb.xcodeproj"> </BuildableReference> </BuildableProductRunnable> + <CommandLineArguments> + <CommandLineArgument + argument = "/Volumes/work/gclayton/Documents/src/args/a.out" + isEnabled = "YES"> + </CommandLineArgument> + </CommandLineArguments> <EnvironmentVariables> <EnvironmentVariable key = "LLDB_LAUNCH_FLAG_DISABLE_ASLR" diff --git a/lldb/source/Commands/CommandCompletions.cpp b/lldb/source/Commands/CommandCompletions.cpp index ff3c0c407337..3ea62aa0ed18 100644 --- a/lldb/source/Commands/CommandCompletions.cpp +++ b/lldb/source/Commands/CommandCompletions.cpp @@ -684,7 +684,7 @@ CommandCompletions::ModuleCompleter::SearchCallback ( bool complete ) { - if (context.module_sp != NULL) + if (context.module_sp) { const char *cur_file_name = context.module_sp->GetFileSpec().GetFilename().GetCString(); const char *cur_dir_name = context.module_sp->GetFileSpec().GetDirectory().GetCString(); diff --git a/lldb/source/Core/Module.cpp b/lldb/source/Core/Module.cpp index 4c997969ea41..2786600b3803 100644 --- a/lldb/source/Core/Module.cpp +++ b/lldb/source/Core/Module.cpp @@ -131,7 +131,8 @@ Module::~Module() ModuleSP Module::GetSP () const { - return ModuleList::GetModuleSP (this); + ModuleSP module_sp(const_cast<Module*>(this)); + return module_sp; } const lldb_private::UUID& diff --git a/lldb/source/Expression/ClangASTSource.cpp b/lldb/source/Expression/ClangASTSource.cpp index a5ac2c3805f8..26bf0b95b224 100644 --- a/lldb/source/Expression/ClangASTSource.cpp +++ b/lldb/source/Expression/ClangASTSource.cpp @@ -10,6 +10,7 @@ #include "clang/AST/ASTContext.h" #include "lldb/Core/Log.h" +#include "lldb/Core/Module.h" #include "lldb/Expression/ClangASTSource.h" #include "lldb/Expression/ClangExpression.h" #include "lldb/Expression/ClangExpressionDeclMap.h" diff --git a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.h b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.h index 431787729558..4f2b70e4fd44 100644 --- a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.h +++ b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.h @@ -98,7 +98,7 @@ protected: AppleIsModuleObjCLibrary (const lldb::ModuleSP &module_sp); static enum ObjCRuntimeVersions - GetObjCVersion (Process *process, ModuleSP &objc_module_sp); + GetObjCVersion (Process *process, lldb::ModuleSP &objc_module_sp); //------------------------------------------------------------------ // PluginInterface protocol diff --git a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.h b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.h index 0e7d87ce2f2b..1f2ace45f2db 100644 --- a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.h +++ b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.h @@ -15,12 +15,8 @@ // Other libraries and framework includes // Project includes #include "lldb/lldb-private.h" -#include "lldb/Target/LanguageRuntime.h" #include "lldb/Target/ObjCLanguageRuntime.h" -#include "lldb/Core/ValueObject.h" #include "AppleObjCRuntime.h" -#include "AppleObjCTrampolineHandler.h" -#include "AppleThreadPlanStepThroughObjCTrampoline.h" namespace lldb_private { diff --git a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp index 4d4d4fbebf50..ef62462e7ad0 100644 --- a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp +++ b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp @@ -91,8 +91,9 @@ extern \"C\" void *__lldb_apple_objc_v2_find_class_name ( const char *AppleObjCRuntimeV2::g_objc_class_symbol_prefix = "OBJC_CLASS_$_"; const char *AppleObjCRuntimeV2::g_objc_class_data_section_name = "__objc_data"; -AppleObjCRuntimeV2::AppleObjCRuntimeV2 (Process *process, ModuleSP &objc_module_sp) : - lldb_private::AppleObjCRuntime (process), +AppleObjCRuntimeV2::AppleObjCRuntimeV2 (Process *process, + const ModuleSP &objc_module_sp) : + AppleObjCRuntime (process), m_get_class_name_args(LLDB_INVALID_ADDRESS), m_get_class_name_args_mutex(Mutex::eMutexTypeNormal), m_isa_to_name_cache(), @@ -109,7 +110,7 @@ AppleObjCRuntimeV2::RunFunctionToFindClassName(lldb::addr_t object_addr, Thread StreamString errors; - LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_STEP)); // FIXME - a more appropriate log channel? + LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_STEP)); // FIXME - a more appropriate log channel? int32_t debug; if (log) @@ -417,7 +418,7 @@ AppleObjCRuntimeV2::GetDynamicTypeAndAddress (ValueObject &in_value, //------------------------------------------------------------------ // Static Functions //------------------------------------------------------------------ -lldb_private::LanguageRuntime * +LanguageRuntime * AppleObjCRuntimeV2::CreateInstance (Process *process, lldb::LanguageType language) { // FIXME: This should be a MacOS or iOS process, and we need to look for the OBJC section to make @@ -581,7 +582,7 @@ AppleObjCRuntimeV2::IsTaggedPointer(lldb::addr_t ptr) // this code relies on the assumption that an Objective-C object always starts // with an ISA at offset 0. an ISA is effectively a pointer to an instance of // struct class_t in the ObjCv2 runtime -lldb_private::ObjCLanguageRuntime::ObjCISA +ObjCLanguageRuntime::ObjCISA AppleObjCRuntimeV2::GetISA(ValueObject& valobj) { if (ClangASTType::GetMinimumLanguage(valobj.GetClangAST(),valobj.GetClangType()) != lldb::eLanguageTypeObjC) @@ -602,7 +603,7 @@ AppleObjCRuntimeV2::GetISA(ValueObject& valobj) uint8_t pointer_size = valobj.GetUpdatePoint().GetProcessSP()->GetAddressByteSize(); Error error; - lldb_private::ObjCLanguageRuntime::ObjCISA isa = + ObjCLanguageRuntime::ObjCISA isa = valobj.GetUpdatePoint().GetProcessSP()->ReadUnsignedIntegerFromMemory(isa_pointer, pointer_size, 0, @@ -613,7 +614,7 @@ AppleObjCRuntimeV2::GetISA(ValueObject& valobj) // TODO: should we have a transparent_kvo parameter here to say if we // want to replace the KVO swizzled class with the actual user-level type? ConstString -AppleObjCRuntimeV2::GetActualTypeName(lldb_private::ObjCLanguageRuntime::ObjCISA isa) +AppleObjCRuntimeV2::GetActualTypeName(ObjCLanguageRuntime::ObjCISA isa) { if (!IsValidISA(isa)) return ConstString(NULL); @@ -713,8 +714,8 @@ AppleObjCRuntimeV2::GetActualTypeName(lldb_private::ObjCLanguageRuntime::ObjCISA return ConstString("unknown"); } -lldb_private::ObjCLanguageRuntime::ObjCISA -AppleObjCRuntimeV2::GetParentClass(lldb_private::ObjCLanguageRuntime::ObjCISA isa) +ObjCLanguageRuntime::ObjCISA +AppleObjCRuntimeV2::GetParentClass(ObjCLanguageRuntime::ObjCISA isa) { if (!IsValidISA(isa)) return 0; diff --git a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.h b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.h index 229a1b3288bd..64ef4447d2a1 100644 --- a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.h +++ b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.h @@ -18,12 +18,8 @@ // Other libraries and framework includes // Project includes #include "lldb/lldb-private.h" -#include "lldb/Target/LanguageRuntime.h" #include "lldb/Target/ObjCLanguageRuntime.h" -#include "lldb/Core/ValueObject.h" #include "AppleObjCRuntime.h" -#include "AppleObjCTrampolineHandler.h" -#include "AppleThreadPlanStepThroughObjCTrampoline.h" namespace lldb_private { @@ -81,7 +77,7 @@ public: GetByteOffsetForIvar (ClangASTType &parent_qual_type, const char *ivar_name); virtual bool - IsValidISA(ObjCISA isa) + IsValidISA (ObjCLanguageRuntime::ObjCISA isa) { return (isa != 0); } @@ -89,28 +85,29 @@ public: // this is not a valid ISA in the sense that no valid // class pointer can live at address 1. we use it to refer to // tagged types, where the ISA must be dynamically determined - static const ObjCISA g_objc_Tagged_ISA = 1; + static const ObjCLanguageRuntime::ObjCISA g_objc_Tagged_ISA = 1; - virtual ObjCISA + virtual ObjCLanguageRuntime::ObjCISA GetISA(ValueObject& valobj); virtual ConstString - GetActualTypeName(ObjCISA isa); + GetActualTypeName(ObjCLanguageRuntime::ObjCISA isa); - virtual ObjCISA - GetParentClass(ObjCISA isa); + virtual ObjCLanguageRuntime::ObjCISA + GetParentClass(ObjCLanguageRuntime::ObjCISA isa); protected: private: - typedef std::map<ObjCISA,ConstString> ISAToNameCache; - typedef std::map<ObjCISA,ObjCISA> ISAToParentCache; + typedef std::map<ObjCLanguageRuntime::ObjCISA, ConstString> ISAToNameCache; + typedef std::map<ObjCLanguageRuntime::ObjCISA, ObjCLanguageRuntime::ObjCISA> ISAToParentCache; typedef ISAToNameCache::iterator ISAToNameIterator; typedef ISAToParentCache::iterator ISAToParentIterator; - AppleObjCRuntimeV2(Process *process, ModuleSP &objc_module_sp); + AppleObjCRuntimeV2 (Process *process, + const lldb::ModuleSP &objc_module_sp); bool IsTaggedPointer(lldb::addr_t ptr); diff --git a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTrampolineHandler.cpp b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTrampolineHandler.cpp index 8bee1545f715..9a5dbc255c9e 100644 --- a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTrampolineHandler.cpp +++ b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTrampolineHandler.cpp @@ -22,6 +22,10 @@ #include "lldb/Core/Log.h" #include "lldb/Core/Module.h" #include "lldb/Core/Value.h" +#include "lldb/Expression/ClangExpression.h" +#include "lldb/Expression/ClangFunction.h" +#include "lldb/Expression/ClangUtilityFunction.h" + #include "lldb/Symbol/ClangASTContext.h" #include "lldb/Target/ObjCLanguageRuntime.h" #include "lldb/Target/Process.h" @@ -156,6 +160,10 @@ AppleObjCTrampolineHandler::AppleObjCVTables::VTableRegion::VTableRegion(AppleOb SetUpRegion (); } +AppleObjCTrampolineHandler::~AppleObjCTrampolineHandler() +{ +} + void AppleObjCTrampolineHandler::AppleObjCVTables::VTableRegion::SetUpRegion() { @@ -301,11 +309,12 @@ AppleObjCTrampolineHandler::AppleObjCVTables::VTableRegion::Dump (Stream &s) } } -AppleObjCTrampolineHandler::AppleObjCVTables::AppleObjCVTables (ProcessSP &process_sp, ModuleSP &objc_module_sp) : - m_process_sp(process_sp), - m_trampoline_header(LLDB_INVALID_ADDRESS), - m_trampolines_changed_bp_id(LLDB_INVALID_BREAK_ID), - m_objc_module_sp(objc_module_sp) +AppleObjCTrampolineHandler::AppleObjCVTables::AppleObjCVTables (const ProcessSP &process_sp, + const ModuleSP &objc_module_sp) : + m_process_sp (process_sp), + m_trampoline_header (LLDB_INVALID_ADDRESS), + m_trampolines_changed_bp_id (LLDB_INVALID_BREAK_ID), + m_objc_module_sp (objc_module_sp) { } @@ -510,7 +519,8 @@ AppleObjCTrampolineHandler::g_dispatch_functions[] = {NULL} }; -AppleObjCTrampolineHandler::AppleObjCTrampolineHandler (ProcessSP process_sp, ModuleSP objc_module_sp) : +AppleObjCTrampolineHandler::AppleObjCTrampolineHandler (const ProcessSP &process_sp, + const ModuleSP &objc_module_sp) : m_process_sp (process_sp), m_objc_module_sp (objc_module_sp), m_impl_fn_addr (LLDB_INVALID_ADDRESS), diff --git a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTrampolineHandler.h b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTrampolineHandler.h index 742685fab1c7..96094c199461 100644 --- a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTrampolineHandler.h +++ b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTrampolineHandler.h @@ -13,28 +13,27 @@ // C Includes // C++ Includes #include <map> -#include <string> +#include <vector> // Other libraries and framework includes // Project includes -#include "lldb/Expression/ClangExpression.h" -#include "lldb/Expression/ClangFunction.h" -#include "lldb/Expression/ClangUtilityFunction.h" +#include "lldb/lldb-public.h" #include "lldb/Host/Mutex.h" namespace lldb_private { -using namespace lldb; class AppleObjCTrampolineHandler { public: - AppleObjCTrampolineHandler (ProcessSP process_sp, ModuleSP objc_module_sp); + AppleObjCTrampolineHandler (const lldb::ProcessSP &process_sp, + const lldb::ModuleSP &objc_module_sp); - ~AppleObjCTrampolineHandler() {} + ~AppleObjCTrampolineHandler(); - ThreadPlanSP - GetStepThroughDispatchPlan (Thread &thread, bool stop_others); + lldb::ThreadPlanSP + GetStepThroughDispatchPlan (Thread &thread, + bool stop_others); ClangFunction * GetLookupImplementationWrapperFunction (); @@ -80,7 +79,7 @@ private: private: struct VTableDescriptor { - VTableDescriptor(uint32_t in_flags, addr_t in_code_start) : + VTableDescriptor(uint32_t in_flags, lldb::addr_t in_code_start) : flags(in_flags), code_start(in_code_start) {} @@ -151,7 +150,8 @@ private: }; public: - AppleObjCVTables(ProcessSP &process_sp, ModuleSP &objc_module_sp); + AppleObjCVTables(const lldb::ProcessSP &process_sp, + const lldb::ModuleSP &objc_module_sp); ~AppleObjCVTables(); @@ -177,7 +177,7 @@ private: } private: - ProcessSP m_process_sp; + lldb::ProcessSP m_process_sp; typedef std::vector<VTableRegion> region_collection; lldb::addr_t m_trampoline_header; lldb::break_id_t m_trampolines_changed_bp_id; @@ -190,8 +190,8 @@ private: typedef std::map<lldb::addr_t, int> MsgsendMap; // This table maps an dispatch fn address to the index in g_dispatch_functions MsgsendMap m_msgSend_map; - ProcessSP m_process_sp; - ModuleSP m_objc_module_sp; + lldb::ProcessSP m_process_sp; + lldb::ModuleSP m_objc_module_sp; std::auto_ptr<ClangFunction> m_impl_function; std::auto_ptr<ClangUtilityFunction> m_impl_code; Mutex m_impl_function_mutex; diff --git a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleThreadPlanStepThroughObjCTrampoline.cpp b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleThreadPlanStepThroughObjCTrampoline.cpp index f235fd579745..62941bfc2323 100644 --- a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleThreadPlanStepThroughObjCTrampoline.cpp +++ b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleThreadPlanStepThroughObjCTrampoline.cpp @@ -23,6 +23,8 @@ #include "lldb/Target/ThreadPlanStepOut.h" #include "lldb/Core/Log.h" + +using namespace lldb; using namespace lldb_private; //---------------------------------------------------------------------- diff --git a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleThreadPlanStepThroughObjCTrampoline.h b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleThreadPlanStepThroughObjCTrampoline.h index e2d2ebc90439..e66ffad4672c 100644 --- a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleThreadPlanStepThroughObjCTrampoline.h +++ b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleThreadPlanStepThroughObjCTrampoline.h @@ -82,9 +82,9 @@ private: lldb::addr_t m_object_addr; // This is only for Description. lldb::addr_t m_isa_addr; // isa_addr and sel_addr are the keys we will use to cache the implementation. lldb::addr_t m_sel_addr; - ThreadPlanSP m_func_sp; // This is the function call plan. We fill it at start, then set it - // to NULL when this plan is done. That way we know to go to: - ThreadPlanSP m_run_to_sp; // The plan that runs to the target. + lldb::ThreadPlanSP m_func_sp; // This is the function call plan. We fill it at start, then set it + // to NULL when this plan is done. That way we know to go to: + lldb::ThreadPlanSP m_run_to_sp; // The plan that runs to the target. ClangFunction *m_impl_function; // This is a pointer to a impl function that // is owned by the client that pushes this plan. bool m_stop_others; diff --git a/lldb/source/Symbol/SymbolContext.cpp b/lldb/source/Symbol/SymbolContext.cpp index 6d570d79ea72..23722f6f75a5 100644 --- a/lldb/source/Symbol/SymbolContext.cpp +++ b/lldb/source/Symbol/SymbolContext.cpp @@ -82,6 +82,10 @@ SymbolContext::SymbolContext (SymbolContextScope *sc_scope) : sc_scope->CalculateSymbolContext (this); } +SymbolContext::~SymbolContext () +{ +} + const SymbolContext& SymbolContext::operator= (const SymbolContext& rhs) { @@ -447,7 +451,7 @@ SymbolContext::FindFunctionsByName (const ConstString &name, // for methods matching name. } - if (module_sp != NULL) + if (module_sp) module_sp->FindFunctions (name, eFunctionNameTypeBase | eFunctionNameTypeFull, include_symbols, true, sc_list); if (target_sp) @@ -489,6 +493,24 @@ SymbolContext::FindTypeByName (const ConstString &name) const // //---------------------------------------------------------------------- +SymbolContextSpecifier::SymbolContextSpecifier (const TargetSP &target_sp) : + m_target_sp (target_sp), + m_module_spec (), + m_module_sp (), + m_file_spec_ap (), + m_start_line (0), + m_end_line (0), + m_function_spec (), + m_class_name (), + m_address_range_ap (), + m_type (eNothingSpecified) +{ +} + +SymbolContextSpecifier::~SymbolContextSpecifier() +{ +} + bool SymbolContextSpecifier::AddLineSpecification (uint32_t line_no, SpecificationType type) { diff --git a/lldb/source/Utility/SharingPtr.cpp b/lldb/source/Utility/SharingPtr.cpp index 88c103ac9e26..3ee01285a3b2 100644 --- a/lldb/source/Utility/SharingPtr.cpp +++ b/lldb/source/Utility/SharingPtr.cpp @@ -14,40 +14,42 @@ namespace lldb_private { namespace imp { -template <class T> -inline T -increment(T& t) -{ - return __sync_add_and_fetch(&t, 1); -} - -template <class T> -inline T -decrement(T& t) -{ - return __sync_add_and_fetch(&t, -1); -} - -shared_count::~shared_count() -{ -} - -void -shared_count::add_shared() -{ - increment(shared_owners_); -} - -void -shared_count::release_shared() -{ - if (decrement(shared_owners_) == -1) + template <class T> + inline T + increment(T& t) { - on_zero_shared(); - delete this; + return __sync_add_and_fetch(&t, 1); + } + + template <class T> + inline T + decrement(T& t) + { + return __sync_add_and_fetch(&t, -1); + } + + shared_count::~shared_count() + { + } + + void + shared_count::add_shared() + { + increment(shared_owners_); + } + + void + shared_count::release_shared() + { + if (decrement(shared_owners_) == -1) + { + on_zero_shared(); + delete this; + } } -} } // imp + } // namespace lldb + diff --git a/lldb/tools/debugserver/source/MacOSX/i386/DNBArchImplI386.cpp b/lldb/tools/debugserver/source/MacOSX/i386/DNBArchImplI386.cpp index 6ab93b37f435..50bf0b152319 100644 --- a/lldb/tools/debugserver/source/MacOSX/i386/DNBArchImplI386.cpp +++ b/lldb/tools/debugserver/source/MacOSX/i386/DNBArchImplI386.cpp @@ -252,7 +252,8 @@ enum gdb_ymm7 = gdb_xmm7 }; -enum DNBArchImplI386::AVXPresence DNBArchImplI386::s_has_avx = DNBArchImplI386::kAVXUnknown; +// AVX support isn't working at all from user space, so disable it for now. +enum DNBArchImplI386::AVXPresence DNBArchImplI386::s_has_avx = DNBArchImplI386::kAVXNotPresent; uint64_t DNBArchImplI386::GetPC(uint64_t failValue) diff --git a/lldb/tools/debugserver/source/MacOSX/x86_64/DNBArchImplX86_64.cpp b/lldb/tools/debugserver/source/MacOSX/x86_64/DNBArchImplX86_64.cpp index 6fc19dba1820..26cfa66dfc24 100644 --- a/lldb/tools/debugserver/source/MacOSX/x86_64/DNBArchImplX86_64.cpp +++ b/lldb/tools/debugserver/source/MacOSX/x86_64/DNBArchImplX86_64.cpp @@ -65,7 +65,7 @@ static bool ForceAVXRegs () #define FORCE_AVX_REGS (0) #endif -enum DNBArchImplX86_64::AVXPresence DNBArchImplX86_64::s_has_avx = DNBArchImplX86_64::kAVXUnknown; +enum DNBArchImplX86_64::AVXPresence DNBArchImplX86_64::s_has_avx = DNBArchImplX86_64::kAVXNotPresent; uint64_t DNBArchImplX86_64::GetPC(uint64_t failValue)