^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) /* SPDX-License-Identifier: GPL-2.0-only */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) * db-export.h: Support for exporting data suitable for import to a database
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) * Copyright (c) 2014, Intel Corporation.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) #ifndef __PERF_DB_EXPORT_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) #define __PERF_DB_EXPORT_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) #include <linux/types.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) #include <linux/list.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) struct evsel;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) struct machine;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) struct thread;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) struct comm;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) struct dso;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) struct perf_sample;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) struct addr_location;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) struct call_return_processor;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) struct call_path_root;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) struct call_path;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) struct call_return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) struct export_sample {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) union perf_event *event;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) struct perf_sample *sample;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) struct evsel *evsel;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) struct addr_location *al;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) u64 db_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) u64 comm_db_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) u64 dso_db_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) u64 sym_db_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) u64 offset; /* ip offset from symbol start */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) u64 addr_dso_db_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) u64 addr_sym_db_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) u64 addr_offset; /* addr offset from symbol start */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) u64 call_path_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) struct db_export {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) int (*export_evsel)(struct db_export *dbe, struct evsel *evsel);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) int (*export_machine)(struct db_export *dbe, struct machine *machine);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) int (*export_thread)(struct db_export *dbe, struct thread *thread,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) u64 main_thread_db_id, struct machine *machine);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) int (*export_comm)(struct db_export *dbe, struct comm *comm,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) struct thread *thread);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) int (*export_comm_thread)(struct db_export *dbe, u64 db_id,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) struct comm *comm, struct thread *thread);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) int (*export_dso)(struct db_export *dbe, struct dso *dso,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) struct machine *machine);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) int (*export_symbol)(struct db_export *dbe, struct symbol *sym,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) struct dso *dso);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) int (*export_branch_type)(struct db_export *dbe, u32 branch_type,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) const char *name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) int (*export_sample)(struct db_export *dbe, struct export_sample *es);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) int (*export_call_path)(struct db_export *dbe, struct call_path *cp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) int (*export_call_return)(struct db_export *dbe,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) struct call_return *cr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) int (*export_context_switch)(struct db_export *dbe, u64 db_id,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) struct machine *machine,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) struct perf_sample *sample,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) u64 th_out_id, u64 comm_out_id,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) u64 th_in_id, u64 comm_in_id, int flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) struct call_return_processor *crp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) struct call_path_root *cpr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) u64 evsel_last_db_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) u64 machine_last_db_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) u64 thread_last_db_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) u64 comm_last_db_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) u64 comm_thread_last_db_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) u64 dso_last_db_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) u64 symbol_last_db_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) u64 sample_last_db_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) u64 call_path_last_db_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) u64 call_return_last_db_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) u64 context_switch_last_db_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) int db_export__init(struct db_export *dbe);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) void db_export__exit(struct db_export *dbe);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) int db_export__evsel(struct db_export *dbe, struct evsel *evsel);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) int db_export__machine(struct db_export *dbe, struct machine *machine);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) int db_export__thread(struct db_export *dbe, struct thread *thread,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) struct machine *machine, struct thread *main_thread);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) int db_export__comm(struct db_export *dbe, struct comm *comm,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) struct thread *thread);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) int db_export__exec_comm(struct db_export *dbe, struct comm *comm,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) struct thread *main_thread);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) int db_export__comm_thread(struct db_export *dbe, struct comm *comm,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) struct thread *thread);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) int db_export__dso(struct db_export *dbe, struct dso *dso,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) struct machine *machine);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) int db_export__symbol(struct db_export *dbe, struct symbol *sym,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) struct dso *dso);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) int db_export__branch_type(struct db_export *dbe, u32 branch_type,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) const char *name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) int db_export__sample(struct db_export *dbe, union perf_event *event,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) struct perf_sample *sample, struct evsel *evsel,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) struct addr_location *al);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) int db_export__branch_types(struct db_export *dbe);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) int db_export__call_path(struct db_export *dbe, struct call_path *cp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) int db_export__call_return(struct db_export *dbe, struct call_return *cr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) u64 *parent_db_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) int db_export__switch(struct db_export *dbe, union perf_event *event,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) struct perf_sample *sample, struct machine *machine);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) #endif