tracecontext.c: remove extraneous white lines
[lttv.git] / markers-userspace / marker-lib.c
1
2 #include "marker.h"
3 #include <stdio.h>
4 #include <errno.h>
5
6 __attribute__ ((visibility ("protected")))
7 extern struct marker __start___markers[];
8
9 __attribute__ ((visibility ("protected")))
10 extern struct marker __stop___markers[];
11
12 /**
13 * __mark_empty_function - Empty probe callback
14 * @probe_private: probe private data
15 * @call_private: call site private data
16 * @fmt: format string
17 * @...: variable argument list
18 *
19 * Empty callback provided as a probe to the markers. By providing this to a
20 * disabled marker, we make sure the execution flow is always valid even
21 * though the function pointer change and the marker enabling are two distinct
22 * operations that modifies the execution flow of preemptible code.
23 */
24 __attribute__ ((visibility ("protected")))
25 void __mark_empty_function(void *probe_private, void *call_private,
26 const char *fmt, va_list *args)
27 {
28 }
29
30 /*
31 * marker_probe_cb Callback that prepares the variable argument list for probes.
32 * @mdata: pointer of type struct marker
33 * @call_private: caller site private data
34 * @fmt: format string
35 * @...: Variable argument list.
36 *
37 */
38 __attribute__ ((visibility ("protected")))
39 void marker_probe_cb(const struct marker *mdata, void *call_private,
40 const char *fmt, ...)
41 {
42 char buf[PAGE_SIZE];
43 va_list ap;
44
45 va_start(ap, fmt);
46 vsnprintf(buf, PAGE_SIZE-1, fmt, ap);
47 sys_trace(0, 0, buf);
48 va_end(ap);
49 }
50
51 //FIXME : imv_read won't work with optimized immediate values.
52 //will need to issue one sys_marker call for each immediate value.
53 __attribute__ ((visibility ("protected")))
54 void testip(void)
55 {
56 printf("addr : %p\n", __builtin_return_address(0));
57 }
58
59 __attribute__((constructor, visibility ("protected")))
60 void marker_init(void)
61 {
62 struct marker *iter;
63 int ret;
64
65 printf("Marker section : from %p to %p (init)\n",
66 __start___markers, __stop___markers);
67 testip();
68 for (iter = __start___markers; iter < __stop___markers; iter++) {
69 printf("Marker : %s\n", iter->name);
70 ret = sys_marker(iter->name, iter->format,
71 &imv_read(iter->state), 1);
72 if (ret)
73 perror("Error connecting markers");
74 }
75 }
76
77 __attribute__((destructor, visibility ("protected")))
78 void marker_fini(void)
79 {
80 struct marker *iter;
81 int ret;
82
83 printf("Marker section : from %p to %p (fini)\n",
84 __start___markers, __stop___markers);
85 for (iter = __start___markers; iter < __stop___markers; iter++) {
86 printf("Marker : %s\n", iter->name);
87 ret = sys_marker(iter->name, iter->format,
88 &imv_read(iter->state), 0);
89 if (ret)
90 perror("Error disconnecting markers");
91 }
92 }
This page took 0.032801 seconds and 4 git commands to generate.