From e72dfb321c5977c65f2d95b8b9d250b69a290b6c Mon Sep 17 00:00:00 2001 From: Greg Clayton Date: Fri, 24 Feb 2012 01:59:29 +0000 Subject: I started work on being able to add symbol files after a debug session had started with a new "target symfile add" command and quickly ran into problems with stale Address objects in breakpoint locations that had lldb_private::Section pointers into modules that had been removed or replaced. This also let to grabbing stale modules from those sections. So I needed to thread harded the Address, Section and related objects. To do this I modified the ModuleChild class to now require a ModuleSP on initialization so that a weak reference can created. I also changed all places that were handing out "Section *" to have them hand out SectionSP. All ObjectFile, SymbolFile and SymbolVendors were inheriting from ModuleChild so all of the find plug-in, static creation function and constructors now require ModuleSP references instead of Module *. Address objects now have weak references to their sections which can safely go stale when a module gets destructed. This checkin doesn't complete the "target symfile add" command, but it does get us a lot clioser to being able to do such things without a high risk of crashing or memory corruption. llvm-svn: 151336 --- .../Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) (limited to 'lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp') diff --git a/lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp b/lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp index 7d8dc04..692e24b 100644 --- a/lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp +++ b/lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp @@ -145,11 +145,11 @@ ObjectFilePECOFF::GetPluginDescriptionStatic() ObjectFile * -ObjectFilePECOFF::CreateInstance (Module* module, DataBufferSP& dataSP, const FileSpec* file, addr_t offset, addr_t length) +ObjectFilePECOFF::CreateInstance (const lldb::ModuleSP &module_sp, DataBufferSP& dataSP, const FileSpec* file, addr_t offset, addr_t length) { if (ObjectFilePECOFF::MagicBytesMatch(dataSP)) { - std::auto_ptr objfile_ap(new ObjectFilePECOFF (module, dataSP, file, offset, length)); + std::auto_ptr objfile_ap(new ObjectFilePECOFF (module_sp, dataSP, file, offset, length)); if (objfile_ap.get() && objfile_ap->ParseHeader()) return objfile_ap.release(); } @@ -157,7 +157,7 @@ ObjectFilePECOFF::CreateInstance (Module* module, DataBufferSP& dataSP, const Fi } ObjectFile * -ObjectFilePECOFF::CreateMemoryInstance (lldb_private::Module* module, +ObjectFilePECOFF::CreateMemoryInstance (const lldb::ModuleSP &module_sp, lldb::DataBufferSP& data_sp, const lldb::ProcessSP &process_sp, lldb::addr_t header_addr) @@ -175,12 +175,12 @@ ObjectFilePECOFF::MagicBytesMatch (DataBufferSP& dataSP) } -ObjectFilePECOFF::ObjectFilePECOFF (Module* module, +ObjectFilePECOFF::ObjectFilePECOFF (const lldb::ModuleSP &module_sp, DataBufferSP& dataSP, const FileSpec* file, addr_t offset, addr_t length) : - ObjectFile (module, file, offset, length, dataSP), + ObjectFile (module_sp, file, offset, length, dataSP), m_mutex (Mutex::eMutexTypeRecursive), m_dos_header (), m_coff_header (), @@ -537,7 +537,7 @@ ObjectFilePECOFF::GetSymtab() symbol.type = symtab_data.GetU16 (&offset); symbol.storage = symtab_data.GetU8 (&offset); symbol.naux = symtab_data.GetU8 (&offset); - Address symbol_addr(sect_list->GetSectionAtIndex(symbol.sect-1).get(), symbol.value); + Address symbol_addr(sect_list->GetSectionAtIndex(symbol.sect-1), symbol.value); symbols[i].GetMangled ().SetValue (symbol_name.c_str(), symbol_name[0]=='_' && symbol_name[1] == 'Z'); symbols[i].SetValue(symbol_addr); @@ -559,7 +559,7 @@ ObjectFilePECOFF::GetSectionList() { m_sections_ap.reset(new SectionList()); const uint32_t nsects = m_sect_headers.size(); - Module *module = GetModule(); + ModuleSP module_sp (GetModule()); for (uint32_t idx = 0; idx