Merge branch 'js/rebase-autosquash-double-fixup-fix'
[git] / trace2 / tr2_tgt.h
1 #ifndef TR2_TGT_H
2 #define TR2_TGT_H
3
4 struct child_process;
5 struct repository;
6 struct json_writer;
7
8 /*
9  * Function prototypes for a TRACE2 "target" vtable.
10  */
11
12 typedef int(tr2_tgt_init_t)(void);
13 typedef void(tr2_tgt_term_t)(void);
14
15 typedef void(tr2_tgt_evt_version_fl_t)(const char *file, int line);
16
17 typedef void(tr2_tgt_evt_start_fl_t)(const char *file, int line,
18                                      uint64_t us_elapsed_absolute,
19                                      const char **argv);
20 typedef void(tr2_tgt_evt_exit_fl_t)(const char *file, int line,
21                                     uint64_t us_elapsed_absolute, int code);
22 typedef void(tr2_tgt_evt_signal_t)(uint64_t us_elapsed_absolute, int signo);
23 typedef void(tr2_tgt_evt_atexit_t)(uint64_t us_elapsed_absolute, int code);
24
25 typedef void(tr2_tgt_evt_error_va_fl_t)(const char *file, int line,
26                                         const char *fmt, va_list ap);
27
28 typedef void(tr2_tgt_evt_command_path_fl_t)(const char *file, int line,
29                                             const char *command_path);
30 typedef void(tr2_tgt_evt_command_name_fl_t)(const char *file, int line,
31                                             const char *name,
32                                             const char *hierarchy);
33 typedef void(tr2_tgt_evt_command_mode_fl_t)(const char *file, int line,
34                                             const char *mode);
35
36 typedef void(tr2_tgt_evt_alias_fl_t)(const char *file, int line,
37                                      const char *alias, const char **argv);
38
39 typedef void(tr2_tgt_evt_child_start_fl_t)(const char *file, int line,
40                                            uint64_t us_elapsed_absolute,
41                                            const struct child_process *cmd);
42 typedef void(tr2_tgt_evt_child_exit_fl_t)(const char *file, int line,
43                                           uint64_t us_elapsed_absolute, int cid,
44                                           int pid, int code,
45                                           uint64_t us_elapsed_child);
46
47 typedef void(tr2_tgt_evt_thread_start_fl_t)(const char *file, int line,
48                                             uint64_t us_elapsed_absolute);
49 typedef void(tr2_tgt_evt_thread_exit_fl_t)(const char *file, int line,
50                                            uint64_t us_elapsed_absolute,
51                                            uint64_t us_elapsed_thread);
52
53 typedef void(tr2_tgt_evt_exec_fl_t)(const char *file, int line,
54                                     uint64_t us_elapsed_absolute, int exec_id,
55                                     const char *exe, const char **argv);
56 typedef void(tr2_tgt_evt_exec_result_fl_t)(const char *file, int line,
57                                            uint64_t us_elapsed_absolute,
58                                            int exec_id, int code);
59
60 typedef void(tr2_tgt_evt_param_fl_t)(const char *file, int line,
61                                      const char *param, const char *value);
62
63 typedef void(tr2_tgt_evt_repo_fl_t)(const char *file, int line,
64                                     const struct repository *repo);
65
66 typedef void(tr2_tgt_evt_region_enter_printf_va_fl_t)(
67         const char *file, int line, uint64_t us_elapsed_absolute,
68         const char *category, const char *label, const struct repository *repo,
69         const char *fmt, va_list ap);
70 typedef void(tr2_tgt_evt_region_leave_printf_va_fl_t)(
71         const char *file, int line, uint64_t us_elapsed_absolute,
72         uint64_t us_elapsed_region, const char *category, const char *label,
73         const struct repository *repo, const char *fmt, va_list ap);
74
75 typedef void(tr2_tgt_evt_data_fl_t)(const char *file, int line,
76                                     uint64_t us_elapsed_absolute,
77                                     uint64_t us_elapsed_region,
78                                     const char *category,
79                                     const struct repository *repo,
80                                     const char *key, const char *value);
81 typedef void(tr2_tgt_evt_data_json_fl_t)(const char *file, int line,
82                                          uint64_t us_elapsed_absolute,
83                                          uint64_t us_elapsed_region,
84                                          const char *category,
85                                          const struct repository *repo,
86                                          const char *key,
87                                          const struct json_writer *value);
88
89 typedef void(tr2_tgt_evt_printf_va_fl_t)(const char *file, int line,
90                                          uint64_t us_elapsed_absolute,
91                                          const char *fmt, va_list ap);
92
93 /*
94  * "vtable" for a TRACE2 target.  Use NULL if a target does not want
95  * to emit that message.
96  */
97 /* clang-format off */
98 struct tr2_tgt {
99         struct tr2_dst                          *pdst;
100
101         tr2_tgt_init_t                          *pfn_init;
102         tr2_tgt_term_t                          *pfn_term;
103
104         tr2_tgt_evt_version_fl_t                *pfn_version_fl;
105         tr2_tgt_evt_start_fl_t                  *pfn_start_fl;
106         tr2_tgt_evt_exit_fl_t                   *pfn_exit_fl;
107         tr2_tgt_evt_signal_t                    *pfn_signal;
108         tr2_tgt_evt_atexit_t                    *pfn_atexit;
109         tr2_tgt_evt_error_va_fl_t               *pfn_error_va_fl;
110         tr2_tgt_evt_command_path_fl_t           *pfn_command_path_fl;
111         tr2_tgt_evt_command_name_fl_t           *pfn_command_name_fl;
112         tr2_tgt_evt_command_mode_fl_t           *pfn_command_mode_fl;
113         tr2_tgt_evt_alias_fl_t                  *pfn_alias_fl;
114         tr2_tgt_evt_child_start_fl_t            *pfn_child_start_fl;
115         tr2_tgt_evt_child_exit_fl_t             *pfn_child_exit_fl;
116         tr2_tgt_evt_thread_start_fl_t           *pfn_thread_start_fl;
117         tr2_tgt_evt_thread_exit_fl_t            *pfn_thread_exit_fl;
118         tr2_tgt_evt_exec_fl_t                   *pfn_exec_fl;
119         tr2_tgt_evt_exec_result_fl_t            *pfn_exec_result_fl;
120         tr2_tgt_evt_param_fl_t                  *pfn_param_fl;
121         tr2_tgt_evt_repo_fl_t                   *pfn_repo_fl;
122         tr2_tgt_evt_region_enter_printf_va_fl_t *pfn_region_enter_printf_va_fl;
123         tr2_tgt_evt_region_leave_printf_va_fl_t *pfn_region_leave_printf_va_fl;
124         tr2_tgt_evt_data_fl_t                   *pfn_data_fl;
125         tr2_tgt_evt_data_json_fl_t              *pfn_data_json_fl;
126         tr2_tgt_evt_printf_va_fl_t              *pfn_printf_va_fl;
127 };
128 /* clang-format on */
129
130 extern struct tr2_tgt tr2_tgt_event;
131 extern struct tr2_tgt tr2_tgt_normal;
132 extern struct tr2_tgt tr2_tgt_perf;
133
134 #endif /* TR2_TGT_H */