[Lldb-commits] [lldb] r212783 - Cleanup the iOS simulator code.
Greg Clayton
gclayton at apple.com
Thu Jul 10 16:33:37 PDT 2014
Author: gclayton
Date: Thu Jul 10 18:33:37 2014
New Revision: 212783
URL: http://llvm.org/viewvc/llvm-project?rev=212783&view=rev
Log:
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.
Modified:
lldb/trunk/source/Core/ArchSpec.cpp
lldb/trunk/source/Expression/IRExecutionUnit.cpp
lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp
lldb/trunk/source/Plugins/Platform/MacOSX/PlatformiOSSimulator.cpp
lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
lldb/trunk/source/Target/TargetList.cpp
Modified: lldb/trunk/source/Core/ArchSpec.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ArchSpec.cpp?rev=212783&r1=212782&r2=212783&view=diff
==============================================================================
--- lldb/trunk/source/Core/ArchSpec.cpp (original)
+++ lldb/trunk/source/Core/ArchSpec.cpp Thu Jul 10 18:33:37 2014
@@ -849,33 +849,10 @@ ArchSpec::IsEqualTo (const ArchSpec& rhs
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();
Modified: lldb/trunk/source/Expression/IRExecutionUnit.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/IRExecutionUnit.cpp?rev=212783&r1=212782&r2=212783&view=diff
==============================================================================
--- lldb/trunk/source/Expression/IRExecutionUnit.cpp (original)
+++ lldb/trunk/source/Expression/IRExecutionUnit.cpp Thu Jul 10 18:33:37 2014
@@ -318,6 +318,8 @@ IRExecutionUnit::GetRunnableInfo(Error &
mCPU,
mAttrs);
+ m_failed_lookups.clear();
+
m_execution_engine_ap.reset(builder.create(target_machine));
if (!m_execution_engine_ap.get())
Modified: lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp?rev=212783&r1=212782&r2=212783&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp (original)
+++ lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp Thu Jul 10 18:33:37 2014
@@ -346,7 +346,7 @@ DynamicLoaderMacOSXDYLD::FindTargetModul
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));
Modified: lldb/trunk/source/Plugins/Platform/MacOSX/PlatformiOSSimulator.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Platform/MacOSX/PlatformiOSSimulator.cpp?rev=212783&r1=212782&r2=212783&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Platform/MacOSX/PlatformiOSSimulator.cpp (original)
+++ lldb/trunk/source/Plugins/Platform/MacOSX/PlatformiOSSimulator.cpp Thu Jul 10 18:33:37 2014
@@ -213,24 +213,27 @@ PlatformiOSSimulator::ResolveExecutable
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::GetSupportedArchit
{
// 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::GetSupportedArchit
{
// This macosx platform supports only 32 bit, so return the *-apple-macosx version
arch = platform_arch;
+ return true;
}
}
return false;
Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp?rev=212783&r1=212782&r2=212783&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp Thu Jul 10 18:33:37 2014
@@ -504,10 +504,16 @@ SymbolFileDWARFDebugMap::GetModuleByComp
// 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));
Modified: lldb/trunk/source/Target/TargetList.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/TargetList.cpp?rev=212783&r1=212782&r2=212783&view=diff
==============================================================================
--- lldb/trunk/source/Target/TargetList.cpp (original)
+++ lldb/trunk/source/Target/TargetList.cpp Thu Jul 10 18:33:37 2014
@@ -85,6 +85,7 @@ TargetList::CreateTarget (Debugger &debu
ArchSpec platform_arch(arch);
+ bool prefer_platform_arch = false;
if (user_exe_path && user_exe_path[0])
{
@@ -104,7 +105,17 @@ TargetList::CreateTarget (Debugger &debu
{
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 &debu
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 &debu
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 &debu
// 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())
+ {
+ if (!platform_sp->IsCompatibleArchitecture(arch, false, &platform_arch))
+ platform_sp = Platform::GetPlatformForArchitecture(arch, &platform_arch);
+ }
+ else if (platform_arch.IsValid())
{
- platform_sp = Platform::GetPlatformForArchitecture(arch, &platform_arch);
+ // 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);
}
}
More information about the lldb-commits
mailing list