]>
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 | ||
72 | typedef void(tr2_tgt_evt_param_fl_t)(const char *file, int line, | |
73 | const char *param, const char *value); | |
74 | ||
75 | typedef void(tr2_tgt_evt_repo_fl_t)(const char *file, int line, | |
76 | const struct repository *repo); | |
77 | ||
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); | |
86 | ||
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); | |
100 | ||
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); | |
104 | ||
8ad57564 JH |
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); | |
108 | ||
81071626 JH |
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); | |
112 | ||
ee4512ed JH |
113 | /* |
114 | * "vtable" for a TRACE2 target. Use NULL if a target does not want | |
115 | * to emit that message. | |
116 | */ | |
117 | /* clang-format off */ | |
118 | struct tr2_tgt { | |
119 | struct tr2_dst *pdst; | |
120 | ||
121 | tr2_tgt_init_t *pfn_init; | |
122 | tr2_tgt_term_t *pfn_term; | |
123 | ||
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; | |
2f732bf1 | 131 | tr2_tgt_evt_command_ancestry_fl_t *pfn_command_ancestry_fl; |
ee4512ed JH |
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; | |
64bc7524 | 137 | tr2_tgt_evt_child_ready_fl_t *pfn_child_ready_fl; |
ee4512ed JH |
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; | |
8ad57564 | 149 | tr2_tgt_evt_timer_t *pfn_timer; |
81071626 | 150 | tr2_tgt_evt_counter_t *pfn_counter; |
ee4512ed JH |
151 | }; |
152 | /* clang-format on */ | |
153 | ||
154 | extern struct tr2_tgt tr2_tgt_event; | |
155 | extern struct tr2_tgt tr2_tgt_normal; | |
156 | extern struct tr2_tgt tr2_tgt_perf; | |
157 | ||
158 | #endif /* TR2_TGT_H */ |