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

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)

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t