From 1fba21778f84f266f7d32153c88e59e1900fbe5b Mon Sep 17 00:00:00 2001 From: Jim Ingham Date: Mon, 25 Jan 2021 14:23:11 -0800 Subject: [PATCH] Follow on to: f05dc40c31d1883b46b8bb60547087db2f4c03e3 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 | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/lldb/source/API/SBDebugger.cpp b/lldb/source/API/SBDebugger.cpp index 65881dc..967ca3b 100644 --- a/lldb/source/API/SBDebugger.cpp +++ b/lldb/source/API/SBDebugger.cpp @@ -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, -- 2.7.4