blob: 81e9af06667845ecd7af147c7547637995de2bb0 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
|
#pragma once
#include "Foundation/PDB_Macros.h"
#include "Foundation/PDB_ArrayView.h"
#include "PDB_ErrorCodes.h"
#include "PDB_TPITypes.h"
#include "PDB_DirectMSFStream.h"
#include "PDB_Util.h"
// PDB TPI stream
// https://llvm.org/docs/PDB/TpiStream.html
namespace PDB
{
class RawFile;
class PDB_NO_DISCARD TPIStream
{
public:
TPIStream(void) PDB_NO_EXCEPT;
TPIStream(TPIStream&& other) PDB_NO_EXCEPT;
TPIStream& operator=(TPIStream&& other) PDB_NO_EXCEPT;
explicit TPIStream(const RawFile& file) PDB_NO_EXCEPT;
PDB_NO_DISCARD inline const DirectMSFStream& GetDirectMSFStream(void) const PDB_NO_EXCEPT
{
return m_stream;
}
// Returns the index of the first type, which is not necessarily zero.
PDB_NO_DISCARD inline uint32_t GetFirstTypeIndex(void) const PDB_NO_EXCEPT
{
return m_header.typeIndexBegin;
}
// Returns the index of the last type.
PDB_NO_DISCARD inline uint32_t GetLastTypeIndex(void) const PDB_NO_EXCEPT
{
return m_header.typeIndexEnd;
}
// Returns the number of type records.
PDB_NO_DISCARD inline size_t GetTypeRecordCount(void) const PDB_NO_EXCEPT
{
return m_recordCount;
}
CodeView::TPI::RecordHeader ReadTypeRecordHeader(size_t offset) const PDB_NO_EXCEPT
{
const CodeView::TPI::RecordHeader header = m_stream.ReadAtOffset<CodeView::TPI::RecordHeader>(offset);
return header;
}
template <typename F>
void ForEachTypeRecordHeaderAndOffset(F&& functor) const PDB_NO_EXCEPT
{
// ignore the stream's header
size_t offset = sizeof(TPI::StreamHeader);
while (offset < m_stream.GetSize())
{
const CodeView::TPI::RecordHeader header = ReadTypeRecordHeader(offset);
functor(header, offset);
// position the stream offset at the next record
offset += sizeof(CodeView::TPI::RecordHeader) + header.size - sizeof(uint16_t);
}
}
private:
DirectMSFStream m_stream;
TPI::StreamHeader m_header;
size_t m_recordCount;
PDB_DISABLE_COPY(TPIStream);
};
// Returns whether the given raw file provides a valid TPI stream.
PDB_NO_DISCARD ErrorCode HasValidTPIStream(const RawFile& file) PDB_NO_EXCEPT;
// Creates the TPI stream from a raw file.
PDB_NO_DISCARD TPIStream CreateTPIStream(const RawFile& file) PDB_NO_EXCEPT;
}
|