[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
|
|
|
//===-- BreakpadRecordsTest.cpp -------------------------------------------===//
|
2019-01-18 18:37:04 +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
|
2019-01-18 18:37:04 +08:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#include "Plugins/ObjectFile/Breakpad/BreakpadRecords.h"
|
|
|
|
#include "gtest/gtest.h"
|
|
|
|
|
|
|
|
using namespace lldb_private;
|
|
|
|
using namespace lldb_private::breakpad;
|
|
|
|
|
|
|
|
TEST(Record, classify) {
|
|
|
|
EXPECT_EQ(Record::Module, Record::classify("MODULE"));
|
|
|
|
EXPECT_EQ(Record::Info, Record::classify("INFO"));
|
|
|
|
EXPECT_EQ(Record::File, Record::classify("FILE"));
|
|
|
|
EXPECT_EQ(Record::Func, Record::classify("FUNC"));
|
|
|
|
EXPECT_EQ(Record::Public, Record::classify("PUBLIC"));
|
2019-04-04 21:23:25 +08:00
|
|
|
EXPECT_EQ(Record::StackCFI, Record::classify("STACK CFI"));
|
2019-08-26 19:25:28 +08:00
|
|
|
EXPECT_EQ(Record::StackWin, Record::classify("STACK WIN"));
|
2019-04-04 21:23:25 +08:00
|
|
|
|
|
|
|
// Any obviously incorrect lines will be classified as such.
|
|
|
|
EXPECT_EQ(llvm::None, Record::classify("STACK"));
|
|
|
|
EXPECT_EQ(llvm::None, Record::classify("STACK CODE_ID"));
|
|
|
|
EXPECT_EQ(llvm::None, Record::classify("CODE_ID"));
|
2019-01-18 18:37:04 +08:00
|
|
|
|
|
|
|
// Any line which does not start with a known keyword will be classified as a
|
|
|
|
// line record, as those are the only ones that start without a keyword.
|
|
|
|
EXPECT_EQ(Record::Line, Record::classify("deadbeef"));
|
|
|
|
EXPECT_EQ(Record::Line, Record::classify("12"));
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST(ModuleRecord, parse) {
|
|
|
|
EXPECT_EQ(ModuleRecord(llvm::Triple::Linux, llvm::Triple::x86_64,
|
|
|
|
UUID::fromData("@ABCDEFGHIJKLMNO", 16)),
|
|
|
|
ModuleRecord::parse(
|
2019-04-16 22:51:47 +08:00
|
|
|
"MODULE Linux x86_64 404142434445464748494a4b4c4d4e4f0 a.out"));
|
2019-01-18 18:37:04 +08:00
|
|
|
|
|
|
|
EXPECT_EQ(llvm::None, ModuleRecord::parse("MODULE"));
|
|
|
|
EXPECT_EQ(llvm::None, ModuleRecord::parse("MODULE Linux"));
|
|
|
|
EXPECT_EQ(llvm::None, ModuleRecord::parse("MODULE Linux x86_64"));
|
|
|
|
EXPECT_EQ(llvm::None,
|
|
|
|
ModuleRecord::parse("MODULE Linux x86_64 deadbeefbaadf00d"));
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST(InfoRecord, parse) {
|
|
|
|
EXPECT_EQ(InfoRecord(UUID::fromData("@ABCDEFGHIJKLMNO", 16)),
|
|
|
|
InfoRecord::parse("INFO CODE_ID 404142434445464748494a4b4c4d4e4f"));
|
|
|
|
EXPECT_EQ(InfoRecord(UUID()), InfoRecord::parse("INFO CODE_ID 47 a.exe"));
|
|
|
|
|
|
|
|
EXPECT_EQ(llvm::None, InfoRecord::parse("INFO"));
|
|
|
|
EXPECT_EQ(llvm::None, InfoRecord::parse("INFO CODE_ID"));
|
|
|
|
}
|
|
|
|
|
2019-01-29 23:39:27 +08:00
|
|
|
TEST(FileRecord, parse) {
|
|
|
|
EXPECT_EQ(FileRecord(47, "foo"), FileRecord::parse("FILE 47 foo"));
|
|
|
|
EXPECT_EQ(llvm::None, FileRecord::parse("FILE 47"));
|
|
|
|
EXPECT_EQ(llvm::None, FileRecord::parse("FILE"));
|
|
|
|
EXPECT_EQ(llvm::None, FileRecord::parse(""));
|
|
|
|
}
|
|
|
|
|
2019-01-22 12:56:31 +08:00
|
|
|
TEST(FuncRecord, parse) {
|
|
|
|
EXPECT_EQ(FuncRecord(true, 0x47, 0x7, 0x8, "foo"),
|
|
|
|
FuncRecord::parse("FUNC m 47 7 8 foo"));
|
|
|
|
EXPECT_EQ(FuncRecord(false, 0x47, 0x7, 0x8, "foo"),
|
|
|
|
FuncRecord::parse("FUNC 47 7 8 foo"));
|
|
|
|
|
|
|
|
EXPECT_EQ(llvm::None, FuncRecord::parse("PUBLIC 47 7 8 foo"));
|
|
|
|
EXPECT_EQ(llvm::None, FuncRecord::parse("FUNC 47 7 8"));
|
|
|
|
EXPECT_EQ(llvm::None, FuncRecord::parse("FUNC 47 7"));
|
|
|
|
EXPECT_EQ(llvm::None, FuncRecord::parse("FUNC 47"));
|
|
|
|
EXPECT_EQ(llvm::None, FuncRecord::parse("FUNC m"));
|
|
|
|
EXPECT_EQ(llvm::None, FuncRecord::parse("FUNC"));
|
|
|
|
}
|
|
|
|
|
2019-01-29 23:39:27 +08:00
|
|
|
TEST(LineRecord, parse) {
|
|
|
|
EXPECT_EQ(LineRecord(0x47, 0x74, 47, 74), LineRecord::parse("47 74 47 74"));
|
|
|
|
EXPECT_EQ(llvm::None, LineRecord::parse("47 74 47"));
|
|
|
|
EXPECT_EQ(llvm::None, LineRecord::parse("47 74"));
|
|
|
|
EXPECT_EQ(llvm::None, LineRecord::parse("47"));
|
|
|
|
EXPECT_EQ(llvm::None, LineRecord::parse(""));
|
|
|
|
EXPECT_EQ(llvm::None, LineRecord::parse("FUNC"));
|
|
|
|
}
|
|
|
|
|
2019-01-18 18:37:04 +08:00
|
|
|
TEST(PublicRecord, parse) {
|
|
|
|
EXPECT_EQ(PublicRecord(true, 0x47, 0x8, "foo"),
|
|
|
|
PublicRecord::parse("PUBLIC m 47 8 foo"));
|
|
|
|
EXPECT_EQ(PublicRecord(false, 0x47, 0x8, "foo"),
|
|
|
|
PublicRecord::parse("PUBLIC 47 8 foo"));
|
|
|
|
|
2019-01-22 12:56:31 +08:00
|
|
|
EXPECT_EQ(llvm::None, PublicRecord::parse("FUNC 47 8 foo"));
|
2019-01-18 18:37:04 +08:00
|
|
|
EXPECT_EQ(llvm::None, PublicRecord::parse("PUBLIC 47 8"));
|
|
|
|
EXPECT_EQ(llvm::None, PublicRecord::parse("PUBLIC 47"));
|
|
|
|
EXPECT_EQ(llvm::None, PublicRecord::parse("PUBLIC m"));
|
|
|
|
EXPECT_EQ(llvm::None, PublicRecord::parse("PUBLIC"));
|
|
|
|
}
|
2019-04-09 16:05:11 +08:00
|
|
|
|
|
|
|
TEST(StackCFIRecord, parse) {
|
|
|
|
EXPECT_EQ(StackCFIRecord(0x47, 0x8, ".cfa: $esp 4 + $eip: .cfa 4 - ^"),
|
|
|
|
StackCFIRecord::parse(
|
|
|
|
"STACK CFI INIT 47 8 .cfa: $esp 4 + $eip: .cfa 4 - ^"));
|
|
|
|
|
|
|
|
EXPECT_EQ(StackCFIRecord(0x47, 0x8, ".cfa: $esp 4 +"),
|
|
|
|
StackCFIRecord::parse("STACK CFI INIT 47 8 .cfa: $esp 4 + "));
|
|
|
|
|
|
|
|
EXPECT_EQ(StackCFIRecord(0x47, llvm::None, ".cfa: $esp 4 +"),
|
|
|
|
StackCFIRecord::parse("STACK CFI 47 .cfa: $esp 4 +"));
|
|
|
|
|
|
|
|
// The validity of the register value expressions is not checked
|
|
|
|
EXPECT_EQ(StackCFIRecord(0x47, 0x8, ".cfa: ^ ^ ^"),
|
|
|
|
StackCFIRecord::parse("STACK CFI INIT 47 8 .cfa: ^ ^ ^"));
|
|
|
|
|
|
|
|
EXPECT_EQ(llvm::None, StackCFIRecord::parse("STACK CFI INIT 47"));
|
|
|
|
EXPECT_EQ(llvm::None, StackCFIRecord::parse("STACK CFI INIT"));
|
|
|
|
EXPECT_EQ(llvm::None, StackCFIRecord::parse("STACK CFI"));
|
|
|
|
EXPECT_EQ(llvm::None, StackCFIRecord::parse("STACK"));
|
|
|
|
EXPECT_EQ(llvm::None, StackCFIRecord::parse("FILE 47 foo"));
|
|
|
|
EXPECT_EQ(llvm::None, StackCFIRecord::parse("42 47"));
|
|
|
|
}
|
2019-08-26 19:25:28 +08:00
|
|
|
|
|
|
|
TEST(StackWinRecord, parse) {
|
|
|
|
EXPECT_EQ(
|
|
|
|
StackWinRecord(0x47, 0x8, 3, 4, 5, llvm::StringRef("$eip $esp ^ =")),
|
|
|
|
StackWinRecord::parse("STACK WIN 4 47 8 1 2 3 4 5 6 1 $eip $esp ^ ="));
|
|
|
|
|
|
|
|
EXPECT_EQ(llvm::None, StackWinRecord::parse(
|
|
|
|
"STACK WIN 0 47 8 1 0 0 0 0 0 1 $eip $esp ^ ="));
|
|
|
|
EXPECT_EQ(llvm::None,
|
|
|
|
StackWinRecord::parse("STACK WIN 4 47 8 1 0 0 0 0 0 0 1"));
|
|
|
|
EXPECT_EQ(llvm::None, StackWinRecord::parse(
|
|
|
|
"STACK WIN 3 47 8 1 0 0 0 0 0 1 $eip $esp ^ ="));
|
|
|
|
EXPECT_EQ(llvm::None,
|
|
|
|
StackWinRecord::parse("STACK WIN 3 47 8 1 0 0 0 0 0 0 1"));
|
|
|
|
EXPECT_EQ(llvm::None, StackWinRecord::parse(
|
|
|
|
"STACK WIN 4 47 8 1 0 0 0 0 1 $eip $esp ^ ="));
|
|
|
|
EXPECT_EQ(llvm::None, StackWinRecord::parse("STACK WIN 4 47 8 1 0 0 0 0 0"));
|
|
|
|
EXPECT_EQ(llvm::None, StackWinRecord::parse("STACK WIN 4 47 8 1 0 0 0 0"));
|
|
|
|
EXPECT_EQ(llvm::None, StackWinRecord::parse("STACK WIN 4 47 8 1 0 0 0"));
|
|
|
|
EXPECT_EQ(llvm::None, StackWinRecord::parse("STACK WIN 4 47 8 1 0 0"));
|
|
|
|
EXPECT_EQ(llvm::None, StackWinRecord::parse("STACK WIN 4 47 8 1 0"));
|
|
|
|
EXPECT_EQ(llvm::None, StackWinRecord::parse("STACK WIN 4 47 8 1"));
|
|
|
|
EXPECT_EQ(llvm::None, StackWinRecord::parse("STACK WIN 4 47 8"));
|
|
|
|
EXPECT_EQ(llvm::None, StackWinRecord::parse("STACK WIN 4 47"));
|
|
|
|
EXPECT_EQ(llvm::None, StackWinRecord::parse("STACK WIN 4"));
|
|
|
|
EXPECT_EQ(llvm::None, StackWinRecord::parse("STACK WIN"));
|
|
|
|
EXPECT_EQ(llvm::None, StackWinRecord::parse("STACK"));
|
|
|
|
EXPECT_EQ(llvm::None, StackWinRecord::parse(""));
|
|
|
|
EXPECT_EQ(llvm::None, StackCFIRecord::parse("FILE 47 foo"));
|
|
|
|
EXPECT_EQ(llvm::None, StackCFIRecord::parse("42 47"));
|
|
|
|
}
|