blob: 9e63bc83548fb547bc18abcde88ffc9794482012 [file] [log] [blame]
Bob Haarman653baa22016-10-21 19:43:19 +00001//===- GSI.h - Common Declarations for GlobalsStream and PublicsStream ----===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9//
10// The data structures defined in this file are based on the reference
11// implementation which is available at
12// https://github.com/Microsoft/microsoft-pdb/blob/master/PDB/dbi/gsi.h
13//
14// When you are reading the reference source code, you'd find the
15// information below useful.
16//
17// - ppdb1->m_fMinimalDbgInfo seems to be always true.
18// - SMALLBUCKETS macro is defined.
19//
20// The reference doesn't compile, so I learned just by reading code.
21// It's not guaranteed to be correct.
22//
23//===----------------------------------------------------------------------===//
24
25#ifndef LLVM_LIB_DEBUGINFO_PDB_RAW_GSI_H
26#define LLVM_LIB_DEBUGINFO_PDB_RAW_GSI_H
27
Adrian McCarthy6b6b8c42017-01-25 22:38:55 +000028#include "llvm/DebugInfo/PDB/Native/RawTypes.h"
Zachary Turnerd9dc2822017-03-02 20:52:51 +000029#include "llvm/Support/BinaryStreamArray.h"
Bob Haarman653baa22016-10-21 19:43:19 +000030
31#include "llvm/Support/Endian.h"
32#include "llvm/Support/Error.h"
33
34namespace llvm {
35
Zachary Turner120faca2017-02-27 22:11:43 +000036class BinaryStreamReader;
Bob Haarman653baa22016-10-21 19:43:19 +000037
38namespace pdb {
39
40/// From https://github.com/Microsoft/microsoft-pdb/blob/master/PDB/dbi/gsi.cpp
41static const unsigned IPHR_HASH = 4096;
42
43/// Header of the hash tables found in the globals and publics sections.
44/// Based on GSIHashHeader in
45/// https://github.com/Microsoft/microsoft-pdb/blob/master/PDB/dbi/gsi.h
46struct GSIHashHeader {
47 enum : unsigned {
48 HdrSignature = ~0U,
49 HdrVersion = 0xeffe0000 + 19990810,
50 };
51 support::ulittle32_t VerSignature;
52 support::ulittle32_t VerHdr;
53 support::ulittle32_t HrSize;
54 support::ulittle32_t NumBuckets;
55};
56
Zachary Turner120faca2017-02-27 22:11:43 +000057Error readGSIHashBuckets(FixedStreamArray<support::ulittle32_t> &HashBuckets,
Zachary Turneraf299ea2017-02-25 00:44:30 +000058 const GSIHashHeader *HashHdr,
Zachary Turner120faca2017-02-27 22:11:43 +000059 BinaryStreamReader &Reader);
60Error readGSIHashHeader(const GSIHashHeader *&HashHdr,
61 BinaryStreamReader &Reader);
62Error readGSIHashRecords(FixedStreamArray<PSHashRecord> &HashRecords,
63 const GSIHashHeader *HashHdr,
64 BinaryStreamReader &Reader);
Bob Haarman653baa22016-10-21 19:43:19 +000065}
66}
67
68#endif