[docs] Fix build-docs.sh
[llvm-project.git] / llvm / unittests / DebugInfo / DWARF / DWARFAcceleratorTableTest.cpp
blob38f3e076ace21310ec15f156445929a3c00b34b7
1 //===- DWARFAcceleratorTableTest.cpp --------------------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
9 #include "llvm/DebugInfo/DWARF/DWARFAcceleratorTable.h"
10 #include "llvm/DebugInfo/DWARF/DWARFContext.h"
11 #include "llvm/Testing/Support/Error.h"
12 #include "gtest/gtest.h"
14 using namespace llvm;
16 static Error ExtractDebugNames(StringRef NamesSecData, StringRef StrSecData) {
17 DWARFDataExtractor NamesExtractor(NamesSecData,
18 /*isLittleEndian=*/true,
19 /*AddrSize=*/4);
20 DataExtractor StrExtractor(StrSecData,
21 /*isLittleEndian=*/true,
22 /*AddrSize=*/4);
23 DWARFDebugNames Table(NamesExtractor, StrExtractor);
24 return Table.extract();
27 namespace {
29 TEST(DWARFDebugNames, ReservedUnitLength) {
30 static const char NamesSecData[64] =
31 "\xf0\xff\xff\xff"; // Reserved unit length value
32 EXPECT_THAT_ERROR(
33 ExtractDebugNames(StringRef(NamesSecData, sizeof(NamesSecData)),
34 StringRef()),
35 FailedWithMessage("parsing .debug_names header at 0x0: unsupported "
36 "reserved unit length of value 0xfffffff0"));
39 TEST(DWARFDebugNames, TooSmallForDWARF64) {
40 // DWARF64 header takes at least 44 bytes.
41 static const char NamesSecData[43] = "\xff\xff\xff\xff"; // DWARF64 mark
42 EXPECT_THAT_ERROR(
43 ExtractDebugNames(StringRef(NamesSecData, sizeof(NamesSecData)),
44 StringRef()),
45 FailedWithMessage("parsing .debug_names header at 0x0: unexpected end of "
46 "data at offset 0x2b while reading [0x28, 0x2c)"));
49 } // end anonymous namespace