]>
Commit | Line | Data |
---|---|---|
ee4512ed JH |
1 | #ifndef TR2_TGT_H |
2 | #define TR2_TGT_H | |
3 | ||
4 | struct child_process; | |
5 | struct repository; | |
6 | struct json_writer; | |
8ad57564 JH |
7 | struct tr2_timer_metadata; |
8 | struct tr2_timer; | |
81071626 JH |
9 | struct tr2_counter_metadata; |
10 | struct tr2_counter; | |
8ad57564 JH |
11 | |
12 | #define NS_TO_SEC(ns) ((double)(ns) / 1.0e9) | |
ee4512ed JH |
13 | |
14 | /* | |
15 | * Function prototypes for a TRACE2 "target" vtable. | |
16 | */ | |
17 | ||
18 | typedef int(tr2_tgt_init_t)(void); | |
19 | typedef void(tr2_tgt_term_t)(void); | |
20 | ||
21 | typedef void(tr2_tgt_evt_version_fl_t)(const char *file, int line); | |
22 | ||
23 | typedef void(tr2_tgt_evt_start_fl_t)(const char *file, int line, | |
39f43177 | 24 | uint64_t us_elapsed_absolute, |
ee4512ed JH |
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); | |
30 | ||
31 | typedef void(tr2_tgt_evt_error_va_fl_t)(const char *file, int line, | |
32 | const char *fmt, va_list ap); | |
33 | ||
34 | typedef void(tr2_tgt_evt_command_path_fl_t)(const char *file, int line, | |
35 | const char *command_path); | |
2f732bf1 ES |
36 | typedef void(tr2_tgt_evt_command_ancestry_fl_t)(const char *file, int line, |
37 | const char **parent_names); | |
ee4512ed JH |
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); | |
43 | ||
44 | typedef void(tr2_tgt_evt_alias_fl_t)(const char *file, int line, | |
45 | const char *alias, const char **argv); | |
46 | ||
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); | |
64bc7524 JH |
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); | |
ee4512ed JH |
58 | |
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); | |
64 | ||
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); | |
71 | ||
dc902084 | 72 | struct key_value_info; |
ee4512ed | 73 | typedef void(tr2_tgt_evt_param_fl_t)(const char *file, int line, |
dc902084 GC |
74 | const char *param, const char *value, |
75 | const struct key_value_info *kvi); | |
ee4512ed JH |
76 | |
77 | typedef void(tr2_tgt_evt_repo_fl_t)(const char *file, int line, | |
78 | const struct repository *repo); | |
79 | ||
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); | |
88 | ||
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); | |
102 | ||
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); | |
106 | ||
8ad57564 JH |
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); | |
110 | ||
81071626 JH |
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); | |
114 | ||
ee4512ed JH |
115 | /* |
116 | * "vtable" for a TRACE2 target. Use NULL if a target does not want | |
117 | * to emit that message. | |
118 | */ | |
119 | /* clang-format off */ | |
120 | struct tr2_tgt { | |
121 | struct tr2_dst *pdst; | |
122 | ||
123 | tr2_tgt_init_t *pfn_init; | |
124 | tr2_tgt_term_t *pfn_term; | |
125 | ||
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; | |
2f732bf1 | 133 | tr2_tgt_evt_command_ancestry_fl_t *pfn_command_ancestry_fl; |
ee4512ed JH |
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; | |
64bc7524 | 139 | tr2_tgt_evt_child_ready_fl_t *pfn_child_ready_fl; |
ee4512ed JH |
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; | |
8ad57564 | 151 | tr2_tgt_evt_timer_t *pfn_timer; |
81071626 | 152 | tr2_tgt_evt_counter_t *pfn_counter; |
ee4512ed JH |
153 | }; |
154 | /* clang-format on */ | |
155 | ||
156 | extern struct tr2_tgt tr2_tgt_event; | |
157 | extern struct tr2_tgt tr2_tgt_normal; | |
158 | extern struct tr2_tgt tr2_tgt_perf; | |
159 | ||
160 | #endif /* TR2_TGT_H */ |