Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions lldb/source/Plugins/ABI/AArch64/ABIAArch64.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include "ABIMacOSX_arm64.h"
#include "ABISysV_arm64.h"
#include "Utility/ARM64_DWARF_Registers.h"
#include "Utility/ARM64_ehframe_Registers.h"
#include "lldb/Core/PluginManager.h"
#include "lldb/Target/Process.h"

Expand Down Expand Up @@ -69,9 +70,9 @@ lldb::addr_t ABIAArch64::FixDataAddress(lldb::addr_t pc) {
std::pair<uint32_t, uint32_t>
ABIAArch64::GetEHAndDWARFNums(llvm::StringRef name) {
if (name == "pc")
return {LLDB_INVALID_REGNUM, arm64_dwarf::pc};
return {arm64_ehframe::pc, arm64_dwarf::pc};
if (name == "cpsr")
return {LLDB_INVALID_REGNUM, arm64_dwarf::cpsr};
return {arm64_ehframe::cpsr, arm64_dwarf::cpsr};
return MCBasedABI::GetEHAndDWARFNums(name);
}

Expand Down
68 changes: 68 additions & 0 deletions lldb/unittests/ABI/AArch64/ABIAArch64Test.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
//===-- ABIAArch64Test.cpp ------------------------------------------------===//

//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//

#include "Plugins/ABI/AArch64/ABIMacOSX_arm64.h"
#include "Plugins/ABI/AArch64/ABISysV_arm64.h"
#include "Utility/ARM64_DWARF_Registers.h"
#include "Utility/ARM64_ehframe_Registers.h"
#include "lldb/Target/DynamicRegisterInfo.h"
#include "lldb/Utility/ArchSpec.h"
#include "llvm/Support/ManagedStatic.h"
#include "llvm/Support/TargetSelect.h"
#include "gtest/gtest.h"
#include <vector>

using namespace lldb_private;
using namespace lldb;

class ABIAArch64TestFixture : public testing::TestWithParam<llvm::StringRef> {
public:
static void SetUpTestCase();
static void TearDownTestCase();

// virtual void SetUp() override { }
// virtual void TearDown() override { }

protected:
};

void ABIAArch64TestFixture::SetUpTestCase() {
LLVMInitializeAArch64TargetInfo();
LLVMInitializeAArch64TargetMC();
ABISysV_arm64::Initialize();
ABIMacOSX_arm64::Initialize();
}

void ABIAArch64TestFixture::TearDownTestCase() {
ABISysV_arm64::Terminate();
ABIMacOSX_arm64::Terminate();
llvm::llvm_shutdown();
}

TEST_P(ABIAArch64TestFixture, AugmentRegisterInfo) {
ABISP abi_sp = ABI::FindPlugin(ProcessSP(), ArchSpec(GetParam()));
ASSERT_TRUE(abi_sp);
using Register = DynamicRegisterInfo::Register;

Register pc{ConstString("pc"), ConstString(), ConstString("GPR")};
std::vector<Register> regs{pc};

abi_sp->AugmentRegisterInfo(regs);

ASSERT_EQ(regs.size(), 1);
Register new_pc = regs[0];
EXPECT_EQ(new_pc.name, pc.name);
EXPECT_EQ(new_pc.set_name, pc.set_name);
EXPECT_EQ(new_pc.regnum_ehframe, arm64_ehframe::pc);
EXPECT_EQ(new_pc.regnum_dwarf, arm64_dwarf::pc);
}

INSTANTIATE_TEST_SUITE_P(ABIAArch64Tests, ABIAArch64TestFixture,
testing::Values("aarch64-pc-linux",
"arm64-apple-macosx"));
9 changes: 9 additions & 0 deletions lldb/unittests/ABI/AArch64/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
add_lldb_unittest(ABIAArch64Tests
ABIAArch64Test.cpp
LINK_COMPONENTS
Support
AArch64
LINK_LIBS
lldbTarget
lldbPluginABIAArch64
)
3 changes: 3 additions & 0 deletions lldb/unittests/ABI/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
if ("AArch64" IN_LIST LLVM_TARGETS_TO_BUILD)
add_subdirectory(AArch64)
endif()
1 change: 1 addition & 0 deletions lldb/unittests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ if (NOT CMAKE_SYSTEM_NAME MATCHES "Windows")
add_subdirectory(API)
add_subdirectory(DAP)
endif()
add_subdirectory(ABI)
add_subdirectory(Breakpoint)
add_subdirectory(Callback)
add_subdirectory(Core)
Expand Down
Loading