Path: blob/main/contrib/llvm-project/lldb/source/Plugins/SymbolFile/NativePDB/PdbSymUid.h
39642 views
//===-- PdbSymUid.h ---------------------------------------------*- C++ -*-===//1//2// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.3// See https://llvm.org/LICENSE.txt for license information.4// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception5//6//===----------------------------------------------------------------------===//7// A unique identification scheme for Pdb records.8// The scheme is to partition a 64-bit integer into an 8-bit tag field, which9// will contain some value from the PDB_SymType enumeration. The format of the10// other 48-bits depend on the tag, but must be sufficient to locate the11// corresponding entry in the underlying PDB file quickly. For example, for12// a compile unit, we use 2 bytes to represent the index, which allows fast13// access to the compile unit's information.14//===----------------------------------------------------------------------===//1516#ifndef LLDB_SOURCE_PLUGINS_SYMBOLFILE_NATIVEPDB_PDBSYMUID_H17#define LLDB_SOURCE_PLUGINS_SYMBOLFILE_NATIVEPDB_PDBSYMUID_H1819#include "llvm/DebugInfo/CodeView/SymbolRecord.h"20#include "llvm/DebugInfo/PDB/PDBTypes.h"21#include "llvm/Support/Compiler.h"2223#include "lldb/Utility/LLDBAssert.h"24#include "lldb/lldb-types.h"2526namespace lldb_private {27namespace npdb {2829enum class PdbSymUidKind : uint8_t {30Compiland,31CompilandSym,32PublicSym,33GlobalSym,34Type,35FieldListMember36};3738struct PdbCompilandId {39// 0-based index of module in PDB40uint16_t modi;41};4243struct PdbCompilandSymId {44PdbCompilandSymId() = default;45PdbCompilandSymId(uint16_t modi, uint32_t offset)46: modi(modi), offset(offset) {}47// 0-based index of module in PDB48uint16_t modi = 0;4950// Offset of symbol's record in module stream. This is51// offset by 4 from the CVSymbolArray's notion of offset52// due to the debug magic at the beginning of the stream.53uint32_t offset = 0;54};5556struct PdbGlobalSymId {57PdbGlobalSymId() = default;58PdbGlobalSymId(uint32_t offset, bool is_public)59: offset(offset), is_public(is_public) {}6061// Offset of symbol's record in globals or publics stream.62uint32_t offset = 0;6364// True if this symbol is in the public stream, false if it's in the globals65// stream.66bool is_public = false;67};6869struct PdbTypeSymId {70PdbTypeSymId() = default;71PdbTypeSymId(llvm::codeview::TypeIndex index, bool is_ipi = false)72: index(index), is_ipi(is_ipi) {}7374// The index of the of the type in the TPI or IPI stream.75llvm::codeview::TypeIndex index;7677// True if this symbol comes from the IPI stream, false if it's from the TPI78// stream.79bool is_ipi = false;80};8182struct PdbFieldListMemberId {83// The TypeIndex of the LF_FIELDLIST record.84llvm::codeview::TypeIndex index;8586// The offset from the beginning of the LF_FIELDLIST record to this record.87uint16_t offset = 0;88};8990class PdbSymUid {91uint64_t m_repr = 0;9293public:94PdbSymUid() = default;95PdbSymUid(uint64_t repr) : m_repr(repr) {}96PdbSymUid(const PdbCompilandId &cid);97PdbSymUid(const PdbCompilandSymId &csid);98PdbSymUid(const PdbGlobalSymId &gsid);99PdbSymUid(const PdbTypeSymId &tsid);100PdbSymUid(const PdbFieldListMemberId &flmid);101102uint64_t toOpaqueId() const { return m_repr; }103104PdbSymUidKind kind() const;105106PdbCompilandId asCompiland() const;107PdbCompilandSymId asCompilandSym() const;108PdbGlobalSymId asGlobalSym() const;109PdbTypeSymId asTypeSym() const;110PdbFieldListMemberId asFieldListMember() const;111};112113template <typename T> uint64_t toOpaqueUid(const T &cid) {114return PdbSymUid(cid).toOpaqueId();115}116117struct SymbolAndUid {118llvm::codeview::CVSymbol sym;119PdbSymUid uid;120};121} // namespace npdb122} // namespace lldb_private123124#endif125126127