Debian Codegraph @

lldb/unittests/ABI/AArch64/ABIAArch64Test.cpp

raw
1 //===-- ABIAArch64Test.cpp ------------------------------------------------===//
2
3 //
4 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
5 // See https://llvm.org/LICENSE.txt for license information.
6 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //
8 //===----------------------------------------------------------------------===//
9
10 #include "Plugins/ABI/AArch64/ABIMacOSX_arm64.h"
11 #include "Plugins/ABI/AArch64/ABISysV_arm64.h"
12 #include "Utility/ARM64_DWARF_Registers.h"
13 #include "Utility/ARM64_ehframe_Registers.h"
14 #include "lldb/Target/DynamicRegisterInfo.h"
15 #include "lldb/Utility/ArchSpec.h"
16 #include "llvm/Support/ManagedStatic.h"
17 #include "llvm/Support/TargetSelect.h"
18 #include "gtest/gtest.h"
19 #include <vector>
20
21 using namespace lldb_private;
22 using namespace lldb;
23
24 class ABIAArch64TestFixture : public testing::TestWithParam<llvm::StringRef> {
25 public:
26 static void SetUpTestCase();
27 static void TearDownTestCase();
28
29 // virtual void SetUp() override { }
30 // virtual void TearDown() override { }
31
32 protected:
33 };
34
35 void ABIAArch64TestFixture::SetUpTestCase() {
36 LLVMInitializeAArch64TargetInfo();
37 LLVMInitializeAArch64TargetMC();
38 ABISysV_arm64::Initialize();
39 ABIMacOSX_arm64::Initialize();
40 }
41
42 void ABIAArch64TestFixture::TearDownTestCase() {
43 ABISysV_arm64::Terminate();
44 ABIMacOSX_arm64::Terminate();
45 llvm::llvm_shutdown();
46 }
47
48 TEST_P(ABIAArch64TestFixture, AugmentRegisterInfo) {
49 ABISP abi_sp = ABI::FindPlugin(ProcessSP(), ArchSpec(GetParam()));
50 ASSERT_TRUE(abi_sp);
51 using Register = DynamicRegisterInfo::Register;
52
53 Register pc;
54 pc.name = ConstString("pc");
55 pc.alt_name = ConstString();
56 pc.set_name = ConstString("GPR");
57 std::vector<Register> regs{pc};
58
59 abi_sp->AugmentRegisterInfo(regs);
60
61 ASSERT_EQ(regs.size(), 1U);
62 Register new_pc = regs[0];
63 EXPECT_EQ(new_pc.name, pc.name);
64 EXPECT_EQ(new_pc.set_name, pc.set_name);
65 EXPECT_EQ(new_pc.regnum_ehframe, arm64_ehframe::pc);
66 EXPECT_EQ(new_pc.regnum_dwarf, arm64_dwarf::pc);
67 }
68
69 INSTANTIATE_TEST_SUITE_P(ABIAArch64Tests, ABIAArch64TestFixture,
70 testing::Values("aarch64-pc-linux",
71 "arm64-apple-macosx"));