LLVM  14.0.0git
NativeEnumGlobals.cpp
Go to the documentation of this file.
1 //==- NativeEnumGlobals.cpp - Native Global Enumerator impl ------*- C++ -*-==//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
10 
18 
19 using namespace llvm;
20 using namespace llvm::codeview;
21 using namespace llvm::pdb;
22 
23 NativeEnumGlobals::NativeEnumGlobals(NativeSession &PDBSession,
24  std::vector<codeview::SymbolKind> Kinds)
25  : Index(0), Session(PDBSession) {
28  for (uint32_t Off : GS.getGlobalsTable()) {
29  CVSymbol S = SS.readRecord(Off);
30  if (!llvm::is_contained(Kinds, S.kind()))
31  continue;
32  MatchOffsets.push_back(Off);
33  }
34 }
35 
37  return static_cast<uint32_t>(MatchOffsets.size());
38 }
39 
40 std::unique_ptr<PDBSymbol>
42  if (N >= MatchOffsets.size())
43  return nullptr;
44 
45  SymIndexId Id =
46  Session.getSymbolCache().getOrCreateGlobalSymbolByOffset(MatchOffsets[N]);
47  return Session.getSymbolCache().getSymbolById(Id);
48 }
49 
50 std::unique_ptr<PDBSymbol> NativeEnumGlobals::getNext() {
51  return getChildAtIndex(Index++);
52 }
53 
54 void NativeEnumGlobals::reset() { Index = 0; }
llvm
---------------------— PointerInfo ------------------------------------—
Definition: AllocatorList.h:23
llvm::pdb::SymbolStream
Definition: SymbolStream.h:23
llvm::pdb::NativeSession::getPDBFile
PDBFile & getPDBFile()
Definition: NativeSession.h:105
llvm::pdb::PDBFile::getPDBSymbolStream
Expected< SymbolStream & > getPDBSymbolStream()
Definition: PDBFile.cpp:349
llvm::pdb::NativeEnumGlobals::getNext
std::unique_ptr< PDBSymbol > getNext() override
Definition: NativeEnumGlobals.cpp:50
llvm::pdb::NativeEnumGlobals::reset
void reset() override
Definition: NativeEnumGlobals.cpp:54
GlobalsStream.h
SymbolDeserializer.h
llvm::pdb::NativeEnumGlobals::getChildCount
uint32_t getChildCount() const override
Definition: NativeEnumGlobals.cpp:36
NativeEnumGlobals.h
PDBSymbol.h
llvm::pdb
Definition: ConcreteSymbolEnumerator.h:20
llvm::pdb::SymbolCache::getSymbolById
std::unique_ptr< PDBSymbol > getSymbolById(SymIndexId SymbolId) const
Definition: SymbolCache.cpp:242
Index
uint32_t Index
Definition: ELFObjHandler.cpp:84
llvm::is_contained
bool is_contained(R &&Range, const E &Element)
Wrapper function around std::find to detect if an element exists in a container.
Definition: STLExtras.h:1616
llvm::pdb::NativeSession::getSymbolCache
SymbolCache & getSymbolCache()
Definition: NativeSession.h:109
IPDBEnumChildren.h
llvm::codeview::CVRecord
CVRecord is a fat pointer (base + size pair) to a symbol or type record.
Definition: CVRecord.h:30
llvm::pdb::GlobalsStream
Definition: GlobalsStream.h:70
llvm::X86AS::SS
@ SS
Definition: X86.h:189
llvm::cantFail
void cantFail(Error Err, const char *Msg=nullptr)
Report a fatal error if Err is a failure value.
Definition: Error.h:737
uint32_t
S
add sub stmia L5 ldr r0 bl L_printf $stub Instead of a and a wouldn t it be better to do three moves *Return an aggregate type is even return S
Definition: README.txt:210
llvm::X86AS::GS
@ GS
Definition: X86.h:187
llvm::pdb::NativeEnumGlobals::getChildAtIndex
std::unique_ptr< PDBSymbol > getChildAtIndex(uint32_t Index) const override
Definition: NativeEnumGlobals.cpp:41
llvm::pdb::NativeSession
Definition: NativeSession.h:28
llvm::codeview
Definition: AppendingTypeTableBuilder.h:22
PDBFile.h
N
#define N
llvm::pdb::SymbolCache::getOrCreateGlobalSymbolByOffset
SymIndexId getOrCreateGlobalSymbolByOffset(uint32_t Offset)
Definition: SymbolCache.cpp:269
SymbolStream.h
llvm::AMDGPU::VGPRIndexMode::Id
Id
Definition: SIDefines.h:228
llvm::pdb::PDBFile::getPDBGlobalsStream
Expected< GlobalsStream & > getPDBGlobalsStream()
Definition: PDBFile.cpp:258
NativeSession.h