1 //===- PDBExtras.h - helper functions and classes for PDBs ------*- 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 
9 #ifndef LLVM_DEBUGINFO_PDB_PDBEXTRAS_H
10 #define LLVM_DEBUGINFO_PDB_PDBEXTRAS_H
11 
12 #include "llvm/ADT/StringRef.h"
13 #include "llvm/DebugInfo/CodeView/CodeView.h"
14 #include "llvm/DebugInfo/PDB/PDBTypes.h"
15 #include "llvm/Support/raw_ostream.h"
16 #include <cstdint>
17 #include <unordered_map>
18 
19 namespace llvm {
20 
21 namespace pdb {
22 
23 using TagStats = std::unordered_map<PDB_SymType, int>;
24 
25 raw_ostream &operator<<(raw_ostream &OS, const PDB_VariantType &Value);
26 raw_ostream &operator<<(raw_ostream &OS, const PDB_CallingConv &Conv);
27 raw_ostream &operator<<(raw_ostream &OS, const PDB_BuiltinType &Type);
28 raw_ostream &operator<<(raw_ostream &OS, const PDB_DataKind &Data);
29 raw_ostream &operator<<(raw_ostream &OS,
30                         const llvm::codeview::CPURegister &CpuReg);
31 raw_ostream &operator<<(raw_ostream &OS, const PDB_LocType &Loc);
32 raw_ostream &operator<<(raw_ostream &OS, const codeview::ThunkOrdinal &Thunk);
33 raw_ostream &operator<<(raw_ostream &OS, const PDB_Checksum &Checksum);
34 raw_ostream &operator<<(raw_ostream &OS, const PDB_Lang &Lang);
35 raw_ostream &operator<<(raw_ostream &OS, const PDB_SymType &Tag);
36 raw_ostream &operator<<(raw_ostream &OS, const PDB_MemberAccess &Access);
37 raw_ostream &operator<<(raw_ostream &OS, const PDB_UdtType &Type);
38 raw_ostream &operator<<(raw_ostream &OS, const PDB_Machine &Machine);
39 
40 raw_ostream &operator<<(raw_ostream &OS, const Variant &Value);
41 raw_ostream &operator<<(raw_ostream &OS, const VersionInfo &Version);
42 raw_ostream &operator<<(raw_ostream &OS, const TagStats &Stats);
43 
44 raw_ostream& dumpPDBSourceCompression(raw_ostream& OS, uint32_t Compression);
45 
46 template <typename T>
47 void dumpSymbolField(raw_ostream &OS, StringRef Name, T Value, int Indent) {
48   OS << "\n";
49   OS.indent(Indent);
50   OS << Name << ": " << Value;
51 }
52 
53 } // end namespace pdb
54 
55 } // end namespace llvm
56 
57 #endif // LLVM_DEBUGINFO_PDB_PDBEXTRAS_H
58