update compat
[lttv.git] / markers-userspace / marker-lib.c
CommitLineData
99c5a086 1
2#include "marker.h"
52204d63 3#include <stdio.h>
c604f8bf 4#include <errno.h>
52204d63 5
a010d844 6__attribute__ ((visibility ("protected")))
7extern struct marker __start___markers[];
8
9__attribute__ ((visibility ("protected")))
10extern struct marker __stop___markers[];
99c5a086 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 */
20fd073e 24__attribute__ ((visibility ("protected")))
99c5a086 25void __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 */
20fd073e 38__attribute__ ((visibility ("protected")))
99c5a086 39void marker_probe_cb(const struct marker *mdata, void *call_private,
40 const char *fmt, ...)
41{
3c23bb5b 42 char buf[PAGE_SIZE];
43 va_list ap;
99c5a086 44
3c23bb5b 45 va_start(ap, fmt);
46 vsnprintf(buf, PAGE_SIZE-1, fmt, ap);
47 sys_trace(0, 0, buf);
48 va_end(ap);
99c5a086 49}
52204d63 50
b664a2ae 51//FIXME : imv_read won't work with optimized immediate values.
52//will need to issue one sys_marker call for each immediate value.
20fd073e 53__attribute__ ((visibility ("protected")))
54void testip(void)
55{
56 printf("addr : %p\n", __builtin_return_address(0));
57}
b664a2ae 58
a010d844 59__attribute__((constructor, visibility ("protected")))
60void marker_init(void)
52204d63 61{
62 struct marker *iter;
c604f8bf 63 int ret;
52204d63 64
b664a2ae 65 printf("Marker section : from %p to %p (init)\n",
66 __start___markers, __stop___markers);
20fd073e 67 testip();
b664a2ae 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
a010d844 77__attribute__((destructor, visibility ("protected")))
78void marker_fini(void)
b664a2ae 79{
80 struct marker *iter;
81 int ret;
82
83 printf("Marker section : from %p to %p (fini)\n",
52204d63 84 __start___markers, __stop___markers);
85 for (iter = __start___markers; iter < __stop___markers; iter++) {
86 printf("Marker : %s\n", iter->name);
b664a2ae 87 ret = sys_marker(iter->name, iter->format,
88 &imv_read(iter->state), 0);
89 if (ret)
90 perror("Error disconnecting markers");
52204d63 91 }
92}
This page took 0.027317 seconds and 4 git commands to generate.