blob: 24322d942facc90f8e031b0344dc1b62e18a8037 [file] [log] [blame]
Zachary Turner2f09b502016-04-29 17:28:47 +00001//===- DbiStream.cpp - PDB Dbi Stream (Stream 3) Access -------------------===//
Zachary Turner53a65ba2016-04-26 18:42:34 +00002//
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//===----------------------------------------------------------------------===//
Rui Ueyama90db7882016-06-02 18:20:20 +00009
Adrian McCarthy6b6b8c42017-01-25 22:38:55 +000010#include "llvm/DebugInfo/PDB/Native/DbiStream.h"
Eugene Zelenko570e39a2016-11-23 23:16:32 +000011#include "llvm/ADT/StringRef.h"
12#include "llvm/DebugInfo/MSF/MappedBlockStream.h"
Zachary Turner67c56012017-04-27 16:11:19 +000013#include "llvm/DebugInfo/PDB/Native/DbiModuleDescriptor.h"
Adrian McCarthy6b6b8c42017-01-25 22:38:55 +000014#include "llvm/DebugInfo/PDB/Native/ISectionContribVisitor.h"
15#include "llvm/DebugInfo/PDB/Native/InfoStream.h"
Adrian McCarthy6b6b8c42017-01-25 22:38:55 +000016#include "llvm/DebugInfo/PDB/Native/PDBFile.h"
17#include "llvm/DebugInfo/PDB/Native/RawConstants.h"
18#include "llvm/DebugInfo/PDB/Native/RawError.h"
19#include "llvm/DebugInfo/PDB/Native/RawTypes.h"
Eugene Zelenko570e39a2016-11-23 23:16:32 +000020#include "llvm/DebugInfo/PDB/PDBTypes.h"
Rui Ueyama90db7882016-06-02 18:20:20 +000021#include "llvm/Object/COFF.h"
Zachary Turnerd9dc2822017-03-02 20:52:51 +000022#include "llvm/Support/BinaryStreamArray.h"
23#include "llvm/Support/BinaryStreamReader.h"
Eugene Zelenko570e39a2016-11-23 23:16:32 +000024#include "llvm/Support/Error.h"
25#include <algorithm>
26#include <cstddef>
27#include <cstdint>
Zachary Turner53a65ba2016-04-26 18:42:34 +000028
29using namespace llvm;
Zachary Turner93839cb2016-06-02 05:07:49 +000030using namespace llvm::codeview;
Zachary Turnerbac69d32016-07-22 19:56:05 +000031using namespace llvm::msf;
Zachary Turner2f09b502016-04-29 17:28:47 +000032using namespace llvm::pdb;
Zachary Turner53a65ba2016-04-26 18:42:34 +000033using namespace llvm::support;
34
Zachary Turner93839cb2016-06-02 05:07:49 +000035template <typename ContribType>
Benjamin Kramer4d098922016-07-10 11:28:51 +000036static Error loadSectionContribs(FixedStreamArray<ContribType> &Output,
Zachary Turner120faca2017-02-27 22:11:43 +000037 BinaryStreamReader &Reader) {
Zachary Turner93839cb2016-06-02 05:07:49 +000038 if (Reader.bytesRemaining() % sizeof(ContribType) != 0)
39 return make_error<RawError>(
40 raw_error_code::corrupt_file,
41 "Invalid number of bytes of section contributions");
42
43 uint32_t Count = Reader.bytesRemaining() / sizeof(ContribType);
44 if (auto EC = Reader.readArray(Output, Count))
45 return EC;
46 return Error::success();
47}
48
Zachary Turnera1657a92016-06-08 17:26:39 +000049DbiStream::DbiStream(PDBFile &File, std::unique_ptr<MappedBlockStream> Stream)
Adrian McCarthy6b6b8c42017-01-25 22:38:55 +000050 : Pdb(File), Stream(std::move(Stream)), Header(nullptr) {}
Zachary Turner53a65ba2016-04-26 18:42:34 +000051
Eugene Zelenko570e39a2016-11-23 23:16:32 +000052DbiStream::~DbiStream() = default;
Zachary Turner53a65ba2016-04-26 18:42:34 +000053
Zachary Turner819e77d2016-05-06 20:51:57 +000054Error DbiStream::reload() {
Zachary Turner120faca2017-02-27 22:11:43 +000055 BinaryStreamReader Reader(*Stream);
Zachary Turner6ba65de2016-04-29 17:22:58 +000056
Zachary Turnerb383d622016-07-22 15:46:46 +000057 if (Stream->getLength() < sizeof(DbiStreamHeader))
Zachary Turner819e77d2016-05-06 20:51:57 +000058 return make_error<RawError>(raw_error_code::corrupt_file,
59 "DBI Stream does not contain a header.");
Zachary Turner8dbe3622016-05-27 01:54:44 +000060 if (auto EC = Reader.readObject(Header))
Zachary Turner819e77d2016-05-06 20:51:57 +000061 return make_error<RawError>(raw_error_code::corrupt_file,
62 "DBI Stream does not contain a header.");
Zachary Turner53a65ba2016-04-26 18:42:34 +000063
64 if (Header->VersionSignature != -1)
Zachary Turner819e77d2016-05-06 20:51:57 +000065 return make_error<RawError>(raw_error_code::corrupt_file,
66 "Invalid DBI version signature.");
Zachary Turner53a65ba2016-04-26 18:42:34 +000067
Zachary Turner1822af542016-04-27 23:41:42 +000068 // Require at least version 7, which should be present in all PDBs
69 // produced in the last decade and allows us to avoid having to
70 // special case all kinds of complicated arcane formats.
71 if (Header->VersionHeader < PdbDbiV70)
Zachary Turner93839cb2016-06-02 05:07:49 +000072 return make_error<RawError>(raw_error_code::feature_unsupported,
Zachary Turner819e77d2016-05-06 20:51:57 +000073 "Unsupported DBI version.");
Zachary Turner53a65ba2016-04-26 18:42:34 +000074
Zachary Turnera1657a92016-06-08 17:26:39 +000075 if (Stream->getLength() !=
Zachary Turnerb383d622016-07-22 15:46:46 +000076 sizeof(DbiStreamHeader) + Header->ModiSubstreamSize +
Zachary Turner53a65ba2016-04-26 18:42:34 +000077 Header->SecContrSubstreamSize + Header->SectionMapSize +
78 Header->FileInfoSize + Header->TypeServerSize +
79 Header->OptionalDbgHdrSize + Header->ECSubstreamSize)
Zachary Turner819e77d2016-05-06 20:51:57 +000080 return make_error<RawError>(raw_error_code::corrupt_file,
81 "DBI Length does not equal sum of substreams.");
Zachary Turner53a65ba2016-04-26 18:42:34 +000082
Zachary Turner84c3a8b2016-04-28 20:05:18 +000083 // Only certain substreams are guaranteed to be aligned. Validate
84 // them here.
Zachary Turner1822af542016-04-27 23:41:42 +000085 if (Header->ModiSubstreamSize % sizeof(uint32_t) != 0)
Zachary Turner819e77d2016-05-06 20:51:57 +000086 return make_error<RawError>(raw_error_code::corrupt_file,
87 "DBI MODI substream not aligned.");
Zachary Turner84c3a8b2016-04-28 20:05:18 +000088 if (Header->SecContrSubstreamSize % sizeof(uint32_t) != 0)
Zachary Turner819e77d2016-05-06 20:51:57 +000089 return make_error<RawError>(
90 raw_error_code::corrupt_file,
91 "DBI section contribution substream not aligned.");
Zachary Turner84c3a8b2016-04-28 20:05:18 +000092 if (Header->SectionMapSize % sizeof(uint32_t) != 0)
Zachary Turner819e77d2016-05-06 20:51:57 +000093 return make_error<RawError>(raw_error_code::corrupt_file,
94 "DBI section map substream not aligned.");
Zachary Turner84c3a8b2016-04-28 20:05:18 +000095 if (Header->FileInfoSize % sizeof(uint32_t) != 0)
Zachary Turner819e77d2016-05-06 20:51:57 +000096 return make_error<RawError>(raw_error_code::corrupt_file,
97 "DBI file info substream not aligned.");
Zachary Turner84c3a8b2016-04-28 20:05:18 +000098 if (Header->TypeServerSize % sizeof(uint32_t) != 0)
Zachary Turner819e77d2016-05-06 20:51:57 +000099 return make_error<RawError>(raw_error_code::corrupt_file,
100 "DBI type server substream not aligned.");
Zachary Turner1822af542016-04-27 23:41:42 +0000101
Zachary Turner1eb9a022017-05-04 23:53:29 +0000102 BinaryStreamRef ModInfoSubstream;
103 BinaryStreamRef FileInfoSubstream;
Zachary Turnerd218c262016-07-22 15:46:37 +0000104 if (auto EC =
105 Reader.readStreamRef(ModInfoSubstream, Header->ModiSubstreamSize))
Zachary Turner1de49c92016-05-27 18:47:20 +0000106 return EC;
Zachary Turner84c3a8b2016-04-28 20:05:18 +0000107
Zachary Turner8dbe3622016-05-27 01:54:44 +0000108 if (auto EC = Reader.readStreamRef(SecContrSubstream,
109 Header->SecContrSubstreamSize))
Zachary Turner84c3a8b2016-04-28 20:05:18 +0000110 return EC;
Zachary Turner8dbe3622016-05-27 01:54:44 +0000111 if (auto EC = Reader.readStreamRef(SecMapSubstream, Header->SectionMapSize))
Zachary Turner84c3a8b2016-04-28 20:05:18 +0000112 return EC;
Zachary Turner8dbe3622016-05-27 01:54:44 +0000113 if (auto EC = Reader.readStreamRef(FileInfoSubstream, Header->FileInfoSize))
Zachary Turner84c3a8b2016-04-28 20:05:18 +0000114 return EC;
Zachary Turner819e77d2016-05-06 20:51:57 +0000115 if (auto EC =
Zachary Turner8dbe3622016-05-27 01:54:44 +0000116 Reader.readStreamRef(TypeServerMapSubstream, Header->TypeServerSize))
Zachary Turner84c3a8b2016-04-28 20:05:18 +0000117 return EC;
Zachary Turner8dbe3622016-05-27 01:54:44 +0000118 if (auto EC = Reader.readStreamRef(ECSubstream, Header->ECSubstreamSize))
Zachary Turner6ba65de2016-04-29 17:22:58 +0000119 return EC;
Adrian McCarthy6b6b8c42017-01-25 22:38:55 +0000120 if (auto EC = Reader.readArray(
121 DbgStreams, Header->OptionalDbgHdrSize / sizeof(ulittle16_t)))
Zachary Turner84c3a8b2016-04-28 20:05:18 +0000122 return EC;
123
Zachary Turner1eb9a022017-05-04 23:53:29 +0000124 if (auto EC = Modules.initialize(ModInfoSubstream, FileInfoSubstream))
125 return EC;
126
Zachary Turner93839cb2016-06-02 05:07:49 +0000127 if (auto EC = initializeSectionContributionData())
128 return EC;
Rui Ueyama90db7882016-06-02 18:20:20 +0000129 if (auto EC = initializeSectionHeadersData())
130 return EC;
Zachary Turner93839cb2016-06-02 05:07:49 +0000131 if (auto EC = initializeSectionMapData())
132 return EC;
Rui Ueyamaef2b4882016-06-06 18:39:21 +0000133 if (auto EC = initializeFpoRecords())
134 return EC;
Zachary Turner1822af542016-04-27 23:41:42 +0000135
Zachary Turner6ba65de2016-04-29 17:22:58 +0000136 if (Reader.bytesRemaining() > 0)
Zachary Turner819e77d2016-05-06 20:51:57 +0000137 return make_error<RawError>(raw_error_code::corrupt_file,
138 "Found unexpected bytes in DBI Stream.");
Zachary Turner6ba65de2016-04-29 17:22:58 +0000139
Zachary Turnerfaa554b2016-07-15 22:16:56 +0000140 if (ECSubstream.getLength() > 0) {
Zachary Turner120faca2017-02-27 22:11:43 +0000141 BinaryStreamReader ECReader(ECSubstream);
Zachary Turnerc504ae32017-05-03 15:58:37 +0000142 if (auto EC = ECNames.reload(ECReader))
Zachary Turnerfaa554b2016-07-15 22:16:56 +0000143 return EC;
144 }
Zachary Turner0eace0b2016-05-02 18:09:14 +0000145
Zachary Turner819e77d2016-05-06 20:51:57 +0000146 return Error::success();
Zachary Turner53a65ba2016-04-26 18:42:34 +0000147}
148
Zachary Turner2f09b502016-04-29 17:28:47 +0000149PdbRaw_DbiVer DbiStream::getDbiVersion() const {
Zachary Turner53a65ba2016-04-26 18:42:34 +0000150 uint32_t Value = Header->VersionHeader;
151 return static_cast<PdbRaw_DbiVer>(Value);
152}
153
Zachary Turner2f09b502016-04-29 17:28:47 +0000154uint32_t DbiStream::getAge() const { return Header->Age; }
Zachary Turner53a65ba2016-04-26 18:42:34 +0000155
Rui Ueyama1f6b6e22016-05-13 21:21:53 +0000156uint16_t DbiStream::getPublicSymbolStreamIndex() const {
157 return Header->PublicSymbolStreamIndex;
158}
159
Zachary Turner96e60f72016-05-24 20:31:48 +0000160uint16_t DbiStream::getGlobalSymbolStreamIndex() const {
161 return Header->GlobalSymbolStreamIndex;
162}
163
Zachary Turnerdbeaea72016-07-11 21:45:26 +0000164uint16_t DbiStream::getFlags() const { return Header->Flags; }
165
Zachary Turner2f09b502016-04-29 17:28:47 +0000166bool DbiStream::isIncrementallyLinked() const {
Zachary Turnerb383d622016-07-22 15:46:46 +0000167 return (Header->Flags & DbiFlags::FlagIncrementalMask) != 0;
Zachary Turner53a65ba2016-04-26 18:42:34 +0000168}
169
Zachary Turner2f09b502016-04-29 17:28:47 +0000170bool DbiStream::hasCTypes() const {
Zachary Turnerb383d622016-07-22 15:46:46 +0000171 return (Header->Flags & DbiFlags::FlagHasCTypesMask) != 0;
Zachary Turner53a65ba2016-04-26 18:42:34 +0000172}
173
Zachary Turner2f09b502016-04-29 17:28:47 +0000174bool DbiStream::isStripped() const {
Zachary Turnerb383d622016-07-22 15:46:46 +0000175 return (Header->Flags & DbiFlags::FlagStrippedMask) != 0;
Zachary Turner53a65ba2016-04-26 18:42:34 +0000176}
177
Zachary Turnerdbeaea72016-07-11 21:45:26 +0000178uint16_t DbiStream::getBuildNumber() const { return Header->BuildNumber; }
179
Zachary Turner2f09b502016-04-29 17:28:47 +0000180uint16_t DbiStream::getBuildMajorVersion() const {
Zachary Turnerb383d622016-07-22 15:46:46 +0000181 return (Header->BuildNumber & DbiBuildNo::BuildMajorMask) >>
182 DbiBuildNo::BuildMajorShift;
Zachary Turner53a65ba2016-04-26 18:42:34 +0000183}
184
Zachary Turner2f09b502016-04-29 17:28:47 +0000185uint16_t DbiStream::getBuildMinorVersion() const {
Zachary Turnerb383d622016-07-22 15:46:46 +0000186 return (Header->BuildNumber & DbiBuildNo::BuildMinorMask) >>
187 DbiBuildNo::BuildMinorShift;
Zachary Turner53a65ba2016-04-26 18:42:34 +0000188}
189
Zachary Turnerdbeaea72016-07-11 21:45:26 +0000190uint16_t DbiStream::getPdbDllRbld() const { return Header->PdbDllRbld; }
191
Zachary Turner2f09b502016-04-29 17:28:47 +0000192uint32_t DbiStream::getPdbDllVersion() const { return Header->PdbDllVersion; }
Zachary Turner53a65ba2016-04-26 18:42:34 +0000193
Rui Ueyama0376b1a2016-05-19 18:05:58 +0000194uint32_t DbiStream::getSymRecordStreamIndex() const {
195 return Header->SymRecordStreamIndex;
196}
Zachary Turner53a65ba2016-04-26 18:42:34 +0000197
Zachary Turner2f09b502016-04-29 17:28:47 +0000198PDB_Machine DbiStream::getMachineType() const {
Zachary Turner53a65ba2016-04-26 18:42:34 +0000199 uint16_t Machine = Header->MachineType;
200 return static_cast<PDB_Machine>(Machine);
201}
Zachary Turner1822af542016-04-27 23:41:42 +0000202
Zachary Turner120faca2017-02-27 22:11:43 +0000203FixedStreamArray<object::coff_section> DbiStream::getSectionHeaders() {
Rui Ueyama90db7882016-06-02 18:20:20 +0000204 return SectionHeaders;
205}
206
Zachary Turner120faca2017-02-27 22:11:43 +0000207FixedStreamArray<object::FpoData> DbiStream::getFpoRecords() {
Rui Ueyamaef2b4882016-06-06 18:39:21 +0000208 return FpoRecords;
209}
210
Zachary Turner1eb9a022017-05-04 23:53:29 +0000211const DbiModuleList &DbiStream::modules() const { return Modules; }
212
Zachary Turner120faca2017-02-27 22:11:43 +0000213FixedStreamArray<SecMapEntry> DbiStream::getSectionMap() const {
Zachary Turner93839cb2016-06-02 05:07:49 +0000214 return SectionMap;
215}
216
Eugene Zelenko570e39a2016-11-23 23:16:32 +0000217void DbiStream::visitSectionContributions(
Zachary Turner93839cb2016-06-02 05:07:49 +0000218 ISectionContribVisitor &Visitor) const {
Zachary Turner1bfb9f42017-06-06 23:54:23 +0000219 if (!SectionContribs.empty()) {
220 assert(SectionContribVersion == DbiSecContribVer60);
Zachary Turner93839cb2016-06-02 05:07:49 +0000221 for (auto &SC : SectionContribs)
222 Visitor.visit(SC);
Zachary Turner1bfb9f42017-06-06 23:54:23 +0000223 } else if (!SectionContribs2.empty()) {
224 assert(SectionContribVersion == DbiSecContribV2);
Zachary Turner93839cb2016-06-02 05:07:49 +0000225 for (auto &SC : SectionContribs2)
226 Visitor.visit(SC);
227 }
228}
229
230Error DbiStream::initializeSectionContributionData() {
Zachary Turnerfaa554b2016-07-15 22:16:56 +0000231 if (SecContrSubstream.getLength() == 0)
232 return Error::success();
233
Zachary Turner120faca2017-02-27 22:11:43 +0000234 BinaryStreamReader SCReader(SecContrSubstream);
Zachary Turner695ed562017-02-28 00:04:07 +0000235 if (auto EC = SCReader.readEnum(SectionContribVersion))
Zachary Turner93839cb2016-06-02 05:07:49 +0000236 return EC;
237
238 if (SectionContribVersion == DbiSecContribVer60)
239 return loadSectionContribs<SectionContrib>(SectionContribs, SCReader);
240 if (SectionContribVersion == DbiSecContribV2)
241 return loadSectionContribs<SectionContrib2>(SectionContribs2, SCReader);
242
243 return make_error<RawError>(raw_error_code::feature_unsupported,
244 "Unsupported DBI Section Contribution version");
245}
246
Rui Ueyama90db7882016-06-02 18:20:20 +0000247// Initializes this->SectionHeaders.
248Error DbiStream::initializeSectionHeadersData() {
Zachary Turnerfaa554b2016-07-15 22:16:56 +0000249 if (DbgStreams.size() == 0)
250 return Error::success();
251
Rui Ueyama90db7882016-06-02 18:20:20 +0000252 uint32_t StreamNum = getDebugStreamIndex(DbgHeaderType::SectionHdr);
Zachary Turnerd2b2bfe2016-06-08 00:25:08 +0000253 if (StreamNum >= Pdb.getNumStreams())
254 return make_error<RawError>(raw_error_code::no_stream);
255
Zachary Turnerd66889c2016-07-28 19:12:28 +0000256 auto SHS = MappedBlockStream::createIndexedStream(
Zachary Turner5b74ff32017-06-03 00:33:35 +0000257 Pdb.getMsfLayout(), Pdb.getMsfBuffer(), StreamNum, Pdb.getAllocator());
Rui Ueyama90db7882016-06-02 18:20:20 +0000258
Zachary Turnerd66889c2016-07-28 19:12:28 +0000259 size_t StreamLen = SHS->getLength();
Rui Ueyama90db7882016-06-02 18:20:20 +0000260 if (StreamLen % sizeof(object::coff_section))
261 return make_error<RawError>(raw_error_code::corrupt_file,
262 "Corrupted section header stream.");
263
264 size_t NumSections = StreamLen / sizeof(object::coff_section);
Zachary Turner120faca2017-02-27 22:11:43 +0000265 BinaryStreamReader Reader(*SHS);
Rui Ueyama90db7882016-06-02 18:20:20 +0000266 if (auto EC = Reader.readArray(SectionHeaders, NumSections))
267 return make_error<RawError>(raw_error_code::corrupt_file,
268 "Could not read a bitmap.");
Zachary Turnera1657a92016-06-08 17:26:39 +0000269
Zachary Turnerd66889c2016-07-28 19:12:28 +0000270 SectionHeaderStream = std::move(SHS);
Rui Ueyama90db7882016-06-02 18:20:20 +0000271 return Error::success();
272}
273
Rui Ueyamaef2b4882016-06-06 18:39:21 +0000274// Initializes this->Fpos.
275Error DbiStream::initializeFpoRecords() {
Zachary Turnerfaa554b2016-07-15 22:16:56 +0000276 if (DbgStreams.size() == 0)
277 return Error::success();
278
Rui Ueyamaef2b4882016-06-06 18:39:21 +0000279 uint32_t StreamNum = getDebugStreamIndex(DbgHeaderType::NewFPO);
Reid Kleckner11582c52016-06-17 20:38:01 +0000280
281 // This means there is no FPO data.
Zachary Turnerb383d622016-07-22 15:46:46 +0000282 if (StreamNum == kInvalidStreamIndex)
Reid Kleckner11582c52016-06-17 20:38:01 +0000283 return Error::success();
284
Zachary Turnerd2b2bfe2016-06-08 00:25:08 +0000285 if (StreamNum >= Pdb.getNumStreams())
286 return make_error<RawError>(raw_error_code::no_stream);
287
Zachary Turnerd66889c2016-07-28 19:12:28 +0000288 auto FS = MappedBlockStream::createIndexedStream(
Zachary Turner5b74ff32017-06-03 00:33:35 +0000289 Pdb.getMsfLayout(), Pdb.getMsfBuffer(), StreamNum, Pdb.getAllocator());
Rui Ueyamaef2b4882016-06-06 18:39:21 +0000290
Zachary Turnerd66889c2016-07-28 19:12:28 +0000291 size_t StreamLen = FS->getLength();
Rui Ueyamaef2b4882016-06-06 18:39:21 +0000292 if (StreamLen % sizeof(object::FpoData))
293 return make_error<RawError>(raw_error_code::corrupt_file,
294 "Corrupted New FPO stream.");
295
296 size_t NumRecords = StreamLen / sizeof(object::FpoData);
Zachary Turner120faca2017-02-27 22:11:43 +0000297 BinaryStreamReader Reader(*FS);
Rui Ueyamaef2b4882016-06-06 18:39:21 +0000298 if (auto EC = Reader.readArray(FpoRecords, NumRecords))
299 return make_error<RawError>(raw_error_code::corrupt_file,
300 "Corrupted New FPO stream.");
Zachary Turnerd66889c2016-07-28 19:12:28 +0000301 FpoStream = std::move(FS);
Rui Ueyamaef2b4882016-06-06 18:39:21 +0000302 return Error::success();
303}
304
Zachary Turner93839cb2016-06-02 05:07:49 +0000305Error DbiStream::initializeSectionMapData() {
Zachary Turnerfaa554b2016-07-15 22:16:56 +0000306 if (SecMapSubstream.getLength() == 0)
307 return Error::success();
308
Zachary Turner120faca2017-02-27 22:11:43 +0000309 BinaryStreamReader SMReader(SecMapSubstream);
Zachary Turner93839cb2016-06-02 05:07:49 +0000310 const SecMapHeader *Header;
311 if (auto EC = SMReader.readObject(Header))
312 return EC;
313 if (auto EC = SMReader.readArray(SectionMap, Header->SecCount))
314 return EC;
315 return Error::success();
316}
Zachary Turner84c3a8b2016-04-28 20:05:18 +0000317
Zachary Turnerd3076ab2016-05-25 05:49:48 +0000318uint32_t DbiStream::getDebugStreamIndex(DbgHeaderType Type) const {
Zachary Turnerd218c262016-07-22 15:46:37 +0000319 uint16_t T = static_cast<uint16_t>(Type);
320 if (T >= DbgStreams.size())
Zachary Turnerb383d622016-07-22 15:46:46 +0000321 return kInvalidStreamIndex;
Zachary Turnerd218c262016-07-22 15:46:37 +0000322 return DbgStreams[T];
Zachary Turnerd3076ab2016-05-25 05:49:48 +0000323}