LLVM  8.0.1
Classes | Macros | Enumerations | Functions | Variables
DwarfDebug.cpp File Reference
#include "DwarfDebug.h"
#include "ByteStreamer.h"
#include "DIEHash.h"
#include "DebugLocEntry.h"
#include "DebugLocStream.h"
#include "DwarfCompileUnit.h"
#include "DwarfExpression.h"
#include "DwarfFile.h"
#include "DwarfUnit.h"
#include "llvm/ADT/APInt.h"
#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/DenseSet.h"
#include "llvm/ADT/MapVector.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/ADT/Triple.h"
#include "llvm/ADT/Twine.h"
#include "llvm/BinaryFormat/Dwarf.h"
#include "llvm/CodeGen/AccelTable.h"
#include "llvm/CodeGen/AsmPrinter.h"
#include "llvm/CodeGen/DIE.h"
#include "llvm/CodeGen/LexicalScopes.h"
#include "llvm/CodeGen/MachineBasicBlock.h"
#include "llvm/CodeGen/MachineFunction.h"
#include "llvm/CodeGen/MachineInstr.h"
#include "llvm/CodeGen/MachineModuleInfo.h"
#include "llvm/CodeGen/MachineOperand.h"
#include "llvm/CodeGen/TargetInstrInfo.h"
#include "llvm/CodeGen/TargetRegisterInfo.h"
#include "llvm/CodeGen/TargetSubtargetInfo.h"
#include "llvm/IR/Constants.h"
#include "llvm/IR/DebugInfoMetadata.h"
#include "llvm/IR/DebugLoc.h"
#include "llvm/IR/Function.h"
#include "llvm/IR/GlobalVariable.h"
#include "llvm/IR/Module.h"
#include "llvm/MC/MCAsmInfo.h"
#include "llvm/MC/MCContext.h"
#include "llvm/MC/MCDwarf.h"
#include "llvm/MC/MCSection.h"
#include "llvm/MC/MCStreamer.h"
#include "llvm/MC/MCSymbol.h"
#include "llvm/MC/MCTargetOptions.h"
#include "llvm/MC/MachineLocation.h"
#include "llvm/MC/SectionKind.h"
#include "llvm/Pass.h"
#include "llvm/Support/Casting.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/MD5.h"
#include "llvm/Support/MathExtras.h"
#include "llvm/Support/Timer.h"
#include "llvm/Support/raw_ostream.h"
#include "llvm/Target/TargetLoweringObjectFile.h"
#include "llvm/Target/TargetMachine.h"
#include "llvm/Target/TargetOptions.h"
#include <algorithm>
#include <cassert>
#include <cstddef>
#include <cstdint>
#include <iterator>
#include <string>
#include <utility>
#include <vector>

Go to the source code of this file.

Classes

struct  ArangeSpan
 

Macros

#define DEBUG_TYPE   "dwarfdebug"
 

Enumerations

enum  DefaultOnOff {
  Default, Enable, Disable, Default,
  Enable, Disable
}
 
enum  LinkageNameOption { DefaultLinkageNames, AllLinkageNames, AbstractLinkageNames }
 

Functions

static AccelTableKind computeAccelTableKind (unsigned DwarfVersion, bool GenerateTypeUnits, DebuggerKind Tuning, const Triple &TT)
 
static bool isObjCClass (StringRef Name)
 
static bool hasObjCCategory (StringRef Name)
 
static void getObjCClassCategory (StringRef In, StringRef &Class, StringRef &Category)
 
static StringRef getObjCMethodName (StringRef In)
 
template<typename Func >
static void forBothCUs (DwarfCompileUnit &CU, Func F)
 
static SmallVectorImpl< DwarfCompileUnit::GlobalExpr > & sortGlobalExprs (SmallVectorImpl< DwarfCompileUnit::GlobalExpr > &GVEs)
 Sort and unique GVEs by comparing their fragment offset. More...
 
static DebugLocEntry::Value getDebugLocValue (const MachineInstr *MI)
 
static bool validThroughout (LexicalScopes &LScopes, const MachineInstr *DbgValue, const MachineInstr *RangeEnd)
 Determine whether a singular DBG_VALUE is valid for the entirety of its enclosing lexical scope. More...
 
static DebugLoc findPrologueEndLoc (const MachineFunction *MF)
 
