blob: 23983cb35706b9a91725ec47e35ff5745afb3647 [file] [log] [blame]
Thomas Gleixner2025cf92019-05-29 07:18:02 -07001/* SPDX-License-Identifier: GPL-2.0-only */
Adrian Hunter0db15b12014-10-23 13:45:13 +03002/*
3 * db-export.h: Support for exporting data suitable for import to a database
4 * Copyright (c) 2014, Intel Corporation.
Adrian Hunter0db15b12014-10-23 13:45:13 +03005 */
6
7#ifndef __PERF_DB_EXPORT_H
8#define __PERF_DB_EXPORT_H
9
10#include <linux/types.h>
Adrian Hunter758008b2014-10-30 16:09:48 +020011#include <linux/list.h>
Adrian Hunter0db15b12014-10-23 13:45:13 +030012
Jiri Olsa32dcd022019-07-21 13:23:51 +020013struct evsel;
Adrian Hunter0db15b12014-10-23 13:45:13 +030014struct machine;
15struct thread;
16struct comm;
17struct dso;
18struct perf_sample;
19struct addr_location;
Adrian Hunter88f50d62014-10-30 16:09:46 +020020struct call_return_processor;
Chris Phlipot0a3eba32016-04-28 01:19:08 -070021struct call_path_root;
Adrian Hunter88f50d62014-10-30 16:09:46 +020022struct call_path;
23struct call_return;
Adrian Hunter0db15b12014-10-23 13:45:13 +030024
25struct export_sample {
26 union perf_event *event;
27 struct perf_sample *sample;
Jiri Olsa32dcd022019-07-21 13:23:51 +020028 struct evsel *evsel;
Adrian Hunter0db15b12014-10-23 13:45:13 +030029 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 */
Chris Phlipot568850e2016-04-28 01:19:09 -070038 u64 call_path_id;
Adrian Hunter0db15b12014-10-23 13:45:13 +030039};
40
41struct db_export {
Jiri Olsa32dcd022019-07-21 13:23:51 +020042 int (*export_evsel)(struct db_export *dbe, struct evsel *evsel);
Adrian Hunter0db15b12014-10-23 13:45:13 +030043 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);
Adrian Hunter8ebf5cc2019-07-10 11:57:57 +030046 int (*export_comm)(struct db_export *dbe, struct comm *comm,
47 struct thread *thread);
Adrian Hunter0db15b12014-10-23 13:45:13 +030048 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);
Adrian Hunterf2bff002014-10-30 16:09:43 +020054 int (*export_branch_type)(struct db_export *dbe, u32 branch_type,
55 const char *name);
Adrian Hunter0db15b12014-10-23 13:45:13 +030056 int (*export_sample)(struct db_export *dbe, struct export_sample *es);
Adrian Hunter88f50d62014-10-30 16:09:46 +020057 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);
Adrian Hunterabde8722019-07-10 11:58:08 +030060 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);
Adrian Hunter88f50d62014-10-30 16:09:46 +020065 struct call_return_processor *crp;
Chris Phlipot0a3eba32016-04-28 01:19:08 -070066 struct call_path_root *cpr;
Adrian Hunter0db15b12014-10-23 13:45:13 +030067 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;
Adrian Hunter88f50d62014-10-30 16:09:46 +020075 u64 call_path_last_db_id;
76 u64 call_return_last_db_id;
Adrian Hunterabde8722019-07-10 11:58:08 +030077 u64 context_switch_last_db_id;
Adrian Hunter0db15b12014-10-23 13:45:13 +030078};
79
80int db_export__init(struct db_export *dbe);
81void db_export__exit(struct db_export *dbe);
Jiri Olsa32dcd022019-07-21 13:23:51 +020082int db_export__evsel(struct db_export *dbe, struct evsel *evsel);
Adrian Hunter0db15b12014-10-23 13:45:13 +030083int db_export__machine(struct db_export *dbe, struct machine *machine);
84int db_export__thread(struct db_export *dbe, struct thread *thread,
Adrian Hunter1ed11952019-07-10 11:57:55 +030085 struct machine *machine, struct thread *main_thread);
Adrian Hunter80859c92019-07-10 11:58:00 +030086int db_export__comm(struct db_export *dbe, struct comm *comm,
87 struct thread *thread);
Adrian Hunter208032f2019-07-10 11:57:51 +030088int db_export__exec_comm(struct db_export *dbe, struct comm *comm,
89 struct thread *main_thread);
Adrian Hunter0db15b12014-10-23 13:45:13 +030090int db_export__comm_thread(struct db_export *dbe, struct comm *comm,
91 struct thread *thread);
92int db_export__dso(struct db_export *dbe, struct dso *dso,
93 struct machine *machine);
94int db_export__symbol(struct db_export *dbe, struct symbol *sym,
95 struct dso *dso);
Adrian Hunterf2bff002014-10-30 16:09:43 +020096int db_export__branch_type(struct db_export *dbe, u32 branch_type,
97 const char *name);
Adrian Hunter0db15b12014-10-23 13:45:13 +030098int db_export__sample(struct db_export *dbe, union perf_event *event,
Jiri Olsa32dcd022019-07-21 13:23:51 +020099 struct perf_sample *sample, struct evsel *evsel,
Adrian Hunter3f8e0092021-05-25 12:51:05 +0300100 struct addr_location *al, struct addr_location *addr_al);
Adrian Hunter0db15b12014-10-23 13:45:13 +0300101
Adrian Hunterf2bff002014-10-30 16:09:43 +0200102int db_export__branch_types(struct db_export *dbe);
103
Adrian Hunter88f50d62014-10-30 16:09:46 +0200104int db_export__call_path(struct db_export *dbe, struct call_path *cp);
Adrian Hunterf4358872019-02-28 15:00:24 +0200105int db_export__call_return(struct db_export *dbe, struct call_return *cr,
106 u64 *parent_db_id);
Adrian Hunterabde8722019-07-10 11:58:08 +0300107int db_export__switch(struct db_export *dbe, union perf_event *event,
108 struct perf_sample *sample, struct machine *machine);
Adrian Hunter88f50d62014-10-30 16:09:46 +0200109
Adrian Hunter0db15b12014-10-23 13:45:13 +0300110#endif