Commit df9c2993 authored by Tianyou Li's avatar Tianyou Li Committed by Namhyung Kim
Browse files

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.

Signed-off-by: default avatarTianyou Li <tianyou.li@intel.com>
Reviewed-by: default avatarPan Deng <pan.deng@intel.com>
Reviewed-by: default avatarZhiguo Zhou <zhiguo.zhou@intel.com>
Reviewed-by: default avatarWangyang Guo <wangyang.guo@intel.com>
Reviewed-by: default avatarTim Chen <tim.c.chen@linux.intel.com>
Link: https://lore.kernel.org/r/20250610040536.2390060-1-tianyou.li@intel.com


Signed-off-by: default avatarNamhyung Kim <namhyung@kernel.org>
parent 317fa41b
Loading
Loading
Loading
Loading
+7 −1
Original line number Diff line number Diff line
@@ -123,7 +123,13 @@ class FlameGraphCLI:
            return ""

        try:
            # if the file name other than perf.data is given,
            # we read the header of that file
            if self.args.input:
                output = subprocess.check_output(["perf", "report", "--header-only", "-i", self.args.input])
            else:
                output = subprocess.check_output(["perf", "report", "--header-only"])

            return output.decode("utf-8")
        except Exception as err:  # pylint: disable=broad-except
            print("Error reading report header: {}".format(err), file=sys.stderr)