Skip to contentSkip to conversation

perf script: Add support for exporting to sqlite3

PATCH In review Adrian Hunter 3 participants 13 messages Aug 3, 2017 – Aug 17, 2017 perf events

lore
Share & tools
lore

Adrian Hunter

author reviewer
#0 lore raw

cover perf script: Add support for exporting to sqlite3

Hi

Here is a script for exporting to SQLite 3 the same data as the PostgreSQL export. The call-graph script is renamed and amended to work with both PostgreSQL and SQLite.

Adrian Hunter (5):
perf script: Fix missing call_path_id in export-to-postgresql script perf script: Fix query in call-graph-from-postgresql.py
perf script: Add support for exporting to sqlite3
perf script: Rename call-graph-from-postgresql.py to call-graph-from-sql.py perf script: Add support for sqlite3 to call-graph-from-sql.py

 tools/perf/Documentation/intel-pt.txt              |   6 +-
 .../scripts/python/bin/export-to-sqlite-record     |   8 +
 .../scripts/python/bin/export-to-sqlite-report     |  29 ++
 ...h-from-postgresql.py => call-graph-from-sql.py} |  70 ++--
 tools/perf/scripts/python/export-to-postgresql.py  |   5 +-
 tools/perf/scripts/python/export-to-sqlite.py      | 451 +++++++++++++++++++++
 6 files changed, 535 insertions(+), 34 deletions(-)
 create mode 100644 tools/perf/scripts/python/bin/export-to-sqlite-record
 create mode 100644 tools/perf/scripts/python/bin/export-to-sqlite-report
 rename tools/perf/scripts/python/{call-graph-from-postgresql.py => call-graph-from-sql.py} (87%)
 create mode 100644 tools/perf/scripts/python/export-to-sqlite.py

Regards
Adrian

author reviewer
#1 lore raw

PATCH 1/5 perf script: Fix missing call_path_id in export-to-postgresql script

The export does not work if only branches are exported because of a missing column in the samples table. Fix by adding the missing call_path_id.

Fixes 3521f3bc9dae ("perf script: Update export-to-postgresql to support callchain export")
---
 tools/perf/scripts/python/export-to-postgresql.py | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
tools/perf/scripts/python/export-to-postgresql.py +2 -1
index 7656ff8aa066..f57811443beb 100644
@@ -340,7 +340,8 @@ if branches:
 		'to_sym_offset	bigint,'
 		'to_ip		bigint,'
 		'branch_type	integer,'
-		'in_tx		boolean)')
+		'in_tx		boolean,'
+		'call_path_id	bigint)')
 else:
 	do_query(query, 'CREATE TABLE samples ('
 		'id		bigint		NOT NULL,'
Signature · 1 line
1.9.1
#2 lore raw

[tip:perf/core] perf scripts python: Fix missing call_path_id in export-to-postgresql script

perf scripts python: Fix missing call_path_id in export-to-postgresql script
Commit-ID:  c8a827285c33e7a19e81dfbff2740e1e67ca42df
Gitweb:     http://git.kernel.org/tip/c8a827285c33e7a19e81dfbff2740e1e67ca42df
Author:     Adrian Hunter <[email protected]>
AuthorDate: Thu, 3 Aug 2017 11:31:26 +0300
Committer:  Arnaldo Carvalho de Melo <[email protected]>
CommitDate: Tue, 15 Aug 2017 16:05:36 -0300

perf scripts python: Fix missing call_path_id in export-to-postgresql script

The export does not work if only branches are exported because of a missing column in the samples table. Fix by adding the missing call_path_id.

Fixes 3521f3bc9dae ("perf script: Update export-to-postgresql to support callchain export")
---
 tools/perf/scripts/python/export-to-postgresql.py | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
tools/perf/scripts/python/export-to-postgresql.py +2 -1
index 7656ff8..f578114 100644
@@ -340,7 +340,8 @@ if branches:
 		'to_sym_offset	bigint,'
 		'to_ip		bigint,'
 		'branch_type	integer,'
-		'in_tx		boolean)')
+		'in_tx		boolean,'
+		'call_path_id	bigint)')
 else:
 	do_query(query, 'CREATE TABLE samples ('
 		'id		bigint		NOT NULL,'
author reviewer
#3 lore raw

PATCH 2/5 perf script: Fix query in call-graph-from-postgresql.py

In reply to Adrian Hunter

Add a missing space which seemed not to affect PostgreSQL but upsets SQLite.

---
 tools/perf/scripts/python/call-graph-from-postgresql.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/scripts/python/call-graph-from-postgresql.py +1 -1
index e78fdc2a5a9d..ed9f7f3ccf22 100644
@@ -160,7 +160,7 @@ class TreeItem():
 				  '( SELECT short_name FROM dsos WHERE id = ( SELECT dso_id FROM symbols WHERE id = ( SELECT symbol_id FROM call_paths WHERE id = call_path_id ) ) ), '
 				  '( SELECT ip FROM call_paths where id = call_path_id ) '
 				  'FROM calls WHERE parent_call_path_id = ' + str(self.call_path_id) + ' AND comm_id = ' + str(self.comm_id) + ' AND thread_id = ' + str(self.thread_id) +
-				  'ORDER BY call_path_id')
+				  ' ORDER BY call_path_id')
 		if not ret:
 			raise Exception("Query failed: " + query.lastError().text())
 		last_call_path_id = 0
