#include "llvm-dwarfdump.h"
#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/DenseSet.h"
#include "llvm/ADT/StringSet.h"
#include "llvm/DebugInfo/DWARF/DWARFContext.h"
#include "llvm/DebugInfo/DWARF/DWARFDebugLoc.h"
#include "llvm/DebugInfo/DWARF/DWARFExpression.h"
#include "llvm/Object/ObjectFile.h"
#include "llvm/Support/JSON.h"
#define DEBUG_TYPE …
usingnamespacellvm;
usingnamespacellvm::dwarfdump;
usingnamespacellvm::object;
namespace {
constexpr int NumOfCoverageCategories = …;
constexpr unsigned ZeroCoverageBucket = …;
constexpr uint64_t OverflowValue = …;
AbstractOriginVarsTy;
AbstractOriginVarsTyMap;
FunctionsWithAbstractOriginTy;
struct SaturatingUINT64 { … };
struct DIELocation { … };
CrossCUReferencingDIELocationTy;
FunctionDIECUTyMap;
struct PerFunctionStats { … };
struct GlobalStats { … };
struct LocationStats { … };
struct LineStats { … };
}
static void collectLocStats(uint64_t ScopeBytesCovered, uint64_t BytesInScope,
std::vector<SaturatingUINT64> &VarParamLocStats,
std::vector<SaturatingUINT64> &ParamLocStats,
std::vector<SaturatingUINT64> &LocalVarLocStats,
bool IsParam, bool IsLocalVar) { … }
static std::string constructDieID(DWARFDie Die,
StringRef Prefix = StringRef()) { … }
static uint64_t calculateOverlap(DWARFAddressRange A, DWARFAddressRange B) { … }
static void collectStatsForDie(DWARFDie Die, const std::string &FnPrefix,
const std::string &VarPrefix,
uint64_t BytesInScope, uint32_t InlineDepth,
StringMap<PerFunctionStats> &FnStatMap,
GlobalStats &GlobalStats,
LocationStats &LocStats,
AbstractOriginVarsTy *AbstractOriginVariables) { … }
static void collectAbstractOriginFnInfo(
DWARFDie Die, uint64_t SPOffset,
AbstractOriginVarsTyMap &GlobalAbstractOriginFnInfo,
AbstractOriginVarsTyMap &LocalAbstractOriginFnInfo) { … }
static void collectStatsRecursive(
DWARFDie Die, std::string FnPrefix, std::string VarPrefix,
uint64_t BytesInScope, uint32_t InlineDepth,
StringMap<PerFunctionStats> &FnStatMap, GlobalStats &GlobalStats,
LocationStats &LocStats, FunctionDIECUTyMap &AbstractOriginFnCUs,
AbstractOriginVarsTyMap &GlobalAbstractOriginFnInfo,
AbstractOriginVarsTyMap &LocalAbstractOriginFnInfo,
FunctionsWithAbstractOriginTy &FnsWithAbstractOriginToBeProcessed,
AbstractOriginVarsTy *AbstractOriginVarsPtr = nullptr) { … }
static void printDatum(json::OStream &J, const char *Key, json::Value Value) { … }
static void printLocationStats(json::OStream &J, const char *Key,
std::vector<SaturatingUINT64> &LocationStats) { … }
static void printSectionSizes(json::OStream &J, const SectionSizes &Sizes) { … }
static void updateVarsWithAbstractOriginLocCovInfo(
DWARFDie FnDieWithAbstractOrigin,
AbstractOriginVarsTy &AbstractOriginVars) { … }
static void collectZeroLocCovForVarsWithAbstractOrigin(
DWARFUnit *DwUnit, GlobalStats &GlobalStats, LocationStats &LocStats,
AbstractOriginVarsTyMap &LocalAbstractOriginFnInfo,
FunctionsWithAbstractOriginTy &FnsWithAbstractOriginToBeProcessed) { … }
static void collectZeroLocCovForVarsWithCrossCUReferencingAbstractOrigin(
LocationStats &LocStats, FunctionDIECUTyMap AbstractOriginFnCUs,
AbstractOriginVarsTyMap &GlobalAbstractOriginFnInfo,
CrossCUReferencingDIELocationTy &CrossCUReferencesToBeResolved) { … }
bool dwarfdump::collectStatsForObjectFile(ObjectFile &Obj, DWARFContext &DICtx,
const Twine &Filename,
raw_ostream &OS) { … }