update
[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{
c604f8bf 42 static unsigned int count = 0;
99c5a086 43
c604f8bf 44 printf("Test probe function %u\n", count++);
99c5a086 45}
52204d63 46
b664a2ae 47//FIXME : imv_read won't work with optimized immediate values.
48//will need to issue one sys_marker call for each immediate value.
20fd073e 49__attribute__ ((visibility ("protected")))
50void testip(void)
51{
52 printf("addr : %p\n", __builtin_return_address(0));
53}
b664a2ae 54
a010d844 55__attribute__((constructor, visibility ("protected")))
56void marker_init(void)
52204d63 57{
58 struct marker *iter;
c604f8bf 59 int ret;
52204d63 60
b664a2ae 61 printf("Marker section : from %p to %p (init)\n",
62 __start___markers, __stop___markers);
20fd073e 63 testip();
b664a2ae 64 for (iter = __start___markers; iter < __stop___markers; iter++) {
65 printf("Marker : %s\n", iter->name);
66 ret = sys_marker(iter->name, iter->format,
67 &imv_read(iter->state), 1);
68 if (ret)
69 perror("Error connecting markers");
70 }
71}
72
a010d844 73__attribute__((destructor, visibility ("protected")))
74void marker_fini(void)
b664a2ae 75{
76 struct marker *iter;
77 int ret;
78
79 printf("Marker section : from %p to %p (fini)\n",
52204d63 80 __start___markers, __stop___markers);
81 for (iter = __start___markers; iter < __stop___markers; iter++) {
82 printf("Marker : %s\n", iter->name);
b664a2ae 83 ret = sys_marker(iter->name, iter->format,
84 &imv_read(iter->state), 0);
85 if (ret)
86 perror("Error disconnecting markers");
52204d63 87 }
88}
This page took 0.027157 seconds and 4 git commands to generate.