Skip to content

Commit f9f6f2a

Browse files
tahiniacmel
authored andcommitted
perf data: Add mmap[2] events to CTF conversion
This adds the mmap and mmap2 events to the CTF trace obtained from perf data. These events will allow CTF trace visualization tools like Trace Compass to automatically resolve the symbols of the callchain to the corresponding function or origin library. To include those events, one needs to convert with the --all option. Here follows an output of babeltrace: $ sudo perf data convert --all --to-ctf myctftrace $ babeltrace ./myctftrace [19:00:00.000000000] (+0.000000000) perf_mmap2: { cpu_id = 0 }, { pid = 638, tid = 638, start = 0x7F54AE39E000, filename = "/usr/lib/ld-2.25.so" } [19:00:00.000000000] (+0.000000000) perf_mmap2: { cpu_id = 0 }, { pid = 638, tid = 638, start = 0x7F54AE565000, filename = "/usr/lib/libudev.so.1.6.6" } [19:00:00.000000000] (+0.000000000) perf_mmap2: { cpu_id = 0 }, { pid = 638, tid = 638, start = 0x7FFC093EA000, filename = "[vdso]" } Signed-off-by: Geneviève Bastien <[email protected]> Acked-by: Jiri Olsa <[email protected]> Tested-by: Arnaldo Carvalho de Melo <[email protected]> Cc: Alexander Shishkin <[email protected]> Cc: Francis Deslauriers <[email protected]> Cc: Julien Desfossez <[email protected]> Cc: Mathieu Desnoyers <[email protected]> Cc: Peter Zijlstra <[email protected]> Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
1 parent a3073c8 commit f9f6f2a

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

tools/perf/util/data-convert-bt.c

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,8 @@ struct ctf_writer {
7676
struct bt_ctf_event_class *comm_class;
7777
struct bt_ctf_event_class *exit_class;
7878
struct bt_ctf_event_class *fork_class;
79+
struct bt_ctf_event_class *mmap_class;
80+
struct bt_ctf_event_class *mmap2_class;
7981
};
8082

8183
struct convert {
@@ -915,6 +917,18 @@ __FUNC_PROCESS_NON_SAMPLE(exit,
915917
__NON_SAMPLE_SET_FIELD(fork, u32, ptid);
916918
__NON_SAMPLE_SET_FIELD(fork, u64, time);
917919
)
920+
__FUNC_PROCESS_NON_SAMPLE(mmap,
921+
__NON_SAMPLE_SET_FIELD(mmap, u32, pid);
922+
__NON_SAMPLE_SET_FIELD(mmap, u32, tid);
923+
__NON_SAMPLE_SET_FIELD(mmap, u64_hex, start);
924+
__NON_SAMPLE_SET_FIELD(mmap, string, filename);
925+
)
926+
__FUNC_PROCESS_NON_SAMPLE(mmap2,
927+
__NON_SAMPLE_SET_FIELD(mmap2, u32, pid);
928+
__NON_SAMPLE_SET_FIELD(mmap2, u32, tid);
929+
__NON_SAMPLE_SET_FIELD(mmap2, u64_hex, start);
930+
__NON_SAMPLE_SET_FIELD(mmap2, string, filename);
931+
)
918932
#undef __NON_SAMPLE_SET_FIELD
919933
#undef __FUNC_PROCESS_NON_SAMPLE
920934

@@ -1254,6 +1268,19 @@ __FUNC_ADD_NON_SAMPLE_EVENT_CLASS(exit,
12541268
__NON_SAMPLE_ADD_FIELD(u64, time);
12551269
)
12561270

1271+
__FUNC_ADD_NON_SAMPLE_EVENT_CLASS(mmap,
1272+
__NON_SAMPLE_ADD_FIELD(u32, pid);
1273+
__NON_SAMPLE_ADD_FIELD(u32, tid);
1274+
__NON_SAMPLE_ADD_FIELD(u64_hex, start);
1275+
__NON_SAMPLE_ADD_FIELD(string, filename);
1276+
)
1277+
1278+
__FUNC_ADD_NON_SAMPLE_EVENT_CLASS(mmap2,
1279+
__NON_SAMPLE_ADD_FIELD(u32, pid);
1280+
__NON_SAMPLE_ADD_FIELD(u32, tid);
1281+
__NON_SAMPLE_ADD_FIELD(u64_hex, start);
1282+
__NON_SAMPLE_ADD_FIELD(string, filename);
1283+
)
12571284
#undef __NON_SAMPLE_ADD_FIELD
12581285
#undef __FUNC_ADD_NON_SAMPLE_EVENT_CLASS
12591286

@@ -1269,6 +1296,12 @@ static int setup_non_sample_events(struct ctf_writer *cw,
12691296
if (ret)
12701297
return ret;
12711298
ret = add_fork_event(cw);
1299+
if (ret)
1300+
return ret;
1301+
ret = add_mmap_event(cw);
1302+
if (ret)
1303+
return ret;
1304+
ret = add_mmap2_event(cw);
12721305
if (ret)
12731306
return ret;
12741307
return 0;
@@ -1572,6 +1605,8 @@ int bt_convert__perf2ctf(const char *input, const char *path,
15721605
c.tool.comm = process_comm_event;
15731606
c.tool.exit = process_exit_event;
15741607
c.tool.fork = process_fork_event;
1608+
c.tool.mmap = process_mmap_event;
1609+
c.tool.mmap2 = process_mmap2_event;
15751610
}
15761611

15771612
err = perf_config(convert__config, &c);

0 commit comments

Comments
 (0)