Signature · 1 line
1.9.1
#4 lore raw

[tip:perf/core] perf scripts python: Fix query in call-graph-from-postgresql.py

perf scripts python: Fix query in call-graph-from-postgresql.py
Commit-ID:  2295e9f850b0efbc57c81fccdd8bd8d26fe10029
Gitweb:     http://git.kernel.org/tip/2295e9f850b0efbc57c81fccdd8bd8d26fe10029
Author:     Adrian Hunter <[email protected]>
AuthorDate: Thu, 3 Aug 2017 11:31:27 +0300
Committer:  Arnaldo Carvalho de Melo <[email protected]>
CommitDate: Tue, 15 Aug 2017 16:06:20 -0300

perf scripts python: Fix query in call-graph-from-postgresql.py

Add a missing space which seemed not to affect PostgreSQL but upsets SQLite.

---
 tools/perf/scripts/python/call-graph-from-postgresql.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/scripts/python/call-graph-from-postgresql.py +1 -1
index e78fdc2..ed9f7f3 100644
@@ -160,7 +160,7 @@ class TreeItem():
 				  '( SELECT short_name FROM dsos WHERE id = ( SELECT dso_id FROM symbols WHERE id = ( SELECT symbol_id FROM call_paths WHERE id = call_path_id ) ) ), '
 				  '( SELECT ip FROM call_paths where id = call_path_id ) '
 				  'FROM calls WHERE parent_call_path_id = ' + str(self.call_path_id) + ' AND comm_id = ' + str(self.comm_id) + ' AND thread_id = ' + str(self.thread_id) +
-				  'ORDER BY call_path_id')
+				  ' ORDER BY call_path_id')
 		if not ret:
 			raise Exception("Query failed: " + query.lastError().text())
 		last_call_path_id = 0
author reviewer
#5 lore raw

PATCH 3/5 perf script: Add support for exporting to sqlite3

In reply to Adrian Hunter

Add support for exporting to SQLite 3 the same data as the PostgreSQL export.

---
 tools/perf/Documentation/intel-pt.txt              |   6 +-
 .../scripts/python/bin/export-to-sqlite-record     |   8 +
 .../scripts/python/bin/export-to-sqlite-report     |  29 ++
 tools/perf/scripts/python/export-to-sqlite.py      | 451 +++++++++++++++++++++
 4 files changed, 491 insertions(+), 3 deletions(-)
 create mode 100644 tools/perf/scripts/python/bin/export-to-sqlite-record
 create mode 100644 tools/perf/scripts/python/bin/export-to-sqlite-report
 create mode 100644 tools/perf/scripts/python/export-to-sqlite.py
tools/perf/Documentation/intel-pt.txt +3 -3
index 4b6cdbf8f935..8e8ae3ad4cbf 100644
@@ -104,9 +104,9 @@ system, asynchronous, interrupt, transaction abort, trace begin, trace end, and
 in transaction, respectively.
 
 While it is possible to create scripts to analyze the data, an alternative
