1*0b57cec5SDimitry Andric //==- DIAEnumDebugStreams.cpp - DIA Debug Stream Enumerator impl -*- C++ -*-==// 2*0b57cec5SDimitry Andric // 3*0b57cec5SDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4*0b57cec5SDimitry Andric // See https://llvm.org/LICENSE.txt for license information. 5*0b57cec5SDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6*0b57cec5SDimitry Andric // 7*0b57cec5SDimitry Andric //===----------------------------------------------------------------------===// 8*0b57cec5SDimitry Andric 9*0b57cec5SDimitry Andric #include "llvm/DebugInfo/PDB/DIA/DIAEnumDebugStreams.h" 10*0b57cec5SDimitry Andric #include "llvm/DebugInfo/PDB/DIA/DIADataStream.h" 11*0b57cec5SDimitry Andric #include "llvm/DebugInfo/PDB/PDBSymbol.h" 12*0b57cec5SDimitry Andric 13*0b57cec5SDimitry Andric using namespace llvm; 14*0b57cec5SDimitry Andric using namespace llvm::pdb; 15*0b57cec5SDimitry Andric DIAEnumDebugStreams(CComPtr<IDiaEnumDebugStreams> DiaEnumerator)16*0b57cec5SDimitry AndricDIAEnumDebugStreams::DIAEnumDebugStreams( 17*0b57cec5SDimitry Andric CComPtr<IDiaEnumDebugStreams> DiaEnumerator) 18*0b57cec5SDimitry Andric : Enumerator(DiaEnumerator) {} 19*0b57cec5SDimitry Andric getChildCount() const20*0b57cec5SDimitry Andricuint32_t DIAEnumDebugStreams::getChildCount() const { 21*0b57cec5SDimitry Andric LONG Count = 0; 22*0b57cec5SDimitry Andric return (S_OK == Enumerator->get_Count(&Count)) ? Count : 0; 23*0b57cec5SDimitry Andric } 24*0b57cec5SDimitry Andric 25*0b57cec5SDimitry Andric std::unique_ptr<IPDBDataStream> getChildAtIndex(uint32_t Index) const26*0b57cec5SDimitry AndricDIAEnumDebugStreams::getChildAtIndex(uint32_t Index) const { 27*0b57cec5SDimitry Andric CComPtr<IDiaEnumDebugStreamData> Item; 28*0b57cec5SDimitry Andric VARIANT VarIndex; 29*0b57cec5SDimitry Andric VarIndex.vt = VT_I4; 30*0b57cec5SDimitry Andric VarIndex.lVal = Index; 31*0b57cec5SDimitry Andric if (S_OK != Enumerator->Item(VarIndex, &Item)) 32*0b57cec5SDimitry Andric return nullptr; 33*0b57cec5SDimitry Andric 34*0b57cec5SDimitry Andric return std::unique_ptr<IPDBDataStream>(new DIADataStream(Item)); 35*0b57cec5SDimitry Andric } 36*0b57cec5SDimitry Andric getNext()37*0b57cec5SDimitry Andricstd::unique_ptr<IPDBDataStream> DIAEnumDebugStreams::getNext() { 38*0b57cec5SDimitry Andric CComPtr<IDiaEnumDebugStreamData> Item; 39*0b57cec5SDimitry Andric ULONG NumFetched = 0; 40*0b57cec5SDimitry Andric if (S_OK != Enumerator->Next(1, &Item, &NumFetched)) 41*0b57cec5SDimitry Andric return nullptr; 42*0b57cec5SDimitry Andric 43*0b57cec5SDimitry Andric return std::unique_ptr<IPDBDataStream>(new DIADataStream(Item)); 44*0b57cec5SDimitry Andric } 45*0b57cec5SDimitry Andric reset()46*0b57cec5SDimitry Andricvoid DIAEnumDebugStreams::reset() { Enumerator->Reset(); } 47