Add ttrace
authorJengHyun Kang <jhyuni.kang@samsung.com>
Thu, 11 Feb 2016 06:44:36 +0000 (15:44 +0900)
committerJengHyun Kang <jhyuni.kang@samsung.com>
Tue, 24 Oct 2017 07:04:33 +0000 (16:04 +0900)
Change-Id: I82a316d226c967a396f6ce5671feeafbfb37bd0f

configure.ac
packaging/libinput.spec
src/Makefile.am
src/evdev.c
src/libinput-private.h
src/libinput.c

index eabc9e14233015c9f478a423a8afb3dcb7220d54..7ee2584a2ed58f7a3623624c48345c39845602a6 100644 (file)
@@ -245,6 +245,17 @@ AM_CONDITIONAL([GCOV_ENABLED], [test "x$enable_gcov" != "xno"])
 AC_SUBST([GCOV_CFLAGS])
 AC_SUBST([GCOV_LDFLAGS])
 
+#######################
+# check for ttrace header files #
+#######################
+PKG_CHECK_MODULES(TTRACE,
+               [ttrace],
+               [have_ttrace="yes"], [have_ttrace="no"])
+
+if test "x$have_ttrace" = "xyes"; then
+       AC_DEFINE(ENABLE_TTRACE, 1, [ttrace available])
+fi
+
 AM_CONDITIONAL(HAVE_VALGRIND, [test "x$VALGRIND" != "x"])
 AM_CONDITIONAL(BUILD_TESTS, [test "x$build_tests" = "xyes"])
 AM_CONDITIONAL(RUN_TESTS, [test "x$run_tests" = "xyes"])
index b1922005e85de481548173459ecd3da4ceda5db3..b6f23b53971509a6a9e4f66f57f67852203f108b 100644 (file)
@@ -16,7 +16,7 @@ BuildRequires:  pkgconfig(libevdev)
 BuildRequires:  pkgconfig(libevent)
 BuildRequires:  pkgconfig(libudev)
 BuildRequires:  pkgconfig(mtdev)
-
+BuildRequires:  pkgconfig(ttrace)
 
 %description
 
index 6723d5ae2c0a6ec46c9faf3a541236873f927bb1..10c3094b56d4c836a166a76fffeacf2265afefc6 100644 (file)
@@ -39,6 +39,7 @@ libinput_la_LIBADD = $(MTDEV_LIBS) \
                     $(LIBUDEV_LIBS) \
                     $(LIBEVDEV_LIBS) \
                     $(LIBWACOM_LIBS) \
+                    $(TTRACE_LIBS) \
                     libinput-util.la
 libinput_la_LDFLAGS = $(GCOV_LDFLAGS) \
                      -version-info $(LIBINPUT_LT_VERSION) -shared \
@@ -51,6 +52,8 @@ libinput_la_CFLAGS = -I$(top_srcdir)/include \
                     $(LIBWACOM_CFLAGS) \
                     $(GCC_CFLAGS) \
                     $(GCOV_CFLAGS)
+                    $(TTRACE_CFLAGS)   \
+                    $(GCC_CFLAGS)
 EXTRA_libinput_la_DEPENDENCIES = $(srcdir)/libinput.sym
 
 libinput_util_la_SOURCES = \
