X-Git-Url: http://git.lttng.org/?a=blobdiff_plain;f=libmarkers%2Fmarker.c;h=e1b62c7f64d908269a399ecf9dfd11ba00894252;hb=f3f6ac655895f40e8c95c1b6dd5156064ea67242;hp=980cf392138c5a1c8107feb7e46c29cfe2d7c667;hpb=9c67dc50afb2eaa1c3966ee73fac3ce55935556c;p=ust.git diff --git a/libmarkers/marker.c b/libmarkers/marker.c index 980cf39..e1b62c7 100644 --- a/libmarkers/marker.c +++ b/libmarkers/marker.c @@ -37,8 +37,8 @@ #include "tracercore.h" #include "tracer.h" -extern struct marker __start___markers[]; -extern struct marker __stop___markers[]; +extern struct marker __start___markers[] __attribute__((visibility("hidden"))); +extern struct marker __stop___markers[] __attribute__((visibility("hidden"))); /* Set to 1 to enable marker debug output */ static const int marker_debug; @@ -678,6 +678,20 @@ void marker_update_probe_range(struct marker *begin, /* * ignore error, continue */ + + /* This is added for UST. We emit a core_marker_id event + * for markers that are already registered to a probe + * upon library load. Otherwise, no core_marker_id will + * be generated for these markers. Is this the right thing + * to do? + */ + trace_mark(metadata, core_marker_id, + "channel %s name %s event_id %hu " + "int #1u%zu long #1u%zu pointer #1u%zu " + "size_t #1u%zu alignment #1u%u", + iter->channel, iter->name, mark_entry->event_id, + sizeof(int), sizeof(long), sizeof(void *), + sizeof(size_t), ltt_get_alignment()); } else { disable_marker(iter); } @@ -705,9 +719,10 @@ void marker_update_probe_range(struct marker *begin, static void marker_update_probes(void) { /* Core kernel markers */ - marker_update_probe_range(__start___markers, __stop___markers); +//ust// marker_update_probe_range(__start___markers, __stop___markers); /* Markers in modules. */ //ust// module_update_markers(); + lib_update_markers(); //ust// tracepoint_probe_update_all(); /* Update immediate values */ core_imv_update(); @@ -802,6 +817,7 @@ int marker_probe_register(const char *channel, const char *name, /* write rcu_pending before calling the RCU callback */ smp_wmb(); call_rcu_sched(&entry->rcu, free_old_closure); + /*synchronize_rcu(); free_old_closure();*/ goto end; error_unregister_channel: @@ -1061,14 +1077,15 @@ static void marker_get_iter(struct marker_iter *iter) int found = 0; /* Core kernel markers */ - if (!iter->module) { + if (!iter->lib) { + /* ust FIXME: how come we cannot disable the following line? we shouldn't need core stuff */ found = marker_get_iter_range(&iter->marker, __start___markers, __stop___markers); if (found) goto end; } /* Markers in modules. */ -//ust// found = module_get_iter_markers(iter); + found = lib_get_iter_markers(iter); end: if (!found) marker_iter_reset(iter); @@ -1099,7 +1116,7 @@ void marker_iter_stop(struct marker_iter *iter) void marker_iter_reset(struct marker_iter *iter) { - iter->module = NULL; + iter->lib = NULL; iter->marker = NULL; } //ust// EXPORT_SYMBOL_GPL(marker_iter_reset); @@ -1412,3 +1429,74 @@ void ltt_dump_marker_state(struct ltt_trace_struct *trace) marker_iter_stop(&iter); } //ust// EXPORT_SYMBOL_GPL(ltt_dump_marker_state); + + +static LIST_HEAD(libs); + +/* + * Returns 0 if current not found. + * Returns 1 if current found. + */ +int lib_get_iter_markers(struct marker_iter *iter) +{ + struct lib *iter_lib; + int found = 0; + +//ust// mutex_lock(&module_mutex); + list_for_each_entry(iter_lib, &libs, list) { + if (iter_lib < iter->lib) + continue; + else if (iter_lib > iter->lib) + iter->marker = NULL; + found = marker_get_iter_range(&iter->marker, + iter_lib->markers_start, + iter_lib->markers_start + iter_lib->markers_count); + if (found) { + iter->lib = iter_lib; + break; + } + } +//ust// mutex_unlock(&module_mutex); + return found; +} + +void lib_update_markers(void) +{ + struct lib *lib; + +//ust// mutex_lock(&module_mutex); + list_for_each_entry(lib, &libs, list) + marker_update_probe_range(lib->markers_start, + lib->markers_start + lib->markers_count); +//ust// mutex_unlock(&module_mutex); +} + +int marker_register_lib(struct marker *markers_start, int markers_count) +{ + struct lib *pl; + + pl = (struct lib *) malloc(sizeof(struct lib)); + + pl->markers_start = markers_start; + pl->markers_count = markers_count; + + list_add(&pl->list, &libs); + + /* FIXME: update just the loaded lib */ + lib_update_markers(); + + printf("just registered a markers section from %p and having %d markers\n", markers_start, markers_count); + + return 0; +} + +static int initialized = 0; + +void __attribute__((constructor)) init_markers(void) +{ + if(!initialized) { + marker_register_lib(__start___markers, (((long)__stop___markers)-((long)__start___markers))/sizeof(struct marker)); + printf("markers_start: %p, markers_stop: %p\n", __start___markers, __stop___markers); + initialized = 1; + } +}