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 & | operator= (const CodeViewContext &other)=delete |
CodeViewContext (const CodeViewContext &other)=delete | |
void | finish () |
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.
|
delete |
bool CodeViewContext::addFile | ( | MCStreamer & | OS, |
unsigned | FileNumber, | ||
StringRef | Filename, | ||
ArrayRef< uint8_t > | ChecksumBytes, | ||
uint8_t | ChecksumKind | ||
) |
Definition at line 42 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 251 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 134 of file MCCodeView.cpp.
References llvm::SmallVectorImpl< T >::append(), 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 441 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 233 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 178 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 428 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 335 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 156 of file MCCodeView.cpp.
References llvm::MCContext::allocFragment(), llvm::MCContext::createTempSymbol(), and OS.
Referenced by llvm::MCObjectStreamer::emitCVStringTableDirective().
void CodeViewContext::encodeDefRange | ( | const MCAssembler & | Asm, |
MCCVDefRangeFragment & | F | ||
) |
Definition at line 607 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 470 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().
void CodeViewContext::finish | ( | ) |
Definition at line 28 of file MCCodeView.cpp.
References llvm::MCEncodedFragmentWithFixups< ContentsSize, FixupsSize >::setContents().
Referenced by llvm::MCWinCOFFStreamer::finishImpl().
MCCVFunctionInfo * CodeViewContext::getCVFunctionInfo | ( | unsigned | FuncId | ) |
Retreive the function info if this is a valid function id, or nullptr.
Definition at line 74 of file MCCodeView.cpp.
References FuncId.
Referenced by llvm::MCStreamer::checkCVLocSection(), encodeInlineLineTable(), getFunctionLineEntries(), getLineExtentIncludingInlinees(), and recordInlinedCallSiteId().
Definition at line 261 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 299 of file MCCodeView.cpp.
Referenced by getLineExtentIncludingInlinees().
std::pair< size_t, size_t > CodeViewContext::getLineExtentIncludingInlinees | ( | unsigned | FuncId | ) |
Definition at line 308 of file MCCodeView.cpp.
References FuncId, getCVFunctionInfo(), getLineExtent(), and llvm::MCCVFunctionInfo::InlinedAtMap.
Referenced by encodeInlineLineTable(), and getFunctionLineEntries().
Definition at line 327 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 35 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 126 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 82 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 95 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().