Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-10 08:43:39

0001 //===- DebugInlineeLinesSubsection.h ----------------------------*- C++ -*-===//
0002 //
0003 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
0004 // See https://llvm.org/LICENSE.txt for license information.
0005 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
0006 //
0007 //===----------------------------------------------------------------------===//
0008 
0009 #ifndef LLVM_DEBUGINFO_CODEVIEW_DEBUGINLINEELINESSUBSECTION_H
0010 #define LLVM_DEBUGINFO_CODEVIEW_DEBUGINLINEELINESSUBSECTION_H
0011 
0012 #include "llvm/ADT/StringRef.h"
0013 #include "llvm/DebugInfo/CodeView/CodeView.h"
0014 #include "llvm/DebugInfo/CodeView/DebugSubsection.h"
0015 #include "llvm/DebugInfo/CodeView/TypeIndex.h"
0016 #include "llvm/Support/BinaryStreamArray.h"
0017 #include "llvm/Support/BinaryStreamReader.h"
0018 #include "llvm/Support/BinaryStreamRef.h"
0019 #include "llvm/Support/Endian.h"
0020 #include "llvm/Support/Error.h"
0021 #include <cstdint>
0022 #include <vector>
0023 
0024 namespace llvm {
0025 
0026 namespace codeview {
0027 
0028 class DebugChecksumsSubsection;
0029 
0030 enum class InlineeLinesSignature : uint32_t {
0031   Normal,    // CV_INLINEE_SOURCE_LINE_SIGNATURE
0032   ExtraFiles // CV_INLINEE_SOURCE_LINE_SIGNATURE_EX
0033 };
0034 
0035 struct InlineeSourceLineHeader {
0036   TypeIndex Inlinee;                  // ID of the function that was inlined.
0037   support::ulittle32_t FileID;        // Offset into FileChecksums subsection.
0038   support::ulittle32_t SourceLineNum; // First line of inlined code.
0039                                       // If extra files present:
0040                                       //   ulittle32_t ExtraFileCount;
0041                                       //   ulittle32_t Files[];
0042 };
0043 
0044 struct InlineeSourceLine {
0045   const InlineeSourceLineHeader *Header;
0046   FixedStreamArray<support::ulittle32_t> ExtraFiles;
0047 };
0048 
0049 } // end namespace codeview
0050 
0051 template <> struct VarStreamArrayExtractor<codeview::InlineeSourceLine> {
0052   Error operator()(BinaryStreamRef Stream, uint32_t &Len,
0053                    codeview::InlineeSourceLine &Item);
0054 
0055   bool HasExtraFiles = false;
0056 };
0057 
0058 namespace codeview {
0059 
0060 class DebugInlineeLinesSubsectionRef final : public DebugSubsectionRef {
0061   using LinesArray = VarStreamArray<InlineeSourceLine>;
0062   using Iterator = LinesArray::Iterator;
0063 
0064 public:
0065   DebugInlineeLinesSubsectionRef();
0066 
0067   static bool classof(const DebugSubsectionRef *S) {
0068     return S->kind() == DebugSubsectionKind::InlineeLines;
0069   }
0070 
0071   Error initialize(BinaryStreamReader Reader);
0072   Error initialize(BinaryStreamRef Section) {
0073     return initialize(BinaryStreamReader(Section));
0074   }
0075 
0076   bool valid() const { return Lines.valid(); }
0077   bool hasExtraFiles() const;
0078 
0079   Iterator begin() const { return Lines.begin(); }
0080   Iterator end() const { return Lines.end(); }
0081 
0082 private:
0083   InlineeLinesSignature Signature;
0084   LinesArray Lines;
0085 };
0086 
0087 class DebugInlineeLinesSubsection final : public DebugSubsection {
0088 public:
0089   struct Entry {
0090     std::vector<support::ulittle32_t> ExtraFiles;
0091     InlineeSourceLineHeader Header;
0092   };
0093 
0094   DebugInlineeLinesSubsection(DebugChecksumsSubsection &Checksums,
0095                               bool HasExtraFiles = false);
0096 
0097   static bool classof(const DebugSubsection *S) {
0098     return S->kind() == DebugSubsectionKind::InlineeLines;
0099   }
0100 
0101   Error commit(BinaryStreamWriter &Writer) const override;
0102   uint32_t calculateSerializedSize() const override;
0103 
0104   void addInlineSite(TypeIndex FuncId, StringRef FileName, uint32_t SourceLine);
0105   void addExtraFile(StringRef FileName);
0106 
0107   bool hasExtraFiles() const { return HasExtraFiles; }
0108   void setHasExtraFiles(bool Has) { HasExtraFiles = Has; }
0109 
0110   std::vector<Entry>::const_iterator begin() const { return Entries.begin(); }
0111   std::vector<Entry>::const_iterator end() const { return Entries.end(); }
0112 
0113 private:
0114   DebugChecksumsSubsection &Checksums;
0115   bool HasExtraFiles = false;
0116   uint32_t ExtraFileCount = 0;
0117   std::vector<Entry> Entries;
0118 };
0119 
0120 } // end namespace codeview
0121 
0122 } // end namespace llvm
0123 
0124 #endif // LLVM_DEBUGINFO_CODEVIEW_DEBUGINLINEELINESSUBSECTION_H