1
"""Execution symbols state event test"""
8
class SymbolsStateHandler(pykd.eventHandler):
9
def __init__(self, modBase):
10
pykd.eventHandler.__init__(self)
11
self._modBase = modBase
13
self.unloadModuleTrigged = False
14
self.unloadAllModulesTrigged = False
16
def onSymbolsLoaded(self, modBase):
18
self.modNames.add( pykd.module(modBase).name() )
20
def onSymbolsUnloaded(self, modBase):
22
self.unloadAllModulesTrigged = True
23
elif self._modBase == modBase:
24
self.unloadModuleTrigged = True
26
class EhSymbolsTest(unittest.TestCase):
27
"""Execution symbols state event test"""
29
def testChangeSymbolsState(self):
30
"""Start new process and track change symbols exception"""
31
_locProcessId = pykd.startProcess( target.appPath + " -testLoadUnload" )
32
with testutils.ContextCallIt( testutils.KillProcess(_locProcessId) ) as killStartedProcess:
34
mod = pykd.module("targetapp")
35
symbolsStateHandler = SymbolsStateHandler( mod.begin() )
37
pykd.dbgCommand(".reload /u targetapp.exe")
38
self.assertTrue( symbolsStateHandler.unloadModuleTrigged )
40
pykd.dbgCommand(".reload /u")
41
self.assertTrue( symbolsStateHandler.unloadAllModulesTrigged )
43
self.assertRaises(pykd.WaitEventException, testutils.infGo)
45
self.assertTrue( "iphlpapi" in symbolsStateHandler.modNames )