1 //===- DWARFAcceleratorTableTest.cpp --------------------------------------===//
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
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"
16 static Error
ExtractDebugNames(StringRef NamesSecData
, StringRef StrSecData
) {
17 DWARFDataExtractor
NamesExtractor(NamesSecData
,
18 /*isLittleEndian=*/true,
20 DataExtractor
StrExtractor(StrSecData
,
21 /*isLittleEndian=*/true,
23 DWARFDebugNames
Table(NamesExtractor
, StrExtractor
);
24 return Table
.extract();
29 TEST(DWARFDebugNames
, ReservedUnitLength
) {
30 static const char NamesSecData
[64] =
31 "\xf0\xff\xff\xff"; // Reserved unit length value
33 ExtractDebugNames(StringRef(NamesSecData
, sizeof(NamesSecData
)),
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
43 ExtractDebugNames(StringRef(NamesSecData
, sizeof(NamesSecData
)),
45 FailedWithMessage("parsing .debug_names header at 0x0: unexpected end of "
46 "data at offset 0x2b while reading [0x28, 0x2c)"));
49 } // end anonymous namespace