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/CVRecord.h"
21#include "llvm/DebugInfo/CodeView/TypeIndex.h"
22#include "llvm/Support/FormatAdapters.h"
23
24namespace lldb_private {
25namespace npdb {
26
35
37 // 0-based index of module in PDB
38 uint16_t modi;
39};
40
42 PdbCompilandSymId() = default;
43 PdbCompilandSymId(uint16_t modi, uint32_t offset)
44 : modi(modi), offset(offset) {}
45 // 0-based index of module in PDB
46 uint16_t modi = 0;
47
48 // Offset of symbol's record in module stream. This is
49 // offset by 4 from the CVSymbolArray's notion of offset
50 // due to the debug magic at the beginning of the stream.
51 uint32_t offset = 0;
52};
53
55 PdbGlobalSymId() = default;
58
59 // Offset of symbol's record in globals or publics stream.
60 uint32_t offset = 0;
61
62 // True if this symbol is in the public stream, false if it's in the globals
63 // stream.
64 bool is_public = false;
65};
66
68 PdbTypeSymId() = default;
69 PdbTypeSymId(llvm::codeview::TypeIndex index, bool is_ipi = false)
70 : index(index), is_ipi(is_ipi) {}
71
72 // The index of the of the type in the TPI or IPI stream.
73 llvm::codeview::TypeIndex index;
74
75 // True if this symbol comes from the IPI stream, false if it's from the TPI
76 // stream.
77 bool is_ipi = false;
78};
79
81 // The TypeIndex of the LF_FIELDLIST record.
82 llvm::codeview::TypeIndex index;
83
84 // The offset from the beginning of the LF_FIELDLIST record to this record.
85 uint16_t offset = 0;
86};
87
88class PdbSymUid {
89 uint64_t m_repr = 0;
90
91public:
92 PdbSymUid() = default;
93 PdbSymUid(uint64_t repr) : m_repr(repr) {}
94 PdbSymUid(const PdbCompilandId &cid);
95 PdbSymUid(const PdbCompilandSymId &csid);
96 PdbSymUid(const PdbGlobalSymId &gsid);
97 PdbSymUid(const PdbTypeSymId &tsid);
98 PdbSymUid(const PdbFieldListMemberId &flmid);
99
100 uint64_t toOpaqueId() const { return m_repr; }
101
102 PdbSymUidKind kind() const;
103
107 PdbTypeSymId asTypeSym() const;
109};
110
111template <typename T> uint64_t toOpaqueUid(const T &cid) {
112 return PdbSymUid(cid).toOpaqueId();
113}
114
116 llvm::codeview::CVSymbol sym;
118};
119} // namespace npdb
120} // namespace lldb_private
121
122namespace llvm {
123
124template <> struct format_provider<lldb_private::npdb::PdbCompilandSymId> {
126 raw_ostream &Stream, StringRef Style);
127};
128
129template <> struct format_provider<lldb_private::npdb::PdbGlobalSymId> {
130 static void format(const lldb_private::npdb::PdbGlobalSymId &V,
131 raw_ostream &Stream, StringRef Style);
132};
133
134} // namespace llvm
135
136#endif
PdbGlobalSymId asGlobalSym() const
PdbCompilandId asCompiland() const
PdbCompilandSymId asCompilandSym() const
PdbTypeSymId asTypeSym() const
PdbFieldListMemberId asFieldListMember() const
uint64_t toOpaqueId() const
Definition PdbSymUid.h:100
PdbSymUidKind kind() const
uint64_t toOpaqueUid(const T &cid)
Definition PdbSymUid.h:111
A class that represents a running process on the host machine.
PdbCompilandSymId(uint16_t modi, uint32_t offset)
Definition PdbSymUid.h:43
llvm::codeview::TypeIndex index
Definition PdbSymUid.h:82
PdbGlobalSymId(uint32_t offset, bool is_public)
Definition PdbSymUid.h:56
llvm::codeview::TypeIndex index
Definition PdbSymUid.h:73
PdbTypeSymId(llvm::codeview::TypeIndex index, bool is_ipi=false)
Definition PdbSymUid.h:69
llvm::codeview::CVSymbol sym
Definition PdbSymUid.h:116
static void format(const lldb_private::npdb::PdbCompilandSymId &V, raw_ostream &Stream, StringRef Style)
static void format(const lldb_private::npdb::PdbGlobalSymId &V, raw_ostream &Stream, StringRef Style)