X-Git-Url: http://git.lttng.org./?a=blobdiff_plain;f=markers-userspace%2Fmarker-lib.c;h=b2165b8b7ac542a86f4da1399a1be0c0a6bda1b1;hb=ae40690b4e49e10908cc6320e1c875b56cb2eb9d;hp=da5bcaa33802bbc2c9ae6acbf5d73f295eb26fa4;hpb=99c5a0863a248fe49e6fb0463e0661673f1c8f67;p=lttv.git diff --git a/markers-userspace/marker-lib.c b/markers-userspace/marker-lib.c index da5bcaa3..b2165b8b 100644 --- a/markers-userspace/marker-lib.c +++ b/markers-userspace/marker-lib.c @@ -1,5 +1,13 @@ #include "marker.h" +#include +#include + +__attribute__ ((visibility ("protected"))) +extern struct marker __start___markers[]; + +__attribute__ ((visibility ("protected"))) +extern struct marker __stop___markers[]; /** * __mark_empty_function - Empty probe callback @@ -13,6 +21,7 @@ * though the function pointer change and the marker enabling are two distinct * operations that modifies the execution flow of preemptible code. */ +__attribute__ ((visibility ("protected"))) void __mark_empty_function(void *probe_private, void *call_private, const char *fmt, va_list *args) { @@ -26,9 +35,58 @@ void __mark_empty_function(void *probe_private, void *call_private, * @...: Variable argument list. * */ +__attribute__ ((visibility ("protected"))) void marker_probe_cb(const struct marker *mdata, void *call_private, const char *fmt, ...) { + char buf[PAGE_SIZE]; + va_list ap; + + va_start(ap, fmt); + vsnprintf(buf, PAGE_SIZE-1, fmt, ap); + sys_trace(0, 0, buf); + va_end(ap); +} + +//FIXME : imv_read won't work with optimized immediate values. +//will need to issue one sys_marker call for each immediate value. +__attribute__ ((visibility ("protected"))) +void testip(void) +{ + printf("addr : %p\n", __builtin_return_address(0)); +} + +__attribute__((constructor, visibility ("protected"))) +void marker_init(void) +{ + struct marker *iter; + int ret; + printf("Marker section : from %p to %p (init)\n", + __start___markers, __stop___markers); + testip(); + for (iter = __start___markers; iter < __stop___markers; iter++) { + printf("Marker : %s\n", iter->name); + ret = sys_marker(iter->name, iter->format, + &imv_read(iter->state), 1); + if (ret) + perror("Error connecting markers"); + } +} + +__attribute__((destructor, visibility ("protected"))) +void marker_fini(void) +{ + struct marker *iter; + int ret; + printf("Marker section : from %p to %p (fini)\n", + __start___markers, __stop___markers); + for (iter = __start___markers; iter < __stop___markers; iter++) { + printf("Marker : %s\n", iter->name); + ret = sys_marker(iter->name, iter->format, + &imv_read(iter->state), 0); + if (ret) + perror("Error disconnecting markers"); + } }