[Lldb-commits] [PATCH] Introduce a new UnwindAssemblySP shared pointer type and use it to fix a memory leak. We are never deleting UnwindAssembly.
Jean-Daniel Dupas
devlists at shadowlab.org
Mon Feb 3 15:59:38 PST 2014
Thank you. Pushed as r200725
Le 4 févr. 2014 à 00:14, Greg Clayton <gclayton at apple.com> a écrit :
> Looks good!
>
> On Feb 3, 2014, at 2:45 PM, Jean-Daniel Dupas <devlists at shadowlab.org> wrote:
>
>> Fix usage of enable_shared_from_this by avoiding creation of naked pointer.
>>
>> http://llvm-reviews.chandlerc.com/D2491
>>
>> CHANGE SINCE LAST DIFF
>> http://llvm-reviews.chandlerc.com/D2491?vs=6821&id=6835#toc
>>
>> Files:
>> include/lldb/Symbol/FuncUnwinders.h
>> include/lldb/Symbol/UnwindTable.h
>> include/lldb/Target/UnwindAssembly.h
>> include/lldb/lldb-forward.h
>> source/Symbol/FuncUnwinders.cpp
>> source/Target/UnwindAssembly.cpp
>>
>> Index: include/lldb/Symbol/FuncUnwinders.h
>> ===================================================================
>> --- include/lldb/Symbol/FuncUnwinders.h
>> +++ include/lldb/Symbol/FuncUnwinders.h
>> @@ -31,7 +31,7 @@
>> // instructions are finished for migrating breakpoints past the
>> // stack frame setup instructions when we don't have line table information.
>>
>> - FuncUnwinders (lldb_private::UnwindTable& unwind_table, lldb_private::UnwindAssembly *assembly_profiler, AddressRange range);
>> + FuncUnwinders (lldb_private::UnwindTable& unwind_table, const lldb::UnwindAssemblySP& assembly_profiler, AddressRange range);
>>
>> ~FuncUnwinders ();
>>
>> @@ -77,7 +77,7 @@
>>
>> private:
>> UnwindTable& m_unwind_table;
>> - UnwindAssembly *m_assembly_profiler;
>> + lldb::UnwindAssemblySP m_assembly_profiler;
>> AddressRange m_range;
>>
>> Mutex m_mutex;
>> Index: include/lldb/Symbol/UnwindTable.h
>> ===================================================================
>> --- include/lldb/Symbol/UnwindTable.h
>> +++ include/lldb/Symbol/UnwindTable.h
>> @@ -57,7 +57,7 @@
>>
>> bool m_initialized; // delay some initialization until ObjectFile is set up
>>
>> - UnwindAssembly* m_assembly_profiler;
>> + lldb::UnwindAssemblySP m_assembly_profiler;
>>
>> DWARFCallFrameInfo* m_eh_frame;
>>
>> Index: include/lldb/Target/UnwindAssembly.h
>> ===================================================================
>> --- include/lldb/Target/UnwindAssembly.h
>> +++ include/lldb/Target/UnwindAssembly.h
>> @@ -17,10 +17,11 @@
>> namespace lldb_private {
>>
>> class UnwindAssembly :
>> + public std::enable_shared_from_this<UnwindAssembly>,
>> public PluginInterface
>> {
>> public:
>> - static UnwindAssembly*
>> + static lldb::UnwindAssemblySP
>> FindPlugin (const ArchSpec &arch);
>>
>> virtual
>> Index: include/lldb/lldb-forward.h
>> ===================================================================
>> --- include/lldb/lldb-forward.h
>> +++ include/lldb/lldb-forward.h
>> @@ -384,6 +384,7 @@
>> #ifndef LLDB_DISABLE_PYTHON
>> typedef std::shared_ptr<lldb_private::ScriptedSyntheticChildren> ScriptedSyntheticChildrenSP;
>> #endif
>> + typedef std::shared_ptr<lldb_private::UnwindAssembly> UnwindAssemblySP;
>> typedef std::shared_ptr<lldb_private::UnwindPlan> UnwindPlanSP;
>> typedef lldb_private::SharingPtr<lldb_private::ValueObject> ValueObjectSP;
>> typedef std::shared_ptr<lldb_private::Value> ValueSP;
>> Index: source/Symbol/FuncUnwinders.cpp
>> ===================================================================
>> --- source/Symbol/FuncUnwinders.cpp
>> +++ source/Symbol/FuncUnwinders.cpp
>> @@ -28,7 +28,7 @@
>> FuncUnwinders::FuncUnwinders
>> (
>> UnwindTable& unwind_table,
>> - UnwindAssembly *assembly_profiler,
>> + const lldb::UnwindAssemblySP& assembly_profiler,
>> AddressRange range
>> ) :
>> m_unwind_table(unwind_table),
>> Index: source/Target/UnwindAssembly.cpp
>> ===================================================================
>> --- source/Target/UnwindAssembly.cpp
>> +++ source/Target/UnwindAssembly.cpp
>> @@ -15,18 +15,18 @@
>> using namespace lldb;
>> using namespace lldb_private;
>>
>> -UnwindAssembly*
>> +UnwindAssemblySP
>> UnwindAssembly::FindPlugin (const ArchSpec &arch)
>> {
>> UnwindAssemblyCreateInstance create_callback;
>>
>> for (uint32_t idx = 0;
>> (create_callback = PluginManager::GetUnwindAssemblyCreateCallbackAtIndex(idx)) != NULL;
>> ++idx)
>> {
>> - std::unique_ptr<UnwindAssembly> assembly_profiler_ap (create_callback (arch));
>> + UnwindAssemblySP assembly_profiler_ap (create_callback (arch));
>> if (assembly_profiler_ap.get ())
>> - return assembly_profiler_ap.release ();
>> + return assembly_profiler_ap;
>> }
>> return NULL;
>> }
>> <D2491.3.patch>_______________________________________________
>> lldb-commits mailing list
>> lldb-commits at cs.uiuc.edu
>> http://lists.cs.uiuc.edu/mailman/listinfo/lldb-commits
>
-- Jean-Daniel
More information about the lldb-commits
mailing list