diff options
| author | Adrian Hunter <adrian.hunter@intel.com> | 2019-03-27 03:28:25 -0400 |
|---|---|---|
| committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2019-03-28 13:41:21 -0400 |
| commit | 8453c936db20489dbf0957187dca9a2656a2a7b6 (patch) | |
| tree | 913d8bcb5aa23d8c2f36b965ddfcb479636030a7 /tools/perf/scripts/python | |
| parent | 977c7a6d1e263ff1d755f28595b99e4bc0c48a9f (diff) | |
perf scripts python: exported-sql-viewer.py: Fix never-ending loop
pyside version 1 fails to handle python3 large integers in some cases,
resulting in Qt getting into a never-ending loop. This affects:
samples Table
samples_view Table
All branches Report
Selected branches Report
Add workarounds for those cases.
Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Fixes: beda0e725e5f ("perf script python: Add Python3 support to exported-sql-viewer.py")
Link: http://lkml.kernel.org/r/20190327072826.19168-2-adrian.hunter@intel.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/scripts/python')
| -rwxr-xr-x | tools/perf/scripts/python/exported-sql-viewer.py | 60 |
1 files changed, 50 insertions, 10 deletions
diff --git a/tools/perf/scripts/python/exported-sql-viewer.py b/tools/perf/scripts/python/exported-sql-viewer.py index e38518cdcbc3..0cf30956064a 100755 --- a/tools/perf/scripts/python/exported-sql-viewer.py +++ b/tools/perf/scripts/python/exported-sql-viewer.py | |||
| @@ -107,6 +107,7 @@ import os | |||
| 107 | from PySide.QtCore import * | 107 | from PySide.QtCore import * |
| 108 | from PySide.QtGui import * | 108 | from PySide.QtGui import * |
| 109 | from PySide.QtSql import * | 109 | from PySide.QtSql import * |
| 110 | pyside_version_1 = True | ||
| 110 | from decimal import * | 111 | from decimal import * |
| 111 | from ctypes import * | 112 | from ctypes import * |
| 112 | from multiprocessing import Process, Array, Value, Event | 113 | from multiprocessing import Process, Array, Value, Event |
| @@ -1526,6 +1527,19 @@ def BranchDataPrep(query): | |||
| 1526 | " (" + dsoname(query.value(15)) + ")") | 1527 | " (" + dsoname(query.value(15)) + ")") |
| 1527 | return data | 1528 | return data |
| 1528 | 1529 | ||
| 1530 | def BranchDataPrepWA(query): | ||
| 1531 | data = [] | ||
| 1532 | data.append(query.value(0)) | ||
| 1533 | # Workaround pyside failing to handle large integers (i.e. time) in python3 by converting to a string | ||
| 1534 | data.append("{:>19}".format(query.value(1))) | ||
| 1535 | for i in xrange(2, 8): | ||
| 1536 | data.append(query.value(i)) | ||
| 1537 | data.append(tohex(query.value(8)).rjust(16) + " " + query.value(9) + offstr(query.value(10)) + | ||
| 1538 | " (" + dsoname(query.value(11)) + ")" + " -> " + | ||
| 1539 | tohex(query.value(12)) + " " + query.value(13) + offstr(query.value(14)) + | ||
| 1540 | " (" + dsoname(query.value(15)) + ")") | ||
| 1541 | return data | ||
| 1542 | |||
| 1529 | # Branch data model | 1543 | # Branch data model |
| 1530 | 1544 | ||
| 1531 | class BranchModel(TreeModel): | 1545 | class BranchModel(TreeModel): |
| @@ -1553,7 +1567,11 @@ class BranchModel(TreeModel): | |||
| 1553 | " AND evsel_id = " + str(self.event_id) + | 1567 | " AND evsel_id = " + str(self.event_id) + |
| 1554 | " ORDER BY samples.id" | 1568 | " ORDER BY samples.id" |
| 1555 | " LIMIT " + str(glb_chunk_sz)) | 1569 | " LIMIT " + str(glb_chunk_sz)) |
| 1556 | self.fetcher = SQLFetcher(glb, sql, BranchDataPrep, self.AddSample) | 1570 | if pyside_version_1 and sys.version_info[0] == 3: |
| 1571 | prep = BranchDataPrepWA | ||
| 1572 | else: | ||
| 1573 | prep = BranchDataPrep | ||
| 1574 | self.fetcher = SQLFetcher(glb, sql, prep, self.AddSample) | ||
| 1557 | self.fetcher.done.connect(self.Update) | 1575 | self.fetcher.done.connect(self.Update) |
| 1558 | self.fetcher.Fetch(glb_chunk_sz) | 1576 | self.fetcher.Fetch(glb_chunk_sz) |
| 1559 | 1577 | ||
| @@ -2079,14 +2097,6 @@ def IsSelectable(db, table, sql = ""): | |||
| 2079 | return False | 2097 | return False |
| 2080 | return True | 2098 | return True |
| 2081 | 2099 | ||
| 2082 | # SQL data preparation | ||
| 2083 | |||
| 2084 | def SQLTableDataPrep(query, count): | ||
| 2085 | data = [] | ||
| 2086 | for i in xrange(count): | ||
| 2087 | data.append(query.value(i)) | ||
| 2088 | return data | ||
| 2089 | |||
| 2090 | # SQL table data model item | 2100 | # SQL table data model item |
| 2091 | 2101 | ||
| 2092 | class SQLTableItem(): | 2102 | class SQLTableItem(): |
| @@ -2110,7 +2120,7 @@ class SQLTableModel(TableModel): | |||
| 2110 | self.more = True | 2120 | self.more = True |
| 2111 | self.populated = 0 | 2121 | self.populated = 0 |
| 2112 | self.column_headers = column_headers | 2122 | self.column_headers = column_headers |
| 2113 | self.fetcher = SQLFetcher(glb, sql, lambda x, y=len(column_headers): SQLTableDataPrep(x, y), self.AddSample) | 2123 | self.fetcher = SQLFetcher(glb, sql, lambda x, y=len(column_headers): self.SQLTableDataPrep(x, y), self.AddSample) |
| 2114 | self.fetcher.done.connect(self.Update) | 2124 | self.fetcher.done.connect(self.Update) |
| 2115 | self.fetcher.Fetch(glb_chunk_sz) | 2125 | self.fetcher.Fetch(glb_chunk_sz) |
| 2116 | 2126 | ||
| @@ -2154,6 +2164,12 @@ class SQLTableModel(TableModel): | |||
| 2154 | def columnHeader(self, column): | 2164 | def columnHeader(self, column): |
| 2155 | return self.column_headers[column] | 2165 | return self.column_headers[column] |
| 2156 | 2166 | ||
| 2167 | def SQLTableDataPrep(self, query, count): | ||
| 2168 | data = [] | ||
| 2169 | for i in xrange(count): | ||
| 2170 | data.append(query.value(i)) | ||
| 2171 | return data | ||
| 2172 | |||
| 2157 | # SQL automatic table data model | 2173 | # SQL automatic table data model |
| 2158 | 2174 | ||
| 2159 | class SQLAutoTableModel(SQLTableModel): | 2175 | class SQLAutoTableModel(SQLTableModel): |
| @@ -2182,8 +2198,32 @@ class SQLAutoTableModel(SQLTableModel): | |||
| 2182 | QueryExec(query, "SELECT column_name FROM information_schema.columns WHERE table_schema = '" + schema + "' and table_name = '" + select_table_name + "'") | 2198 | QueryExec(query, "SELECT column_name FROM information_schema.columns WHERE table_schema = '" + schema + "' and table_name = '" + select_table_name + "'") |
| 2183 | while query.next(): | 2199 | while query.next(): |
| 2184 | column_headers.append(query.value(0)) | 2200 | column_headers.append(query.value(0)) |
| 2201 | if pyside_version_1 and sys.version_info[0] == 3: | ||
| 2202 | if table_name == "samples_view": | ||
| 2203 | self.SQLTableDataPrep = self.samples_view_DataPrep | ||
| 2204 | if table_name == "samples": | ||
| 2205 | self.SQLTableDataPrep = self.samples_DataPrep | ||
| 2185 | super(SQLAutoTableModel, self).__init__(glb, sql, column_headers, parent) | 2206 | super(SQLAutoTableModel, self).__init__(glb, sql, column_headers, parent) |
| 2186 | 2207 | ||
| 2208 | def samples_view_DataPrep(self, query, count): | ||
| 2209 | data = [] | ||
| 2210 | data.append(query.value(0)) | ||
| 2211 | # Workaround pyside failing to handle large integers (i.e. time) in python3 by converting to a string | ||
| 2212 | data.append("{:>19}".format(query.value(1))) | ||
| 2213 | for i in xrange(2, count): | ||
| 2214 | data.append(query.value(i)) | ||
| 2215 | return data | ||
| 2216 | |||
| 2217 | def samples_DataPrep(self, query, count): | ||
| 2218 | data = [] | ||
| 2219 | for i in xrange(9): | ||
| 2220 | data.append(query.value(i)) | ||
| 2221 | # Workaround pyside failing to handle large integers (i.e. time) in python3 by converting to a string | ||
| 2222 | data.append("{:>19}".format(query.value(9))) | ||
| 2223 | for i in xrange(10, count): | ||
| 2224 | data.append(query.value(i)) | ||
| 2225 | return data | ||
| 2226 | |||
| 2187 | # Base class for custom ResizeColumnsToContents | 2227 | # Base class for custom ResizeColumnsToContents |
| 2188 | 2228 | ||
| 2189 | class ResizeColumnsToContentsBase(QObject): | 2229 | class ResizeColumnsToContentsBase(QObject): |
