Add ttrace
authorJengHyun Kang <jhyuni.kang@samsung.com>
Thu, 11 Feb 2016 06:44:36 +0000 (15:44 +0900)
committerduna.oh <duna.oh@samsung.com>
Fri, 27 Jan 2023 05:00:52 +0000 (14:00 +0900)
Change-Id: I82a316d226c967a396f6ce5671feeafbfb37bd0f

meson.build
packaging/libinput.spec
src/evdev-fallback.c
src/evdev.c
src/libinput-private.h
src/libinput.c

index d9e3eff7b28ef38852cfdd4bb5f11eab9059de35..ac8219baa1b1d1d55cbb7126d3baf01b2fdc28c3 100644 (file)
@@ -166,6 +166,14 @@ else
        dep_libwacom = declare_dependency()
 endif
 
+############ ttrace configuration ############
+
+dep_ttrace = dependency('ttrace', required : false)
+if dep_ttrace.found()
+       config_h.set10('ENABLE_TTRACE', 1)
+endif
+
+
 ############ udev bits ############
 
 executable('libinput-device-group',
@@ -370,7 +378,8 @@ deps_libinput = [
        dep_rt,
        dep_libwacom,
        dep_libinput_util,
-       dep_libquirks
+       dep_libquirks,
+       dep_ttrace
 ]
 
 libinput_version_h_config = configuration_data()
index af0deada620971e4adf18eacd567a40985268002..d666dee20951b2d58936dbd974eb999bec5e5b8b 100644 (file)
@@ -16,7 +16,7 @@ BuildRequires:  pkgconfig(libevdev)
 BuildRequires:  pkgconfig(libevent)
 BuildRequires:  pkgconfig(libudev)
 BuildRequires:  pkgconfig(mtdev)
-BuildRequires:  pkgconfig(wacom)
+BuildRequires:  pkgconfig(ttrace)
 
 
 %description
index 3bfaf9ea1094dc8da57cd8eab6f75fe2f928e36a..227b09b9efec07701101e83d6dc5f9d2657330ba 100644 (file)
@@ -176,8 +176,12 @@ fallback_flush_relative_motion(struct fallback_dispatch *dispatch,
        struct normalized_coords accel;
        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);
 
@@ -187,8 +191,10 @@ fallback_flush_relative_motion(struct fallback_dispatch *dispatch,
        dispatch->rel.y = 0;
 
        /* Use unaccelerated deltas for pointing stick scroll */
-       if (post_button_scroll(device, raw, time))
+       if (post_button_scroll(device, raw, time)) {
+               TRACE_END();
                return;
+       }
 
        if (device->pointer.filter) {
                /* Apply pointer acceleration. */
@@ -202,10 +208,13 @@ fallback_flush_relative_motion(struct fallback_dispatch *dispatch,
                accel.x = accel.y = 0;
        }
 
-       if (normalized_is_zero(accel))
+       if (normalized_is_zero(accel)) {
+               TRACE_END();
                return;
+       }
 
        pointer_notify_motion(base, time, &accel, &raw);
+       TRACE_END();
 }
 
 static void
@@ -485,9 +494,13 @@ fallback_process_key(struct fallback_dispatch *dispatch,
 {
        enum key_type type;
 
+       TRACE_BEGIN(fallbak_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)
@@ -495,6 +508,7 @@ fallback_process_key(struct fallback_dispatch *dispatch,
                                                      device,
                                                      time,
                                                      e->value);
+               TRACE_END();
                return;
        }
 
@@ -509,8 +523,10 @@ fallback_process_key(struct fallback_dispatch *dispatch,
        case KEY_TYPE_KEY:
        case KEY_TYPE_BUTTON:
                if ((e->value && hw_is_key_down(dispatch, e->code)) ||
-                   (e->value == 0 && !hw_is_key_down(dispatch, e->code)))
+                   (e->value == 0 && !hw_is_key_down(dispatch, e->code))) {
+                   TRACE_END();
                        return;
+               }
 
                dispatch->pending_event |= EVDEV_KEY;
                break;
@@ -533,6 +549,7 @@ fallback_process_key(struct fallback_dispatch *dispatch,
        case KEY_TYPE_BUTTON:
                break;
        }
+       TRACE_END();
 }
 
 static void
@@ -791,8 +808,12 @@ fallback_process_relative(struct fallback_dispatch *dispatch,
                          struct evdev_device *device,
                          struct input_event *e, uint64_t time)
 {
-       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:
@@ -806,6 +827,7 @@ fallback_process_relative(struct fallback_dispatch *dispatch,
        }
 
        fallback_wheel_process_relative(dispatch, device, e, time);
+       TRACE_END();
 }
 
 static inline void
@@ -814,11 +836,13 @@ fallback_process_absolute(struct fallback_dispatch *dispatch,
                          struct input_event *e,
                          uint64_t time)
 {
+       TRACE_BEGIN(fallback_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
index e4e8692b000dbbb9289bc497f664d8bd42d6229e..7f0c0c1e6e5864917eb16fb18a72bea2cae45839 100644 (file)
@@ -1107,7 +1107,11 @@ evdev_process_event(struct evdev_device *device, struct input_event *e)
 
        libinput_timer_flush(evdev_libinput_context(device), time);
 
+       TRACE_BEGIN(evdev_process_event);
+
        dispatch->interface->process(dispatch, device, e, time);
+
+       TRACE_END();
 }
 
 static inline void
index a6e451f09117e9da2aa3b41bd16544cde5902187..501bf245d73edf67afc95fabfde1c6d6f3f09f6e 100644 (file)
 #include "libinput-util.h"
 #include "libinput-version.h"
 
+#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 f4ca88ba929784f0a4e684764977f77a3be65cf6..fe28c8660e36b5de23559b03b29295447f5603d8 100644 (file)
@@ -2480,6 +2480,8 @@ 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);
 
        post_base_event(device,
@@ -2491,6 +2493,7 @@ notify_added_device(struct libinput_device *device)
         * pretend to free it  */
        free(added_device_event);
 #endif
+       TRACE_END();
 }
 
 void
@@ -2498,6 +2501,8 @@ 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);
 
        post_base_event(device,
@@ -2509,6 +2514,7 @@ notify_removed_device(struct libinput_device *device)
         * pretend to free it  */
        free(removed_device_event);
 #endif
+       TRACE_END();
 }
 
 static inline bool
@@ -2561,8 +2567,12 @@ 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);
 
