Lines Matching +full:os +full:- +full:code +full:- +full:offset
1 //===- MCCodeView.h - Machine Code CodeView support -------------*- C++ -*-===//
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
11 //===----------------------------------------------------------------------===//
32 StrTabFragment->destroy(); in ~CodeViewContext()
38 unsigned Idx = FileNumber - 1; in isValidFileNumber()
44 bool CodeViewContext::addFile(MCStreamer &OS, unsigned FileNumber, in addFile() argument
51 unsigned Idx = FileNumber - 1; in addFile()
63 unsigned Offset = FilenameOffset.second; in addFile() local
66 OS.getContext().createTempSymbol("checksum_offset", false); in addFile()
67 Files[Idx].StringTableOffset = Offset; in addFile()
114 Info->ParentFuncIdPlusOne = IAFunc + 1; in recordInlinedCallSiteId()
115 Info->InlinedAt = InlinedAt; in recordInlinedCallSiteId()
119 while (Info->isInlinedCallSite()) { in recordInlinedCallSiteId()
120 InlinedAt = Info->InlinedAt; in recordInlinedCallSiteId()
121 Info = getCVFunctionInfo(Info->getParentFuncId()); in recordInlinedCallSiteId()
122 Info->InlinedAtMap[FuncId] = InlinedAt; in recordInlinedCallSiteId()
138 StrTabFragment = MCCtx->allocFragment<MCDataFragment>(); in getStringTableFragment()
140 StrTabFragment->getContents().push_back('\0'); in getStringTableFragment()
146 SmallVectorImpl<char> &Contents = getStringTableFragment()->getContents(); in addToStringTable()
151 std::make_pair(Insertion.first->first(), Insertion.first->second); in addToStringTable()
160 // A string table offset of zero is always the empty string. in getStringTableOffset()
165 return I->second; in getStringTableOffset()
168 void CodeViewContext::emitStringTable(MCObjectStreamer &OS) { in emitStringTable() argument
169 MCContext &Ctx = OS.getContext(); in emitStringTable()
173 OS.emitInt32(uint32_t(DebugSubsectionKind::StringTable)); in emitStringTable()
174 OS.emitAbsoluteSymbolDiff(StringEnd, StringBegin, 4); in emitStringTable()
175 OS.emitLabel(StringBegin); in emitStringTable()
181 OS.insert(getStringTableFragment()); in emitStringTable()
185 OS.emitValueToAlignment(Align(4), 0); in emitStringTable()
187 OS.emitLabel(StringEnd); in emitStringTable()
190 void CodeViewContext::emitFileChecksums(MCObjectStreamer &OS) { in emitFileChecksums() argument
196 MCContext &Ctx = OS.getContext(); in emitFileChecksums()
200 OS.emitInt32(uint32_t(DebugSubsectionKind::FileChecksums)); in emitFileChecksums()
201 OS.emitAbsoluteSymbolDiff(FileEnd, FileBegin, 4); in emitFileChecksums()
202 OS.emitLabel(FileBegin); in emitFileChecksums()
207 // user-provided file number. Each entry may be a variable number of bytes in emitFileChecksums()
210 OS.emitAssignment(File.ChecksumTableOffset, in emitFileChecksums()
212 CurrentOffset += 4; // String table offset. in emitFileChecksums()
222 OS.emitInt32(File.StringTableOffset); in emitFileChecksums()
227 OS.emitInt32(0); in emitFileChecksums()
230 OS.emitInt8(static_cast<uint8_t>(File.Checksum.size())); in emitFileChecksums()
231 OS.emitInt8(File.ChecksumKind); in emitFileChecksums()
232 OS.emitBytes(toStringRef(File.Checksum)); in emitFileChecksums()
233 OS.emitValueToAlignment(Align(4)); in emitFileChecksums()
236 OS.emitLabel(FileEnd); in emitFileChecksums()
241 // Output checksum table offset of the given file number. It is possible that
242 // not all files have been registered yet, and so the offset cannot be
243 // calculated. In this case a symbol representing the offset is emitted, and
245 void CodeViewContext::emitFileChecksumOffset(MCObjectStreamer &OS, in emitFileChecksumOffset() argument
247 unsigned Idx = FileNo - 1; in emitFileChecksumOffset()
253 OS.emitSymbolValue(Files[Idx].ChecksumTableOffset, 4); in emitFileChecksumOffset()
258 MCSymbolRefExpr::create(Files[Idx].ChecksumTableOffset, OS.getContext()); in emitFileChecksumOffset()
260 OS.emitValueImpl(SRE, 4); in emitFileChecksumOffset()
264 size_t Offset = MCCVLines.size(); in addLineEntry() local
266 {LineEntry.getFunctionId(), {Offset, Offset + 1}}); in addLineEntry()
268 I.first->second.second = Offset + 1; in addLineEntry()
291 auto I = SiteInfo->InlinedAtMap.find(LocationFuncId); in getFunctionLineEntries()
292 if (I != SiteInfo->InlinedAtMap.end()) { in getFunctionLineEntries()
293 MCCVFunctionInfo::LineInfo &IA = I->second; in getFunctionLineEntries()
316 return I->second; in getLineExtent()
328 for (auto &KV : SiteInfo->InlinedAtMap) { in getLineExtentIncludingInlinees()
344 return ArrayRef(&MCCVLines[L], R - L); in getLinesForExtent()
347 void CodeViewContext::emitLineTableForFunction(MCObjectStreamer &OS, in emitLineTableForFunction() argument
351 MCContext &Ctx = OS.getContext(); in emitLineTableForFunction()
355 OS.emitInt32(uint32_t(DebugSubsectionKind::Lines)); in emitLineTableForFunction()
356 OS.emitAbsoluteSymbolDiff(LineEnd, LineBegin, 4); in emitLineTableForFunction()
357 OS.emitLabel(LineBegin); in emitLineTableForFunction()
358 OS.emitCOFFSecRel32(FuncBegin, /*Offset=*/0); in emitLineTableForFunction()
359 OS.emitCOFFSectionIndex(FuncBegin); in emitLineTableForFunction()
366 OS.emitInt16(HaveColumns ? int(LF_HaveColumns) : 0); in emitLineTableForFunction()
367 OS.emitAbsoluteSymbolDiff(FuncEnd, FuncBegin, 4); in emitLineTableForFunction()
371 unsigned CurFileNum = I->getFileNum(); in emitLineTableForFunction()
376 unsigned EntryCount = FileSegEnd - I; in emitLineTableForFunction()
377 OS.AddComment( in emitLineTableForFunction()
380 ->getContents()[Files[CurFileNum - 1].StringTableOffset]) + in emitLineTableForFunction()
382 OS.emitCVFileChecksumOffsetDirective(CurFileNum); in emitLineTableForFunction()
383 OS.emitInt32(EntryCount); in emitLineTableForFunction()
388 OS.emitInt32(SegmentSize); in emitLineTableForFunction()
391 OS.emitAbsoluteSymbolDiff(J->getLabel(), FuncBegin, 4); in emitLineTableForFunction()
392 unsigned LineData = J->getLine(); in emitLineTableForFunction()
393 if (J->isStmt()) in emitLineTableForFunction()
395 OS.emitInt32(LineData); in emitLineTableForFunction()
399 OS.emitInt16(J->getColumn()); in emitLineTableForFunction()
400 OS.emitInt16(0); in emitLineTableForFunction()
405 OS.emitLabel(LineEnd); in emitLineTableForFunction()
438 return ((-Data) << 1) | 1; in encodeSignedNumber()
442 void CodeViewContext::emitInlineLineTableForFunction(MCObjectStreamer &OS, in emitInlineLineTableForFunction() argument
450 auto *F = MCCtx->allocFragment<MCCVInlineLineTableFragment>( in emitInlineLineTableForFunction()
452 OS.insert(F); in emitInlineLineTableForFunction()
456 MCObjectStreamer &OS, in emitDefRange() argument
462 MCCtx->allocFragment<MCCVDefRangeFragment>(Ranges, FixedSizePortion); in emitDefRange()
463 OS.insert(F); in emitDefRange()
476 bool Success = AddrDelta->evaluateKnownAbsolute(Result, Asm); in computeLabelDiff()
498 const MCSection *FirstSec = &Locs.front().getLabel()->getSection(); in encodeInlineLineTable()
500 if (&Loc.getLabel()->getSection() != FirstSec) { in encodeInlineLineTable()
533 size_t MaxBufferSize = MaxRecordLength - InlineSiteSize - AnnotationSize; in encodeInlineLineTable()
541 auto I = SiteInfo->InlinedAtMap.find(Loc.getFunctionId()); in encodeInlineLineTable()
542 if (I != SiteInfo->InlinedAtMap.end()) { in encodeInlineLineTable()
546 CurSourceLoc = I->second; in encodeInlineLineTable()
572 Files[CurSourceLoc.File - 1] in encodeInlineLineTable()
573 .ChecksumTableOffset->getVariableValue()) in encodeInlineLineTable()
574 ->getValue(); in encodeInlineLineTable()
579 int LineDelta = CurSourceLoc.Line - LastSourceLoc.Line; in encodeInlineLineTable()
584 // encoded line delta uses 3 or fewer set bits and the code offset fits in encodeInlineLineTable()
591 // Otherwise use the separate line and code deltas. in encodeInlineLineTable()
613 if (&Loc.getLabel()->getSection() == &LastLabel->getSection()) in encodeInlineLineTable()
628 raw_svector_ostream OS(Contents); in encodeDefRange() local
654 unsigned NumGaps = J - I - 1; in encodeDefRange()
656 support::endian::Writer LEWriter(OS, llvm::endianness::little); in encodeDefRange()
668 // Each record begins with a 2-byte number indicating how large the record in encodeDefRange()
678 OS << FixedSizePortion; in encodeDefRange()
680 // relocation pointing at the offset where the variable becomes live. in encodeDefRange()
682 LEWriter.write<uint32_t>(0); // Fixup for code start. in encodeDefRange()
683 // Make space for a fixup that will record the section index for the code. in encodeDefRange()
691 RangeSize -= Chunk; in encodeDefRange()