提交 648b054a 编写于 作者: A Al Grant 提交者: Arnaldo Carvalho de Melo

perf inject: Correct event attribute sizes

When 'perf inject' reads a perf.data file from an older version of perf,
it writes event attributes into the output with the original size field,
but lays them out as if they had the size currently used. Readers see a
corrupt file. Update the size field to match the layout.
Signed-off-by: NAl Grant <al.grant@foss.arm.com>
Acked-by: NJiri Olsa <jolsa@redhat.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lore.kernel.org/lkml/20201124195818.30603-1-al.grant@arm.comSigned-off-by: NDenis Nikitin <denik@chromium.org>
Signed-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
上级 5501e922
......@@ -3323,6 +3323,14 @@ int perf_session__write_header(struct perf_session *session,
attr_offset = lseek(ff.fd, 0, SEEK_CUR);
evlist__for_each_entry(evlist, evsel) {
if (evsel->core.attr.size < sizeof(evsel->core.attr)) {
/*
* We are likely in "perf inject" and have read
* from an older file. Update attr size so that
* reader gets the right offset to the ids.
*/
evsel->core.attr.size = sizeof(evsel->core.attr);
}
f_attr = (struct perf_file_attr){
.attr = evsel->core.attr,
.ids = {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册