From 729b3a0af5604c775560873baf4d85b3c2b6809b Mon Sep 17 00:00:00 2001 From: "SND\\EreTIk_cp" Date: Thu, 28 Mar 2013 18:50:37 +0000 Subject: [PATCH] [0.2.x] ~refactoring git-svn-id: https://pykd.svn.codeplex.com/svn@83102 9b283d60-5439-405e-af05-b73fd8c4d996 --- pykd/symsessioncache.cpp | 128 ++++++++++++++++++++------------------- 1 file changed, 66 insertions(+), 62 deletions(-) diff --git a/pykd/symsessioncache.cpp b/pykd/symsessioncache.cpp index 68268f1..55d712b 100644 --- a/pykd/symsessioncache.cpp +++ b/pykd/symsessioncache.cpp @@ -11,12 +11,23 @@ namespace pykd { +///////////////////////////////////////////////////////////////////////////////////// + +namespace +{ + + + ///////////////////////////////////////////////////////////////////////////////////// class Impl : protected DEBUG_EVENT_CALLBACK { public: - Impl(); - ~Impl(); + Impl() { + eventRegisterCallbacks(this); + } + ~Impl() { + eventRemoveCallbacks(this); + } bool find(const SymCacheModuleKey &cacheKey, SymbolSessionPtr &symSession); @@ -57,32 +68,6 @@ private: ///////////////////////////////////////////////////////////////////////////////////// -Impl::Impl() -{ - eventRegisterCallbacks(this); -} - -///////////////////////////////////////////////////////////////////////////////////// - -Impl::~Impl() -{ - eventRemoveCallbacks(this); -} - -///////////////////////////////////////////////////////////////////////////////////// - -DEBUG_CALLBACK_RESULT Impl::OnModuleUnload( ULONG64 modBase, const std::string & ) -{ - boost::recursive_mutex::scoped_lock l(m_base2KeyLock); - if (modBase) - m_base2Key.erase(modBase); - else - m_base2Key.clear(); - return DebugCallbackNoChange; -} - -///////////////////////////////////////////////////////////////////////////////////// - void Impl::onSymbolsUnloaded(ULONG64 modBase) { if (!modBase) @@ -107,25 +92,6 @@ void Impl::onSymbolsUnloaded(ULONG64 modBase) ///////////////////////////////////////////////////////////////////////////////////// -namespace -{ - -Impl &getImpl() -{ - // construct after DebugEngine - static Impl g_Impl; - return g_Impl; -} - -} - -///////////////////////////////////////////////////////////////////////////////////// - -bool findSymCacheEntry(const SymCacheModuleKey &cacheKey, SymbolSessionPtr &symSession) -{ - return getImpl().find(cacheKey, symSession); -} - bool Impl::find(const SymCacheModuleKey &cacheKey, SymbolSessionPtr &symSession) { boost::recursive_mutex::scoped_lock l(m_key2SymLock); @@ -142,11 +108,6 @@ bool Impl::find(const SymCacheModuleKey &cacheKey, SymbolSessionPtr &symSession) ///////////////////////////////////////////////////////////////////////////////////// -void insertSymCacheEntry(ULONG64 modBase, const SymCacheModuleKey &cacheKey, SymbolSessionPtr symSession) -{ - return getImpl().insert(modBase, cacheKey, symSession); -} - void Impl::insert(ULONG64 modBase, const SymCacheModuleKey &cacheKey, SymbolSessionPtr symSession) { { @@ -162,11 +123,6 @@ void Impl::insert(ULONG64 modBase, const SymCacheModuleKey &cacheKey, SymbolSess ///////////////////////////////////////////////////////////////////////////////////// -void eraseSymCacheEntry(const SymCacheModuleKey &cacheKey) -{ - return getImpl().erase(cacheKey); -} - void Impl::erase(const SymCacheModuleKey &cacheKey) { boost::recursive_mutex::scoped_lock l(m_key2SymLock); @@ -175,11 +131,6 @@ void Impl::erase(const SymCacheModuleKey &cacheKey) ///////////////////////////////////////////////////////////////////////////////////// -void clearSymCache() -{ - return getImpl().clear(); -} - void Impl::clear() { boost::recursive_mutex::scoped_lock l(m_key2SymLock); @@ -188,6 +139,59 @@ void Impl::clear() ///////////////////////////////////////////////////////////////////////////////////// +DEBUG_CALLBACK_RESULT Impl::OnModuleUnload( ULONG64 modBase, const std::string & ) +{ + boost::recursive_mutex::scoped_lock l(m_base2KeyLock); + if (modBase) + m_base2Key.erase(modBase); + else + m_base2Key.clear(); + return DebugCallbackNoChange; +} + +///////////////////////////////////////////////////////////////////////////////////// + +Impl &getImpl() +{ + // construct after DebugEngine + static Impl g_Impl; + return g_Impl; +} + +///////////////////////////////////////////////////////////////////////////////////// + +} + +///////////////////////////////////////////////////////////////////////////////////// + +bool findSymCacheEntry(const SymCacheModuleKey &cacheKey, SymbolSessionPtr &symSession) +{ + return getImpl().find(cacheKey, symSession); +} + +///////////////////////////////////////////////////////////////////////////////////// + +void insertSymCacheEntry(ULONG64 modBase, const SymCacheModuleKey &cacheKey, SymbolSessionPtr symSession) +{ + return getImpl().insert(modBase, cacheKey, symSession); +} + +///////////////////////////////////////////////////////////////////////////////////// + +void eraseSymCacheEntry(const SymCacheModuleKey &cacheKey) +{ + return getImpl().erase(cacheKey); +} + +///////////////////////////////////////////////////////////////////////////////////// + +void clearSymCache() +{ + return getImpl().clear(); +} + +///////////////////////////////////////////////////////////////////////////////////// + } // namespace pykd //////////////////////////////////////////////////////////////////////////////