Cleanup the iOS simulator code.

Fixes include:
- Don't say that "<arch>-apple-ios" is compatible with "<arch>-apple-macosx"
- Fixed DynamicLoaderMacOSXDYLD so specify an architecture that was converted solely from a cputype and subtype, just specify the file + UUID.
- Fixed PlatformiOSSimulator::GetSupportedArchitectureAtIndex() so it returns the correct archs
- Fixed SymbolFileDWARFDebugMap to load .o files correctly by just specifying the architecture without the vendor and OS now that "<arch>-apple-ios" is not compatible with "<arch>-apple-macosx" so we can load .o files correctly for DWARF with debug map
- Fixed the coded in TargetList::CreateTarget() so it does the right thing with an underspecified triple where just the arch is specified.

llvm-svn: 212783
This commit is contained in:
Greg Clayton 2014-07-10 23:33:37 +00:00
parent 675d401a26
commit 3f19ada88e
6 changed files with 60 additions and 58 deletions

View File

@ -849,33 +849,10 @@ ArchSpec::IsEqualTo (const ArchSpec& rhs, bool exact_match) const
return false;
}
bool ios_simulator_compatible = false;
// Check for iOS desktop simulator matches where:
// x86_64-apple-ios is compatible with x86_64-apple-macosx
// i386-apple-ios is compatible with i386-apple-macosx
if (lhs_triple_vendor == llvm::Triple::Apple)
{
const llvm::Triple::ArchType lhs_arch = lhs_triple.getArch();
if (lhs_arch == llvm::Triple::x86_64 ||
lhs_arch == llvm::Triple::x86)
{
if ((lhs_triple_os == llvm::Triple::MacOSX && rhs_triple_os == llvm::Triple::IOS ) ||
(lhs_triple_os == llvm::Triple::IOS && rhs_triple_os == llvm::Triple::MacOSX ))
{
ios_simulator_compatible = true;
}
}
}
// Only fail if both os types are not unknown or if we determined the triples
// match for x86_64 or x86 iOS simulator
if (!ios_simulator_compatible)
{
if (lhs_triple_os != llvm::Triple::UnknownOS &&
rhs_triple_os != llvm::Triple::UnknownOS)
return false;
}
// Only fail if both os types are not unknown
if (lhs_triple_os != llvm::Triple::UnknownOS &&
rhs_triple_os != llvm::Triple::UnknownOS)
return false;
}
const llvm::Triple::EnvironmentType lhs_triple_env = lhs_triple.getEnvironment();

View File

@ -318,6 +318,8 @@ IRExecutionUnit::GetRunnableInfo(Error &error,
mCPU,
mAttrs);
m_failed_lookups.clear();
m_execution_engine_ap.reset(builder.create(target_machine));
if (!m_execution_engine_ap.get())

View File

