summaryrefslogtreecommitdiffstats
path: root/lldb/source/Core/Module.cpp
diff options
context:
space:
mode:
authorGreg Clayton <gclayton@apple.com>2012-02-24 01:59:29 +0000
committerGreg Clayton <gclayton@apple.com>2012-02-24 01:59:29 +0000
commite72dfb321c5977c65f2d95b8b9d250b69a290b6c (patch)
tree1141c7e9afa82b440290a8b2578501deb85fb096 /lldb/source/Core/Module.cpp
parentda970541146d44d426b4306d3692cce19fae9689 (diff)
downloadbcm5719-llvm-e72dfb321c5977c65f2d95b8b9d250b69a290b6c.tar.gz
bcm5719-llvm-e72dfb321c5977c65f2d95b8b9d250b69a290b6c.zip
<rdar://problem/10103468>
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
Diffstat (limited to 'lldb/source/Core/Module.cpp')
-rw-r--r--lldb/source/Core/Module.cpp25
1 files changed, 17 insertions, 8 deletions
diff --git a/lldb/source/Core/Module.cpp b/lldb/source/Core/Module.cpp
index 707b651c194..eb8d35c2188 100644
--- a/lldb/source/Core/Module.cpp
+++ b/lldb/source/Core/Module.cpp
@@ -122,6 +122,7 @@ Module::Module(const FileSpec& file_spec, const lldb::ProcessSP &process_sp, lld
m_uuid (),
m_file (file_spec),
m_platform_file(),
+ m_symfile_spec (),
m_object_name (),
m_object_offset (),
m_objfile_sp (),
@@ -158,7 +159,7 @@ Module::Module(const FileSpec& file_spec, const lldb::ProcessSP &process_sp, lld
if (bytes_read == 512)
{
data_sp.reset (data_ap.release());
- m_objfile_sp = ObjectFile::FindPlugin(this, process_sp, header_addr, data_sp);
+ m_objfile_sp = ObjectFile::FindPlugin(shared_from_this(), process_sp, header_addr, data_sp);
if (m_objfile_sp)
{
// Once we get the object file, update our module with the object file's
@@ -170,13 +171,17 @@ Module::Module(const FileSpec& file_spec, const lldb::ProcessSP &process_sp, lld
}
}
-Module::Module(const FileSpec& file_spec, const ArchSpec& arch, const ConstString *object_name, off_t object_offset) :
+Module::Module(const FileSpec& file_spec,
+ const ArchSpec& arch,
+ const ConstString *object_name,
+ off_t object_offset) :
m_mutex (Mutex::eMutexTypeRecursive),
m_mod_time (file_spec.GetModificationTime()),
m_arch (arch),
m_uuid (),
m_file (file_spec),
m_platform_file(),
+ m_symfile_spec (),
m_object_name (),
m_object_offset (object_offset),
m_objfile_sp (),
@@ -320,10 +325,10 @@ Module::CalculateSymbolContext(SymbolContext* sc)
sc->module_sp = shared_from_this();
}
-Module *
+ModuleSP
Module::CalculateSymbolContextModule ()
{
- return this;
+ return shared_from_this();
}
void
@@ -380,10 +385,10 @@ Module::ResolveSymbolContextForAddress (const Address& so_addr, uint32_t resolve
sc.Clear();
// Get the section from the section/offset address.
- const Section *section = so_addr.GetSection();
+ SectionSP section_sp (so_addr.GetSection());
// Make sure the section matches this module before we try and match anything
- if (section && section->GetModule() == this)
+ if (section_sp && section_sp->GetModule().get() == this)
{
// If the section offset based address resolved itself, then this
// is the right module.
@@ -667,7 +672,7 @@ Module::GetSymbolVendor (bool can_create)
if (obj_file != NULL)
{
Timer scoped_timer(__PRETTY_FUNCTION__, __PRETTY_FUNCTION__);
- m_symfile_ap.reset(SymbolVendor::FindPlugin(this));
+ m_symfile_ap.reset(SymbolVendor::FindPlugin(shared_from_this()));
m_did_load_symbol_vendor = true;
}
}
@@ -890,7 +895,11 @@ Module::GetObjectFile()
Timer scoped_timer(__PRETTY_FUNCTION__,
"Module::GetObjectFile () module = %s", GetFileSpec().GetFilename().AsCString(""));
DataBufferSP file_data_sp;
- m_objfile_sp = ObjectFile::FindPlugin(this, &m_file, m_object_offset, m_file.GetByteSize(), file_data_sp);
+ m_objfile_sp = ObjectFile::FindPlugin (shared_from_this(),
+ &m_file,
+ m_object_offset,
+ m_file.GetByteSize(),
+ file_data_sp);
if (m_objfile_sp)
{
// Once we get the object file, update our module with the object file's
OpenPOWER on IntegriCloud