-approach is available to export the data to a postgresql database.  Refer to
-script export-to-postgresql.py for more details, and to script
-call-graph-from-postgresql.py for an example of using the database.
+approach is available to export the data to a sqlite or postgresql database.
+Refer to script export-to-sqlite.py or export-to-postgresql.py for more details,
+and to script call-graph-from-postgresql.py for an example of using the database.
 
 There is also script intel-pt-events.py which provides an example of how to
 unpack the raw data for power events and PTWRITE.
tools/perf/scripts/python/bin/export-to-sqlite-record new file +8 -0
new file mode 100644
index 000000000000..070204fd6d00
@@ -0,0 +1,8 @@
+#!/bin/bash
+
+#
+# export perf data to a sqlite3 database. Can cover
+# perf ip samples (excluding the tracepoints). No special
+# record requirements, just record what you want to export.
+#
+perf record $@
tools/perf/scripts/python/bin/export-to-sqlite-report new file +29 -0
new file mode 100644
index 000000000000..5ff6033e70ba
@@ -0,0 +1,29 @@
+#!/bin/bash
+# description: export perf data to a sqlite3 database
+# args: [database name] [columns] [calls]
+n_args=0
+for i in "$@"
+do
+    if expr match "$i" "-" > /dev/null ; then
+	break
+    fi
+    n_args=$(( $n_args + 1 ))
+done
+if [ "$n_args" -gt 3 ] ; then
+    echo "usage: export-to-sqlite-report [database name] [columns] [calls]"
+    exit
+fi
+if [ "$n_args" -gt 2 ] ; then
+    dbname=$1
+    columns=$2
+    calls=$3
+    shift 3
+elif [ "$n_args" -gt 1 ] ; then
+    dbname=$1
+    columns=$2
+    shift 2
+elif [ "$n_args" -gt 0 ] ; then
+    dbname=$1
+    shift
+fi
+perf script $@ -s "$PERF_EXEC_PATH"/scripts/python/export-to-sqlite.py $dbname $columns $calls
tools/perf/scripts/python/export-to-sqlite.py new file +451 -0

451 lines not on this page · raw message

Signature · 1 line
1.9.1
#6 lore raw

[tip:perf/core] perf script python: Add support for exporting to sqlite3

perf script python: Add support for exporting to sqlite3
Commit-ID:  564b9527d1ccf5d581275391e39ac4b1f29f0d08
Gitweb:     http://git.kernel.org/tip/564b9527d1ccf5d581275391e39ac4b1f29f0d08
Author:     Adrian Hunter <[email protected]>
AuthorDate: Thu, 3 Aug 2017 11:31:28 +0300
Committer:  Arnaldo Carvalho de Melo <[email protected]>
CommitDate: Tue, 15 Aug 2017 16:37:55 -0300

perf script python: Add support for exporting to sqlite3

Add support for exporting to SQLite 3 the same data as the PostgreSQL export.

Committer note:

Tested on RHEL 7.4 using the 1.2.2-4el python-pyside packages from EPEL.

---
 tools/perf/Documentation/intel-pt.txt              |   6 +-
 .../scripts/python/bin/export-to-sqlite-record     |   8 +
 .../scripts/python/bin/export-to-sqlite-report     |  29 ++
 tools/perf/scripts/python/export-to-sqlite.py      | 451 +++++++++++++++++++++
 4 files changed, 491 insertions(+), 3 deletions(-)
tools/perf/Documentation/intel-pt.txt +3 -3
index 4b6cdbf..8e8ae3a 100644
@@ -104,9 +104,9 @@ system, asynchronous, interrupt, transaction abort, trace begin, trace end, and
 in transaction, respectively.
 
 While it is possible to create scripts to analyze the data, an alternative
-approach is available to export the data to a postgresql database.  Refer to
-script export-to-postgresql.py for more details, and to script
-call-graph-from-postgresql.py for an example of using the database.
+approach is available to export the data to a sqlite or postgresql database.
+Refer to script export-to-sqlite.py or export-to-postgresql.py for more details,
+and to script call-graph-from-postgresql.py for an example of using the database.
 
 There is also script intel-pt-events.py which provides an example of how to
 unpack the raw data for power events and PTWRITE.
