convert from svn repository: remove tags directory
[lttv.git] / trunk / markers-userspace / marker.h
CommitLineData
99c5a086 1#ifndef _LINUX_MARKER_H
2#define _LINUX_MARKER_H
3
4/*
5 * Code markup for dynamic and static tracing.
6 *
7 * See Documentation/marker.txt.
8 *
9 * (C) Copyright 2006 Mathieu Desnoyers <mathieu.desnoyers@polymtl.ca>
10 *
11 * This file is released under the GPLv2.
12 * See the file COPYING for more details.
13 */
14
15//#include <linux/immediate.h>
16//#include <linux/types.h>
17
18#include "kernel-api.h"
19#include <stdint.h>
20#include <stdarg.h>
21
22struct module;
23struct marker;
24
25/**
26 * marker_probe_func - Type of a marker probe function
27 * @probe_private: probe private data
28 * @call_private: call site private data
29 * @fmt: format string
30 * @args: variable argument list pointer. Use a pointer to overcome C's
31 * inability to pass this around as a pointer in a portable manner in
32 * the callee otherwise.
33 *
34 * Type of marker probe functions. They receive the mdata and need to parse the
35 * format string to recover the variable argument list.
36 */
37typedef void marker_probe_func(void *probe_private, void *call_private,
38 const char *fmt, va_list *args);
39
40struct marker_probe_closure {
41 marker_probe_func *func; /* Callback */
42 void *probe_private; /* Private probe data */
43};
44
45struct marker {
46 const char *name; /* Marker name */
47 const char *format; /* Marker format string, describing the
48 * variable argument list.
49 */
50 DEFINE_IMV(char, state);/* Immediate value state. */
51 char ptype; /* probe type : 0 : single, 1 : multi */
52 void (*call)(const struct marker *mdata, /* Probe wrapper */
53 void *call_private, const char *fmt, ...);
54 struct marker_probe_closure single;
55 struct marker_probe_closure *multi;
56} __attribute__((aligned(8)));
57
58#ifdef CONFIG_MARKERS
59
60/*
61 * Generic marker flavor always available.
62 * Note : the empty asm volatile with read constraint is used here instead of a
63 * "used" attribute to fix a gcc 4.1.x bug.
64 * Make sure the alignment of the structure in the __markers section will
65 * not add unwanted padding between the beginning of the section and the
66 * structure. Force alignment to the same alignment as the section start.
67 */
68#define __trace_mark(generic, name, call_private, format, args...) \
69 do { \
70 static const char __mstrtab_##name[] \
71 __attribute__((section("__markers_strings"))) \
72 = #name "\0" format; \
73 static struct marker __mark_##name \
74 __attribute__((section("__markers"), aligned(8))) = \
75 { __mstrtab_##name, &__mstrtab_##name[sizeof(#name)], \
76 0, 0, marker_probe_cb, \
77 { __mark_empty_function, NULL}, NULL }; \
78 __mark_check_format(format, ## args); \
79 if (!generic) { \
80 if (unlikely(imv_read(__mark_##name.state))) \
81 (*__mark_##name.call) \
82 (&__mark_##name, call_private, \
83 format, ## args); \
84 } else { \
85 if (unlikely(_imv_read(__mark_##name.state))) \
86 (*__mark_##name.call) \
87 (&__mark_##name, call_private, \
88 format, ## args); \
89 } \
90 } while (0)
91
92extern void marker_update_probe_range(struct marker *begin,
93 struct marker *end);
94#else /* !CONFIG_MARKERS */
95#define __trace_mark(generic, name, call_private, format, args...) \
96 __mark_check_format(format, ## args)
97static inline void marker_update_probe_range(struct marker *begin,
98 struct marker *end)
99{ }
100#endif /* CONFIG_MARKERS */
101
102/**
103 * trace_mark - Marker using code patching
104 * @name: marker name, not quoted.
105 * @format: format string
106 * @args...: variable argument list
107 *
108 * Places a marker using optimized code patching technique (imv_read())
109 * to be enabled.
110 */
111#define trace_mark(name, format, args...) \
112 __trace_mark(0, name, NULL, format, ## args)
113
114/**
115 * _trace_mark - Marker using variable read
116 * @name: marker name, not quoted.
117 * @format: format string
118 * @args...: variable argument list
119 *
120 * Places a marker using a standard memory read (_imv_read()) to be
121 * enabled. Should be used for markers in __init and __exit functions and in
122 * lockdep code.
123 */
124#define _trace_mark(name, format, args...) \
125 __trace_mark(1, name, NULL, format, ## args)
126
127/**
128 * MARK_NOARGS - Format string for a marker with no argument.
129 */
130#define MARK_NOARGS " "
131
132/* To be used for string format validity checking with gcc */
133static inline void __attribute__((format (printf, 1, 2)))
134__mark_check_format(const char *fmt, ...)
135{
136}
137
138extern marker_probe_func __mark_empty_function;
139
140extern void marker_probe_cb(const struct marker *mdata,
141 void *call_private, const char *fmt, ...);
142extern void marker_probe_cb_noarg(const struct marker *mdata,
143 void *call_private, const char *fmt, ...);
144
145/*
146 * Connect a probe to a marker.
147 * private data pointer must be a valid allocated memory address, or NULL.
148 */
149extern int marker_probe_register(const char *name, const char *format,
150 marker_probe_func *probe, void *probe_private);
151
152/*
153 * Returns the private data given to marker_probe_register.
154 */
155extern int marker_probe_unregister(const char *name,
156 marker_probe_func *probe, void *probe_private);
157/*
158 * Unregister a marker by providing the registered private data.
159 */
160extern int marker_probe_unregister_private_data(marker_probe_func *probe,
161 void *probe_private);
162
163extern void *marker_get_private_data(const char *name, marker_probe_func *probe,
164 int num);
165
166struct marker_iter {
167 struct module *module;
168 struct marker *marker;
169};
170
171extern void marker_iter_start(struct marker_iter *iter);
172extern void marker_iter_next(struct marker_iter *iter);
173extern void marker_iter_stop(struct marker_iter *iter);
174extern void marker_iter_reset(struct marker_iter *iter);
175extern int marker_get_iter_range(struct marker **marker, struct marker *begin,
176 struct marker *end);
177
178#endif
This page took 0.033484 seconds and 4 git commands to generate.