index e51f55114568e8c2f425d6607fce7b92e10a0e17..c9071bb09fc082187146293252ccc9c5152b32c3 100644 (file)
@@ -559,8 +559,12 @@ fallback_flush_relative_motion(struct fallback_dispatch *dispatch,
        struct normalized_coords accel, unaccel;
        struct device_float_coords raw;
 
-       if (!(device->seat_caps & EVDEV_DEVICE_POINTER))
+       TRACE_BEGIN(fallback_flush_relative_motion);
+
+       if (!(device->seat_caps & EVDEV_DEVICE_POINTER)) {
+               TRACE_END();
                return;
+       }
 
        fallback_rotate_relative(dispatch, device);
 
@@ -571,8 +575,10 @@ fallback_flush_relative_motion(struct fallback_dispatch *dispatch,
        dispatch->rel.y = 0;
 
        /* Use unaccelerated deltas for pointing stick scroll */
-       if (evdev_post_trackpoint_scroll(device, unaccel, time))
+       if (evdev_post_trackpoint_scroll(device, unaccel, time)) {
+               TRACE_END();
                return;
+       }
 
        if (device->pointer.filter) {
                /* Apply pointer acceleration. */
@@ -586,10 +592,14 @@ fallback_flush_relative_motion(struct fallback_dispatch *dispatch,
                accel = unaccel;
        }
 
-       if (normalized_is_zero(accel) && normalized_is_zero(unaccel))
+       if (normalized_is_zero(accel) && normalized_is_zero(unaccel)) {
+               TRACE_END();
                return;
+       }
 
        pointer_notify_motion(base, time, &accel, &raw);
+
+       TRACE_END();
 }
 
 static void
@@ -927,9 +937,13 @@ fallback_process_key(struct fallback_dispatch *dispatch,
 {
        enum evdev_key_type type;
 
+       TRACE_BEGIN(evdev_process_key);
+
        /* ignore kernel key repeat */
-       if (e->value == 2)
+       if (e->value == 2) {
+               TRACE_END();
                return;
+       }
 
        if (e->code == BTN_TOUCH) {
                if (!device->is_mt)
@@ -937,6 +951,7 @@ fallback_process_key(struct fallback_dispatch *dispatch,
                                                      device,
                                                      time,
                                                      e->value);
+               TRACE_END();
                return;
        }
 
@@ -952,8 +967,10 @@ fallback_process_key(struct fallback_dispatch *dispatch,
                        break;
                case EVDEV_KEY_TYPE_KEY:
                case EVDEV_KEY_TYPE_BUTTON:
-                       if (!hw_is_key_down(dispatch, e->code))
+                       if (!hw_is_key_down(dispatch, e->code)) {
+                               TRACE_END();
                                return;
+                       }
                }
        }
 
@@ -980,6 +997,7 @@ fallback_process_key(struct fallback_dispatch *dispatch,
                                   LIBINPUT_BUTTON_STATE_RELEASED);
                break;
        }
+       TRACE_END();
 }
 
 static void
@@ -1112,8 +1130,12 @@ fallback_process_relative(struct fallback_dispatch *dispatch,
        struct discrete_coords discrete = { 0.0, 0.0 };
        enum libinput_pointer_axis_source source;
 
-       if (fallback_reject_relative(device, e, time))
+       TRACE_BEGIN(fallback_process_relative);
+
+       if (fallback_reject_relative(device, e, time)) {
+               TRACE_END();
                return;
+       }
 
        switch (e->code) {
        case REL_X:
@@ -1165,6 +1187,7 @@ fallback_process_relative(struct fallback_dispatch *dispatch,
                        &discrete);
                break;
        }
+       TRACE_END();
 }
 
 static inline void
@@ -1173,11 +1196,13 @@ fallback_process_absolute(struct fallback_dispatch *dispatch,
                          struct input_event *e,
                          uint64_t time)
 {
+       TRACE_BEGIN(evdev_process_absolute);
        if (device->is_mt) {
                fallback_process_touch(dispatch, device, e, time);
        } else {
                fallback_process_absolute_motion(dispatch, device, e);
        }
+       TRACE_END();
 }
 
 static inline bool
@@ -2039,7 +2064,11 @@ evdev_process_event(struct evdev_device *device, struct input_event *e)
                          e->value);
 #endif
 
+       TRACE_BEGIN(evdev_process_event);
+
        dispatch->interface->process(dispatch, device, e, time);
+
+       TRACE_END();
 }
 
 static inline void
index 39fcbf8e8c82a1033e4f45d71eced460360f0173..667d4e92f0bd805f4e3d577d5c18cccf30b0f95b 100644 (file)
 #define HTTP_DOC_LINK "https://wayland.freedesktop.org/libinput/doc/" LIBINPUT_VERSION "/"
 #endif
 
+#ifdef ENABLE_TTRACE
+#include <ttrace.h>
+
+#define TRACE_BEGIN(NAME) traceBegin(TTRACE_TAG_INPUT, "INPUT:LIBINPUT:"#NAME)
+#define TRACE_END() traceEnd(TTRACE_TAG_INPUT)
+#else
+#define TRACE_BEGIN(NAME)
+#define TRACE_END()
+#endif
+
 struct libinput_source;
 
 /* A coordinate pair in device coordinates */
index cb9b27e6c3ec06ba4e2927096f89d66486b2441d..c2e7297f383b8c84001efd36eb62ef1fcc94547b 100644 (file)
@@ -2343,13 +2343,19 @@ notify_added_device(struct libinput_device *device)
 {
        struct libinput_event_device_notify *added_device_event;
 
+       TRACE_BEGIN(notify_added_device);
+
        added_device_event = zalloc(sizeof *added_device_event);
-       if (!added_device_event)
+       if (!added_device_event) {
+               TRACE_END();
                return;
+       }
 
        post_base_event(device,
                        LIBINPUT_EVENT_DEVICE_ADDED,
                        &added_device_event->base);
+
+       TRACE_END();
 }
 
 void
