Skip to content

Commit baec608

Browse files
namhyungacmel
authored andcommitted
libperf: Add perf_record_header_attr_id()
The HEADER_ATTR record has an event attr followed by the id array. But perf data from a different version could have different size of attr. So it cannot just use event->attr.id to access the array. Let's add the perf_record_header_attr_id() macro to calculate the start of the array. Signed-off-by: Namhyung Kim <namhyung@kernel.org> Cc: Adrian Hunter <adrian.hunter@intel.com> Cc: Ian Rogers <irogers@google.com> Cc: Ingo Molnar <mingo@kernel.org> Cc: Jiri Olsa <jolsa@kernel.org> Cc: Peter Zijlstra <peterz@infradead.org> Link: https://lore.kernel.org/r/20230825152552.112913-2-namhyung@kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
1 parent 9bf6328 commit baec608

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

tools/lib/perf/include/perf/event.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,10 @@ struct perf_record_header_attr {
151151
__u64 id[];
152152
};
153153

154+
/* Returns the pointer to id array based on the actual attr size. */
155+
#define perf_record_header_attr_id(evt) \
156+
((void *)&(evt)->attr.attr + (evt)->attr.attr.size)
157+
154158
enum {
155159
PERF_CPU_MAP__CPUS = 0,
156160
PERF_CPU_MAP__MASK = 1,

0 commit comments

Comments
 (0)