Skip to content

Commit f26d1c3

Browse files
committed
perf script: Handle -i option for perf script flamegraph
JIRA: https://issues.redhat.com/browse/RHEL-78200 upstream ======== commit df9c299 Author: Tianyou Li <[email protected]> Date: Tue Jun 10 12:04:22 2025 +0800 description =========== 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. Signed-off-by: Tianyou Li <[email protected]> Reviewed-by: Pan Deng <[email protected]> Reviewed-by: Zhiguo Zhou <[email protected]> Reviewed-by: Wangyang Guo <[email protected]> Reviewed-by: Tim Chen <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Namhyung Kim <[email protected]> Signed-off-by: Anubhav Shelat <[email protected]>
1 parent a3ce864 commit f26d1c3

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

tools/perf/scripts/python/flamegraph.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,13 @@ def get_report_header(self):
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)

0 commit comments

Comments
 (0)