mirror of
https://github.com/Fishwaldo/linux-bl808.git
synced 2025-06-17 20:25:19 +00:00
perf script python: Add support for sqlite3 to call-graph-from-sql.py
Add support for SQLite 3 to the call-graph-from-sql.py script. The SQL statements work as is, so just detect the database type by checking if the SQLite 3 file exists. Committer notes: Tested collecting the PT data on a RHEL7.4, generating the SQLite3 database there and then moving it to a Fedora 26 system where the call-graph-from-sql.py script was run, using python-pyside version 1.2.2-7fc26 to see the callgraphs using Qt4. Signed-off-by: Adrian Hunter <adrian.hunter@intel.com> Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com> Link: http://lkml.kernel.org/r/1501749090-20357-6-git-send-email-adrian.hunter@intel.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
This commit is contained in:
parent
69e6e410f1
commit
1fe03b5f2d
1 changed files with 35 additions and 23 deletions
|
@ -1,5 +1,5 @@
|
||||||
#!/usr/bin/python2
|
#!/usr/bin/python2
|
||||||
# call-graph-from-sql.py: create call-graph from postgresql database
|
# call-graph-from-sql.py: create call-graph from sql database
|
||||||
# Copyright (c) 2014-2017, Intel Corporation.
|
# Copyright (c) 2014-2017, Intel Corporation.
|
||||||
#
|
#
|
||||||
# This program is free software; you can redistribute it and/or modify it
|
# This program is free software; you can redistribute it and/or modify it
|
||||||
|
@ -11,16 +11,17 @@
|
||||||
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||||
# more details.
|
# more details.
|
||||||
|
|
||||||
# To use this script you will need to have exported data using the
|
# To use this script you will need to have exported data using either the
|
||||||
# export-to-postgresql.py script. Refer to that script for details.
|
# export-to-sqlite.py or the export-to-postgresql.py script. Refer to those
|
||||||
|
# scripts for details.
|
||||||
#
|
#
|
||||||
# Following on from the example in the export-to-postgresql.py script, a
|
# Following on from the example in the export scripts, a
|
||||||
# call-graph can be displayed for the pt_example database like this:
|
# call-graph can be displayed for the pt_example database like this:
|
||||||
#
|
#
|
||||||
# python tools/perf/scripts/python/call-graph-from-sql.py pt_example
|
# python tools/perf/scripts/python/call-graph-from-sql.py pt_example
|
||||||
#
|
#
|
||||||
# Note this script supports connecting to remote databases by setting hostname,
|
# Note that for PostgreSQL, this script supports connecting to remote databases
|
||||||
# port, username, password, and dbname e.g.
|
# by setting hostname, port, username, password, and dbname e.g.
|
||||||
#
|
#
|
||||||
# python tools/perf/scripts/python/call-graph-from-sql.py "hostname=myhost username=myuser password=mypassword dbname=pt_example"
|
# python tools/perf/scripts/python/call-graph-from-sql.py "hostname=myhost username=myuser password=mypassword dbname=pt_example"
|
||||||
#
|
#
|
||||||
|
@ -296,24 +297,35 @@ if __name__ == '__main__':
|
||||||
|
|
||||||
dbname = sys.argv[1]
|
dbname = sys.argv[1]
|
||||||
|
|
||||||
db = QSqlDatabase.addDatabase('QPSQL')
|
is_sqlite3 = False
|
||||||
|
try:
|
||||||
|
f = open(dbname)
|
||||||
|
if f.read(15) == "SQLite format 3":
|
||||||
|
is_sqlite3 = True
|
||||||
|
f.close()
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
|
||||||
opts = dbname.split()
|
if is_sqlite3:
|
||||||
for opt in opts:
|
db = QSqlDatabase.addDatabase('QSQLITE')
|
||||||
if '=' in opt:
|
else:
|
||||||
opt = opt.split('=')
|
db = QSqlDatabase.addDatabase('QPSQL')
|
||||||
if opt[0] == 'hostname':
|
opts = dbname.split()
|
||||||
db.setHostName(opt[1])
|
for opt in opts:
|
||||||
elif opt[0] == 'port':
|
if '=' in opt:
|
||||||
db.setPort(int(opt[1]))
|
opt = opt.split('=')
|
||||||
elif opt[0] == 'username':
|
if opt[0] == 'hostname':
|
||||||
db.setUserName(opt[1])
|
db.setHostName(opt[1])
|
||||||
elif opt[0] == 'password':
|
elif opt[0] == 'port':
|
||||||
db.setPassword(opt[1])
|
db.setPort(int(opt[1]))
|
||||||
elif opt[0] == 'dbname':
|
elif opt[0] == 'username':
|
||||||
dbname = opt[1]
|
db.setUserName(opt[1])
|
||||||
else:
|
elif opt[0] == 'password':
|
||||||
dbname = opt
|
db.setPassword(opt[1])
|
||||||
|
elif opt[0] == 'dbname':
|
||||||
|
dbname = opt[1]
|
||||||
|
else:
|
||||||
|
dbname = opt
|
||||||
|
|
||||||
db.setDatabaseName(dbname)
|
db.setDatabaseName(dbname)
|
||||||
if not db.open():
|
if not db.open():
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue