3d57eb5b |
1 | /***************************************************************************** |
38f24d5c |
2 | * ltt-usertrace.h |
3d57eb5b |
3 | * |
38f24d5c |
4 | * LTT userspace tracing header |
3d57eb5b |
5 | * |
6 | * Mathieu Desnoyers, March 2006 |
7 | */ |
8 | |
38f24d5c |
9 | #ifndef _LTT_USERTRACE_H |
10 | #define _LTT_USERTRACE_H |
3d57eb5b |
11 | |
12 | #include <errno.h> |
13 | #include <syscall.h> |
14 | #include <linux/unistd.h> |
3d57eb5b |
15 | #include <string.h> |
16 | #include <sys/types.h> |
17 | #include <stdint.h> |
d86395c3 |
18 | #ifdef powerpc |
19 | #define __KERNEL__ /* Ugly hack : atomic.h is broken */ |
20 | #endif |
21 | #include <asm/atomic.h> |
22 | #include "ltt/ltt-usertrace-ppc.h" |
23 | #ifdef powerpc |
24 | #undef __KERNEL__ /* Ugly hack : atomic.h is broken */ |
25 | #endif |
3d57eb5b |
26 | |
27 | #ifndef min |
28 | #define min(a,b) ((a)<(b)?(a):(b)) |
29 | #endif |
30 | |
d86395c3 |
31 | #ifdef i386 |
7f23953b |
32 | #define __NR_ltt_trace_generic 311 |
33 | #define __NR_ltt_register_generic 312 |
3d57eb5b |
34 | #undef NR_syscalls |
7f23953b |
35 | #define NR_syscalls 313 |
d86395c3 |
36 | #endif |
37 | |
38 | #ifdef powerpc |
39 | #define __NR_ltt_trace_generic 283 |
40 | #define __NR_ltt_register_generic 284 |
41 | #undef NR_syscalls |
42 | #define NR_syscalls 285 |
43 | #endif |
3d57eb5b |
44 | |
45 | //FIXME : setup for ARM |
46 | //FIXME : setup for MIPS |
47 | |
48 | #ifndef _LIBC |
49 | // Put in bits/syscall.h |
50 | #define SYS_ltt_trace_generic __NR_ltt_trace_generic |
51 | #define SYS_ltt_register_generic __NR_ltt_register_generic |
52 | #endif |
53 | |
54 | #define FACNAME_LEN 32 |
55 | |
972a52cf |
56 | /* LTT userspace tracing is non blocking by default when buffers are full */ |
57 | #ifndef LTT_BLOCKING |
58 | #define LTT_BLOCKING 0 |
59 | #endif //LTT_BLOCKING |
60 | |
3d57eb5b |
61 | typedef unsigned int ltt_facility_t; |
62 | |
63 | struct user_facility_info { |
64 | char name[FACNAME_LEN]; |
65 | unsigned int num_events; |
66 | size_t alignment; |
67 | uint32_t checksum; |
68 | size_t int_size; |
69 | size_t long_size; |
70 | size_t pointer_size; |
71 | size_t size_t_size; |
72 | }; |
73 | |
e90c7b86 |
74 | static inline __attribute__((no_instrument_function)) |
75 | _syscall5(int, ltt_trace_generic, unsigned int, facility_id, |
76 | unsigned int, event_id, void *, data, size_t, data_size, int, blocking) |
77 | static inline __attribute__((no_instrument_function)) |
78 | _syscall2(int, ltt_register_generic, unsigned int *, facility_id, |
79 | const struct user_facility_info *, info) |
3d57eb5b |
80 | |
81 | #ifndef LTT_PACK |
82 | /* Calculate the offset needed to align the type */ |
e90c7b86 |
83 | static inline unsigned int __attribute__((no_instrument_function)) |
84 | ltt_align(size_t align_drift, |
85 | size_t size_of_type) |
3d57eb5b |
86 | { |
87 | size_t alignment = min(sizeof(void*), size_of_type); |
88 | |
89 | return ((alignment - align_drift) & (alignment-1)); |
90 | } |
8a9103df |
91 | #define LTT_ALIGN |
3d57eb5b |
92 | #else |
e90c7b86 |
93 | static inline unsigned int __attribute__((no_instrument_function)) |
94 | ltt_align(size_t align_drift, |
95 | size_t size_of_type) |
3d57eb5b |
96 | { |
97 | return 0; |
98 | } |
8a9103df |
99 | #define LTT_ALIGN __attribute__((packed)) |
3d57eb5b |
100 | #endif //LTT_PACK |
101 | |
976db1b3 |
102 | #ifdef LTT_TRACE_FAST |
103 | #include <ltt/ltt-usertrace-fast.h> |
104 | #endif //LTT_TRACE_FAST |
105 | |
38f24d5c |
106 | #endif //_LTT_USERTRACE_H |
3d57eb5b |
107 | |
108 | |