Files
archived-llvm/include/llvm/DebugInfo/CodeView/ModuleDebugInlineeLinesFragment.h
Zachary Turner ff94599664 [CodeView] Use actual strings for dealing with checksums and lines.
The raw CodeView format references strings by "offsets", but it's
confusing what table the offset refers to.  In the case of line
number information, it's an offset into a buffer of records,
and an indirection is required to get another offset into a
different table to find the final string.  And in the case of
checksum information, there is no indirection, and the offset
refers directly to the location of the string in another buffer.

This would be less confusing if we always just referred to the
strings by their value, and have the library be smart enough
to correctly resolve the offsets on its own from the right
location.

This patch makes that possible.  When either reading or writing,
all the user deals with are strings, and the library does the
appropriate translations behind the scenes.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@302053 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-03 17:11:40 +00:00

108 lines
3.3 KiB
C++

//===- ModuleDebugInlineeLinesFragment.h ------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#ifndef LLVM_DEBUGINFO_CODEVIEW_MODULEDEBUGINLINEELINESFRAGMENT_H
#define LLVM_DEBUGINFO_CODEVIEW_MODULEDEBUGINLINEELINESFRAGMENT_H
#include "llvm/DebugInfo/CodeView/Line.h"
#include "llvm/DebugInfo/CodeView/ModuleDebugFragment.h"
#include "llvm/Support/BinaryStreamArray.h"
#include "llvm/Support/BinaryStreamReader.h"
#include "llvm/Support/Error.h"
namespace llvm {
namespace codeview {
class ModuleDebugInlineeLineFragmentRef;
class ModuleDebugFileChecksumFragment;
class StringTable;
enum class InlineeLinesSignature : uint32_t {
Normal, // CV_INLINEE_SOURCE_LINE_SIGNATURE
ExtraFiles // CV_INLINEE_SOURCE_LINE_SIGNATURE_EX
};
struct InlineeSourceLineHeader {
TypeIndex Inlinee; // ID of the function that was inlined.
support::ulittle32_t FileID; // Offset into FileChecksums subsection.
support::ulittle32_t SourceLineNum; // First line of inlined code.
// If extra files present:
// ulittle32_t ExtraFileCount;
// ulittle32_t Files[];
};
struct InlineeSourceLine {
const InlineeSourceLineHeader *Header;
FixedStreamArray<support::ulittle32_t> ExtraFiles;
};
}
template <> struct VarStreamArrayExtractor<codeview::InlineeSourceLine> {
typedef bool ContextType;
static Error extract(BinaryStreamRef Stream, uint32_t &Len,
codeview::InlineeSourceLine &Item, bool HasExtraFiles);
};
namespace codeview {
class ModuleDebugInlineeLineFragmentRef final : public ModuleDebugFragmentRef {
typedef VarStreamArray<InlineeSourceLine> LinesArray;
typedef LinesArray::Iterator Iterator;
public:
ModuleDebugInlineeLineFragmentRef();
static bool classof(const ModuleDebugFragmentRef *S) {
return S->kind() == ModuleDebugFragmentKind::InlineeLines;
}
Error initialize(BinaryStreamReader Reader);
bool hasExtraFiles() const;
Iterator begin() const { return Lines.begin(); }
Iterator end() const { return Lines.end(); }
private:
InlineeLinesSignature Signature;
VarStreamArray<InlineeSourceLine> Lines;
};
class ModuleDebugInlineeLineFragment final : public ModuleDebugFragment {
public:
ModuleDebugInlineeLineFragment(ModuleDebugFileChecksumFragment &Checksums,
StringTable &Strings, bool HasExtraFiles);
static bool classof(const ModuleDebugFragment *S) {
return S->kind() == ModuleDebugFragmentKind::InlineeLines;
}
Error commit(BinaryStreamWriter &Writer) override;
uint32_t calculateSerializedLength() override;
void addInlineSite(TypeIndex FuncId, StringRef FileName, uint32_t SourceLine);
void addExtraFile(StringRef FileName);
private:
ModuleDebugFileChecksumFragment &Checksums;
StringTable &Strings;
bool HasExtraFiles = false;
uint32_t ExtraFileCount = 0;
struct Entry {
std::vector<support::ulittle32_t> ExtraFiles;
InlineeSourceLineHeader Header;
};
std::vector<Entry> Entries;
};
}
}
#endif