static dwarf::PubIndexEntryDescriptor computeIndexValue (DwarfUnit *CU, const DIE *Die)
 computeIndexValue - Compute the gdb index value for the DIE and CU. More...
 
static void emitDebugLocValue (const AsmPrinter &AP, const DIBasicType *BT, const DebugLocEntry::Value &Value, DwarfExpression &DwarfExpr)
 
static void emitListsTableHeaderStart (AsmPrinter *Asm, const DwarfFile &Holder, MCSymbol *TableStart, MCSymbol *TableEnd)
 
static MCSymbolemitRnglistsTableHeader (AsmPrinter *Asm, const DwarfFile &Holder)
 
static MCSymbolemitLoclistsTableHeader (AsmPrinter *Asm, const DwarfFile &Holder)
 
static void emitRangeList (DwarfDebug &DD, AsmPrinter *Asm, const RangeSpanList &List)
 Emit a single range list. We handle both DWARF v5 and earlier. More...
 
static void emitDebugRangesImpl (DwarfDebug &DD, AsmPrinter *Asm, const DwarfFile &Holder, MCSymbol *TableEnd)
 

Variables

static cl::opt< boolDisableDebugInfoPrinting ("disable-debug-info-print", cl::Hidden, cl::desc("Disable debug info printing"))
 
static cl::opt< boolUseDwarfRangesBaseAddressSpecifier ("use-dwarf-ranges-base-address-specifier", cl::Hidden, cl::desc("Use base address specifiers in debug_ranges"), cl::init(false))
 
static cl::opt< boolGenerateARangeSection ("generate-arange-section", cl::Hidden, cl::desc("Generate dwarf aranges"), cl::init(false))
 
static cl::opt< boolGenerateDwarfTypeUnits ("generate-type-units", cl::Hidden, cl::desc("Generate DWARF4 type units."), cl::init(false))
 
static cl::opt< boolSplitDwarfCrossCuReferences ("split-dwarf-cross-cu-references", cl::Hidden, cl::desc("Enable cross-cu references in DWO files"), cl::init(false))
 
static cl::opt< DefaultOnOffUnknownLocations ("use-unknown-locations", cl::Hidden, cl::desc("Make an absence of debug location information explicit."), cl::values(clEnumVal(Default, "At top of block or after label"), clEnumVal(Enable, "In all cases"), clEnumVal(Disable, "Never")), cl::init(Default))
 
static cl::opt< AccelTableKindAccelTables ("accel-tables", cl::Hidden, cl::desc("Output dwarf accelerator tables."), cl::values(clEnumValN(AccelTableKind::Default, "Default", "Default for platform"), clEnumValN(AccelTableKind::None, "Disable", "Disabled."), clEnumValN(AccelTableKind::Apple, "Apple", "Apple"), clEnumValN(AccelTableKind::Dwarf, "Dwarf", "DWARF")), cl::init(AccelTableKind::Default))
 
static cl::opt< DefaultOnOffDwarfInlinedStrings ("dwarf-inlined-strings", cl::Hidden, cl::desc("Use inlined strings rather than string section."), cl::values(clEnumVal(Default, "Default for platform"), clEnumVal(Enable, "Enabled"), clEnumVal(Disable, "Disabled")), cl::init(Default))
 
static cl::opt< boolNoDwarfRangesSection ("no-dwarf-ranges-section", cl::Hidden, cl::desc("Disable emission .debug_ranges section."), cl::init(false))
 
static cl::opt< DefaultOnOffDwarfSectionsAsReferences ("dwarf-sections-as-references", cl::Hidden, cl::desc("Use sections+offset as references rather than labels."), cl::values(clEnumVal(Default, "Default for platform"), clEnumVal(Enable, "Enabled"), clEnumVal(Disable, "Disabled")), cl::init(Default))
 
static cl::opt< LinkageNameOptionDwarfLinkageNames ("dwarf-linkage-names", cl::Hidden, cl::desc("Which DWARF linkage-name attributes to emit."), cl::values(clEnumValN(DefaultLinkageNames, "Default", "Default for platform"), clEnumValN(AllLinkageNames, "All", "All"), clEnumValN(AbstractLinkageNames, "Abstract", "Abstract subprograms")), cl::init(DefaultLinkageNames))
 
static const char *const DWARFGroupName = "dwarf"
 
static const char *const DWARFGroupDescription = "DWARF Emission"
 
static const char *const DbgTimerName = "writer"
 
