Skip to contentSkip to conversation

perf inject: Set PERF_RECORD_MISC_BUILD_ID_SIZE

PATCH Applied Namhyung Kim 3 participants 3 messages Nov 19, 2022 – Nov 23, 2022 perf events

lore
Share & tools
lore

Namhyung Kim

author maintainer
#0 lore raw

PATCH 1/1 perf inject: Set PERF_RECORD_MISC_BUILD_ID_SIZE

With perf inject -b, it synthesizes build-id event for DSOs. But it missed to set the size and resulted in having trailing zeros.

As perf record sets the size in write_build_id(), let's set the size here as well.

---
 tools/perf/util/synthetic-events.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
tools/perf/util/synthetic-events.c +2 -1
index cccd293b5312..0645795ff080 100644
@@ -2218,8 +2218,9 @@ int perf_event__synthesize_build_id(struct perf_tool *tool, struct dso *pos, u16
 	len = pos->long_name_len + 1;
 	len = PERF_ALIGN(len, NAME_ALIGN);
 	memcpy(&ev.build_id.build_id, pos->bid.data, sizeof(pos->bid.data));
+	ev.build_id.size = pos->bid.size;
 	ev.build_id.header.type = PERF_RECORD_HEADER_BUILD_ID;
-	ev.build_id.header.misc = misc;
+	ev.build_id.header.misc = misc | PERF_RECORD_MISC_BUILD_ID_SIZE;
 	ev.build_id.pid = machine->pid;
 	ev.build_id.header.size = sizeof(ev.build_id) + len;
 	memcpy(&ev.build_id.filename, pos->long_name, pos->long_name_len);
Signature · 1 line
2.38.1.584.g0f3c55d4c2-goog
reviewer Acked-by on v1 1/1
#1 lore raw
Quoted 7 lines · Namhyung Kim

With perf inject -b, it synthesizes build-id event for DSOs. But it missed to set the size and resulted in having trailing zeros.

As perf record sets the size in write_build_id(), let's set the size here as well.

Quoted 19 lines
---
 tools/perf/util/synthetic-events.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
tools/perf/util/synthetic-events.c +2 -1
index cccd293b5312..0645795ff080 100644
@@ -2218,8 +2218,9 @@ int perf_event__synthesize_build_id(struct perf_tool *tool, struct dso *pos, u16
 	len = pos->long_name_len + 1;
 	len = PERF_ALIGN(len, NAME_ALIGN);
 	memcpy(&ev.build_id.build_id, pos->bid.data, sizeof(pos->bid.data));
+	ev.build_id.size = pos->bid.size;
 	ev.build_id.header.type = PERF_RECORD_HEADER_BUILD_ID;
-	ev.build_id.header.misc = misc;
+	ev.build_id.header.misc = misc | PERF_RECORD_MISC_BUILD_ID_SIZE;
 	ev.build_id.pid = machine->pid;
 	ev.build_id.header.size = sizeof(ev.build_id) + len;
 	memcpy(&ev.build_id.filename, pos->long_name, pos->long_name_len);
maintainer Applied
#2 lore raw

Em Mon, Nov 21, 2022 at 10:45:14AM +0200, Adrian Hunter escreveu:

Quoted 10 lines · Namhyung Kim
Quoted 7 lines

With perf inject -b, it synthesizes build-id event for DSOs. But it missed to set the size and resulted in having trailing zeros.

As perf record sets the size in write_build_id(), let's set the size here as well.

Thanks, applied.

- Arnaldo

Quoted 19 lines
Quoted 19 lines
---
 tools/perf/util/synthetic-events.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
tools/perf/util/synthetic-events.c +2 -1
index cccd293b5312..0645795ff080 100644
@@ -2218,8 +2218,9 @@ int perf_event__synthesize_build_id(struct perf_tool *tool, struct dso *pos, u16
 	len = pos->long_name_len + 1;
 	len = PERF_ALIGN(len, NAME_ALIGN);
 	memcpy(&ev.build_id.build_id, pos->bid.data, sizeof(pos->bid.data));
+	ev.build_id.size = pos->bid.size;
 	ev.build_id.header.type = PERF_RECORD_HEADER_BUILD_ID;
-	ev.build_id.header.misc = misc;
+	ev.build_id.header.misc = misc | PERF_RECORD_MISC_BUILD_ID_SIZE;
 	ev.build_id.pid = machine->pid;
 	ev.build_id.header.size = sizeof(ev.build_id) + len;
 	memcpy(&ev.build_id.filename, pos->long_name, pos->long_name_len);
Signature · 1 line
- Arnaldo