Markers: sync from LTTng 0.249 marker code
[ust.git] / include / ust / marker-internal.h
CommitLineData
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
71extern void lock_ust_marker(void);
72extern void unlock_ust_marker(void);
73
74extern void ust_marker_compact_event_ids(void);
75
76/*
77 * Connect a probe to a marker.
78 * private data pointer must be a valid allocated memory address, or NULL.
79 */
80extern int ust_marker_probe_register(const char *channel, const char *name,
81 const char *format, ust_marker_probe_func *probe, void *probe_private);
82
83/*
84 * Returns the private data given to ust_marker_probe_register.
85 */
86extern int ust_marker_probe_unregister(const char *channel, const char *name,
87 ust_marker_probe_func *probe, void *probe_private);
88/*
89 * Unregister a marker by providing the registered private data.
90 */
91extern int ust_marker_probe_unregister_private_data(ust_marker_probe_func *probe,
92 void *probe_private);
93
94extern void *ust_marker_get_private_data(const char *channel, const char *name,
95 ust_marker_probe_func *probe, int num);
96
97/*
98 * ust_marker_synchronize_unregister must be called between the last
99 * marker probe unregistration and the first one of
100 * - the end of library exit function
101 * - the free of any resource used by the probes
102 * to ensure the code and data are valid for any possibly running probes.
103 */
104#define ust_marker_synchronize_unregister() synchronize_rcu()
105
106struct ust_marker_iter {
107 struct ust_marker_lib *lib;
108 struct ust_marker * const *ust_marker;
109};
110
111extern void ust_marker_iter_start(struct ust_marker_iter *iter);
112extern void ust_marker_iter_next(struct ust_marker_iter *iter);
113extern void ust_marker_iter_stop(struct ust_marker_iter *iter);
114extern void ust_marker_iter_reset(struct ust_marker_iter *iter);
535b0d0a 115
535b0d0a
MD
116extern int is_ust_marker_enabled(const char *channel, const char *name);
117
118extern void ust_marker_set_new_ust_marker_cb(void (*cb)(struct ust_marker *));
119extern void init_ust_marker(void);
120
121#endif /* _UST_MARKER_INTERNAL_H */
This page took 0.026054 seconds and 4 git commands to generate.