tools/perf/scripts/python/bin/export-to-sqlite-record new file +8 -0
new file mode 100644
index 0000000..070204f
@@ -0,0 +1,8 @@
+#!/bin/bash
+
+#
+# export perf data to a sqlite3 database. Can cover
+# perf ip samples (excluding the tracepoints). No special
+# record requirements, just record what you want to export.
+#
+perf record $@
tools/perf/scripts/python/bin/export-to-sqlite-report new file +29 -0
new file mode 100644
index 0000000..5ff6033
@@ -0,0 +1,29 @@
+#!/bin/bash
+# description: export perf data to a sqlite3 database
+# args: [database name] [columns] [calls]
+n_args=0
+for i in "$@"
+do
+    if expr match "$i" "-" > /dev/null ; then
+	break
+    fi
+    n_args=$(( $n_args + 1 ))
+done
+if [ "$n_args" -gt 3 ] ; then
+    echo "usage: export-to-sqlite-report [database name] [columns] [calls]"
+    exit
+fi
+if [ "$n_args" -gt 2 ] ; then
+    dbname=$1
+    columns=$2
+    calls=$3
+    shift 3
+elif [ "$n_args" -gt 1 ] ; then
+    dbname=$1
+    columns=$2
+    shift 2
+elif [ "$n_args" -gt 0 ] ; then
+    dbname=$1
+    shift
+fi
+perf script $@ -s "$PERF_EXEC_PATH"/scripts/python/export-to-sqlite.py $dbname $columns $calls
tools/perf/scripts/python/export-to-sqlite.py new file +451 -0

451 lines not on this page · raw message

author reviewer
#7 lore raw

PATCH 4/5 perf script: Rename call-graph-from-postgresql.py to call-graph-from-sql.py

In reply to Adrian Hunter

Rename call-graph-from-postgresql.py to call-graph-from-sql.py in preparation for adding support to it for SQLite 3.

---
 tools/perf/Documentation/intel-pt.txt              |   2 +-
 .../scripts/python/call-graph-from-postgresql.py   | 327 ---------------------
 tools/perf/scripts/python/call-graph-from-sql.py   | 327 +++++++++++++++++++++
 tools/perf/scripts/python/export-to-postgresql.py  |   2 +-
 4 files changed, 329 insertions(+), 329 deletions(-)
 delete mode 100644 tools/perf/scripts/python/call-graph-from-postgresql.py
 create mode 100644 tools/perf/scripts/python/call-graph-from-sql.py
tools/perf/Documentation/intel-pt.txt +1 -1
index 8e8ae3ad4cbf..ab1b0825130a 100644
@@ -106,7 +106,7 @@ in transaction, respectively.
 While it is possible to create scripts to analyze the data, an alternative
 approach is available to export the data to a sqlite or postgresql database.
 Refer to script export-to-sqlite.py or export-to-postgresql.py for more details,
-and to script call-graph-from-postgresql.py for an example of using the database.
+and to script call-graph-from-sql.py for an example of using the database.
 
 There is also script intel-pt-events.py which provides an example of how to
 unpack the raw data for power events and PTWRITE.
tools/perf/scripts/python/call-graph-from-postgresql.py deleted +0 -327

327 lines not on this page · raw message

tools/perf/scripts/python/call-graph-from-sql.py new file +327 -0

327 lines not on this page · raw message

tools/perf/scripts/python/export-to-postgresql.py +1 -1
index f57811443beb..efcaf6cac2eb 100644
@@ -59,7 +59,7 @@ import datetime
 #	pt_example=# \q
 #
 # An example of using the database is provided by the script
-# call-graph-from-postgresql.py.  Refer to that script for details.
+# call-graph-from-sql.py.  Refer to that script for details.
 #
 # Tables:
 #
Signature · 1 line
1.9.1
#8 lore raw

[tip:perf/core] perf script python: Rename call-graph-from-postgresql.py to call-graph-from-sql.py

perf script python: Rename call-graph-from-postgresql.py to call-graph-from-sql.py
Commit-ID:  69e6e410f1a1e69cb656e8ebddaae0ba2138b235
Gitweb:     http://git.kernel.org/tip/69e6e410f1a1e69cb656e8ebddaae0ba2138b235
Author:     Adrian Hunter <[email protected]>
AuthorDate: Thu, 3 Aug 2017 11:31:29 +0300
Committer:  Arnaldo Carvalho de Melo <[email protected]>
CommitDate: Tue, 15 Aug 2017 16:38:06 -0300

