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>
Mon, 7 Feb 2022 11:52:00 +0000 (20:52 +0900)
Change-Id: I82a316d226c967a396f6ce5671feeafbfb37bd0f

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

index b94f53d2d628f48a74d4733f2db2a1b8330fb61b..25fa15c33d43209d588fed62169ee3bdb1324c73 100644 (file)
@@ -162,6 +162,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',
@@ -382,7 +390,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 256735bf1e7ee96332f398845c5899728e8c258b..cd1e1ca164335d9e7cccace97f2cf524a78eb6df 100644 (file)
@@ -168,8 +168,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);
 
@@ -180,8 +184,10 @@ fallback_flush_relative_motion(struct fallback_dispatch *dispatch,
        dispatch->rel.y = 0;
 
        /* Use unaccelerated deltas for pointing stick scroll */
-       if (post_trackpoint_scroll(device, unaccel, time))
+       if (post_trackpoint_scroll(device, unaccel, time)) {
+               TRACE_END();
                return;
+       }
 
        if (device->pointer.filter) {
                /* Apply pointer acceleration. */
@@ -195,10 +201,13 @@ 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
@@ -535,9 +544,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)
@@ -545,6 +558,7 @@ fallback_process_key(struct fallback_dispatch *dispatch,
                                                      device,
                                                      time,
                                                      e->value);
+               TRACE_END();
                return;
        }
 
@@ -559,8 +573,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;
@@ -583,6 +599,7 @@ fallback_process_key(struct fallback_dispatch *dispatch,
        case KEY_TYPE_BUTTON:
                break;
        }
+       TRACE_END();
 }
 
 static void
@@ -841,8 +858,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:
@@ -862,6 +883,7 @@ fallback_process_relative(struct fallback_dispatch *dispatch,
                dispatch->pending_event |= EVDEV_WHEEL;
                break;
        }
+       TRACE_END();
 }
 
 static inline void
@@ -870,11 +892,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 886df79a12a69b1b53307c476ab0ab3b288d7395..16418d9c8216909ecef15db998fa4c79fc78c963 100644 (file)
@@ -1017,7 +1017,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 5e32f6e9e64ce149475b58df585ea464ed12974b..eccbb96a125c16de60c445baa6c2f2347d5e791f 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 f842bda69ae8c53c80abf4a24b7eeae9b816face..e7ad40d9bd0c5052cebe6919808d937a6cd562de 100644 (file)
@@ -2397,6 +2397,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,
@@ -2408,6 +2410,7 @@ notify_added_device(struct libinput_device *device)
         * pretend to free it  */
        free(added_device_event);
 #endif
+       TRACE_END();
 }
 
 void
@@ -2415,6 +2418,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,
@@ -2426,6 +2431,7 @@ notify_removed_device(struct libinput_device *device)
         * pretend to free it  */
        free(removed_device_event);
 #endif
+       TRACE_END();
 }
 
 static inline bool
@@ -2478,8 +2484,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);
 
@@ -2495,6 +2505,8 @@ keyboard_notify_key(struct libinput_device *device,
        post_device_event(device, time,
                          LIBINPUT_EVENT_KEYBOARD_KEY,
                          &key_event->base);
+
+       TRACE_END();
 }
 
 void
@@ -2505,9 +2517,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) {
@@ -2519,6 +2535,8 @@ pointer_notify_motion(struct libinput_device *device,
        post_device_event(device, time,
                          LIBINPUT_EVENT_POINTER_MOTION,
                          &motion_event->base);
+
+       TRACE_END();
 }
 
 void
@@ -2528,8 +2546,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);
 
@@ -2541,6 +2563,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
@@ -2552,8 +2576,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);
 
@@ -2571,6 +2599,8 @@ pointer_notify_button(struct libinput_device *device,
        post_device_event(device, time,
                          LIBINPUT_EVENT_POINTER_BUTTON,
                          &button_event->base);
+
+       TRACE_END();
 }
 
 void
@@ -2583,8 +2613,12 @@ 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);
 
@@ -2599,6 +2633,8 @@ pointer_notify_axis(struct libinput_device *device,
        post_device_event(device, time,
                          LIBINPUT_EVENT_POINTER_AXIS,
                          &axis_event->base);
+
+       TRACE_END();
 }
 
 void
@@ -2612,8 +2648,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);
 
@@ -2629,6 +2669,8 @@ touch_notify_touch_down(struct libinput_device *device,
        post_device_event(device, time,
                          LIBINPUT_EVENT_TOUCH_DOWN,
                          &touch_event->base);
+
+       TRACE_END();
 }
 
 void
@@ -2642,8 +2684,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);
 
@@ -2659,6 +2705,8 @@ touch_notify_touch_motion(struct libinput_device *device,
        post_device_event(device, time,
                          LIBINPUT_EVENT_TOUCH_MOTION,
                          &touch_event->base);
+
+       TRACE_END();
 }
 
 void
@@ -2669,8 +2717,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);
 
@@ -2683,6 +2735,8 @@ touch_notify_touch_up(struct libinput_device *device,
        post_device_event(device, time,
                          LIBINPUT_EVENT_TOUCH_UP,
                          &touch_event->base);
+
+       TRACE_END();
 }
 
 void