//=- tools/dsymutil/DebugMap.h - Generic debug map representation -*- 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 // //===----------------------------------------------------------------------===// // /// \file /// /// This file contains the class declaration of the DebugMap /// entity. A DebugMap lists all the object files linked together to /// produce an executable along with the linked address of all the /// atoms used in these object files. /// The DebugMap is an input to the DwarfLinker class that will /// extract the Dwarf debug information from the referenced object /// files and link their usefull debug info together. // //===----------------------------------------------------------------------===// #ifndef LLVM_TOOLS_DSYMUTIL_DEBUGMAP_H #define LLVM_TOOLS_DSYMUTIL_DEBUGMAP_H #include "RelocationMap.h" #include "llvm/ADT/DenseMap.h" #include "llvm/ADT/StringMap.h" #include "llvm/ADT/StringRef.h" #include "llvm/ADT/iterator_range.h" #include "llvm/Object/MachO.h" #include "llvm/Support/Chrono.h" #include "llvm/Support/ErrorOr.h" #include "llvm/Support/YAMLTraits.h" #include "llvm/TargetParser/Triple.h" #include <chrono> #include <cstddef> #include <cstdint> #include <memory> #include <optional> #include <string> #include <utility> #include <vector> namespace llvm { class raw_ostream; namespace dsymutil { class DebugMapObject; /// The DebugMap object stores the list of object files to query for debug /// information along with the mapping between the symbols' addresses in the /// object file to their linked address in the linked binary. /// /// A DebugMap producer could look like this: /// DebugMap *DM = new DebugMap(); /// for (const auto &Obj: LinkedObjects) { /// DebugMapObject &DMO = DM->addDebugMapObject(Obj.getPath()); /// for (const auto &Sym: Obj.getLinkedSymbols()) /// DMO.addSymbol(Sym.getName(), Sym.getObjectFileAddress(), /// Sym.getBinaryAddress()); /// } /// /// A DebugMap consumer can then use the map to link the debug /// information. For example something along the lines of: /// for (const auto &DMO: DM->objects()) { /// auto Obj = createBinary(DMO.getObjectFilename()); /// for (auto &DIE: Obj.getDwarfDIEs()) { /// if (SymbolMapping *Sym = DMO.lookup(DIE.getName())) /// DIE.relocate(Sym->ObjectAddress, Sym->BinaryAddress); /// else /// DIE.discardSubtree(); /// } /// } class DebugMap { … }; /// The DebugMapObject represents one object file described by the DebugMap. It /// contains a list of mappings between addresses in the object file and in the /// linked binary for all the linked atoms in this object file. class DebugMapObject { … }; } // end namespace dsymutil } // end namespace llvm LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::dsymutil::DebugMapObject::YAMLSymbolMapping) namespace llvm { namespace yaml { usingnamespacellvm::dsymutil; template <> struct MappingTraits<std::pair<std::string, SymbolMapping>> { … }; template <> struct MappingTraits<dsymutil::DebugMapObject> { … }; template <> struct SequenceTraits<std::vector<std::unique_ptr<dsymutil::DebugMapObject>>> { … }; template <> struct MappingTraits<dsymutil::DebugMap> { … }; template <> struct MappingTraits<std::unique_ptr<dsymutil::DebugMap>> { … }; } // end namespace yaml } // end namespace llvm #endif // LLVM_TOOLS_DSYMUTIL_DEBUGMAP_H