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