LLVM 20.0.0git
|
#include "DwarfDebug.h"
#include "ByteStreamer.h"
#include "DIEHash.h"
#include "DwarfCompileUnit.h"
#include "DwarfExpression.h"
#include "DwarfUnit.h"
#include "llvm/ADT/APInt.h"
#include "llvm/ADT/Statistic.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/ADT/Twine.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/MachineModuleInfo.h"
#include "llvm/CodeGen/MachineOperand.h"
#include "llvm/CodeGen/TargetInstrInfo.h"
#include "llvm/CodeGen/TargetLowering.h"
#include "llvm/CodeGen/TargetRegisterInfo.h"
#include "llvm/CodeGen/TargetSubtargetInfo.h"
#include "llvm/DebugInfo/DWARF/DWARFDataExtractor.h"
#include "llvm/DebugInfo/DWARF/DWARFExpression.h"
#include "llvm/IR/Constants.h"
#include "llvm/IR/DebugInfoMetadata.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/MCSection.h"
#include "llvm/MC/MCStreamer.h"
#include "llvm/MC/MCSymbol.h"
#include "llvm/MC/MCTargetOptions.h"
#include "llvm/MC/MachineLocation.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/raw_ostream.h"
#include "llvm/Target/TargetLoweringObjectFile.h"
#include "llvm/Target/TargetMachine.h"
#include "llvm/TargetParser/Triple.h"
#include <algorithm>
#include <cstddef>
#include <iterator>
#include <optional>
#include <string>
#include "llvm/BinaryFormat/Dwarf.def"
Go to the source code of this file.
Classes | |
struct | FwdRegParamInfo |
Represents a parameter whose call site value can be described by applying a debug expression to a register in the forwarded register worklist. More... | |
struct | ArangeSpan |
Macros | |
#define | DEBUG_TYPE "dwarfdebug" |
#define | HANDLE_MACRO_FLAG(ID, NAME) MACRO_FLAG_##NAME = ID, |
Typedefs | |
using | FwdRegWorklist = MapVector< uint64_t, SmallVector< FwdRegParamInfo, 2 > > |
Register worklist for finding call site values. | |
using | ClobberedRegSet = SmallSet< Register, 16 > |
Container for the set of registers known to be clobbered on the path to a call site. | |
Enumerations | |
enum | DefaultOnOff { Default , Enable , Disable } |
enum | LinkageNameOption { DefaultLinkageNames , AllLinkageNames , AbstractLinkageNames } |
Functions | |
STATISTIC (NumCSParams, "Number of dbg call site params created") | |
static DbgValueLoc | getDebugLocValue (const MachineInstr *MI) |
Get .debug_loc entry for the instruction range starting at MI. | |
static uint64_t | getFragmentOffsetInBits (const DIExpression &Expr) |
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 const DIExpression * | combineDIExpressions (const DIExpression *Original, const DIExpression *Addition) |
Append the expression Addition to Original and return the result. | |
template<typename ValT > | |
static void | finishCallSiteParams (ValT Val, const DIExpression *Expr, ArrayRef< FwdRegParamInfo > DescribedParams, ParamSet &Params) |
Emit call site parameter entries that are described by the given value and debug expression. | |
static void | addToFwdRegWorklist (FwdRegWorklist &Worklist, unsigned Reg, const DIExpression *Expr, ArrayRef< FwdRegParamInfo > ParamsToAdd) |
Add Reg to the worklist, if it's not already present, and mark that the given parameter registers' values can (potentially) be described using that register and an debug expression. | |
static void | interpretValues (const MachineInstr *CurMI, FwdRegWorklist &ForwardedRegWorklist, ParamSet &Params, ClobberedRegSet &ClobberedRegUnits) |
Interpret values loaded into registers by CurMI . | |
static bool | interpretNextInstr (const MachineInstr *CurMI, FwdRegWorklist &ForwardedRegWorklist, ParamSet &Params, ClobberedRegSet &ClobberedRegUnits) |
static void | collectCallSiteParameters (const MachineInstr *CallMI, ParamSet &Params) |
Try to interpret values loaded into registers that forward parameters for CallMI . | |
static SmallVectorImpl< DwarfCompileUnit::GlobalExpr > & | sortGlobalExprs (SmallVectorImpl< DwarfCompileUnit::GlobalExpr > &GVEs) |
Sort and unique GVEs by comparing their fragment offset. | |
static const DILocalScope * | getRetainedNodeScope (const MDNode *N) |
static bool | validThroughout (LexicalScopes &LScopes, const MachineInstr *DbgValue, const MachineInstr *RangeEnd, const InstructionOrdering &Ordering) |
Determine whether a singular DBG_VALUE is valid for the entirety of its enclosing lexical scope. | |
static std::pair< const MachineInstr *, bool > | findPrologueEndLoc (const MachineFunction *MF) |
static void | recordSourceLine (AsmPrinter &Asm, unsigned Line, unsigned Col, const MDNode *S, unsigned Flags, unsigned CUID, uint16_t DwarfVersion, ArrayRef< std::unique_ptr< DwarfCompileUnit > > DCUs) |
Register a source line with debug info. | |
static dwarf::PubIndexEntryDescriptor | computeIndexValue (DwarfUnit *CU, const DIE *Die) |
computeIndexValue - Compute the gdb index value for the DIE and CU. | |
static MCSymbol * | emitRnglistsTableHeader (AsmPrinter *Asm, const DwarfFile &Holder) |
static MCSymbol * | emitLoclistsTableHeader (AsmPrinter *Asm, const DwarfDebug &DD) |
template<typename Ranges , typename PayloadEmitter > | |
static void | emitRangeList (DwarfDebug &DD, AsmPrinter *Asm, MCSymbol *Sym, const Ranges &R, const DwarfCompileUnit &CU, unsigned BaseAddressx, unsigned OffsetPair, unsigned StartxLength, unsigned EndOfList, StringRef(*StringifyEnum)(unsigned), bool ShouldUseBaseAddress, PayloadEmitter EmitPayload) |
static void | emitLocList (DwarfDebug &DD, AsmPrinter *Asm, const DebugLocStream::List &List) |
static void | emitRangeList (DwarfDebug &DD, AsmPrinter *Asm, const RangeSpanList &List) |
Emit a single range list. We handle both DWARF v5 and earlier. | |
static void | emitMacroHeader (AsmPrinter *Asm, const DwarfDebug &DD, const DwarfCompileUnit &CU, uint16_t DwarfVersion) |
Emit the header of a DWARF 5 macro section, or the GNU extension for DWARF 4. | |
Variables | |
static 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 cl::opt< bool > | GenerateARangeSection ("generate-arange-section", cl::Hidden, cl::desc("Generate dwarf aranges"), cl::init(false)) |
static cl::opt< bool > | GenerateDwarfTypeUnits ("generate-type-units", cl::Hidden, cl::desc("Generate DWARF4 type units."), cl::init(false)) |
static cl::opt< bool > | SplitDwarfCrossCuReferences ("split-dwarf-cross-cu-references", cl::Hidden, cl::desc("Enable cross-cu references in DWO files"), cl::init(false)) |
static 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 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 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 cl::opt< bool > | NoDwarfRangesSection ("no-dwarf-ranges-section", cl::Hidden, cl::desc("Disable emission .debug_ranges section."), cl::init(false)) |
static 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 cl::opt< bool > | UseGNUDebugMacro ("use-gnu-debug-macro", cl::Hidden, cl::desc("Emit the GNU .debug_macro format with DWARF <5"), cl::init(false)) |
static cl::opt< DefaultOnOff > | DwarfOpConvert ("dwarf-op-convert", cl::Hidden, cl::desc("Enable use of the DWARFv5 DW_OP_convert operator"), cl::values(clEnumVal(Default, "Default for platform"), clEnumVal(Enable, "Enabled"), clEnumVal(Disable, "Disabled")), cl::init(Default)) |
static 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 cl::opt< DwarfDebug::MinimizeAddrInV5 > | MinimizeAddrInV5Option ("minimize-addr-in-v5", cl::Hidden, cl::desc("Always use DW_AT_ranges in DWARFv5 whenever it could allow more " "address pool entry sharing to reduce relocations/object size"), cl::values(clEnumValN(DwarfDebug::MinimizeAddrInV5::Default, "Default", "Default address minimization strategy"), clEnumValN(DwarfDebug::MinimizeAddrInV5::Ranges, "Ranges", "Use rnglists for contiguous ranges if that allows " "using a pre-existing base address"), clEnumValN(DwarfDebug::MinimizeAddrInV5::Expressions, "Expressions", "Use exprloc addrx+offset expressions for any " "address with a prior base address"), clEnumValN(DwarfDebug::MinimizeAddrInV5::Form, "Form", "Use addrx+offset extension form for any address " "with a prior base address"), clEnumValN(DwarfDebug::MinimizeAddrInV5::Disabled, "Disabled", "Stuff")), cl::init(DwarfDebug::MinimizeAddrInV5::Default)) |
static constexpr unsigned | ULEB128PadSize = 4 |
#define DEBUG_TYPE "dwarfdebug" |
Definition at line 65 of file DwarfDebug.cpp.
#define HANDLE_MACRO_FLAG | ( | ID, | |
NAME | |||
) | MACRO_FLAG_##NAME = ID, |
using ClobberedRegSet = SmallSet<Register, 16> |
Container for the set of registers known to be clobbered on the path to a call site.
Definition at line 582 of file DwarfDebug.cpp.
using FwdRegWorklist = MapVector<uint64_t, SmallVector<FwdRegParamInfo, 2> > |
Register worklist for finding call site values.
Definition at line 579 of file DwarfDebug.cpp.
enum DefaultOnOff |
Enumerator | |
---|---|
Default | |
Enable | |
Disable |
Definition at line 87 of file DwarfDebug.cpp.
enum LinkageNameOption |
Enumerator | |
---|---|
DefaultLinkageNames | |
AllLinkageNames | |
AbstractLinkageNames |
Definition at line 137 of file DwarfDebug.cpp.
|
static |
Add Reg
to the worklist, if it's not already present, and mark that the given parameter registers' values can (potentially) be described using that register and an debug expression.
Definition at line 630 of file DwarfDebug.cpp.
References assert(), combineDIExpressions(), D, and llvm::none_of().
Referenced by interpretValues().
|
static |
Try to interpret values loaded into registers that forward parameters for CallMI
.
Store parameters with interpreted value into Params
.
Definition at line 797 of file DwarfDebug.cpp.
References assert(), llvm::MachineFunction::begin(), llvm::MapVector< KeyT, ValueT, MapType, VectorType >::erase(), llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT >::find(), finishCallSiteParams(), llvm::MDNode::get(), llvm::getBundleEnd(), llvm::MachineFunction::getCallSitesInfo(), llvm::Function::getContext(), llvm::MachineFunction::getFunction(), llvm::ilist_node_impl< OptionsT >::getIterator(), llvm::MachineInstr::getMF(), llvm::MachineInstr::getParent(), llvm::ilist_node_impl< OptionsT >::getReverseIterator(), llvm::MachineInstr::hasDelaySlot(), I, llvm::MapVector< KeyT, ValueT, MapType, VectorType >::insert(), interpretNextInstr(), MBB, llvm::MachineBasicBlock::rend(), and llvm::MachineInstr::uses().
|
static |
Append the expression Addition
to Original
and return the result.
Definition at line 585 of file DwarfDebug.cpp.
References llvm::DIExpression::append(), llvm::erase(), llvm::DIExpression::getElements(), llvm::DIExpression::isImplicit(), and llvm::ArrayRef< T >::vec().
Referenced by addToFwdRegWorklist(), and finishCallSiteParams().
|
static |
Definition at line 306 of file DwarfDebug.cpp.
References AccelTables, llvm::Apple, llvm::Default, llvm::Dwarf, llvm::LLDB, and llvm::None.
Referenced by llvm::DwarfDebug::DwarfDebug().
|
static |
computeIndexValue - Compute the gdb index value for the DIE and CU.
Definition at line 2708 of file DwarfDebug.cpp.
References llvm::DIE::findAttribute(), 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, and llvm::dwarf::isCPlusPlus().
|
static |
Definition at line 3186 of file DwarfDebug.cpp.
References emitRangeList(), llvm::DwarfDebug::getDebugLocs(), llvm::DebugLocStream::getEntries(), llvm::List, and llvm::dwarf::LocListEncodingString().
|
static |
Definition at line 3061 of file DwarfDebug.cpp.
References llvm::mcdwarf::emitListsTableHeaderStart(), llvm::DwarfDebug::getDebugLocs(), and llvm::List.
|
static |
Emit the header of a DWARF 5 macro section, or the GNU extension for DWARF 4.
Definition at line 3464 of file DwarfDebug.cpp.
References llvm::DwarfDebug::useSplitDwarf().
|
static |
Emit a single range list. We handle both DWARF v5 and earlier.
Definition at line 3412 of file DwarfDebug.cpp.
References emitRangeList(), llvm::DwarfDebug::getDwarfVersion(), llvm::List, and llvm::dwarf::RangeListEncodingString().
|
static |
Definition at line 3079 of file DwarfDebug.cpp.
References assert(), llvm::sampleprof::Base, End, EndOfList, llvm::DwarfDebug::getAddressPool(), llvm::DwarfDebug::getDwarfVersion(), llvm::AddressPool::getIndex(), llvm::MCSymbol::getSection(), llvm::DwarfDebug::getSectionLabel(), P, Range, Size, Sym, and llvm::DwarfDebug::tuneForGDB().
Referenced by emitLocList(), and emitRangeList().
|
static |
Definition at line 3043 of file DwarfDebug.cpp.
References llvm::mcdwarf::emitListsTableHeaderStart(), llvm::DwarfFile::getRangeLists(), llvm::DwarfFile::getRnglistsTableBaseSym(), and llvm::List.
|
static |
Definition at line 2148 of file DwarfDebug.cpp.
References assert(), llvm::MachineFunction::begin(), llvm::MachineFunction::end(), F, llvm::MachineInstr::FrameSetup, llvm::MachineFunction::getFunction(), llvm::TargetSubtargetInfo::getInstrInfo(), llvm::MachineInstr::getParent(), llvm::MachineFunction::getSubtarget(), isCopy(), MI, TII, and true.
Referenced by llvm::DwarfDebug::emitInitialLocDirective().
|
static |
Emit call site parameter entries that are described by the given value and debug expression.
Definition at line 599 of file DwarfDebug.cpp.
References assert(), combineDIExpressions(), llvm::DIExpression::isEntryValue(), llvm::DIExpression::isValid(), and llvm::SmallVectorTemplateBase< T, bool >::push_back().
Referenced by collectCallSiteParameters(), and interpretValues().
|
static |
Definition at line 531 of file DwarfDebug.cpp.
References F.
|
static |
Get .debug_loc entry for the instruction range starting at MI.
Definition at line 235 of file DwarfDebug.cpp.
References assert(), llvm::DIExpression::convertToNonVariadicExpression(), llvm_unreachable, MI, and llvm::SmallVectorTemplateBase< T, bool >::push_back().
|
static |
Definition at line 268 of file DwarfDebug.cpp.
References llvm::DIExpression::getFragmentInfo().
Definition at line 460 of file DwarfDebug.cpp.
References hasObjCCategory().
Referenced by llvm::DwarfDebug::addSubprogramNames().
Definition at line 472 of file DwarfDebug.cpp.
Referenced by llvm::DwarfDebug::addSubprogramNames().
|
static |
Definition at line 1515 of file DwarfDebug.cpp.
References llvm::DIScope::getScope(), llvm_unreachable, and N.
Referenced by llvm::DwarfDebug::endFunctionImpl().
Definition at line 453 of file DwarfDebug.cpp.
References isObjCClass(), and Name.
|
static |
Definition at line 769 of file DwarfDebug.cpp.
References llvm::MapVector< KeyT, ValueT, MapType, VectorType >::empty(), llvm::MachineInstr::getNumOperands(), interpretValues(), llvm::MachineInstr::isBundle(), and llvm::MachineInstr::isCall().
Referenced by collectCallSiteParameters().
|
static |
Interpret values loaded into registers by CurMI
.
Definition at line 651 of file DwarfDebug.cpp.
References addToFwdRegWorklist(), llvm::SmallSet< T, N, C >::begin(), llvm::MapVector< KeyT, ValueT, MapType, VectorType >::clear(), llvm::SetVector< T, Vector, Set, N >::empty(), llvm::SmallSet< T, N, C >::end(), llvm::MapVector< KeyT, ValueT, MapType, VectorType >::erase(), finishCallSiteParams(), FP, llvm::MDNode::get(), llvm::Function::getContext(), llvm::MachineFunction::getFunction(), llvm::TargetSubtargetInfo::getInstrInfo(), llvm::MachineInstr::getMF(), llvm::TargetSubtargetInfo::getRegisterInfo(), llvm::MachineFunction::getSubtarget(), llvm::TargetSubtargetInfo::getTargetLowering(), llvm::SmallSet< T, N, C >::insert(), MI, TII, and TRI.
Referenced by interpretNextInstr().
Definition at line 449 of file DwarfDebug.cpp.
References Name.
Referenced by llvm::DwarfDebug::addSubprogramNames(), and hasObjCCategory().
|
static |
Register a source line with debug info.
Returns the unique label that was emitted and which provides correspondence to the source line list.
Definition at line 2272 of file DwarfDebug.cpp.
|
static |
Sort and unique GVEs by comparing their fragment offset.
Definition at line 1117 of file DwarfDebug.cpp.
References A, B, llvm::SmallVectorTemplateCommon< T, typename >::end(), llvm::SmallVectorImpl< T >::erase(), if(), llvm::sort(), and llvm::unique().
Referenced by llvm::DwarfDebug::beginModule().
STATISTIC | ( | NumCSParams | , |
"Number of dbg call site params created" | |||
) |
|
static |
Determine whether a singular DBG_VALUE is valid for the entirety of its enclosing lexical scope.
The check ensures there are no other instructions in the same lexical scope preceding the DBG_VALUE and that its range is either open or otherwise rolls off the end of the scope.
Definition at line 1596 of file DwarfDebug.cpp.
References llvm::all_of(), assert(), DL, llvm::LexicalScopes::findLexicalScope(), llvm::MachineInstr::FrameSetup, llvm::MachineInstr::getParent(), llvm::LexicalScope::getRanges(), MBB, llvm::MachineBasicBlock::pred_empty(), and llvm::MachineBasicBlock::rend().
|
static |
Referenced by computeAccelTableKind().
|
static |
Referenced by llvm::DwarfDebug::DwarfDebug().
|
static |
Referenced by llvm::DwarfDebug::DwarfDebug().
|
static |
Referenced by llvm::DwarfDebug::DwarfDebug().
|
static |
Referenced by llvm::DwarfDebug::DwarfDebug().
|
static |
Referenced by llvm::DwarfDebug::DwarfDebug().
|
static |
Referenced by llvm::DwarfDebug::DwarfDebug().
|
static |
Referenced by llvm::DwarfDebug::DwarfDebug().
|
static |
Referenced by llvm::DwarfDebug::DwarfDebug().
|
static |
Referenced by llvm::DwarfDebug::shareAcrossDWOCUs().
|
staticconstexpr |
Definition at line 173 of file DwarfDebug.cpp.
Referenced by llvm::APByteStreamer::emitDIERef(), and llvm::BufferByteStreamer::emitDIERef().
|
static |
Referenced by llvm::DwarfDebug::beginInstruction().
|
static |
|
static |
Referenced by llvm::DwarfDebug::DwarfDebug().