t5551: stop writing packed-refs directly
[alt-git.git] / trace2 / tr2_tgt.h
blob1f626cffea0fc01508beaa65248398faa8c0a8ab
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 struct key_value_info;
73 typedef void(tr2_tgt_evt_param_fl_t)(const char *file, int line,
74 const char *param, const char *value,
75 const struct key_value_info *kvi);
77 typedef void(tr2_tgt_evt_repo_fl_t)(const char *file, int line,
78 const struct repository *repo);
80 typedef void(tr2_tgt_evt_region_enter_printf_va_fl_t)(
81 const char *file, int line, uint64_t us_elapsed_absolute,
82 const char *category, const char *label, const struct repository *repo,
83 const char *fmt, va_list ap);
84 typedef void(tr2_tgt_evt_region_leave_printf_va_fl_t)(
85 const char *file, int line, uint64_t us_elapsed_absolute,
86 uint64_t us_elapsed_region, const char *category, const char *label,
87 const struct repository *repo, const char *fmt, va_list ap);
89 typedef void(tr2_tgt_evt_data_fl_t)(const char *file, int line,
90 uint64_t us_elapsed_absolute,
91 uint64_t us_elapsed_region,
92 const char *category,
93 const struct repository *repo,
94 const char *key, const char *value);
95 typedef void(tr2_tgt_evt_data_json_fl_t)(const char *file, int line,
96 uint64_t us_elapsed_absolute,
97 uint64_t us_elapsed_region,
98 const char *category,
99 const struct repository *repo,
100 const char *key,
101 const struct json_writer *value);
103 typedef void(tr2_tgt_evt_printf_va_fl_t)(const char *file, int line,
104 uint64_t us_elapsed_absolute,
105 const char *fmt, va_list ap);
107 typedef void(tr2_tgt_evt_timer_t)(const struct tr2_timer_metadata *meta,
108 const struct tr2_timer *timer,
109 int is_final_data);
111 typedef void(tr2_tgt_evt_counter_t)(const struct tr2_counter_metadata *meta,
112 const struct tr2_counter *counter,
113 int is_final_data);
116 * "vtable" for a TRACE2 target. Use NULL if a target does not want
117 * to emit that message.
119 /* clang-format off */
120 struct tr2_tgt {
121 struct tr2_dst *pdst;
123 tr2_tgt_init_t *pfn_init;
124 tr2_tgt_term_t *pfn_term;
126 tr2_tgt_evt_version_fl_t *pfn_version_fl;
127 tr2_tgt_evt_start_fl_t *pfn_start_fl;
128 tr2_tgt_evt_exit_fl_t *pfn_exit_fl;
129 tr2_tgt_evt_signal_t *pfn_signal;
130 tr2_tgt_evt_atexit_t *pfn_atexit;
131 tr2_tgt_evt_error_va_fl_t *pfn_error_va_fl;
132 tr2_tgt_evt_command_path_fl_t *pfn_command_path_fl;
133 tr2_tgt_evt_command_ancestry_fl_t *pfn_command_ancestry_fl;
134 tr2_tgt_evt_command_name_fl_t *pfn_command_name_fl;
135 tr2_tgt_evt_command_mode_fl_t *pfn_command_mode_fl;
136 tr2_tgt_evt_alias_fl_t *pfn_alias_fl;
137 tr2_tgt_evt_child_start_fl_t *pfn_child_start_fl;
138 tr2_tgt_evt_child_exit_fl_t *pfn_child_exit_fl;
139 tr2_tgt_evt_child_ready_fl_t *pfn_child_ready_fl;
140 tr2_tgt_evt_thread_start_fl_t *pfn_thread_start_fl;
141 tr2_tgt_evt_thread_exit_fl_t *pfn_thread_exit_fl;
142 tr2_tgt_evt_exec_fl_t *pfn_exec_fl;
143 tr2_tgt_evt_exec_result_fl_t *pfn_exec_result_fl;
144 tr2_tgt_evt_param_fl_t *pfn_param_fl;
145 tr2_tgt_evt_repo_fl_t *pfn_repo_fl;
146 tr2_tgt_evt_region_enter_printf_va_fl_t *pfn_region_enter_printf_va_fl;
147 tr2_tgt_evt_region_leave_printf_va_fl_t *pfn_region_leave_printf_va_fl;
148 tr2_tgt_evt_data_fl_t *pfn_data_fl;
149 tr2_tgt_evt_data_json_fl_t *pfn_data_json_fl;
150 tr2_tgt_evt_printf_va_fl_t *pfn_printf_va_fl;
151 tr2_tgt_evt_timer_t *pfn_timer;
152 tr2_tgt_evt_counter_t *pfn_counter;
154 /* clang-format on */
156 extern struct tr2_tgt tr2_tgt_event;
157 extern struct tr2_tgt tr2_tgt_normal;
158 extern struct tr2_tgt tr2_tgt_perf;
160 #endif /* TR2_TGT_H */