ust: collect many channels and start work on pipe listener
[ust.git] / libmarkers / marker.c
index f9f82fb0f90dce294113e5dea3e0f1ee6d0cdb55..d31f2cfa97ebaaef8ca4c7ae4ef5ef0c78c8bc2c 100644 (file)
@@ -35,6 +35,7 @@
 #include "usterr.h"
 #include "channels.h"
 #include "tracercore.h"
+#include "tracer.h"
 
 extern struct marker __start___markers[];
 extern struct marker __stop___markers[];
@@ -1031,7 +1032,7 @@ void *marker_get_private_data(const char *channel, const char *name,
 //ust//        }
 //ust// }
 
-#ifdef CONFIG_MODULES
+//ust//#ifdef CONFIG_MODULES
 
 /**
  * marker_get_iter_range - Get a next marker iterator given a range.
@@ -1060,14 +1061,14 @@ static void marker_get_iter(struct marker_iter *iter)
        int found = 0;
 
        /* Core kernel markers */
-       if (!iter->module) {
+       if (!iter->lib) {
                found = marker_get_iter_range(&iter->marker,
                                __start___markers, __stop___markers);
                if (found)
                        goto end;
        }
        /* Markers in modules. */
-       found = module_get_iter_markers(iter);
+       found = lib_get_iter_markers(iter);
 end:
        if (!found)
                marker_iter_reset(iter);
@@ -1098,7 +1099,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);
@@ -1338,7 +1339,7 @@ int is_marker_enabled(const char *channel, const char *name)
 
        return entry && !!entry->refcount;
 }
-#endif
+//ust// #endif
 
 int marker_module_notify(struct notifier_block *self,
                         unsigned long val, void *data)
@@ -1372,42 +1373,88 @@ struct notifier_block marker_module_nb = {
 
 #endif /* CONFIG_MODULES */
 
-//ust// void ltt_dump_marker_state(struct ltt_trace_struct *trace)
-//ust// {
-//ust//        struct marker_iter iter;
-//ust//        struct ltt_probe_private_data call_data;
-//ust//        const char *channel;
-//ust// 
-//ust//        call_data.trace = trace;
-//ust//        call_data.serializer = NULL;
-//ust// 
-//ust//        marker_iter_reset(&iter);
-//ust//        marker_iter_start(&iter);
-//ust//        for (; iter.marker != NULL; marker_iter_next(&iter)) {
-//ust//                if (!_imv_read(iter.marker->state))
-//ust//                        continue;
-//ust//                channel = ltt_channels_get_name_from_index(
-//ust//                                iter.marker->channel_id);
-//ust//                __trace_mark(0, metadata, core_marker_id,
-//ust//                        &call_data,
-//ust//                        "channel %s name %s event_id %hu "
-//ust//                        "int #1u%zu long #1u%zu pointer #1u%zu "
-//ust//                        "size_t #1u%zu alignment #1u%u",
-//ust//                        channel,
-//ust//                        iter.marker->name,
-//ust//                        iter.marker->event_id,
-//ust//                        sizeof(int), sizeof(long),
-//ust//                        sizeof(void *), sizeof(size_t),
-//ust//                        ltt_get_alignment());
-//ust//                if (iter.marker->format)
-//ust//                        __trace_mark(0, metadata,
-//ust//                                core_marker_format,
-//ust//                                &call_data,
-//ust//                                "channel %s name %s format %s",
-//ust//                                channel,
-//ust//                                iter.marker->name,
-//ust//                                iter.marker->format);
-//ust//        }
-//ust//        marker_iter_stop(&iter);
-//ust// }
+void ltt_dump_marker_state(struct ltt_trace_struct *trace)
+{
+       struct marker_iter iter;
+       struct ltt_probe_private_data call_data;
+       const char *channel;
+
+       call_data.trace = trace;
+       call_data.serializer = NULL;
+
+       marker_iter_reset(&iter);
+       marker_iter_start(&iter);
+       for (; iter.marker != NULL; marker_iter_next(&iter)) {
+               if (!_imv_read(iter.marker->state))
+                       continue;
+               channel = ltt_channels_get_name_from_index(
+                               iter.marker->channel_id);
+               __trace_mark(0, metadata, core_marker_id,
+                       &call_data,
+                       "channel %s name %s event_id %hu "
+                       "int #1u%zu long #1u%zu pointer #1u%zu "
+                       "size_t #1u%zu alignment #1u%u",
+                       channel,
+                       iter.marker->name,
+                       iter.marker->event_id,
+                       sizeof(int), sizeof(long),
+                       sizeof(void *), sizeof(size_t),
+                       ltt_get_alignment());
+               if (iter.marker->format)
+                       __trace_mark(0, metadata,
+                               core_marker_format,
+                               &call_data,
+                               "channel %s name %s format %s",
+                               channel,
+                               iter.marker->name,
+                               iter.marker->format);
+       }
+       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;
+}
+
+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);
+
+       printf("just registered a markers section from %p and having %d markers\n", markers_start, markers_count);
+       
+       return 0;
+}
This page took 0.027257 seconds and 4 git commands to generate.