llvm/llvm/unittests/DebugInfo/DWARF/DWARFDebugLineTest.cpp

//===- DWARFDebugLineTest.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 "DwarfGenerator.h"
#include "DwarfUtils.h"
#include "llvm/DebugInfo/DWARF/DWARFContext.h"
#include "llvm/DebugInfo/DWARF/DWARFDebugLine.h"
#include "llvm/Object/ObjectFile.h"
#include "llvm/Testing/Support/Error.h"
#include "gtest/gtest.h"

// AIX doesn't support the debug_addr section
#ifdef _AIX
#define NO_SUPPORT_DEBUG_ADDR
#endif

usingnamespacellvm;
usingnamespacedwarf;
usingnamespacedwarfgen;
usingnamespaceobject;
usingnamespaceutils;
usingnamespacetesting;

namespace {
struct CommonFixture {};

// Fixtures must derive from "Test", but parameterised fixtures from
// "TestWithParam". It does not seem possible to inherit from both, so we share
// the common state in a separate class, inherited by the two fixture classes.
struct DebugLineBasicFixture : public Test, public CommonFixture {};

struct DebugLineParameterisedFixture
    : public TestWithParam<std::pair<uint16_t, DwarfFormat>>,
      public CommonFixture {};

void checkDefaultPrologue(uint16_t Version, DwarfFormat Format,
                          DWARFDebugLine::Prologue Prologue,
                          uint64_t BodyLength) {}

TEST_F(DebugLineBasicFixture, GetOrParseLineTableAtInvalidOffset) {}

TEST_F(DebugLineBasicFixture, GetOrParseLineTableAtInvalidOffsetAfterData) {}

#ifdef NO_SUPPORT_DEBUG_ADDR
TEST_P(DebugLineParameterisedFixture, DISABLED_PrologueGetLength) {
#else
TEST_P(DebugLineParameterisedFixture, PrologueGetLength) {}

#ifdef NO_SUPPORT_DEBUG_ADDR
TEST_P(DebugLineParameterisedFixture, DISABLED_GetOrParseLineTableValidTable) {
#else
TEST_P(DebugLineParameterisedFixture, GetOrParseLineTableValidTable) {}

#ifdef NO_SUPPORT_DEBUG_ADDR
TEST_P(DebugLineParameterisedFixture, DISABLED_ClearLineValidTable) {
#else
TEST_P(DebugLineParameterisedFixture, ClearLineValidTable) {}

TEST_F(DebugLineBasicFixture, ErrorForReservedLength) {}

struct DebugLineUnsupportedVersionFixture : public TestWithParam<uint16_t>,
                                            public CommonFixture {};

TEST_P(DebugLineUnsupportedVersionFixture, ErrorForUnsupportedVersion) {}

INSTANTIATE_TEST_SUITE_P();

#ifdef NO_SUPPORT_DEBUG_ADDR
TEST_F(DebugLineBasicFixture, DISABLED_ErrorForInvalidV5IncludeDirTable) {
#else
TEST_F(DebugLineBasicFixture, ErrorForInvalidV5IncludeDirTable) {}

#ifdef NO_SUPPORT_DEBUG_ADDR
TEST_P(DebugLineParameterisedFixture, DISABLED_ErrorForTooLargePrologueLength) {
#else
TEST_P(DebugLineParameterisedFixture, ErrorForTooLargePrologueLength) {}

#ifdef NO_SUPPORT_DEBUG_ADDR
TEST_P(DebugLineParameterisedFixture, DISABLED_ErrorForTooShortPrologueLength) {
#else
TEST_P(DebugLineParameterisedFixture, ErrorForTooShortPrologueLength) {}

INSTANTIATE_TEST_SUITE_P();

TEST_F(DebugLineBasicFixture, ErrorForExtendedOpcodeLengthSmallerThanExpected) {}

TEST_F(DebugLineBasicFixture, ErrorForExtendedOpcodeLengthLargerThanExpected) {}

TEST_F(DebugLineBasicFixture, ErrorForUnitLengthTooLarge) {}

TEST_F(DebugLineBasicFixture, ErrorForMismatchedAddressSize) {}

TEST_F(DebugLineBasicFixture,
       ErrorForMismatchedAddressSizeUnsetInitialAddress) {}

TEST_F(DebugLineBasicFixture,
       ErrorForUnsupportedAddressSizeInSetAddressLength) {}

TEST_F(DebugLineBasicFixture, ErrorForAddressSizeGreaterThanByteSize) {}

#ifdef NO_SUPPORT_DEBUG_ADDR
TEST_F(DebugLineBasicFixture,
       DISABLED_ErrorForUnsupportedAddressSizeDefinedInHeader) {
#else
TEST_F(DebugLineBasicFixture, ErrorForUnsupportedAddressSizeDefinedInHeader) {}

TEST_F(DebugLineBasicFixture, CallbackUsedForUnterminatedSequence) {}

struct AdjustAddressFixtureBase : public CommonFixture {};

struct OpIndexFixture : Test, CommonFixture {};

TEST_F(OpIndexFixture, OpIndexAdvance) {}

TEST_F(OpIndexFixture, OpIndexReset) {}

TEST_F(OpIndexFixture, MaxOpsZeroDwarf3) {}

TEST_F(OpIndexFixture, MaxOpsZeroDwarf4) {}

struct LineRangeFixture : TestWithParam<std::tuple<uint8_t, bool>>,
                          AdjustAddressFixtureBase {};

TEST_P(LineRangeFixture, LineRangeProblemsReportedCorrectly) {}

INSTANTIATE_TEST_SUITE_P(); // Test non-zero value (no error).

struct BadMinInstLenFixture : TestWithParam<std::tuple<uint8_t, bool>>,
                              AdjustAddressFixtureBase {};

TEST_P(BadMinInstLenFixture, MinInstLengthProblemsReportedCorrectly) {}

INSTANTIATE_TEST_SUITE_P(); // Test non-zero value (no error).

TEST_F(DebugLineBasicFixture, ParserParsesCorrectly) {}

TEST_F(DebugLineBasicFixture, ParserSkipsCorrectly) {}

TEST_F(DebugLineBasicFixture, ParserAlwaysDoneForEmptySection) {}

TEST_F(DebugLineBasicFixture, ParserMarkedAsDoneForBadLengthWhenParsing) {}

TEST_F(DebugLineBasicFixture, ParserMarkedAsDoneForBadLengthWhenSkipping) {}

TEST_F(DebugLineBasicFixture, ParserReportsFirstErrorInEachTableWhenParsing) {}

TEST_F(DebugLineBasicFixture, ParserReportsNonPrologueProblemsWhenParsing) {}

TEST_F(DebugLineBasicFixture,
       ParserReportsPrologueErrorsInEachTableWhenSkipping) {}

TEST_F(DebugLineBasicFixture, ParserIgnoresNonPrologueErrorsWhenSkipping) {}

#ifdef NO_SUPPORT_DEBUG_ADDR
TEST_F(DebugLineBasicFixture, DISABLED_VerboseOutput) {
#else
TEST_F(DebugLineBasicFixture, VerboseOutput) {}

struct TruncatedPrologueFixture
    : public TestWithParam<
          std::tuple<uint64_t, uint64_t, uint16_t, DwarfFormat, StringRef>>,
      public CommonFixture {};

#ifdef NO_SUPPORT_DEBUG_ADDR
TEST_P(TruncatedPrologueFixture, DISABLED_ErrorForTruncatedPrologue) {
#else
TEST_P(TruncatedPrologueFixture, ErrorForTruncatedPrologue) {}

INSTANTIATE_TEST_SUITE_P();

ValueAndLengths;

struct TruncatedOpcodeFixtureBase : public CommonFixture {};

struct TruncatedStandardOpcodeFixture
    : public TestWithParam<
          std::tuple<uint64_t, uint8_t, ValueAndLengths, StringRef, StringRef>>,
      public TruncatedOpcodeFixtureBase {};

struct TruncatedExtendedOpcodeFixture
    : public TestWithParam<std::tuple<uint64_t, uint64_t, uint8_t,
                                      ValueAndLengths, StringRef, StringRef>>,
      public TruncatedOpcodeFixtureBase {};

TEST_P(TruncatedExtendedOpcodeFixture, ErrorForTruncatedExtendedOpcode) {}

INSTANTIATE_TEST_SUITE_P();

TEST_P(TruncatedStandardOpcodeFixture, ErrorForTruncatedStandardOpcode) {}

INSTANTIATE_TEST_SUITE_P();

#ifdef NO_SUPPORT_DEBUG_ADDR
TEST_F(DebugLineBasicFixture, DISABLED_PrintPathsProperly) {
#else
TEST_F(DebugLineBasicFixture, PrintPathsProperly) {}

} // end anonymous namespace