David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame^] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 2 | /* |
| 3 | * db-export.h: Support for exporting data suitable for import to a database |
| 4 | * Copyright (c) 2014, Intel Corporation. |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 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 | |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame^] | 13 | struct evsel; |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 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; |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame^] | 28 | struct evsel *evsel; |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 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 { |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame^] | 42 | int (*export_evsel)(struct db_export *dbe, struct evsel *evsel); |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 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); |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame^] | 46 | int (*export_comm)(struct db_export *dbe, struct comm *comm, |
| 47 | struct thread *thread); |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 48 | int (*export_comm_thread)(struct db_export *dbe, u64 db_id, |
| 49 | struct comm *comm, struct thread *thread); |
| 50 | int (*export_dso)(struct db_export *dbe, struct dso *dso, |
| 51 | struct machine *machine); |
| 52 | int (*export_symbol)(struct db_export *dbe, struct symbol *sym, |
| 53 | struct dso *dso); |
| 54 | int (*export_branch_type)(struct db_export *dbe, u32 branch_type, |
| 55 | const char *name); |
| 56 | int (*export_sample)(struct db_export *dbe, struct export_sample *es); |
| 57 | int (*export_call_path)(struct db_export *dbe, struct call_path *cp); |
| 58 | int (*export_call_return)(struct db_export *dbe, |
| 59 | struct call_return *cr); |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame^] | 60 | int (*export_context_switch)(struct db_export *dbe, u64 db_id, |
| 61 | struct machine *machine, |
| 62 | struct perf_sample *sample, |
| 63 | u64 th_out_id, u64 comm_out_id, |
| 64 | u64 th_in_id, u64 comm_in_id, int flags); |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 65 | struct call_return_processor *crp; |
| 66 | struct call_path_root *cpr; |
| 67 | u64 evsel_last_db_id; |
| 68 | u64 machine_last_db_id; |
| 69 | u64 thread_last_db_id; |
| 70 | u64 comm_last_db_id; |
| 71 | u64 comm_thread_last_db_id; |
| 72 | u64 dso_last_db_id; |
| 73 | u64 symbol_last_db_id; |
| 74 | u64 sample_last_db_id; |
| 75 | u64 call_path_last_db_id; |
| 76 | u64 call_return_last_db_id; |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame^] | 77 | u64 context_switch_last_db_id; |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 78 | }; |
| 79 | |
| 80 | int db_export__init(struct db_export *dbe); |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 81 | void db_export__exit(struct db_export *dbe); |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame^] | 82 | int db_export__evsel(struct db_export *dbe, struct evsel *evsel); |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 83 | int db_export__machine(struct db_export *dbe, struct machine *machine); |
| 84 | int db_export__thread(struct db_export *dbe, struct thread *thread, |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame^] | 85 | struct machine *machine, struct thread *main_thread); |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 86 | int db_export__comm(struct db_export *dbe, struct comm *comm, |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame^] | 87 | struct thread *thread); |
| 88 | int db_export__exec_comm(struct db_export *dbe, struct comm *comm, |
| 89 | struct thread *main_thread); |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 90 | int db_export__comm_thread(struct db_export *dbe, struct comm *comm, |
| 91 | struct thread *thread); |
| 92 | int db_export__dso(struct db_export *dbe, struct dso *dso, |
| 93 | struct machine *machine); |
| 94 | int db_export__symbol(struct db_export *dbe, struct symbol *sym, |
| 95 | struct dso *dso); |
| 96 | int db_export__branch_type(struct db_export *dbe, u32 branch_type, |
| 97 | const char *name); |
| 98 | int db_export__sample(struct db_export *dbe, union perf_event *event, |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame^] | 99 | struct perf_sample *sample, struct evsel *evsel, |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 100 | struct addr_location *al); |
| 101 | |
| 102 | int db_export__branch_types(struct db_export *dbe); |
| 103 | |
| 104 | int db_export__call_path(struct db_export *dbe, struct call_path *cp); |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame^] | 105 | int db_export__call_return(struct db_export *dbe, struct call_return *cr, |
| 106 | u64 *parent_db_id); |
| 107 | int db_export__switch(struct db_export *dbe, union perf_event *event, |
| 108 | struct perf_sample *sample, struct machine *machine); |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 109 | |
| 110 | #endif |