1ebe69fe11e48d322045d5949c83283927a0d790bStephen Hines//==- DIAEnumDebugStreams.cpp - DIA Debug Stream Enumerator impl -*- C++ -*-==// 2ebe69fe11e48d322045d5949c83283927a0d790bStephen Hines// 3ebe69fe11e48d322045d5949c83283927a0d790bStephen Hines// The LLVM Compiler Infrastructure 4ebe69fe11e48d322045d5949c83283927a0d790bStephen Hines// 5ebe69fe11e48d322045d5949c83283927a0d790bStephen Hines// This file is distributed under the University of Illinois Open Source 6ebe69fe11e48d322045d5949c83283927a0d790bStephen Hines// License. See LICENSE.TXT for details. 7ebe69fe11e48d322045d5949c83283927a0d790bStephen Hines// 8ebe69fe11e48d322045d5949c83283927a0d790bStephen Hines//===----------------------------------------------------------------------===// 9ebe69fe11e48d322045d5949c83283927a0d790bStephen Hines 10ebe69fe11e48d322045d5949c83283927a0d790bStephen Hines#include "llvm/DebugInfo/PDB/PDBSymbol.h" 11ebe69fe11e48d322045d5949c83283927a0d790bStephen Hines#include "llvm/DebugInfo/PDB/DIA/DIADataStream.h" 12ebe69fe11e48d322045d5949c83283927a0d790bStephen Hines#include "llvm/DebugInfo/PDB/DIA/DIAEnumDebugStreams.h" 13ebe69fe11e48d322045d5949c83283927a0d790bStephen Hines 14ebe69fe11e48d322045d5949c83283927a0d790bStephen Hinesusing namespace llvm; 15ebe69fe11e48d322045d5949c83283927a0d790bStephen Hines 16ebe69fe11e48d322045d5949c83283927a0d790bStephen HinesDIAEnumDebugStreams::DIAEnumDebugStreams( 17ebe69fe11e48d322045d5949c83283927a0d790bStephen Hines CComPtr<IDiaEnumDebugStreams> DiaEnumerator) 18ebe69fe11e48d322045d5949c83283927a0d790bStephen Hines : Enumerator(DiaEnumerator) {} 19ebe69fe11e48d322045d5949c83283927a0d790bStephen Hines 20ebe69fe11e48d322045d5949c83283927a0d790bStephen Hinesuint32_t DIAEnumDebugStreams::getChildCount() const { 21ebe69fe11e48d322045d5949c83283927a0d790bStephen Hines LONG Count = 0; 22ebe69fe11e48d322045d5949c83283927a0d790bStephen Hines return (S_OK == Enumerator->get_Count(&Count)) ? Count : 0; 23ebe69fe11e48d322045d5949c83283927a0d790bStephen Hines} 24ebe69fe11e48d322045d5949c83283927a0d790bStephen Hines 25ebe69fe11e48d322045d5949c83283927a0d790bStephen Hinesstd::unique_ptr<IPDBDataStream> 26ebe69fe11e48d322045d5949c83283927a0d790bStephen HinesDIAEnumDebugStreams::getChildAtIndex(uint32_t Index) const { 27ebe69fe11e48d322045d5949c83283927a0d790bStephen Hines CComPtr<IDiaEnumDebugStreamData> Item; 28ebe69fe11e48d322045d5949c83283927a0d790bStephen Hines VARIANT VarIndex; 29ebe69fe11e48d322045d5949c83283927a0d790bStephen Hines VarIndex.vt = VT_I4; 30ebe69fe11e48d322045d5949c83283927a0d790bStephen Hines VarIndex.lVal = Index; 31ebe69fe11e48d322045d5949c83283927a0d790bStephen Hines if (S_OK != Enumerator->Item(VarIndex, &Item)) 32ebe69fe11e48d322045d5949c83283927a0d790bStephen Hines return nullptr; 33ebe69fe11e48d322045d5949c83283927a0d790bStephen Hines 34ebe69fe11e48d322045d5949c83283927a0d790bStephen Hines return std::unique_ptr<IPDBDataStream>(new DIADataStream(Item)); 35ebe69fe11e48d322045d5949c83283927a0d790bStephen Hines} 36ebe69fe11e48d322045d5949c83283927a0d790bStephen Hines 37ebe69fe11e48d322045d5949c83283927a0d790bStephen Hinesstd::unique_ptr<IPDBDataStream> DIAEnumDebugStreams::getNext() { 38ebe69fe11e48d322045d5949c83283927a0d790bStephen Hines CComPtr<IDiaEnumDebugStreamData> Item; 39ebe69fe11e48d322045d5949c83283927a0d790bStephen Hines ULONG NumFetched = 0; 40ebe69fe11e48d322045d5949c83283927a0d790bStephen Hines if (S_OK != Enumerator->Next(1, &Item, &NumFetched)) 41ebe69fe11e48d322045d5949c83283927a0d790bStephen Hines return nullptr; 42ebe69fe11e48d322045d5949c83283927a0d790bStephen Hines 43ebe69fe11e48d322045d5949c83283927a0d790bStephen Hines return std::unique_ptr<IPDBDataStream>(new DIADataStream(Item)); 44ebe69fe11e48d322045d5949c83283927a0d790bStephen Hines} 45ebe69fe11e48d322045d5949c83283927a0d790bStephen Hines 46ebe69fe11e48d322045d5949c83283927a0d790bStephen Hinesvoid DIAEnumDebugStreams::reset() { Enumerator->Reset(); } 47ebe69fe11e48d322045d5949c83283927a0d790bStephen Hines 48ebe69fe11e48d322045d5949c83283927a0d790bStephen HinesDIAEnumDebugStreams *DIAEnumDebugStreams::clone() const { 49ebe69fe11e48d322045d5949c83283927a0d790bStephen Hines CComPtr<IDiaEnumDebugStreams> EnumeratorClone; 50ebe69fe11e48d322045d5949c83283927a0d790bStephen Hines if (S_OK != Enumerator->Clone(&EnumeratorClone)) 51ebe69fe11e48d322045d5949c83283927a0d790bStephen Hines return nullptr; 52ebe69fe11e48d322045d5949c83283927a0d790bStephen Hines return new DIAEnumDebugStreams(EnumeratorClone); 53ebe69fe11e48d322045d5949c83283927a0d790bStephen Hines} 54