diff --git a/lib/DxilDia/DxilDiaSession.cpp b/lib/DxilDia/DxilDiaSession.cpp index 1c45aa6f53..52c903ae03 100644 --- a/lib/DxilDia/DxilDiaSession.cpp +++ b/lib/DxilDia/DxilDiaSession.cpp @@ -96,13 +96,15 @@ void dxil_dia::Session::Init(std::shared_ptr context, DXASSERT(m_rvaMap[It->second] == It->first, "instruction mapped to wrong rva"); } +} - // Initialize symbols +const dxil_dia::SymbolManager &dxil_dia::Session::SymMgr() { try { m_symsMgr.Init(this); } catch (const hlsl::Exception &) { m_symsMgr = dxil_dia::SymbolManager(); } + return m_symsMgr; } HRESULT dxil_dia::Session::getSourceFileIdByName(llvm::StringRef fileName, @@ -138,7 +140,7 @@ STDMETHODIMP dxil_dia::Session::get_globalScope( *pRetVal = nullptr; Symbol *ret; - IFR(m_symsMgr.GetGlobalScope(&ret)); + IFR(SymMgr().GetGlobalScope(&ret)); *pRetVal = ret; return S_OK; } @@ -378,7 +380,7 @@ STDMETHODIMP dxil_dia::Session::findInlineFramesByAddr( HRESULT hr; SymbolChildrenEnumerator *ChildrenEnum; - IFR(hr = m_symsMgr.DbgScopeOf(It->second, &ChildrenEnum)); + IFR(hr = SymMgr().DbgScopeOf(It->second, &ChildrenEnum)); *ppResult = ChildrenEnum; return hr; diff --git a/lib/DxilDia/DxilDiaSession.h b/lib/DxilDia/DxilDiaSession.h index 9ea27f308b..945462c95f 100644 --- a/lib/DxilDia/DxilDiaSession.h +++ b/lib/DxilDia/DxilDiaSession.h @@ -61,7 +61,7 @@ class Session : public IDiaSession, public IDxcPixDxilDebugInfoFactory { hlsl::DxilModule &DxilModuleRef() { return *m_dxilModule.get(); } llvm::Module &ModuleRef() { return *m_module.get(); } llvm::DebugInfoFinder &InfoRef() { return *m_finder.get(); } - const SymbolManager &SymMgr() const { return m_symsMgr; } + const SymbolManager &SymMgr(); const RVAMap &InstructionsRef() const { return m_instructions; } const std::vector &InstructionLinesRef() const { return m_instructionLines; diff --git a/lib/DxilDia/DxilDiaSymbolManager.cpp b/lib/DxilDia/DxilDiaSymbolManager.cpp index 28a265f2d7..5f612da934 100644 --- a/lib/DxilDia/DxilDiaSymbolManager.cpp +++ b/lib/DxilDia/DxilDiaSymbolManager.cpp @@ -2343,7 +2343,8 @@ dxil_dia::SymbolManager::SymbolManager() = default; dxil_dia::SymbolManager::~SymbolManager() { m_pSession = nullptr; } void dxil_dia::SymbolManager::Init(Session *pSes) { - DXASSERT(m_pSession == nullptr, "SymbolManager already initialized"); + if (m_pSession != nullptr) + return; // Already initialized m_pSession = pSes; m_symbolCtors.clear(); m_parentToChildren.clear();