mirror of
https://github.com/ivellioscolin/pykd.git
synced 2025-04-21 04:13:22 +08:00
[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:
parent
ebc6910cd6
commit
961932950b
@ -26,7 +26,7 @@ class BreakExceptionHandler(pykd.eventHandler):
|
|||||||
"""Breakpoint handler"""
|
"""Breakpoint handler"""
|
||||||
self.wasBreakpoint = True
|
self.wasBreakpoint = True
|
||||||
self.wasBreakpointIds.append( bpId )
|
self.wasBreakpointIds.append( bpId )
|
||||||
return pykd.DEBUG_STATUS_NO_CHANGE
|
return pykd.DEBUG_STATUS_BREAK
|
||||||
|
|
||||||
def onException(self, exceptParams):
|
def onException(self, exceptParams):
|
||||||
"""Exception handler"""
|
"""Exception handler"""
|
||||||
@ -41,7 +41,7 @@ class BreakExceptionHandler(pykd.eventHandler):
|
|||||||
elif exceptParams["Code"] == pykd.EXCEPTION_BREAKPOINT:
|
elif exceptParams["Code"] == pykd.EXCEPTION_BREAKPOINT:
|
||||||
self.bpCount += 1
|
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):
|
class EhExceptionBreakpointTest(unittest.TestCase):
|
||||||
"""Unit tests of exceptions end breakpoint handling"""
|
"""Unit tests of exceptions end breakpoint handling"""
|
||||||
@ -55,33 +55,51 @@ class EhExceptionBreakpointTest(unittest.TestCase):
|
|||||||
|
|
||||||
bpIdSoftware = testClient.setBp( targetMod.offset("changeValueForAccessTesting") )
|
bpIdSoftware = testClient.setBp( targetMod.offset("changeValueForAccessTesting") )
|
||||||
|
|
||||||
bpIdHwExecute = testClient.setBp( targetMod.offset("readValueForAccessTesting"),
|
allBp = testClient.getAllBp()
|
||||||
1,
|
self.assertEqual( 1, len( allBp ) )
|
||||||
pykd.DEBUG_BREAK_EXECUTE )
|
self.assertTrue( bpIdSoftware in allBp )
|
||||||
|
|
||||||
bpIdHwWrite = testClient.setBp( targetMod.offset("g_valueForAccessTesting1"),
|
hwBpIsNotSet = True
|
||||||
1,
|
# kd> ba e 1 <some_address>
|
||||||
pykd.DEBUG_BREAK_WRITE )
|
# ^ Unable to set breakpoint error
|
||||||
|
# The system resets thread contexts after the process
|
||||||
bpIdHwRead = testClient.setBp( targetMod.offset("g_valueForAccessTesting2"),
|
# breakpoint so hardware breakpoints cannot be set.
|
||||||
1,
|
# Go to the executable's entry point and set it then.
|
||||||
pykd.DEBUG_BREAK_READ )
|
|
||||||
|
|
||||||
self.assertEqual( 4, len( testClient.getAllBp() ) )
|
|
||||||
|
|
||||||
breakExceptionHandler = BreakExceptionHandler( testClient )
|
breakExceptionHandler = BreakExceptionHandler( testClient )
|
||||||
while not breakExceptionHandler.wasSecondChance:
|
while not breakExceptionHandler.wasSecondChance:
|
||||||
testClient.go()
|
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, 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.assertEqual( [3, ], breakExceptionHandler.secondChanceAccessAddresses )
|
||||||
|
|
||||||
|
self.assertTrue( breakExceptionHandler.wasBreakpoint )
|
||||||
|
|
||||||
self.assertTrue( bpIdSoftware in breakExceptionHandler.wasBreakpointIds )
|
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)
|
testClient.removeBp(bpIdHwRead)
|
||||||
self.assertEqual( 3, len( testClient.getAllBp() ) )
|
self.assertEqual( 3, len( testClient.getAllBp() ) )
|
||||||
|
@ -367,6 +367,8 @@ void readValueForAccessTesting()
|
|||||||
|
|
||||||
int doExeptions()
|
int doExeptions()
|
||||||
{
|
{
|
||||||
|
__debugbreak();
|
||||||
|
|
||||||
changeValueForAccessTesting();
|
changeValueForAccessTesting();
|
||||||
|
|
||||||
readValueForAccessTesting();
|
readValueForAccessTesting();
|
||||||
|
Loading…
Reference in New Issue
Block a user