@@ -2357,13 +2363,19 @@ notify_removed_device(struct libinput_device *device)
 {
        struct libinput_event_device_notify *removed_device_event;
 
+       TRACE_BEGIN(notify_removed_device);
+
        removed_device_event = zalloc(sizeof *removed_device_event);
-       if (!removed_device_event)
+       if (!removed_device_event) {
+               TRACE_END();
                return;
+       }
 
        post_base_event(device,
                        LIBINPUT_EVENT_DEVICE_REMOVED,
                        &removed_device_event->base);
+
+       TRACE_END();
 }
 
 static inline bool
@@ -2416,12 +2428,18 @@ keyboard_notify_key(struct libinput_device *device,
        struct libinput_event_keyboard *key_event;
        uint32_t seat_key_count;
 
-       if (!device_has_cap(device, LIBINPUT_DEVICE_CAP_KEYBOARD))
+       TRACE_BEGIN(keyboard_notify_key);
+
+       if (!device_has_cap(device, LIBINPUT_DEVICE_CAP_KEYBOARD)) {
+               TRACE_END();
                return;
+       }
 
        key_event = zalloc(sizeof *key_event);
-       if (!key_event)
+       if (!key_event) {
+               TRACE_END();
                return;
+       }
 
        seat_key_count = update_seat_key_count(device->seat, key, state);
 
@@ -2435,6 +2453,8 @@ keyboard_notify_key(struct libinput_device *device,
        post_device_event(device, time,
                          LIBINPUT_EVENT_KEYBOARD_KEY,
                          &key_event->base);
+
+       TRACE_END();
 }
 
 void
@@ -2445,12 +2465,18 @@ pointer_notify_motion(struct libinput_device *device,
 {
        struct libinput_event_pointer *motion_event;
 
-       if (!device_has_cap(device, LIBINPUT_DEVICE_CAP_POINTER))
-               return;
+       TRACE_BEGIN(pointer_notify_motion);
 
+       if (!device_has_cap(device, LIBINPUT_DEVICE_CAP_POINTER)) {
+               TRACE_END();
+               return;
+       }
+       
        motion_event = zalloc(sizeof *motion_event);
-       if (!motion_event)
+       if (!motion_event) {
+               TRACE_END();
                return;
+       }
 
        *motion_event = (struct libinput_event_pointer) {
                .time = time,
@@ -2461,6 +2487,8 @@ pointer_notify_motion(struct libinput_device *device,
        post_device_event(device, time,
                          LIBINPUT_EVENT_POINTER_MOTION,
                          &motion_event->base);
+
+       TRACE_END();
 }
 
 void
@@ -2470,12 +2498,18 @@ pointer_notify_motion_absolute(struct libinput_device *device,
 {
        struct libinput_event_pointer *motion_absolute_event;
 
-       if (!device_has_cap(device, LIBINPUT_DEVICE_CAP_POINTER))
+       TRACE_BEGIN(pointer_notify_motion_absolute);
+
+       if (!device_has_cap(device, LIBINPUT_DEVICE_CAP_POINTER)) {
+               TRACE_END();
                return;
+       }
 
        motion_absolute_event = zalloc(sizeof *motion_absolute_event);
-       if (!motion_absolute_event)
+       if (!motion_absolute_event) {
+               TRACE_END();
                return;
+       }
 
        *motion_absolute_event = (struct libinput_event_pointer) {
                .time = time,
@@ -2485,6 +2519,8 @@ pointer_notify_motion_absolute(struct libinput_device *device,
        post_device_event(device, time,
                          LIBINPUT_EVENT_POINTER_MOTION_ABSOLUTE,
                          &motion_absolute_event->base);
+
+       TRACE_END();
 }
 
 void
@@ -2496,12 +2532,18 @@ pointer_notify_button(struct libinput_device *device,
        struct libinput_event_pointer *button_event;
        int32_t seat_button_count;
 
-       if (!device_has_cap(device, LIBINPUT_DEVICE_CAP_POINTER))
+       TRACE_BEGIN(pointer_notify_button);
+
+       if (!device_has_cap(device, LIBINPUT_DEVICE_CAP_POINTER)) {
+               TRACE_END();
                return;
+       }
 
        button_event = zalloc(sizeof *button_event);
-       if (!button_event)
+       if (!button_event) {
+               TRACE_END();
                return;
+       }
 
        seat_button_count = update_seat_button_count(device->seat,
                                                     button,
@@ -2517,6 +2559,8 @@ pointer_notify_button(struct libinput_device *device,
        post_device_event(device, time,
                          LIBINPUT_EVENT_POINTER_BUTTON,
                          &button_event->base);
+
+       TRACE_END();
 }
 
 void
@@ -2529,12 +2573,18 @@ pointer_notify_axis(struct libinput_device *device,
 {
        struct libinput_event_pointer *axis_event;
 
-       if (!device_has_cap(device, LIBINPUT_DEVICE_CAP_POINTER))
+       TRACE_BEGIN(pointer_notify_axis);
+
+       if (!device_has_cap(device, LIBINPUT_DEVICE_CAP_POINTER)) {
+               TRACE_END();
                return;
+       }
 
        axis_event = zalloc(sizeof *axis_event);
-       if (!axis_event)
+       if (!axis_event) {
+               TRACE_END();
                return;
+       }
 
        *axis_event = (struct libinput_event_pointer) {
                .time = time,
@@ -2547,6 +2597,8 @@ pointer_notify_axis(struct libinput_device *device,
        post_device_event(device, time,
                          LIBINPUT_EVENT_POINTER_AXIS,
                          &axis_event->base);
+
+       TRACE_END();
 }
 
 void
@@ -2560,12 +2612,18 @@ touch_notify_touch_down(struct libinput_device *device,
 {
        struct libinput_event_touch *touch_event;
 
-       if (!device_has_cap(device, LIBINPUT_DEVICE_CAP_TOUCH))
+       TRACE_BEGIN(touch_notify_touch_down);
+
+       if (!device_has_cap(device, LIBINPUT_DEVICE_CAP_TOUCH)) {
+               TRACE_END();
                return;
+       }
 
        touch_event = zalloc(sizeof *touch_event);
-       if (!touch_event)
+       if (!touch_event) {
+               TRACE_END();
                return;
+       }
 
        *touch_event = (struct libinput_event_touch) {
                .time = time,
@@ -2579,6 +2637,8 @@ touch_notify_touch_down(struct libinput_device *device,
        post_device_event(device, time,
                          LIBINPUT_EVENT_TOUCH_DOWN,
                          &touch_event->base);
+
+       TRACE_END();
 }
 
 void
@@ -2592,12 +2652,18 @@ touch_notify_touch_motion(struct libinput_device *device,
 {
        struct libinput_event_touch *touch_event;
 
-       if (!device_has_cap(device, LIBINPUT_DEVICE_CAP_TOUCH))
+       TRACE_BEGIN(touch_notify_touch_motion);
+
+       if (!device_has_cap(device, LIBINPUT_DEVICE_CAP_TOUCH)) {
+               TRACE_END();
                return;
+       }
 
        touch_event = zalloc(sizeof *touch_event);
-       if (!touch_event)
+       if (!touch_event) {
+               TRACE_END();
                return;
+       }
 
        *touch_event = (struct libinput_event_touch) {
                .time = time,
@@ -2611,6 +2677,8 @@ touch_notify_touch_motion(struct libinput_device *device,
        post_device_event(device, time,
                          LIBINPUT_EVENT_TOUCH_MOTION,
                          &touch_event->base);
+
+       TRACE_END();
 }
 
 void
@@ -2621,12 +2689,18 @@ touch_notify_touch_up(struct libinput_device *device,
 {
        struct libinput_event_touch *touch_event;
 
-       if (!device_has_cap(device, LIBINPUT_DEVICE_CAP_TOUCH))
+       TRACE_BEGIN(touch_notify_touch_up);
+
+       if (!device_has_cap(device, LIBINPUT_DEVICE_CAP_TOUCH)) {
+               TRACE_END();
                return;
+       }
 
        touch_event = zalloc(sizeof *touch_event);
-       if (!touch_event)
+       if (!touch_event) {
+               TRACE_END();
                return;
+       }
 
        *touch_event = (struct libinput_event_touch) {
                .time = time,
@@ -2637,6 +2711,8 @@ touch_notify_touch_up(struct libinput_device *device,
        post_device_event(device, time,
                          LIBINPUT_EVENT_TOUCH_UP,
                          &touch_event->base);
+
+       TRACE_END();
 }
 
 void