static const char *const DbgTimerDescription = "DWARF Debug Writer"
 

Macro Definition Documentation

◆ DEBUG_TYPE

#define DEBUG_TYPE   "dwarfdebug"

Definition at line 83 of file DwarfDebug.cpp.

Enumeration Type Documentation

◆ DefaultOnOff

Enumerator
Default 
Enable 
Disable 
Default 
Enable 
Disable 

Definition at line 107 of file DwarfDebug.cpp.

◆ LinkageNameOption

Enumerator
DefaultLinkageNames 
AllLinkageNames 
AbstractLinkageNames 

Definition at line 145 of file DwarfDebug.cpp.

Function Documentation

◆ computeAccelTableKind()

static AccelTableKind computeAccelTableKind ( unsigned  DwarfVersion,
bool  GenerateTypeUnits,
DebuggerKind  Tuning,
const Triple TT 
)
static

◆ computeIndexValue()

static dwarf::PubIndexEntryDescriptor computeIndexValue ( DwarfUnit CU,
const DIE Die 
)
static

computeIndexValue - Compute the gdb index value for the DIE and CU.

Definition at line 1749 of file DwarfDebug.cpp.

References llvm::DebugHandlerBase::Asm, llvm::AsmPrinter::createTempSymbol(), llvm::dwarf::DW_PUBNAMES_VERSION, llvm::AsmPrinter::EmitDwarfOffset(), llvm::AsmPrinter::emitDwarfSymbolReference(), llvm::AsmPrinter::emitInt16(), llvm::AsmPrinter::emitInt32(), llvm::AsmPrinter::emitInt8(), llvm::AsmPrinter::EmitLabelDifference(), llvm::DwarfFile::emitStrings(), llvm::DIE::findAttribute(), llvm::dwarf::GDBIndexEntryKindString(), llvm::dwarf::GDBIndexEntryLinkageString(), llvm::MCSection::getBeginSymbol(), llvm::DwarfUnit::getCUNode(), llvm::DIEUnit::getDebugSectionOffset(), llvm::MCObjectFileInfo::getDwarfGnuPubNamesSection(), llvm::MCObjectFileInfo::getDwarfGnuPubTypesSection(), llvm::MCObjectFileInfo::getDwarfPubNamesSection(), llvm::MCObjectFileInfo::getDwarfPubTypesSection(), llvm::MCObjectFileInfo::getDwarfStrOffSection(), llvm::MCObjectFileInfo::getDwarfStrSection(), llvm::DwarfCompileUnit::getGlobalNames(), llvm::DwarfCompileUnit::getGlobalTypes(), llvm::DwarfCompileUnit::getLabelBegin(), llvm::DwarfUnit::getLanguage(), llvm::DwarfCompileUnit::getLength(), llvm::DICompileUnit::getNameTableKind(), llvm::AsmPrinter::getObjFileLowering(), llvm::DIE::getOffset(), llvm::DIEUnit::getSection(), llvm::DwarfCompileUnit::getSkeleton(), llvm::DIE::getTag(), llvm::dwarf::GIEK_FUNCTION, llvm::dwarf::GIEK_NONE, llvm::dwarf::GIEK_TYPE, llvm::dwarf::GIEK_VARIABLE, llvm::dwarf::GIEL_EXTERNAL, llvm::dwarf::GIEL_STATIC, llvm::DICompileUnit::GNU, llvm::DwarfCompileUnit::hasDwarfPubSections(), llvm::dwarf::PubIndexEntryDescriptor::Kind, llvm::dwarf::PubIndexEntryDescriptor::Linkage, Name, llvm::AsmPrinter::OutStreamer, llvm::dwarf::PubIndexEntryDescriptor::toBits(), llvm::DwarfDebug::useSectionsAsReferences(), llvm::DwarfDebug::useSegmentedStringOffsetsTable(), and llvm::DwarfDebug::useSplitDwarf().

◆ emitDebugLocValue()

static void emitDebugLocValue ( const AsmPrinter AP,
const DIBasicType BT,
const DebugLocEntry::Value Value,
DwarfExpression DwarfExpr 
)
static

◆ emitDebugRangesImpl()

static void emitDebugRangesImpl ( DwarfDebug DD,
AsmPrinter Asm,
const DwarfFile Holder,
MCSymbol TableEnd 
)
static

Definition at line 2381 of file DwarfDebug.cpp.

