blob: 67bc6b8ad2d6ecc42519e980a66e78e71da108ab [file] [log] [blame]
Adrian Hunter0db15b12014-10-23 13:45:13 +03001/*
2 * db-export.h: Support for exporting data suitable for import to a database
3 * Copyright (c) 2014, Intel Corporation.
4 *
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms and conditions of the GNU General Public License,
7 * version 2, as published by the Free Software Foundation.
8 *
9 * This program is distributed in the hope it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12 * more details.
13 *
14 */
15
16#ifndef __PERF_DB_EXPORT_H
17#define __PERF_DB_EXPORT_H
18
19#include <linux/types.h>
Adrian Hunter758008b2014-10-30 16:09:48 +020020#include <linux/list.h>
Adrian Hunter0db15b12014-10-23 13:45:13 +030021
22struct perf_evsel;
23struct machine;
24struct thread;
25struct comm;
26struct dso;
27struct perf_sample;
28struct addr_location;
Adrian Hunter88f50d62014-10-30 16:09:46 +020029struct call_return_processor;
Chris Phlipot0a3eba32016-04-28 01:19:08 -070030struct call_path_root;
Adrian Hunter88f50d62014-10-30 16:09:46 +020031struct call_path;
32struct call_return;
Adrian Hunter0db15b12014-10-23 13:45:13 +030033
34struct export_sample {
35 union perf_event *event;
36 struct perf_sample *sample;
37 struct perf_evsel *evsel;
Adrian Hunter0db15b12014-10-23 13:45:13 +030038 struct addr_location *al;
39 u64 db_id;
40 u64 comm_db_id;
41 u64 dso_db_id;
42 u64 sym_db_id;
43 u64 offset; /* ip offset from symbol start */
44 u64 addr_dso_db_id;
45 u64 addr_sym_db_id;
46 u64 addr_offset; /* addr offset from symbol start */
Chris Phlipot568850e2016-04-28 01:19:09 -070047 u64 call_path_id;
Adrian Hunter0db15b12014-10-23 13:45:13 +030048};
49
50struct db_export {
51 int (*export_evsel)(struct db_export *dbe, struct perf_evsel *evsel);
52 int (*export_machine)(struct db_export *dbe, struct machine *machine);
53 int (*export_thread)(struct db_export *dbe, struct thread *thread,
54 u64 main_thread_db_id, struct machine *machine);
55 int (*export_comm)(struct db_export *dbe, struct comm *comm);
56 int (*export_comm_thread)(struct db_export *dbe, u64 db_id,
57 struct comm *comm, struct thread *thread);
58 int (*export_dso)(struct db_export *dbe, struct dso *dso,
59 struct machine *machine);
60 int (*export_symbol)(struct db_export *dbe, struct symbol *sym,
61 struct dso *dso);
Adrian Hunterf2bff002014-10-30 16:09:43 +020062 int (*export_branch_type)(struct db_export *dbe, u32 branch_type,
63 const char *name);
Adrian Hunter0db15b12014-10-23 13:45:13 +030064 int (*export_sample)(struct db_export *dbe, struct export_sample *es);
Adrian Hunter88f50d62014-10-30 16:09:46 +020065 int (*export_call_path)(struct db_export *dbe, struct call_path *cp);
66 int (*export_call_return)(struct db_export *dbe,
67 struct call_return *cr);
68 struct call_return_processor *crp;
Chris Phlipot0a3eba32016-04-28 01:19:08 -070069 struct call_path_root *cpr;
Adrian Hunter0db15b12014-10-23 13:45:13 +030070 u64 evsel_last_db_id;
71 u64 machine_last_db_id;
72 u64 thread_last_db_id;
73 u64 comm_last_db_id;
74 u64 comm_thread_last_db_id;
75 u64 dso_last_db_id;
76 u64 symbol_last_db_id;
77 u64 sample_last_db_id;
Adrian Hunter88f50d62014-10-30 16:09:46 +020078 u64 call_path_last_db_id;
79 u64 call_return_last_db_id;
Adrian Hunter758008b2014-10-30 16:09:48 +020080 struct list_head deferred;
Adrian Hunter0db15b12014-10-23 13:45:13 +030081};
82
83int db_export__init(struct db_export *dbe);
Adrian Hunter758008b2014-10-30 16:09:48 +020084int db_export__flush(struct db_export *dbe);
Adrian Hunter0db15b12014-10-23 13:45:13 +030085void db_export__exit(struct db_export *dbe);
86int db_export__evsel(struct db_export *dbe, struct perf_evsel *evsel);
87int db_export__machine(struct db_export *dbe, struct machine *machine);
88int db_export__thread(struct db_export *dbe, struct thread *thread,
89 struct machine *machine, struct comm *comm);
90int db_export__comm(struct db_export *dbe, struct comm *comm,
91 struct thread *main_thread);
92int db_export__comm_thread(struct db_export *dbe, struct comm *comm,
93 struct thread *thread);
94int db_export__dso(struct db_export *dbe, struct dso *dso,
95 struct machine *machine);
96int db_export__symbol(struct db_export *dbe, struct symbol *sym,
97 struct dso *dso);
Adrian Hunterf2bff002014-10-30 16:09:43 +020098int db_export__branch_type(struct db_export *dbe, u32 branch_type,
99 const char *name);
Adrian Hunter0db15b12014-10-23 13:45:13 +0300100int db_export__sample(struct db_export *dbe, union perf_event *event,
101 struct perf_sample *sample, struct perf_evsel *evsel,
Arnaldo Carvalho de Melo73272592015-04-02 11:08:30 -0300102 struct addr_location *al);
Adrian Hunter0db15b12014-10-23 13:45:13 +0300103
Adrian Hunterf2bff002014-10-30 16:09:43 +0200104int db_export__branch_types(struct db_export *dbe);
105
Adrian Hunter88f50d62014-10-30 16:09:46 +0200106int db_export__call_path(struct db_export *dbe, struct call_path *cp);
107int db_export__call_return(struct db_export *dbe, struct call_return *cr);
108
Adrian Hunter0db15b12014-10-23 13:45:13 +0300109#endif