Skip to content

Commit 61051f9

Browse files
captain5050namhyung
authored andcommitted
perf header: In pipe mode dump features without --header/-I
In pipe mode the header features are contained within events. While other events dump details the header features only dump if --header or -I are passed, which doesn't make sense as in pipe mode there is no perf file header. Make the printing of the information conditional on dump_trace as with other events. Before: ``` $ perf record -o - -a sleep 1 | perf script -D -i - ... 0x2c8@pipe [0x54]: event: 80 . . ... raw event: size 84 bytes . 0000: 50 00 00 00 00 00 54 00 05 00 00 00 00 00 00 00 P.....T......... . 0010: 40 00 00 00 36 2e 31 35 2e 72 63 37 2e 67 61 64 @...6.15.rc7.gad . 0020: 32 61 36 39 31 63 39 39 66 62 00 00 00 00 00 00 2a691c99fb...... . 0030: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ . 0040: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ . 0050: 00 00 00 00 .... 0 0 0x2c8 [0x54]: PERF_RECORD_FEATURE ``` After: ``` $ perf record -o - -a sleep 1 | perf script -D -i - ... 0x2c8@pipe [0x54]: event: 80 . . ... raw event: size 84 bytes . 0000: 50 00 00 00 00 00 54 00 05 00 00 00 00 00 00 00 P.....T......... . 0010: 40 00 00 00 36 2e 31 35 2e 72 63 37 2e 67 61 64 @...6.15.rc7.gad . 0020: 32 61 36 39 31 63 39 39 66 62 00 00 00 00 00 00 2a691c99fb...... . 0030: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ . 0040: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ . 0050: 00 00 00 00 .... 0 0 0x2c8 [0x54]: PERF_RECORD_FEATURE, # perf version : 6.15.rc7.gad2a691c99fb ``` Signed-off-by: Ian Rogers <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Namhyung Kim <[email protected]>
1 parent 45cd84b commit 61051f9

File tree

1 file changed

+8
-14
lines changed

1 file changed

+8
-14
lines changed

tools/perf/util/header.c

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4326,7 +4326,6 @@ int perf_session__read_header(struct perf_session *session)
43264326
int perf_event__process_feature(struct perf_session *session,
43274327
union perf_event *event)
43284328
{
4329-
const struct perf_tool *tool = session->tool;
43304329
struct feat_fd ff = { .fd = 0 };
43314330
struct perf_record_header_feature *fe = (struct perf_record_header_feature *)event;
43324331
int type = fe->header.type;
@@ -4342,28 +4341,23 @@ int perf_event__process_feature(struct perf_session *session,
43424341
return -1;
43434342
}
43444343

4345-
if (!feat_ops[feat].process)
4346-
return 0;
4347-
43484344
ff.buf = (void *)fe->data;
43494345
ff.size = event->header.size - sizeof(*fe);
43504346
ff.ph = &session->header;
43514347

4352-
if (feat_ops[feat].process(&ff, NULL)) {
4348+
if (feat_ops[feat].process && feat_ops[feat].process(&ff, NULL)) {
43534349
ret = -1;
43544350
goto out;
43554351
}
43564352

4357-
if (!feat_ops[feat].print || !tool->show_feat_hdr)
4358-
goto out;
4359-
4360-
if (!feat_ops[feat].full_only ||
4361-
tool->show_feat_hdr >= SHOW_FEAT_HEADER_FULL_INFO) {
4362-
feat_ops[feat].print(&ff, stdout);
4363-
} else {
4364-
fprintf(stdout, "# %s info available, use -I to display\n",
4365-
feat_ops[feat].name);
4353+
if (dump_trace) {
4354+
printf(", ");
4355+
if (feat_ops[feat].print)
4356+
feat_ops[feat].print(&ff, stdout);
4357+
else
4358+
printf("# %s", feat_ops[feat].name);
43664359
}
4360+
43674361
out:
43684362
free_event_desc(ff.events);
43694363
return ret;

0 commit comments

Comments
 (0)