Skip to content

Commit

Permalink
Explicitly iterate symbols of selected tags, which makes it much fast…
Browse files Browse the repository at this point in the history
…er for some symbol files
  • Loading branch information
m417z committed Sep 26, 2024
1 parent 2985458 commit 43f2c3c
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
12 changes: 9 additions & 3 deletions symbol_enum.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -371,11 +371,10 @@ SymbolEnum::SymbolEnum(PCWSTR modulePath,
wil::com_ptr<IDiaSession> diaSession;
THROW_IF_FAILED(diaSource->openSession(&diaSession));

wil::com_ptr<IDiaSymbol> diaGlobal;
THROW_IF_FAILED(diaSession->get_globalScope(&diaGlobal));
THROW_IF_FAILED(diaSession->get_globalScope(&m_diaGlobal));

THROW_IF_FAILED(
diaGlobal->findChildren(SymTagNull, nullptr, nsNone, &m_diaSymbols));
m_diaGlobal->findChildren(kSymTags[0], nullptr, nsNone, &m_diaSymbols));
}

std::optional<SymbolEnum::Symbol> SymbolEnum::GetNextSymbol() {
Expand All @@ -386,6 +385,13 @@ std::optional<SymbolEnum::Symbol> SymbolEnum::GetNextSymbol() {
THROW_IF_FAILED(hr);

if (hr == S_FALSE || count == 0) {
m_symTagIndex++;
if (m_symTagIndex < ARRAYSIZE(kSymTags)) {
THROW_IF_FAILED(m_diaGlobal->findChildren(
kSymTags[m_symTagIndex], nullptr, nsNone, &m_diaSymbols));
continue;
}

return std::nullopt;
}

Expand Down
8 changes: 8 additions & 0 deletions symbol_enum.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,18 @@ class SymbolEnum {
private:
wil::com_ptr<IDiaDataSource> LoadMsdia();

static constexpr enum SymTagEnum kSymTags[] = {
SymTagPublicSymbol,
SymTagFunction,
SymTagData,
};

HMODULE m_moduleBase;
UndecorateMode m_undecorateMode;
wil::unique_hmodule m_msdiaModule;
wil::com_ptr<IDiaSymbol> m_diaGlobal;
wil::com_ptr<IDiaEnumSymbols> m_diaSymbols;
size_t m_symTagIndex = 0;
wil::unique_bstr m_currentSymbolName;
wil::unique_bstr m_currentDecoratedSymbolName;
};

0 comments on commit 43f2c3c

Please sign in to comment.