@@ -1614,6 +1614,35 @@ static llvm::Optional<StringRef> GetDSYMBundle(Module &module) {
1614
1614
return dsym;
1615
1615
}
1616
1616
1617
+ // / Force parsing of the CUs to extract the SDK info.
1618
+ static std::string GetSDKPathFromDebugInfo (std::string m_description,
1619
+ Module &module ) {
1620
+ XcodeSDK sdk;
1621
+ bool found_public_sdk = false ;
1622
+ bool found_internal_sdk = false ;
1623
+ if (SymbolFile *sym_file = module .GetSymbolFile ())
1624
+ for (unsigned i = 0 ; i < sym_file->GetNumCompileUnits (); ++i)
1625
+ if (auto cu_sp = sym_file->GetCompileUnitAtIndex (i))
1626
+ if (cu_sp->GetLanguage () == lldb::eLanguageTypeSwift) {
1627
+ auto cu_sdk = sym_file->ParseXcodeSDK (*cu_sp);
1628
+ sdk.Merge (cu_sdk);
1629
+ bool is_internal_sdk = cu_sdk.IsAppleInternalSDK ();
1630
+ found_public_sdk |= !is_internal_sdk;
1631
+ found_internal_sdk |= is_internal_sdk;
1632
+ }
1633
+
1634
+ if (found_public_sdk && found_internal_sdk)
1635
+ HEALTH_LOG_PRINTF (" Unsupported mixing of public and internal SDKs in "
1636
+ " '%s'. Mixed use of SDKs indicates use of different "
1637
+ " toolchains, which is not supported." ,
1638
+ module .GetFileSpec ().GetFilename ().GetCString ());
1639
+
1640
+ std::string sdk_path = HostInfo::GetXcodeSDKPath (sdk).str ();
1641
+ LOG_PRINTF (LIBLLDB_LOG_TYPES, " Host SDK path for sdk %s is %s." ,
1642
+ sdk.GetString ().str ().c_str (), sdk_path.c_str ());
1643
+ return sdk_path;
1644
+ }
1645
+
1617
1646
// / Detect whether a Swift module was "imported" by DWARFImporter.
1618
1647
// / All this *really* means is that it couldn't be loaded through any
1619
1648
// / other mechanism.
@@ -1759,30 +1788,7 @@ SwiftASTContext::CreateInstance(lldb::LanguageType language, Module &module,
1759
1788
LOG_PRINTF (LIBLLDB_LOG_TYPES, " Serialized SDK path is %s." ,
1760
1789
serialized_sdk_path.str ().c_str ());
1761
1790
1762
- // Force parsing of the CUs to extract the SDK info.
1763
- XcodeSDK sdk;
1764
- bool found_public_sdk = false ;
1765
- bool found_internal_sdk = false ;
1766
- if (SymbolFile *sym_file = module .GetSymbolFile ())
1767
- for (unsigned i = 0 ; i < sym_file->GetNumCompileUnits (); ++i)
1768
- if (auto cu_sp = sym_file->GetCompileUnitAtIndex (i))
1769
- if (cu_sp->GetLanguage () == lldb::eLanguageTypeSwift) {
1770
- auto cu_sdk = sym_file->ParseXcodeSDK (*cu_sp);
1771
- sdk.Merge (cu_sdk);
1772
- bool is_internal_sdk = cu_sdk.IsAppleInternalSDK ();
1773
- found_public_sdk |= !is_internal_sdk;
1774
- found_internal_sdk |= is_internal_sdk;
1775
- }
1776
-
1777
- if (found_public_sdk && found_internal_sdk)
1778
- HEALTH_LOG_PRINTF (" Unsupported mixing of public and internal SDKs in "
1779
- " '%s'. Mixed use of SDKs indicates use of different "
1780
- " toolchains, which is not supported." ,
1781
- module .GetFileSpec ().GetFilename ().GetCString ());
1782
-
1783
- std::string sdk_path = HostInfo::GetXcodeSDKPath (sdk).str ();
1784
- LOG_PRINTF (LIBLLDB_LOG_TYPES, " Host SDK path for sdk %s is %s." ,
1785
- sdk.GetString ().str ().c_str (), sdk_path.c_str ());
1791
+ std::string sdk_path = GetSDKPathFromDebugInfo (m_description, module );
1786
1792
if (FileSystem::Instance ().Exists (sdk_path)) {
1787
1793
// Note that this is not final. InitializeSearchPathOptions()
1788
1794
// will set the SDK path based on the triple if this fails.
0 commit comments