2016-04-28 07:41:42 +08:00
|
|
|
//===- ModInfo.cpp - PDB module information -------------------------------===//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2017-01-26 06:38:55 +08:00
|
|
|
#include "llvm/DebugInfo/PDB/Native/ModInfo.h"
|
2017-02-25 08:33:34 +08:00
|
|
|
#include "llvm/DebugInfo/MSF/BinaryStreamReader.h"
|
2017-01-26 06:38:55 +08:00
|
|
|
#include "llvm/DebugInfo/PDB/Native/RawTypes.h"
|
2016-04-28 07:41:42 +08:00
|
|
|
#include "llvm/Support/Endian.h"
|
2016-11-24 07:16:32 +08:00
|
|
|
#include "llvm/Support/Error.h"
|
|
|
|
#include "llvm/Support/MathExtras.h"
|
|
|
|
#include <cstdint>
|
2016-04-28 07:41:42 +08:00
|
|
|
|
|
|
|
using namespace llvm;
|
2016-04-30 01:28:47 +08:00
|
|
|
using namespace llvm::pdb;
|
2016-04-28 07:41:42 +08:00
|
|
|
using namespace llvm::support;
|
|
|
|
|
2016-11-24 07:16:32 +08:00
|
|
|
ModInfo::ModInfo() = default;
|
2016-04-28 07:41:42 +08:00
|
|
|
|
2016-11-24 07:16:32 +08:00
|
|
|
ModInfo::ModInfo(const ModInfo &Info) = default;
|
2016-04-28 07:41:42 +08:00
|
|
|
|
2016-11-24 07:16:32 +08:00
|
|
|
ModInfo::~ModInfo() = default;
|
2016-04-28 07:41:42 +08:00
|
|
|
|
2017-02-28 06:11:43 +08:00
|
|
|
Error ModInfo::initialize(BinaryStreamRef Stream, ModInfo &Info) {
|
|
|
|
BinaryStreamReader Reader(Stream);
|
2016-05-28 13:21:57 +08:00
|
|
|
if (auto EC = Reader.readObject(Info.Layout))
|
|
|
|
return EC;
|
|
|
|
|
2017-02-28 06:11:43 +08:00
|
|
|
if (auto EC = Reader.readCString(Info.ModuleName))
|
2016-05-28 13:21:57 +08:00
|
|
|
return EC;
|
|
|
|
|
2017-02-28 06:11:43 +08:00
|
|
|
if (auto EC = Reader.readCString(Info.ObjFileName))
|
2016-05-28 13:21:57 +08:00
|
|
|
return EC;
|
|
|
|
return Error::success();
|
|
|
|
}
|
|
|
|
|
2016-07-22 23:46:46 +08:00
|
|
|
bool ModInfo::hasECInfo() const {
|
|
|
|
return (Layout->Flags & ModInfoFlags::HasECFlagMask) != 0;
|
|
|
|
}
|
2016-04-28 07:41:42 +08:00
|
|
|
|
|
|
|
uint16_t ModInfo::getTypeServerIndex() const {
|
2016-07-22 23:46:46 +08:00
|
|
|
return (Layout->Flags & ModInfoFlags::TypeServerIndexMask) >>
|
|
|
|
ModInfoFlags::TypeServerIndexShift;
|
2016-04-28 07:41:42 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
uint16_t ModInfo::getModuleStreamIndex() const { return Layout->ModDiStream; }
|
|
|
|
|
|
|
|
uint32_t ModInfo::getSymbolDebugInfoByteSize() const {
|
|
|
|
return Layout->SymBytes;
|
|
|
|
}
|
|
|
|
|
|
|
|
uint32_t ModInfo::getLineInfoByteSize() const { return Layout->LineBytes; }
|
|
|
|
|
|
|
|
uint32_t ModInfo::getC13LineInfoByteSize() const { return Layout->C13Bytes; }
|
|
|
|
|
|
|
|
uint32_t ModInfo::getNumberOfFiles() const { return Layout->NumFiles; }
|
|
|
|
|
|
|
|
uint32_t ModInfo::getSourceFileNameIndex() const {
|
|
|
|
return Layout->SrcFileNameNI;
|
|
|
|
}
|
|
|
|
|
|
|
|
uint32_t ModInfo::getPdbFilePathNameIndex() const {
|
|
|
|
return Layout->PdbFilePathNI;
|
|
|
|
}
|
|
|
|
|
2016-05-27 09:54:44 +08:00
|
|
|
StringRef ModInfo::getModuleName() const { return ModuleName; }
|
2016-04-28 07:41:42 +08:00
|
|
|
|
2016-05-27 09:54:44 +08:00
|
|
|
StringRef ModInfo::getObjFileName() const { return ObjFileName; }
|
2016-04-28 07:41:42 +08:00
|
|
|
|
2016-05-27 09:54:44 +08:00
|
|
|
uint32_t ModInfo::getRecordLength() const {
|
|
|
|
uint32_t M = ModuleName.str().size() + 1;
|
|
|
|
uint32_t O = ObjFileName.str().size() + 1;
|
2016-07-22 23:46:46 +08:00
|
|
|
uint32_t Size = sizeof(ModuleInfoHeader) + M + O;
|
2016-11-24 07:16:32 +08:00
|
|
|
Size = alignTo(Size, 4);
|
2016-05-27 09:54:44 +08:00
|
|
|
return Size;
|
2016-04-28 07:41:42 +08:00
|
|
|
}
|