[lldb][NFC] Fix all formatting errors in .cpp file headers
Summary:
A *.cpp file header in LLDB (and in LLDB) should like this:
```
//===-- TestUtilities.cpp -------------------------------------------------===//
```
However in LLDB most of our source files have arbitrary changes to this format and
these changes are spreading through LLDB as folks usually just use the existing
source files as templates for their new files (most notably the unnecessary
editor language indicator `-*- C++ -*-` is spreading and in every review
someone is pointing out that this is wrong, resulting in people pointing out that this
is done in the same way in other files).
This patch removes most of these inconsistencies including the editor language indicators,
all the different missing/additional '-' characters, files that center the file name, missing
trailing `===//` (mostly caused by clang-format breaking the line).
Reviewers: aprantl, espindola, jfb, shafik, JDevlieghere
Reviewed By: JDevlieghere
Subscribers: dexonsmith, wuzish, emaste, sdardis, nemanjai, kbarton, MaskRay, atanasyan, arphaman, jfb, abidh, jsji, JDevlieghere, usaxena95, lldb-commits
Tags: #lldb
Differential Revision: https://reviews.llvm.org/D73258
2020-01-24 15:23:27 +08:00
|
|
|
//===-- TestArmv7Disassembly.cpp ------------------------------------------===//
|
2018-09-07 09:28:48 +08:00
|
|
|
|
|
|
|
//
|
2019-01-19 16:50:56 +08:00
|
|
|
// 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
|
2018-09-07 09:28:48 +08:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#include "gtest/gtest.h"
|
|
|
|
|
|
|
|
#include "lldb/Core/Address.h"
|
|
|
|
#include "lldb/Core/Disassembler.h"
|
|
|
|
#include "lldb/Utility/ArchSpec.h"
|
|
|
|
#include "lldb/Target/ExecutionContext.h"
|
|
|
|
|
2020-01-22 07:14:28 +08:00
|
|
|
#include "Plugins/Disassembler/LLVMC/DisassemblerLLVMC.h"
|
2018-09-07 09:28:48 +08:00
|
|
|
#include "llvm/Support/TargetSelect.h"
|
|
|
|
|
|
|
|
using namespace lldb;
|
|
|
|
using namespace lldb_private;
|
|
|
|
|
|
|
|
class TestArmv7Disassembly : public testing::Test {
|
|
|
|
public:
|
|
|
|
static void SetUpTestCase();
|
|
|
|
static void TearDownTestCase();
|
|
|
|
|
|
|
|
// virtual void SetUp() override { }
|
|
|
|
// virtual void TearDown() override { }
|
|
|
|
|
|
|
|
protected:
|
|
|
|
};
|
|
|
|
|
|
|
|
void TestArmv7Disassembly::SetUpTestCase() {
|
|
|
|
llvm::InitializeAllTargets();
|
|
|
|
llvm::InitializeAllAsmPrinters();
|
|
|
|
llvm::InitializeAllTargetMCs();
|
|
|
|
llvm::InitializeAllDisassemblers();
|
|
|
|
DisassemblerLLVMC::Initialize();
|
|
|
|
}
|
|
|
|
|
|
|
|
void TestArmv7Disassembly::TearDownTestCase() {
|
|
|
|
DisassemblerLLVMC::Terminate();
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_F(TestArmv7Disassembly, TestCortexFPDisass) {
|
|
|
|
ArchSpec arch("armv7em--");
|
|
|
|
|
2018-09-11 20:45:22 +08:00
|
|
|
const unsigned num_of_instructions = 3;
|
2018-09-07 09:28:48 +08:00
|
|
|
uint8_t data[] = {
|
|
|
|
0x00, 0xee, 0x10, 0x2a, // 0xee002a10 : vmov s0, r2
|
|
|
|
0xb8, 0xee, 0xc0, 0x0b, // 0xeeb80bc0 : vcvt.f64.s32 d0, s0
|
|
|
|
0xb6, 0xee, 0x00, 0x0a, // 0xeeb60a00 : vmov.f32 s0, #5.000000e-01
|
|
|
|
};
|
|
|
|
|
|
|
|
// these can be disassembled by hand with llvm-mc, e.g.
|
|
|
|
//
|
|
|
|
// 0x00, 0xee, 0x10, 0x2a, // 0xee002a10 : vmov s0, r2
|
|
|
|
//
|
|
|
|
// echo 0x00 0xee 0x10 0x2a | llvm-mc -arch thumb -disassemble -mattr=+fp-armv8
|
|
|
|
// vmov s0, r2
|
|
|
|
|
|
|
|
DisassemblerSP disass_sp;
|
|
|
|
Address start_addr(0x100);
|
|
|
|
disass_sp = Disassembler::DisassembleBytes(arch, nullptr, nullptr, start_addr,
|
|
|
|
&data, sizeof (data), num_of_instructions, false);
|
|
|
|
|
2018-09-13 03:30:03 +08:00
|
|
|
// If we failed to get a disassembler, we can assume it is because
|
|
|
|
// the llvm we linked against was not built with the ARM target,
|
|
|
|
// and we should skip these tests without marking anything as failing.
|
|
|
|
|
2018-09-07 09:28:48 +08:00
|
|
|
if (disass_sp) {
|
|
|
|
const InstructionList inst_list (disass_sp->GetInstructionList());
|
|
|
|
EXPECT_EQ (num_of_instructions, inst_list.GetSize());
|
|
|
|
|
|
|
|
InstructionSP inst_sp;
|
|
|
|
const char *mnemonic;
|
|
|
|
ExecutionContext exe_ctx (nullptr, nullptr, nullptr);
|
|
|
|
inst_sp = inst_list.GetInstructionAtIndex (0);
|
|
|
|
mnemonic = inst_sp->GetMnemonic(&exe_ctx);
|
|
|
|
ASSERT_STREQ ("vmov", mnemonic);
|
|
|
|
|
|
|
|
inst_sp = inst_list.GetInstructionAtIndex (1);
|
|
|
|
mnemonic = inst_sp->GetMnemonic(&exe_ctx);
|
|
|
|
ASSERT_STREQ ("vcvt.f64.s32", mnemonic);
|
|
|
|
|
|
|
|
inst_sp = inst_list.GetInstructionAtIndex (2);
|
|
|
|
mnemonic = inst_sp->GetMnemonic(&exe_ctx);
|
|
|
|
ASSERT_STREQ ("vmov.f32", mnemonic);
|
|
|
|
}
|
|
|
|
}
|