//===- DIASymbol.h - Dump debug info from a PDB file ------------*- C++ -*-===// // // The LLVM Compiler Infrastructure // // This file is distributed under the University of Illinois Open Source // License. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// // // Provides a wrapper around the IDiaSymbol interface. IDiaSymbol is used to // represent any kind of symbol from functions, to compilands, to source files. // It provides a monolithic interface of close to 200 operations, and the set // of operations that are valid depends on the type of the symbol. Since it is // not clearly documented which set of operations is valid for which type of // symbol, the best way of figuring it out is to dump every method for every // symbol, and see which methods return errors. This wrapper provides a clean // way of doing this without involving needing to embed lots of unsightly // HRESULT checking at every callsite. // //===----------------------------------------------------------------------===// #ifndef LLVM_TOOLS_LLVMPDBDUMP_DIASYMBOL_H #define LLVM_TOOLS_LLVMPDBDUMP_DIASYMBOL_H #include "DIAExtras.h" #include "llvm/ADT/SmallString.h" namespace llvm { namespace sys { namespace windows { class DIASymbol { public: DIASymbol(IDiaSymbol *DiaSymbol); ~DIASymbol(); /// Dumps the value of every property (if it exists) with a default name. /// This is useful for understanding what symbol types support what methods /// during development time. void fullDump(int IndentLevel); // TODO: The following methods are present on IDiaSymbol but do not yet have // wrapper methods. // // HRESULT get_value(VARIANT *pRetVal) = 0; // HRESULT get_undecoratedNameEx(DWORD undecorateOptions, BSTR *name) = 0; // HRESULT getSrcLineOnTypeDefn(IDiaLineNumber **ppResult) = 0; // HRESULT get_dataBytes(DWORD cbData, DWORD *pcbData, BYTE *pbData) = 0; // HRESULT get_types(DWORD cTypes, DWORD *pcTypes, IDiaSymbol **pTypes) = 0; // HRESULT get_typeIds(DWORD cTypeIds, DWORD *pcTypeIds, DWORD *pdwTypeIds) = 0; // HRESULT get_numericProperties(DWORD cnt, DWORD *pcnt, // DWORD *pProperties) = 0; // HRESULT get_modifierValues(DWORD cnt, DWORD *pcnt, WORD *pModifiers) = 0; // HRESULT get_acceleratorPointerTags(DWORD cnt, DWORD *pcnt, DWORD // *pPointerTags) = 0; // HRESULT get_hfaFloat(BOOL *pRetVal) = 0; // HRESULT get_hfaDouble(BOOL *pRetVal) = 0; // HRESULT get_paramBasePointerRegisterId(DWORD *pRetVal) = 0; // HRESULT get_isWinRTPointer(BOOL *pRetVal) = 0; #if (_MSC_FULL_VER >= 180031101) // These methods are only available on VS 2013 SP 4 and higher. DIAResult isPGO(); DIAResult hasValidPGOCounts(); DIAResult isOptimizedForSpeed(); DIAResult getPGOEntryCount(); DIAResult getPGOEdgeCount(); DIAResult getPGODynamicInstructionCount(); DIAResult getStaticSize(); DIAResult getFinalLiveStaticSize(); DIAResult getPhaseName(); DIAResult hasControlFlowCheck(); #endif DIAResult getLexicalParent(); DIAResult getClassParent(); DIAResult getType(); DIAResult getArrayIndexType(); DIAResult getVirtualTableShape(); DIAResult getLowerBound(); DIAResult getUpperBound(); DIAResult getObjectPointerType(); DIAResult getContainer(); DIAResult getVirtualBaseTableType(); DIAResult getUnmodifiedType(); DIAResult getSubType(); DIAResult getBaseSymbol(); DIAResult getAccess(); DIAResult getAddressOffset(); DIAResult getAddressSection(); DIAResult getAge(); DIAResult getArrayIndexTypeId(); DIAResult getBackEndBuild(); DIAResult getBackEndMajor(); DIAResult getBackEndMinor(); DIAResult getBackEndQFE(); DIAResult getBaseDataOffset(); DIAResult getBaseDataSlot(); DIAResult getBaseSymbolId(); DIAResult getBaseType(); DIAResult getBitPosition(); DIAResult getBuiltInKind(); DIAResult getCallingConvention(); DIAResult getClassParentId(); DIAResult getCompilerName(); DIAResult getCount(); DIAResult getCountLiveRanges(); DIAResult getFrontEndBuild(); DIAResult getFrontEndMajor(); DIAResult getFrontEndMinor(); DIAResult getFrontEndQFE(); DIAResult getLanguage(); DIAResult getLexicalParentId(); DIAResult getLibraryName(); DIAResult getLiveRangeStartAddressOffset(); DIAResult getLiveRangeStartAddressSection(); DIAResult getLiveRangeStartRelativeVirtualAddress(); DIAResult getLocalBasePointerRegisterId(); DIAResult getLowerBoundId(); DIAResult getMemorySpaceKind(); DIAResult getName(); DIAResult getNumberOfAcceleratorPointerTags(); DIAResult getNumberOfColumns(); DIAResult getNumberOfModifiers(); DIAResult getNumberOfRegisterIndices(); DIAResult getNumberOfRows(); DIAResult getObjectFileName(); DIAResult getOemSymbolId(); DIAResult getOffsetInUdt(); DIAResult getPlatform(); DIAResult getRank(); DIAResult getRegisterId(); DIAResult getRegisterType(); DIAResult getRelativeVirtualAddress(); DIAResult getSamplerSlot(); DIAResult getSignature(); DIAResult getSizeInUdt(); DIAResult getSlot(); DIAResult getSourceFileName(); DIAResult getStride(); DIAResult getSubTypeId(); DIAResult getSymbolsFileName(); DIAResult getSymIndexId(); DIAResult getTargetOffset(); DIAResult getTargetRelativeVirtualAddress(); DIAResult getTargetSection(); DIAResult getTextureSlot(); DIAResult getTimeStamp(); DIAResult getToken(); DIAResult getUavSlot(); DIAResult getUndecoratedName(); DIAResult getUnmodifiedTypeId(); DIAResult getUpperBoundId(); DIAResult getVirtualBaseDispIndex(); DIAResult getVirtualBaseOffset(); DIAResult getVirtualTableShapeId(); DIAResult getDataKind(); DIAResult getSymTag(); DIAResult getGuid(); DIAResult getOffset(); DIAResult getThisAdjust(); DIAResult getVirtualBasePointerOffset(); DIAResult getLocationType(); DIAResult getMachineType(); DIAResult getThunkOrdinal(); DIAResult getLength(); DIAResult getLiveRangeLength(); DIAResult getTargetVirtualAddress(); DIAResult getVirtualAddress(); DIAResult getUdtKind(); DIAResult hasConstructor(); DIAResult hasCustomCallingConvention(); DIAResult hasFarReturn(); DIAResult isCode(); DIAResult isCompilerGenerated(); DIAResult isConstType(); DIAResult isEditAndContinueEnabled(); DIAResult isFunction(); DIAResult getAddressTaken(); DIAResult getNoStackOrdering(); DIAResult hasAlloca(); DIAResult hasAssignmentOperator(); DIAResult hasCTypes(); DIAResult hasCastOperator(); DIAResult hasDebugInfo(); DIAResult hasEH(); DIAResult hasEHa(); DIAResult hasInlAsm(); DIAResult hasInlineAttribute(); DIAResult hasInterruptReturn(); DIAResult hasLongJump(); DIAResult hasManagedCode(); DIAResult hasNestedTypes(); DIAResult hasNoInlineAttribute(); DIAResult hasNoReturnAttribute(); DIAResult hasOptimizedCodeDebugInfo(); DIAResult hasOverloadedOperator(); DIAResult hasSEH(); DIAResult hasSecurityChecks(); DIAResult hasSetJump(); DIAResult hasStrictGSCheck(); DIAResult isAcceleratorGroupSharedLocal(); DIAResult isAcceleratorPointerTagLiveRange(); DIAResult isAcceleratorStubFunction(); DIAResult isAggregated(); DIAResult isBaseVirtualFunction(); DIAResult isCVTCIL(); DIAResult isConstructorVirtualBase(); DIAResult isCxxReturnUdt(); DIAResult isDataAligned(); DIAResult isHLSLData(); DIAResult isHotpatchable(); DIAResult isIndirectVirtualBaseClass(); DIAResult isInterfaceUdt(); DIAResult isIntrinsic(); DIAResult isLTCG(); DIAResult isLocationControlFlowDependent(); DIAResult isMSILNetmodule(); DIAResult isManagedRef(); DIAResult isMatrixRowMajor(); DIAResult isMsilRef(); DIAResult isMultipleInheritance(); DIAResult isNaked(); DIAResult isNested(); DIAResult isOptimizedAway(); DIAResult isPacked(); DIAResult isPointerBasedOnSymbolValue(); DIAResult isPointerToDataMember(); DIAResult isPointerToMemberFunction(); DIAResult isPureVirtual(); DIAResult isRValueReference(); DIAResult isRefUdt(); DIAResult isReference(); DIAResult isRestrictedType(); DIAResult isReturnValue(); DIAResult isSafeBuffers(); DIAResult isScoped(); DIAResult isSdl(); DIAResult isSingleInheritance(); DIAResult isSplitted(); DIAResult isStatic(); DIAResult isStripped(); DIAResult isUnalignedType(); DIAResult isUnreached(); DIAResult isValueUdt(); DIAResult isVirtual(); DIAResult isVirtualBaseClass(); DIAResult isVirtualInheritance(); DIAResult isVolatileType(); private: template DIAResult InternalGetDIAValue(HRESULT (__stdcall IDiaSymbol::*Method)(T *)) { T Value; if (S_OK == (Symbol->*Method)(&Value)) return DIAResult(U(Value)); else return DIAResult(); } DIAResult InternalGetDIAStringValue(HRESULT (__stdcall IDiaSymbol::*Method)(BSTR *)) { BSTR String16; if (S_OK == (Symbol->*Method)(&String16)) { std::string String8; llvm::sys::windows::BSTRToUTF8(String16, String8); SysFreeString(String16); return DIAResult(DIAString(String8)); } else return DIAResult(); } IDiaSymbol *Symbol; }; } // namespace windows } // namespace sys } // namespace llvm #endif