References llvm::all_of(), llvm::DebugHandlerBase::Asm, assert(), llvm::dwarf::DW_MACINFO_end_file, llvm::dwarf::DW_MACINFO_start_file, llvm::AsmPrinter::emitInt8(), emitRangeList(), emitRnglistsTableHeader(), llvm::AsmPrinter::EmitULEB128(), llvm::StringRef::empty(), F(), llvm::DwarfUnit::getCUNode(), llvm::DIScope::getDirectory(), llvm::MCObjectFileInfo::getDwarfAbbrevDWOSection(), llvm::MCObjectFileInfo::getDwarfAddrSection(), llvm::MCObjectFileInfo::getDwarfInfoSection(), llvm::MCObjectFileInfo::getDwarfLineDWOSection(), llvm::MCObjectFileInfo::getDwarfMacinfoSection(), llvm::MCObjectFileInfo::getDwarfRangesSection(), llvm::MCObjectFileInfo::getDwarfRnglistsDWOSection(), llvm::MCObjectFileInfo::getDwarfRnglistsSection(), llvm::MCObjectFileInfo::getDwarfStrDWOSection(), llvm::MCObjectFileInfo::getDwarfStrOffDWOSection(), llvm::DwarfDebug::getDwarfVersion(), llvm::DIMacroFile::getElements(), llvm::DIScope::getFile(), llvm::DIMacroFile::getFile(), llvm::DIScope::getFilename(), llvm::DIMacro::getLine(), llvm::DIMacroFile::getLine(), llvm::DIMacroNode::getMacinfoType(), llvm::DwarfCompileUnit::getMacroLabelBegin(), llvm::DwarfUnit::getMD5AsBytes(), llvm::DIMacro::getName(), llvm::AsmPrinter::getObjFileLowering(), llvm::DwarfCompileUnit::getOrCreateSourceID(), llvm::DwarfFile::getRangeLists(), llvm::DwarfCompileUnit::getSkeleton(), llvm::DIScope::getSource(), llvm::DwarfCompileUnit::getUniqueID(), llvm::DIEUnit::getUnitDie(), llvm::DIMacro::getValue(), llvm::DICompileUnit::isDebugDirectivesOnly(), List, llvm_unreachable, llvm::none_of(), llvm::AsmPrinter::OutStreamer, P, llvm::DIEUnit::setSection(), llvm::DwarfDebug::useRangesSection(), llvm::DwarfDebug::useSegmentedStringOffsetsTable(), and llvm::DwarfDebug::useSplitDwarf().

◆ emitListsTableHeaderStart()

static void emitListsTableHeaderStart ( AsmPrinter Asm,
const DwarfFile Holder,
MCSymbol TableStart,
MCSymbol TableEnd 
)
static

◆ emitLoclistsTableHeader()

static MCSymbol* emitLoclistsTableHeader ( AsmPrinter Asm,
const DwarfFile Holder 
)
static

◆ emitRangeList()

static void emitRangeList ( DwarfDebug DD,
AsmPrinter Asm,
const RangeSpanList List 
)
static

◆ emitRnglistsTableHeader()

static MCSymbol* emitRnglistsTableHeader ( AsmPrinter Asm,
const DwarfFile Holder 
)
static

◆ findPrologueEndLoc()

static DebugLoc findPrologueEndLoc ( const MachineFunction MF)
static

Definition at line 1513 of file DwarfDebug.cpp.

References llvm::MachineInstr::FrameSetup, and MI.

Referenced by llvm::DwarfDebug::beginFunctionImpl().

◆ forBothCUs()

template<typename Func >
static void forBothCUs ( DwarfCompileUnit CU,
Func  F 
)
static

◆ getDebugLocValue()

static DebugLocEntry::Value getDebugLocValue ( const MachineInstr MI)
static

◆ getObjCClassCategory()

static void getObjCClassCategory ( StringRef  In,
StringRef Class,
StringRef Category 
)
static

◆ getObjCMethodName()

static StringRef getObjCMethodName ( StringRef  In)
static

◆ hasObjCCategory()

static bool hasObjCCategory ( StringRef  Name)
static

Definition at line 395 of file DwarfDebug.cpp.

References llvm::StringRef::find(), isObjCClass(), and llvm::StringRef::npos.

Referenced by getObjCClassCategory().

◆ isObjCClass()

static bool isObjCClass ( StringRef  Name)
static

