You've already forked linux-packaging-mono
acceptance-tests
data
debian
docs
external
Newtonsoft.Json
api-doc-tools
api-snapshot
aspnetwebstack
bdwgc
binary-reference-assemblies
bockbuild
boringssl
cecil
cecil-legacy
corefx
corert
helix-binaries
ikdasm
ikvm
illinker-test-assets
linker
llvm-project
clang
clang-tools-extra
compiler-rt
libcxx
libcxxabi
libunwind
lld
lldb
llvm
bindings
cmake
docs
examples
include
lib
Analysis
AsmParser
BinaryFormat
Bitcode
CodeGen
AsmPrinter
ARMException.cpp
AddressPool.cpp
AddressPool.h
AsmPrinter.cpp.REMOVED.git-id
AsmPrinterDwarf.cpp
AsmPrinterHandler.h
AsmPrinterInlineAsm.cpp
ByteStreamer.h
CMakeLists.txt
CodeViewDebug.cpp
CodeViewDebug.h
DIE.cpp
DIEHash.cpp
DIEHash.h
DIEHashAttributes.def
DbgValueHistoryCalculator.cpp
DbgValueHistoryCalculator.h
DebugHandlerBase.cpp
DebugHandlerBase.h
DebugLocEntry.h
DebugLocStream.cpp
DebugLocStream.h
DwarfAccelTable.cpp
DwarfAccelTable.h
DwarfCFIException.cpp
DwarfCompileUnit.cpp
DwarfCompileUnit.h
DwarfDebug.cpp
DwarfDebug.h
DwarfException.h
DwarfExpression.cpp
DwarfExpression.h
DwarfFile.cpp
DwarfFile.h
DwarfStringPool.cpp
DwarfStringPool.h
DwarfUnit.cpp
DwarfUnit.h
EHStreamer.cpp
EHStreamer.h
ErlangGCPrinter.cpp
LLVMBuild.txt
MonoException.cpp
MonoException.h
OcamlGCPrinter.cpp
WinException.cpp
WinException.h
GlobalISel
MIRParser
SelectionDAG
AggressiveAntiDepBreaker.cpp
AggressiveAntiDepBreaker.h
AllocationOrder.cpp
AllocationOrder.h
Analysis.cpp
AntiDepBreaker.h
AtomicExpandPass.cpp
BasicTargetTransformInfo.cpp
BranchFolding.cpp
BranchFolding.h
BranchRelaxation.cpp
BuiltinGCs.cpp
CMakeLists.txt
CalcSpillWeights.cpp
CallingConvLower.cpp
CodeGen.cpp
CodeGenPrepare.cpp.REMOVED.git-id
CriticalAntiDepBreaker.cpp
CriticalAntiDepBreaker.h
DFAPacketizer.cpp
DeadMachineInstructionElim.cpp
DetectDeadLanes.cpp
DwarfEHPrepare.cpp
EarlyIfConversion.cpp
EdgeBundles.cpp
ExecutionDepsFix.cpp
ExpandISelPseudos.cpp
ExpandMemCmp.cpp
ExpandPostRAPseudos.cpp
ExpandReductions.cpp
FEntryInserter.cpp
FaultMaps.cpp
FuncletLayout.cpp
GCMetadata.cpp
GCMetadataPrinter.cpp
GCRootLowering.cpp
GCStrategy.cpp
GlobalMerge.cpp
IfConversion.cpp
ImplicitNullChecks.cpp
IndirectBrExpandPass.cpp
InlineSpiller.cpp
InterferenceCache.cpp
InterferenceCache.h
InterleavedAccessPass.cpp
IntrinsicLowering.cpp
LLVMBuild.txt
LLVMTargetMachine.cpp
LatencyPriorityQueue.cpp
LazyMachineBlockFrequencyInfo.cpp
LexicalScopes.cpp
LiveDebugValues.cpp
LiveDebugVariables.cpp
LiveDebugVariables.h
LiveInterval.cpp
LiveIntervalUnion.cpp
LiveIntervals.cpp
LivePhysRegs.cpp
LiveRangeCalc.cpp
LiveRangeCalc.h
LiveRangeEdit.cpp
LiveRangeShrink.cpp
LiveRangeUtils.h
LiveRegMatrix.cpp
LiveRegUnits.cpp
LiveStacks.cpp
LiveVariables.cpp
LocalStackSlotAllocation.cpp
LowLevelType.cpp
LowerEmuTLS.cpp
MIRCanonicalizerPass.cpp
MIRPrinter.cpp
MIRPrintingPass.cpp
MachineBasicBlock.cpp
MachineBlockFrequencyInfo.cpp
MachineBlockPlacement.cpp.REMOVED.git-id
MachineBranchProbabilityInfo.cpp
MachineCSE.cpp
MachineCombiner.cpp
MachineCopyPropagation.cpp
MachineDominanceFrontier.cpp
MachineDominators.cpp
MachineFrameInfo.cpp
MachineFunction.cpp
MachineFunctionPass.cpp
MachineFunctionPrinterPass.cpp
MachineInstr.cpp
MachineInstrBundle.cpp
MachineLICM.cpp
MachineLoopInfo.cpp
MachineModuleInfo.cpp
MachineModuleInfoImpls.cpp
MachineOperand.cpp
MachineOptimizationRemarkEmitter.cpp
MachineOutliner.cpp
MachinePassRegistry.cpp
MachinePipeliner.cpp.REMOVED.git-id
MachinePostDominators.cpp
MachineRegionInfo.cpp
MachineRegisterInfo.cpp
MachineSSAUpdater.cpp
MachineScheduler.cpp.REMOVED.git-id
MachineSink.cpp
MachineTraceMetrics.cpp
MachineVerifier.cpp
MacroFusion.cpp
OptimizePHIs.cpp
PHIElimination.cpp
PHIEliminationUtils.cpp
PHIEliminationUtils.h
ParallelCG.cpp
PatchableFunction.cpp
PeepholeOptimizer.cpp
PostRAHazardRecognizer.cpp
PostRASchedulerList.cpp
PreISelIntrinsicLowering.cpp
ProcessImplicitDefs.cpp
PrologEpilogInserter.cpp
PseudoSourceValue.cpp
README.txt
RegAllocBase.cpp
RegAllocBase.h
RegAllocBasic.cpp
RegAllocFast.cpp
RegAllocGreedy.cpp.REMOVED.git-id
RegAllocPBQP.cpp
RegUsageInfoCollector.cpp
RegUsageInfoPropagate.cpp
RegisterClassInfo.cpp
RegisterCoalescer.cpp.REMOVED.git-id
RegisterCoalescer.h
RegisterPressure.cpp
RegisterScavenging.cpp
RegisterUsageInfo.cpp
RenameIndependentSubregs.cpp
ResetMachineFunctionPass.cpp
SafeStack.cpp
SafeStackColoring.cpp
SafeStackColoring.h
SafeStackLayout.cpp
SafeStackLayout.h
ScalarizeMaskedMemIntrin.cpp
ScheduleDAG.cpp
ScheduleDAGInstrs.cpp
ScheduleDAGPrinter.cpp
ScoreboardHazardRecognizer.cpp
ShadowStackGCLowering.cpp
ShrinkWrap.cpp
SjLjEHPrepare.cpp
SlotIndexes.cpp
SpillPlacement.cpp
SpillPlacement.h
Spiller.h
SplitKit.cpp
SplitKit.h
StackColoring.cpp
StackMapLivenessAnalysis.cpp
StackMaps.cpp
StackProtector.cpp
StackSlotColoring.cpp
TailDuplication.cpp
TailDuplicator.cpp
TargetFrameLoweringImpl.cpp
TargetInstrInfo.cpp
TargetLoweringBase.cpp
TargetLoweringObjectFileImpl.cpp
TargetOptionsImpl.cpp
TargetPassConfig.cpp
TargetRegisterInfo.cpp
TargetSchedule.cpp
TargetSubtargetInfo.cpp
TwoAddressInstructionPass.cpp
UnreachableBlockElim.cpp
VirtRegMap.cpp
WinEHPrepare.cpp
XRayInstrumentation.cpp
DebugInfo
Demangle
ExecutionEngine
FuzzMutate
Fuzzer
IR
IRReader
LTO
LineEditor
Linker
MC
Object
ObjectYAML
Option
Passes
ProfileData
Support
TableGen
Target
Testing
ToolDrivers
Transforms
WindowsManifest
XRay
CMakeLists.txt
LLVMBuild.txt
projects
resources
runtimes
scripts
test
tools
unittests
utils
.arcconfig
.clang-format
.clang-tidy
.gitattributes
.gitignore
CMakeLists.txt
CODE_OWNERS.TXT
CREDITS.TXT
LICENSE.TXT
LLVMBuild.txt
README.txt
RELEASE_TESTERS.TXT
configure
llvm.spec.in
openmp
polly
nuget-buildtasks
nunit-lite
roslyn-binaries
rx
xunit-binaries
how-to-bump-roslyn-binaries.md
ikvm-native
llvm
m4
man
mcs
mk
mono
msvc
netcore
po
runtime
samples
scripts
support
tools
COPYING.LIB
LICENSE
Makefile.am
Makefile.in
NEWS
README.md
acinclude.m4
aclocal.m4
autogen.sh
code_of_conduct.md
compile
config.guess
config.h.in
config.rpath
config.sub
configure.REMOVED.git-id
configure.ac.REMOVED.git-id
depcomp
install-sh
ltmain.sh.REMOVED.git-id
missing
mkinstalldirs
mono-uninstalled.pc.in
test-driver
winconfig.h
194 lines
5.8 KiB
C
194 lines
5.8 KiB
C
![]() |
//===--- lib/CodeGen/DebugLocStream.h - DWARF debug_loc stream --*- C++ -*-===//
|
||
|
//
|
||
|
// The LLVM Compiler Infrastructure
|
||
|
//
|
||
|
// This file is distributed under the University of Illinois Open Source
|
||
|
// License. See LICENSE.TXT for details.
|
||
|
//
|
||
|
//===----------------------------------------------------------------------===//
|
||
|
|
||
|
#ifndef LLVM_LIB_CODEGEN_ASMPRINTER_DEBUGLOCSTREAM_H
|
||
|
#define LLVM_LIB_CODEGEN_ASMPRINTER_DEBUGLOCSTREAM_H
|
||
|
|
||
|
#include "ByteStreamer.h"
|
||
|
#include "llvm/ADT/ArrayRef.h"
|
||
|
#include "llvm/ADT/SmallVector.h"
|
||
|
|
||
|
namespace llvm {
|
||
|
|
||
|
class AsmPrinter;
|
||
|
class DbgVariable;
|
||
|
class DwarfCompileUnit;
|
||
|
class MachineInstr;
|
||
|
class MCSymbol;
|
||
|
|
||
|
/// \brief Byte stream of .debug_loc entries.
|
||
|
///
|
||
|
/// Stores a unified stream of .debug_loc entries. There's \a List for each
|
||
|
/// variable/inlined-at pair, and an \a Entry for each \a DebugLocEntry.
|
||
|
///
|
||
|
/// FIXME: Do we need all these temp symbols?
|
||
|
/// FIXME: Why not output directly to the output stream?
|
||
|
class DebugLocStream {
|
||
|
public:
|
||
|
struct List {
|
||
|
DwarfCompileUnit *CU;
|
||
|
MCSymbol *Label = nullptr;
|
||
|
size_t EntryOffset;
|
||
|
List(DwarfCompileUnit *CU, size_t EntryOffset)
|
||
|
: CU(CU), EntryOffset(EntryOffset) {}
|
||
|
};
|
||
|
struct Entry {
|
||
|
const MCSymbol *BeginSym;
|
||
|
const MCSymbol *EndSym;
|
||
|
size_t ByteOffset;
|
||
|
size_t CommentOffset;
|
||
|
Entry(const MCSymbol *BeginSym, const MCSymbol *EndSym, size_t ByteOffset,
|
||
|
size_t CommentOffset)
|
||
|
: BeginSym(BeginSym), EndSym(EndSym), ByteOffset(ByteOffset),
|
||
|
CommentOffset(CommentOffset) {}
|
||
|
};
|
||
|
|
||
|
private:
|
||
|
SmallVector<List, 4> Lists;
|
||
|
SmallVector<Entry, 32> Entries;
|
||
|
SmallString<256> DWARFBytes;
|
||
|
SmallVector<std::string, 32> Comments;
|
||
|
|
||
|
/// \brief Only verbose textual output needs comments. This will be set to
|
||
|
/// true for that case, and false otherwise.
|
||
|
bool GenerateComments;
|
||
|
|
||
|
public:
|
||
|
DebugLocStream(bool GenerateComments) : GenerateComments(GenerateComments) { }
|
||
|
size_t getNumLists() const { return Lists.size(); }
|
||
|
const List &getList(size_t LI) const { return Lists[LI]; }
|
||
|
ArrayRef<List> getLists() const { return Lists; }
|
||
|
|
||
|
class ListBuilder;
|
||
|
class EntryBuilder;
|
||
|
|
||
|
private:
|
||
|
/// \brief Start a new .debug_loc entry list.
|
||
|
///
|
||
|
/// Start a new .debug_loc entry list. Return the new list's index so it can
|
||
|
/// be retrieved later via \a getList().
|
||
|
///
|
||
|
/// Until the next call, \a startEntry() will add entries to this list.
|
||
|
size_t startList(DwarfCompileUnit *CU) {
|
||
|
size_t LI = Lists.size();
|
||
|
Lists.emplace_back(CU, Entries.size());
|
||
|
return LI;
|
||
|
}
|
||
|
|
||
|
/// Finalize a .debug_loc entry list.
|
||
|
///
|
||
|
/// If there are no entries in this list, delete it outright. Otherwise,
|
||
|
/// create a label with \a Asm.
|
||
|
///
|
||
|
/// \return false iff the list is deleted.
|
||
|
bool finalizeList(AsmPrinter &Asm);
|
||
|
|
||
|
/// \brief Start a new .debug_loc entry.
|
||
|
///
|
||
|
/// Until the next call, bytes added to the stream will be added to this
|
||
|
/// entry.
|
||
|
void startEntry(const MCSymbol *BeginSym, const MCSymbol *EndSym) {
|
||
|
Entries.emplace_back(BeginSym, EndSym, DWARFBytes.size(), Comments.size());
|
||
|
}
|
||
|
|
||
|
/// Finalize a .debug_loc entry, deleting if it's empty.
|
||
|
void finalizeEntry();
|
||
|
|
||
|
public:
|
||
|
BufferByteStreamer getStreamer() {
|
||
|
return BufferByteStreamer(DWARFBytes, Comments, GenerateComments);
|
||
|
}
|
||
|
|
||
|
ArrayRef<Entry> getEntries(const List &L) const {
|
||
|
size_t LI = getIndex(L);
|
||
|
return makeArrayRef(Entries)
|
||
|
.slice(Lists[LI].EntryOffset, getNumEntries(LI));
|
||
|
}
|
||
|
|
||
|
ArrayRef<char> getBytes(const Entry &E) const {
|
||
|
size_t EI = getIndex(E);
|
||
|
return makeArrayRef(DWARFBytes.begin(), DWARFBytes.end())
|
||
|
.slice(Entries[EI].ByteOffset, getNumBytes(EI));
|
||
|
}
|
||
|
ArrayRef<std::string> getComments(const Entry &E) const {
|
||
|
size_t EI = getIndex(E);
|
||
|
return makeArrayRef(Comments)
|
||
|
.slice(Entries[EI].CommentOffset, getNumComments(EI));
|
||
|
}
|
||
|
|
||
|
private:
|
||
|
size_t getIndex(const List &L) const {
|
||
|
assert(&Lists.front() <= &L && &L <= &Lists.back() &&
|
||
|
"Expected valid list");
|
||
|
return &L - &Lists.front();
|
||
|
}
|
||
|
size_t getIndex(const Entry &E) const {
|
||
|
assert(&Entries.front() <= &E && &E <= &Entries.back() &&
|
||
|
"Expected valid entry");
|
||
|
return &E - &Entries.front();
|
||
|
}
|
||
|
size_t getNumEntries(size_t LI) const {
|
||
|
if (LI + 1 == Lists.size())
|
||
|
return Entries.size() - Lists[LI].EntryOffset;
|
||
|
return Lists[LI + 1].EntryOffset - Lists[LI].EntryOffset;
|
||
|
}
|
||
|
size_t getNumBytes(size_t EI) const {
|
||
|
if (EI + 1 == Entries.size())
|
||
|
return DWARFBytes.size() - Entries[EI].ByteOffset;
|
||
|
return Entries[EI + 1].ByteOffset - Entries[EI].ByteOffset;
|
||
|
}
|
||
|
size_t getNumComments(size_t EI) const {
|
||
|
if (EI + 1 == Entries.size())
|
||
|
return Comments.size() - Entries[EI].CommentOffset;
|
||
|
return Entries[EI + 1].CommentOffset - Entries[EI].CommentOffset;
|
||
|
}
|
||
|
};
|
||
|
|
||
|
/// Builder for DebugLocStream lists.
|
||
|
class DebugLocStream::ListBuilder {
|
||
|
DebugLocStream &Locs;
|
||
|
AsmPrinter &Asm;
|
||
|
DbgVariable &V;
|
||
|
const MachineInstr &MI;
|
||
|
size_t ListIndex;
|
||
|
|
||
|
public:
|
||
|
ListBuilder(DebugLocStream &Locs, DwarfCompileUnit &CU, AsmPrinter &Asm,
|
||
|
DbgVariable &V, const MachineInstr &MI)
|
||
|
: Locs(Locs), Asm(Asm), V(V), MI(MI), ListIndex(Locs.startList(&CU)) {}
|
||
|
|
||
|
/// Finalize the list.
|
||
|
///
|
||
|
/// If the list is empty, delete it. Otherwise, finalize it by creating a
|
||
|
/// temp symbol in \a Asm and setting up the \a DbgVariable.
|
||
|
~ListBuilder();
|
||
|
|
||
|
DebugLocStream &getLocs() { return Locs; }
|
||
|
};
|
||
|
|
||
|
/// Builder for DebugLocStream entries.
|
||
|
class DebugLocStream::EntryBuilder {
|
||
|
DebugLocStream &Locs;
|
||
|
|
||
|
public:
|
||
|
EntryBuilder(ListBuilder &List, const MCSymbol *Begin, const MCSymbol *End)
|
||
|
: Locs(List.getLocs()) {
|
||
|
Locs.startEntry(Begin, End);
|
||
|
}
|
||
|
|
||
|
/// Finalize the entry, deleting it if it's empty.
|
||
|
~EntryBuilder() { Locs.finalizeEntry(); }
|
||
|
|
||
|
BufferByteStreamer getStreamer() { return Locs.getStreamer(); }
|
||
|
};
|
||
|
|
||
|
} // namespace llvm
|
||
|
|
||
|
#endif
|