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