forked from OSchip/llvm-project
A bit more cleanup on the process_events.py to use best practices for event handling.
llvm-svn: 185089
This commit is contained in:
parent
7dcbe3d356
commit
96eb9ab047
|
@ -174,7 +174,6 @@ def main(argv):
|
||||||
pid = process.GetProcessID()
|
pid = process.GetProcessID()
|
||||||
listener = debugger.GetListener()
|
listener = debugger.GetListener()
|
||||||
# sign up for process state change events
|
# sign up for process state change events
|
||||||
#process.GetBroadcaster().AddListener(listener, lldb.SBProcess.eBroadcastBitStateChanged)
|
|
||||||
stop_idx = 0
|
stop_idx = 0
|
||||||
done = False
|
done = False
|
||||||
while not done:
|
while not done:
|
||||||
|
@ -182,7 +181,11 @@ def main(argv):
|
||||||
if listener.WaitForEvent (options.event_timeout, event):
|
if listener.WaitForEvent (options.event_timeout, event):
|
||||||
if lldb.SBProcess.EventIsProcessEvent(event):
|
if lldb.SBProcess.EventIsProcessEvent(event):
|
||||||
state = lldb.SBProcess.GetStateFromEvent (event)
|
state = lldb.SBProcess.GetStateFromEvent (event)
|
||||||
print "event %s" % (lldb.SBDebugger.StateAsCString(state))
|
if state == lldb.eStateInvalid:
|
||||||
|
# Not a state event
|
||||||
|
print 'process event = %s' % (event)
|
||||||
|
else:
|
||||||
|
print "process state changed event: %s" % (lldb.SBDebugger.StateAsCString(state))
|
||||||
if state == lldb.eStateStopped:
|
if state == lldb.eStateStopped:
|
||||||
if stop_idx == 0:
|
if stop_idx == 0:
|
||||||
if launch_info:
|
if launch_info:
|
||||||
|
@ -234,10 +237,25 @@ def main(argv):
|
||||||
print "process attaching"
|
print "process attaching"
|
||||||
elif state == lldb.eStateLaunching:
|
elif state == lldb.eStateLaunching:
|
||||||
print "process launching"
|
print "process launching"
|
||||||
|
else:
|
||||||
|
print 'event = %s' % (event)
|
||||||
else:
|
else:
|
||||||
# timeout waiting for an event
|
# timeout waiting for an event
|
||||||
print "no process event for %u seconds, killing the process..." % (options.event_timeout)
|
print "no process event for %u seconds, killing the process..." % (options.event_timeout)
|
||||||
done = True
|
done = True
|
||||||
|
# Now that we are done dump the stdout and stderr
|
||||||
|
process_stdout = process.GetSTDOUT(1024)
|
||||||
|
if process_stdout:
|
||||||
|
print "Process STDOUT:\n%s" % (process_stdout)
|
||||||
|
while process_stdout:
|
||||||
|
process_stdout = process.GetSTDOUT(1024)
|
||||||
|
print process_stdout
|
||||||
|
process_stderr = process.GetSTDERR(1024)
|
||||||
|
if process_stderr:
|
||||||
|
print "Process STDERR:\n%s" % (process_stderr)
|
||||||
|
while process_stderr:
|
||||||
|
process_stderr = process.GetSTDERR(1024)
|
||||||
|
print process_stderr
|
||||||
process.Kill() # kill the process
|
process.Kill() # kill the process
|
||||||
else:
|
else:
|
||||||
if error:
|
if error:
|
||||||
|
|
Loading…
Reference in New Issue