1 //===-- XcodeSDKModuleTests.cpp -------------------------------------------===// 2 // 3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 // See https://llvm.org/LICENSE.txt for license information. 5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 // 7 //===----------------------------------------------------------------------===// 8 9 #include "Plugins/Platform/MacOSX/PlatformMacOSX.h" 10 #include "Plugins/SymbolFile/DWARF/DWARFCompileUnit.h" 11 #include "Plugins/SymbolFile/DWARF/DWARFDIE.h" 12 #include "Plugins/TypeSystem/Clang/TypeSystemClang.h" 13 #include "TestingSupport/Symbol/YAMLModuleTester.h" 14 #include "lldb/Core/PluginManager.h" 15 #include "gmock/gmock.h" 16 #include "gtest/gtest.h" 17 18 using namespace lldb; 19 using namespace lldb_private; 20 21 #ifdef __APPLE__ 22 namespace { 23 class XcodeSDKModuleTests : public testing::Test { 24 void SetUp() override { 25 HostInfoBase::Initialize(); 26 PlatformMacOSX::Initialize(); 27 } 28 void TearDown() override { 29 PlatformMacOSX::Terminate(); 30 HostInfoBase::Terminate(); 31 } 32 }; 33 } // namespace 34 35 36 TEST_F(XcodeSDKModuleTests, TestModuleGetXcodeSDK) { 37 const char *yamldata = R"( 38 debug_str: 39 - MacOSX10.9.sdk 40 debug_abbrev: 41 - Code: 0x00000001 42 Tag: DW_TAG_compile_unit 43 Children: DW_CHILDREN_no 44 Attributes: 45 - Attribute: DW_AT_language 46 Form: DW_FORM_data2 47 - Attribute: DW_AT_APPLE_sdk 48 Form: DW_FORM_strp 49 debug_info: 50 - Length: 51 TotalLength: 8 52 Version: 2 53 AbbrOffset: 0 54 AddrSize: 8 55 Entries: 56 - AbbrCode: 0x00000001 57 Values: 58 - Value: 0x000000000000000C 59 - Value: 0x0000000000000000 60 - AbbrCode: 0x00000000 61 Values: [] 62 ... 63 )"; 64 65 auto triple = "x86_64-apple-macosx"; 66 YAMLModuleTester t(yamldata, triple); 67 auto module = t.GetModule(); 68 auto dwarf_unit_sp = t.GetDwarfUnit(); 69 auto *dwarf_cu = llvm::cast<DWARFCompileUnit>(dwarf_unit_sp.get()); 70 ASSERT_TRUE((bool)dwarf_cu); 71 ASSERT_TRUE((bool)dwarf_cu->GetSymbolFileDWARF().GetCompUnitForDWARFCompUnit( 72 *dwarf_cu)); 73 XcodeSDK sdk = module->GetXcodeSDK(); 74 ASSERT_EQ(sdk.GetType(), XcodeSDK::Type::MacOSX); 75 } 76 #endif 77