summaryrefslogtreecommitdiffstats
path: root/lldb/source/Core/Module.cpp
diff options
context:
space:
mode:
authorGreg Clayton <gclayton@apple.com>2012-02-26 05:51:37 +0000
committerGreg Clayton <gclayton@apple.com>2012-02-26 05:51:37 +0000
commitb9a01b3990ee0911c560939b8caa282e03b7f42d (patch)
treeda515ffdc0753faf5c08d615a08b30bbaa56dee9 /lldb/source/Core/Module.cpp
parenta640db900abcc49d5390192b2bcbd7760a9c3113 (diff)
downloadbcm5719-llvm-b9a01b3990ee0911c560939b8caa282e03b7f42d.tar.gz
bcm5719-llvm-b9a01b3990ee0911c560939b8caa282e03b7f42d.zip
Made a ModuleSpec class in Module.h which can specify a module using one or
more of the local path, platform path, associated symbol file, UUID, arch, object name and object offset. This allows many of the calls that were GetSharedModule to reduce the number of arguments that were used in a call to these functions. It also allows a module to be created with a ModuleSpec which allows many things to be specified prior to any accessors being called on the Module class itself. I was running into problems when adding support for "target symbol add" where you can specify a stand alone debug info file after debugging has started where I needed to specify the associated symbol file path and if I waited until after construction, the wrong symbol file had already been located. By using the ModuleSpec it allows us to construct a module with as little or as much information as needed and not have to change the parameter list. llvm-svn: 151476
Diffstat (limited to 'lldb/source/Core/Module.cpp')
-rw-r--r--lldb/source/Core/Module.cpp83
1 files changed, 83 insertions, 0 deletions
diff --git a/lldb/source/Core/Module.cpp b/lldb/source/Core/Module.cpp
index 18f07ae9189..f2c32c57ec9 100644
--- a/lldb/source/Core/Module.cpp
+++ b/lldb/source/Core/Module.cpp
@@ -114,6 +114,44 @@ namespace lldb {
#endif
+Module::Module (const ModuleSpec &module_spec) :
+ m_mutex (Mutex::eMutexTypeRecursive),
+ m_mod_time (module_spec.GetFileSpec().GetModificationTime()),
+ m_arch (module_spec.GetArchitecture()),
+ m_uuid (),
+ m_file (module_spec.GetFileSpec()),
+ m_platform_file(module_spec.GetPlatformFileSpec()),
+ m_symfile_spec (module_spec.GetSymbolFileSpec()),
+ m_object_name (module_spec.GetObjectName()),
+ m_object_offset (module_spec.GetObjectOffset()),
+ m_objfile_sp (),
+ m_symfile_ap (),
+ m_ast (),
+ m_did_load_objfile (false),
+ m_did_load_symbol_vendor (false),
+ m_did_parse_uuid (false),
+ m_did_init_ast (false),
+ m_is_dynamic_loader_module (false),
+ m_was_modified (false)
+{
+ // Scope for locker below...
+ {
+ Mutex::Locker locker (GetAllocationModuleCollectionMutex());
+ GetModuleCollection().push_back(this);
+ }
+
+ LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_OBJECT));
+ if (log)
+ log->Printf ("%p Module::Module((%s) '%s/%s%s%s%s')",
+ this,
+ m_arch.GetArchitectureName(),
+ m_file.GetDirectory().AsCString(""),
+ m_file.GetFilename().AsCString(""),
+ m_object_name.IsEmpty() ? "" : "(",
+ m_object_name.IsEmpty() ? "" : m_object_name.AsCString(""),
+ m_object_name.IsEmpty() ? "" : ")");
+}
+
Module::Module(const FileSpec& file_spec,
const ArchSpec& arch,
const ConstString *object_name,
@@ -1073,3 +1111,48 @@ Module::SetLoadAddress (Target &target, lldb::addr_t offset, bool &changed)
return false;
}
+
+bool
+Module::MatchesModuleSpec (const ModuleSpec &module_ref)
+{
+ const UUID &uuid = module_ref.GetUUID();
+
+ if (uuid.IsValid())
+ {
+ // If the UUID matches, then nothing more needs to match...
+ if (uuid == GetUUID())
+ return true;
+ else
+ return false;
+ }
+
+ const FileSpec &file_spec = module_ref.GetFileSpec();
+ if (file_spec)
+ {
+ if (!FileSpec::Equal (file_spec, m_file, file_spec.GetDirectory()))
+ return false;
+ }
+
+ const FileSpec &platform_file_spec = module_ref.GetPlatformFileSpec();
+ if (platform_file_spec)
+ {
+ if (!FileSpec::Equal (platform_file_spec, m_platform_file, platform_file_spec.GetDirectory()))
+ return false;
+ }
+
+ const ArchSpec &arch = module_ref.GetArchitecture();
+ if (arch.IsValid())
+ {
+ if (m_arch != arch)
+ return false;
+ }
+
+ const ConstString &object_name = module_ref.GetObjectName();
+ if (object_name)
+ {
+ if (object_name != GetObjectName())
+ return false;
+ }
+ return true;
+}
+
OpenPOWER on IntegriCloud