◆ sortGlobalExprs()

◆ validThroughout()

static bool validThroughout ( LexicalScopes LScopes,
const MachineInstr DbgValue,
const MachineInstr RangeEnd 
)
static

Variable Documentation

◆ AccelTables

cl::opt<AccelTableKind> AccelTables("accel-tables", cl::Hidden, cl::desc("Output dwarf accelerator tables."), cl::values(clEnumValN(AccelTableKind::Default, "Default", "Default for platform"), clEnumValN(AccelTableKind::None, "Disable", "Disabled."), clEnumValN(AccelTableKind::Apple, "Apple", "Apple"), clEnumValN(AccelTableKind::Dwarf, "Dwarf", "DWARF")), cl::init(AccelTableKind::Default))
static

Referenced by computeAccelTableKind().

◆ DbgTimerDescription

const char* const DbgTimerDescription = "DWARF Debug Writer"
static

Definition at line 164 of file DwarfDebug.cpp.

◆ DbgTimerName

const char* const DbgTimerName = "writer"
static

Definition at line 163 of file DwarfDebug.cpp.

◆ DisableDebugInfoPrinting

cl::opt<bool> DisableDebugInfoPrinting("disable-debug-info-print", cl::Hidden, cl::desc("Disable debug info printing"))
static

◆ DWARFGroupDescription

const char* const DWARFGroupDescription = "DWARF Emission"
static

Definition at line 162 of file DwarfDebug.cpp.

◆ DWARFGroupName

const char* const DWARFGroupName = "dwarf"
static

Definition at line 161 of file DwarfDebug.cpp.

◆ DwarfInlinedStrings

cl::opt<DefaultOnOff> DwarfInlinedStrings("dwarf-inlined-strings", cl::Hidden, cl::desc("Use inlined strings rather than string section."), cl::values(clEnumVal(Default, "Default for platform"), clEnumVal(Enable, "Enabled"), clEnumVal(Disable, "Disabled")), cl::init(Default))
static

◆ DwarfLinkageNames

cl::opt<LinkageNameOption> DwarfLinkageNames("dwarf-linkage-names", cl::Hidden, cl::desc("Which DWARF linkage-name attributes to emit."), cl::values(clEnumValN(DefaultLinkageNames, "Default", "Default for platform"), clEnumValN(AllLinkageNames, "All", "All"), clEnumValN(AbstractLinkageNames, "Abstract", "Abstract subprograms")), cl::init(DefaultLinkageNames))
static

◆ DwarfSectionsAsReferences

cl::opt<DefaultOnOff> DwarfSectionsAsReferences("dwarf-sections-as-references", cl::Hidden, cl::desc("Use sections+offset as references rather than labels."), cl::values(clEnumVal(Default, "Default for platform"), clEnumVal(Enable, "Enabled"), clEnumVal(Disable, "Disabled")), cl::init(Default))
static

◆ GenerateARangeSection

cl::opt<bool> GenerateARangeSection("generate-arange-section", cl::Hidden, cl::desc("Generate dwarf aranges"), cl::init(false))
static

◆ GenerateDwarfTypeUnits

cl::opt<bool> GenerateDwarfTypeUnits("generate-type-units", cl::Hidden, cl::desc("Generate DWARF4 type units."), cl::init(false))
static

◆ NoDwarfRangesSection

cl::opt<bool> NoDwarfRangesSection("no-dwarf-ranges-section", cl::Hidden, cl::desc("Disable emission .debug_ranges section."), cl::init(false))
static

◆ SplitDwarfCrossCuReferences

cl::opt<bool> SplitDwarfCrossCuReferences("split-dwarf-cross-cu-references", cl::Hidden, cl::desc("Enable cross-cu references in DWO files"), cl::init(false))
static

◆ UnknownLocations

cl::opt<DefaultOnOff> UnknownLocations("use-unknown-locations", cl::Hidden, cl::desc("Make an absence of debug location information explicit."), cl::values(clEnumVal(Default, "At top of block or after label"), clEnumVal(Enable, "In all cases"), clEnumVal(Disable, "Never")), cl::init(Default))
static

◆ UseDwarfRangesBaseAddressSpecifier

cl::opt<bool> UseDwarfRangesBaseAddressSpecifier("use-dwarf-ranges-base-address-specifier", cl::Hidden, cl::desc("Use base address specifiers in debug_ranges"), cl::init(false))
static