//===- DWARFAcceleratorTable.h ----------------------------------*- C++ -*-===// // // 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 // //===----------------------------------------------------------------------===// #ifndef LLVM_DEBUGINFO_DWARF_DWARFACCELERATORTABLE_H #define LLVM_DEBUGINFO_DWARF_DWARFACCELERATORTABLE_H #include "llvm/ADT/DenseSet.h" #include "llvm/ADT/SmallString.h" #include "llvm/ADT/SmallVector.h" #include "llvm/BinaryFormat/Dwarf.h" #include "llvm/DebugInfo/DWARF/DWARFDataExtractor.h" #include "llvm/DebugInfo/DWARF/DWARFFormValue.h" #include <cstdint> #include <utility> namespace llvm { class raw_ostream; class ScopedPrinter; /// The accelerator tables are designed to allow efficient random access /// (using a symbol name as a key) into debug info by providing an index of the /// debug info DIEs. This class implements the common functionality of Apple and /// DWARF 5 accelerator tables. /// TODO: Generalize the rest of the AppleAcceleratorTable interface and move it /// to this class. class DWARFAcceleratorTable { … }; /// This implements the Apple accelerator table format, a precursor of the /// DWARF 5 accelerator table format. class AppleAcceleratorTable : public DWARFAcceleratorTable { … }; /// .debug_names section consists of one or more units. Each unit starts with a /// header, which is followed by a list of compilation units, local and foreign /// type units. /// /// These may be followed by an (optional) hash lookup table, which consists of /// an array of buckets and hashes similar to the apple tables above. The only /// difference is that the hashes array is 1-based, and consequently an empty /// bucket is denoted by 0 and not UINT32_MAX. /// /// Next is the name table, which consists of an array of names and array of /// entry offsets. This is different from the apple tables, which store names /// next to the actual entries. /// /// The structure of the entries is described by an abbreviations table, which /// comes after the name table. Unlike the apple tables, which have a uniform /// entry structure described in the header, each .debug_names entry may have /// different index attributes (DW_IDX_???) attached to it. /// /// The last segment consists of a list of entries, which is a 0-terminated list /// referenced by the name table and interpreted with the help of the /// abbreviation table. class DWARFDebugNames : public DWARFAcceleratorTable { … }; /// Calculates the starting offsets for various sections within the /// .debug_names section. namespace dwarf { DWARFDebugNames::DWARFDebugNamesOffsets findDebugNamesOffsets(uint64_t EndOfHeaderOffset, const DWARFDebugNames::Header &Hdr); } /// If `Name` is the name of a templated function that includes template /// parameters, returns a substring of `Name` containing no template /// parameters. /// E.g.: StripTemplateParameters("foo<int>") = "foo". std::optional<StringRef> StripTemplateParameters(StringRef Name); struct ObjCSelectorNames { … }; /// If `Name` is the AT_name of a DIE which refers to an Objective-C selector, /// returns an instance of ObjCSelectorNames. The Selector and ClassName fields /// are guaranteed to be non-empty in the result. std::optional<ObjCSelectorNames> getObjCNamesIfSelector(StringRef Name); } // end namespace llvm #endif // LLVM_DEBUGINFO_DWARF_DWARFACCELERATORTABLE_H