Follow on to: f05dc40c31d1883b46b8bb60547087db2f4c03e3
authorJim Ingham <jingham@apple.com>
Mon, 25 Jan 2021 22:23:11 +0000 (14:23 -0800)
committerJim Ingham <jingham@apple.com>
Mon, 25 Jan 2021 22:25:51 +0000 (14:25 -0800)
When you pass in a bogus ArchSpec, TargetList.CreateTarget
makes a target with the arch of the executable.  That wasn't the
case with a bogus triple, so this change caused one of the bogus
input data tests to fail.  So check that the ArchSpec is valid
before passing it to CreateTarget.

lldb/source/API/SBDebugger.cpp

index 65881dc..967ca3b 100644 (file)
@@ -808,13 +808,15 @@ SBTarget SBDebugger::CreateTargetWithFileAndArch(const char *filename,
     PlatformSP platform_sp = m_opaque_sp->GetPlatformList().GetSelectedPlatform();
     ArchSpec arch = Platform::GetAugmentedArchSpec(
         platform_sp.get(), arch_cstr);
-    error = m_opaque_sp->GetTargetList().CreateTarget(
-        *m_opaque_sp, filename, arch,
-        add_dependent_modules ? eLoadDependentsYes : eLoadDependentsNo, 
-        platform_sp, target_sp);
+    if (arch.IsValid()) {
+      error = m_opaque_sp->GetTargetList().CreateTarget(
+          *m_opaque_sp, filename, arch,
+          add_dependent_modules ? eLoadDependentsYes : eLoadDependentsNo, 
+          platform_sp, target_sp);
 
-    if (error.Success())
-      sb_target.SetSP(target_sp);
+      if (error.Success())
+        sb_target.SetSP(target_sp);
+    }
   }
 
   LLDB_LOGF(log,