add trace event
authorcompudj <compudj@04897980-b3bd-0310-b5e0-8ef037075253>
Wed, 21 Mar 2007 23:28:04 +0000 (23:28 +0000)
committercompudj <compudj@04897980-b3bd-0310-b5e0-8ef037075253>
Wed, 21 Mar 2007 23:28:04 +0000 (23:28 +0000)
git-svn-id: http://ltt.polymtl.ca/svn@2451 04897980-b3bd-0310-b5e0-8ef037075253

tests/kernel/trace-event.h [new file with mode: 0644]

diff --git a/tests/kernel/trace-event.h b/tests/kernel/trace-event.h
new file mode 100644 (file)
index 0000000..c755503
--- /dev/null
@@ -0,0 +1,104 @@
+#include <stdarg.h>
+
+/* LTT flags
+ *
+ * LTT_FLAG_TRACE : first arg contains trace to write into.
+ *                 (type : struct ltt_trace_struct *)
+ * LTT_FLAG_CHANNEL : following arg contains channel index to write into.
+ *                    (type : uint8_t)
+ * LTT_FLAG_FORCE : Force write in disabled traces (internal ltt use)
+ */
+
+#define _LTT_FLAG_TRACE                0       
+#define _LTT_FLAG_CHANNEL      1
+#define _LTT_FLAG_FORCE                2
+
+#define LTT_FLAG_TRACE         (1 << _LTT_FLAG_TRACE)
+#define LTT_FLAG_CHANNEL       (1 << _LTT_FLAG_CHANNEL)
+#define LTT_FLAG_FORCE         (1 << _LTT_FLAG_FORCE)
+
+/* Calculate data size */
+/* Assume that the padding for alignment starts at a
+ * sizeof(void *) address. */
+static inline __attribute__((no_instrument_function))
+size_t ltt_get_data_size(ltt_facility_t fID, uint8_t eID,
+                               const char *fmt, va_list args)
+{
+
+
+
+}
+
+static inline __attribute__((no_instrument_function))
+size_t ltt_write_event_data(char *buffer,
+                               ltt_facility_t fID, uint8_t eID,
+                               const char *fmt, va_list args)
+{
+
+
+
+}
+
+
+__attribute__((no_instrument_function))
+void vtrace(ltt_facility_t fID, uint8_t eID, long flags, 
+               const char *fmt, va_list args)
+{
+       size_t data_size, slot_size;
+       uint8_t channel_index;
+       struct ltt_channel_struct *channel;
+       struct ltt_trace_struct *trace, *dest_trace;
+       void *transport_data;
+       uint64_t tsc;
+       char *buffer;
+
+       /* This test is useful for quickly exiting static tracing when no
+        * trace is active. */
+       if (likely(ltt_traces.num_active_traces == 0 && !(flags & LTT_FLAG_FORCE)))
+               return;
+
+       data_size = ltt_get_data_size(fID, eID, fmt, args);
+       preempt_disable();
+       ltt_nesting[smp_processor_id()]++;
+
+       if (unlikely(flags & LTT_FLAG_TRACE))
+               dest_trace = va_arg(args, struct ltt_trace_struct *);
+       if (unlikely(flags & LTT_FLAG_CHANNEL))
+               channel_index = va_arg(args, uint8_t);
+       else
+               channel_index = ltt_get_channel_index(fID, eID);
+
+       /* Iterate on each traces */
+       list_for_each_entry_rcu(trace, &ltt_traces.head, list) {
+               if (unlikely(!trace->active && !(flags & LTT_FLAG_FORCE)))
+                       continue;
+               if (unlikely(flags & LTT_FLAG_TRACE && trace != dest_trace))
+                       continue;
+               channel = ltt_get_channel_from_index(trace, channel_index);
+               /* reserve space : header and data */
+               buffer = ltt_reserve_slot(trace, channel, &transport_data,
+                                               data_size, &slot_size, &tsc);
+               if (unlikely(!buffer))
+                       continue; /* buffer full */
+               /* Out-of-order write : header and data */
+               buffer = ltt_write_event_header(trace, channel, buffer,
+                                               fID, eID, data_size, tsc);
+               ltt_write_event_data(buffer, fID, eID, fmt, args);
+               /* Out-of-order commit */
+               ltt_commit_slot(channel, &transport_data, buffer, slot_size);
+       }
+
+       ltt_nesting[smp_processor_id()]--;
+       preempt_enable();
+}
+
+__attribute__((no_instrument_function))
+void trace(ltt_facility_t fID, uint8_t eID, const char *fmt, ...)
+{
+       va_list args;
+
+       va_start(args, fmt);
+       vtrace(fmt, args);
+       va_end(args);
+}
+
This page took 0.024736 seconds and 4 git commands to generate.