cobalt-posix.h 30.4 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
/*
 * Copyright (C) 2014 Jan Kiszka <jan.kiszka@siemens.com>.
 * Copyright (C) 2014 Philippe Gerum <rpm@xenomai.org>.
 *
 * Xenomai is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published
 * by the Free Software Foundation; either version 2 of the License,
 * or (at your option) any later version.
 *
 * Xenomai is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with Xenomai; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 * 02111-1307, USA.
 */
20
#undef TRACE_SYSTEM
21
#define TRACE_SYSTEM cobalt_posix
22
23
24
25
26

#if !defined(_TRACE_COBALT_POSIX_H) || defined(TRACE_HEADER_MULTI_READ)
#define _TRACE_COBALT_POSIX_H

#include <linux/tracepoint.h>
27
#include <linux/trace_seq.h>
28
#include <xenomai/posix/cond.h>
29
#include <xenomai/posix/mqueue.h>
30
#include <xenomai/posix/event.h>
31
32

#define __timespec_fields(__name)				\
33
	__field(time64_t, tv_sec_##__name)			\
34
35
36
37
38
39
40
41
42
	__field(long, tv_nsec_##__name)

#define __assign_timespec(__to, __from)				\
	do {							\
		__entry->tv_sec_##__to = (__from)->tv_sec;	\
		__entry->tv_nsec_##__to = (__from)->tv_nsec;	\
	} while (0)

#define __timespec_args(__name)					\
43
	(long long)__entry->tv_sec_##__name, __entry->tv_nsec_##__name
44

45
46
47
48
#ifdef CONFIG_IA32_EMULATION
#define __sc_compat(__name)	, { sc_cobalt_##__name + __COBALT_IA32_BASE, "compat-" #__name }
#else
#define __sc_compat(__name)
49
50
#endif

51
52
53
54
#define __cobalt_symbolic_syscall(__name)				\
	{ sc_cobalt_##__name, #__name }					\
	__sc_compat(__name)						\

55
56
57
58
59
60
61
62
63
64
65
#define __cobalt_syscall_name(__nr)					\
	__print_symbolic((__nr),					\
		__cobalt_symbolic_syscall(bind),			\
		__cobalt_symbolic_syscall(thread_create),		\
		__cobalt_symbolic_syscall(thread_getpid),		\
		__cobalt_symbolic_syscall(thread_setmode),		\
		__cobalt_symbolic_syscall(thread_setname),		\
		__cobalt_symbolic_syscall(thread_join),			\
		__cobalt_symbolic_syscall(thread_kill),			\
		__cobalt_symbolic_syscall(thread_setschedparam_ex),	\
		__cobalt_symbolic_syscall(thread_getschedparam_ex),	\
66
		__cobalt_symbolic_syscall(thread_setschedprio),		\
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
		__cobalt_symbolic_syscall(thread_getstat),		\
		__cobalt_symbolic_syscall(sem_init),			\
		__cobalt_symbolic_syscall(sem_destroy),			\
		__cobalt_symbolic_syscall(sem_post),			\
		__cobalt_symbolic_syscall(sem_wait),			\
		__cobalt_symbolic_syscall(sem_trywait),			\
		__cobalt_symbolic_syscall(sem_getvalue),		\
		__cobalt_symbolic_syscall(sem_open),			\
		__cobalt_symbolic_syscall(sem_close),			\
		__cobalt_symbolic_syscall(sem_unlink),			\
		__cobalt_symbolic_syscall(sem_timedwait),		\
		__cobalt_symbolic_syscall(sem_inquire),			\
		__cobalt_symbolic_syscall(sem_broadcast_np),		\
		__cobalt_symbolic_syscall(clock_getres),		\
		__cobalt_symbolic_syscall(clock_gettime),		\
		__cobalt_symbolic_syscall(clock_settime),		\
		__cobalt_symbolic_syscall(clock_nanosleep),		\
		__cobalt_symbolic_syscall(mutex_init),			\
		__cobalt_symbolic_syscall(mutex_check_init),		\
		__cobalt_symbolic_syscall(mutex_destroy),		\
		__cobalt_symbolic_syscall(mutex_lock),			\
		__cobalt_symbolic_syscall(mutex_timedlock),		\
		__cobalt_symbolic_syscall(mutex_trylock),		\
		__cobalt_symbolic_syscall(mutex_unlock),		\
		__cobalt_symbolic_syscall(cond_init),			\
		__cobalt_symbolic_syscall(cond_destroy),		\
		__cobalt_symbolic_syscall(cond_wait_prologue),		\
		__cobalt_symbolic_syscall(cond_wait_epilogue),		\
		__cobalt_symbolic_syscall(mq_open),			\
		__cobalt_symbolic_syscall(mq_close),			\
		__cobalt_symbolic_syscall(mq_unlink),			\
		__cobalt_symbolic_syscall(mq_getattr),			\
		__cobalt_symbolic_syscall(mq_timedsend),		\
		__cobalt_symbolic_syscall(mq_timedreceive),		\
		__cobalt_symbolic_syscall(mq_notify),			\
		__cobalt_symbolic_syscall(sched_minprio),		\
		__cobalt_symbolic_syscall(sched_maxprio),		\
		__cobalt_symbolic_syscall(sched_weightprio),		\
		__cobalt_symbolic_syscall(sched_yield),			\
		__cobalt_symbolic_syscall(sched_setscheduler_ex),	\
		__cobalt_symbolic_syscall(sched_getscheduler_ex),	\
		__cobalt_symbolic_syscall(sched_setconfig_np),		\
		__cobalt_symbolic_syscall(sched_getconfig_np),		\
		__cobalt_symbolic_syscall(timer_create),		\
		__cobalt_symbolic_syscall(timer_delete),		\
		__cobalt_symbolic_syscall(timer_settime),		\
		__cobalt_symbolic_syscall(timer_gettime),		\
		__cobalt_symbolic_syscall(timer_getoverrun),		\
		__cobalt_symbolic_syscall(timerfd_create),		\
		__cobalt_symbolic_syscall(timerfd_settime),		\
		__cobalt_symbolic_syscall(timerfd_gettime),		\
		__cobalt_symbolic_syscall(sigwait),			\
		__cobalt_symbolic_syscall(sigwaitinfo),			\
		__cobalt_symbolic_syscall(sigtimedwait),		\
		__cobalt_symbolic_syscall(sigpending),			\
		__cobalt_symbolic_syscall(kill),			\
		__cobalt_symbolic_syscall(sigqueue),			\
		__cobalt_symbolic_syscall(monitor_init),		\
		__cobalt_symbolic_syscall(monitor_destroy),		\
		__cobalt_symbolic_syscall(monitor_enter),		\
		__cobalt_symbolic_syscall(monitor_wait),		\
		__cobalt_symbolic_syscall(monitor_sync),		\
		__cobalt_symbolic_syscall(monitor_exit),		\
		__cobalt_symbolic_syscall(event_init),			\
		__cobalt_symbolic_syscall(event_wait),			\
		__cobalt_symbolic_syscall(event_sync),			\
		__cobalt_symbolic_syscall(event_destroy),		\
		__cobalt_symbolic_syscall(event_inquire),		\
		__cobalt_symbolic_syscall(open),			\
		__cobalt_symbolic_syscall(socket),			\
		__cobalt_symbolic_syscall(close),			\
		__cobalt_symbolic_syscall(ioctl),			\
		__cobalt_symbolic_syscall(read),			\
		__cobalt_symbolic_syscall(write),			\
		__cobalt_symbolic_syscall(recvmsg),			\
		__cobalt_symbolic_syscall(sendmsg),			\
		__cobalt_symbolic_syscall(mmap),			\
		__cobalt_symbolic_syscall(select),			\
		__cobalt_symbolic_syscall(fcntl),			\
		__cobalt_symbolic_syscall(migrate),			\
		__cobalt_symbolic_syscall(archcall),			\
		__cobalt_symbolic_syscall(trace),			\
		__cobalt_symbolic_syscall(corectl),			\
		__cobalt_symbolic_syscall(get_current),			\
		__cobalt_symbolic_syscall(backtrace),			\
		__cobalt_symbolic_syscall(serialdbg),			\
		__cobalt_symbolic_syscall(extend),			\
154
155
		__cobalt_symbolic_syscall(ftrace_puts),			\
		__cobalt_symbolic_syscall(recvmmsg),			\
156
		__cobalt_symbolic_syscall(sendmmsg),			\
157
158
159
160
161
162
163
		__cobalt_symbolic_syscall(clock_adjtime),		\
		__cobalt_symbolic_syscall(sem_timedwait64),		\
		__cobalt_symbolic_syscall(clock_gettime64),		\
		__cobalt_symbolic_syscall(clock_settime64),		\
		__cobalt_symbolic_syscall(clock_nanosleep64),		\
		__cobalt_symbolic_syscall(clock_getres64),		\
		__cobalt_symbolic_syscall(clock_adjtime64))
164

165
DECLARE_EVENT_CLASS(cobalt_syscall_entry,
166
167
	TP_PROTO(unsigned int nr),
	TP_ARGS(nr),
168
169

	TP_STRUCT__entry(
170
		__field(unsigned int, nr)
171
172
173
174
175
176
	),

	TP_fast_assign(
		__entry->nr = nr;
	),

177
	TP_printk("syscall=%s", __cobalt_syscall_name(__entry->nr))
178
179
);

180
DECLARE_EVENT_CLASS(cobalt_syscall_exit,
181
182
	TP_PROTO(long result),
	TP_ARGS(result),
183
184

	TP_STRUCT__entry(
185
		__field(long, result)
186
187
188
189
190
191
	),

	TP_fast_assign(
		__entry->result = result;
	),

192
	TP_printk("result=%ld", __entry->result)
193
194
);

195
196
197
198
199
200
201
202
203
#define cobalt_print_sched_policy(__policy)			\
	__print_symbolic(__policy,				\
			 {SCHED_NORMAL, "normal"},		\
			 {SCHED_FIFO, "fifo"},			\
			 {SCHED_RR, "rr"},			\
			 {SCHED_TP, "tp"},			\
			 {SCHED_QUOTA, "quota"},		\
			 {SCHED_SPORADIC, "sporadic"},		\
			 {SCHED_COBALT, "cobalt"},		\
204
			 {SCHED_WEAK, "weak"})
205

206
207
208
209
210
211
const char *cobalt_trace_parse_sched_params(struct trace_seq *, int,
					    struct sched_param_ex *);

#define __parse_sched_params(policy, params)			\
	cobalt_trace_parse_sched_params(p, policy,		\
					(struct sched_param_ex *)(params))
212
213
214

DECLARE_EVENT_CLASS(cobalt_posix_schedparam,
	TP_PROTO(unsigned long pth, int policy,
215
		 const struct sched_param_ex *param_ex),
216
217
218
219
220
221
222
223
224
225
226
227
228
229
	TP_ARGS(pth, policy, param_ex),

	TP_STRUCT__entry(
		__field(unsigned long, pth)
		__field(int, policy)
		__dynamic_array(char, param_ex, sizeof(struct sched_param_ex))
	),

	TP_fast_assign(
		__entry->pth = pth;
		__entry->policy = policy;
		memcpy(__get_dynamic_array(param_ex), param_ex, sizeof(*param_ex));
	),

230
231
	TP_printk("pth=%p policy=%s param={ %s }",
		  (void *)__entry->pth,
232
		  cobalt_print_sched_policy(__entry->policy),
233
234
		  __parse_sched_params(__entry->policy,
				       __get_dynamic_array(param_ex))
235
236
237
	)
);

238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
DECLARE_EVENT_CLASS(cobalt_posix_scheduler,
	TP_PROTO(pid_t pid, int policy,
		 const struct sched_param_ex *param_ex),
	TP_ARGS(pid, policy, param_ex),

	TP_STRUCT__entry(
		__field(pid_t, pid)
		__field(int, policy)
		__dynamic_array(char, param_ex, sizeof(struct sched_param_ex))
	),

	TP_fast_assign(
		__entry->pid = pid;
		__entry->policy = policy;
		memcpy(__get_dynamic_array(param_ex), param_ex, sizeof(*param_ex));
	),

255
256
	TP_printk("pid=%d policy=%s param={ %s }",
		  __entry->pid,
257
		  cobalt_print_sched_policy(__entry->policy),
258
259
		  __parse_sched_params(__entry->policy,
				       __get_dynamic_array(param_ex))
260
261
262
	)
);

263
264
265
266
DECLARE_EVENT_CLASS(cobalt_void,
	TP_PROTO(int dummy),
	TP_ARGS(dummy),
	TP_STRUCT__entry(
267
		__field(int, dummy)
268
269
270
271
272
273
274
	),
	TP_fast_assign(
		(void)dummy;
	),
	TP_printk("%s", "")
);

275
DEFINE_EVENT(cobalt_syscall_entry, cobalt_head_sysentry,
276
277
	TP_PROTO(unsigned int nr),
	TP_ARGS(nr)
278
279
);

280
DEFINE_EVENT(cobalt_syscall_exit, cobalt_head_sysexit,
281
282
	TP_PROTO(long result),
	TP_ARGS(result)
283
284
);

285
DEFINE_EVENT(cobalt_syscall_entry, cobalt_root_sysentry,
286
287
	TP_PROTO(unsigned int nr),
	TP_ARGS(nr)
288
289
);

290
DEFINE_EVENT(cobalt_syscall_exit, cobalt_root_sysexit,
291
292
	TP_PROTO(long result),
	TP_ARGS(result)
293
294
);

295
296
DEFINE_EVENT(cobalt_posix_schedparam, cobalt_pthread_create,
	TP_PROTO(unsigned long pth, int policy,
297
		 const struct sched_param_ex *param_ex),
298
299
300
301
302
	TP_ARGS(pth, policy, param_ex)
);

DEFINE_EVENT(cobalt_posix_schedparam, cobalt_pthread_setschedparam,
	TP_PROTO(unsigned long pth, int policy,
303
		 const struct sched_param_ex *param_ex),
304
305
306
307
308
	TP_ARGS(pth, policy, param_ex)
);

DEFINE_EVENT(cobalt_posix_schedparam, cobalt_pthread_getschedparam,
	TP_PROTO(unsigned long pth, int policy,
309
		 const struct sched_param_ex *param_ex),
310
311
312
	TP_ARGS(pth, policy, param_ex)
);

313
314
315
316
317
318
319
320
321
322
323
324
325
326
TRACE_EVENT(cobalt_pthread_setschedprio,
	TP_PROTO(unsigned long pth, int prio),
	TP_ARGS(pth, prio),
	TP_STRUCT__entry(
		__field(unsigned long, pth)
		__field(int, prio)
	),
	TP_fast_assign(
		__entry->pth = pth;
		__entry->prio = prio;
	),
	TP_printk("pth=%p prio=%d", (void *)__entry->pth, __entry->prio)
);

327
328
329
330
331
332
#define cobalt_print_thread_mode(__mode)			\
	__print_flags(__mode, "|",				\
		      {PTHREAD_WARNSW, "warnsw"},		\
		      {PTHREAD_LOCK_SCHED, "lock"},		\
		      {PTHREAD_DISABLE_LOCKBREAK, "nolockbreak"})

333
TRACE_EVENT(cobalt_pthread_setmode,
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
	TP_PROTO(int clrmask, int setmask),
	TP_ARGS(clrmask, setmask),
	TP_STRUCT__entry(
		__field(int, clrmask)
		__field(int, setmask)
	),
	TP_fast_assign(
		__entry->clrmask = clrmask;
		__entry->setmask = setmask;
	),
	TP_printk("clrmask=%#x(%s) setmask=%#x(%s)",
		  __entry->clrmask, cobalt_print_thread_mode(__entry->clrmask),
		  __entry->setmask, cobalt_print_thread_mode(__entry->setmask))
);

349
TRACE_EVENT(cobalt_pthread_setname,
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
	TP_PROTO(unsigned long pth, const char *name),
	TP_ARGS(pth, name),
	TP_STRUCT__entry(
		__field(unsigned long, pth)
		__string(name, name)
	),
	TP_fast_assign(
		__entry->pth = pth;
		__assign_str(name, name);
	),
	TP_printk("pth=%p name=%s", (void *)__entry->pth, __get_str(name))
);

DECLARE_EVENT_CLASS(cobalt_posix_pid,
	TP_PROTO(pid_t pid),
	TP_ARGS(pid),
	TP_STRUCT__entry(
		__field(pid_t, pid)
	),
	TP_fast_assign(
		__entry->pid = pid;
	),
	TP_printk("pid=%d", __entry->pid)
);

DEFINE_EVENT(cobalt_posix_pid, cobalt_pthread_stat,
	TP_PROTO(pid_t pid),
	TP_ARGS(pid)
);

TRACE_EVENT(cobalt_pthread_kill,
	TP_PROTO(unsigned long pth, int sig),
	TP_ARGS(pth, sig),
	TP_STRUCT__entry(
		__field(unsigned long, pth)
		__field(int, sig)
	),
	TP_fast_assign(
		__entry->pth = pth;
		__entry->sig = sig;
	),
	TP_printk("pth=%p sig=%d", (void *)__entry->pth, __entry->sig)
);

TRACE_EVENT(cobalt_pthread_join,
	TP_PROTO(unsigned long pth),
	TP_ARGS(pth),
	TP_STRUCT__entry(
		__field(unsigned long, pth)
	),
	TP_fast_assign(
		__entry->pth = pth;
	),
	TP_printk("pth=%p", (void *)__entry->pth)
);

406
407
408
409
410
411
412
413
414
415
416
417
TRACE_EVENT(cobalt_pthread_pid,
	TP_PROTO(unsigned long pth),
	TP_ARGS(pth),
	TP_STRUCT__entry(
		__field(unsigned long, pth)
	),
	TP_fast_assign(
		__entry->pth = pth;
	),
	TP_printk("pth=%p", (void *)__entry->pth)
);

418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
TRACE_EVENT(cobalt_pthread_extend,
	TP_PROTO(unsigned long pth, const char *name),
	TP_ARGS(pth, name),
	TP_STRUCT__entry(
		__field(unsigned long, pth)
		__string(name, name)
	),
	TP_fast_assign(
		__entry->pth = pth;
		__assign_str(name, name);
	),
	TP_printk("pth=%p +personality=%s", (void *)__entry->pth, __get_str(name))
);

TRACE_EVENT(cobalt_pthread_restrict,
	TP_PROTO(unsigned long pth, const char *name),
	TP_ARGS(pth, name),
	TP_STRUCT__entry(
		__field(unsigned long, pth)
		__string(name, name)
	),
	TP_fast_assign(
		__entry->pth = pth;
		__assign_str(name, name);
	),
	TP_printk("pth=%p -personality=%s", (void *)__entry->pth, __get_str(name))
);

DEFINE_EVENT(cobalt_void, cobalt_pthread_yield,
	TP_PROTO(int dummy),
	TP_ARGS(dummy)
);

451
TRACE_EVENT(cobalt_sched_setconfig,
452
453
454
455
456
457
458
459
460
461
462
463
	TP_PROTO(int cpu, int policy, size_t len),
	TP_ARGS(cpu, policy, len),
	TP_STRUCT__entry(
		__field(int, cpu)
		__field(int, policy)
		__field(size_t, len)
	),
	TP_fast_assign(
		__entry->cpu = cpu;
		__entry->policy = policy;
		__entry->len = len;
	),
464
	TP_printk("cpu=%d policy=%d(%s) len=%zu",
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
		  __entry->cpu, __entry->policy,
		  cobalt_print_sched_policy(__entry->policy),
		  __entry->len)
);

TRACE_EVENT(cobalt_sched_get_config,
	TP_PROTO(int cpu, int policy, size_t rlen),
	TP_ARGS(cpu, policy, rlen),
	TP_STRUCT__entry(
		__field(int, cpu)
		__field(int, policy)
		__field(ssize_t, rlen)
	),
	TP_fast_assign(
		__entry->cpu = cpu;
		__entry->policy = policy;
		__entry->rlen = rlen;
	),
	TP_printk("cpu=%d policy=%d(%s) rlen=%Zd",
		  __entry->cpu, __entry->policy,
		  cobalt_print_sched_policy(__entry->policy),
		  __entry->rlen)
);

489
490
491
492
493
494
DEFINE_EVENT(cobalt_posix_scheduler, cobalt_sched_setscheduler,
	TP_PROTO(pid_t pid, int policy,
		 const struct sched_param_ex *param_ex),
	TP_ARGS(pid, policy, param_ex)
);

495
496
497
498
499
DEFINE_EVENT(cobalt_posix_pid, cobalt_sched_getscheduler,
	TP_PROTO(pid_t pid),
	TP_ARGS(pid)
);

500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
DECLARE_EVENT_CLASS(cobalt_posix_prio_bound,
	TP_PROTO(int policy, int prio),
	TP_ARGS(policy, prio),
	TP_STRUCT__entry(
		__field(int, policy)
		__field(int, prio)
	),
	TP_fast_assign(
		__entry->policy = policy;
		__entry->prio = prio;
	),
	TP_printk("policy=%d(%s) prio=%d",
		  __entry->policy,
		  cobalt_print_sched_policy(__entry->policy),
		  __entry->prio)
);

DEFINE_EVENT(cobalt_posix_prio_bound, cobalt_sched_min_prio,
	TP_PROTO(int policy, int prio),
	TP_ARGS(policy, prio)
);

DEFINE_EVENT(cobalt_posix_prio_bound, cobalt_sched_max_prio,
	TP_PROTO(int policy, int prio),
	TP_ARGS(policy, prio)
);

DECLARE_EVENT_CLASS(cobalt_posix_sem,
	TP_PROTO(xnhandle_t handle),
	TP_ARGS(handle),
	TP_STRUCT__entry(
		__field(xnhandle_t, handle)
	),
	TP_fast_assign(
		__entry->handle = handle;
	),
536
	TP_printk("sem=%#x", __entry->handle)
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
);

DEFINE_EVENT(cobalt_posix_sem, cobalt_psem_wait,
	TP_PROTO(xnhandle_t handle),
	TP_ARGS(handle)
);

DEFINE_EVENT(cobalt_posix_sem, cobalt_psem_trywait,
	TP_PROTO(xnhandle_t handle),
	TP_ARGS(handle)
);

DEFINE_EVENT(cobalt_posix_sem, cobalt_psem_timedwait,
	TP_PROTO(xnhandle_t handle),
	TP_ARGS(handle)
);

DEFINE_EVENT(cobalt_posix_sem, cobalt_psem_post,
	TP_PROTO(xnhandle_t handle),
	TP_ARGS(handle)
);

DEFINE_EVENT(cobalt_posix_sem, cobalt_psem_destroy,
	TP_PROTO(xnhandle_t handle),
	TP_ARGS(handle)
);

DEFINE_EVENT(cobalt_posix_sem, cobalt_psem_broadcast,
	TP_PROTO(xnhandle_t handle),
	TP_ARGS(handle)
);

DEFINE_EVENT(cobalt_posix_sem, cobalt_psem_inquire,
	TP_PROTO(xnhandle_t handle),
	TP_ARGS(handle)
);

TRACE_EVENT(cobalt_psem_getvalue,
	TP_PROTO(xnhandle_t handle, int value),
	TP_ARGS(handle, value),
	TP_STRUCT__entry(
		__field(xnhandle_t, handle)
		__field(int, value)
	),
	TP_fast_assign(
		__entry->handle = handle;
		__entry->value = value;
	),
585
	TP_printk("sem=%#x value=%d", __entry->handle, __entry->value)
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
);

#define cobalt_print_sem_flags(__flags)				\
  	__print_flags(__flags, "|",				\
			 {SEM_FIFO, "fifo"},			\
			 {SEM_PULSE, "pulse"},			\
			 {SEM_PSHARED, "pshared"},		\
			 {SEM_REPORT, "report"},		\
			 {SEM_WARNDEL, "warndel"},		\
			 {SEM_RAWCLOCK, "rawclock"},		\
			 {SEM_NOBUSYDEL, "nobusydel"})

TRACE_EVENT(cobalt_psem_init,
	TP_PROTO(const char *name, xnhandle_t handle,
		 int flags, unsigned int value),
	TP_ARGS(name, handle, flags, value),
	TP_STRUCT__entry(
		__string(name, name)
		__field(xnhandle_t, handle)
		__field(int, flags)
		__field(unsigned int, value)
	),
	TP_fast_assign(
		__assign_str(name, name);
		__entry->handle = handle;
		__entry->flags = flags;
		__entry->value = value;
	),
614
	TP_printk("sem=%#x(%s) flags=%#x(%s) value=%u",
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
		  __entry->handle,
		  __get_str(name),
		  __entry->flags,
		  cobalt_print_sem_flags(__entry->flags),
		  __entry->value)
);

TRACE_EVENT(cobalt_psem_init_failed,
	TP_PROTO(const char *name, int flags, unsigned int value, int status),
	TP_ARGS(name, flags, value, status),
	TP_STRUCT__entry(
		__string(name, name)
		__field(int, flags)
		__field(unsigned int, value)
		__field(int, status)
	),
	TP_fast_assign(
		__assign_str(name, name);
		__entry->flags = flags;
		__entry->value = value;
		__entry->status = status;
	),
	TP_printk("name=%s flags=%#x(%s) value=%u error=%d",
		  __get_str(name),
		  __entry->flags,
		  cobalt_print_sem_flags(__entry->flags),
		  __entry->value, __entry->status)
);

#define cobalt_print_oflags(__flags)		\
	__print_flags(__flags,  "|", 		\
		      {O_RDONLY, "rdonly"},	\
		      {O_WRONLY, "wronly"},	\
		      {O_RDWR, "rdwr"},		\
		      {O_CREAT, "creat"},	\
		      {O_EXCL, "excl"},		\
		      {O_DIRECT, "direct"},	\
		      {O_NONBLOCK, "nonblock"},	\
		      {O_TRUNC, "trunc"})

TRACE_EVENT(cobalt_psem_open,
	TP_PROTO(const char *name, xnhandle_t handle,
		 int oflags, mode_t mode, unsigned int value),
	TP_ARGS(name, handle, oflags, mode, value),
	TP_STRUCT__entry(
		__string(name, name)
		__field(xnhandle_t, handle)
		__field(int, oflags)
		__field(mode_t, mode)
		__field(unsigned int, value)
	),
	TP_fast_assign(
		__assign_str(name, name);
		__entry->handle = handle;
		__entry->oflags = oflags;
		if (oflags & O_CREAT) {
			__entry->mode = mode;
			__entry->value = value;
		} else {
			__entry->mode = 0;
			__entry->value = 0;
		}
	),
678
	TP_printk("named_sem=%#x=(%s) oflags=%#x(%s) mode=%o value=%u",
679
680
681
682
683
684
685
686
		  __entry->handle, __get_str(name),
		  __entry->oflags, cobalt_print_oflags(__entry->oflags),
		  __entry->mode, __entry->value)
);

TRACE_EVENT(cobalt_psem_open_failed,
	TP_PROTO(const char *name, int oflags, mode_t mode,
		 unsigned int value, int status),
687
	TP_ARGS(name, oflags, mode, value, status),
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
	TP_STRUCT__entry(
		__string(name, name)
		__field(int, oflags)
		__field(mode_t, mode)
		__field(unsigned int, value)
		__field(int, status)
	),
	TP_fast_assign(
		__assign_str(name, name);
		__entry->oflags = oflags;
		__entry->status = status;
		if (oflags & O_CREAT) {
			__entry->mode = mode;
			__entry->value = value;
		} else {
			__entry->mode = 0;
			__entry->value = 0;
		}
	),
	TP_printk("named_sem=%s oflags=%#x(%s) mode=%o value=%u error=%d",
		  __get_str(name),
		  __entry->oflags, cobalt_print_oflags(__entry->oflags),
		  __entry->mode, __entry->value, __entry->status)
);

DEFINE_EVENT(cobalt_posix_sem, cobalt_psem_close,
	TP_PROTO(xnhandle_t handle),
	TP_ARGS(handle)
);

TRACE_EVENT(cobalt_psem_unlink,
	TP_PROTO(const char *name),
	TP_ARGS(name),
	TP_STRUCT__entry(
		__string(name, name)
	),
	TP_fast_assign(
		__assign_str(name, name);
	),
	TP_printk("name=%s", __get_str(name))
);

730
DECLARE_EVENT_CLASS(cobalt_clock_timespec,
731
	TP_PROTO(clockid_t clk_id, const struct timespec64 *val),
732
733
734
735
736
737
738
739
740
741
742
743
	TP_ARGS(clk_id, val),

	TP_STRUCT__entry(
		__field(clockid_t, clk_id)
		__timespec_fields(val)
	),

	TP_fast_assign(
		__entry->clk_id = clk_id;
		__assign_timespec(val, val);
	),

744
	TP_printk("clock_id=%d timeval=(%lld.%09ld)",
745
746
747
748
749
750
		  __entry->clk_id,
		  __timespec_args(val)
	)
);

DEFINE_EVENT(cobalt_clock_timespec, cobalt_clock_getres,
751
	TP_PROTO(clockid_t clk_id, const struct timespec64 *res),
752
753
754
755
	TP_ARGS(clk_id, res)
);

DEFINE_EVENT(cobalt_clock_timespec, cobalt_clock_gettime,
756
	TP_PROTO(clockid_t clk_id, const struct timespec64 *time),
757
758
759
760
	TP_ARGS(clk_id, time)
);

DEFINE_EVENT(cobalt_clock_timespec, cobalt_clock_settime,
761
	TP_PROTO(clockid_t clk_id, const struct timespec64 *time),
762
763
764
	TP_ARGS(clk_id, time)
);

765
TRACE_EVENT(cobalt_clock_adjtime,
766
	TP_PROTO(clockid_t clk_id, struct __kernel_timex *tx),
767
768
769
770
	TP_ARGS(clk_id, tx),

	TP_STRUCT__entry(
		__field(clockid_t, clk_id)
771
		__field(struct __kernel_timex *, tx)
772
773
774
775
776
777
778
779
780
781
782
783
784
	),

	TP_fast_assign(
		__entry->clk_id = clk_id;
		__entry->tx = tx;
	),

	TP_printk("clock_id=%d timex=%p",
		  __entry->clk_id,
		  __entry->tx
	)
);

785
786
787
788
789
#define cobalt_print_timer_flags(__flags)			\
	__print_flags(__flags, "|",				\
		      {TIMER_ABSTIME, "TIMER_ABSTIME"})

TRACE_EVENT(cobalt_clock_nanosleep,
790
	TP_PROTO(clockid_t clk_id, int flags, const struct timespec64 *time),
791
792
793
794
795
796
797
798
799
800
801
802
803
804
	TP_ARGS(clk_id, flags, time),

	TP_STRUCT__entry(
		__field(clockid_t, clk_id)
		__field(int, flags)
		__timespec_fields(time)
	),

	TP_fast_assign(
		__entry->clk_id = clk_id;
		__entry->flags = flags;
		__assign_timespec(time, time);
	),

805
	TP_printk("clock_id=%d flags=%#x(%s) rqt=(%lld.%09ld)",
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
		  __entry->clk_id,
		  __entry->flags, cobalt_print_timer_flags(__entry->flags),
		  __timespec_args(time)
	)
);

DECLARE_EVENT_CLASS(cobalt_clock_ident,
	TP_PROTO(const char *name, clockid_t clk_id),
	TP_ARGS(name, clk_id),
	TP_STRUCT__entry(
		__string(name, name)
		__field(clockid_t, clk_id)
	),
	TP_fast_assign(
		__assign_str(name, name);
		__entry->clk_id = clk_id;
	),
	TP_printk("name=%s, id=%#x", __get_str(name), __entry->clk_id)
);

DEFINE_EVENT(cobalt_clock_ident, cobalt_clock_register,
	TP_PROTO(const char *name, clockid_t clk_id),
	TP_ARGS(name, clk_id)
);

DEFINE_EVENT(cobalt_clock_ident, cobalt_clock_deregister,
	TP_PROTO(const char *name, clockid_t clk_id),
	TP_ARGS(name, clk_id)
);

836
837
838
839
840
841
842
843
#define cobalt_print_clock(__clk_id)					\
	__print_symbolic(__clk_id,					\
			 {CLOCK_MONOTONIC, "CLOCK_MONOTONIC"},		\
			 {CLOCK_MONOTONIC_RAW, "CLOCK_MONOTONIC_RAW"},	\
			 {CLOCK_REALTIME, "CLOCK_REALTIME"})

TRACE_EVENT(cobalt_cond_init,
	TP_PROTO(const struct cobalt_cond_shadow __user *u_cnd,
844
		 const struct cobalt_condattr *attr),
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
	TP_ARGS(u_cnd, attr),
	TP_STRUCT__entry(
		__field(const struct cobalt_cond_shadow __user *, u_cnd)
		__field(clockid_t, clk_id)
		__field(int, pshared)
	),
	TP_fast_assign(
		__entry->u_cnd = u_cnd;
		__entry->clk_id = attr->clock;
		__entry->pshared = attr->pshared;
	),
	TP_printk("cond=%p attr={ .clock=%s, .pshared=%d }",
		  __entry->u_cnd,
		  cobalt_print_clock(__entry->clk_id),
		  __entry->pshared)
);

TRACE_EVENT(cobalt_cond_destroy,
	TP_PROTO(const struct cobalt_cond_shadow __user *u_cnd),
	TP_ARGS(u_cnd),
	TP_STRUCT__entry(
		__field(const struct cobalt_cond_shadow __user *, u_cnd)
	),
	TP_fast_assign(
		__entry->u_cnd = u_cnd;
	),
	TP_printk("cond=%p", __entry->u_cnd)
);

TRACE_EVENT(cobalt_cond_timedwait,
	TP_PROTO(const struct cobalt_cond_shadow __user *u_cnd,
		 const struct cobalt_mutex_shadow __user *u_mx,
877
		 const struct timespec64 *timeout),
878
879
880
881
882
883
884
885
886
887
888
	TP_ARGS(u_cnd, u_mx, timeout),
	TP_STRUCT__entry(
		__field(const struct cobalt_cond_shadow __user *, u_cnd)
		__field(const struct cobalt_mutex_shadow __user *, u_mx)
		__timespec_fields(timeout)
	),
	TP_fast_assign(
		__entry->u_cnd = u_cnd;
		__entry->u_mx = u_mx;
		__assign_timespec(timeout, timeout);
	),
889
	TP_printk("cond=%p, mutex=%p, timeout=(%lld.%09ld)",
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
		  __entry->u_cnd, __entry->u_mx, __timespec_args(timeout))
);

TRACE_EVENT(cobalt_cond_wait,
	TP_PROTO(const struct cobalt_cond_shadow __user *u_cnd,
		 const struct cobalt_mutex_shadow __user *u_mx),
	TP_ARGS(u_cnd, u_mx),
	TP_STRUCT__entry(
		__field(const struct cobalt_cond_shadow __user *, u_cnd)
		__field(const struct cobalt_mutex_shadow __user *, u_mx)
	),
	TP_fast_assign(
		__entry->u_cnd = u_cnd;
		__entry->u_mx = u_mx;
	),
	TP_printk("cond=%p, mutex=%p",
		  __entry->u_cnd, __entry->u_mx)
);

909
TRACE_EVENT(cobalt_mq_open,
910
911
	TP_PROTO(const char *name, int oflags, mode_t mode),
	TP_ARGS(name, oflags, mode),
912
913
914
915
916
917
918
919
920
921
922
923
924

	TP_STRUCT__entry(
		__string(name, name)
		__field(int, oflags)
		__field(mode_t, mode)
	),

	TP_fast_assign(
		__assign_str(name, name);
		__entry->oflags = oflags;
		__entry->mode = (oflags & O_CREAT) ? mode : 0;
	),

925
	TP_printk("name=%s oflags=%#x(%s) mode=%o",
926
927
		  __get_str(name),
		  __entry->oflags, cobalt_print_oflags(__entry->oflags),
928
		  __entry->mode)
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
);

TRACE_EVENT(cobalt_mq_notify,
	TP_PROTO(mqd_t mqd, const struct sigevent *sev),
	TP_ARGS(mqd, sev),

	TP_STRUCT__entry(
		__field(mqd_t, mqd)
		__field(int, signo)
	),

	TP_fast_assign(
		__entry->mqd = mqd;
		__entry->signo = sev && sev->sigev_notify != SIGEV_NONE ?
			sev->sigev_signo : 0;
	),

	TP_printk("mqd=%d signo=%d",
		  __entry->mqd, __entry->signo)
);

TRACE_EVENT(cobalt_mq_close,
	TP_PROTO(mqd_t mqd),
	TP_ARGS(mqd),

	TP_STRUCT__entry(
		__field(mqd_t, mqd)
	),

	TP_fast_assign(
		__entry->mqd = mqd;
	),

	TP_printk("mqd=%d", __entry->mqd)
);

TRACE_EVENT(cobalt_mq_unlink,
	TP_PROTO(const char *name),
	TP_ARGS(name),

	TP_STRUCT__entry(
		__string(name, name)
	),

	TP_fast_assign(
		__assign_str(name, name);
	),

	TP_printk("name=%s", __get_str(name))
);

TRACE_EVENT(cobalt_mq_send,
	TP_PROTO(mqd_t mqd, const void __user *u_buf, size_t len,
		 unsigned int prio),
	TP_ARGS(mqd, u_buf, len, prio),
	TP_STRUCT__entry(
		__field(mqd_t, mqd)
		__field(const void __user *, u_buf)
		__field(size_t, len)
		__field(unsigned int, prio)
	),
	TP_fast_assign(
		__entry->mqd = mqd;
		__entry->u_buf = u_buf;
		__entry->len = len;
		__entry->prio = prio;
	),
996
	TP_printk("mqd=%d buf=%p len=%zu prio=%u",
997
998
999
1000
1001
1002
		  __entry->mqd, __entry->u_buf, __entry->len,
		  __entry->prio)
);

TRACE_EVENT(cobalt_mq_timedreceive,
	TP_PROTO(mqd_t mqd, const void __user *u_buf, size_t len,
1003
		 const struct timespec64 *timeout),
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
	TP_ARGS(mqd, u_buf, len, timeout),
	TP_STRUCT__entry(
		__field(mqd_t, mqd)
		__field(const void __user *, u_buf)
		__field(size_t, len)
		__timespec_fields(timeout)
	),
	TP_fast_assign(
		__entry->mqd = mqd;
		__entry->u_buf = u_buf;
		__entry->len = len;
		__assign_timespec(timeout, timeout);
	),
1017
	TP_printk("mqd=%d buf=%p len=%zu timeout=(%lld.%09ld)",
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
		  __entry->mqd, __entry->u_buf, __entry->len,
		  __timespec_args(timeout))
);

TRACE_EVENT(cobalt_mq_receive,
	TP_PROTO(mqd_t mqd, const void __user *u_buf, size_t len),
	TP_ARGS(mqd, u_buf, len),
	TP_STRUCT__entry(
		__field(mqd_t, mqd)
		__field(const void __user *, u_buf)
		__field(size_t, len)
	),
	TP_fast_assign(
		__entry->mqd = mqd;
		__entry->u_buf = u_buf;
		__entry->len = len;
	),
1035
	TP_printk("mqd=%d buf=%p len=%zu",
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
		  __entry->mqd, __entry->u_buf, __entry->len)
);

DECLARE_EVENT_CLASS(cobalt_posix_mqattr,
	TP_PROTO(mqd_t mqd, const struct mq_attr *attr),
	TP_ARGS(mqd, attr),
	TP_STRUCT__entry(
		__field(mqd_t, mqd)
		__field(long, flags)
		__field(long, curmsgs)
		__field(long, msgsize)
		__field(long, maxmsg)
	),
	TP_fast_assign(
		__entry->mqd = mqd;
		__entry->flags = attr->mq_flags;
		__entry->curmsgs = attr->mq_curmsgs;
		__entry->msgsize = attr->mq_msgsize;
		__entry->maxmsg = attr->mq_maxmsg;
	),
	TP_printk("mqd=%d flags=%#lx(%s) curmsgs=%ld msgsize=%ld maxmsg=%ld",
		  __entry->mqd,
		  __entry->flags, cobalt_print_oflags(__entry->flags),
		  __entry->curmsgs,
		  __entry->msgsize,
		  __entry->maxmsg
	)
);

DEFINE_EVENT(cobalt_posix_mqattr, cobalt_mq_getattr,
	TP_PROTO(mqd_t mqd, const struct mq_attr *attr),
	TP_ARGS(mqd, attr)
);

DEFINE_EVENT(cobalt_posix_mqattr, cobalt_mq_setattr,
	TP_PROTO(mqd_t mqd, const struct mq_attr *attr),
	TP_ARGS(mqd, attr)
);

1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
#define cobalt_print_evflags(__flags)			\
	__print_flags(__flags,  "|",			\
		      {COBALT_EVENT_SHARED, "shared"},	\
		      {COBALT_EVENT_PRIO, "prio"})

TRACE_EVENT(cobalt_event_init,
	TP_PROTO(const struct cobalt_event_shadow __user *u_event,
		 unsigned long value, int flags),
	TP_ARGS(u_event, value, flags),
	TP_STRUCT__entry(
		__field(const struct cobalt_event_shadow __user *, u_event)
		__field(unsigned long, value)
		__field(int, flags)
	),
	TP_fast_assign(
		__entry->u_event = u_event;
		__entry->value = value;
		__entry->flags = flags;
	),
	TP_printk("event=%p value=%lu flags=%#x(%s)",
		  __entry->u_event, __entry->value,
		  __entry->flags, cobalt_print_evflags(__entry->flags))
);

#define cobalt_print_evmode(__mode)			\
	__print_symbolic(__mode,			\
			 {COBALT_EVENT_ANY, "any"},	\
			 {COBALT_EVENT_ALL, "all"})

TRACE_EVENT(cobalt_event_timedwait,
	TP_PROTO(const struct cobalt_event_shadow __user *u_event,
		 unsigned long bits, int mode,
1107
		 const struct timespec64 *timeout),
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
	TP_ARGS(u_event, bits, mode, timeout),
	TP_STRUCT__entry(
		__field(const struct cobalt_event_shadow __user *, u_event)
		__field(unsigned long, bits)
		__field(int, mode)
		__timespec_fields(timeout)
	),
	TP_fast_assign(
		__entry->u_event = u_event;
		__entry->bits = bits;
		__entry->mode = mode;
		__assign_timespec(timeout, timeout);
	),
1121
	TP_printk("event=%p bits=%#lx mode=%#x(%s) timeout=(%lld.%09ld)",
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
		  __entry->u_event, __entry->bits, __entry->mode,
		  cobalt_print_evmode(__entry->mode),
		  __timespec_args(timeout))
);

TRACE_EVENT(cobalt_event_wait,
	TP_PROTO(const struct cobalt_event_shadow __user *u_event,
		 unsigned long bits, int mode),
	TP_ARGS(u_event, bits, mode),
	TP_STRUCT__entry(
		__field(const struct cobalt_event_shadow __user *, u_event)
		__field(unsigned long, bits)
		__field(int, mode)
	),
	TP_fast_assign(
		__entry->u_event = u_event;
		__entry->bits = bits;
		__entry->mode = mode;
	),
	TP_printk("event=%p bits=%#lx mode=%#x(%s)",
		  __entry->u_event, __entry->bits, __entry->mode,
		  cobalt_print_evmode(__entry->mode))
);

DECLARE_EVENT_CLASS(cobalt_event_ident,
	TP_PROTO(const struct cobalt_event_shadow __user *u_event),
	TP_ARGS(u_event),
	TP_STRUCT__entry(
		__field(const struct cobalt_event_shadow __user *, u_event)
	),
	TP_fast_assign(
		__entry->u_event = u_event;
	),
	TP_printk("event=%p", __entry->u_event)
);

DEFINE_EVENT(cobalt_event_ident, cobalt_event_destroy,
	TP_PROTO(const struct cobalt_event_shadow __user *u_event),
	TP_ARGS(u_event)
);

DEFINE_EVENT(cobalt_event_ident, cobalt_event_sync,
	TP_PROTO(const struct cobalt_event_shadow __user *u_event),
	TP_ARGS(u_event)
);

DEFINE_EVENT(cobalt_event_ident, cobalt_event_inquire,
	TP_PROTO(const struct cobalt_event_shadow __user *u_event),
	TP_ARGS(u_event)
);

1173
1174
1175
#endif /* _TRACE_COBALT_POSIX_H */

/* This part must be outside protection */
1176
1177
1178
#undef TRACE_INCLUDE_PATH
#undef TRACE_INCLUDE_FILE
#define TRACE_INCLUDE_FILE cobalt-posix
1179
#include <trace/define_trace.h>