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
This commit is contained in:
Greg Clayton
2012-02-26 05:51:37 +00:00
parent a640db900a
commit b9a01b3990
27 changed files with 576 additions and 565 deletions

View File

@@ -1627,22 +1627,17 @@ SBTarget::AddModule (const char *path,
TargetSP target_sp(GetSP());
if (target_sp)
{
FileSpec module_file_spec;
UUID module_uuid;
ArchSpec module_arch;
ModuleSpec module_spec;
if (path)
module_file_spec.SetFile(path, false);
module_spec.GetFileSpec().SetFile(path, false);
if (uuid_cstr)
module_uuid.SetfromCString(uuid_cstr);
module_spec.GetUUID().SetfromCString(uuid_cstr);
if (triple)
module_arch.SetTriple (triple, target_sp->GetPlatform ().get());
module_spec.GetArchitecture().SetTriple (triple, target_sp->GetPlatform ().get());
sb_module.SetSP(target_sp->GetSharedModule (module_file_spec,
module_arch,
uuid_cstr ? &module_uuid : NULL));
sb_module.SetSP(target_sp->GetSharedModule (module_spec));
}
return sb_module;
}
@@ -1697,8 +1692,9 @@ SBTarget::FindModule (const SBFileSpec &sb_file_spec)
TargetSP target_sp(GetSP());
if (target_sp && sb_file_spec.IsValid())
{
ModuleSpec module_spec(*sb_file_spec);
// The module list is thread safe, no need to lock
sb_module.SetSP (target_sp->GetImages().FindFirstModuleForFileSpec (*sb_file_spec, NULL, NULL));
sb_module.SetSP (target_sp->GetImages().FindFirstModule (module_spec));
}
return sb_module;
}