LLVM 20.0.0git
|
Holds state from .cv_file and .cv_loc directives for later emission. More...
#include "llvm/MC/MCCodeView.h"
Public Member Functions | |
CodeViewContext (MCContext *MCCtx) | |
~CodeViewContext () | |
CodeViewContext & | operator= (const CodeViewContext &other)=delete |
CodeViewContext (const CodeViewContext &other)=delete | |
bool | isValidFileNumber (unsigned FileNumber) const |
This is a valid number for use with .cv_loc if we've already seen a .cv_file for it. | |
bool | addFile (MCStreamer &OS, unsigned FileNumber, StringRef Filename, ArrayRef< uint8_t > ChecksumBytes, uint8_t ChecksumKind) |
bool | recordFunctionId (unsigned FuncId) |
Records the function id of a normal function. | |
bool | recordInlinedCallSiteId (unsigned FuncId, unsigned IAFunc, unsigned IAFile, unsigned IALine, unsigned IACol) |
Records the function id of an inlined call site. | |
MCCVFunctionInfo * | getCVFunctionInfo (unsigned FuncId) |
Retreive the function info if this is a valid function id, or nullptr. | |
void | recordCVLoc (MCContext &Ctx, const MCSymbol *Label, unsigned FunctionId, unsigned FileNo, unsigned Line, unsigned Column, bool PrologueEnd, bool IsStmt) |
Saves the information from the currently parsed .cv_loc directive and sets CVLocSeen. | |
void | addLineEntry (const MCCVLoc &LineEntry) |
Add a line entry. | |
std::vector< MCCVLoc > | getFunctionLineEntries (unsigned FuncId) |
std::pair< size_t, size_t > | getLineExtent (unsigned FuncId) |
std::pair< size_t, size_t > | getLineExtentIncludingInlinees (unsigned FuncId) |
ArrayRef< MCCVLoc > | getLinesForExtent (size_t L, size_t R) |
void | emitLineTableForFunction (MCObjectStreamer &OS, unsigned FuncId, const MCSymbol *FuncBegin, const MCSymbol *FuncEnd) |
Emits a line table substream. | |
void | emitInlineLineTableForFunction (MCObjectStreamer &OS, unsigned PrimaryFunctionId, unsigned SourceFileId, unsigned SourceLineNum, const MCSymbol *FnStartSym, const MCSymbol *FnEndSym) |
void | encodeInlineLineTable (const MCAssembler &Asm, MCCVInlineLineTableFragment &F) |
Encodes the binary annotations once we have a layout. | |
MCFragment * | emitDefRange (MCObjectStreamer &OS, ArrayRef< std::pair< const MCSymbol *, const MCSymbol * > > Ranges, StringRef FixedSizePortion) |
void | encodeDefRange (const MCAssembler &Asm, MCCVDefRangeFragment &F) |
void | emitStringTable (MCObjectStreamer &OS) |
Emits the string table substream. | |
void | emitFileChecksums (MCObjectStreamer &OS) |
Emits the file checksum substream. | |
void | emitFileChecksumOffset (MCObjectStreamer &OS, unsigned FileNo) |
Emits the offset into the checksum table of the given file number. | |
std::pair< StringRef, unsigned > | addToStringTable (StringRef S) |
Add something to the string table. | |
Holds state from .cv_file and .cv_loc directives for later emission.
Definition at line 144 of file MCCodeView.h.
|
inline |
Definition at line 146 of file MCCodeView.h.
CodeViewContext::~CodeViewContext | ( | ) |
Definition at line 28 of file MCCodeView.cpp.
References llvm::MCFragment::destroy().
|
delete |
bool CodeViewContext::addFile | ( | MCStreamer & | OS, |
unsigned | FileNumber, | ||
StringRef | Filename, | ||
ArrayRef< uint8_t > | ChecksumBytes, | ||
uint8_t | ChecksumKind | ||
) |
Definition at line 44 of file MCCodeView.cpp.
References addToStringTable(), assert(), Idx, llvm::Offset, OS, llvm::SmallVectorImpl< T >::resize(), and llvm::SmallVectorBase< Size_T >::size().
Referenced by llvm::MCStreamer::emitCVFileDirective().
Add a line entry.
Definition at line 263 of file MCCodeView.cpp.
References llvm::MCCVLoc::getFunctionId(), I, and llvm::Offset.
Referenced by recordCVLoc().
Add something to the string table.
Returns the final string as well as offset into the string table.
Definition at line 145 of file MCCodeView.cpp.
References llvm::SmallVectorImpl< T >::append(), llvm::MCEncodedFragmentWithFixups< ContentsSize, FixupsSize >::getContents(), and llvm::SmallVectorBase< Size_T >::size().
Referenced by addFile().
MCFragment * CodeViewContext::emitDefRange | ( | MCObjectStreamer & | OS, |
ArrayRef< std::pair< const MCSymbol *, const MCSymbol * > > | Ranges, | ||
StringRef | FixedSizePortion | ||
) |
Definition at line 455 of file MCCodeView.cpp.
References llvm::MCContext::allocFragment(), F, and OS.
Referenced by llvm::MCObjectStreamer::emitCVDefRangeDirective().
void CodeViewContext::emitFileChecksumOffset | ( | MCObjectStreamer & | OS, |
unsigned | FileNo | ||
) |
Emits the offset into the checksum table of the given file number.
Definition at line 245 of file MCCodeView.cpp.
References llvm::MCSymbolRefExpr::create(), Idx, OS, llvm::SmallVectorImpl< T >::resize(), and llvm::SmallVectorBase< Size_T >::size().
Referenced by llvm::MCObjectStreamer::emitCVFileChecksumOffsetDirective().
void CodeViewContext::emitFileChecksums | ( | MCObjectStreamer & | OS | ) |
Emits the file checksum substream.
Definition at line 190 of file MCCodeView.cpp.
References llvm::alignTo(), llvm::MCConstantExpr::create(), llvm::MCContext::createTempSymbol(), llvm::SmallVectorBase< Size_T >::empty(), and OS.
Referenced by llvm::MCObjectStreamer::emitCVFileChecksumsDirective().
void CodeViewContext::emitInlineLineTableForFunction | ( | MCObjectStreamer & | OS, |
unsigned | PrimaryFunctionId, | ||
unsigned | SourceFileId, | ||
unsigned | SourceLineNum, | ||
const MCSymbol * | FnStartSym, | ||
const MCSymbol * | FnEndSym | ||
) |
Definition at line 442 of file MCCodeView.cpp.
References llvm::MCContext::allocFragment(), F, and OS.
Referenced by llvm::MCObjectStreamer::emitCVInlineLinetableDirective().
void CodeViewContext::emitLineTableForFunction | ( | MCObjectStreamer & | OS, |
unsigned | FuncId, | ||
const MCSymbol * | FuncBegin, | ||
const MCSymbol * | FuncEnd | ||
) |
Emits a line table substream.
Definition at line 347 of file MCCodeView.cpp.
References llvm::any_of(), llvm::MCContext::createTempSymbol(), FuncId, llvm::MCCVLoc::getColumn(), llvm::MCCVLoc::getFileNum(), getFunctionLineEntries(), I, llvm::codeview::LF_HaveColumns, and OS.
Referenced by llvm::MCObjectStreamer::emitCVLinetableDirective().
void CodeViewContext::emitStringTable | ( | MCObjectStreamer & | OS | ) |
Emits the string table substream.
Definition at line 168 of file MCCodeView.cpp.
References llvm::MCContext::createTempSymbol(), and OS.
Referenced by llvm::MCObjectStreamer::emitCVStringTableDirective().
void CodeViewContext::encodeDefRange | ( | const MCAssembler & | Asm, |
MCCVDefRangeFragment & | F | ||
) |
Definition at line 621 of file MCCodeView.cpp.
References assert(), llvm::SmallVectorImpl< T >::clear(), computeLabelDiff(), llvm::MCSymbolRefExpr::create(), llvm::MCConstantExpr::create(), llvm::MCFixup::create(), llvm::MCBinaryExpr::createAdd(), llvm::FK_SecRel_2, llvm::FK_SecRel_4, llvm::MCEncodedFragmentWithFixups< ContentsSize, FixupsSize >::getContents(), llvm::MCCVDefRangeFragment::getFixedSizePortion(), llvm::MCEncodedFragmentWithFixups< ContentsSize, FixupsSize >::getFixups(), llvm::MCCVDefRangeFragment::getRanges(), I, llvm::little, llvm::codeview::MaxDefRange, OS, llvm::SmallVectorTemplateBase< T, bool >::push_back(), Range, llvm::SmallVectorBase< Size_T >::size(), llvm::StringRef::size(), and llvm::support::endian::Writer::write().
void CodeViewContext::encodeInlineLineTable | ( | const MCAssembler & | Asm, |
MCCVInlineLineTableFragment & | F | ||
) |
Encodes the binary annotations once we have a layout.
Definition at line 484 of file MCCodeView.cpp.
References assert(), llvm::SmallVectorImpl< T >::clear(), compressAnnotation(), computeLabelDiff(), llvm::ArrayRef< T >::empty(), encodeSignedNumber(), llvm::errs(), llvm::MCCVFunctionInfo::LineInfo::File, llvm::ArrayRef< T >::front(), llvm::MCCVInlineLineTableFragment::getContents(), getCVFunctionInfo(), llvm::MCCVInlineLineTableFragment::getFnEndSym(), llvm::MCCVInlineLineTableFragment::getFnStartSym(), llvm::MCCVLoc::getLabel(), getLineExtentIncludingInlinees(), getLinesForExtent(), llvm::MCSymbol::getSection(), I, llvm::MCCVFunctionInfo::InlinedAtMap, llvm::Length, llvm::MCCVFunctionInfo::LineInfo::Line, llvm_unreachable, llvm::codeview::MaxRecordLength, llvm::MCCVLoc::setFileNum(), llvm::MCCVLoc::setLabel(), llvm::MCCVLoc::setLine(), and llvm::SmallVectorBase< Size_T >::size().
MCCVFunctionInfo * CodeViewContext::getCVFunctionInfo | ( | unsigned | FuncId | ) |
Retreive the function info if this is a valid function id, or nullptr.
Definition at line 76 of file MCCodeView.cpp.
References FuncId.
Referenced by llvm::MCStreamer::checkCVLocSection(), encodeInlineLineTable(), getFunctionLineEntries(), getLineExtentIncludingInlinees(), and recordInlinedCallSiteId().
Definition at line 273 of file MCCodeView.cpp.
References FuncId, getCVFunctionInfo(), getLineExtentIncludingInlinees(), I, Idx, and llvm::MCCVFunctionInfo::InlinedAtMap.
Referenced by emitLineTableForFunction().
std::pair< size_t, size_t > CodeViewContext::getLineExtent | ( | unsigned | FuncId | ) |
Definition at line 311 of file MCCodeView.cpp.
Referenced by getLineExtentIncludingInlinees().
std::pair< size_t, size_t > CodeViewContext::getLineExtentIncludingInlinees | ( | unsigned | FuncId | ) |
Definition at line 320 of file MCCodeView.cpp.
References FuncId, getCVFunctionInfo(), getLineExtent(), and llvm::MCCVFunctionInfo::InlinedAtMap.
Referenced by encodeInlineLineTable(), and getFunctionLineEntries().
Definition at line 339 of file MCCodeView.cpp.
Referenced by encodeInlineLineTable().
This is a valid number for use with .cv_loc if we've already seen a .cv_file for it.
Definition at line 37 of file MCCodeView.cpp.
References Idx, and llvm::SmallVectorBase< Size_T >::size().
|
delete |
void CodeViewContext::recordCVLoc | ( | MCContext & | Ctx, |
const MCSymbol * | Label, | ||
unsigned | FunctionId, | ||
unsigned | FileNo, | ||
unsigned | Line, | ||
unsigned | Column, | ||
bool | PrologueEnd, | ||
bool | IsStmt | ||
) |
Saves the information from the currently parsed .cv_loc directive and sets CVLocSeen.
When the next instruction is assembled an entry in the line number table with this information and the address of the instruction will be created.
Definition at line 128 of file MCCodeView.cpp.
References addLineEntry().
Referenced by llvm::MCObjectStreamer::emitCVLocDirective().
Records the function id of a normal function.
Returns false if the function id has already been used, and true otherwise.
Definition at line 84 of file MCCodeView.cpp.
References FuncId, and llvm::MCCVFunctionInfo::FunctionSentinel.
Referenced by llvm::MCStreamer::emitCVFuncIdDirective().
bool CodeViewContext::recordInlinedCallSiteId | ( | unsigned | FuncId, |
unsigned | IAFunc, | ||
unsigned | IAFile, | ||
unsigned | IALine, | ||
unsigned | IACol | ||
) |
Records the function id of an inlined call site.
Records the "inlined at" location info of the call site, including what function or inlined call site it was inlined into. Returns false if the function id has already been used, and true otherwise.
Definition at line 97 of file MCCodeView.cpp.
References llvm::MCCVFunctionInfo::LineInfo::Col, llvm::MCCVFunctionInfo::LineInfo::File, FuncId, getCVFunctionInfo(), Info, and llvm::MCCVFunctionInfo::LineInfo::Line.
Referenced by llvm::MCStreamer::emitCVInlineSiteIdDirective().