Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

perf script python: Add Python3 support to stackcollapse.py

Support both Python2 and Python3 in the stackcollapse.py script

There may be differences in the ordering of output lines due to
differences in dictionary ordering etc. However the format within lines
should be unchanged.

The use of 'from __future__' implies the minimum supported Python2 version
is now v2.6

Signed-off-by: Tony Jones <tonyj@suse.de>
Cc: Paolo Bonzini <pbonzini@redhat.com> <pbonzini@redhat.com>
Link: http://lkml.kernel.org/r/20190222230619.17887-12-tonyj@suse.de
Signed-off-by: Seeteena Thoufeek <s1seetee@linux.vnet.ibm.com>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

authored by

Tony Jones and committed by
Arnaldo Carvalho de Melo
6d22d999 ee75a896

+4 -3
+4 -3
tools/perf/scripts/python/stackcollapse.py
··· 19 19 # Written by Paolo Bonzini <pbonzini@redhat.com> 20 20 # Based on Brendan Gregg's stackcollapse-perf.pl script. 21 21 22 + from __future__ import print_function 23 + 22 24 import os 23 25 import sys 24 26 from collections import defaultdict ··· 122 120 lines[stack_string] = lines[stack_string] + 1 123 121 124 122 def trace_end(): 125 - list = lines.keys() 126 - list.sort() 123 + list = sorted(lines) 127 124 for stack in list: 128 - print "%s %d" % (stack, lines[stack]) 125 + print("%s %d" % (stack, lines[stack]))