@ -346,7 +346,7 @@ DynamicLoaderMacOSXDYLD::FindTargetModuleForDYLDImageInfo (DYLDImageInfo &image_
Target &target = m_process->GetTarget();
const ModuleList &target_images = target.GetImages();
ModuleSpec module_spec (image_info.file_spec, image_info.GetArchitecture ());
ModuleSpec module_spec (image_info.file_spec);
module_spec.GetUUID() = image_info.uuid;
ModuleSP module_sp (target_images.FindFirstModule (module_spec));

View File

@ -213,24 +213,27 @@ PlatformiOSSimulator::ResolveExecutable (const FileSpec &exe_file,
ArchSpec platform_arch;
for (uint32_t idx = 0; GetSupportedArchitectureAtIndex (idx, module_spec.GetArchitecture()); ++idx)
{
error = ModuleList::GetSharedModule (module_spec,
exe_module_sp,
NULL,
NULL,
NULL);
// Did we find an executable using one of the
if (error.Success())
// Only match x86 with x86 and x86_64 with x86_64...
if (!exe_arch.IsValid() || exe_arch.GetCore() == module_spec.GetArchitecture().GetCore())
{
if (exe_module_sp && exe_module_sp->GetObjectFile())
break;
else
error.SetErrorToGenericError();
error = ModuleList::GetSharedModule (module_spec,
exe_module_sp,
NULL,
NULL,
NULL);
// Did we find an executable using one of the
if (error.Success())
{
if (exe_module_sp && exe_module_sp->GetObjectFile())
break;
else
error.SetErrorToGenericError();
}
if (idx > 0)
arch_names.PutCString (", ");
arch_names.PutCString (platform_arch.GetArchitectureName());
}
if (idx > 0)
arch_names.PutCString (", ");
arch_names.PutCString (platform_arch.GetArchitectureName());
}
if (error.Fail() || !exe_module_sp)
@ -436,6 +439,7 @@ PlatformiOSSimulator::GetSupportedArchitectureAtIndex (uint32_t idx, ArchSpec &a
{
// 32/64: return "x86_64-apple-macosx" for architecture 1
arch = platform_arch64;
return true;
}
else if (idx == 2 || idx == 3)
{
@ -454,6 +458,7 @@ PlatformiOSSimulator::GetSupportedArchitectureAtIndex (uint32_t idx, ArchSpec &a
{
// This macosx platform supports only 32 bit, so return the *-apple-macosx version
arch = platform_arch;
return true;
}
}
return false;

View File

@ -504,10 +504,16 @@ 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.
ArchSpec oso_arch;
// Only adopt the architecture from the module (not the vendor or OS)
// since .o files for "i386-apple-ios" will historically show up as "i386-apple-macosx"
// due to the lack of a LC_VERSION_MIN_MACOSX or LC_VERSION_MIN_IPHONEOS
// load command...
oso_arch.SetTriple(m_obj_file->GetModule()->GetArchitecture().GetTriple().getArchName().str().c_str());
comp_unit_info->oso_sp->module_sp.reset (new DebugMapModule (obj_file->GetModule(),
GetCompUnitInfoIndex(comp_unit_info),
oso_file,
m_obj_file->GetModule()->GetArchitecture(),
oso_arch,
oso_object ? &oso_object : NULL,
0,
oso_object ? &comp_unit_info->oso_mod_time : NULL));

View File

@ -85,6 +85,7 @@ TargetList::CreateTarget (Debugger &debugger,
ArchSpec platform_arch(arch);
bool prefer_platform_arch = false;
if (user_exe_path && user_exe_path[0])
{
@ -104,7 +105,17 @@ TargetList::CreateTarget (Debugger &debugger,
{
if (platform_arch.IsValid())
{
if (!platform_arch.IsCompatibleMatch(matching_module_spec.GetArchitecture()))
if (platform_arch.IsCompatibleMatch(matching_module_spec.GetArchitecture()))
{
// If the OS or vendor weren't specified, then adopt the module's
// architecture so that the platform matching can be more accurate
if (!platform_arch.TripleOSWasSpecified() || !platform_arch.TripleVendorWasSpecified())
{
prefer_platform_arch = true;
platform_arch = matching_module_spec.GetArchitecture();
}
}
else
{
error.SetErrorStringWithFormat("the specified architecture '%s' is not compatible with '%s' in '%s'",
platform_arch.GetTriple().str().c_str(),
@ -116,6 +127,7 @@ TargetList::CreateTarget (Debugger &debugger,
else
{
// Only one arch and none was specified
prefer_platform_arch = true;
platform_arch = matching_module_spec.GetArchitecture();
}
}
@ -127,19 +139,10 @@ TargetList::CreateTarget (Debugger &debugger,
module_spec.GetArchitecture() = arch;
if (module_specs.FindMatchingModuleSpec(module_spec, matching_module_spec))
{
prefer_platform_arch = true;
platform_arch = matching_module_spec.GetArchitecture();
}
}
// Don't just select the first architecture, we want to let the platform select
// the best architecture first when there are multiple archs.
// else
// {
// // No arch specified, select the first arch
// if (module_specs.GetModuleSpecAtIndex(0, matching_module_spec))
// {
// platform_arch = matching_module_spec.GetArchitecture();
// }
// }
}
}
}
@ -166,9 +169,18 @@ TargetList::CreateTarget (Debugger &debugger,
// current architecture if we have a valid architecture.
platform_sp = debugger.GetPlatformList().GetSelectedPlatform ();
if (arch.IsValid() && !platform_sp->IsCompatibleArchitecture(arch, false, &platform_arch))
if (!prefer_platform_arch && arch.IsValid())
{
platform_sp = Platform::GetPlatformForArchitecture(arch, &platform_arch);
if (!platform_sp->IsCompatibleArchitecture(arch, false, &platform_arch))
platform_sp = Platform::GetPlatformForArchitecture(arch, &platform_arch);
}
else if (platform_arch.IsValid())
{
// if "arch" isn't valid, yet "platform_arch" is, it means we have an executable file with
// a single architecture which should be used
ArchSpec fixed_platform_arch;
if (!platform_sp->IsCompatibleArchitecture(platform_arch, false, &fixed_platform_arch))
platform_sp = Platform::GetPlatformForArchitecture(platform_arch, &fixed_platform_arch);
}
}