[0.1.x] ~ fixed and supplemented breakpoint tests

git-svn-id: https://pykd.svn.codeplex.com/svn@73583 9b283d60-5439-405e-af05-b73fd8c4d996
This commit is contained in:
SND\EreTIk_cp 2012-01-24 20:40:07 +00:00 committed by Mikhail I. Izmestev
parent ebc6910cd6
commit 961932950b
2 changed files with 36 additions and 16 deletions

View File

@ -26,7 +26,7 @@ class BreakExceptionHandler(pykd.eventHandler):
"""Breakpoint handler"""
self.wasBreakpoint = True
self.wasBreakpointIds.append( bpId )
return pykd.DEBUG_STATUS_NO_CHANGE
return pykd.DEBUG_STATUS_BREAK
def onException(self, exceptParams):
"""Exception handler"""
@ -41,7 +41,7 @@ class BreakExceptionHandler(pykd.eventHandler):
elif exceptParams["Code"] == pykd.EXCEPTION_BREAKPOINT:
self.bpCount += 1
return pykd.DEBUG_STATUS_BREAK if self.wasSecondChance else pykd.DEBUG_STATUS_NO_CHANGE
return pykd.DEBUG_STATUS_BREAK
class EhExceptionBreakpointTest(unittest.TestCase):
"""Unit tests of exceptions end breakpoint handling"""
@ -55,33 +55,51 @@ class EhExceptionBreakpointTest(unittest.TestCase):
bpIdSoftware = testClient.setBp( targetMod.offset("changeValueForAccessTesting") )
bpIdHwExecute = testClient.setBp( targetMod.offset("readValueForAccessTesting"),
1,
pykd.DEBUG_BREAK_EXECUTE )
allBp = testClient.getAllBp()
self.assertEqual( 1, len( allBp ) )
self.assertTrue( bpIdSoftware in allBp )
bpIdHwWrite = testClient.setBp( targetMod.offset("g_valueForAccessTesting1"),
1,
pykd.DEBUG_BREAK_WRITE )
bpIdHwRead = testClient.setBp( targetMod.offset("g_valueForAccessTesting2"),
1,
pykd.DEBUG_BREAK_READ )
self.assertEqual( 4, len( testClient.getAllBp() ) )
hwBpIsNotSet = True
# kd> ba e 1 <some_address>
# ^ Unable to set breakpoint error
# The system resets thread contexts after the process
# breakpoint so hardware breakpoints cannot be set.
# Go to the executable's entry point and set it then.
breakExceptionHandler = BreakExceptionHandler( testClient )
while not breakExceptionHandler.wasSecondChance:
testClient.go()
if hwBpIsNotSet:
hwBpIsNotSet = False
bpIdHwExecute = testClient.setBp( targetMod.offset("readValueForAccessTesting"),
1, pykd.DEBUG_BREAK_EXECUTE )
bpIdHwWrite = testClient.setBp( targetMod.offset("g_valueForAccessTesting1"),
1, pykd.DEBUG_BREAK_WRITE )
bpIdHwRead = testClient.setBp( targetMod.offset("g_valueForAccessTesting2"),
1, pykd.DEBUG_BREAK_READ )
allBp = testClient.getAllBp()
self.assertEqual( 4, len( allBp ) )
self.assertTrue( bpIdSoftware in allBp )
self.assertTrue( bpIdHwExecute in allBp )
self.assertTrue( bpIdHwWrite in allBp )
self.assertTrue( bpIdHwRead in allBp )
self.assertTrue( breakExceptionHandler.wasBreakpoint )
self.assertEqual( [2, 3], breakExceptionHandler.firstChanceAccessAddresses )
self.assertEqual( 2, breakExceptionHandler.bpCount ) # main and doExeptions
self.assertEqual( 3, breakExceptionHandler.bpCount ) # main and 2 in doExeptions
self.assertEqual( [3, ], breakExceptionHandler.secondChanceAccessAddresses )
self.assertTrue( breakExceptionHandler.wasBreakpoint )
self.assertTrue( bpIdSoftware in breakExceptionHandler.wasBreakpointIds )
self.assertTrue( bpIdHwExecute in breakExceptionHandler.wasBreakpointIds )
self.assertTrue( bpIdHwWrite in breakExceptionHandler.wasBreakpointIds )
self.assertTrue( bpIdHwRead in breakExceptionHandler.wasBreakpointIds )
testClient.removeBp(bpIdHwRead)
self.assertEqual( 3, len( testClient.getAllBp() ) )

View File

@ -367,6 +367,8 @@ void readValueForAccessTesting()
int doExeptions()
{
__debugbreak();
changeValueForAccessTesting();
readValueForAccessTesting();