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