summaryrefslogtreecommitdiffstats
path: root/src/error.h
blob: b01cedb4fb776b787815d720e3f0489b2a85014c (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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
#ifndef ERROR_H
#define ERROR_H

enum {
	LT_ERROR_FILTER_TYPE_NTH,
	LT_ERROR_FILTER_TYPE_SEQ,
	LT_ERROR_FILTER_TYPE_STACK,
	LT_ERROR_FILTER_TYPE_INTERACTIVE,
};

enum {
	LT_ERROR_START_TYPE_AFTER,
};

struct lt_error_start {
	int type;
	union {
		struct {
			long entries;
			long exits;
			union {
				int index;
				char *sym;
			} name;
		} after;
	};
};

struct lt_error_sym {
	/*
	 * It is 'symbol' for normal usage and 'index' for
	 * file storage in names section (see struct
	 * lt_error_config definition
	 */
	union {
		char *symbol;
		int index;
	} name;
#define LT_MAXRET 20
	long ret;
	long call_current;
	long call_configured;

	int handle_sigsegv;
	int keep;
};

/*
 * stored in file like:
 *
 * struct lt_error_config
 * struct lt_error_config_sym array
 * names..
 */
struct lt_error_config {
	unsigned long n;
	int type;
	int sym_cnt;
	int names_size;
	struct lt_error_start start;
	struct lt_error_sym sym[0];
};

struct lt_error_app_return_sym {
	char *name;

#define LT_MAX_SYM_RETURNS 10
	union {
		long val;
		long vals[LT_MAX_SYM_RETURNS];
	};

	int val_idx;
	int val_cnt;

	/* When the symbol return is changed,
	 * set SIGSEGV handlers. */
	int handle_sigsegv;
	/* Do not change the return value. */
	int keep;

	struct lt_list_head list;
};

struct lt_error_app_filter {
	int type;
};

struct lt_error_app_return {
	char *name;
	struct lt_error_app_filter filter;

	struct lt_list_head head_sym;
	struct lt_list_head list_app;
	struct lt_list_head list_run;
};

enum {
	LT_ERROR_RUN_TYPE_SEQ,
	LT_ERROR_RUN_TYPE_AUTO,
	LT_ERROR_RUN_TYPE_REPLAY,
};

struct lt_error_app_run {
	char *name;
	char **args;
	int type;
	struct lt_error_start start;
	struct lt_list_head head_return;
	struct lt_list_head list_go;
	struct lt_list_head list_app;
};

struct lt_error_app_go {
	char *name;
	struct lt_list_head head_run;
	struct lt_list_head list;
};

struct lt_error_app {
	char *name;
	char *dir;
	int  no_storage;
	char *prog;

	struct lt_list_head head_run;
	struct lt_list_head head_go;
	struct lt_list_head head_return;
	struct lt_list_head list;
};

struct lt_config_app;
struct lt_config_audit;

#ifdef CONFIG_ARCH_HAVE_ERROR_SIM
int lt_error_app(struct lt_config_app *cfg,
		 struct lt_error_app *error_app);
int lt_error_go(struct lt_config_app *cfg,
		struct lt_error_app_go **go,
		struct lt_error_app *error_app,
		char *name, struct lt_list_head *runs);
int lt_error_run_return(struct lt_config_app *cfg,
			struct lt_error_app_run **run,
			struct lt_error_app *error_app,
			struct lt_list_head *ret);
int lt_error_run_args(struct lt_config_app *cfg,
		      struct lt_error_app_run **run,
		      struct lt_list_head *args);
int lt_error_run_type(struct lt_config_app *cfg,
		      struct lt_error_app_run **run,
		      int type);
int lt_error_run_start_after(struct lt_config_app *cfg,
			     struct lt_error_app_run **run,
			     int is_entries, long cnt, char *sym);
int lt_error_return_ass(struct lt_config_app *cfg,
			struct lt_error_app_return **ret,
			char *name, struct lt_list_head *list_vals,
			int handle_sigsegv, int keep);
int lt_error_return_filter(struct lt_config_app *cfg,
			   struct lt_error_app_return **ret,
			   int type, void *data);
int lt_error_app_init(struct lt_error_app *app);
int lt_error_config_write(struct lt_config_app *cfg, int fd);
int lt_error_config_read(struct lt_config_audit *cfg, int fd);
#else
static inline int lt_error_app(struct lt_config_app *cfg,
		 struct lt_error_app *error_app)
{
	return -1;
}

static int lt_error_go(struct lt_config_app *cfg,
		struct lt_error_app_go **go,
		struct lt_error_app *error_app,
		char *name, struct lt_list_head *runs)
{
	return -1;
}

static inline int lt_error_run_return(struct lt_config_app *cfg,
			struct lt_error_app_run **run,
			struct lt_error_app *error_app,
			struct lt_list_head *ret)
{
	return -1;
}

static inline int lt_error_run_args(struct lt_config_app *cfg,
		      struct lt_error_app_run **run,
		      struct lt_list_head *args)
{
	return -1;
}

static inline int lt_error_run_type(struct lt_config_app *cfg,
			struct lt_error_app_run **run,
			int type);
{
	return -1;
}


static int lt_error_run_start_after(struct lt_config_app *cfg,
				    struct lt_error_app_run **run,
				    int is_entries, long cnt, char *sym)
{
	return -1;
}

static inline int lt_error_app_init(struct lt_error_app *app)
{
	return -1;
}

static inline int lt_error_return_ass(struct lt_config_app *cfg,
			struct lt_error_app_return **ret,
			char *name, struct lt_list_head *list_vals,
			int handle_sigsegv, int keep)
{
	return -1;
}

static inline int lt_error_return_filter(struct lt_config_app *cfg,
			   struct lt_error_app_return **ret,
			   int type, void *data)
{
	return -1;
}

static inline int lt_error_config_write(struct lt_config_app *cfg, int fd)
{
	return 0;
}
#endif

#endif /* ERROR_H */