fix bug in PostHookBreakpoint, add test

This commit is contained in:
l1berty
2014-11-15 12:45:26 -05:00
parent 8d472ea95d
commit ea9efd54d4
2 changed files with 26 additions and 1 deletions
+5 -1
View File
@@ -389,6 +389,10 @@ class PostHookBreakpoint(NiceBreakpoint):
print('Post hook callback "%s" exception: %s' % (hook_cb, str(e)))
def notify(self, event, trace):
ret_addr, args = self.parent.callinfo[trace.getCurrentThread()]
tup = self.parent.callinfo.get(trace.getCurrentThread(), None)
if tup == None:
return
ret_addr, args = tup
self.runPostHookCallbacks(event, trace, ret_addr, args)
+21
View File
@@ -0,0 +1,21 @@
import unittest
import vtrace.breakpoints
# TODO: move testmods.hookbptest tests in here as well.
class MockTrace(object):
def getCurrentThread(self):
return 0
class HookBpPostTests(unittest.TestCase):
def test_PostHitNoCallinfo(self):
'''
tests condition where:
1. thread 1 hits hookbp and sets up postbp
2. thread 2 hits postbp (there's nothing in callinfo for thread 2)
'''
hbp = vtrace.breakpoints.HookBreakpoint('0xdeadbeef')
phbp = vtrace.breakpoints.PostHookBreakpoint('0xcafebabe', hbp)
phbp.notify(None, MockTrace())