X-Git-Url: http://git.lttng.org./?a=blobdiff_plain;f=libust%2Fmarker.c;h=788d87691beb0ddc6fd4f51efb2df7cad151545c;hb=f08ebbe29cc9f6fa1c108907be5d9d92d297067e;hp=664f59c61c6495229ba4661206e267b5e5a7635c;hpb=eb5d20c68aaf73661ffc02ba8fea3683c0358702;p=ust.git diff --git a/libust/marker.c b/libust/marker.c index 664f59c..788d876 100644 --- a/libust/marker.c +++ b/libust/marker.c @@ -35,8 +35,8 @@ __thread long ust_reg_stack[500]; volatile __thread long *ust_reg_stack_ptr = (long *) 0; -extern struct marker * const __start___markers[] __attribute__((visibility("hidden"))); -extern struct marker * const __stop___markers[] __attribute__((visibility("hidden"))); +extern struct marker * const __start___markers_ptrs[] __attribute__((visibility("hidden"))); +extern struct marker * const __stop___markers_ptrs[] __attribute__((visibility("hidden"))); /* Set to 1 to enable marker debug output */ static const int marker_debug; @@ -685,6 +685,8 @@ void marker_update_probe_range(struct marker * const *begin, pthread_mutex_lock(&markers_mutex); for (iter = begin; iter < end; iter++) { + if (!*iter) + continue; /* skip dummy */ mark_entry = get_marker((*iter)->channel, (*iter)->name); if (mark_entry) { set_marker(mark_entry, *iter, !!mark_entry->refcount); @@ -743,10 +745,6 @@ static void lib_update_markers(void) */ static void marker_update_probes(void) { - /* Core kernel markers */ -//ust// marker_update_probe_range(__start___markers, __stop___markers); - /* Markers in modules. */ -//ust// module_update_markers(); lib_update_markers(); tracepoint_probe_update_all(); /* Update immediate values */ @@ -1118,12 +1116,14 @@ int marker_get_iter_range(struct marker * const **marker, struct marker * const *begin, struct marker * const *end) { - if (!*marker && begin != end) { + if (!*marker && begin != end) *marker = begin; - return 1; + while (*marker >= begin && *marker < end) { + if (!**marker) + (*marker)++; /* skip dummy */ + else + return 1; } - if (*marker >= begin && *marker < end) - return 1; return 0; } //ust// EXPORT_SYMBOL_GPL(marker_get_iter_range); @@ -1132,17 +1132,7 @@ static void marker_get_iter(struct marker_iter *iter) { int found = 0; - /* Core kernel markers */ - 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. */ found = lib_get_iter_markers(iter); -end: if (!found) marker_iter_reset(iter); } @@ -1356,15 +1346,17 @@ static void new_markers(struct marker * const *start, struct marker * const *end { if (new_marker_cb) { struct marker * const *m; - for(m=start; m < end; m++) { - new_marker_cb(*m); + + for(m = start; m < end; m++) { + if (*m) + new_marker_cb(*m); } } } int marker_register_lib(struct marker * const *markers_start, int markers_count) { - struct lib *pl; + struct lib *pl, *iter; pl = (struct lib *) zmalloc(sizeof(struct lib)); @@ -1373,7 +1365,21 @@ int marker_register_lib(struct marker * const *markers_start, int markers_count) /* FIXME: maybe protect this with its own mutex? */ lock_markers(); + + /* + * We sort the libs by struct lib pointer address. + */ + cds_list_for_each_entry_reverse(iter, &libs, list) { + BUG_ON(iter == pl); /* Should never be in the list twice */ + if (iter < pl) { + /* We belong to the location right after iter. */ + cds_list_add(&pl->list, &iter->list); + goto lib_added; + } + } + /* We should be added at the head of the list */ cds_list_add(&pl->list, &libs); +lib_added: unlock_markers(); new_markers(markers_start, markers_start + markers_count); @@ -1381,7 +1387,8 @@ int marker_register_lib(struct marker * const *markers_start, int markers_count) /* FIXME: update just the loaded lib */ lib_update_markers(); - DBG("just registered a markers section from %p and having %d markers", markers_start, markers_count); + /* markers_count - 1: skip dummy */ + DBG("just registered a markers section from %p and having %d markers", markers_start, markers_count - 1); return 0; } @@ -1415,15 +1422,15 @@ static int initialized = 0; void __attribute__((constructor)) init_markers(void) { - if(!initialized) { - marker_register_lib(__start___markers, - (((long)__stop___markers) - ((long)__start___markers)) - / sizeof(*__start___markers)); + if (!initialized) { + marker_register_lib(__start___markers_ptrs, + __stop___markers_ptrs + - __start___markers_ptrs); initialized = 1; } } -void __attribute__((constructor)) destroy_markers(void) +void __attribute__((destructor)) destroy_markers(void) { - marker_unregister_lib(__start___markers); + marker_unregister_lib(__start___markers_ptrs); }