perf script python: Rename call-graph-from-postgresql.py to call-graph-from-sql.py

Rename call-graph-from-postgresql.py to call-graph-from-sql.py in preparation for adding support to it for SQLite 3.

---
 tools/perf/Documentation/intel-pt.txt                          |  2 +-
 .../{call-graph-from-postgresql.py => call-graph-from-sql.py}  | 10 +++++-----
 tools/perf/scripts/python/export-to-postgresql.py              |  2 +-
 3 files changed, 7 insertions(+), 7 deletions(-)
tools/perf/Documentation/intel-pt.txt +1 -1
index 8e8ae3a..ab1b082 100644
@@ -106,7 +106,7 @@ in transaction, respectively.
 While it is possible to create scripts to analyze the data, an alternative
 approach is available to export the data to a sqlite or postgresql database.
 Refer to script export-to-sqlite.py or export-to-postgresql.py for more details,
-and to script call-graph-from-postgresql.py for an example of using the database.
+and to script call-graph-from-sql.py for an example of using the database.
 
 There is also script intel-pt-events.py which provides an example of how to
 unpack the raw data for power events and PTWRITE.
tools/perf/scripts/python/call-graph-from-sql.py renamed from tools/perf/scripts/python/call-graph-from-postgresql.py +5 -5
similarity index 96%
rename from tools/perf/scripts/python/call-graph-from-postgresql.py
rename to tools/perf/scripts/python/call-graph-from-sql.py
index ed9f7f3..f18406d 100644
@@ -1,6 +1,6 @@
 #!/usr/bin/python2
-# call-graph-from-postgresql.py: create call-graph from postgresql database
-# Copyright (c) 2014, Intel Corporation.
+# call-graph-from-sql.py: create call-graph from postgresql database
+# Copyright (c) 2014-2017, Intel Corporation.
 #
 # This program is free software; you can redistribute it and/or modify it
 # under the terms and conditions of the GNU General Public License,
@@ -17,12 +17,12 @@
 # Following on from the example in the export-to-postgresql.py script, a
 # call-graph can be displayed for the pt_example database like this:
 #
-#	python tools/perf/scripts/python/call-graph-from-postgresql.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,
 # port, username, password, and dbname e.g.
 #
-#	python tools/perf/scripts/python/call-graph-from-postgresql.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"
 #
 # The result is a GUI window with a tree representing a context-sensitive
 # call-graph.  Expanding a couple of levels of the tree and adjusting column
@@ -291,7 +291,7 @@ class MainWindow(QMainWindow):
 
 if __name__ == '__main__':
 	if (len(sys.argv) < 2):
-		print >> sys.stderr, "Usage is: call-graph-from-postgresql.py <database name>"
+		print >> sys.stderr, "Usage is: call-graph-from-sql.py <database name>"
 		raise Exception("Too few arguments")
 
 	dbname = sys.argv[1]
tools/perf/scripts/python/export-to-postgresql.py +1 -1
index f578114..efcaf6c 100644
@@ -59,7 +59,7 @@ import datetime
 #	pt_example=# \q
 #
 # An example of using the database is provided by the script
-# call-graph-from-postgresql.py.  Refer to that script for details.
+# call-graph-from-sql.py.  Refer to that script for details.
 #
 # Tables:
 #
author reviewer
#9 lore raw

PATCH 5/5 perf script: Add support for sqlite3 to call-graph-from-sql.py

In reply to Adrian Hunter

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.

---
 tools/perf/scripts/python/call-graph-from-sql.py | 60 ++++++++++++++----------
 1 file changed, 36 insertions(+), 24 deletions(-)
tools/perf/scripts/python/call-graph-from-sql.py +36 -24
index f18406d3faf7..b494a67a1c67 100644
@@ -1,5 +1,5 @@
 #!/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.
 #
 # 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
 # more details.
 
-# To use this script you will need to have exported data using the
-# export-to-postgresql.py script.  Refer to that script for details.
+# To use this script you will need to have exported data using either the
+# 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:
 #
 #	python tools/perf/scripts/python/call-graph-from-sql.py pt_example
 #
