diff options
author | Greg Clayton <gclayton@apple.com> | 2012-01-29 20:56:30 +0000 |
---|---|---|
committer | Greg Clayton <gclayton@apple.com> | 2012-01-29 20:56:30 +0000 |
commit | e1cd1be6d64cde1765336489d05d71cd2785f15a (patch) | |
tree | b387c4c316a696ab74c5dbf3a780224544076284 /lldb/source/Plugins/SymbolFile | |
parent | 3f09de6442ebf51b80359e3639d863a3945170dd (diff) | |
download | bcm5719-llvm-e1cd1be6d64cde1765336489d05d71cd2785f15a.tar.gz bcm5719-llvm-e1cd1be6d64cde1765336489d05d71cd2785f15a.zip |
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
Diffstat (limited to 'lldb/source/Plugins/SymbolFile')
7 files changed, 19 insertions, 22 deletions
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.h b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.h index e71d31963da..f4ee96b7c7d 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.h +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.h @@ -21,7 +21,7 @@ typedef std::multimap<const char*, dw_offset_t, CStringCompareFunctionObject> CS typedef CStringToDIEMap::iterator CStringToDIEMapIter; typedef CStringToDIEMap::const_iterator CStringToDIEMapConstIter; -typedef lldb::SharedPtr<DWARFCompileUnit>::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 51e00628848..843d0812bef 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<Prologue>::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<LineTable>::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 816cd647de2..5e963508231 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<dw_offset_t> 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<dw_offset_t> 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 7f4b16e015a..72ac34656fa 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 5c4fba29b49..2fa5a934dd1 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 6d80d77d044..8dca2c5cd93 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<uint32_t> function_indexes; std::vector<uint32_t> static_indexes; - lldb::SharedPtr<lldb_private::SectionList>::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 d560bc3a838..6fc5968d9dd 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. |