Skip to content

Commit 606bd60

Browse files
ahunter6acmel
authored andcommitted
perf scripts python: exported-sql-viewer.py: Fix python3 support
Unlike python2, python3 strings are not compatible with byte strings. That results in disassembly not working for the branches reports. Fixup those places overlooked in the port to python3. Signed-off-by: Adrian Hunter <adrian.hunter@intel.com> Cc: Jiri Olsa <jolsa@redhat.com> Fixes: beda0e7 ("perf script python: Add Python3 support to exported-sql-viewer.py") Link: http://lkml.kernel.org/r/20190327072826.19168-3-adrian.hunter@intel.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
1 parent 8453c93 commit 606bd60

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

tools/perf/scripts/python/exported-sql-viewer.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2908,9 +2908,13 @@ def DisassembleOne(self, inst, bytes_ptr, bytes_cnt, ip):
29082908
ok = self.xed_format_context(2, inst.xedp, inst.bufferp, sizeof(inst.buffer), ip, 0, 0)
29092909
if not ok:
29102910
return 0, ""
2911+
if sys.version_info[0] == 2:
2912+
result = inst.buffer.value
2913+
else:
2914+
result = inst.buffer.value.decode()
29112915
# Return instruction length and the disassembled instruction text
29122916
# For now, assume the length is in byte 166
2913-
return inst.xedd[166], inst.buffer.value
2917+
return inst.xedd[166], result
29142918

29152919
def TryOpen(file_name):
29162920
try:
@@ -2926,9 +2930,14 @@ def Is64Bit(f):
29262930
header = f.read(7)
29272931
f.seek(pos)
29282932
magic = header[0:4]
2929-
eclass = ord(header[4])
2930-
encoding = ord(header[5])
2931-
version = ord(header[6])
2933+
if sys.version_info[0] == 2:
2934+
eclass = ord(header[4])
2935+
encoding = ord(header[5])
2936+
version = ord(header[6])
2937+
else:
2938+
eclass = header[4]
2939+
encoding = header[5]
2940+
version = header[6]
29322941
if magic == chr(127) + "ELF" and eclass > 0 and eclass < 3 and encoding > 0 and encoding < 3 and version == 1:
29332942
result = True if eclass == 2 else False
29342943
return result

0 commit comments

Comments
 (0)