From e1cd1be6d64cde1765336489d05d71cd2785f15a Mon Sep 17 00:00:00 2001 From: Greg Clayton Date: Sun, 29 Jan 2012 20:56:30 +0000 Subject: [PATCH] Switching back to using std::tr1::shared_ptr. We originally switched away due to RTTI worries since llvm and clang don't use RTTI, but I was able to switch back with no issues as far as I can tell. Once the RTTI issue wasn't an issue, we were looking for a way to properly track weak pointers to objects to solve some of the threading issues we have been running into which naturally led us back to std::tr1::weak_ptr. We also wanted the ability to make a shared pointer from just a pointer, which is also easily solved using the std::tr1::enable_shared_from_this class. The main reason for this move back is so we can start properly having weak references to objects. Currently a lldb_private::Thread class has a refrence to its parent lldb_private::Process. This doesn't work well when we now hand out a SBThread object that contains a shared pointer to a lldb_private::Thread as this SBThread can be held onto by external clients and if they end up using one of these objects we can easily crash. So the next task is to start adopting std::tr1::weak_ptr where ever it makes sense which we can do with lldb_private::Debugger, lldb_private::Target, lldb_private::Process, lldb_private::Thread, lldb_private::StackFrame, and many more objects now that they are no longer using intrusive ref counted pointer objects (you can't do std::tr1::weak_ptr functionality with intrusive pointers). llvm-svn: 149207 --- lldb/include/lldb/Breakpoint/Breakpoint.h | 6 +- .../lldb/Breakpoint/BreakpointLocation.h | 2 +- lldb/include/lldb/Breakpoint/BreakpointSite.h | 6 +- lldb/include/lldb/Core/Address.h | 5 +- lldb/include/lldb/Core/Debugger.h | 5 +- lldb/include/lldb/Core/FormatClasses.h | 16 +- lldb/include/lldb/Core/FormatManager.h | 2 +- lldb/include/lldb/Core/FormatNavigator.h | 2 +- lldb/include/lldb/Core/Module.h | 2 +- lldb/include/lldb/Core/SearchFilter.h | 14 +- lldb/include/lldb/Core/SourceManager.h | 2 +- .../lldb/Expression/ClangExpressionVariable.h | 2 +- .../lldb/Expression/ClangUserExpression.h | 2 +- lldb/include/lldb/Interpreter/Args.h | 2 +- lldb/include/lldb/Symbol/ClangASTImporter.h | 13 +- lldb/include/lldb/Symbol/DWARFCallFrameInfo.h | 2 +- lldb/include/lldb/Symbol/ObjectFile.h | 5 +- lldb/include/lldb/Symbol/Type.h | 4 +- lldb/include/lldb/Target/Memory.h | 2 +- lldb/include/lldb/Target/Process.h | 7 +- lldb/include/lldb/Target/RegisterContext.h | 1 + lldb/include/lldb/Target/StackFrame.h | 5 +- lldb/include/lldb/Target/Target.h | 7 +- lldb/include/lldb/Target/Thread.h | 6 +- lldb/include/lldb/Target/ThreadList.h | 3 + .../lldb/Utility/PriorityPointerPair.h | 2 +- lldb/include/lldb/lldb-forward-rtti.h | 138 +++++++++--------- lldb/include/lldb/lldb-types.h | 37 ++--- .../xcshareddata/xcschemes/lldb-tool.xcscheme | 11 ++ lldb/source/API/SBAddress.cpp | 4 +- lldb/source/API/SBBreakpoint.cpp | 4 +- lldb/source/API/SBBreakpointLocation.cpp | 2 +- lldb/source/API/SBFrame.cpp | 2 +- lldb/source/API/SBFunction.cpp | 6 +- lldb/source/API/SBProcess.cpp | 2 +- lldb/source/API/SBSection.cpp | 2 +- lldb/source/API/SBSymbol.cpp | 6 +- lldb/source/API/SBTarget.cpp | 2 +- lldb/source/API/SBValue.cpp | 4 +- lldb/source/Breakpoint/Breakpoint.cpp | 8 - lldb/source/Breakpoint/BreakpointLocation.cpp | 9 +- lldb/source/Breakpoint/BreakpointSite.cpp | 4 +- lldb/source/Commands/CommandObjectArgs.cpp | 2 +- lldb/source/Commands/CommandObjectSource.cpp | 4 +- lldb/source/Commands/CommandObjectTarget.cpp | 10 +- lldb/source/Commands/CommandObjectType.cpp | 4 +- lldb/source/Core/Address.cpp | 49 ++++--- lldb/source/Core/AddressRange.cpp | 2 +- lldb/source/Core/Debugger.cpp | 8 - lldb/source/Core/Disassembler.cpp | 2 +- lldb/source/Core/Module.cpp | 8 +- lldb/source/Core/ModuleList.cpp | 2 +- lldb/source/Core/SearchFilter.cpp | 10 +- lldb/source/Core/ValueObject.cpp | 2 +- lldb/source/Core/ValueObjectMemory.cpp | 2 +- lldb/source/Expression/ClangASTSource.cpp | 2 +- lldb/source/Expression/ClangFunction.cpp | 6 +- .../source/Expression/ClangUserExpression.cpp | 2 +- .../Expression/ClangUtilityFunction.cpp | 2 +- lldb/source/Expression/IRInterpreter.cpp | 6 +- .../source/Interpreter/CommandInterpreter.cpp | 2 +- .../Interpreter/ScriptInterpreterPython.cpp | 4 +- .../Disassembler/llvm/DisassemblerLLVM.cpp | 2 +- .../MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp | 6 +- .../AppleObjCRuntime/AppleObjCRuntime.cpp | 2 +- .../AppleObjCSymbolVendor.cpp | 2 +- .../BSD-Archive/ObjectContainerBSDArchive.h | 2 +- .../Process/MacOSX-Kernel/ProcessKDPLog.cpp | 2 +- .../Process/Utility/RegisterContextLLDB.cpp | 16 +- .../Process/Utility/RegisterContextLLDB.h | 2 +- .../Plugins/Process/Utility/UnwindLLDB.cpp | 47 +++--- .../Plugins/Process/Utility/UnwindLLDB.h | 10 +- .../gdb-remote/ProcessGDBRemoteLog.cpp | 2 +- .../Plugins/SymbolFile/DWARF/DWARFDebugInfo.h | 2 +- .../Plugins/SymbolFile/DWARF/DWARFDebugLine.h | 4 +- .../SymbolFile/DWARF/SymbolFileDWARF.cpp | 22 ++- .../SymbolFile/DWARF/SymbolFileDWARF.h | 1 - .../DWARF/SymbolFileDWARFDebugMap.cpp | 8 +- .../DWARF/SymbolFileDWARFDebugMap.h | 2 +- .../SymbolFile/Symtab/SymbolFileSymtab.cpp | 2 +- .../MacOSX/SymbolVendorMacOSX.cpp | 2 +- lldb/source/Symbol/ObjectFile.cpp | 8 - lldb/source/Symbol/Symbol.cpp | 18 +-- lldb/source/Symbol/SymbolVendor.cpp | 2 +- lldb/source/Symbol/Type.cpp | 2 +- lldb/source/Symbol/Variable.cpp | 4 +- lldb/source/Target/ExecutionContext.cpp | 34 +++-- lldb/source/Target/Process.cpp | 17 +-- lldb/source/Target/StackFrame.cpp | 22 +-- lldb/source/Target/Target.cpp | 37 ++--- lldb/source/Target/Thread.cpp | 9 -- lldb/source/Target/ThreadList.cpp | 37 +++++ .../source/Target/ThreadPlanTestCondition.cpp | 2 +- lldb/source/lldb-log.cpp | 2 +- 94 files changed, 409 insertions(+), 416 deletions(-) diff --git a/lldb/include/lldb/Breakpoint/Breakpoint.h b/lldb/include/lldb/Breakpoint/Breakpoint.h index 30e9fc30af93..2c2174f9ba3c 100644 --- a/lldb/include/lldb/Breakpoint/Breakpoint.h +++ b/lldb/include/lldb/Breakpoint/Breakpoint.h @@ -74,7 +74,7 @@ namespace lldb_private { /// not by the breakpoint. //---------------------------------------------------------------------- class Breakpoint: - public ReferenceCountedBase, + public std::tr1::enable_shared_from_this, public Stoppoint { public: @@ -286,10 +286,6 @@ public: lldb::BreakpointLocationSP GetLocationAtIndex (uint32_t index); - - const lldb::BreakpointSP - GetSP (); - //------------------------------------------------------------------ // The next section deals with various breakpoint options. //------------------------------------------------------------------ diff --git a/lldb/include/lldb/Breakpoint/BreakpointLocation.h b/lldb/include/lldb/Breakpoint/BreakpointLocation.h index 6569e183dcf4..71126efde4d1 100644 --- a/lldb/include/lldb/Breakpoint/BreakpointLocation.h +++ b/lldb/include/lldb/Breakpoint/BreakpointLocation.h @@ -47,7 +47,7 @@ namespace lldb_private { //---------------------------------------------------------------------- class BreakpointLocation : - public ReferenceCountedBase, + public std::tr1::enable_shared_from_this, public StoppointLocation { public: diff --git a/lldb/include/lldb/Breakpoint/BreakpointSite.h b/lldb/include/lldb/Breakpoint/BreakpointSite.h index 718311528bf5..774aff822e0f 100644 --- a/lldb/include/lldb/Breakpoint/BreakpointSite.h +++ b/lldb/include/lldb/Breakpoint/BreakpointSite.h @@ -39,7 +39,7 @@ namespace lldb_private { //---------------------------------------------------------------------- class BreakpointSite : - public ReferenceCountedBase, + public std::tr1::enable_shared_from_this, public StoppointLocation { public: @@ -159,7 +159,7 @@ public: /// \a owner is the Breakpoint Location to add. //------------------------------------------------------------------ void - AddOwner (lldb::BreakpointLocationSP &owner); + AddOwner (const lldb::BreakpointLocationSP &owner); //------------------------------------------------------------------ /// This method returns the number of breakpoint locations currently @@ -263,7 +263,7 @@ private: // Only the Process can create breakpoint sites in // Process::CreateBreakpointSite (lldb::BreakpointLocationSP &, bool). BreakpointSite (BreakpointSiteList *list, - lldb::BreakpointLocationSP& owner, + const lldb::BreakpointLocationSP& owner, lldb::addr_t m_addr, lldb::tid_t tid, bool use_hardware); diff --git a/lldb/include/lldb/Core/Address.h b/lldb/include/lldb/Core/Address.h index 1b82346aa183..5b1980a299b3 100644 --- a/lldb/include/lldb/Core/Address.h +++ b/lldb/include/lldb/Core/Address.h @@ -435,7 +435,10 @@ public: /// isn't resolved yet. //------------------------------------------------------------------ Module * - GetModule () const; + GetModulePtr () const; + + lldb::ModuleSP + GetModuleSP () const; //------------------------------------------------------------------ /// Get const accessor for the section. diff --git a/lldb/include/lldb/Core/Debugger.h b/lldb/include/lldb/Core/Debugger.h index d5e308c8cd62..f17e5f0a1c66 100644 --- a/lldb/include/lldb/Core/Debugger.h +++ b/lldb/include/lldb/Core/Debugger.h @@ -251,7 +251,7 @@ private: class Debugger : - public ReferenceCountedBaseVirtual, + public std::tr1::enable_shared_from_this, public UserID, public DebuggerInstanceSettings { @@ -315,9 +315,6 @@ public: void Clear(); - lldb::DebuggerSP - GetSP (); - bool GetAsyncExecution (); diff --git a/lldb/include/lldb/Core/FormatClasses.h b/lldb/include/lldb/Core/FormatClasses.h index 2ed21063a5b9..985f108c3350 100644 --- a/lldb/include/lldb/Core/FormatClasses.h +++ b/lldb/include/lldb/Core/FormatClasses.h @@ -57,7 +57,7 @@ struct ValueFormat bool skipptr = false, bool skipref = false); - typedef lldb::SharedPtr::Type SharedPointer; + typedef SHARED_PTR(ValueFormat) SharedPointer; typedef bool(*ValueCallback)(void*, ConstString, const lldb::ValueFormatSP&); ~ValueFormat() @@ -115,7 +115,7 @@ public: virtual void Update() = 0; - typedef lldb::SharedPtr::Type SharedPointer; + typedef SHARED_PTR(SyntheticChildrenFrontEnd) SharedPointer; }; @@ -166,7 +166,7 @@ public: virtual SyntheticChildrenFrontEnd::SharedPointer GetFrontEnd(lldb::ValueObjectSP backend) = 0; - typedef lldb::SharedPtr::Type SharedPointer; + typedef SHARED_PTR(SyntheticChildren) SharedPointer; typedef bool(*SyntheticChildrenCallback)(void*, ConstString, const SyntheticChildren::SharedPointer&); }; @@ -266,7 +266,7 @@ public: return UINT32_MAX; } - typedef lldb::SharedPtr::Type SharedPointer; + typedef SHARED_PTR(SyntheticChildrenFrontEnd) SharedPointer; }; @@ -351,7 +351,7 @@ public: return m_interpreter->GetIndexOfChildWithName(m_wrapper, name.GetCString()); } - typedef lldb::SharedPtr::Type SharedPointer; + typedef SHARED_PTR(SyntheticChildrenFrontEnd) SharedPointer; }; @@ -550,7 +550,7 @@ public: virtual uint32_t GetIndexOfChildWithName (const ConstString &name_cs); - typedef lldb::SharedPtr::Type SharedPointer; + typedef SHARED_PTR(SyntheticChildrenFrontEnd) SharedPointer; }; @@ -628,7 +628,7 @@ struct SummaryFormat virtual std::string GetDescription() = 0; - typedef lldb::SharedPtr::Type SharedPointer; + typedef SHARED_PTR(SummaryFormat) SharedPointer; typedef bool(*SummaryCallback)(void*, ConstString, const lldb::SummaryFormatSP&); typedef bool(*RegexSummaryCallback)(void*, lldb::RegularExpressionSP, const lldb::SummaryFormatSP&); @@ -706,7 +706,7 @@ struct ScriptSummaryFormat : public SummaryFormat virtual std::string GetDescription(); - typedef lldb::SharedPtr::Type SharedPointer; + typedef SHARED_PTR(ScriptSummaryFormat) SharedPointer; }; diff --git a/lldb/include/lldb/Core/FormatManager.h b/lldb/include/lldb/Core/FormatManager.h index 8f56287ad2dc..4b1098b54fd9 100644 --- a/lldb/include/lldb/Core/FormatManager.h +++ b/lldb/include/lldb/Core/FormatManager.h @@ -154,7 +154,7 @@ public: const char** matching_category = NULL, FormatCategoryItems* matching_type = NULL); - typedef lldb::SharedPtr::Type SharedPointer; + typedef SHARED_PTR(FormatCategory) SharedPointer; private: SummaryNavigator::SharedPointer m_summary_nav; diff --git a/lldb/include/lldb/Core/FormatNavigator.h b/lldb/include/lldb/Core/FormatNavigator.h index 437cecadef10..8b0dfa446970 100644 --- a/lldb/include/lldb/Core/FormatNavigator.h +++ b/lldb/include/lldb/Core/FormatNavigator.h @@ -232,7 +232,7 @@ public: typedef typename MapType::mapped_type MapValueType; typedef typename BackEndType::CallbackType CallbackType; - typedef typename lldb::SharedPtr >::Type SharedPointer; + typedef typename std::tr1::shared_ptr > SharedPointer; friend class FormatCategory; diff --git a/lldb/include/lldb/Core/Module.h b/lldb/include/lldb/Core/Module.h index bf8ed401c745..2e187ee0ae69 100644 --- a/lldb/include/lldb/Core/Module.h +++ b/lldb/include/lldb/Core/Module.h @@ -44,7 +44,7 @@ namespace lldb_private { class Module : - public ReferenceCountedBaseVirtual, + public std::tr1::enable_shared_from_this, public SymbolContextScope { public: diff --git a/lldb/include/lldb/Core/SearchFilter.h b/lldb/include/lldb/Core/SearchFilter.h index 0101ec2862bd..e875c4f2e0ba 100644 --- a/lldb/include/lldb/Core/SearchFilter.h +++ b/lldb/include/lldb/Core/SearchFilter.h @@ -281,7 +281,7 @@ class SearchFilterForNonModuleSpecificSearches : public SearchFilter { public: - SearchFilterForNonModuleSpecificSearches (lldb::TargetSP &targetSP) : SearchFilter(targetSP) {}; + SearchFilterForNonModuleSpecificSearches (const lldb::TargetSP &targetSP) : SearchFilter(targetSP) {}; ~SearchFilterForNonModuleSpecificSearches () {} virtual bool @@ -311,7 +311,7 @@ public: /// @param[in] module /// The Module that limits the search. //------------------------------------------------------------------ - SearchFilterByModule (lldb::TargetSP &targetSP, + SearchFilterByModule (const lldb::TargetSP &targetSP, const FileSpec &module); SearchFilterByModule (const SearchFilterByModule& rhs); @@ -372,8 +372,8 @@ public: /// @param[in] module /// The Module that limits the search. //------------------------------------------------------------------ - SearchFilterByModuleList (lldb::TargetSP &targetSP, - const FileSpecList &module_list); + SearchFilterByModuleList (const lldb::TargetSP &targetSP, + const FileSpecList &module_list); SearchFilterByModuleList (const SearchFilterByModuleList& rhs); @@ -433,9 +433,9 @@ public: /// @param[in] module /// The Module that limits the search. //------------------------------------------------------------------ - SearchFilterByModuleListAndCU (lldb::TargetSP &targetSP, - const FileSpecList &module_list, - const FileSpecList &cu_list); + SearchFilterByModuleListAndCU (const lldb::TargetSP &targetSP, + const FileSpecList &module_list, + const FileSpecList &cu_list); SearchFilterByModuleListAndCU (const SearchFilterByModuleListAndCU& rhs); diff --git a/lldb/include/lldb/Core/SourceManager.h b/lldb/include/lldb/Core/SourceManager.h index 9fc9a3f89f48..fbbb7f13e5ce 100644 --- a/lldb/include/lldb/Core/SourceManager.h +++ b/lldb/include/lldb/Core/SourceManager.h @@ -79,7 +79,7 @@ public: #endif // SWIG - typedef lldb::SharedPtr::Type FileSP; + typedef std::tr1::shared_ptr FileSP; #ifndef SWIG diff --git a/lldb/include/lldb/Expression/ClangExpressionVariable.h b/lldb/include/lldb/Expression/ClangExpressionVariable.h index 00897265130e..cdc2b7a72c1f 100644 --- a/lldb/include/lldb/Expression/ClangExpressionVariable.h +++ b/lldb/include/lldb/Expression/ClangExpressionVariable.h @@ -216,7 +216,7 @@ public: void TransferAddress (bool force = false); - typedef lldb::SharedPtr::Type ValueObjectConstResultSP; + typedef SHARED_PTR(ValueObjectConstResult) ValueObjectConstResultSP; //---------------------------------------------------------------------- /// Members diff --git a/lldb/include/lldb/Expression/ClangUserExpression.h b/lldb/include/lldb/Expression/ClangUserExpression.h index 9e0080312b11..613434ceca18 100644 --- a/lldb/include/lldb/Expression/ClangUserExpression.h +++ b/lldb/include/lldb/Expression/ClangUserExpression.h @@ -47,7 +47,7 @@ namespace lldb_private class ClangUserExpression : public ClangExpression { public: - typedef lldb::SharedPtr::Type ClangUserExpressionSP; + typedef SHARED_PTR(ClangUserExpression) ClangUserExpressionSP; //------------------------------------------------------------------ /// Constructor diff --git a/lldb/include/lldb/Interpreter/Args.h b/lldb/include/lldb/Interpreter/Args.h index a5b66ac387c7..07811405a818 100644 --- a/lldb/include/lldb/Interpreter/Args.h +++ b/lldb/include/lldb/Interpreter/Args.h @@ -30,7 +30,7 @@ namespace lldb_private { typedef std::pair OptionArgValue; typedef std::pair OptionArgPair; typedef std::vector OptionArgVector; -typedef lldb::SharedPtr::Type OptionArgVectorSP; +typedef SHARED_PTR(OptionArgVector) OptionArgVectorSP; struct OptionArgElement { diff --git a/lldb/include/lldb/Symbol/ClangASTImporter.h b/lldb/include/lldb/Symbol/ClangASTImporter.h index 901081ff278e..1e1dd53c1870 100644 --- a/lldb/include/lldb/Symbol/ClangASTImporter.h +++ b/lldb/include/lldb/Symbol/ClangASTImporter.h @@ -86,7 +86,7 @@ public: // typedef std::vector < std::pair > NamespaceMap; - typedef lldb::SharedPtr::Type NamespaceMapSP; + typedef SHARED_PTR(NamespaceMap) NamespaceMapSP; void RegisterNamespaceMap (const clang::NamespaceDecl *decl, NamespaceMapSP &namespace_map); @@ -193,9 +193,9 @@ private: clang::ASTContext *m_source_ctx; }; - typedef lldb::SharedPtr::Type MinionSP; - typedef std::map MinionMap; - typedef std::map NamespaceMetaMap; + typedef SHARED_PTR(Minion) MinionSP; + typedef std::map MinionMap; + typedef std::map NamespaceMetaMap; struct ASTContextMetadata { @@ -216,11 +216,10 @@ private: MapCompleter *m_map_completer; }; - typedef lldb::SharedPtr::Type ASTContextMetadataSP; - + typedef SHARED_PTR(ASTContextMetadata) ASTContextMetadataSP; typedef std::map ContextMetadataMap; - ContextMetadataMap m_metadata_map; + ContextMetadataMap m_metadata_map; ASTContextMetadataSP GetContextMetadata (clang::ASTContext *dst_ctx) diff --git a/lldb/include/lldb/Symbol/DWARFCallFrameInfo.h b/lldb/include/lldb/Symbol/DWARFCallFrameInfo.h index 0d667aef14d8..bd646d150687 100644 --- a/lldb/include/lldb/Symbol/DWARFCallFrameInfo.h +++ b/lldb/include/lldb/Symbol/DWARFCallFrameInfo.h @@ -78,7 +78,7 @@ private: inst_length (0), ptr_encoding (0), initial_row() {} }; - typedef lldb::SharedPtr::Type CIESP; + typedef SHARED_PTR(CIE) CIESP; struct FDEEntry { diff --git a/lldb/include/lldb/Symbol/ObjectFile.h b/lldb/include/lldb/Symbol/ObjectFile.h index 1bbd8149135d..6b356e5c1b49 100644 --- a/lldb/include/lldb/Symbol/ObjectFile.h +++ b/lldb/include/lldb/Symbol/ObjectFile.h @@ -50,7 +50,7 @@ namespace lldb_private { /// this abstract class. //---------------------------------------------------------------------- class ObjectFile: - public ReferenceCountedBaseVirtual, + public std::tr1::enable_shared_from_this, public PluginInterface, public ModuleChild { @@ -100,9 +100,6 @@ public: virtual ~ObjectFile(); - lldb::ObjectFileSP - GetSP (); - //------------------------------------------------------------------ /// Dump a description of this object to a Stream. /// diff --git a/lldb/include/lldb/Symbol/Type.h b/lldb/include/lldb/Symbol/Type.h index 21e11dc56171..35fcd23d2c25 100644 --- a/lldb/include/lldb/Symbol/Type.h +++ b/lldb/include/lldb/Symbol/Type.h @@ -21,7 +21,7 @@ namespace lldb_private { class SymbolFileType : - public ReferenceCountedBaseVirtual, + public std::tr1::enable_shared_from_this, public UserID { public: @@ -50,7 +50,7 @@ class SymbolFileType : }; class Type : - public ReferenceCountedBaseVirtual, + public std::tr1::enable_shared_from_this, public UserID { public: diff --git a/lldb/include/lldb/Target/Memory.h b/lldb/include/lldb/Target/Memory.h index 941e4c0258bf..3a45c911b3ee 100644 --- a/lldb/include/lldb/Target/Memory.h +++ b/lldb/include/lldb/Target/Memory.h @@ -163,7 +163,7 @@ namespace lldb_private { DeallocateMemory (lldb::addr_t ptr); protected: - typedef lldb::SharedPtr::Type AllocatedBlockSP; + typedef std::tr1::shared_ptr AllocatedBlockSP; AllocatedBlockSP AllocatePage (uint32_t byte_size, diff --git a/lldb/include/lldb/Target/Process.h b/lldb/include/lldb/Target/Process.h index 730422abf74c..20f58489d2ea 100644 --- a/lldb/include/lldb/Target/Process.h +++ b/lldb/include/lldb/Target/Process.h @@ -1263,7 +1263,7 @@ protected: /// @brief A plug-in interface definition class for debugging a process. //---------------------------------------------------------------------- class Process : - public ReferenceCountedBaseVirtual, + public std::tr1::enable_shared_from_this, public UserID, public Broadcaster, public ExecutionContextScope, @@ -2769,7 +2769,7 @@ public: ClearBreakpointSiteByID (lldb::user_id_t break_id); lldb::break_id_t - CreateBreakpointSite (lldb::BreakpointLocationSP &owner, + CreateBreakpointSite (const lldb::BreakpointLocationSP &owner, bool use_hardware); Error @@ -2997,9 +2997,6 @@ public: virtual void CalculateExecutionContext (ExecutionContext &exe_ctx); - lldb::ProcessSP - GetSP (); - void SetSTDIOFileDescriptor (int file_descriptor); diff --git a/lldb/include/lldb/Target/RegisterContext.h b/lldb/include/lldb/Target/RegisterContext.h index 06742d2d7b11..af6a20e54ead 100644 --- a/lldb/include/lldb/Target/RegisterContext.h +++ b/lldb/include/lldb/Target/RegisterContext.h @@ -20,6 +20,7 @@ namespace lldb_private { class RegisterContext : + public std::tr1::enable_shared_from_this, public ExecutionContextScope { public: diff --git a/lldb/include/lldb/Target/StackFrame.h b/lldb/include/lldb/Target/StackFrame.h index e90959bcb43e..0995a04f8cfc 100644 --- a/lldb/include/lldb/Target/StackFrame.h +++ b/lldb/include/lldb/Target/StackFrame.h @@ -27,7 +27,7 @@ namespace lldb_private { class StackFrame : - public ReferenceCountedBaseVirtual, + public std::tr1::enable_shared_from_this, public ExecutionContextScope { public: @@ -166,9 +166,6 @@ public: virtual void CalculateExecutionContext (ExecutionContext &exe_ctx); - lldb::StackFrameSP - GetSP (); - bool GetStatus (Stream &strm, bool show_frame_info, diff --git a/lldb/include/lldb/Target/Target.h b/lldb/include/lldb/Target/Target.h index a202fb8ee6c8..a6132d891e4a 100644 --- a/lldb/include/lldb/Target/Target.h +++ b/lldb/include/lldb/Target/Target.h @@ -246,7 +246,7 @@ protected: // Target //---------------------------------------------------------------------- class Target : - public ReferenceCountedBaseVirtual, + public std::tr1::enable_shared_from_this, public Broadcaster, public ExecutionContextScope, public TargetInstanceSettings @@ -340,9 +340,6 @@ public: const lldb::ProcessSP & GetProcessSP () const; - lldb::TargetSP - GetSP(); - void Destroy(); @@ -912,7 +909,7 @@ public: StopHook (lldb::TargetSP target_sp, lldb::user_id_t uid); friend class Target; }; - typedef lldb::SharedPtr::Type StopHookSP; + typedef SHARED_PTR(StopHook) StopHookSP; // Add an empty stop hook to the Target's stop hook list, and returns a shared pointer to it in new_hook. // Returns the id of the new hook. diff --git a/lldb/include/lldb/Target/Thread.h b/lldb/include/lldb/Target/Thread.h index ab416ca2ab1e..437456748201 100644 --- a/lldb/include/lldb/Target/Thread.h +++ b/lldb/include/lldb/Target/Thread.h @@ -85,7 +85,7 @@ private: }; class Thread : - public ReferenceCountedBaseVirtual, + public std::tr1::enable_shared_from_this, public UserID, public ExecutionContextScope, public ThreadInstanceSettings @@ -233,9 +233,6 @@ public: lldb::StateType GetState() const; - lldb::ThreadSP - GetSP (); - void SetState (lldb::StateType state); @@ -769,6 +766,7 @@ public: protected: friend class ThreadPlan; + friend class ThreadList; friend class StackFrameList; // This is necessary to make sure thread assets get destroyed while the thread is still in good shape diff --git a/lldb/include/lldb/Target/ThreadList.h b/lldb/include/lldb/Target/ThreadList.h index 66fbd26ec0eb..3a998c49f852 100644 --- a/lldb/include/lldb/Target/ThreadList.h +++ b/lldb/include/lldb/Target/ThreadList.h @@ -59,6 +59,9 @@ public: void Clear(); + void + Destroy(); + // Note that "idx" is not the same as the "thread_index". It is a zero // based index to accessing the current threads, whereas "thread_index" // is a unique index assigned diff --git a/lldb/include/lldb/Utility/PriorityPointerPair.h b/lldb/include/lldb/Utility/PriorityPointerPair.h index 949173d302ef..21e60bb29153 100644 --- a/lldb/include/lldb/Utility/PriorityPointerPair.h +++ b/lldb/include/lldb/Utility/PriorityPointerPair.h @@ -30,7 +30,7 @@ public: typedef T& reference_type; typedef T* pointer_type; - typedef typename lldb::SharedPtr::Type T_SP; + typedef typename SHARED_PTR(T) T_SP; PriorityPointerPair() : m_high(), diff --git a/lldb/include/lldb/lldb-forward-rtti.h b/lldb/include/lldb/lldb-forward-rtti.h index c9f7b539047e..5709f47292cf 100644 --- a/lldb/include/lldb/lldb-forward-rtti.h +++ b/lldb/include/lldb/lldb-forward-rtti.h @@ -13,84 +13,84 @@ #if defined(__cplusplus) #include "lldb/lldb-types.h" +#include // for std::tr1::shared_ptr //---------------------------------------------------------------------- // lldb forward declarations //---------------------------------------------------------------------- namespace lldb { - typedef SharedPtr::Type ABISP; - typedef SharedPtr::Type AddressResolverSP; - typedef SharedPtr::Type BatonSP; - typedef SharedPtr::Type BlockSP; - typedef IntrusiveSharedPtr::Type BreakpointSP; - typedef IntrusiveSharedPtr::Type BreakpointSiteSP; - typedef IntrusiveSharedPtr::Type BreakpointLocationSP; - typedef SharedPtr::Type BreakpointResolverSP; - typedef SharedPtr::Type BroadcasterSP; - typedef SharedPtr::Type ClangExpressionVariableSP; - typedef SharedPtr::Type CommandObjectSP; - typedef SharedPtr::Type CommunicationSP; - typedef SharedPtr::Type ConnectionSP; - typedef SharedPtr::Type CompUnitSP; - typedef SharedPtr::Type DataBufferSP; - typedef SharedPtr::Type DataExtractorSP; - typedef IntrusiveSharedPtr::Type DebuggerSP; - typedef SharedPtr::Type DisassemblerSP; - typedef SharedPtr::Type DynamicLoaderSP; - typedef SharedPtr::Type EventSP; - typedef SharedPtr::Type FormatCategorySP; - typedef SharedPtr::Type FunctionSP; - typedef SharedPtr::Type InlineFunctionInfoSP; - typedef SharedPtr::Type InputReaderSP; - typedef SharedPtr::Type InstanceSettingsSP; - typedef SharedPtr::Type InstructionSP; - typedef SharedPtr::Type LanguageRuntimeSP; - typedef SharedPtr::Type LineTableSP; - typedef SharedPtr::Type ListenerSP; - typedef SharedPtr::Type LogSP; - typedef SharedPtr::Type LogChannelSP; - typedef IntrusiveSharedPtr::Type ModuleSP; - typedef IntrusiveSharedPtr::Type ObjectFileSP; - typedef SharedPtr::Type OptionValueSP; - typedef SharedPtr::Type PlatformSP; - typedef IntrusiveSharedPtr::Type ProcessSP; - typedef SharedPtr::Type RegisterContextSP; - typedef SharedPtr::Type RegularExpressionSP; - typedef SharedPtr::Type SectionSP; - typedef SharedPtr::Type SearchFilterSP; + typedef std::tr1::shared_ptr ABISP; + typedef std::tr1::shared_ptr BatonSP; + typedef std::tr1::shared_ptr BlockSP; + typedef std::tr1::shared_ptr BreakpointSP; // make_shared_from_this + typedef std::tr1::shared_ptr BreakpointSiteSP; // make_shared_from_this + typedef std::tr1::shared_ptr BreakpointLocationSP; // make_shared_from_this + typedef std::tr1::shared_ptr BreakpointResolverSP; + typedef std::tr1::shared_ptr BroadcasterSP; + typedef std::tr1::shared_ptr ClangExpressionVariableSP; + typedef std::tr1::shared_ptr CommandObjectSP; + typedef std::tr1::shared_ptr CommunicationSP; + typedef std::tr1::shared_ptr ConnectionSP; + typedef std::tr1::shared_ptr CompUnitSP; + typedef std::tr1::shared_ptr DataBufferSP; + typedef std::tr1::shared_ptr DataExtractorSP; + typedef std::tr1::shared_ptr DebuggerSP; // make_shared_from_this + typedef std::tr1::shared_ptr DisassemblerSP; + typedef std::tr1::shared_ptr DynamicLoaderSP; + typedef std::tr1::shared_ptr EventSP; + typedef std::tr1::shared_ptr FormatCategorySP; + typedef std::tr1::shared_ptr FunctionSP; + typedef std::tr1::shared_ptr InlineFunctionInfoSP; + typedef std::tr1::shared_ptr InputReaderSP; + typedef std::tr1::shared_ptr InstanceSettingsSP; + typedef std::tr1::shared_ptr InstructionSP; + typedef std::tr1::shared_ptr LanguageRuntimeSP; + typedef std::tr1::shared_ptr LineTableSP; + typedef std::tr1::shared_ptr ListenerSP; + typedef std::tr1::shared_ptr LogSP; + typedef std::tr1::shared_ptr LogChannelSP; + typedef std::tr1::shared_ptr ModuleSP; // make_shared_from_this + typedef std::tr1::shared_ptr ObjectFileSP; // make_shared_from_this + typedef std::tr1::shared_ptr OptionValueSP; + typedef std::tr1::shared_ptr PlatformSP; + typedef std::tr1::shared_ptr ProcessSP; // make_shared_from_this + typedef std::tr1::shared_ptr RegisterContextSP; + typedef std::tr1::shared_ptr RegularExpressionSP; + typedef std::tr1::shared_ptr SectionSP; + typedef std::tr1::shared_ptr SearchFilterSP; #ifndef LLDB_DISABLE_PYTHON - typedef SharedPtr::Type ScriptFormatSP; + typedef std::tr1::shared_ptr ScriptFormatSP; #endif // #ifndef LLDB_DISABLE_PYTHON - typedef IntrusiveSharedPtr::Type StackFrameSP; - typedef SharedPtr::Type StackFrameListSP; - typedef SharedPtr::Type StopInfoSP; - typedef SharedPtr::Type StoppointLocationSP; - typedef SharedPtr::Type StreamSP; - typedef SharedPtr::Type StringSummaryFormatSP; - typedef SharedPtr::Type SummaryFormatSP; - typedef SharedPtr::Type SymbolFileSP; - typedef IntrusiveSharedPtr::Type SymbolFileTypeSP; - typedef SharedPtr::Type SymbolContextSpecifierSP; - typedef SharedPtr::Type SyntheticChildrenSP; - typedef SharedPtr::Type SyntheticChildrenFrontEndSP; - typedef IntrusiveSharedPtr::Type TargetSP; - typedef IntrusiveSharedPtr::Type ThreadSP; - typedef SharedPtr::Type ThreadPlanSP; - typedef SharedPtr::Type ThreadPlanTracerSP; - typedef IntrusiveSharedPtr::Type TypeSP; - typedef SharedPtr::Type TypeImplSP; - typedef SharedPtr::Type FuncUnwindersSP; - typedef SharedPtr::Type UserSettingsControllerSP; - typedef SharedPtr::Type UnwindPlanSP; + typedef std::tr1::shared_ptr StackFrameSP; // make_shared_from_this + typedef std::tr1::shared_ptr StackFrameListSP; + typedef std::tr1::shared_ptr StopInfoSP; + typedef std::tr1::shared_ptr StoppointLocationSP; + typedef std::tr1::shared_ptr StreamSP; + typedef std::tr1::shared_ptr StringSummaryFormatSP; + typedef std::tr1::shared_ptr SummaryFormatSP; + typedef std::tr1::shared_ptr SymbolFileSP; + typedef std::tr1::shared_ptr SymbolFileTypeSP; // make_shared_from_this + typedef std::tr1::shared_ptr SymbolContextSpecifierSP; + typedef std::tr1::shared_ptr SyntheticChildrenSP; + typedef std::tr1::shared_ptr SyntheticChildrenFrontEndSP; + typedef std::tr1::shared_ptr TargetSP; // make_shared_from_this + typedef std::tr1::shared_ptr ThreadSP; // make_shared_from_this + typedef std::tr1::shared_ptr ThreadPlanSP; + typedef std::tr1::shared_ptr ThreadPlanTracerSP; + typedef std::tr1::shared_ptr TypeSP; // make_shared_from_this + typedef std::tr1::shared_ptr TypeImplSP; + typedef std::tr1::shared_ptr FuncUnwindersSP; + typedef std::tr1::shared_ptr UserSettingsControllerSP; + typedef std::tr1::shared_ptr UnwindPlanSP; typedef SharedPtr::Type ValueObjectSP; - typedef SharedPtr::Type ValueSP; - typedef SharedPtr::Type ValueFormatSP; - typedef SharedPtr::Type ValueListSP; - typedef SharedPtr::Type VariableSP; - typedef SharedPtr::Type VariableListSP; - typedef SharedPtr::Type ValueObjectListSP; - typedef SharedPtr::Type WatchpointSP; + typedef std::tr1::shared_ptr ValueSP; + typedef std::tr1::shared_ptr ValueFormatSP; + typedef std::tr1::shared_ptr ValueListSP; + typedef std::tr1::shared_ptr VariableSP; + typedef std::tr1::shared_ptr VariableListSP; + typedef std::tr1::shared_ptr ValueObjectListSP; + typedef std::tr1::shared_ptr WatchpointSP; } // namespace lldb diff --git a/lldb/include/lldb/lldb-types.h b/lldb/include/lldb/lldb-types.h index 1067965af158..d1908db13d70 100644 --- a/lldb/include/lldb/lldb-types.h +++ b/lldb/include/lldb/lldb-types.h @@ -23,13 +23,13 @@ //---------------------------------------------------------------------- // All host systems must define: -// liblldb::condition_t The native condition type (or a substitute class) for conditions on the host system. -// liblldb::mutex_t The native mutex type for mutex objects on the host system. -// liblldb::thread_t The native thread type for spawned threads on the system -// liblldb::thread_arg_t The type of the one any only thread creation argument for the host system -// liblldb::thread_result_t The return type that gets returned when a thread finishes. -// liblldb::thread_func_t The function prototype used to spawn a thread on the host system. -// liblldb::SharedPtr The template that wraps up the host version of a reference counted pointer (like boost::shared_ptr) +// lldb::condition_t The native condition type (or a substitute class) for conditions on the host system. +// lldb::mutex_t The native mutex type for mutex objects on the host system. +// lldb::thread_t The native thread type for spawned threads on the system +// lldb::thread_arg_t The type of the one any only thread creation argument for the host system +// lldb::thread_result_t The return type that gets returned when a thread finishes. +// lldb::thread_func_t The function prototype used to spawn a thread on the host system. +// lldb::SharedPtr The template that wraps up the host version of a reference counted pointer (like boost::shared_ptr) // #define LLDB_INVALID_PROCESS_ID ... // #define LLDB_INVALID_THREAD_ID ... // #define LLDB_INVALID_HOST_THREAD ... @@ -64,17 +64,17 @@ namespace lldb { { typedef lldb_private::SharingPtr<_Tp> Type; }; - template - struct LoggingSharedPtr - { - typedef lldb_private::LoggingSharingPtr<_Tp> Type; - }; - - template - struct IntrusiveSharedPtr - { - typedef lldb_private::IntrusiveSharingPtr<_Tp> Type; - }; +// template +// struct LoggingSharedPtr +// { +// typedef lldb_private::LoggingSharingPtr<_Tp> Type; +// }; +// +// template +// struct IntrusiveSharedPtr +// { +// typedef lldb_private::IntrusiveSharingPtr<_Tp> Type; +// }; } // namespace lldb @@ -91,6 +91,7 @@ const lldb::thread_t lldb_invalid_host_thread_const = { NULL, 0 } ; #endif +#define SHARED_PTR(T) std::tr1::shared_ptr #define LLDB_INVALID_HOST_TIME { 0, 0 } namespace lldb diff --git a/lldb/lldb.xcodeproj/xcshareddata/xcschemes/lldb-tool.xcscheme b/lldb/lldb.xcodeproj/xcshareddata/xcschemes/lldb-tool.xcscheme index 6e12c06c956d..43205cd4e07f 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"> + + + + + + GetModule(); if (module) - *sb_module = module; + *sb_module = module->shared_from_this(); } return sb_module; } diff --git a/lldb/source/API/SBBreakpoint.cpp b/lldb/source/API/SBBreakpoint.cpp index 62e4a4cc103f..33bdbe0b472f 100644 --- a/lldb/source/API/SBBreakpoint.cpp +++ b/lldb/source/API/SBBreakpoint.cpp @@ -497,14 +497,14 @@ SBBreakpoint::PrivateBreakpointHitCallback Process *process = ctx->exe_ctx.GetProcessPtr(); if (process) { - SBProcess sb_process (process->GetSP()); + SBProcess sb_process (process->shared_from_this()); SBThread sb_thread; SBBreakpointLocation sb_location; assert (bp_sp); sb_location.SetLocation (bp_sp->FindLocationByID (break_loc_id)); Thread *thread = ctx->exe_ctx.GetThreadPtr(); if (thread) - sb_thread.SetThread(thread->GetSP()); + sb_thread.SetThread(thread->shared_from_this()); return data->callback (data->callback_baton, sb_process, diff --git a/lldb/source/API/SBBreakpointLocation.cpp b/lldb/source/API/SBBreakpointLocation.cpp index 619428eb8c88..57cf5a1a5c7e 100644 --- a/lldb/source/API/SBBreakpointLocation.cpp +++ b/lldb/source/API/SBBreakpointLocation.cpp @@ -301,7 +301,7 @@ SBBreakpointLocation::GetBreakpoint () if (m_opaque_sp) { Mutex::Locker api_locker (m_opaque_sp->GetBreakpoint().GetTarget().GetAPIMutex()); - *sb_bp = m_opaque_sp->GetBreakpoint ().GetSP(); + *sb_bp = m_opaque_sp->GetBreakpoint ().shared_from_this(); } if (log) diff --git a/lldb/source/API/SBFrame.cpp b/lldb/source/API/SBFrame.cpp index 3a3c58238274..c0a69782568b 100644 --- a/lldb/source/API/SBFrame.cpp +++ b/lldb/source/API/SBFrame.cpp @@ -553,7 +553,7 @@ SBFrame::GetThread () const if (m_opaque_sp) { Mutex::Locker api_locker (m_opaque_sp->GetThread().GetProcess().GetTarget().GetAPIMutex()); - sb_thread.SetThread (m_opaque_sp->GetThread().GetSP()); + sb_thread.SetThread (m_opaque_sp->GetThread().shared_from_this()); } if (log) diff --git a/lldb/source/API/SBFunction.cpp b/lldb/source/API/SBFunction.cpp index 4e23b9dfb493..f55b21477418 100644 --- a/lldb/source/API/SBFunction.cpp +++ b/lldb/source/API/SBFunction.cpp @@ -133,10 +133,10 @@ SBFunction::GetInstructions (SBTarget target) target->CalculateExecutionContext (exe_ctx); exe_ctx.SetProcessSP(target->GetProcessSP()); } - Module *module = m_opaque_ptr->GetAddressRange().GetBaseAddress().GetModule(); - if (module) + ModuleSP module_sp = m_opaque_ptr->GetAddressRange().GetBaseAddress().GetModuleSP(); + if (module_sp) { - sb_instructions.SetDisassembler (Disassembler::DisassembleRange (module->GetArchitecture(), + sb_instructions.SetDisassembler (Disassembler::DisassembleRange (module_sp->GetArchitecture(), NULL, exe_ctx, m_opaque_ptr->GetAddressRange())); diff --git a/lldb/source/API/SBProcess.cpp b/lldb/source/API/SBProcess.cpp index aacec526ce45..76c1badba64d 100644 --- a/lldb/source/API/SBProcess.cpp +++ b/lldb/source/API/SBProcess.cpp @@ -238,7 +238,7 @@ SBProcess::GetTarget() const SBTarget sb_target; if (m_opaque_sp) - sb_target = m_opaque_sp->GetTarget().GetSP(); + sb_target = m_opaque_sp->GetTarget().shared_from_this(); if (log) log->Printf ("SBProcess(%p)::GetTarget () => SBTarget(%p)", m_opaque_sp.get(), sb_target.get()); diff --git a/lldb/source/API/SBSection.cpp b/lldb/source/API/SBSection.cpp index ed6dba76e582..dedcc7a28500 100644 --- a/lldb/source/API/SBSection.cpp +++ b/lldb/source/API/SBSection.cpp @@ -29,7 +29,7 @@ namespace lldb_private m_section (section) { if (section) - m_module_sp = section->GetModule(); + m_module_sp = section->GetModule()->shared_from_this(); } SectionImpl (const SectionImpl &rhs) : diff --git a/lldb/source/API/SBSymbol.cpp b/lldb/source/API/SBSymbol.cpp index 1765dbddd8ea..51bb98c194a7 100644 --- a/lldb/source/API/SBSymbol.cpp +++ b/lldb/source/API/SBSymbol.cpp @@ -131,10 +131,10 @@ SBSymbol::GetInstructions (SBTarget target) const AddressRange *symbol_range = m_opaque_ptr->GetAddressRangePtr(); if (symbol_range) { - Module *module = symbol_range->GetBaseAddress().GetModule(); - if (module) + ModuleSP module_sp = symbol_range->GetBaseAddress().GetModuleSP(); + if (module_sp) { - sb_instructions.SetDisassembler (Disassembler::DisassembleRange (module->GetArchitecture (), + sb_instructions.SetDisassembler (Disassembler::DisassembleRange (module_sp->GetArchitecture (), NULL, exe_ctx, *symbol_range)); diff --git a/lldb/source/API/SBTarget.cpp b/lldb/source/API/SBTarget.cpp index 82224a930c65..f594827a1e26 100644 --- a/lldb/source/API/SBTarget.cpp +++ b/lldb/source/API/SBTarget.cpp @@ -119,7 +119,7 @@ SBTarget::GetDebugger () const { SBDebugger debugger; if (m_opaque_sp) - debugger.reset (m_opaque_sp->GetDebugger().GetSP()); + debugger.reset (m_opaque_sp->GetDebugger().shared_from_this()); return debugger; } diff --git a/lldb/source/API/SBValue.cpp b/lldb/source/API/SBValue.cpp index 1ed3fea133a5..87413e036d21 100644 --- a/lldb/source/API/SBValue.cpp +++ b/lldb/source/API/SBValue.cpp @@ -883,7 +883,7 @@ SBValue::GetThread() { if (m_opaque_sp->GetExecutionContextScope()) { - result = SBThread(m_opaque_sp->GetExecutionContextScope()->CalculateThread()->GetSP()); + result = SBThread(m_opaque_sp->GetExecutionContextScope()->CalculateThread()->shared_from_this()); } } LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); @@ -905,7 +905,7 @@ SBValue::GetFrame() { if (m_opaque_sp->GetExecutionContextScope()) { - result.SetFrame (m_opaque_sp->GetExecutionContextScope()->CalculateStackFrame()->GetSP()); + result.SetFrame (m_opaque_sp->GetExecutionContextScope()->CalculateStackFrame()->shared_from_this()); } } LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); diff --git a/lldb/source/Breakpoint/Breakpoint.cpp b/lldb/source/Breakpoint/Breakpoint.cpp index 9095db064ee8..aa9fab25618c 100644 --- a/lldb/source/Breakpoint/Breakpoint.cpp +++ b/lldb/source/Breakpoint/Breakpoint.cpp @@ -556,11 +556,3 @@ Breakpoint::GetFilterDescription (Stream *s) { m_filter_sp->GetDescription (s); } - -const BreakpointSP -Breakpoint::GetSP () -{ - // This object contains an instrusive ref count base class so we can - // easily make a shared pointer to this object - return BreakpointSP (this); -} diff --git a/lldb/source/Breakpoint/BreakpointLocation.cpp b/lldb/source/Breakpoint/BreakpointLocation.cpp index 9adf18989be9..fb123de56e6d 100644 --- a/lldb/source/Breakpoint/BreakpointLocation.cpp +++ b/lldb/source/Breakpoint/BreakpointLocation.cpp @@ -149,11 +149,10 @@ BreakpointLocation::SetCondition (const char *condition) ThreadPlan * BreakpointLocation::GetThreadPlanToTestCondition (ExecutionContext &exe_ctx, Stream &error) { - lldb::BreakpointLocationSP this_sp(this); if (m_options_ap.get()) - return m_options_ap->GetThreadPlanToTestCondition (exe_ctx, this_sp, error); + return m_options_ap->GetThreadPlanToTestCondition (exe_ctx, shared_from_this(), error); else - return m_owner.GetThreadPlanToTestCondition (exe_ctx, this_sp, error); + return m_owner.GetThreadPlanToTestCondition (exe_ctx, shared_from_this(), error); } const char * @@ -259,9 +258,7 @@ BreakpointLocation::ResolveBreakpointSite () if (m_owner.GetTarget().GetSectionLoadList().IsEmpty()) return false; - BreakpointLocationSP this_sp(this); - - lldb::break_id_t new_id = process->CreateBreakpointSite (this_sp, false); + lldb::break_id_t new_id = process->CreateBreakpointSite (shared_from_this(), false); if (new_id == LLDB_INVALID_BREAK_ID) { diff --git a/lldb/source/Breakpoint/BreakpointSite.cpp b/lldb/source/Breakpoint/BreakpointSite.cpp index 962117c27dfa..1ad7f8f14404 100644 --- a/lldb/source/Breakpoint/BreakpointSite.cpp +++ b/lldb/source/Breakpoint/BreakpointSite.cpp @@ -23,7 +23,7 @@ using namespace lldb_private; BreakpointSite::BreakpointSite ( BreakpointSiteList *list, - BreakpointLocationSP& owner, + const BreakpointLocationSP& owner, lldb::addr_t addr, lldb::tid_t tid, bool use_hardware @@ -155,7 +155,7 @@ BreakpointSite::SetEnabled (bool enabled) } void -BreakpointSite::AddOwner (BreakpointLocationSP &owner) +BreakpointSite::AddOwner (const BreakpointLocationSP &owner) { m_owners.Add(owner); } diff --git a/lldb/source/Commands/CommandObjectArgs.cpp b/lldb/source/Commands/CommandObjectArgs.cpp index dfbbe7969b6b..01f798f573f4 100644 --- a/lldb/source/Commands/CommandObjectArgs.cpp +++ b/lldb/source/Commands/CommandObjectArgs.cpp @@ -148,7 +148,7 @@ CommandObjectArgs::Execute return false; } - Module *thread_module = thread_cur_frame->GetFrameCodeAddress ().GetModule (); + Module *thread_module = thread_cur_frame->GetFrameCodeAddress ().GetModulePtr (); if (!thread_module) { result.AppendError ("The PC has no associated module."); diff --git a/lldb/source/Commands/CommandObjectSource.cpp b/lldb/source/Commands/CommandObjectSource.cpp index 07e133c6bb7a..21f6339b014f 100644 --- a/lldb/source/Commands/CommandObjectSource.cpp +++ b/lldb/source/Commands/CommandObjectSource.cpp @@ -468,7 +468,7 @@ public: { const bool show_inlines = true; m_breakpoint_locations.Reset (last_file_sp->GetFileSpec(), 0, show_inlines); - SearchFilter target_search_filter (target->GetSP()); + SearchFilter target_search_filter (target->shared_from_this()); target_search_filter.Search (m_breakpoint_locations); } } @@ -570,7 +570,7 @@ public: { const bool show_inlines = true; m_breakpoint_locations.Reset (*sc.comp_unit, 0, show_inlines); - SearchFilter target_search_filter (target->GetSP()); + SearchFilter target_search_filter (target->shared_from_this()); target_search_filter.Search (m_breakpoint_locations); } else diff --git a/lldb/source/Commands/CommandObjectTarget.cpp b/lldb/source/Commands/CommandObjectTarget.cpp index 8b0fd17d1590..3e05d2141e02 100644 --- a/lldb/source/Commands/CommandObjectTarget.cpp +++ b/lldb/source/Commands/CommandObjectTarget.cpp @@ -1329,7 +1329,7 @@ LookupAddressInModule { if (!target->GetSectionLoadList().ResolveLoadAddress (addr, so_addr)) return false; - else if (so_addr.GetModule() != module) + else if (so_addr.GetModulePtr() != module) return false; } else @@ -1643,7 +1643,7 @@ FindModulesByName (Target *target, { if (FileSpec::Equal(module->GetFileSpec(), module_file_spec, true)) { - module_sp = module; + module_sp = module->shared_from_this(); module_list.AppendIfNeeded(module_sp); } } @@ -2757,7 +2757,7 @@ public: Address module_address; if (module_address.SetLoadAddress(m_options.m_module_addr, target)) { - Module *module = module_address.GetModule(); + Module *module = module_address.GetModulePtr(); if (module) { PrintModule (strm, module); @@ -2800,7 +2800,7 @@ public: if (use_global_module_list) { module = Module::GetAllocatedModuleAtIndex(image_idx); - module_sp = module; + module_sp = module->shared_from_this(); } else { @@ -2874,7 +2874,7 @@ protected: case 'r': { uint32_t ref_count = 0; - ModuleSP module_sp (module); + ModuleSP module_sp (module->shared_from_this()); if (module_sp) { // Take one away to make sure we don't count our local "module_sp" diff --git a/lldb/source/Commands/CommandObjectType.cpp b/lldb/source/Commands/CommandObjectType.cpp index 26a110ee336c..61756d7942e6 100644 --- a/lldb/source/Commands/CommandObjectType.cpp +++ b/lldb/source/Commands/CommandObjectType.cpp @@ -75,7 +75,7 @@ public: { } - typedef lldb::SharedPtr::Type SharedPointer; + typedef SHARED_PTR(ScriptAddOptions) SharedPointer; }; @@ -108,7 +108,7 @@ public: { } - typedef lldb::SharedPtr::Type SharedPointer; + typedef SHARED_PTR(SynthAddOptions) SharedPointer; }; diff --git a/lldb/source/Core/Address.cpp b/lldb/source/Core/Address.cpp index 2ea3bb173121..120ae5e4aa7c 100644 --- a/lldb/source/Core/Address.cpp +++ b/lldb/source/Core/Address.cpp @@ -55,7 +55,7 @@ GetByteOrderAndAddressSize (ExecutionContextScope *exe_scope, const Address &add if (byte_order == eByteOrderInvalid || addr_size == 0) { - Module *module = address.GetModule(); + Module *module = address.GetModulePtr(); if (module) { byte_order = module->GetArchitecture().GetByteOrder(); @@ -118,7 +118,7 @@ ReadAddress (ExecutionContextScope *exe_scope, const Address &address, uint32_t { // If we were not running, yet able to read an integer, we must // have a module - Module *module = address.GetModule(); + Module *module = address.GetModulePtr(); assert (module); if (module->ResolveFileAddress(deref_addr, deref_so_addr)) return true; @@ -248,13 +248,26 @@ Address::ResolveAddressUsingFileSections (addr_t addr, const SectionList *sectio } Module * -Address::GetModule () const +Address::GetModulePtr () const { if (m_section) return m_section->GetModule(); return NULL; } +ModuleSP +Address::GetModuleSP () const +{ + lldb::ModuleSP module_sp; + if (m_section) + { + Module *module = m_section->GetModule(); + if (module) + module_sp = module->shared_from_this(); + } + return module_sp; +} + addr_t Address::GetFileAddress () const { @@ -434,7 +447,7 @@ Address::Dump (Stream *s, ExecutionContextScope *exe_scope, DumpStyle style, Dum } uint32_t pointer_size = 4; - Module *module = GetModule(); + Module *module = GetModulePtr(); if (target) pointer_size = target->GetArchitecture().GetAddressByteSize(); else if (module) @@ -670,7 +683,7 @@ Address::Dump (Stream *s, ExecutionContextScope *exe_scope, DumpStyle style, Dum case DumpStyleDetailedSymbolContext: if (IsSectionOffset()) { - Module *module = GetModule(); + Module *module = GetModulePtr(); if (module) { SymbolContext sc; @@ -738,7 +751,7 @@ Address::CalculateSymbolContext (SymbolContext *sc, uint32_t resolve_scope) cons Module *address_module = m_section->GetModule(); if (address_module) { - sc->module_sp = address_module; + sc->module_sp = address_module->shared_from_this(); if (sc->module_sp) return sc->module_sp->ResolveSymbolContextForAddress (*this, resolve_scope, *sc); } @@ -760,7 +773,7 @@ Address::CalculateSymbolContextCompileUnit () const if (m_section) { SymbolContext sc; - sc.module_sp = m_section->GetModule(); + sc.module_sp = m_section->GetModule()->shared_from_this(); if (sc.module_sp) { sc.module_sp->ResolveSymbolContextForAddress (*this, eSymbolContextCompUnit, sc); @@ -776,7 +789,7 @@ Address::CalculateSymbolContextFunction () const if (m_section) { SymbolContext sc; - sc.module_sp = m_section->GetModule(); + sc.module_sp = m_section->GetModule()->shared_from_this(); if (sc.module_sp) { sc.module_sp->ResolveSymbolContextForAddress (*this, eSymbolContextFunction, sc); @@ -792,7 +805,7 @@ Address::CalculateSymbolContextBlock () const if (m_section) { SymbolContext sc; - sc.module_sp = m_section->GetModule(); + sc.module_sp = m_section->GetModule()->shared_from_this(); if (sc.module_sp) { sc.module_sp->ResolveSymbolContextForAddress (*this, eSymbolContextBlock, sc); @@ -808,7 +821,7 @@ Address::CalculateSymbolContextSymbol () const if (m_section) { SymbolContext sc; - sc.module_sp = m_section->GetModule(); + sc.module_sp = m_section->GetModule()->shared_from_this(); if (sc.module_sp) { sc.module_sp->ResolveSymbolContextForAddress (*this, eSymbolContextSymbol, sc); @@ -824,7 +837,7 @@ Address::CalculateSymbolContextLineEntry (LineEntry &line_entry) const if (m_section) { SymbolContext sc; - sc.module_sp = m_section->GetModule(); + sc.module_sp = m_section->GetModule()->shared_from_this(); if (sc.module_sp) { sc.module_sp->ResolveSymbolContextForAddress (*this, eSymbolContextLineEntry, sc); @@ -868,8 +881,8 @@ Address::CompareLoadAddress (const Address& a, const Address& b, Target *target) int Address::CompareModulePointerAndOffset (const Address& a, const Address& b) { - Module *a_module = a.GetModule (); - Module *b_module = b.GetModule (); + Module *a_module = a.GetModulePtr (); + Module *b_module = b.GetModulePtr (); if (a_module < b_module) return -1; if (a_module > b_module) @@ -913,8 +926,8 @@ Address::MemorySize () const bool lldb_private::operator< (const Address& lhs, const Address& rhs) { - Module *lhs_module = lhs.GetModule(); - Module *rhs_module = rhs.GetModule(); + Module *lhs_module = lhs.GetModulePtr(); + Module *rhs_module = rhs.GetModulePtr(); if (lhs_module == rhs_module) { // Addresses are in the same module, just compare the file addresses @@ -931,8 +944,8 @@ lldb_private::operator< (const Address& lhs, const Address& rhs) bool lldb_private::operator> (const Address& lhs, const Address& rhs) { - Module *lhs_module = lhs.GetModule(); - Module *rhs_module = rhs.GetModule(); + Module *lhs_module = lhs.GetModulePtr(); + Module *rhs_module = rhs.GetModulePtr(); if (lhs_module == rhs_module) { // Addresses are in the same module, just compare the file addresses @@ -987,7 +1000,7 @@ Address::ResolveLinkedAddress () AddressClass Address::GetAddressClass () const { - Module *module = GetModule(); + Module *module = GetModulePtr(); if (module) { ObjectFile *obj_file = module->GetObjectFile(); diff --git a/lldb/source/Core/AddressRange.cpp b/lldb/source/Core/AddressRange.cpp index 391f611dc35a..700de90806c1 100644 --- a/lldb/source/Core/AddressRange.cpp +++ b/lldb/source/Core/AddressRange.cpp @@ -177,7 +177,7 @@ AddressRange::Dump(Stream *s, Target *target, Address::DumpStyle style, Address: { if (show_module) { - Module *module = GetBaseAddress().GetModule(); + Module *module = GetBaseAddress().GetModulePtr(); if (module) s->Printf("%s", module->GetFileSpec().GetFilename().AsCString()); } diff --git a/lldb/source/Core/Debugger.cpp b/lldb/source/Core/Debugger.cpp index 8b5e8d42bacb..f979c8d5877e 100644 --- a/lldb/source/Core/Debugger.cpp +++ b/lldb/source/Core/Debugger.cpp @@ -262,14 +262,6 @@ Debugger::Destroy (DebuggerSP &debugger_sp) } } -DebuggerSP -Debugger::GetSP () -{ - // This object contains an instrusive ref count base class so we can - // easily make a shared pointer to this object - return DebuggerSP (this); -} - DebuggerSP Debugger::FindDebuggerWithInstanceName (const ConstString &instance_name) { diff --git a/lldb/source/Core/Disassembler.cpp b/lldb/source/Core/Disassembler.cpp index fe044a6dc4cc..d6b19acdaa36 100644 --- a/lldb/source/Core/Disassembler.cpp +++ b/lldb/source/Core/Disassembler.cpp @@ -383,7 +383,7 @@ Disassembler::PrintInstructions prev_sc = sc; - Module *module = addr.GetModule(); + Module *module = addr.GetModulePtr(); if (module) { uint32_t resolved_mask = module->ResolveSymbolContextForAddress(addr, eSymbolContextEverything, sc); diff --git a/lldb/source/Core/Module.cpp b/lldb/source/Core/Module.cpp index 556b4a57a7c0..28e8be2334be 100644 --- a/lldb/source/Core/Module.cpp +++ b/lldb/source/Core/Module.cpp @@ -224,7 +224,7 @@ Module::ParseAllDebugSymbols() return; SymbolContext sc; - sc.module_sp = this; + sc.module_sp = shared_from_this(); uint32_t cu_idx; SymbolVendor *symbols = GetSymbolVendor (); @@ -258,7 +258,7 @@ Module::ParseAllDebugSymbols() void Module::CalculateSymbolContext(SymbolContext* sc) { - sc->module_sp = this; + sc->module_sp = shared_from_this(); } Module * @@ -328,7 +328,7 @@ Module::ResolveSymbolContextForAddress (const Address& so_addr, uint32_t resolve { // If the section offset based address resolved itself, then this // is the right module. - sc.module_sp = this; + sc.module_sp = shared_from_this(); resolved_flags |= eSymbolContextModule; // Resolve the compile unit, function, block, line table or line @@ -430,7 +430,7 @@ Module::FindCompileUnits (const FileSpec &path, const uint32_t start_size = sc_list.GetSize(); const uint32_t num_compile_units = GetNumCompileUnits(); SymbolContext sc; - sc.module_sp = this; + sc.module_sp = shared_from_this(); const bool compare_directory = path.GetDirectory(); for (uint32_t i=0; iResolveSymbolContextForAddress (so_addr, diff --git a/lldb/source/Core/SearchFilter.cpp b/lldb/source/Core/SearchFilter.cpp index d31ed8b58182..342e988c1472 100644 --- a/lldb/source/Core/SearchFilter.cpp +++ b/lldb/source/Core/SearchFilter.cpp @@ -318,7 +318,7 @@ SearchFilter::DoFunctionIteration (Function *function, const SymbolContext &cont // SearchFilterByModule constructors //---------------------------------------------------------------------- -SearchFilterByModule::SearchFilterByModule (lldb::TargetSP &target_sp, const FileSpec &module) : +SearchFilterByModule::SearchFilterByModule (const lldb::TargetSP &target_sp, const FileSpec &module) : SearchFilter (target_sp), m_module_spec (module) { @@ -430,7 +430,7 @@ SearchFilterByModule::Search (Searcher &searcher) Module* module = m_target_sp->GetImages().GetModulePointerAtIndex(i); if (FileSpec::Compare (m_module_spec, module->GetFileSpec(), false) == 0) { - SymbolContext matchingContext(m_target_sp, ModuleSP(module)); + SymbolContext matchingContext(m_target_sp, module->shared_from_this()); Searcher::CallbackReturn shouldContinue; shouldContinue = DoModuleIteration(matchingContext, searcher); @@ -476,7 +476,7 @@ SearchFilterByModule::Dump (Stream *s) const // SearchFilterByModuleList constructors //---------------------------------------------------------------------- -SearchFilterByModuleList::SearchFilterByModuleList (lldb::TargetSP &target_sp, const FileSpecList &module_list) : +SearchFilterByModuleList::SearchFilterByModuleList (const lldb::TargetSP &target_sp, const FileSpecList &module_list) : SearchFilter (target_sp), m_module_spec_list (module_list) { @@ -594,7 +594,7 @@ SearchFilterByModuleList::Search (Searcher &searcher) Module* module = m_target_sp->GetImages().GetModulePointerAtIndex(i); if (m_module_spec_list.FindFileIndex(0, module->GetFileSpec(), false) != UINT32_MAX) { - SymbolContext matchingContext(m_target_sp, ModuleSP(module)); + SymbolContext matchingContext(m_target_sp, module->shared_from_this()); Searcher::CallbackReturn shouldContinue; shouldContinue = DoModuleIteration(matchingContext, searcher); @@ -664,7 +664,7 @@ SearchFilterByModuleList::Dump (Stream *s) const // SearchFilterByModuleListAndCU constructors //---------------------------------------------------------------------- -SearchFilterByModuleListAndCU::SearchFilterByModuleListAndCU (lldb::TargetSP &target_sp, +SearchFilterByModuleListAndCU::SearchFilterByModuleListAndCU (const lldb::TargetSP &target_sp, const FileSpecList &module_list, const FileSpecList &cu_list) : SearchFilterByModuleList (target_sp, module_list), diff --git a/lldb/source/Core/ValueObject.cpp b/lldb/source/Core/ValueObject.cpp index cfc5dcd3fd25..dbf5bc6ae9b3 100644 --- a/lldb/source/Core/ValueObject.cpp +++ b/lldb/source/Core/ValueObject.cpp @@ -3490,7 +3490,7 @@ ValueObject::EvaluationPoint::EvaluationPoint (ExecutionContextScope *exe_scope, Target *target = exe_ctx.GetTargetPtr(); if (target != NULL) { - m_target_sp = target; + m_target_sp = target->shared_from_this(); m_process_sp = exe_ctx.GetProcessSP(); if (!m_process_sp) m_process_sp = target->GetProcessSP(); diff --git a/lldb/source/Core/ValueObjectMemory.cpp b/lldb/source/Core/ValueObjectMemory.cpp index bd7a791b9b10..5d9406e02f2a 100644 --- a/lldb/source/Core/ValueObjectMemory.cpp +++ b/lldb/source/Core/ValueObjectMemory.cpp @@ -272,7 +272,7 @@ ValueObjectMemory::IsInScope () Module * ValueObjectMemory::GetModule() { - return m_address.GetModule(); + return m_address.GetModulePtr(); } diff --git a/lldb/source/Expression/ClangASTSource.cpp b/lldb/source/Expression/ClangASTSource.cpp index d7a19264b882..162dfab2ef44 100644 --- a/lldb/source/Expression/ClangASTSource.cpp +++ b/lldb/source/Expression/ClangASTSource.cpp @@ -946,7 +946,7 @@ ClangASTSource::CompleteNamespaceMap (ClangASTImporter::NamespaceMapSP &namespac NamespaceDecl * ClangASTSource::AddNamespace (NameSearchContext &context, ClangASTImporter::NamespaceMapSP &namespace_decls) { - if (namespace_decls.empty()) + if (!namespace_decls) return NULL; lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS)); diff --git a/lldb/source/Expression/ClangFunction.cpp b/lldb/source/Expression/ClangFunction.cpp index c583da90d3e4..22447692749c 100644 --- a/lldb/source/Expression/ClangFunction.cpp +++ b/lldb/source/Expression/ClangFunction.cpp @@ -70,7 +70,7 @@ ClangFunction::ClangFunction // Can't make a ClangFunction without a process. assert (process != NULL); - m_jit_process_sp = process->GetSP(); + m_jit_process_sp = process->shared_from_this(); } ClangFunction::ClangFunction @@ -95,7 +95,7 @@ ClangFunction::ClangFunction // Can't make a ClangFunction without a process. assert (process != NULL); - m_jit_process_sp = process->GetSP(); + m_jit_process_sp = process->shared_from_this(); m_function_addr = m_function_ptr->GetAddressRange().GetBaseAddress(); m_function_return_qual_type = m_function_ptr->GetReturnClangType(); @@ -266,7 +266,7 @@ ClangFunction::WriteFunctionWrapper (ExecutionContext &exe_ctx, Stream &errors) if (!jit_error.Success()) return false; if (process && m_jit_alloc != LLDB_INVALID_ADDRESS) - m_jit_process_sp = process->GetSP(); + m_jit_process_sp = process->shared_from_this(); return true; } diff --git a/lldb/source/Expression/ClangUserExpression.cpp b/lldb/source/Expression/ClangUserExpression.cpp index 7719f0815187..0bcae47c5198 100644 --- a/lldb/source/Expression/ClangUserExpression.cpp +++ b/lldb/source/Expression/ClangUserExpression.cpp @@ -357,7 +357,7 @@ ClangUserExpression::Parse (Stream &error_stream, if (jit_error.Success()) { if (process && m_jit_alloc != LLDB_INVALID_ADDRESS) - m_jit_process_sp = process->GetSP(); + m_jit_process_sp = process->shared_from_this(); return true; } else diff --git a/lldb/source/Expression/ClangUtilityFunction.cpp b/lldb/source/Expression/ClangUtilityFunction.cpp index 7220be8ae6b2..78c3c16e306c 100644 --- a/lldb/source/Expression/ClangUtilityFunction.cpp +++ b/lldb/source/Expression/ClangUtilityFunction.cpp @@ -148,7 +148,7 @@ ClangUtilityFunction::Install (Stream &error_stream, } if (m_jit_start_addr != LLDB_INVALID_ADDRESS) - m_jit_process_sp = process->GetSP(); + m_jit_process_sp = process->shared_from_this(); #if 0 // jingham: look here diff --git a/lldb/source/Expression/IRInterpreter.cpp b/lldb/source/Expression/IRInterpreter.cpp index 3cbe9f3bd8f2..a7ca4c865811 100644 --- a/lldb/source/Expression/IRInterpreter.cpp +++ b/lldb/source/Expression/IRInterpreter.cpp @@ -69,8 +69,8 @@ PrintType(const Type *type, bool truncate = false) return s; } -typedef lldb::SharedPtr ::Type DataEncoderSP; -typedef lldb::SharedPtr ::Type DataExtractorSP; +typedef SHARED_PTR(lldb_private::DataEncoder) DataEncoderSP; +typedef SHARED_PTR(lldb_private::DataExtractor) DataExtractorSP; class Memory { @@ -127,7 +127,7 @@ public: } }; - typedef lldb::SharedPtr ::Type AllocationSP; + typedef SHARED_PTR(Allocation) AllocationSP; struct Region { diff --git a/lldb/source/Interpreter/CommandInterpreter.cpp b/lldb/source/Interpreter/CommandInterpreter.cpp index 77cab233b7a8..9d6ac257ee8e 100644 --- a/lldb/source/Interpreter/CommandInterpreter.cpp +++ b/lldb/source/Interpreter/CommandInterpreter.cpp @@ -2559,7 +2559,7 @@ CommandInterpreter::UpdateExecutionContext (ExecutionContext *override_context) m_exe_ctx.SetProcessSP (process_sp); if (process_sp && process_sp->IsAlive() && !process_sp->IsRunning()) { - ThreadSP thread_sp (process_sp->GetThreadList().GetSelectedThread().get()); + ThreadSP thread_sp (process_sp->GetThreadList().GetSelectedThread()); if (thread_sp) { m_exe_ctx.SetThreadSP (thread_sp); diff --git a/lldb/source/Interpreter/ScriptInterpreterPython.cpp b/lldb/source/Interpreter/ScriptInterpreterPython.cpp index 691e0d5ae313..58cb329a95c0 100644 --- a/lldb/source/Interpreter/ScriptInterpreterPython.cpp +++ b/lldb/source/Interpreter/ScriptInterpreterPython.cpp @@ -1727,7 +1727,7 @@ ScriptInterpreterPython::LoadScriptingModule (const char* pathname, return false; } - lldb::DebuggerSP debugger_sp = m_interpreter.GetDebugger().GetSP(); + lldb::DebuggerSP debugger_sp = m_interpreter.GetDebugger().shared_from_this(); { Locker py_lock(this); @@ -1837,7 +1837,7 @@ ScriptInterpreterPython::RunScriptBasedCommand(const char* impl_function, return false; } - lldb::DebuggerSP debugger_sp = m_interpreter.GetDebugger().GetSP(); + lldb::DebuggerSP debugger_sp = m_interpreter.GetDebugger().shared_from_this(); if (!debugger_sp.get()) { diff --git a/lldb/source/Plugins/Disassembler/llvm/DisassemblerLLVM.cpp b/lldb/source/Plugins/Disassembler/llvm/DisassemblerLLVM.cpp index e395cccfad8b..0d1e74b2513b 100644 --- a/lldb/source/Plugins/Disassembler/llvm/DisassemblerLLVM.cpp +++ b/lldb/source/Plugins/Disassembler/llvm/DisassemblerLLVM.cpp @@ -122,7 +122,7 @@ AddSymbolicInfo (ExecutionContextScope *exe_scope, } else { - Module *module = inst_addr.GetModule(); + Module *module = inst_addr.GetModulePtr(); if (module) { if (module->ResolveFileAddress(operand_value, so_addr)) diff --git a/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp b/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp index d74bdf1eafb2..4f915a93552d 100644 --- a/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp +++ b/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp @@ -1255,12 +1255,12 @@ DynamicLoaderMacOSXDYLD::AlwaysRelyOnEHUnwindInfo (SymbolContext &sym_ctx) AddressRange *ar = sym_ctx.symbol->GetAddressRangePtr(); if (ar) { - module_sp = ar->GetBaseAddress().GetModule(); + module_sp = ar->GetBaseAddress().GetModuleSP(); } } if (module_sp.get() == NULL && sym_ctx.function) { - module_sp = sym_ctx.function->GetAddressRange().GetBaseAddress().GetModule(); + module_sp = sym_ctx.function->GetAddressRange().GetBaseAddress().GetModuleSP(); } if (module_sp.get() == NULL) return false; @@ -1522,7 +1522,7 @@ DynamicLoaderMacOSXDYLD::GetStepThroughTrampolinePlan (Thread &thread, bool stop Module* module_to_add = sc.symbol->CalculateSymbolContextModule(); if (module_to_add) - modules_to_search.AppendIfNeeded(static_cast(module_to_add)); + modules_to_search.AppendIfNeeded(module_to_add->shared_from_this()); } // If the original stub symbol is a resolver, then we don't want to break on the symbol with the diff --git a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp index 7df812c84e80..c6e081970446 100644 --- a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp +++ b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp @@ -220,7 +220,7 @@ AppleObjCRuntime::ReadObjCLibrary (const ModuleSP &module_sp) { // Maybe check here and if we have a handler already, and the UUID of this module is the same as the one in the // current module, then we don't have to reread it? - m_objc_trampoline_handler_ap.reset(new AppleObjCTrampolineHandler (m_process->GetSP(), module_sp)); + m_objc_trampoline_handler_ap.reset(new AppleObjCTrampolineHandler (m_process->shared_from_this(), module_sp)); if (m_objc_trampoline_handler_ap.get() != NULL) { m_read_objc_library = true; diff --git a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCSymbolVendor.cpp b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCSymbolVendor.cpp index b7c7a1d1ad09..13dc7d70e8b2 100644 --- a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCSymbolVendor.cpp +++ b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCSymbolVendor.cpp @@ -19,7 +19,7 @@ using namespace lldb_private; AppleObjCSymbolVendor::AppleObjCSymbolVendor(Process *process) : SymbolVendor(NULL), - m_process(process->GetSP()), + m_process(process->shared_from_this()), m_ast_ctx(process->GetTarget().GetArchitecture().GetTriple().getTriple().c_str()) { } diff --git a/lldb/source/Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.h b/lldb/source/Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.h index def3f731fff7..6501c5ad976c 100644 --- a/lldb/source/Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.h +++ b/lldb/source/Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.h @@ -118,7 +118,7 @@ protected: class Archive { public: - typedef lldb::SharedPtr::Type shared_ptr; + typedef SHARED_PTR(Archive) shared_ptr; typedef std::multimap Map; static Map & diff --git a/lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDPLog.cpp b/lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDPLog.cpp index 199b55c6a86a..6e230fb19175 100644 --- a/lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDPLog.cpp +++ b/lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDPLog.cpp @@ -104,7 +104,7 @@ ProcessKDPLog::EnableLog (StreamSP &log_stream_sp, uint32_t log_options, Args &a // Now make a new log with this stream if one was provided if (log_stream_sp) { - log = make_shared(log_stream_sp); + log.reset (new Log(log_stream_sp)); GetLog () = log; } diff --git a/lldb/source/Plugins/Process/Utility/RegisterContextLLDB.cpp b/lldb/source/Plugins/Process/Utility/RegisterContextLLDB.cpp index 3dc21027be84..3ae19f9f5111 100644 --- a/lldb/source/Plugins/Process/Utility/RegisterContextLLDB.cpp +++ b/lldb/source/Plugins/Process/Utility/RegisterContextLLDB.cpp @@ -126,7 +126,7 @@ RegisterContextLLDB::InitializeZerothFrame() { m_current_offset = frame_sp->GetFrameCodeAddress().GetOffset() - m_start_pc.GetOffset(); } - else if (frame_sp->GetFrameCodeAddress().GetModule() == m_start_pc.GetModule()) + else if (frame_sp->GetFrameCodeAddress().GetModulePtr() == m_start_pc.GetModulePtr()) { // This means that whatever symbol we kicked up isn't really correct // as no should cross section boundaries... We really should NULL out @@ -284,7 +284,7 @@ RegisterContextLLDB::InitializeNonZerothFrame() // If we don't have a Module for some reason, we're not going to find symbol/function information - just // stick in some reasonable defaults and hope we can unwind past this frame. - if (!m_current_pc.IsValid() || m_current_pc.GetModule() == NULL) + if (!m_current_pc.IsValid() || m_current_pc.GetModulePtr() == NULL) { if (log) { @@ -397,7 +397,7 @@ RegisterContextLLDB::InitializeNonZerothFrame() } // We require that eSymbolContextSymbol be successfully filled in or this context is of no use to us. - if ((m_current_pc.GetModule()->ResolveSymbolContextForAddress (m_current_pc, eSymbolContextFunction| eSymbolContextSymbol, m_sym_ctx) & eSymbolContextSymbol) == eSymbolContextSymbol) + if ((m_current_pc.GetModulePtr()->ResolveSymbolContextForAddress (m_current_pc, eSymbolContextFunction| eSymbolContextSymbol, m_sym_ctx) & eSymbolContextSymbol) == eSymbolContextSymbol) { m_sym_ctx_valid = true; } @@ -436,7 +436,7 @@ RegisterContextLLDB::InitializeNonZerothFrame() temporary_pc.SetOffset(m_current_pc.GetOffset() - 1); m_sym_ctx.Clear(); m_sym_ctx_valid = false; - if ((m_current_pc.GetModule()->ResolveSymbolContextForAddress (temporary_pc, eSymbolContextFunction| eSymbolContextSymbol, m_sym_ctx) & eSymbolContextSymbol) == eSymbolContextSymbol) + if ((m_current_pc.GetModulePtr()->ResolveSymbolContextForAddress (temporary_pc, eSymbolContextFunction| eSymbolContextSymbol, m_sym_ctx) & eSymbolContextSymbol) == eSymbolContextSymbol) { m_sym_ctx_valid = true; } @@ -619,13 +619,13 @@ UnwindPlanSP RegisterContextLLDB::GetFastUnwindPlanForFrame () { UnwindPlanSP unwind_plan_sp; - if (!m_current_pc.IsValid() || m_current_pc.GetModule() == NULL || m_current_pc.GetModule()->GetObjectFile() == NULL) + if (!m_current_pc.IsValid() || m_current_pc.GetModulePtr() == NULL || m_current_pc.GetModulePtr()->GetObjectFile() == NULL) return unwind_plan_sp; if (IsFrameZero ()) return unwind_plan_sp; - FuncUnwindersSP func_unwinders_sp (m_current_pc.GetModule()->GetObjectFile()->GetUnwindTable().GetFuncUnwindersContainingAddress (m_current_pc, m_sym_ctx)); + FuncUnwindersSP func_unwinders_sp (m_current_pc.GetModulePtr()->GetObjectFile()->GetUnwindTable().GetFuncUnwindersContainingAddress (m_current_pc, m_sym_ctx)); if (!func_unwinders_sp) return unwind_plan_sp; @@ -712,7 +712,7 @@ RegisterContextLLDB::GetFullUnwindPlanForFrame () } // No Module for the current pc, try using the architecture default unwind. - if (!m_current_pc.IsValid() || m_current_pc.GetModule() == NULL || m_current_pc.GetModule()->GetObjectFile() == NULL) + if (!m_current_pc.IsValid() || m_current_pc.GetModulePtr() == NULL || m_current_pc.GetModulePtr()->GetObjectFile() == NULL) { m_frame_type = eNormalFrame; return arch_default_unwind_plan_sp; @@ -721,7 +721,7 @@ RegisterContextLLDB::GetFullUnwindPlanForFrame () FuncUnwindersSP func_unwinders_sp; if (m_sym_ctx_valid) { - func_unwinders_sp = m_current_pc.GetModule()->GetObjectFile()->GetUnwindTable().GetFuncUnwindersContainingAddress (m_current_pc, m_sym_ctx); + func_unwinders_sp = m_current_pc.GetModulePtr()->GetObjectFile()->GetUnwindTable().GetFuncUnwindersContainingAddress (m_current_pc, m_sym_ctx); } // No FuncUnwinders available for this pc, try using architectural default unwind. diff --git a/lldb/source/Plugins/Process/Utility/RegisterContextLLDB.h b/lldb/source/Plugins/Process/Utility/RegisterContextLLDB.h index a578fd779fe0..cdb0ccbc3256 100644 --- a/lldb/source/Plugins/Process/Utility/RegisterContextLLDB.h +++ b/lldb/source/Plugins/Process/Utility/RegisterContextLLDB.h @@ -25,7 +25,7 @@ class UnwindLLDB; class RegisterContextLLDB : public lldb_private::RegisterContext { public: - typedef lldb::SharedPtr::Type SharedPtr; + typedef SHARED_PTR(RegisterContextLLDB) SharedPtr; RegisterContextLLDB (lldb_private::Thread &thread, const SharedPtr& next_frame, diff --git a/lldb/source/Plugins/Process/Utility/UnwindLLDB.cpp b/lldb/source/Plugins/Process/Utility/UnwindLLDB.cpp index 954ad8b32832..bf71b008bd5c 100644 --- a/lldb/source/Plugins/Process/Utility/UnwindLLDB.cpp +++ b/lldb/source/Plugins/Process/Utility/UnwindLLDB.cpp @@ -69,10 +69,10 @@ UnwindLLDB::AddFirstFrame () { // First, set up the 0th (initial) frame CursorSP first_cursor_sp(new Cursor ()); - RegisterContextLLDBSharedPtr reg_ctx_sp (new RegisterContextLLDB (m_thread, - RegisterContextLLDBSharedPtr(), - first_cursor_sp->sctx, - 0, *this)); + RegisterContextLLDBSP reg_ctx_sp (new RegisterContextLLDB (m_thread, + RegisterContextLLDBSP(), + first_cursor_sp->sctx, + 0, *this)); if (reg_ctx_sp.get() == NULL) return false; @@ -87,7 +87,7 @@ UnwindLLDB::AddFirstFrame () // Everything checks out, so release the auto pointer value and let the // cursor own it in its shared pointer - first_cursor_sp->reg_ctx = reg_ctx_sp; + first_cursor_sp->reg_ctx_lldb_sp = reg_ctx_sp; m_frames.push_back (first_cursor_sp); return true; } @@ -104,10 +104,11 @@ UnwindLLDB::AddOneMoreFrame (ABI *abi) return false; uint32_t cur_idx = m_frames.size (); - RegisterContextLLDBSharedPtr reg_ctx_sp(new RegisterContextLLDB (m_thread, - m_frames[cur_idx - 1]->reg_ctx, - cursor_sp->sctx, - cur_idx, *this)); + RegisterContextLLDBSP reg_ctx_sp(new RegisterContextLLDB (m_thread, + m_frames[cur_idx - 1]->reg_ctx_lldb_sp, + cursor_sp->sctx, + cur_idx, + *this)); if (reg_ctx_sp.get() == NULL) return false; @@ -171,7 +172,7 @@ UnwindLLDB::AddOneMoreFrame (ABI *abi) } } } - cursor_sp->reg_ctx = reg_ctx_sp; + cursor_sp->reg_ctx_lldb_sp = reg_ctx_sp; m_frames.push_back (cursor_sp); return true; } @@ -218,21 +219,27 @@ UnwindLLDB::DoCreateRegisterContextForFrame (StackFrame *frame) ABI *abi = m_thread.GetProcess().GetABI().get(); - while (idx >= m_frames.size() && AddOneMoreFrame (abi)) - ; + while (idx >= m_frames.size()) + { + if (!AddOneMoreFrame (abi)) + break; + } - if (idx < m_frames.size ()) - reg_ctx_sp = m_frames[idx]->reg_ctx; + const uint32_t num_frames = m_frames.size(); + if (idx < num_frames) + { + Cursor *frame_cursor = m_frames[idx].get(); + reg_ctx_sp = frame_cursor->reg_ctx_lldb_sp->shared_from_this(); + } return reg_ctx_sp; } -UnwindLLDB::RegisterContextLLDBSharedPtr +UnwindLLDB::RegisterContextLLDBSP UnwindLLDB::GetRegisterContextForFrameNum (uint32_t frame_num) { - RegisterContextLLDBSharedPtr reg_ctx_sp; - if (frame_num >= m_frames.size()) - return reg_ctx_sp; - reg_ctx_sp = m_frames[frame_num]->reg_ctx; + RegisterContextLLDBSP reg_ctx_sp; + if (frame_num < m_frames.size()) + reg_ctx_sp = m_frames[frame_num]->reg_ctx_lldb_sp; return reg_ctx_sp; } @@ -244,7 +251,7 @@ UnwindLLDB::SearchForSavedLocationForRegister (uint32_t lldb_regnum, lldb_privat return false; while (frame_num >= 0) { - if (m_frames[frame_num]->reg_ctx->SavedLocationForRegister (lldb_regnum, regloc, false)) + if (m_frames[frame_num]->reg_ctx_lldb_sp->SavedLocationForRegister (lldb_regnum, regloc, false)) return true; frame_num--; } diff --git a/lldb/source/Plugins/Process/Utility/UnwindLLDB.h b/lldb/source/Plugins/Process/Utility/UnwindLLDB.h index ec9271ba8da4..b9352b61b8bf 100644 --- a/lldb/source/Plugins/Process/Utility/UnwindLLDB.h +++ b/lldb/source/Plugins/Process/Utility/UnwindLLDB.h @@ -69,11 +69,11 @@ protected: lldb::RegisterContextSP DoCreateRegisterContextForFrame (lldb_private::StackFrame *frame); - typedef lldb::SharedPtr::Type RegisterContextLLDBSharedPtr; + typedef SHARED_PTR(RegisterContextLLDB) RegisterContextLLDBSP; // Needed to retrieve the "next" frame (e.g. frame 2 needs to retrieve frame 1's RegisterContextLLDB) // The RegisterContext for frame_num must already exist or this returns an empty shared pointer. - RegisterContextLLDBSharedPtr + RegisterContextLLDBSP GetRegisterContextForFrameNum (uint32_t frame_num); // Iterate over the RegisterContextLLDB's in our m_frames vector, look for the first one that @@ -89,14 +89,14 @@ private: lldb::addr_t start_pc; // The start address of the function/symbol for this frame - current pc if unknown lldb::addr_t cfa; // The canonical frame address for this stack frame lldb_private::SymbolContext sctx; // A symbol context we'll contribute to & provide to the StackFrame creation - RegisterContextLLDBSharedPtr reg_ctx; // These are all RegisterContextLLDB's + RegisterContextLLDBSP reg_ctx_lldb_sp; // These are all RegisterContextLLDB's - Cursor () : start_pc (LLDB_INVALID_ADDRESS), cfa (LLDB_INVALID_ADDRESS), sctx(), reg_ctx() { } + Cursor () : start_pc (LLDB_INVALID_ADDRESS), cfa (LLDB_INVALID_ADDRESS), sctx(), reg_ctx_lldb_sp() { } private: DISALLOW_COPY_AND_ASSIGN (Cursor); }; - typedef lldb::SharedPtr::Type CursorSP; + typedef SHARED_PTR(Cursor) CursorSP; std::vector m_frames; bool AddOneMoreFrame (ABI *abi); diff --git a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemoteLog.cpp b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemoteLog.cpp index a605221d157a..7fd58026c28c 100644 --- a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemoteLog.cpp +++ b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemoteLog.cpp @@ -104,7 +104,7 @@ ProcessGDBRemoteLog::EnableLog (StreamSP &log_stream_sp, uint32_t log_options, A // Now make a new log with this stream if one was provided if (log_stream_sp) { - log = make_shared(log_stream_sp); + log.reset (new Log(log_stream_sp)); GetLog () = log; } diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.h b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.h index e71d31963da0..f4ee96b7c7d4 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.h +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.h @@ -21,7 +21,7 @@ typedef std::multimap CS typedef CStringToDIEMap::iterator CStringToDIEMapIter; typedef CStringToDIEMap::const_iterator CStringToDIEMapConstIter; -typedef lldb::SharedPtr::Type DWARFCompileUnitSP; +typedef SHARED_PTR(DWARFCompileUnit) DWARFCompileUnitSP; class DWARFDebugInfo { diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugLine.h b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugLine.h index 51e006288483..843d0812bef2 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugLine.h +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugLine.h @@ -68,7 +68,7 @@ public: { } - typedef lldb::SharedPtr::Type shared_ptr; + typedef SHARED_PTR(Prologue) shared_ptr; uint32_t total_length; // The size in bytes of the statement information for this compilation unit (not including the total_length field itself). uint16_t version; // Version identifier for the statement information format. @@ -135,7 +135,7 @@ public: //------------------------------------------------------------------ struct LineTable { - typedef lldb::SharedPtr::Type shared_ptr; + typedef SHARED_PTR(LineTable) shared_ptr; LineTable() : prologue(), diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp index 816cd647de22..5e963508231f 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp @@ -2031,7 +2031,7 @@ SymbolFileDWARF::GetFunction (DWARFCompileUnit* curr_cu, const DWARFDebugInfoEnt if (sc.function) { - sc.module_sp = sc.function->CalculateSymbolContextModule(); + sc.module_sp = sc.function->CalculateSymbolContextModule()->shared_from_this(); return true; } @@ -2449,7 +2449,7 @@ SymbolFileDWARF::FindGlobalVariables (const ConstString &name, const lldb_privat if (num_matches) { SymbolContext sc; - sc.module_sp = m_obj_file->GetModule(); + sc.module_sp = m_obj_file->GetModule()->shared_from_this(); assert (sc.module_sp); DWARFDebugInfo* debug_info = DebugInfo(); @@ -2535,7 +2535,7 @@ SymbolFileDWARF::FindGlobalVariables(const RegularExpression& regex, bool append } SymbolContext sc; - sc.module_sp = m_obj_file->GetModule(); + sc.module_sp = m_obj_file->GetModule()->shared_from_this(); assert (sc.module_sp); DWARFCompileUnit* dwarf_cu = NULL; @@ -3149,7 +3149,7 @@ SymbolFileDWARF::FindTypes (const SymbolContext& sc, if (matching_type) { // We found a type pointer, now find the shared pointer form our type list - types.InsertUnique (TypeSP (matching_type)); + types.InsertUnique (matching_type->shared_from_this()); if (types.GetSize() >= max_matches) break; } @@ -3267,7 +3267,7 @@ SymbolFileDWARF::FindTypes(std::vector die_offsets, uint32_t max_ma if (matching_type) { // We found a type pointer, now find the shared pointer form our type list - types.InsertUnique (TypeSP (matching_type)); + types.InsertUnique (matching_type->shared_from_this()); ++num_matches; if (num_matches >= max_matches) break; @@ -3282,7 +3282,6 @@ SymbolFileDWARF::FindTypes(std::vector die_offsets, uint32_t max_ma size_t SymbolFileDWARF::ParseChildParameters (const SymbolContext& sc, clang::DeclContext *containing_decl_ctx, - TypeSP& type_sp, DWARFCompileUnit* dwarf_cu, const DWARFDebugInfoEntry *parent_die, bool skip_artificial, @@ -3676,7 +3675,7 @@ SymbolFileDWARF::GetTypeForDIE (DWARFCompileUnit *curr_cu, const DWARFDebugInfoE else if (type_ptr != DIE_IS_BEING_PARSED) { // Grab the existing type from the master types lists - type_sp = type_ptr; + type_sp = type_ptr->shared_from_this(); } } @@ -4026,7 +4025,7 @@ SymbolFileDWARF::FindCompleteObjCDefinitionTypeForDIE (const DWARFDebugInfoEntry if (die) m_die_to_type[die] = resolved_type; - type_sp = resolved_type; + type_sp = resolved_type->shared_from_this(); break; } } @@ -4148,7 +4147,7 @@ SymbolFileDWARF::FindDefinitionTypeForDIE (DWARFCompileUnit* cu, MakeUserID(type_cu->GetOffset())); m_die_to_type[die] = resolved_type; - type_sp = resolved_type; + type_sp = resolved_type->shared_from_this(); break; } } @@ -4934,7 +4933,6 @@ SymbolFileDWARF::ParseType (const SymbolContext& sc, DWARFCompileUnit* dwarf_cu, bool skip_artificial = true; ParseChildParameters (sc, containing_decl_ctx, - type_sp, dwarf_cu, die, skip_artificial, @@ -5120,7 +5118,7 @@ SymbolFileDWARF::ParseType (const SymbolContext& sc, DWARFCompileUnit* dwarf_cu, type_ptr = m_die_to_type[die]; if (type_ptr) { - type_sp = type_ptr; + type_sp = type_ptr->shared_from_this(); break; } } @@ -5343,7 +5341,7 @@ SymbolFileDWARF::ParseType (const SymbolContext& sc, DWARFCompileUnit* dwarf_cu, } else if (type_ptr != DIE_IS_BEING_PARSED) { - type_sp = type_ptr; + type_sp = type_ptr->shared_from_this(); } } return type_sp; diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h index 7f4b16e015a8..72ac34656fa3 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h +++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h @@ -347,7 +347,6 @@ protected: size_t ParseChildParameters( const lldb_private::SymbolContext& sc, clang::DeclContext *containing_decl_ctx, - lldb::TypeSP& type_sp, DWARFCompileUnit* dwarf_cu, const DWARFDebugInfoEntry *parent_die, bool skip_artificial, diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp index 5c4fba29b493..2fa5a934dd1f 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp @@ -172,10 +172,10 @@ SymbolFileDWARFDebugMap::GetModuleByCompUnitInfo (CompileUnitInfo *comp_unit_inf // use the debug map, to add new sections to each .o file and // even though a .o file might not have changed, the sections // that get added to the .o file can change. - comp_unit_info->oso_module_sp = new Module (oso_file_spec, - m_obj_file->GetModule()->GetArchitecture(), - NULL, - 0); + comp_unit_info->oso_module_sp.reset (new Module (oso_file_spec, + m_obj_file->GetModule()->GetArchitecture(), + NULL, + 0)); } } return comp_unit_info->oso_module_sp.get(); diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h index 6d80d77d0442..8dca2c5cd93e 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h +++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h @@ -141,7 +141,7 @@ protected: lldb_private::SymbolVendor *oso_symbol_vendor; std::vector function_indexes; std::vector static_indexes; - lldb::SharedPtr::Type debug_map_sections_sp; + SHARED_PTR(lldb_private::SectionList) debug_map_sections_sp; CompileUnitInfo() : so_file (), diff --git a/lldb/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.cpp b/lldb/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.cpp index d560bc3a8387..6fc5968d9ddd 100644 --- a/lldb/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.cpp +++ b/lldb/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.cpp @@ -411,7 +411,7 @@ SymbolFileSymtab::FindTypes (const lldb_private::SymbolContext& sc, Declaration decl; - lldb::TypeSP type(new Type (iter->second, + lldb::TypeSP type(new Type (match->value, this, name, 0, // byte_size - don't change this from 0, we currently use that to identify these "synthetic" ObjC class types. diff --git a/lldb/source/Plugins/SymbolVendor/MacOSX/SymbolVendorMacOSX.cpp b/lldb/source/Plugins/SymbolVendor/MacOSX/SymbolVendorMacOSX.cpp index 12243676aed8..fce609b82ebd 100644 --- a/lldb/source/Plugins/SymbolVendor/MacOSX/SymbolVendorMacOSX.cpp +++ b/lldb/source/Plugins/SymbolVendor/MacOSX/SymbolVendorMacOSX.cpp @@ -162,7 +162,7 @@ SymbolVendorMacOSX::CreateInstance(Module* module) // Just create our symbol vendor using the current objfile as this is either // an executable with no dSYM (that we could locate), an executable with // a dSYM that has a UUID that doesn't match. - symbol_vendor->AddSymbolFileRepresentation(obj_file->GetSP()); + symbol_vendor->AddSymbolFileRepresentation(obj_file->shared_from_this()); } } return symbol_vendor; diff --git a/lldb/source/Symbol/ObjectFile.cpp b/lldb/source/Symbol/ObjectFile.cpp index 075e48fbc526..02f176ab691a 100644 --- a/lldb/source/Symbol/ObjectFile.cpp +++ b/lldb/source/Symbol/ObjectFile.cpp @@ -276,14 +276,6 @@ ObjectFile::GetAddressClass (addr_t file_addr) return eAddressClassUnknown; } -ObjectFileSP -ObjectFile::GetSP () -{ - // This object contains an instrusive ref count base class so we can - // easily make a shared pointer to this object - return ObjectFileSP (this); -} - size_t ObjectFile::GetData (off_t offset, size_t length, DataExtractor &data) const { diff --git a/lldb/source/Symbol/Symbol.cpp b/lldb/source/Symbol/Symbol.cpp index 016ac972a242..0f1b7ce2a160 100644 --- a/lldb/source/Symbol/Symbol.cpp +++ b/lldb/source/Symbol/Symbol.cpp @@ -267,7 +267,7 @@ Symbol::GetPrologueByteSize () if (!m_type_data_resolved) { m_type_data_resolved = true; - Module *module = m_addr_range.GetBaseAddress().GetModule(); + Module *module = m_addr_range.GetBaseAddress().GetModulePtr(); SymbolContext sc; if (module && module->ResolveSymbolContextForAddress (m_addr_range.GetBaseAddress(), eSymbolContextLineEntry, @@ -350,15 +350,9 @@ Symbol::CalculateSymbolContext (SymbolContext *sc) sc->symbol = this; const AddressRange *range = GetAddressRangePtr(); if (range) - { - Module *module = range->GetBaseAddress().GetModule (); - if (module) - { - sc->module_sp = module; - return; - } - } - sc->module_sp.reset(); + sc->module_sp = range->GetBaseAddress().GetModuleSP (); + else + sc->module_sp.reset(); } Module * @@ -366,7 +360,7 @@ Symbol::CalculateSymbolContextModule () { const AddressRange *range = GetAddressRangePtr(); if (range) - return range->GetBaseAddress().GetModule (); + return range->GetBaseAddress().GetModulePtr (); return NULL; } @@ -384,7 +378,7 @@ Symbol::DumpSymbolContext (Stream *s) const AddressRange *range = GetAddressRangePtr(); if (range) { - Module *module = range->GetBaseAddress().GetModule (); + Module *module = range->GetBaseAddress().GetModulePtr (); if (module) { dumped_module = true; diff --git a/lldb/source/Symbol/SymbolVendor.cpp b/lldb/source/Symbol/SymbolVendor.cpp index 3a4875641d0f..631135d9e671 100644 --- a/lldb/source/Symbol/SymbolVendor.cpp +++ b/lldb/source/Symbol/SymbolVendor.cpp @@ -58,7 +58,7 @@ SymbolVendor::FindPlugin (Module* module) { ObjectFile *objfile = module->GetObjectFile(); if (objfile) - instance_ap->AddSymbolFileRepresentation(objfile->GetSP()); + instance_ap->AddSymbolFileRepresentation(objfile->shared_from_this()); } return instance_ap.release(); } diff --git a/lldb/source/Symbol/Type.cpp b/lldb/source/Symbol/Type.cpp index 985174b770ce..66a13e2f38a4 100644 --- a/lldb/source/Symbol/Type.cpp +++ b/lldb/source/Symbol/Type.cpp @@ -34,7 +34,7 @@ Type * SymbolFileType::GetType () { if (!m_type_sp) - m_type_sp = m_symbol_file.ResolveTypeUID (GetID()); + m_type_sp = m_symbol_file.ResolveTypeUID (GetID())->shared_from_this(); return m_type_sp.get(); } diff --git a/lldb/source/Symbol/Variable.cpp b/lldb/source/Symbol/Variable.cpp index cb3f86eb97f3..a868e5f5cbb1 100644 --- a/lldb/source/Symbol/Variable.cpp +++ b/lldb/source/Symbol/Variable.cpp @@ -243,7 +243,7 @@ Variable::LocationIsValidForAddress (const Address &address) { SymbolContext sc; CalculateSymbolContext(&sc); - if (sc.module_sp.get() == address.GetModule()) + if (sc.module_sp.get() == address.GetModulePtr()) { // Is the variable is described by a single location? if (!m_location.IsLocationList()) @@ -480,7 +480,7 @@ Variable::DumpLocationForAddress (Stream *s, const Address &address) { SymbolContext sc; CalculateSymbolContext(&sc); - if (sc.module_sp.get() == address.GetModule()) + if (sc.module_sp.get() == address.GetModulePtr()) { ABI *abi = NULL; if (m_owner_scope) diff --git a/lldb/source/Target/ExecutionContext.cpp b/lldb/source/Target/ExecutionContext.cpp index 41cf04d0dbe2..8360d1addcfa 100644 --- a/lldb/source/Target/ExecutionContext.cpp +++ b/lldb/source/Target/ExecutionContext.cpp @@ -46,7 +46,7 @@ ExecutionContext::operator =(const ExecutionContext &rhs) } ExecutionContext::ExecutionContext (Target* t, bool fill_current_process_thread_frame) : - m_target_sp (t), + m_target_sp (t->shared_from_this()), m_process_sp (), m_thread_sp (), m_frame_sp () @@ -58,17 +58,19 @@ ExecutionContext::ExecutionContext (Target* t, bool fill_current_process_thread_ { m_thread_sp = m_process_sp->GetThreadList().GetSelectedThread(); if (m_thread_sp) - m_frame_sp = m_thread_sp->GetSelectedFrame().get(); + m_frame_sp = m_thread_sp->GetSelectedFrame(); } } } ExecutionContext::ExecutionContext(Process* process, Thread *thread, StackFrame *frame) : - m_target_sp (process ? &process->GetTarget() : NULL), - m_process_sp (process), - m_thread_sp (thread), - m_frame_sp (frame) + m_target_sp (), + m_process_sp (process->shared_from_this()), + m_thread_sp (thread->shared_from_this()), + m_frame_sp (frame->shared_from_this()) { + if (process) + m_target_sp = process->GetTarget().shared_from_this(); } ExecutionContext::ExecutionContext (ExecutionContextScope *exe_scope_ptr) @@ -200,24 +202,36 @@ ExecutionContext::SetFrameSP (const lldb::StackFrameSP &frame_sp) void ExecutionContext::SetTargetPtr (Target* target) { - m_target_sp = target; + if (target) + m_target_sp = target->shared_from_this(); + else + m_target_sp.reset(); } void ExecutionContext::SetProcessPtr (Process *process) { - m_process_sp = process; + if (process) + m_process_sp = process->shared_from_this(); + else + m_process_sp.reset(); } void ExecutionContext::SetThreadPtr (Thread *thread) { - m_thread_sp = thread; + if (thread) + m_thread_sp = thread->shared_from_this(); + else + m_thread_sp.reset(); } void ExecutionContext::SetFramePtr (StackFrame *frame) { - m_frame_sp = frame; + if (frame) + m_frame_sp = frame->shared_from_this(); + else + m_frame_sp.reset(); } diff --git a/lldb/source/Target/Process.cpp b/lldb/source/Target/Process.cpp index 2eb519ff7c95..e991437366e5 100644 --- a/lldb/source/Target/Process.cpp +++ b/lldb/source/Target/Process.cpp @@ -848,7 +848,7 @@ Process::Finalize() m_abi_sp.reset(); m_os_ap.reset(); m_dyld_ap.reset(); - m_thread_list.Clear(); + m_thread_list.Destroy(); std::vector empty_notifications; m_notifications.swap(empty_notifications); m_image_tokens.clear(); @@ -1543,7 +1543,7 @@ Process::EnableBreakpointSiteByID (lldb::user_id_t break_id) } lldb::break_id_t -Process::CreateBreakpointSite (BreakpointLocationSP &owner, bool use_hardware) +Process::CreateBreakpointSite (const BreakpointLocationSP &owner, bool use_hardware) { const addr_t load_addr = owner->GetAddress().GetOpcodeLoadAddress (&m_target); if (load_addr != LLDB_INVALID_ADDRESS) @@ -3410,12 +3410,6 @@ Process::CalculateExecutionContext (ExecutionContext &exe_ctx) exe_ctx.SetFramePtr (NULL); } -lldb::ProcessSP -Process::GetSP () -{ - return GetTarget().GetProcessSP(); -} - //uint32_t //Process::ListProcessesMatchingName (const char *name, StringList &matches, std::vector &pids) //{ @@ -3680,13 +3674,10 @@ void Process::UpdateInstanceName () { Module *module = GetTarget().GetExecutableModulePointer(); - if (module) + if (module && module->GetFileSpec().GetFilename()) { - StreamString sstr; - sstr.Printf ("%s", module->GetFileSpec().GetFilename().AsCString()); - GetSettingsController()->RenameInstanceSettings (GetInstanceName().AsCString(), - sstr.GetData()); + module->GetFileSpec().GetFilename().AsCString()); } } diff --git a/lldb/source/Target/StackFrame.cpp b/lldb/source/Target/StackFrame.cpp index 666bc1d94c37..2ce69f8c04e8 100644 --- a/lldb/source/Target/StackFrame.cpp +++ b/lldb/source/Target/StackFrame.cpp @@ -95,7 +95,7 @@ StackFrame::StackFrame (user_id_t frame_idx, if (reg_context_sp && !m_sc.target_sp) { - m_sc.target_sp = reg_context_sp->GetThread().GetProcess().GetTarget().GetSP(); + m_sc.target_sp = reg_context_sp->GetThread().GetProcess().GetTarget().shared_from_this(); m_flags.Set (eSymbolContextTarget); } } @@ -129,16 +129,16 @@ StackFrame::StackFrame (user_id_t frame_idx, if (m_sc.target_sp.get() == NULL && reg_context_sp) { - m_sc.target_sp = reg_context_sp->GetThread().GetProcess().GetTarget().GetSP(); + m_sc.target_sp = reg_context_sp->GetThread().GetProcess().GetTarget().shared_from_this(); m_flags.Set (eSymbolContextTarget); } - Module *pc_module = pc_addr.GetModule(); + Module *pc_module = pc_addr.GetModulePtr(); if (m_sc.module_sp.get() == NULL || m_sc.module_sp.get() != pc_module) { if (pc_module) { - m_sc.module_sp = pc_module; + m_sc.module_sp = pc_module->shared_from_this(); m_flags.Set (eSymbolContextModule); } else @@ -218,7 +218,7 @@ StackFrame::GetFrameCodeAddress() Module *module = section->GetModule(); if (module) { - m_sc.module_sp = module; + m_sc.module_sp = module->shared_from_this(); if (m_sc.module_sp) m_flags.Set(eSymbolContextModule); } @@ -417,7 +417,7 @@ StackFrame::GetSymbolContext (uint32_t resolve_scope) // If the target was requested add that: if (m_sc.target_sp.get() == NULL) { - m_sc.target_sp = CalculateProcess()->GetTarget().GetSP(); + m_sc.target_sp = CalculateProcess()->GetTarget().shared_from_this(); if (m_sc.target_sp) resolved |= eSymbolContextTarget; } @@ -1245,16 +1245,6 @@ StackFrame::HasCachedData () const return false; } -StackFrameSP -StackFrame::GetSP () -{ - // This object contains an instrusive ref count base class so we can - // easily make a shared pointer to this object - return StackFrameSP (this); -} - - - bool StackFrame::GetStatus (Stream& strm, bool show_frame_info, diff --git a/lldb/source/Target/Target.cpp b/lldb/source/Target/Target.cpp index 46ce1d32caf9..f4159de5cd97 100644 --- a/lldb/source/Target/Target.cpp +++ b/lldb/source/Target/Target.cpp @@ -149,14 +149,6 @@ Target::GetProcessSP () const return m_process_sp; } -lldb::TargetSP -Target::GetSP() -{ - // This object contains an instrusive ref count base class so we can - // easily make a shared pointer to this object - return TargetSP(this); -} - void Target::Destroy() { @@ -256,8 +248,7 @@ Target::CreateBreakpoint (lldb::addr_t addr, bool internal) BreakpointSP Target::CreateBreakpoint (Address &addr, bool internal) { - TargetSP target_sp = this->GetSP(); - SearchFilterSP filter_sp(new SearchFilterForNonModuleSpecificSearches (target_sp)); + SearchFilterSP filter_sp(new SearchFilterForNonModuleSpecificSearches (shared_from_this())); BreakpointResolverSP resolver_sp (new BreakpointResolverAddress (NULL, addr)); return CreateBreakpoint (filter_sp, resolver_sp, internal); } @@ -290,17 +281,16 @@ SearchFilterSP Target::GetSearchFilterForModule (const FileSpec *containingModule) { SearchFilterSP filter_sp; - lldb::TargetSP target_sp = this->GetSP(); if (containingModule != NULL) { // TODO: We should look into sharing module based search filters // across many breakpoints like we do for the simple target based one - filter_sp.reset (new SearchFilterByModule (target_sp, *containingModule)); + filter_sp.reset (new SearchFilterByModule (shared_from_this(), *containingModule)); } else { if (m_search_filter_sp.get() == NULL) - m_search_filter_sp.reset (new SearchFilterForNonModuleSpecificSearches (target_sp)); + m_search_filter_sp.reset (new SearchFilterForNonModuleSpecificSearches (shared_from_this())); filter_sp = m_search_filter_sp; } return filter_sp; @@ -310,17 +300,16 @@ SearchFilterSP Target::GetSearchFilterForModuleList (const FileSpecList *containingModules) { SearchFilterSP filter_sp; - lldb::TargetSP target_sp = this->GetSP(); if (containingModules && containingModules->GetSize() != 0) { // TODO: We should look into sharing module based search filters // across many breakpoints like we do for the simple target based one - filter_sp.reset (new SearchFilterByModuleList (target_sp, *containingModules)); + filter_sp.reset (new SearchFilterByModuleList (shared_from_this(), *containingModules)); } else { if (m_search_filter_sp.get() == NULL) - m_search_filter_sp.reset (new SearchFilterForNonModuleSpecificSearches (target_sp)); + m_search_filter_sp.reset (new SearchFilterForNonModuleSpecificSearches (shared_from_this())); filter_sp = m_search_filter_sp; } return filter_sp; @@ -333,17 +322,16 @@ Target::GetSearchFilterForModuleAndCUList (const FileSpecList *containingModules return GetSearchFilterForModuleList(containingModules); SearchFilterSP filter_sp; - lldb::TargetSP target_sp = this->GetSP(); if (containingModules == NULL) { // We could make a special "CU List only SearchFilter". Better yet was if these could be composable, // but that will take a little reworking. - filter_sp.reset (new SearchFilterByModuleListAndCU (target_sp, FileSpecList(), *containingSourceFiles)); + filter_sp.reset (new SearchFilterByModuleListAndCU (shared_from_this(), FileSpecList(), *containingSourceFiles)); } else { - filter_sp.reset (new SearchFilterByModuleListAndCU (target_sp, *containingModules, *containingSourceFiles)); + filter_sp.reset (new SearchFilterByModuleListAndCU (shared_from_this(), *containingModules, *containingSourceFiles)); } return filter_sp; } @@ -1073,11 +1061,12 @@ Target::ReadMemory (const Address& addr, if (load_addr == LLDB_INVALID_ADDRESS) { - if (resolved_addr.GetModule() && resolved_addr.GetModule()->GetFileSpec()) + Module *addr_module = resolved_addr.GetModulePtr(); + if (addr_module && addr_module->GetFileSpec()) error.SetErrorStringWithFormat("%s[0x%llx] can't be resolved, %s in not currently loaded", - resolved_addr.GetModule()->GetFileSpec().GetFilename().AsCString(), + addr_module->GetFileSpec().GetFilename().AsCString(), resolved_addr.GetFileAddress(), - resolved_addr.GetModule()->GetFileSpec().GetFilename().AsCString()); + addr_module->GetFileSpec().GetFilename().AsCString()); else error.SetErrorStringWithFormat("0x%llx can't be resolved", resolved_addr.GetFileAddress()); } @@ -1339,7 +1328,7 @@ Target::GetScratchClangASTContext(bool create_on_demand) if (m_scratch_ast_context_ap.get() == NULL && m_arch.IsValid() && create_on_demand) { m_scratch_ast_context_ap.reset (new ClangASTContext(m_arch.GetTriple().str().c_str())); - m_scratch_ast_source_ap.reset (new ClangASTSource(GetSP())); + m_scratch_ast_source_ap.reset (new ClangASTSource(shared_from_this())); m_scratch_ast_source_ap->InstallASTContext(m_scratch_ast_context_ap->getASTContext()); llvm::OwningPtr proxy_ast_source(m_scratch_ast_source_ap->CreateProxy()); m_scratch_ast_context_ap->SetExternalSource(proxy_ast_source); @@ -1678,7 +1667,7 @@ lldb::user_id_t Target::AddStopHook (Target::StopHookSP &new_hook_sp) { lldb::user_id_t new_uid = ++m_stop_hook_next_id; - new_hook_sp.reset (new StopHook(GetSP(), new_uid)); + new_hook_sp.reset (new StopHook(shared_from_this(), new_uid)); m_stop_hooks[new_uid] = new_hook_sp; return new_uid; } diff --git a/lldb/source/Target/Thread.cpp b/lldb/source/Target/Thread.cpp index ae083c770e36..5d7c9056263d 100644 --- a/lldb/source/Target/Thread.cpp +++ b/lldb/source/Target/Thread.cpp @@ -1030,15 +1030,6 @@ Thread::DumpUsingSettingsFormat (Stream &strm, uint32_t frame_idx) &end); } -lldb::ThreadSP -Thread::GetSP () -{ - // This object contains an instrusive ref count base class so we can - // easily make a shared pointer to this object - return ThreadSP(this); -} - - void Thread::SettingsInitialize () { diff --git a/lldb/source/Target/ThreadList.cpp b/lldb/source/Target/ThreadList.cpp index f4d75f5502fb..62eb1defde30 100644 --- a/lldb/source/Target/ThreadList.cpp +++ b/lldb/source/Target/ThreadList.cpp @@ -354,6 +354,17 @@ ThreadList::Clear() m_selected_tid = LLDB_INVALID_THREAD_ID; } +void +ThreadList::Destroy() +{ + Mutex::Locker locker(m_threads_mutex); + const uint32_t num_threads = m_threads.size(); + for (uint32_t idx = 0; idx < num_threads; ++idx) + { + m_threads[idx]->DestroyThread(); + } +} + void ThreadList::RefreshStateAfterStop () { @@ -603,6 +614,32 @@ ThreadList::Update (ThreadList &rhs) m_stop_id = rhs.m_stop_id; m_threads.swap(rhs.m_threads); m_selected_tid = rhs.m_selected_tid; + + + // Now we look for threads that we are done with and + // make sure to clear them up as much as possible so + // anyone with a shared pointer will still have a reference, + // but the thread won't be of much use. Using std::weak_ptr + // for all backward references (such as a thread to a process) + // will eventually solve this issue for us, but for now, we + // need to work around the issue + collection::iterator rhs_pos, rhs_end = rhs.m_threads.end(); + for (rhs_pos = rhs.m_threads.begin(); rhs_pos != rhs_end; ++rhs_pos) + { + const lldb::tid_t tid = (*rhs_pos)->GetID(); + bool thread_is_alive = false; + const uint32_t num_threads = m_threads.size(); + for (uint32_t idx = 0; idx < num_threads; ++idx) + { + if (m_threads[idx]->GetID() == tid) + { + thread_is_alive = true; + break; + } + } + if (!thread_is_alive) + (*rhs_pos)->DestroyThread(); + } } } diff --git a/lldb/source/Target/ThreadPlanTestCondition.cpp b/lldb/source/Target/ThreadPlanTestCondition.cpp index 42aa01cf8b7a..b9f8a27268c6 100644 --- a/lldb/source/Target/ThreadPlanTestCondition.cpp +++ b/lldb/source/Target/ThreadPlanTestCondition.cpp @@ -119,7 +119,7 @@ ThreadPlanTestCondition::ShouldStop (Event *event_ptr) else { // Now we have to change the event to a breakpoint event and mark it up appropriately: - Process::ProcessEventData *new_data = new Process::ProcessEventData (m_thread.GetProcess().GetSP(), eStateStopped); + Process::ProcessEventData *new_data = new Process::ProcessEventData (m_thread.GetProcess().shared_from_this(), eStateStopped); event_ptr->SetData(new_data); event_ptr->SetType(Process::eBroadcastBitStateChanged); SetStopInfo(StopInfo::CreateStopReasonWithBreakpointSiteID (m_thread, diff --git a/lldb/source/lldb-log.cpp b/lldb/source/lldb-log.cpp index 6dc32f0d3786..b02dd25d5f10 100644 --- a/lldb/source/lldb-log.cpp +++ b/lldb/source/lldb-log.cpp @@ -169,7 +169,7 @@ lldb_private::EnableLog (StreamSP &log_stream_sp, uint32_t log_options, Args &ar // Now make a new log with this stream if one was provided if (log_stream_sp) { - log = make_shared(log_stream_sp); + log.reset (new Log(log_stream_sp)); GetLog () = log; }