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