• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/usr/bin/python3
2# Copyright (C) 2019 The Android Open Source Project
3#
4# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License at
7#
8#      http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
15
16import re
17import sys
18import argparse
19
20from lib.trace2db import Trace2Db
21
22# This script requires 'sqlalchemy' to access the sqlite3 database.
23#
24# $> sudo apt-get install python3-pip
25# $> pip3 install --user sqlalchemy
26#
27
28def main(argv):
29  parser = argparse.ArgumentParser(description='Convert ftrace/systrace file into sqlite3 db.')
30  parser.add_argument('db_filename', metavar='sql_filename.db', type=str,
31                      help='path to sqlite3 db filename')
32  parser.add_argument('trace_filename', metavar='systrace.ftrace', type=str,
33                      help='path to ftrace/systrace filename')
34  parser.add_argument('--limit', type=int, help='limit the number of entries parsed [for debugging]')
35
36  args = parser.parse_args()
37
38  db_filename = args.db_filename
39  trace_filename = args.trace_filename
40
41  trace2db = Trace2Db(db_filename)
42  print("SQL Alchemy db initialized")
43
44  # parse 'raw_ftrace_entries' table
45  count = trace2db.parse_file_into_db(trace_filename, limit=args.limit)
46  print("Count was ", count)
47
48  return 0
49
50if __name__ == '__main__':
51  main(sys.argv)
52