36 lines · python
1import lldb2import time3 4class 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 key8 # for these dictionaries, and then the test can fetch out the right9 # one.10 counter = {}11 non_stops = {}12 def __init__(self, target, extra_args, dict):13 self.target = target14 self.regs = {}15 self.instance = extra_args.GetValueForKey("instance").GetStringValue(100)16 StopHook.counter[self.instance] = 017 StopHook.non_stops[self.instance] = 018 19 def handle_stop(self, exe_ctx, stream):20 import time21 # All this stop hook does is sleep a bit and count. There was a bug22 # where we were sending the secondary listener events when the23 # private state thread's DoOnRemoval completed, rather than when24 # the primary public process Listener consumes the event. That25 # became really clear when a stop hook artificially delayed the26 # delivery of the primary listener's event - since IT had to come27 # after the stop hook ran.28 time.sleep(0.5)29 StopHook.counter[self.instance] += 130 # When we were sending events too early, one symptom was the stop31 # 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] += 135 36