diff options
| author | Takashi Iwai <tiwai@suse.de> | 2019-05-06 10:14:09 -0400 |
|---|---|---|
| committer | Takashi Iwai <tiwai@suse.de> | 2019-05-06 10:14:34 -0400 |
| commit | d81645510ce2a140816c4cb37c45b78d810ca63f (patch) | |
| tree | edd9464900904d22a23da362bb152669480c5d26 /tools/perf/scripts/python/exported-sql-viewer.py | |
| parent | 2854cd34fbab5f28a356d3667c26b7856a7b73e2 (diff) | |
| parent | 378d590c494551a68a824b939c711bb9a280e9ef (diff) | |
Merge tag 'asoc-v5.2' of https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound into for-linus
ASoC: Updates for v5.2
This is a pretty huge set of changes, it's been a pretty active release
all round but the big thing with this release is the Sound Open Firmware
changes from Intel, providing another DSP framework for use with the
DSPs in their SoCs. This one works with the firmware of the same name
which is free software (unlike the previous DSP firmwares and framework)
and there has been some interest in adoption by other systems already so
hopefully we will see adoption by other vendors in the future.
Other highlights include:
- Support for MCLK/sample rate ratio setting in the generic cards.
- Support for pin switches in the generic cards.
- A big set of improvements to the TLV320AIC32x4 drivers from Annaliese
McDermond.
- New drivers for Freescale audio mixers, several Intel machines,
several Mediatek machines, Meson G12A, Sound Open Firmware and
Spreadtrum compressed audio and DMA devices.
Diffstat (limited to 'tools/perf/scripts/python/exported-sql-viewer.py')
| -rwxr-xr-x | tools/perf/scripts/python/exported-sql-viewer.py | 119 |
1 files changed, 91 insertions, 28 deletions
diff --git a/tools/perf/scripts/python/exported-sql-viewer.py b/tools/perf/scripts/python/exported-sql-viewer.py index afec9479ca7f..74ef92f1d19a 100755 --- a/tools/perf/scripts/python/exported-sql-viewer.py +++ b/tools/perf/scripts/python/exported-sql-viewer.py | |||
| @@ -88,20 +88,39 @@ | |||
| 88 | # 7fab593ea956 48 89 15 3b 13 22 00 movq %rdx, 0x22133b(%rip) | 88 | # 7fab593ea956 48 89 15 3b 13 22 00 movq %rdx, 0x22133b(%rip) |
| 89 | # 8107675243232 2 ls 22011 22011 hardware interrupt No 7fab593ea956 _dl_start+0x26 (ld-2.19.so) -> ffffffff86a012e0 page_fault ([kernel]) | 89 | # 8107675243232 2 ls 22011 22011 hardware interrupt No 7fab593ea956 _dl_start+0x26 (ld-2.19.so) -> ffffffff86a012e0 page_fault ([kernel]) |
| 90 | 90 | ||
| 91 | from __future__ import print_function | ||
| 92 | |||
| 91 | import sys | 93 | import sys |
| 92 | import weakref | 94 | import weakref |
| 93 | import threading | 95 | import threading |
| 94 | import string | 96 | import string |
| 95 | import cPickle | 97 | try: |
| 98 | # Python2 | ||
| 99 | import cPickle as pickle | ||
| 100 | # size of pickled integer big enough for record size | ||
| 101 | glb_nsz = 8 | ||
| 102 | except ImportError: | ||
| 103 | import pickle | ||
| 104 | glb_nsz = 16 | ||
| 96 | import re | 105 | import re |
| 97 | import os | 106 | import os |
| 98 | from PySide.QtCore import * | 107 | from PySide.QtCore import * |
| 99 | from PySide.QtGui import * | 108 | from PySide.QtGui import * |
| 100 | from PySide.QtSql import * | 109 | from PySide.QtSql import * |
| 110 | pyside_version_1 = True | ||
| 101 | from decimal import * | 111 | from decimal import * |
| 102 | from ctypes import * | 112 | from ctypes import * |
| 103 | from multiprocessing import Process, Array, Value, Event | 113 | from multiprocessing import Process, Array, Value, Event |
| 104 | 114 | ||
| 115 | # xrange is range in Python3 | ||
| 116 | try: | ||
| 117 | xrange | ||
| 118 | except NameError: | ||
| 119 | xrange = range | ||
| 120 | |||
| 121 | def printerr(*args, **keyword_args): | ||
| 122 | print(*args, file=sys.stderr, **keyword_args) | ||
| 123 | |||
| 105 | # Data formatting helpers | 124 | # Data formatting helpers |
| 106 | 125 | ||
| 107 | def tohex(ip): | 126 | def tohex(ip): |
| @@ -1004,10 +1023,6 @@ class ChildDataItemFinder(): | |||
| 1004 | 1023 | ||
| 1005 | glb_chunk_sz = 10000 | 1024 | glb_chunk_sz = 10000 |
| 1006 | 1025 | ||
| 1007 | # size of pickled integer big enough for record size | ||
| 1008 | |||
| 1009 | glb_nsz = 8 | ||
| 1010 | |||
| 1011 | # Background process for SQL data fetcher | 1026 | # Background process for SQL data fetcher |
| 1012 | 1027 | ||
| 1013 | class SQLFetcherProcess(): | 1028 | class SQLFetcherProcess(): |
| @@ -1066,7 +1081,7 @@ class SQLFetcherProcess(): | |||
| 1066 | return True | 1081 | return True |
| 1067 | if space >= glb_nsz: | 1082 | if space >= glb_nsz: |
| 1068 | # Use 0 (or space < glb_nsz) to mean there is no more at the top of the buffer | 1083 | # Use 0 (or space < glb_nsz) to mean there is no more at the top of the buffer |
| 1069 | nd = cPickle.dumps(0, cPickle.HIGHEST_PROTOCOL) | 1084 | nd = pickle.dumps(0, pickle.HIGHEST_PROTOCOL) |
| 1070 | self.buffer[self.local_head : self.local_head + len(nd)] = nd | 1085 | self.buffer[self.local_head : self.local_head + len(nd)] = nd |
| 1071 | self.local_head = 0 | 1086 | self.local_head = 0 |
| 1072 | if self.local_tail - self.local_head > sz: | 1087 | if self.local_tail - self.local_head > sz: |
| @@ -1084,9 +1099,9 @@ class SQLFetcherProcess(): | |||
| 1084 | self.wait_event.wait() | 1099 | self.wait_event.wait() |
| 1085 | 1100 | ||
| 1086 | def AddToBuffer(self, obj): | 1101 | def AddToBuffer(self, obj): |
| 1087 | d = cPickle.dumps(obj, cPickle.HIGHEST_PROTOCOL) | 1102 | d = pickle.dumps(obj, pickle.HIGHEST_PROTOCOL) |
| 1088 | n = len(d) | 1103 | n = len(d) |
| 1089 | nd = cPickle.dumps(n, cPickle.HIGHEST_PROTOCOL) | 1104 | nd = pickle.dumps(n, pickle.HIGHEST_PROTOCOL) |
| 1090 | sz = n + glb_nsz | 1105 | sz = n + glb_nsz |
| 1091 | self.WaitForSpace(sz) | 1106 | self.WaitForSpace(sz) |
| 1092 | pos = self.local_head | 1107 | pos = self.local_head |
| @@ -1198,12 +1213,12 @@ class SQLFetcher(QObject): | |||
| 1198 | pos = self.local_tail | 1213 | pos = self.local_tail |
| 1199 | if len(self.buffer) - pos < glb_nsz: | 1214 | if len(self.buffer) - pos < glb_nsz: |
| 1200 | pos = 0 | 1215 | pos = 0 |
| 1201 | n = cPickle.loads(self.buffer[pos : pos + glb_nsz]) | 1216 | n = pickle.loads(self.buffer[pos : pos + glb_nsz]) |
| 1202 | if n == 0: | 1217 | if n == 0: |
| 1203 | pos = 0 | 1218 | pos = 0 |
| 1204 | n = cPickle.loads(self.buffer[0 : glb_nsz]) | 1219 | n = pickle.loads(self.buffer[0 : glb_nsz]) |
| 1205 | pos += glb_nsz | 1220 | pos += glb_nsz |
| 1206 | obj = cPickle.loads(self.buffer[pos : pos + n]) | 1221 | obj = pickle.loads(self.buffer[pos : pos + n]) |
| 1207 | self.local_tail = pos + n | 1222 | self.local_tail = pos + n |
| 1208 | return obj | 1223 | return obj |
| 1209 | 1224 | ||
| @@ -1512,6 +1527,19 @@ def BranchDataPrep(query): | |||
| 1512 | " (" + dsoname(query.value(15)) + ")") | 1527 | " (" + dsoname(query.value(15)) + ")") |
| 1513 | return data | 1528 | return data |
| 1514 | 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 | |||
| 1515 | # Branch data model | 1543 | # Branch data model |
| 1516 | 1544 | ||
| 1517 | class BranchModel(TreeModel): | 1545 | class BranchModel(TreeModel): |
| @@ -1539,7 +1567,11 @@ class BranchModel(TreeModel): | |||
| 1539 | " AND evsel_id = " + str(self.event_id) + | 1567 | " AND evsel_id = " + str(self.event_id) + |
| 1540 | " ORDER BY samples.id" | 1568 | " ORDER BY samples.id" |
| 1541 | " LIMIT " + str(glb_chunk_sz)) | 1569 | " LIMIT " + str(glb_chunk_sz)) |
| 1542 | 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) | ||
| 1543 | self.fetcher.done.connect(self.Update) | 1575 | self.fetcher.done.connect(self.Update) |
| 1544 | self.fetcher.Fetch(glb_chunk_sz) | 1576 | self.fetcher.Fetch(glb_chunk_sz) |
| 1545 | 1577 | ||
| @@ -2065,14 +2097,6 @@ def IsSelectable(db, table, sql = ""): | |||
| 2065 | return False | 2097 | return False |
| 2066 | return True | 2098 | return True |
| 2067 | 2099 | ||
| 2068 | # SQL data preparation | ||
| 2069 | |||
| 2070 | def SQLTableDataPrep(query, count): | ||
| 2071 | data = [] | ||
| 2072 | for i in xrange(count): | ||
| 2073 | data.append(query.value(i)) | ||
| 2074 | return data | ||
| 2075 | |||
| 2076 | # SQL table data model item | 2100 | # SQL table data model item |
| 2077 | 2101 | ||
| 2078 | class SQLTableItem(): | 2102 | class SQLTableItem(): |
| @@ -2096,7 +2120,7 @@ class SQLTableModel(TableModel): | |||
| 2096 | self.more = True | 2120 | self.more = True |
| 2097 | self.populated = 0 | 2121 | self.populated = 0 |
| 2098 | self.column_headers = column_headers | 2122 | self.column_headers = column_headers |
| 2099 | 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) |
| 2100 | self.fetcher.done.connect(self.Update) | 2124 | self.fetcher.done.connect(self.Update) |
| 2101 | self.fetcher.Fetch(glb_chunk_sz) | 2125 | self.fetcher.Fetch(glb_chunk_sz) |
| 2102 | 2126 | ||
| @@ -2140,6 +2164,12 @@ class SQLTableModel(TableModel): | |||
| 2140 | def columnHeader(self, column): | 2164 | def columnHeader(self, column): |
| 2141 | return self.column_headers[column] | 2165 | return self.column_headers[column] |
| 2142 | 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 | |||
| 2143 | # SQL automatic table data model | 2173 | # SQL automatic table data model |
| 2144 | 2174 | ||
| 2145 | class SQLAutoTableModel(SQLTableModel): | 2175 | class SQLAutoTableModel(SQLTableModel): |
| @@ -2168,8 +2198,32 @@ class SQLAutoTableModel(SQLTableModel): | |||
| 2168 | 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 + "'") |
| 2169 | while query.next(): | 2199 | while query.next(): |
| 2170 | 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 | ||
| 2171 | super(SQLAutoTableModel, self).__init__(glb, sql, column_headers, parent) | 2206 | super(SQLAutoTableModel, self).__init__(glb, sql, column_headers, parent) |
| 2172 | 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 | |||
| 2173 | # Base class for custom ResizeColumnsToContents | 2227 | # Base class for custom ResizeColumnsToContents |
| 2174 | 2228 | ||
| 2175 | class ResizeColumnsToContentsBase(QObject): | 2229 | class ResizeColumnsToContentsBase(QObject): |
| @@ -2854,9 +2908,13 @@ class LibXED(): | |||
| 2854 | ok = self.xed_format_context(2, inst.xedp, inst.bufferp, sizeof(inst.buffer), ip, 0, 0) | 2908 | ok = self.xed_format_context(2, inst.xedp, inst.bufferp, sizeof(inst.buffer), ip, 0, 0) |
| 2855 | if not ok: | 2909 | if not ok: |
| 2856 | return 0, "" | 2910 | return 0, "" |
| 2911 | if sys.version_info[0] == 2: | ||
| 2912 | result = inst.buffer.value | ||
| 2913 | else: | ||
| 2914 | result = inst.buffer.value.decode() | ||
| 2857 | # Return instruction length and the disassembled instruction text | 2915 | # Return instruction length and the disassembled instruction text |
| 2858 | # For now, assume the length is in byte 166 | 2916 | # For now, assume the length is in byte 166 |
| 2859 | return inst.xedd[166], inst.buffer.value | 2917 | return inst.xedd[166], result |
| 2860 | 2918 | ||
| 2861 | def TryOpen(file_name): | 2919 | def TryOpen(file_name): |
| 2862 | try: | 2920 | try: |
| @@ -2872,9 +2930,14 @@ def Is64Bit(f): | |||
| 2872 | header = f.read(7) | 2930 | header = f.read(7) |
| 2873 | f.seek(pos) | 2931 | f.seek(pos) |
| 2874 | magic = header[0:4] | 2932 | magic = header[0:4] |
| 2875 | eclass = ord(header[4]) | 2933 | if sys.version_info[0] == 2: |
| 2876 | encoding = ord(header[5]) | 2934 | eclass = ord(header[4]) |
| 2877 | version = ord(header[6]) | 2935 | encoding = ord(header[5]) |
| 2936 | version = ord(header[6]) | ||
| 2937 | else: | ||
| 2938 | eclass = header[4] | ||
| 2939 | encoding = header[5] | ||
| 2940 | version = header[6] | ||
| 2878 | if magic == chr(127) + "ELF" and eclass > 0 and eclass < 3 and encoding > 0 and encoding < 3 and version == 1: | 2941 | if magic == chr(127) + "ELF" and eclass > 0 and eclass < 3 and encoding > 0 and encoding < 3 and version == 1: |
| 2879 | result = True if eclass == 2 else False | 2942 | result = True if eclass == 2 else False |
| 2880 | return result | 2943 | return result |
| @@ -2973,7 +3036,7 @@ class DBRef(): | |||
| 2973 | 3036 | ||
| 2974 | def Main(): | 3037 | def Main(): |
| 2975 | if (len(sys.argv) < 2): | 3038 | if (len(sys.argv) < 2): |
| 2976 | print >> sys.stderr, "Usage is: exported-sql-viewer.py {<database name> | --help-only}" | 3039 | printerr("Usage is: exported-sql-viewer.py {<database name> | --help-only}"); |
| 2977 | raise Exception("Too few arguments") | 3040 | raise Exception("Too few arguments") |
| 2978 | 3041 | ||
| 2979 | dbname = sys.argv[1] | 3042 | dbname = sys.argv[1] |
| @@ -2986,8 +3049,8 @@ def Main(): | |||
| 2986 | 3049 | ||
| 2987 | is_sqlite3 = False | 3050 | is_sqlite3 = False |
| 2988 | try: | 3051 | try: |
| 2989 | f = open(dbname) | 3052 | f = open(dbname, "rb") |
| 2990 | if f.read(15) == "SQLite format 3": | 3053 | if f.read(15) == b'SQLite format 3': |
| 2991 | is_sqlite3 = True | 3054 | is_sqlite3 = True |
| 2992 | f.close() | 3055 | f.close() |
| 2993 | except: | 3056 | except: |
