Commit | Line | Data |
---|---|---|
535b0d0a MD |
1 | #ifndef _UST_MARKER_INTERNAL_H |
2 | #define _UST_MARKER_INTERNAL_H | |
3 | ||
4 | /* | |
5 | * Code markup for dynamic and static tracing. (internal header) | |
6 | * | |
7 | * See Documentation/marker.txt. | |
8 | * | |
9 | * (C) Copyright 2006 Mathieu Desnoyers <mathieu.desnoyers@polymtl.ca> | |
10 | * (C) Copyright 2009 Pierre-Marc Fournier <pierre-marc dot fournier at polymtl dot ca> | |
11 | * (C) Copyright 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com> | |
12 | * | |
13 | * This library is free software; you can redistribute it and/or | |
14 | * modify it under the terms of the GNU Lesser General Public | |
15 | * License as published by the Free Software Foundation; | |
16 | * version 2.1 of the License. | |
17 | * | |
18 | * This library is distributed in the hope that it will be useful, | |
19 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
20 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
21 | * Lesser General Public License for more details. | |
22 | * | |
23 | * You should have received a copy of the GNU Lesser General Public | |
24 | * License along with this library; if not, write to the Free Software | |
25 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | |
26 | */ | |
27 | ||
28 | #include <stdarg.h> | |
29 | #include <bits/wordsize.h> | |
30 | #include <urcu-bp.h> | |
31 | #include <urcu/list.h> | |
32 | #include <ust/core.h> | |
33 | #include <ust/kcompat/kcompat.h> | |
34 | #include <ust/marker.h> | |
35 | ||
36 | #define GET_UST_MARKER(name) (__ust_marker_def_##name) | |
37 | ||
38 | #define DEFINE_UST_MARKER(name, format) \ | |
39 | _DEFINE_UST_MARKER(ust, name, NULL, NULL, format) | |
40 | ||
41 | #define DEFINE_UST_MARKER_TP(name, tp_name, tp_cb, format) \ | |
42 | _DEFINE_UST_MARKER(ust, name, #tp_name, tp_cb, format) | |
43 | ||
44 | #define __ust_marker_tp(name, call_private, tp_name, tp_cb, \ | |
45 | format, args...) \ | |
46 | do { \ | |
47 | void __check_tp_type(void) \ | |
48 | { \ | |
49 | register_trace_##tp_name(tp_cb, call_private); \ | |
50 | } \ | |
51 | DEFINE_UST_MARKER_TP(name, #tp_name, tp_cb, format); \ | |
52 | __ust_marker_check_format(format, ## args); \ | |
53 | (*__ust_marker_def_##name.call) \ | |
54 | (&__ust_marker_def_##name, call_private, ## args); \ | |
55 | } while (0) | |
56 | ||
57 | /** | |
58 | * ust_marker_tp - Marker in a tracepoint callback | |
59 | * @name: marker name, not quoted. | |
60 | * @tp_name: tracepoint name, not quoted. | |
61 | * @tp_cb: tracepoint callback. Should have an associated global symbol so it | |
62 | * is not optimized away by the compiler (should not be static). | |
63 | * @format: format string | |
64 | * @args...: variable argument list | |
65 | * | |
66 | * Places a marker in a tracepoint callback. | |
67 | */ | |
68 | #define ust_marker_tp(name, tp_name, tp_cb, format, args...) \ | |
69 | __ust_marker_tp(ust, name, NULL, tp_name, tp_cb, format, ## args) | |
70 | ||
535b0d0a MD |
71 | extern void ust_marker_compact_event_ids(void); |
72 | ||
73 | /* | |
74 | * Connect a probe to a marker. | |
75 | * private data pointer must be a valid allocated memory address, or NULL. | |
76 | */ | |
77 | extern int ust_marker_probe_register(const char *channel, const char *name, | |
78 | const char *format, ust_marker_probe_func *probe, void *probe_private); | |
79 | ||
80 | /* | |
81 | * Returns the private data given to ust_marker_probe_register. | |
82 | */ | |
83 | extern int ust_marker_probe_unregister(const char *channel, const char *name, | |
84 | ust_marker_probe_func *probe, void *probe_private); | |
85 | /* | |
86 | * Unregister a marker by providing the registered private data. | |
87 | */ | |
88 | extern int ust_marker_probe_unregister_private_data(ust_marker_probe_func *probe, | |
89 | void *probe_private); | |
90 | ||
91 | extern void *ust_marker_get_private_data(const char *channel, const char *name, | |
92 | ust_marker_probe_func *probe, int num); | |
93 | ||
94 | /* | |
95 | * ust_marker_synchronize_unregister must be called between the last | |
96 | * marker probe unregistration and the first one of | |
97 | * - the end of library exit function | |
98 | * - the free of any resource used by the probes | |
99 | * to ensure the code and data are valid for any possibly running probes. | |
100 | */ | |
101 | #define ust_marker_synchronize_unregister() synchronize_rcu() | |
102 | ||
103 | struct ust_marker_iter { | |
104 | struct ust_marker_lib *lib; | |
105 | struct ust_marker * const *ust_marker; | |
106 | }; | |
107 | ||
108 | extern void ust_marker_iter_start(struct ust_marker_iter *iter); | |
109 | extern void ust_marker_iter_next(struct ust_marker_iter *iter); | |
110 | extern void ust_marker_iter_stop(struct ust_marker_iter *iter); | |
111 | extern void ust_marker_iter_reset(struct ust_marker_iter *iter); | |
535b0d0a | 112 | |
535b0d0a MD |
113 | extern int is_ust_marker_enabled(const char *channel, const char *name); |
114 | ||
115 | extern void ust_marker_set_new_ust_marker_cb(void (*cb)(struct ust_marker *)); | |
116 | extern void init_ust_marker(void); | |
117 | ||
b27f8e75 MD |
118 | void lock_ust_marker(void); |
119 | void unlock_ust_marker(void); | |
120 | ||
535b0d0a | 121 | #endif /* _UST_MARKER_INTERNAL_H */ |