1 //===- DWARFGdbIndex.h ------------------------------------------*- C++ -*-===// 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 //===----------------------------------------------------------------------===// 8 9 #ifndef LLVM_DEBUGINFO_DWARF_DWARFGDBINDEX_H 10 #define LLVM_DEBUGINFO_DWARF_DWARFGDBINDEX_H 11 12 #include "llvm/ADT/SmallVector.h" 13 #include "llvm/ADT/StringRef.h" 14 #include "llvm/Support/DataExtractor.h" 15 #include <cstdint> 16 #include <utility> 17 18 namespace llvm { 19 20 class raw_ostream; 21 22 class DWARFGdbIndex { 23 uint32_t Version; 24 25 uint32_t CuListOffset; 26 uint32_t TuListOffset; 27 uint32_t AddressAreaOffset; 28 uint32_t SymbolTableOffset; 29 uint32_t ConstantPoolOffset; 30 31 struct CompUnitEntry { 32 uint64_t Offset; /// Offset of a CU in the .debug_info section. 33 uint64_t Length; /// Length of that CU. 34 }; 35 SmallVector<CompUnitEntry, 0> CuList; 36 37 struct TypeUnitEntry { 38 uint64_t Offset; 39 uint64_t TypeOffset; 40 uint64_t TypeSignature; 41 }; 42 SmallVector<TypeUnitEntry, 0> TuList; 43 44 struct AddressEntry { 45 uint64_t LowAddress; /// The low address. 46 uint64_t HighAddress; /// The high address. 47 uint32_t CuIndex; /// The CU index. 48 }; 49 SmallVector<AddressEntry, 0> AddressArea; 50 51 struct SymTableEntry { 52 uint32_t NameOffset; /// Offset of the symbol's name in the constant pool. 53 uint32_t VecOffset; /// Offset of the CU vector in the constant pool. 54 }; 55 SmallVector<SymTableEntry, 0> SymbolTable; 56 57 /// Each value is CU index + attributes. 58 SmallVector<std::pair<uint32_t, SmallVector<uint32_t, 0>>, 0> 59 ConstantPoolVectors; 60 61 StringRef ConstantPoolStrings; 62 uint32_t StringPoolOffset; 63 64 void dumpCUList(raw_ostream &OS) const; 65 void dumpTUList(raw_ostream &OS) const; 66 void dumpAddressArea(raw_ostream &OS) const; 67 void dumpSymbolTable(raw_ostream &OS) const; 68 void dumpConstantPool(raw_ostream &OS) const; 69 70 bool parseImpl(DataExtractor Data); 71 72 public: 73 void dump(raw_ostream &OS); 74 void parse(DataExtractor Data); 75 76 bool HasContent = false; 77 bool HasError = false; 78 }; 79 80 } // end namespace llvm 81 82 #endif // LLVM_DEBUGINFO_DWARF_DWARFGDBINDEX_H 83