~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/tools/perf/util/trace-event.c

Version: ~ [ linux-4.20-rc6 ] ~ [ linux-4.19.8 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.87 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.144 ] ~ [ linux-4.8.17 ] ~ [ linux-4.7.10 ] ~ [ linux-4.6.7 ] ~ [ linux-4.5.7 ] ~ [ linux-4.4.166 ] ~ [ linux-4.3.6 ] ~ [ linux-4.2.8 ] ~ [ linux-4.1.52 ] ~ [ linux-4.0.9 ] ~ [ linux-3.19.8 ] ~ [ linux-3.18.128 ] ~ [ linux-3.17.8 ] ~ [ linux-3.16.61 ] ~ [ linux-3.15.10 ] ~ [ linux-3.14.79 ] ~ [ linux-3.13.11 ] ~ [ linux-3.12.74 ] ~ [ linux-3.11.10 ] ~ [ linux-3.10.108 ] ~ [ linux-3.9.11 ] ~ [ linux-3.8.13 ] ~ [ linux-3.7.10 ] ~ [ linux-3.6.11 ] ~ [ linux-3.5.7 ] ~ [ linux-3.4.113 ] ~ [ linux-3.3.8 ] ~ [ linux-3.2.102 ] ~ [ linux-3.1.10 ] ~ [ linux-3.0.101 ] ~ [ linux-2.6.39.4 ] ~ [ linux-2.6.38.8 ] ~ [ linux-2.6.37.6 ] ~ [ linux-2.6.36.4 ] ~ [ linux-2.6.35.14 ] ~ [ linux-2.6.34.15 ] ~ [ linux-2.6.33.20 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.31.14 ] ~ [ linux-2.6.30.10 ] ~ [ linux-2.6.29.6 ] ~ [ linux-2.6.28.10 ] ~ [ linux-2.6.27.62 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.5 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 
  2 #include <stdio.h>
  3 #include <unistd.h>
  4 #include <stdlib.h>
  5 #include <errno.h>
  6 #include <sys/types.h>
  7 #include <sys/stat.h>
  8 #include <fcntl.h>
  9 #include <linux/kernel.h>
 10 #include <traceevent/event-parse.h>
 11 #include "trace-event.h"
 12 #include "util.h"
 13 
 14 /*
 15  * global trace_event object used by trace_event__tp_format
 16  *
 17  * TODO There's no cleanup call for this. Add some sort of
 18  * __exit function support and call trace_event__cleanup
 19  * there.
 20  */
 21 static struct trace_event tevent;
 22 
 23 int trace_event__init(struct trace_event *t)
 24 {
 25         struct pevent *pevent = pevent_alloc();
 26 
 27         if (pevent) {
 28                 t->plugin_list = traceevent_load_plugins(pevent);
 29                 t->pevent  = pevent;
 30         }
 31 
 32         return pevent ? 0 : -1;
 33 }
 34 
 35 void trace_event__cleanup(struct trace_event *t)
 36 {
 37         traceevent_unload_plugins(t->plugin_list, t->pevent);
 38         pevent_free(t->pevent);
 39 }
 40 
 41 static struct event_format*
 42 tp_format(const char *sys, const char *name)
 43 {
 44         struct pevent *pevent = tevent.pevent;
 45         struct event_format *event = NULL;
 46         char path[PATH_MAX];
 47         size_t size;
 48         char *data;
 49 
 50         scnprintf(path, PATH_MAX, "%s/%s/%s/format",
 51                   tracing_events_path, sys, name);
 52 
 53         if (filename__read_str(path, &data, &size))
 54                 return NULL;
 55 
 56         pevent_parse_format(pevent, &event, data, size, sys);
 57 
 58         free(data);
 59         return event;
 60 }
 61 
 62 struct event_format*
 63 trace_event__tp_format(const char *sys, const char *name)
 64 {
 65         static bool initialized;
 66 
 67         if (!initialized) {
 68                 int be = traceevent_host_bigendian();
 69                 struct pevent *pevent;
 70 
 71                 if (trace_event__init(&tevent))
 72                         return NULL;
 73 
 74                 pevent = tevent.pevent;
 75                 pevent_set_flag(pevent, PEVENT_NSEC_OUTPUT);
 76                 pevent_set_file_bigendian(pevent, be);
 77                 pevent_set_host_bigendian(pevent, be);
 78                 initialized = true;
 79         }
 80 
 81         return tp_format(sys, name);
 82 }
 83 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | Wiki (Japanese) | Wiki (English) | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

osdn.jp