1#!/usr/bin/env python 2# Copyright 2020 The Chromium Authors. All rights reserved. 3# Use of this source code is governed by a BSD-style license that can be 4# found in the LICENSE file. 5 6import subprocess 7import sys 8import threading 9import time 10 11# Usage: ios_debug_cmd.py <bundle_id> <args...> 12# Runs the given app with the given args with full debug output enabled, then 13# outputs syslog for the period when the command was running. Exits with the 14# exit code of idevicedebug. 15 16 17bundle_id = sys.argv[1] 18args = sys.argv[2:] 19 20logp = subprocess.Popen(['idevicesyslog'], stdout=subprocess.PIPE, bufsize=-1) 21log = '' 22def collect_log(): 23 global log 24 while True: 25 out = logp.stdout.read().decode('utf-8') 26 if out: 27 log = log + out 28 else: 29 return 30 31logt = threading.Thread(target=collect_log) 32logt.start() 33 34rv = subprocess.call(['idevicedebug', '--debug', 'run', bundle_id] + args) 35 36print('\n\nreturned %d' % rv) 37 38logp.terminate() 39print('\n\nreading syslog...') 40logt.join() 41print('syslog follows') 42print(log) 43 44exit(rv) 45