History

perf script: Handle -i option for perf script flamegraph

If specify the perf data file with -i option, the script will try to read the header information regardless of the file name specified, instead it will try to access the perf.data. This simple patch use the file name from -i option for command perf report --header-only to read the header.

Tianyou Li committed 1 year ago

Commit df9c2991 parent 317fa411 file · +7 −1Browse files

Showing the changes to tools/perf/scripts/python (1 of 1 file). Show all

Unified · Split

tools/perf/scripts/python/flamegraph.py+7−1
@@ -123,7 +123,13 @@ class FlameGraphCLI: · 122 unmodified lines
123123 return ""
124124
125125 try:
126− output = subprocess.check_output(["perf", "report", "--header-only"])
126+ # if the file name other than perf.data is given,
127+ # we read the header of that file
128+ if self.args.input:
129+ output = subprocess.check_output(["perf", "report", "--header-only", "-i", self.args.input])
130+ else:
131+ output = subprocess.check_output(["perf", "report", "--header-only"])
132+
127133 return output.decode("utf-8")
128134 except Exception as err: # pylint: disable=broad-except
129135 print("Error reading report header: {}".format(err), file=sys.stderr)