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