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