-# Note this script supports connecting to remote databases by setting hostname,
-# port, username, password, and dbname e.g.
+# Note that for PostgreSQL, this script supports connecting to remote databases
+# 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"
 #
@@ -296,24 +297,35 @@ if __name__ == '__main__':
 
 	dbname = sys.argv[1]
 
-	db = QSqlDatabase.addDatabase('QPSQL')
-
-	opts = dbname.split()
-	for opt in opts:
-		if '=' in opt:
-			opt = opt.split('=')
-			if opt[0] == 'hostname':
-				db.setHostName(opt[1])
-			elif opt[0] == 'port':
-				db.setPort(int(opt[1]))
-			elif opt[0] == 'username':
-				db.setUserName(opt[1])
-			elif opt[0] == 'password':
-				db.setPassword(opt[1])
-			elif opt[0] == 'dbname':
-				dbname = opt[1]
-		else:
-			dbname = opt
+	is_sqlite3 = False
+	try:
+		f = open(dbname)
+		if f.read(15) == "SQLite format 3":
+			is_sqlite3 = True
+		f.close()
+	except:
+		pass
+
+	if is_sqlite3:
+		db = QSqlDatabase.addDatabase('QSQLITE')
+	else:
+		db = QSqlDatabase.addDatabase('QPSQL')
+		opts = dbname.split()
+		for opt in opts:
+			if '=' in opt:
+				opt = opt.split('=')
+				if opt[0] == 'hostname':
+					db.setHostName(opt[1])
+				elif opt[0] == 'port':
+					db.setPort(int(opt[1]))
+				elif opt[0] == 'username':
+					db.setUserName(opt[1])
+				elif opt[0] == 'password':
+					db.setPassword(opt[1])
+				elif opt[0] == 'dbname':
+					dbname = opt[1]
+			else:
+				dbname = opt
 
 	db.setDatabaseName(dbname)
 	if not db.open():
Signature · 1 line
1.9.1
#10 lore raw

[tip:perf/core] perf script python: Add support for sqlite3 to call-graph-from-sql.py

perf script python: Add support for sqlite3 to call-graph-from-sql.py
Commit-ID:  1fe03b5f2d70b48c4a10785edf2678ff05506e59
Gitweb:     http://git.kernel.org/tip/1fe03b5f2d70b48c4a10785edf2678ff05506e59
Author:     Adrian Hunter <[email protected]>
AuthorDate: Thu, 3 Aug 2017 11:31:30 +0300
Committer:  Arnaldo Carvalho de Melo <[email protected]>
CommitDate: Tue, 15 Aug 2017 17:03:38 -0300

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.

---
 tools/perf/scripts/python/call-graph-from-sql.py | 60 ++++++++++++++----------
 1 file changed, 36 insertions(+), 24 deletions(-)
tools/perf/scripts/python/call-graph-from-sql.py +36 -24
index f18406d..b494a67 100644
@@ -1,5 +1,5 @@
 #!/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.
 #
 # 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
 # more details.
 
-# To use this script you will need to have exported data using the
-# export-to-postgresql.py script.  Refer to that script for details.
+# To use this script you will need to have exported data using either the
+# 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:
 #
 #	python tools/perf/scripts/python/call-graph-from-sql.py pt_example
 #
-# Note this script supports connecting to remote databases by setting hostname,
-# port, username, password, and dbname e.g.
+# Note that for PostgreSQL, this script supports connecting to remote databases
+# 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"
 #
@@ -296,24 +297,35 @@ if __name__ == '__main__':
 
 	dbname = sys.argv[1]
 
