#include "bolt/Core/DIEBuilder.h"
#include "bolt/Core/BinaryContext.h"
#include "bolt/Core/ParallelUtilities.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/BinaryFormat/Dwarf.h"
#include "llvm/CodeGen/DIE.h"
#include "llvm/DebugInfo/DWARF/DWARFAbbreviationDeclaration.h"
#include "llvm/DebugInfo/DWARF/DWARFDie.h"
#include "llvm/DebugInfo/DWARF/DWARFExpression.h"
#include "llvm/DebugInfo/DWARF/DWARFFormValue.h"
#include "llvm/DebugInfo/DWARF/DWARFTypeUnit.h"
#include "llvm/DebugInfo/DWARF/DWARFUnit.h"
#include "llvm/DebugInfo/DWARF/DWARFUnitIndex.h"
#include "llvm/Support/Casting.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/FileSystem.h"
#include "llvm/Support/LEB128.h"
#include <algorithm>
#include <cstdint>
#include <memory>
#include <mutex>
#include <optional>
#include <unordered_map>
#include <utility>
#include <vector>
#undef DEBUG_TYPE
#define DEBUG_TYPE …
namespace opts {
extern cl::opt<unsigned> Verbosity;
}
namespace llvm {
namespace bolt {
static std::string
getDWOName(llvm::DWARFUnit &CU,
std::unordered_map<std::string, uint32_t> &NameToIndexMap,
std::optional<StringRef> &DwarfOutputPath) { … }
static void addStringHelper(DebugStrOffsetsWriter &StrOffstsWriter,
DebugStrWriter &StrWriter, DIEBuilder &DIEBldr,
DIE &Die, const DWARFUnit &Unit,
DIEValue &DIEAttrInfo, StringRef Str) { … }
std::string DIEBuilder::updateDWONameCompDir(
DebugStrOffsetsWriter &StrOffstsWriter, DebugStrWriter &StrWriter,
DWARFUnit &SkeletonCU, std::optional<StringRef> DwarfOutputPath,
std::optional<StringRef> DWONameToUse) { … }
void DIEBuilder::updateDWONameCompDirForTypes(
DebugStrOffsetsWriter &StrOffstsWriter, DebugStrWriter &StrWriter,
DWARFUnit &Unit, std::optional<StringRef> DwarfOutputPath,
const StringRef DWOName) { … }
void DIEBuilder::updateReferences() { … }
uint32_t DIEBuilder::allocDIE(const DWARFUnit &DU, const DWARFDie &DDie,
BumpPtrAllocator &Alloc, const uint32_t UId) { … }
void DIEBuilder::constructFromUnit(DWARFUnit &DU) { … }
DIEBuilder::DIEBuilder(BinaryContext &BC, DWARFContext *DwarfContext,
DWARF5AcceleratorTable &DebugNamesTable,
DWARFUnit *SkeletonCU)
: … { … }
static unsigned int getCUNum(DWARFContext *DwarfContext, bool IsDWO) { … }
void DIEBuilder::buildTypeUnits(DebugStrOffsetsWriter *StrOffsetWriter,
const bool Init) { … }
void DIEBuilder::buildCompileUnits(const bool Init) { … }
void DIEBuilder::buildCompileUnits(const std::vector<DWARFUnit *> &CUs) { … }
void DIEBuilder::buildDWOUnit(DWARFUnit &U) { … }
DIE *DIEBuilder::constructDIEFast(DWARFDie &DDie, DWARFUnit &U,
uint32_t UnitId) { … }
static DWARFUnit *
getUnitForOffset(DIEBuilder &Builder, DWARFContext &DWCtx,
const uint64_t Offset,
const DWARFAbbreviationDeclaration::AttributeSpec AttrSpec) { … }
uint32_t DIEBuilder::finalizeDIEs(DWARFUnit &CU, DIE &Die,
uint32_t &CurOffset) { … }
void DIEBuilder::finish() { … }
void DIEBuilder::populateDebugNamesTable(
DWARFUnit &CU, const DIE &Die,
std::optional<BOLTDWARF5AccelTableData *> Parent,
uint32_t NumberParentsInChain) { … }
void DIEBuilder::updateDebugNamesTable() { … }
DWARFDie DIEBuilder::resolveDIEReference(
const DWARFAbbreviationDeclaration::AttributeSpec AttrSpec,
const uint64_t RefOffset, DWARFUnit *&RefCU,
DWARFDebugInfoEntry &DwarfDebugInfoEntry) { … }
void DIEBuilder::cloneDieOffsetReferenceAttribute(
DIE &Die, const DWARFUnit &U, const DWARFDie &InputDIE,
const DWARFAbbreviationDeclaration::AttributeSpec AttrSpec, uint64_t Ref) { … }
void DIEBuilder::cloneStringAttribute(
DIE &Die, const DWARFUnit &U,
const DWARFAbbreviationDeclaration::AttributeSpec AttrSpec,
const DWARFFormValue &Val) { … }
bool DIEBuilder::cloneExpression(const DataExtractor &Data,
const DWARFExpression &Expression,
DWARFUnit &U,
SmallVectorImpl<uint8_t> &OutputBuffer,
const CloneExpressionStage &Stage) { … }
void DIEBuilder::cloneBlockAttribute(
DIE &Die, DWARFUnit &U,
const DWARFAbbreviationDeclaration::AttributeSpec AttrSpec,
const DWARFFormValue &Val) { … }
void DIEBuilder::cloneAddressAttribute(
DIE &Die, const DWARFUnit &U,
const DWARFAbbreviationDeclaration::AttributeSpec AttrSpec,
const DWARFFormValue &Val) { … }
void DIEBuilder::cloneRefsigAttribute(
DIE &Die, DWARFAbbreviationDeclaration::AttributeSpec AttrSpec,
const DWARFFormValue &Val) { … }
void DIEBuilder::cloneScalarAttribute(
DIE &Die, const DWARFDie &InputDIE,
const DWARFAbbreviationDeclaration::AttributeSpec AttrSpec,
const DWARFFormValue &Val) { … }
void DIEBuilder::cloneLoclistAttrubute(
DIE &Die, const DWARFDie &InputDIE,
const DWARFAbbreviationDeclaration::AttributeSpec AttrSpec,
const DWARFFormValue &Val) { … }
void DIEBuilder::cloneAttribute(
DIE &Die, const DWARFDie &InputDIE, DWARFUnit &U, const DWARFFormValue &Val,
const DWARFAbbreviationDeclaration::AttributeSpec AttrSpec) { … }
void DIEBuilder::assignAbbrev(DIEAbbrev &Abbrev) { … }
void DIEBuilder::generateAbbrevs() { … }
void DIEBuilder::generateUnitAbbrevs(DIE *Die) { … }
static uint64_t getHash(const DWARFUnit &DU) { … }
void DIEBuilder::registerUnit(DWARFUnit &DU, bool NeedSort) { … }
std::optional<uint32_t> DIEBuilder::getUnitId(const DWARFUnit &DU) { … }
}
}