blob: 6839c68a45de4fee3b73a9b29957e67e045b6f14 [file] [log] [blame]
#!/usr/bin/env python3
# Copyright 2020 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
"""Prints the specified trace file information in JSON format"""
from __future__ import print_function
import argparse
import hashlib
import json
import os
import subprocess
import sys
import utils
def main(args):
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument('trace_file', help='.trace file name')
opts = parser.parse_args(args)
trace_fname = opts.trace_file
if not os.path.isfile(trace_fname):
utils.panic('Unable to open <%s>. File not found.' % trace_fname)
cmd = ['apitrace', 'info', '--json', trace_fname]
result =
cmd, check=True, encoding='utf-8', capture_output=True)
res = json.loads(result.stdout)
data_results = {
'trace_file_version': res['FileVersion'],
'trace_frames_count': res['FramesCount'],
print(json.dumps(data_results, indent=2, sort_keys=True))
except subprocess.CalledProcessError as e:
utils.panic(f'Unable to retreive {trace_fname} information. {str(e)}')
except Exception as e:
utils.panic(f'Unable to decode apitrace info output: <{str(e)}>')
if __name__ == '__main__':