t5000: use check_mtime()
[git/debian.git] / trace2 / tr2_tgt.h
blobbf8745c4f0540cbe0f280e56d3938ec9939413cd
1 #ifndef TR2_TGT_H
2 #define TR2_TGT_H
4 struct child_process;
5 struct repository;
6 struct json_writer;
7 struct tr2_timer_metadata;
8 struct tr2_timer;
9 struct tr2_counter_metadata;
10 struct tr2_counter;
12 #define NS_TO_SEC(ns) ((double)(ns) / 1.0e9)
15 * Function prototypes for a TRACE2 "target" vtable.
18 typedef int(tr2_tgt_init_t)(void);
19 typedef void(tr2_tgt_term_t)(void);
21 typedef void(tr2_tgt_evt_version_fl_t)(const char *file, int line);
23 typedef void(tr2_tgt_evt_start_fl_t)(const char *file, int line,
24 uint64_t us_elapsed_absolute,
25 const char **argv);
26 typedef void(tr2_tgt_evt_exit_fl_t)(const char *file, int line,
27 uint64_t us_elapsed_absolute, int code);
28 typedef void(tr2_tgt_evt_signal_t)(uint64_t us_elapsed_absolute, int signo);
29 typedef void(tr2_tgt_evt_atexit_t)(uint64_t us_elapsed_absolute, int code);
31 typedef void(tr2_tgt_evt_error_va_fl_t)(const char *file, int line,
32 const char *fmt, va_list ap);
34 typedef void(tr2_tgt_evt_command_path_fl_t)(const char *file, int line,
35 const char *command_path);
36 typedef void(tr2_tgt_evt_command_ancestry_fl_t)(const char *file, int line,
37 const char **parent_names);
38 typedef void(tr2_tgt_evt_command_name_fl_t)(const char *file, int line,
39 const char *name,
40 const char *hierarchy);
41 typedef void(tr2_tgt_evt_command_mode_fl_t)(const char *file, int line,
42 const char *mode);
44 typedef void(tr2_tgt_evt_alias_fl_t)(const char *file, int line,
45 const char *alias, const char **argv);
47 typedef void(tr2_tgt_evt_child_start_fl_t)(const char *file, int line,
48 uint64_t us_elapsed_absolute,
49 const struct child_process *cmd);
50 typedef void(tr2_tgt_evt_child_exit_fl_t)(const char *file, int line,
51 uint64_t us_elapsed_absolute, int cid,
52 int pid, int code,
53 uint64_t us_elapsed_child);
54 typedef void(tr2_tgt_evt_child_ready_fl_t)(const char *file, int line,
55 uint64_t us_elapsed_absolute,
56 int cid, int pid, const char *ready,
57 uint64_t us_elapsed_child);
59 typedef void(tr2_tgt_evt_thread_start_fl_t)(const char *file, int line,
60 uint64_t us_elapsed_absolute);
61 typedef void(tr2_tgt_evt_thread_exit_fl_t)(const char *file, int line,
62 uint64_t us_elapsed_absolute,
63 uint64_t us_elapsed_thread);
65 typedef void(tr2_tgt_evt_exec_fl_t)(const char *file, int line,
66 uint64_t us_elapsed_absolute, int exec_id,
67 const char *exe, const char **argv);
68 typedef void(tr2_tgt_evt_exec_result_fl_t)(const char *file, int line,
69 uint64_t us_elapsed_absolute,
70 int exec_id, int code);
72 typedef void(tr2_tgt_evt_param_fl_t)(const char *file, int line,
73 const char *param, const char *value);
75 typedef void(tr2_tgt_evt_repo_fl_t)(const char *file, int line,
76 const struct repository *repo);
78 typedef void(tr2_tgt_evt_region_enter_printf_va_fl_t)(
79 const char *file, int line, uint64_t us_elapsed_absolute,
80 const char *category, const char *label, const struct repository *repo,
81 const char *fmt, va_list ap);
82 typedef void(tr2_tgt_evt_region_leave_printf_va_fl_t)(
83 const char *file, int line, uint64_t us_elapsed_absolute,
84 uint64_t us_elapsed_region, const char *category, const char *label,
85 const struct repository *repo, const char *fmt, va_list ap);
87 typedef void(tr2_tgt_evt_data_fl_t)(const char *file, int line,
88 uint64_t us_elapsed_absolute,
89 uint64_t us_elapsed_region,
90 const char *category,
91 const struct repository *repo,
92 const char *key, const char *value);
93 typedef void(tr2_tgt_evt_data_json_fl_t)(const char *file, int line,
94 uint64_t us_elapsed_absolute,
95 uint64_t us_elapsed_region,
96 const char *category,
97 const struct repository *repo,
98 const char *key,
99 const struct json_writer *value);
101 typedef void(tr2_tgt_evt_printf_va_fl_t)(const char *file, int line,
102 uint64_t us_elapsed_absolute,
103 const char *fmt, va_list ap);
105 typedef void(tr2_tgt_evt_timer_t)(const struct tr2_timer_metadata *meta,
106 const struct tr2_timer *timer,
107 int is_final_data);
109 typedef void(tr2_tgt_evt_counter_t)(const struct tr2_counter_metadata *meta,
110 const struct tr2_counter *counter,
111 int is_final_data);
114 * "vtable" for a TRACE2 target. Use NULL if a target does not want
115 * to emit that message.
117 /* clang-format off */
118 struct tr2_tgt {
119 struct tr2_dst *pdst;
121 tr2_tgt_init_t *pfn_init;
122 tr2_tgt_term_t *pfn_term;
124 tr2_tgt_evt_version_fl_t *pfn_version_fl;
125 tr2_tgt_evt_start_fl_t *pfn_start_fl;
126 tr2_tgt_evt_exit_fl_t *pfn_exit_fl;
127 tr2_tgt_evt_signal_t *pfn_signal;
128 tr2_tgt_evt_atexit_t *pfn_atexit;
129 tr2_tgt_evt_error_va_fl_t *pfn_error_va_fl;
130 tr2_tgt_evt_command_path_fl_t *pfn_command_path_fl;
131 tr2_tgt_evt_command_ancestry_fl_t *pfn_command_ancestry_fl;
132 tr2_tgt_evt_command_name_fl_t *pfn_command_name_fl;
133 tr2_tgt_evt_command_mode_fl_t *pfn_command_mode_fl;
134 tr2_tgt_evt_alias_fl_t *pfn_alias_fl;
135 tr2_tgt_evt_child_start_fl_t *pfn_child_start_fl;
136 tr2_tgt_evt_child_exit_fl_t *pfn_child_exit_fl;
137 tr2_tgt_evt_child_ready_fl_t *pfn_child_ready_fl;
138 tr2_tgt_evt_thread_start_fl_t *pfn_thread_start_fl;
139 tr2_tgt_evt_thread_exit_fl_t *pfn_thread_exit_fl;
140 tr2_tgt_evt_exec_fl_t *pfn_exec_fl;
141 tr2_tgt_evt_exec_result_fl_t *pfn_exec_result_fl;
142 tr2_tgt_evt_param_fl_t *pfn_param_fl;
143 tr2_tgt_evt_repo_fl_t *pfn_repo_fl;
144 tr2_tgt_evt_region_enter_printf_va_fl_t *pfn_region_enter_printf_va_fl;
145 tr2_tgt_evt_region_leave_printf_va_fl_t *pfn_region_leave_printf_va_fl;
146 tr2_tgt_evt_data_fl_t *pfn_data_fl;
147 tr2_tgt_evt_data_json_fl_t *pfn_data_json_fl;
148 tr2_tgt_evt_printf_va_fl_t *pfn_printf_va_fl;
149 tr2_tgt_evt_timer_t *pfn_timer;
150 tr2_tgt_evt_counter_t *pfn_counter;
152 /* clang-format on */
154 extern struct tr2_tgt tr2_tgt_event;
155 extern struct tr2_tgt tr2_tgt_normal;
156 extern struct tr2_tgt tr2_tgt_perf;
158 #endif /* TR2_TGT_H */