@@ -2578,6 +2588,8 @@ keyboard_notify_key(struct libinput_device *device,
        post_device_event(device, time,
                          LIBINPUT_EVENT_KEYBOARD_KEY,
                          &key_event->base);
+
+       TRACE_END();
 }
 
 void
@@ -2588,9 +2600,13 @@ 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);
 
        *motion_event = (struct libinput_event_pointer) {
@@ -2602,6 +2618,8 @@ pointer_notify_motion(struct libinput_device *device,
        post_device_event(device, time,
                          LIBINPUT_EVENT_POINTER_MOTION,
                          &motion_event->base);
+
+       TRACE_END();
 }
 
 void
@@ -2611,8 +2629,12 @@ 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);
 
@@ -2624,6 +2646,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
@@ -2635,8 +2659,12 @@ 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);
 
@@ -2654,6 +2682,8 @@ pointer_notify_button(struct libinput_device *device,
        post_device_event(device, time,
                          LIBINPUT_EVENT_POINTER_BUTTON,
                          &button_event->base);
+
+       TRACE_END();
 }
 
 void
@@ -2734,8 +2764,12 @@ pointer_notify_axis_legacy_wheel(struct libinput_device *device,
        struct libinput_event_pointer *axis_event;
        const struct wheel_v120 zero_v120 = {0};
 
-       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);
 
@@ -2751,6 +2785,8 @@ pointer_notify_axis_legacy_wheel(struct libinput_device *device,
        post_device_event(device, time,
                          LIBINPUT_EVENT_POINTER_AXIS,
                          &axis_event->base);
+
+       TRACE_END();
 }
 
 void
@@ -2795,8 +2831,12 @@ 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);
 
@@ -2812,6 +2852,8 @@ touch_notify_touch_down(struct libinput_device *device,
        post_device_event(device, time,
                          LIBINPUT_EVENT_TOUCH_DOWN,
                          &touch_event->base);
+
+       TRACE_END();
 }
 
 void
@@ -2825,8 +2867,12 @@ 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);
 
@@ -2842,6 +2888,8 @@ touch_notify_touch_motion(struct libinput_device *device,
        post_device_event(device, time,
                          LIBINPUT_EVENT_TOUCH_MOTION,
                          &touch_event->base);
+
+       TRACE_END();
 }
 
 void
@@ -2852,8 +2900,12 @@ 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);
 
@@ -2866,6 +2918,8 @@ touch_notify_touch_up(struct libinput_device *device,
        post_device_event(device, time,
                          LIBINPUT_EVENT_TOUCH_UP,
                          &touch_event->base);
+
+       TRACE_END();
 }
 
 void