#include "llvm/DebugInfo/DWARF/DWARFDebugLine.h"
#include "llvm/ADT/SmallString.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/BinaryFormat/Dwarf.h"
#include "llvm/DebugInfo/DWARF/DWARFDataExtractor.h"
#include "llvm/DebugInfo/DWARF/DWARFDie.h"
#include "llvm/DebugInfo/DWARF/DWARFFormValue.h"
#include "llvm/Support/Errc.h"
#include "llvm/Support/Format.h"
#include "llvm/Support/FormatVariadic.h"
#include "llvm/Support/raw_ostream.h"
#include <algorithm>
#include <cassert>
#include <cinttypes>
#include <cstdint>
#include <cstdio>
#include <utility>
usingnamespacellvm;
usingnamespacedwarf;
FileLineInfoKind;
namespace {
struct ContentDescriptor { … };
ContentDescriptors;
}
static bool versionIsSupported(uint16_t Version) { … }
void DWARFDebugLine::ContentTypeTracker::trackContentType(
dwarf::LineNumberEntryFormat ContentType) { … }
DWARFDebugLine::Prologue::Prologue() { … }
bool DWARFDebugLine::Prologue::hasFileAtIndex(uint64_t FileIndex) const { … }
std::optional<uint64_t>
DWARFDebugLine::Prologue::getLastValidFileIndex() const { … }
const llvm::DWARFDebugLine::FileNameEntry &
DWARFDebugLine::Prologue::getFileNameEntry(uint64_t Index) const { … }
void DWARFDebugLine::Prologue::clear() { … }
void DWARFDebugLine::Prologue::dump(raw_ostream &OS,
DIDumpOptions DumpOptions) const { … }
static Error
parseV2DirFileTables(const DWARFDataExtractor &DebugLineData,
uint64_t *OffsetPtr,
DWARFDebugLine::ContentTypeTracker &ContentTypes,
std::vector<DWARFFormValue> &IncludeDirectories,
std::vector<DWARFDebugLine::FileNameEntry> &FileNames) { … }
static llvm::Expected<ContentDescriptors>
parseV5EntryFormat(const DWARFDataExtractor &DebugLineData, uint64_t *OffsetPtr,
DWARFDebugLine::ContentTypeTracker *ContentTypes) { … }
static Error
parseV5DirFileTables(const DWARFDataExtractor &DebugLineData,
uint64_t *OffsetPtr, const dwarf::FormParams &FormParams,
const DWARFContext &Ctx, const DWARFUnit *U,
DWARFDebugLine::ContentTypeTracker &ContentTypes,
std::vector<DWARFFormValue> &IncludeDirectories,
std::vector<DWARFDebugLine::FileNameEntry> &FileNames) { … }
uint64_t DWARFDebugLine::Prologue::getLength() const { … }
Error DWARFDebugLine::Prologue::parse(
DWARFDataExtractor DebugLineData, uint64_t *OffsetPtr,
function_ref<void(Error)> RecoverableErrorHandler, const DWARFContext &Ctx,
const DWARFUnit *U) { … }
DWARFDebugLine::Row::Row(bool DefaultIsStmt) { … }
void DWARFDebugLine::Row::postAppend() { … }
void DWARFDebugLine::Row::reset(bool DefaultIsStmt) { … }
void DWARFDebugLine::Row::dumpTableHeader(raw_ostream &OS, unsigned Indent) { … }
void DWARFDebugLine::Row::dump(raw_ostream &OS) const { … }
DWARFDebugLine::Sequence::Sequence() { … }
void DWARFDebugLine::Sequence::reset() { … }
DWARFDebugLine::LineTable::LineTable() { … }
void DWARFDebugLine::LineTable::dump(raw_ostream &OS,
DIDumpOptions DumpOptions) const { … }
void DWARFDebugLine::LineTable::clear() { … }
DWARFDebugLine::ParsingState::ParsingState(
struct LineTable *LT, uint64_t TableOffset,
function_ref<void(Error)> ErrorHandler)
: … { … }
void DWARFDebugLine::ParsingState::resetRowAndSequence() { … }
void DWARFDebugLine::ParsingState::appendRowToMatrix() { … }
const DWARFDebugLine::LineTable *
DWARFDebugLine::getLineTable(uint64_t Offset) const { … }
Expected<const DWARFDebugLine::LineTable *> DWARFDebugLine::getOrParseLineTable(
DWARFDataExtractor &DebugLineData, uint64_t Offset, const DWARFContext &Ctx,
const DWARFUnit *U, function_ref<void(Error)> RecoverableErrorHandler) { … }
void DWARFDebugLine::clearLineTable(uint64_t Offset) { … }
static StringRef getOpcodeName(uint8_t Opcode, uint8_t OpcodeBase) { … }
DWARFDebugLine::ParsingState::AddrOpIndexDelta
DWARFDebugLine::ParsingState::advanceAddrOpIndex(uint64_t OperationAdvance,
uint8_t Opcode,
uint64_t OpcodeOffset) { … }
DWARFDebugLine::ParsingState::OpcodeAdvanceResults
DWARFDebugLine::ParsingState::advanceForOpcode(uint8_t Opcode,
uint64_t OpcodeOffset) { … }
DWARFDebugLine::ParsingState::SpecialOpcodeDelta
DWARFDebugLine::ParsingState::handleSpecialOpcode(uint8_t Opcode,
uint64_t OpcodeOffset) { … }
template <typename T>
static std::optional<T> parseULEB128(DWARFDataExtractor &Data,
DataExtractor::Cursor &Cursor) { … }
Error DWARFDebugLine::LineTable::parse(
DWARFDataExtractor &DebugLineData, uint64_t *OffsetPtr,
const DWARFContext &Ctx, const DWARFUnit *U,
function_ref<void(Error)> RecoverableErrorHandler, raw_ostream *OS,
bool Verbose) { … }
uint32_t DWARFDebugLine::LineTable::findRowInSeq(
const DWARFDebugLine::Sequence &Seq,
object::SectionedAddress Address) const { … }
uint32_t
DWARFDebugLine::LineTable::lookupAddress(object::SectionedAddress Address,
bool *IsApproximateLine) const { … }
uint32_t
DWARFDebugLine::LineTable::lookupAddressImpl(object::SectionedAddress Address,
bool *IsApproximateLine) const { … }
bool DWARFDebugLine::LineTable::lookupAddressRange(
object::SectionedAddress Address, uint64_t Size,
std::vector<uint32_t> &Result) const { … }
bool DWARFDebugLine::LineTable::lookupAddressRangeImpl(
object::SectionedAddress Address, uint64_t Size,
std::vector<uint32_t> &Result) const { … }
std::optional<StringRef>
DWARFDebugLine::LineTable::getSourceByIndex(uint64_t FileIndex,
FileLineInfoKind Kind) const { … }
static bool isPathAbsoluteOnWindowsOrPosix(const Twine &Path) { … }
bool DWARFDebugLine::Prologue::getFileNameByIndex(
uint64_t FileIndex, StringRef CompDir, FileLineInfoKind Kind,
std::string &Result, sys::path::Style Style) const { … }
bool DWARFDebugLine::LineTable::getFileLineInfoForAddress(
object::SectionedAddress Address, bool Approximate, const char *CompDir,
FileLineInfoKind Kind, DILineInfo &Result) const { … }
bool DWARFDebugLine::LineTable::getDirectoryForEntry(
const FileNameEntry &Entry, std::string &Directory) const { … }
static DWARFDebugLine::SectionParser::LineToUnitMap
buildLineToUnitMap(DWARFUnitVector::iterator_range Units) { … }
DWARFDebugLine::SectionParser::SectionParser(
DWARFDataExtractor &Data, const DWARFContext &C,
DWARFUnitVector::iterator_range Units)
: … { … }
bool DWARFDebugLine::Prologue::totalLengthIsValid() const { … }
DWARFDebugLine::LineTable DWARFDebugLine::SectionParser::parseNext(
function_ref<void(Error)> RecoverableErrorHandler,
function_ref<void(Error)> UnrecoverableErrorHandler, raw_ostream *OS,
bool Verbose) { … }
void DWARFDebugLine::SectionParser::skip(
function_ref<void(Error)> RecoverableErrorHandler,
function_ref<void(Error)> UnrecoverableErrorHandler) { … }
DWARFUnit *DWARFDebugLine::SectionParser::prepareToParse(uint64_t Offset) { … }
bool DWARFDebugLine::SectionParser::hasValidVersion(uint64_t Offset) { … }
void DWARFDebugLine::SectionParser::moveToNextTable(uint64_t OldOffset,
const Prologue &P) { … }