99c5a086 |
1 | |
2 | #include "marker.h" |
52204d63 |
3 | #include <stdio.h> |
c604f8bf |
4 | #include <errno.h> |
52204d63 |
5 | |
6 | extern struct marker __start___markers[]; |
7 | 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 | */ |
21 | void __mark_empty_function(void *probe_private, void *call_private, |
22 | const char *fmt, va_list *args) |
23 | { |
24 | } |
25 | |
26 | /* |
27 | * marker_probe_cb Callback that prepares the variable argument list for probes. |
28 | * @mdata: pointer of type struct marker |
29 | * @call_private: caller site private data |
30 | * @fmt: format string |
31 | * @...: Variable argument list. |
32 | * |
33 | */ |
34 | void marker_probe_cb(const struct marker *mdata, void *call_private, |
35 | const char *fmt, ...) |
36 | { |
c604f8bf |
37 | static unsigned int count = 0; |
99c5a086 |
38 | |
c604f8bf |
39 | printf("Test probe function %u\n", count++); |
99c5a086 |
40 | } |
52204d63 |
41 | |
b664a2ae |
42 | //FIXME : imv_read won't work with optimized immediate values. |
43 | //will need to issue one sys_marker call for each immediate value. |
44 | |
52204d63 |
45 | __attribute__((constructor)) void marker_init(void) |
46 | { |
47 | struct marker *iter; |
c604f8bf |
48 | int ret; |
52204d63 |
49 | |
b664a2ae |
50 | printf("Marker section : from %p to %p (init)\n", |
51 | __start___markers, __stop___markers); |
52 | for (iter = __start___markers; iter < __stop___markers; iter++) { |
53 | printf("Marker : %s\n", iter->name); |
54 | ret = sys_marker(iter->name, iter->format, |
55 | &imv_read(iter->state), 1); |
56 | if (ret) |
57 | perror("Error connecting markers"); |
58 | } |
59 | } |
60 | |
61 | __attribute__((destructor)) void marker_fini(void) |
62 | { |
63 | struct marker *iter; |
64 | int ret; |
65 | |
66 | printf("Marker section : from %p to %p (fini)\n", |
52204d63 |
67 | __start___markers, __stop___markers); |
68 | for (iter = __start___markers; iter < __stop___markers; iter++) { |
69 | printf("Marker : %s\n", iter->name); |
b664a2ae |
70 | ret = sys_marker(iter->name, iter->format, |
71 | &imv_read(iter->state), 0); |
72 | if (ret) |
73 | perror("Error disconnecting markers"); |
52204d63 |
74 | } |
75 | } |