Run dos2unix against llvm-pdbdump.
[oota-llvm.git] / tools / llvm-pdbdump / DIASymbol.h
1 //===- DIASymbol.h - Dump debug info from a PDB file ------------*- C++ -*-===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // Provides a wrapper around the IDiaSymbol interface.  IDiaSymbol is used to
11 // represent any kind of symbol from functions, to compilands, to source files.
12 // It provides a monolithic interface of close to 200 operations, and the set
13 // of operations that are valid depends on the type of the symbol.  Since it is
14 // not clearly documented which set of operations is valid for which type of
15 // symbol, the best way of figuring it out is to dump every method for every
16 // symbol, and see which methods return errors.  This wrapper provides a clean
17 // way of doing this without involving needing to embed lots of unsightly
18 // HRESULT checking at every callsite.
19 //
20 //===----------------------------------------------------------------------===//
21
22 #ifndef LLVM_TOOLS_LLVMPDBDUMP_DIASYMBOL_H
23 #define LLVM_TOOLS_LLVMPDBDUMP_DIASYMBOL_H
24
25 #include "DIAExtras.h"
26 #include "llvm/ADT/SmallString.h"
27
28 namespace llvm {
29 namespace sys {
30 namespace windows {
31
32 class DIASymbol {
33 public:
34   DIASymbol(IDiaSymbol *DiaSymbol);
35   ~DIASymbol();
36
37   /// Dumps the value of every property (if it exists) with a default name.
38   /// This is useful for understanding what symbol types support what methods
39   /// during development time.
40   void fullDump(int IndentLevel);
41
42 // TODO: The following methods are present on IDiaSymbol but do not yet have
43 // wrapper methods.
44 //
45 // HRESULT get_value(VARIANT *pRetVal) = 0;
46 // HRESULT get_undecoratedNameEx(DWORD undecorateOptions, BSTR *name) = 0;
47 // HRESULT getSrcLineOnTypeDefn(IDiaLineNumber **ppResult) = 0;
48 // HRESULT get_dataBytes(DWORD cbData, DWORD *pcbData, BYTE *pbData) = 0;
49 // HRESULT get_types(DWORD cTypes, DWORD *pcTypes, IDiaSymbol **pTypes) = 0;
50 // HRESULT get_typeIds(DWORD cTypeIds, DWORD *pcTypeIds, DWORD *pdwTypeIds) = 0;
51 // HRESULT get_numericProperties(DWORD cnt, DWORD *pcnt,
52 //                               DWORD *pProperties) = 0;
53 // HRESULT get_modifierValues(DWORD cnt, DWORD *pcnt, WORD *pModifiers) = 0;
54 // HRESULT get_acceleratorPointerTags(DWORD cnt, DWORD *pcnt, DWORD
55 //                                    *pPointerTags) = 0;
56 // HRESULT get_hfaFloat(BOOL *pRetVal) = 0;
57 // HRESULT get_hfaDouble(BOOL *pRetVal) = 0;
58 // HRESULT get_paramBasePointerRegisterId(DWORD *pRetVal) = 0;
59 // HRESULT get_isWinRTPointer(BOOL *pRetVal) = 0;
60
61 #if (_MSC_FULL_VER >= 180031101)
62   // These methods are only available on VS 2013 SP 4 and higher.
63   DIAResult<BOOL> isPGO();
64   DIAResult<BOOL> hasValidPGOCounts();
65   DIAResult<BOOL> isOptimizedForSpeed();
66   DIAResult<DWORD> getPGOEntryCount();
67   DIAResult<DWORD> getPGOEdgeCount();
68   DIAResult<ULONGLONG> getPGODynamicInstructionCount();
69   DIAResult<DWORD> getStaticSize();
70   DIAResult<DWORD> getFinalLiveStaticSize();
71   DIAResult<DIAString> getPhaseName();
72   DIAResult<BOOL> hasControlFlowCheck();
73 #endif
74
75   DIAResult<DiaSymbolPtr> getLexicalParent();
76   DIAResult<DiaSymbolPtr> getClassParent();
77   DIAResult<DiaSymbolPtr> getType();
78   DIAResult<DiaSymbolPtr> getArrayIndexType();
79   DIAResult<DiaSymbolPtr> getVirtualTableShape();
80   DIAResult<DiaSymbolPtr> getLowerBound();
81   DIAResult<DiaSymbolPtr> getUpperBound();
82   DIAResult<DiaSymbolPtr> getObjectPointerType();
83   DIAResult<DiaSymbolPtr> getContainer();
84   DIAResult<DiaSymbolPtr> getVirtualBaseTableType();
85   DIAResult<DiaSymbolPtr> getUnmodifiedType();
86   DIAResult<DiaSymbolPtr> getSubType();
87   DIAResult<DiaSymbolPtr> getBaseSymbol();
88
89   DIAResult<DWORD> getAccess();
90   DIAResult<DWORD> getAddressOffset();
91   DIAResult<DWORD> getAddressSection();
92   DIAResult<DWORD> getAge();
93   DIAResult<DWORD> getArrayIndexTypeId();
94   DIAResult<DWORD> getBackEndBuild();
95   DIAResult<DWORD> getBackEndMajor();
96   DIAResult<DWORD> getBackEndMinor();
97   DIAResult<DWORD> getBackEndQFE();
98   DIAResult<DWORD> getBaseDataOffset();
99   DIAResult<DWORD> getBaseDataSlot();
100   DIAResult<DWORD> getBaseSymbolId();
101   DIAResult<DWORD> getBaseType();
102   DIAResult<DWORD> getBitPosition();
103   DIAResult<DWORD> getBuiltInKind();
104   DIAResult<CV_call_e> getCallingConvention();
105   DIAResult<DWORD> getClassParentId();
106   DIAResult<DIAString> getCompilerName();
107   DIAResult<DWORD> getCount();
108   DIAResult<DWORD> getCountLiveRanges();
109   DIAResult<DWORD> getFrontEndBuild();
110   DIAResult<DWORD> getFrontEndMajor();
111   DIAResult<DWORD> getFrontEndMinor();
112   DIAResult<DWORD> getFrontEndQFE();
113   DIAResult<CV_CFL_LANG> getLanguage();
114   DIAResult<DWORD> getLexicalParentId();
115   DIAResult<DIAString> getLibraryName();
116   DIAResult<DWORD> getLiveRangeStartAddressOffset();
117   DIAResult<DWORD> getLiveRangeStartAddressSection();
118   DIAResult<DWORD> getLiveRangeStartRelativeVirtualAddress();
119   DIAResult<DWORD> getLocalBasePointerRegisterId();
120   DIAResult<DWORD> getLowerBoundId();
121   DIAResult<DWORD> getMemorySpaceKind();
122   DIAResult<DIAString> getName();
123   DIAResult<DWORD> getNumberOfAcceleratorPointerTags();
124   DIAResult<DWORD> getNumberOfColumns();
125   DIAResult<DWORD> getNumberOfModifiers();
126   DIAResult<DWORD> getNumberOfRegisterIndices();
127   DIAResult<DWORD> getNumberOfRows();
128   DIAResult<DIAString> getObjectFileName();
129   DIAResult<DWORD> getOemSymbolId();
130   DIAResult<DWORD> getOffsetInUdt();
131   DIAResult<CV_CPU_TYPE_e> getPlatform();
132   DIAResult<DWORD> getRank();
133   DIAResult<DWORD> getRegisterId();
134   DIAResult<DWORD> getRegisterType();
135   DIAResult<DWORD> getRelativeVirtualAddress();
136   DIAResult<DWORD> getSamplerSlot();
137   DIAResult<DWORD> getSignature();
138   DIAResult<DWORD> getSizeInUdt();
139   DIAResult<DWORD> getSlot();
140   DIAResult<DIAString> getSourceFileName();
141   DIAResult<DWORD> getStride();
142   DIAResult<DWORD> getSubTypeId();
143   DIAResult<DIAString> getSymbolsFileName();
144   DIAResult<DWORD> getSymIndexId();
145   DIAResult<DWORD> getTargetOffset();
146   DIAResult<DWORD> getTargetRelativeVirtualAddress();
147   DIAResult<DWORD> getTargetSection();
148   DIAResult<DWORD> getTextureSlot();
149   DIAResult<DWORD> getTimeStamp();
150   DIAResult<DWORD> getToken();
151   DIAResult<DWORD> getUavSlot();
152   DIAResult<DIAString> getUndecoratedName();
153   DIAResult<DWORD> getUnmodifiedTypeId();
154   DIAResult<DWORD> getUpperBoundId();
155   DIAResult<DWORD> getVirtualBaseDispIndex();
156   DIAResult<DWORD> getVirtualBaseOffset();
157   DIAResult<DWORD> getVirtualTableShapeId();
158   DIAResult<DataKind> getDataKind();
159   DIAResult<DiaSymTagEnum> getSymTag();
160   DIAResult<GUID> getGuid();
161   DIAResult<LONG> getOffset();
162   DIAResult<LONG> getThisAdjust();
163   DIAResult<LONG> getVirtualBasePointerOffset();
164   DIAResult<LocationType> getLocationType();
165   DIAResult<MachineTypeEnum> getMachineType();
166   DIAResult<THUNK_ORDINAL> getThunkOrdinal();
167   DIAResult<ULONGLONG> getLength();
168   DIAResult<ULONGLONG> getLiveRangeLength();
169   DIAResult<ULONGLONG> getTargetVirtualAddress();
170   DIAResult<ULONGLONG> getVirtualAddress();
171   DIAResult<UdtKind> getUdtKind();
172   DIAResult<BOOL> hasConstructor();
173   DIAResult<BOOL> hasCustomCallingConvention();
174   DIAResult<BOOL> hasFarReturn();
175   DIAResult<BOOL> isCode();
176   DIAResult<BOOL> isCompilerGenerated();
177   DIAResult<BOOL> isConstType();
178   DIAResult<BOOL> isEditAndContinueEnabled();
179   DIAResult<BOOL> isFunction();
180   DIAResult<BOOL> getAddressTaken();
181   DIAResult<BOOL> getNoStackOrdering();
182   DIAResult<BOOL> hasAlloca();
183   DIAResult<BOOL> hasAssignmentOperator();
184   DIAResult<BOOL> hasCTypes();
185   DIAResult<BOOL> hasCastOperator();
186   DIAResult<BOOL> hasDebugInfo();
187   DIAResult<BOOL> hasEH();
188   DIAResult<BOOL> hasEHa();
189   DIAResult<BOOL> hasInlAsm();
190   DIAResult<BOOL> hasInlineAttribute();
191   DIAResult<BOOL> hasInterruptReturn();
192   DIAResult<BOOL> hasLongJump();
193   DIAResult<BOOL> hasManagedCode();
194   DIAResult<BOOL> hasNestedTypes();
195   DIAResult<BOOL> hasNoInlineAttribute();
196   DIAResult<BOOL> hasNoReturnAttribute();
197   DIAResult<BOOL> hasOptimizedCodeDebugInfo();
198   DIAResult<BOOL> hasOverloadedOperator();
199   DIAResult<BOOL> hasSEH();
200   DIAResult<BOOL> hasSecurityChecks();
201   DIAResult<BOOL> hasSetJump();
202   DIAResult<BOOL> hasStrictGSCheck();
203   DIAResult<BOOL> isAcceleratorGroupSharedLocal();
204   DIAResult<BOOL> isAcceleratorPointerTagLiveRange();
205   DIAResult<BOOL> isAcceleratorStubFunction();
206   DIAResult<BOOL> isAggregated();
207   DIAResult<BOOL> isBaseVirtualFunction();
208   DIAResult<BOOL> isCVTCIL();
209   DIAResult<BOOL> isConstructorVirtualBase();
210   DIAResult<BOOL> isCxxReturnUdt();
211   DIAResult<BOOL> isDataAligned();
212   DIAResult<BOOL> isHLSLData();
213   DIAResult<BOOL> isHotpatchable();
214   DIAResult<BOOL> isIndirectVirtualBaseClass();
215   DIAResult<BOOL> isInterfaceUdt();
216   DIAResult<BOOL> isIntrinsic();
217   DIAResult<BOOL> isLTCG();
218   DIAResult<BOOL> isLocationControlFlowDependent();
219   DIAResult<BOOL> isMSILNetmodule();
220   DIAResult<BOOL> isManagedRef();
221   DIAResult<BOOL> isMatrixRowMajor();
222   DIAResult<BOOL> isMsilRef();
223   DIAResult<BOOL> isMultipleInheritance();
224   DIAResult<BOOL> isNaked();
225   DIAResult<BOOL> isNested();
226   DIAResult<BOOL> isOptimizedAway();
227   DIAResult<BOOL> isPacked();
228   DIAResult<BOOL> isPointerBasedOnSymbolValue();
229   DIAResult<BOOL> isPointerToDataMember();
230   DIAResult<BOOL> isPointerToMemberFunction();
231   DIAResult<BOOL> isPureVirtual();
232   DIAResult<BOOL> isRValueReference();
233   DIAResult<BOOL> isRefUdt();
234   DIAResult<BOOL> isReference();
235   DIAResult<BOOL> isRestrictedType();
236   DIAResult<BOOL> isReturnValue();
237   DIAResult<BOOL> isSafeBuffers();
238   DIAResult<BOOL> isScoped();
239   DIAResult<BOOL> isSdl();
240   DIAResult<BOOL> isSingleInheritance();
241   DIAResult<BOOL> isSplitted();
242   DIAResult<BOOL> isStatic();
243   DIAResult<BOOL> isStripped();
244   DIAResult<BOOL> isUnalignedType();
245   DIAResult<BOOL> isUnreached();
246   DIAResult<BOOL> isValueUdt();
247   DIAResult<BOOL> isVirtual();
248   DIAResult<BOOL> isVirtualBaseClass();
249   DIAResult<BOOL> isVirtualInheritance();
250   DIAResult<BOOL> isVolatileType();
251
252 private:
253   template <class T, class U = T>
254   DIAResult<U>
255   InternalGetDIAValue(HRESULT (__stdcall IDiaSymbol::*Method)(T *)) {
256     T Value;
257     if (S_OK == (Symbol->*Method)(&Value))
258       return DIAResult<U>(U(Value));
259     else
260       return DIAResult<U>();
261   }
262
263   DIAResult<DIAString>
264   InternalGetDIAStringValue(HRESULT (__stdcall IDiaSymbol::*Method)(BSTR *)) {
265     BSTR String16;
266     if (S_OK == (Symbol->*Method)(&String16)) {
267       std::string String8;
268       llvm::sys::windows::BSTRToUTF8(String16, String8);
269       SysFreeString(String16);
270       return DIAResult<DIAString>(DIAString(String8));
271     } else
272       return DIAResult<DIAString>();
273   }
274
275   IDiaSymbol *Symbol;
276 };
277
278 } // namespace windows
279 } // namespace sys
280 } // namespace llvm
281
282 #endif