LLDB  mainline
PdbSymUid.h
Go to the documentation of this file.
1 //===-- PdbSymUid.h ---------------------------------------------*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 // A unique identification scheme for Pdb records.
9 // The scheme is to partition a 64-bit integer into an 8-bit tag field, which
10 // will contain some value from the PDB_SymType enumeration. The format of the
11 // other 48-bits depend on the tag, but must be sufficient to locate the
12 // corresponding entry in the underlying PDB file quickly. For example, for
13 // a compile unit, we use 2 bytes to represent the index, which allows fast
14 // access to the compile unit's information.
15 //===----------------------------------------------------------------------===//
16 
17 #ifndef LLDB_SOURCE_PLUGINS_SYMBOLFILE_NATIVEPDB_PDBSYMUID_H
18 #define LLDB_SOURCE_PLUGINS_SYMBOLFILE_NATIVEPDB_PDBSYMUID_H
19 
20 #include "llvm/DebugInfo/CodeView/SymbolRecord.h"
21 #include "llvm/DebugInfo/PDB/PDBTypes.h"
22 #include "llvm/Support/Compiler.h"
23 
25 #include "lldb/lldb-types.h"
26 
27 namespace lldb_private {
28 namespace npdb {
29 
30 enum class PdbSymUidKind : uint8_t {
31  Compiland,
33  PublicSym,
34  GlobalSym,
35  Type,
37 };
38 
40  // 0-based index of module in PDB
42 };
43 
45  PdbCompilandSymId() = default;
47  : modi(modi), offset(offset) {}
48  // 0-based index of module in PDB
50 
51  // Offset of symbol's record in module stream. This is
52  // offset by 4 from the CVSymbolArray's notion of offset
53  // due to the debug magic at the beginning of the stream.
55 };
56 
58  PdbGlobalSymId() = default;
61 
62  // Offset of symbol's record in globals or publics stream.
64 
65  // True if this symbol is in the public stream, false if it's in the globals
66  // stream.
67  bool is_public = false;
68 };
69 
70 struct PdbTypeSymId {
71  PdbTypeSymId() = default;
72  PdbTypeSymId(llvm::codeview::TypeIndex index, bool is_ipi = false)
73  : index(index), is_ipi(is_ipi) {}
74 
75  // The index of the of the type in the TPI or IPI stream.
76  llvm::codeview::TypeIndex index;
77 
78  // True if this symbol comes from the IPI stream, false if it's from the TPI
79  // stream.
80  bool is_ipi = false;
81 };
82 
84  // The TypeIndex of the LF_FIELDLIST record.
85  llvm::codeview::TypeIndex index;
86 
87  // The offset from the beginning of the LF_FIELDLIST record to this record.
89 };
90 
91 class PdbSymUid {
92  uint64_t m_repr = 0;
93 
94 public:
95  PdbSymUid() = default;
96  PdbSymUid(uint64_t repr) : m_repr(repr) {}
97  PdbSymUid(const PdbCompilandId &cid);
98  PdbSymUid(const PdbCompilandSymId &csid);
99  PdbSymUid(const PdbGlobalSymId &gsid);
100  PdbSymUid(const PdbTypeSymId &tsid);
101  PdbSymUid(const PdbFieldListMemberId &flmid);
102 
103  uint64_t toOpaqueId() const { return m_repr; }
104 
105  PdbSymUidKind kind() const;
106 
107  PdbCompilandId asCompiland() const;
109  PdbGlobalSymId asGlobalSym() const;
110  PdbTypeSymId asTypeSym() const;
112 };
113 
114 template <typename T> uint64_t toOpaqueUid(const T &cid) {
115  return PdbSymUid(cid).toOpaqueId();
116 }
117 
118 struct SymbolAndUid {
119  llvm::codeview::CVSymbol sym;
121 };
122 } // namespace npdb
123 } // namespace lldb_private
124 
125 #endif
lldb_private::npdb::PdbSymUidKind::Type
@ Type
lldb_private::npdb::PdbSymUid::asTypeSym
PdbTypeSymId asTypeSym() const
Definition: PdbSymUid.cpp:144
lldb_private::npdb::PdbTypeSymId::PdbTypeSymId
PdbTypeSymId(llvm::codeview::TypeIndex index, bool is_ipi=false)
Definition: PdbSymUid.h:72
lldb_private::npdb::SymbolAndUid::uid
PdbSymUid uid
Definition: PdbSymUid.h:120
lldb_private::npdb::PdbCompilandSymId::PdbCompilandSymId
PdbCompilandSymId(uint16_t modi, uint32_t offset)
Definition: PdbSymUid.h:46
lldb_private::npdb::PdbSymUid::asCompilandSym
PdbCompilandSymId asCompilandSym() const
Definition: PdbSymUid.cpp:125
lldb_private::npdb::PdbCompilandSymId
Definition: PdbSymUid.h:44
lldb_private::npdb::PdbTypeSymId::index
llvm::codeview::TypeIndex index
Definition: PdbSymUid.h:76
lldb_private::npdb::PdbSymUidKind::FieldListMember
@ FieldListMember
lldb_private::npdb::PdbCompilandSymId::modi
uint16_t modi
Definition: PdbSymUid.h:49
lldb_private::npdb::PdbGlobalSymId::offset
uint32_t offset
Definition: PdbSymUid.h:63
lldb_private::npdb::SymbolAndUid::sym
llvm::codeview::CVSymbol sym
Definition: PdbSymUid.h:119
lldb_private::npdb::PdbSymUidKind::Compiland
@ Compiland
lldb_private::npdb::PdbSymUidKind::CompilandSym
@ CompilandSym
lldb_private::npdb::toOpaqueUid
uint64_t toOpaqueUid(const T &cid)
Definition: PdbSymUid.h:114
lldb_private::npdb::PdbSymUid::toOpaqueId
uint64_t toOpaqueId() const
Definition: PdbSymUid.h:103
LLDBAssert.h
lldb_private::npdb::PdbGlobalSymId
Definition: PdbSymUid.h:57
lldb_private::npdb::PdbSymUid::m_repr
uint64_t m_repr
Definition: PdbSymUid.h:92
lldb_private::npdb::PdbGlobalSymId::PdbGlobalSymId
PdbGlobalSymId()=default
lldb_private::npdb::PdbFieldListMemberId
Definition: PdbSymUid.h:83
lldb_private::npdb::PdbTypeSymId
Definition: PdbSymUid.h:70
lldb_private::npdb::PdbCompilandSymId::offset
uint32_t offset
Definition: PdbSymUid.h:54
lldb_private::npdb::PdbGlobalSymId::is_public
bool is_public
Definition: PdbSymUid.h:67
lldb_private::npdb::PdbSymUid::asFieldListMember
PdbFieldListMemberId asFieldListMember() const
Definition: PdbSymUid.cpp:153
lldb_private::npdb::PdbSymUidKind::GlobalSym
@ GlobalSym
lldb_private::npdb::PdbSymUid::PdbSymUid
PdbSymUid(uint64_t repr)
Definition: PdbSymUid.h:96
lldb_private::npdb::PdbTypeSymId::is_ipi
bool is_ipi
Definition: PdbSymUid.h:80
lldb_private::npdb::PdbCompilandId
Definition: PdbSymUid.h:39
lldb_private::npdb::PdbSymUidKind
PdbSymUidKind
Definition: PdbSymUid.h:30
lldb_private::npdb::PdbFieldListMemberId::offset
uint16_t offset
Definition: PdbSymUid.h:88
lldb-types.h
lldb_private::npdb::PdbTypeSymId::PdbTypeSymId
PdbTypeSymId()=default
lldb_private::npdb::PdbSymUidKind::PublicSym
@ PublicSym
uint32_t
lldb_private::npdb::PdbCompilandId::modi
uint16_t modi
Definition: PdbSymUid.h:41
uint16_t
lldb_private::npdb::PdbSymUid::kind
PdbSymUidKind kind() const
Definition: PdbSymUid.cpp:112
lldb_private::npdb::PdbFieldListMemberId::index
llvm::codeview::TypeIndex index
Definition: PdbSymUid.h:85
lldb_private::npdb::PdbCompilandSymId::PdbCompilandSymId
PdbCompilandSymId()=default
lldb_private::npdb::PdbGlobalSymId::PdbGlobalSymId
PdbGlobalSymId(uint32_t offset, bool is_public)
Definition: PdbSymUid.h:59
lldb_private
A class that represents a running process on the host machine.
Definition: SBCommandInterpreterRunOptions.h:16
lldb_private::npdb::PdbSymUid::asGlobalSym
PdbGlobalSymId asGlobalSym() const
Definition: PdbSymUid.cpp:134
lldb_private::npdb::PdbSymUid::PdbSymUid
PdbSymUid()=default
lldb_private::npdb::PdbSymUid
Definition: PdbSymUid.h:91
lldb_private::npdb::PdbSymUid::asCompiland
PdbCompilandId asCompiland() const
Definition: PdbSymUid.cpp:117
lldb_private::npdb::SymbolAndUid
Definition: PdbSymUid.h:118