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.
Showing the changes to tools/perf/scripts/python/flamegraph.py (1 of 1 file). Show all
Unified · Split
| @@ -123,7 +123,13 @@ class FlameGraphCLI: · 122 unmodified lines | ||
| 123 | 123 | return "" |
| 124 | 124 | |
| 125 | 125 | 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 | + | |
| 127 | 133 | return output.decode("utf-8") |
| 128 | 134 | except Exception as err: # pylint: disable=broad-except |
| 129 | 135 | print("Error reading report header: {}".format(err), file=sys.stderr) |