sleep(1);
for(i=0; i<50; i++) {
- trace_mark(foo, bar, "str %s", "FOOBAZ");
- trace_mark(foo, bar2, "number1 %d number2 %d", 53, 9800);
+ trace_mark(ust, bar, "str %s", "FOOBAZ");
+ trace_mark(ust, bar2, "number1 %d number2 %d", 53, 9800);
usleep(100000);
}
all: libmallocwrap.so
libmallocwrap.so: mallocwrap.c
- gcc -shared -fPIC -g -I../share -I../libmarkers -I../libtracing -I../libtracectl -L../libmarkers -L../libtracing -L../libtracectl -ldl -lmarkers -o libmallocwrap.so mallocwrap.c
+ gcc -shared -fPIC -g -I../share -I../libmarkers -I../libtracing -I../libtracectl -L../libmarkers -L../libtracing -L../libtracectl $(CFLAGS) -ldl -lmarkers -o libmallocwrap.so mallocwrap.c
.PHONY: libmallocwrap.so
//ust// mutex_unlock(&module_mutex);
}
+static void (*new_marker_cb)(struct marker *) = NULL;
+
+void marker_set_new_marker_cb(void (*cb)(struct marker *))
+{
+ new_marker_cb = cb;
+}
+
+static void new_markers(struct marker *start, struct marker *end)
+{
+ if(new_marker_cb) {
+ struct marker *m;
+ for(m=start; m < end; m++) {
+ new_marker_cb(m);
+ }
+ }
+}
+
int marker_register_lib(struct marker *markers_start, int markers_count)
{
struct lib *pl;
list_add(&pl->list, &libs);
+ new_markers(markers_start, markers_start + markers_count);
+
/* FIXME: update just the loaded lib */
lib_update_markers();
}
#endif
+
+void marker_set_new_marker_cb(void (*cb)(struct marker *));
return 0;
}
-static void __attribute__((constructor)) init()
+static void auto_probe_connect(struct marker *m)
{
int result;
+ result = ltt_marker_connect(m->channel, m->name, "default");
+ if(result)
+ ERR("ltt_marker_connect");
+
+ DBG("just auto connected marker %s %s to probe default", m->channel, m->name);
+}
+
+static void __attribute__((constructor(101))) init0()
+{
+ DBG("UST_AUTOPROBE constructor");
+ if(getenv("UST_AUTOPROBE")) {
+ marker_set_new_marker_cb(auto_probe_connect);
+ }
+}
+
+static void __attribute__((constructor(1000))) init()
+{
+ int result;
+
+ DBG("UST_TRACE constructor");
+
mypid = getpid();
if(getenv("UST_TRACE")) {
/* Ensure markers are initialized */
init_markers();
- result = ltt_marker_connect("foo", "bar", "default");
- if(result)
- ERR("ltt_marker_connect");
-
- result = ltt_marker_connect("foo", "bar2", "default");
- if(result)
- ERR("ltt_marker_connect");
+ /* In case. */
+ ltt_channels_register("ust");
result = ltt_trace_setup(trace_name);
if(result < 0) {