|
| 1 | +import lldb |
| 2 | +import time |
| 3 | + |
| 4 | +class StopHook: |
| 5 | + # These dictionaries are used to pass data back to the test case. |
| 6 | + # Since these are global, we need to know which test run is which. |
| 7 | + # The test passes a key in the extra_args, we use that as the key |
| 8 | + # for these dictionaries, and then the test can fetch out the right |
| 9 | + # one. |
| 10 | + counter = {} |
| 11 | + non_stops = {} |
| 12 | + def __init__(self, target, extra_args, dict): |
| 13 | + self.target = target |
| 14 | + self.regs = {} |
| 15 | + self.instance = extra_args.GetValueForKey("instance").GetStringValue(100) |
| 16 | + StopHook.counter[self.instance] = 0 |
| 17 | + StopHook.non_stops[self.instance] = 0 |
| 18 | + |
| 19 | + def handle_stop(self, exe_ctx, stream): |
| 20 | + import time |
| 21 | + # All this stop hook does is sleep a bit and count. There was a bug |
| 22 | + # where we were sending the secondary listener events when the |
| 23 | + # private state thread's DoOnRemoval completed, rather than when |
| 24 | + # the primary public process Listener consumes the event. That |
| 25 | + # became really clear when a stop hook artificially delayed the |
| 26 | + # delivery of the primary listener's event - since IT had to come |
| 27 | + # after the stop hook ran. |
| 28 | + time.sleep(0.5) |
| 29 | + StopHook.counter[self.instance] += 1 |
| 30 | + # When we were sending events too early, one symptom was the stop |
| 31 | + # event would get triggered before the state had been changed. |
| 32 | + # Watch for that here. |
| 33 | + if exe_ctx.process.GetState() != lldb.eStateStopped: |
| 34 | + StopHook.non_stops[self.instance] += 1 |
| 35 | + |
0 commit comments