-	db = QSqlDatabase.addDatabase('QPSQL')
-
-	opts = dbname.split()
-	for opt in opts:
-		if '=' in opt:
-			opt = opt.split('=')
-			if opt[0] == 'hostname':
-				db.setHostName(opt[1])
-			elif opt[0] == 'port':
-				db.setPort(int(opt[1]))
-			elif opt[0] == 'username':
-				db.setUserName(opt[1])
-			elif opt[0] == 'password':
-				db.setPassword(opt[1])
-			elif opt[0] == 'dbname':
-				dbname = opt[1]
-		else:
-			dbname = opt
+	is_sqlite3 = False
+	try:
+		f = open(dbname)
+		if f.read(15) == "SQLite format 3":
+			is_sqlite3 = True
+		f.close()
+	except:
+		pass
+
+	if is_sqlite3:
+		db = QSqlDatabase.addDatabase('QSQLITE')
+	else:
+		db = QSqlDatabase.addDatabase('QPSQL')
+		opts = dbname.split()
+		for opt in opts:
+			if '=' in opt:
+				opt = opt.split('=')
+				if opt[0] == 'hostname':
+					db.setHostName(opt[1])
+				elif opt[0] == 'port':
+					db.setPort(int(opt[1]))
+				elif opt[0] == 'username':
+					db.setUserName(opt[1])
+				elif opt[0] == 'password':
+					db.setPassword(opt[1])
+				elif opt[0] == 'dbname':
+					dbname = opt[1]
+			else:
+				dbname = opt
 
 	db.setDatabaseName(dbname)
 	if not db.open():
author reviewer
#11 lore raw
In reply to Adrian Hunter
Quoted 14 lines · Adrian Hunter

Hi

Here is a script for exporting to SQLite 3 the same data as the PostgreSQL export. The call-graph script is renamed and amended to work with both PostgreSQL and SQLite.

Adrian Hunter (5):
perf script: Fix missing call_path_id in export-to-postgresql script perf script: Fix query in call-graph-from-postgresql.py
perf script: Add support for exporting to sqlite3
perf script: Rename call-graph-from-postgresql.py to call-graph-from-sql.py perf script: Add support for sqlite3 to call-graph-from-sql.py

Quoted 11 lines
 tools/perf/Documentation/intel-pt.txt              |   6 +-
 .../scripts/python/bin/export-to-sqlite-record     |   8 +
 .../scripts/python/bin/export-to-sqlite-report     |  29 ++
 ...h-from-postgresql.py => call-graph-from-sql.py} |  70 ++--
 tools/perf/scripts/python/export-to-postgresql.py  |   5 +-
 tools/perf/scripts/python/export-to-sqlite.py      | 451 +++++++++++++++++++++
 6 files changed, 535 insertions(+), 34 deletions(-)
 create mode 100644 tools/perf/scripts/python/bin/export-to-sqlite-record
 create mode 100644 tools/perf/scripts/python/bin/export-to-sqlite-report
 rename tools/perf/scripts/python/{call-graph-from-postgresql.py => call-graph-from-sql.py} (87%)
 create mode 100644 tools/perf/scripts/python/export-to-sqlite.py

Any problem with these?

#12 lore raw

Em Tue, Aug 15, 2017 at 12:25:24PM +0300, Adrian Hunter escreveu:

Quoted 27 lines · Adrian Hunter
Quoted 14 lines

Hi

Here is a script for exporting to SQLite 3 the same data as the PostgreSQL export. The call-graph script is renamed and amended to work with both PostgreSQL and SQLite.

Adrian Hunter (5):
perf script: Fix missing call_path_id in export-to-postgresql script perf script: Fix query in call-graph-from-postgresql.py
perf script: Add support for exporting to sqlite3
perf script: Rename call-graph-from-postgresql.py to call-graph-from-sql.py perf script: Add support for sqlite3 to call-graph-from-sql.py

Quoted 11 lines
 tools/perf/Documentation/intel-pt.txt              |   6 +-
 .../scripts/python/bin/export-to-sqlite-record     |   8 +
 .../scripts/python/bin/export-to-sqlite-report     |  29 ++
 ...h-from-postgresql.py => call-graph-from-sql.py} |  70 ++--
 tools/perf/scripts/python/export-to-postgresql.py  |   5 +-
 tools/perf/scripts/python/export-to-sqlite.py      | 451 +++++++++++++++++++++
 6 files changed, 535 insertions(+), 34 deletions(-)
 create mode 100644 tools/perf/scripts/python/bin/export-to-sqlite-record
 create mode 100644 tools/perf/scripts/python/bin/export-to-sqlite-report
 rename tools/perf/scripts/python/{call-graph-from-postgresql.py => call-graph-from-sql.py} (87%)
 create mode 100644 tools/perf/scripts/python/export-to-sqlite.py
Quoted 1 line

Any problem with these?

Nope, will try and process them soon, sorry for the delay...

- Arnaldo