1 //===- DIAExtras.h - Helper classes and functions for accessing DIA C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // Defines helper types, classes, and functions for working with DIA.
12 //===----------------------------------------------------------------------===//
14 #ifndef LLVM_TOOLS_LLVMPDBDUMP_DIAEXTRAS_H
15 #define LLVM_TOOLS_LLVMPDBDUMP_DIAEXTRAS_H
17 #include "llvm/ADT/SmallString.h"
18 #include "llvm/Support/raw_ostream.h"
20 #include "COMExtras.h"
26 typedef llvm::SmallString<16> DIAString;
28 template <class T> class DIAResult {
30 DIAResult() : IsValid(false) {}
31 DIAResult(const T &ResultValue) : Result(ResultValue), IsValid(true) {}
33 bool hasValue() const { return IsValid; }
34 T value() const { return Result; }
36 void dump(StringRef Name, unsigned IndentLevel) const {
39 outs().indent(IndentLevel);
40 outs() << Name << ": " << value() << "\n";
49 void DIAResult<BOOL>::dump(StringRef Name, unsigned IndentLevel) const {
52 outs().indent(IndentLevel);
53 outs() << Name << ": " << (value() ? "true" : "false") << "\n";
57 void DIAResult<GUID>::dump(StringRef Name, unsigned IndentLevel) const {
61 CComBSTR GuidBSTR(value());
62 BSTRToUTF8(GuidBSTR.m_str, Guid8);
64 outs().indent(IndentLevel);
65 outs() << Name << ": " << Guid8 << "\n";
68 // MSDN documents the IDiaSymbol::get_machineType method as returning a value
69 // from the CV_CPU_TYPE_e enumeration. This documentation is wrong, however,
70 // and this method actually returns a value from the IMAGE_FILE_xxx set of
71 // defines from winnt.h. These correspond to the platform magic number in
72 // the COFF file. This enumeration is built from the set of values in winnt.h
73 enum MachineTypeEnum {
74 MachineTypeUnknown = IMAGE_FILE_MACHINE_UNKNOWN,
75 MachineTypeX86 = IMAGE_FILE_MACHINE_I386,
76 MachineTypeR3000 = IMAGE_FILE_MACHINE_R3000,
77 MachineTypeR4000 = IMAGE_FILE_MACHINE_R4000,
78 MachineTypeR10000 = IMAGE_FILE_MACHINE_R10000,
79 MachineTypeWCEMIPSv2 = IMAGE_FILE_MACHINE_WCEMIPSV2,
80 MachineTypeAlpha = IMAGE_FILE_MACHINE_ALPHA,
81 MachineTypeSH3 = IMAGE_FILE_MACHINE_SH3,
82 MachineTypeSH3DSP = IMAGE_FILE_MACHINE_SH3DSP,
83 MachineTypeSH3E = IMAGE_FILE_MACHINE_SH3E,
84 MachineTypeSH4 = IMAGE_FILE_MACHINE_SH4,
85 MachineTypeSH5 = IMAGE_FILE_MACHINE_SH5,
86 MachineTypeArm = IMAGE_FILE_MACHINE_ARM,
87 MachineTypeThumb = IMAGE_FILE_MACHINE_THUMB,
88 MachineTypeArmNT = IMAGE_FILE_MACHINE_ARMNT,
89 MachineTypeAM33 = IMAGE_FILE_MACHINE_AM33,
90 MachineTypePowerPC = IMAGE_FILE_MACHINE_POWERPC,
91 MachineTypePowerPCFP = IMAGE_FILE_MACHINE_POWERPCFP,
92 MachineTypeIa64 = IMAGE_FILE_MACHINE_IA64,
93 MachineTypeMips16 = IMAGE_FILE_MACHINE_MIPS16,
94 MachineTypeAlpha64 = IMAGE_FILE_MACHINE_ALPHA64,
95 MachineTypeMipsFpu = IMAGE_FILE_MACHINE_MIPSFPU,
96 MachineTypeMipsFpu16 = IMAGE_FILE_MACHINE_MIPSFPU16,
97 MachineTypeTriCore = IMAGE_FILE_MACHINE_TRICORE,
98 MachineTypeCEF = IMAGE_FILE_MACHINE_CEF,
99 MachineTypeEBC = IMAGE_FILE_MACHINE_EBC,
100 MachineTypeAmd64 = IMAGE_FILE_MACHINE_AMD64,
101 MachineTypeM32R = IMAGE_FILE_MACHINE_M32R,
102 MachineTypeCEE = IMAGE_FILE_MACHINE_CEE,
105 enum HashAlgorithm { HashNone = 0, HashMD5 = 1, HashSHA1 = 2 };
107 // SymTagEnum has the unfortunate property that it is not only the name of
108 // the enum, but also the name of one of the values of the enum. So that we
109 // don't have to always type "enum SymTagEnum", we typedef this to a different
110 // name so that we can refer to it more easily.
111 typedef enum SymTagEnum DiaSymTagEnum;
113 typedef CComPtr<IDiaSymbol> DiaSymbolPtr;
115 } // namespace windows
122 raw_ostream &operator<<(raw_ostream &Stream,
123 llvm::sys::windows::DiaSymTagEnum SymTag);
124 raw_ostream &operator<<(raw_ostream &Stream, CV_CPU_TYPE_e CpuType);
125 raw_ostream &operator<<(raw_ostream &Stream,
126 llvm::sys::windows::MachineTypeEnum CpuType);
127 raw_ostream &operator<<(raw_ostream &Stream,
128 llvm::sys::windows::HashAlgorithm Algorithm);