Cc: Gu Ping <[email protected]>
Signed-off-by: Hitoshi Mitake <[email protected]>
---
 lib/Makefile.am           |  4 +--
 lib/event.c               |  9 +++++++
 lib/tracepoint/event_tp.c | 13 ++++++++++
 lib/tracepoint/event_tp.h | 63 +++++++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 87 insertions(+), 2 deletions(-)
 create mode 100644 lib/tracepoint/event_tp.c
 create mode 100644 lib/tracepoint/event_tp.h

diff --git a/lib/Makefile.am b/lib/Makefile.am
index 64ac309..0fa6dd8 100644
--- a/lib/Makefile.am
+++ b/lib/Makefile.am
@@ -37,10 +37,10 @@ endif
 
 # for LTTng ust tracepoints
 AM_CPPFLAGS            = -I$(top_srcdir)/lib/tracepoint
-noinst_HEADERS         =  tracepoint/work_tp.h tracepoint/sockfd_cache_tp.h
+noinst_HEADERS         =  tracepoint/work_tp.h tracepoint/sockfd_cache_tp.h 
tracepoint/event_tp.h
 
 if BUILD_LTTNG_UST
-libsheepdog_a_SOURCES  += tracepoint/work_tp.c tracepoint/sockfd_cache_tp.c
+libsheepdog_a_SOURCES  += tracepoint/work_tp.c tracepoint/sockfd_cache_tp.c 
tracepoint/event_tp.c
 endif
 
 # support for GNU Flymake
diff --git a/lib/event.c b/lib/event.c
index eb55fff..3a0f968 100644
--- a/lib/event.c
+++ b/lib/event.c
@@ -19,6 +19,9 @@
 #include "util.h"
 #include "event.h"
 
+#define TRACEPOINT_DEFINE
+#include "event_tp.h"
+
 static int efd;
 static struct rb_root events_tree = RB_ROOT;
 
@@ -119,6 +122,8 @@ int register_event_prio(int fd, event_handler_t h, void 
*data, int prio)
        } else
                rb_insert(&events_tree, ei, rb, event_cmp);
 
+       tracepoint(event, _register, fd, (void *)h, data, prio);
+
        return ret;
 }
 
@@ -143,6 +148,8 @@ void unregister_event(int fd)
         * to be called in do_event_loop().  Refreshing the event loop is safe.
         */
        event_force_refresh();
+
+       tracepoint(event, unregister, fd);
 }
 
 int modify_event(int fd, unsigned int new_events)
@@ -203,6 +210,8 @@ refresh:
                sd_err("epoll_wait failed: %m");
                exit(1);
        } else if (nr) {
+               tracepoint(event, loop_start, nr_events);
+
                for (i = 0; i < nr; i++) {
                        struct event_info *ei;
 
diff --git a/lib/tracepoint/event_tp.c b/lib/tracepoint/event_tp.c
new file mode 100644
index 0000000..1c8e54c
--- /dev/null
+++ b/lib/tracepoint/event_tp.c
@@ -0,0 +1,13 @@
+/*
+ * Copyright (C) 2015 Nippon Telegraph and Telephone Corporation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License version
+ * 2 as published by the Free Software Foundation.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#define TRACEPOINT_CREATE_PROBES
+#include "event_tp.h"
diff --git a/lib/tracepoint/event_tp.h b/lib/tracepoint/event_tp.h
new file mode 100644
index 0000000..cf7c562
--- /dev/null
+++ b/lib/tracepoint/event_tp.h
@@ -0,0 +1,63 @@
+/*
+ * Copyright (C) 2015 Nippon Telegraph and Telephone Corporation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License version
+ * 2 as published by the Free Software Foundation.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifdef ENABLE_LTTNG_UST
+
+#undef TRACEPOINT_PROVIDER
+#define TRACEPOINT_PROVIDER event
+
+#undef TRACEPOINT_INCLUDE
+#define TRACEPOINT_INCLUDE "./event_tp.h"
+
+#if !defined(EVENT_TRACEPOINT_H) || defined(TRACEPOINT_HEADER_MULTI_READ)
+#define EVENT_TRACEPOINT_H
+
+#include <lttng/tracepoint.h>
+
+TRACEPOINT_EVENT(
+       event,
+       loop_start,
+       TP_ARGS(int, nr_events),
+       TP_FIELDS(
+               ctf_integer(int, nr, nr_events)
+               )
+       )
+
+TRACEPOINT_EVENT(
+       event,
+       _register,
+       TP_ARGS(int, _fd, void *, _handler, void *, _data, int, _prio),
+       TP_FIELDS(
+               ctf_integer(int, fd, _fd)
+               ctf_integer(void *, handler, _handler)
+               ctf_integer(void *, data, _data)
+               ctf_integer(int, prio, _prio)
+               )
+       )
+
+TRACEPOINT_EVENT(
+       event,
+       unregister,
+       TP_ARGS(int, _fd),
+       TP_FIELDS(
+               ctf_integer(int, fd, _fd)
+               )
+       )
+
+#endif /* EVENT_TRACEPOINT_H */
+
+#include <lttng/tracepoint-event.h>
+
+#else /* ENABLE_LTTNG_UST */
+
+#include "lttng_disable.h"
+
+#endif
-- 
1.9.1

-- 
sheepdog mailing list
[email protected]
https://lists.wpkg.org/mailman/listinfo/sheepdog

Reply via email to