Move kernelcompat.h to include/ust/ and share.h, usterr.h to include/
[ust.git] / libust / marker.c
index ade2d9c1f1edcd3f5a754196f8f1f34a902d677d..8690d2b1151e0a5861c2c81327226cb55e46757a 100644 (file)
@@ -1,19 +1,19 @@
 /*
  * Copyright (C) 2007 Mathieu Desnoyers
  *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
  *
- * This program is distributed in the hope that it will be useful,
+ * This library is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
  *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301 USA
  */
 //ust// #include <linux/module.h>
 //ust// #include <linux/mutex.h>
 //ust// #include <linux/user_marker.h>
 //ust// #include <linux/ltt-tracer.h>
 
-#include "marker.h"
-#include "kernelcompat.h"
+#define _LGPL_SOURCE
+#include <urcu-bp.h>
+
+#include <ust/kernelcompat.h>
+
+#include <ust/marker.h>
 #include "usterr.h"
 #include "channels.h"
 #include "tracercore.h"
 #include "tracer.h"
-#include "urcu.h"
 
 extern struct marker __start___markers[] __attribute__((visibility("hidden")));
 extern struct marker __stop___markers[] __attribute__((visibility("hidden")));
@@ -50,6 +53,9 @@ static const int marker_debug;
  */
 static DEFINE_MUTEX(markers_mutex);
 
+static LIST_HEAD(libs);
+
+
 void lock_markers(void)
 {
        mutex_lock(&markers_mutex);
@@ -628,9 +634,9 @@ static int set_marker(struct marker_entry *entry, struct marker *elem,
  */
 static void disable_marker(struct marker *elem)
 {
-       int ret;
-
-       /* leave "call" as is. It is known statically. */
+//ust//        int ret;
+//ust//
+//ust//        /* leave "call" as is. It is known statically. */
 //ust//        if (elem->tp_name && _imv_read(elem->state)) {
 //ust//                WARN_ON(!elem->tp_cb);
 //ust//                /*
@@ -700,6 +706,18 @@ void marker_update_probe_range(struct marker *begin,
        mutex_unlock(&markers_mutex);
 }
 
+static void lib_update_markers(void)
+{
+       struct lib *lib;
+
+       /* FIXME: we should probably take a mutex here on libs */
+//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);
+}
+
 /*
  * Update probes, removing the faulty probes.
  *
@@ -1053,6 +1071,33 @@ void *marker_get_private_data(const char *channel, const char *name,
 
 //ust//#ifdef CONFIG_MODULES
 
+/*
+ * 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;
+}
+
 /**
  * marker_get_iter_range - Get a next marker iterator given a range.
  * @marker: current markers (in), next marker (out)
@@ -1395,84 +1440,43 @@ struct notifier_block marker_module_nb = {
 
 void ltt_dump_marker_state(struct ltt_trace_struct *trace)
 {
-       struct marker_iter iter;
+       struct marker_entry *entry;
        struct ltt_probe_private_data call_data;
-       const char *channel;
+       struct hlist_head *head;
+       struct hlist_node *node;
+       unsigned int i;
 
+       mutex_lock(&markers_mutex);
        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,
+       for (i = 0; i < MARKER_TABLE_SIZE; i++) {
+               head = &marker_table[i];
+               hlist_for_each_entry(entry, node, head, hlist) {
+                       __trace_mark(0, metadata, core_marker_id,
                                &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;
+                               "channel %s name %s event_id %hu "
+                               "int #1u%zu long #1u%zu pointer #1u%zu "
+                               "size_t #1u%zu alignment #1u%u",
+                               entry->channel,
+                               entry->name,
+                               entry->event_id,
+                               sizeof(int), sizeof(long),
+                               sizeof(void *), sizeof(size_t),
+                               ltt_get_alignment());
+                       if (entry->format)
+                               __trace_mark(0, metadata,
+                                       core_marker_format,
+                                       &call_data,
+                                       "channel %s name %s format %s",
+                                       entry->channel,
+                                       entry->name,
+                                       entry->format);
                }
        }
-//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);
+       mutex_unlock(&markers_mutex);
 }
+//ust// EXPORT_SYMBOL_GPL(ltt_dump_marker_state);
 
 static void (*new_marker_cb)(struct marker *) = NULL;
 
@@ -1529,7 +1533,7 @@ 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);
+               DBG("markers_start: %p, markers_stop: %p\n", __start___markers, __stop___markers);
                initialized = 1;
        }
 }
This page took 0.025803 seconds and 4 git commands to generate.