[PATCH wayland] debug: add timestamps when logging

laszlo.p.agocs at nokia.com laszlo.p.agocs at nokia.com
Mon Jul 18 01:01:49 PDT 2011


Doesn't clock_gettime need -lrt? Otherwise (on Ubuntu at least) the linker will complain about an undefined reference in libwayland-client.so when building wayland apps.

Laszlo


-----Original Message-----
From: wayland-devel-bounces+laszlo.p.agocs=nokia.com at lists.freedesktop.org [mailto:wayland-devel-bounces+laszlo.p.agocs=nokia.com at lists.freedesktop.org] On Behalf Of ext Kristian Høgsberg
Sent: 15 July 2011 22:09
To: Tiago Vignatti
Cc: wayland-devel at lists.freedesktop.org
Subject: Re: [PATCH wayland] debug: add timestamps when logging

On Thu, Jul 14, 2011 at 11:56 AM, Tiago Vignatti
<tiago.vignatti at intel.com> wrote:
> Signed-off-by: Tiago Vignatti <tiago.vignatti at intel.com>
> ---
>  wayland/connection.c     |   16 ++++++++++++++--
>  wayland/connection.h     |    2 +-
>  wayland/wayland-client.c |    9 ++++-----
>  wayland/wayland-server.c |    9 ++++-----
>  4 files changed, 23 insertions(+), 13 deletions(-)

Yeah, that's useful, comitted.

Kristian

> diff --git a/wayland/connection.c b/wayland/connection.c
> index 0f2051a..4f6a845 100644
> --- a/wayland/connection.c
> +++ b/wayland/connection.c
> @@ -34,6 +34,7 @@
>  #include <unistd.h>
>  #include <sys/types.h>
>  #include <sys/socket.h>
> +#include <time.h>
>
>  #include "wayland-util.h"
>  #include "connection.h"
> @@ -684,12 +685,23 @@ wl_closure_send(struct wl_closure *closure, struct wl_connection *connection)
>  }
>
>  void
> -wl_closure_print(struct wl_closure *closure, struct wl_object *target)
> +wl_closure_print(struct wl_closure *closure, struct wl_object *target, int send)
>  {
>        union wl_value *value;
> +       char buffer[4] = "\0";
>        int i;
> +       struct timespec tp;
> +       unsigned int time;
>
> -       fprintf(stderr, "%s@%d.%s(",
> +       if (send)
> +               sprintf(buffer, " -> ");
> +
> +       clock_gettime(CLOCK_REALTIME, &tp);
> +       time = (tp.tv_sec * 1000000L) + (tp.tv_nsec / 1000);
> +
> +       fprintf(stderr, "[%10.3f] %s%s@%d.%s(",
> +               time / 1000.0,
> +               buffer,
>                target->interface->name, target->id,
>                closure->message->name);
>
> diff --git a/wayland/connection.h b/wayland/connection.h
> index 413977d..5f4588b 100644
> --- a/wayland/connection.h
> +++ b/wayland/connection.h
> @@ -61,7 +61,7 @@ wl_closure_invoke(struct wl_closure *closure,
>  void
>  wl_closure_send(struct wl_closure *closure, struct wl_connection *connection);
>  void
> -wl_closure_print(struct wl_closure *closure, struct wl_object *target);
> +wl_closure_print(struct wl_closure *closure, struct wl_object *target, int send);
>  void
>  wl_closure_destroy(struct wl_closure *closure);
>
> diff --git a/wayland/wayland-client.c b/wayland/wayland-client.c
> index e8266e1..ce27a90 100644
> --- a/wayland/wayland-client.c
> +++ b/wayland/wayland-client.c
> @@ -24,6 +24,7 @@
>  #include <stdint.h>
>  #include <stddef.h>
>  #include <stdio.h>
> +#include <stdbool.h>
>  #include <errno.h>
>  #include <string.h>
>  #include <unistd.h>
> @@ -201,10 +202,8 @@ wl_proxy_marshal(struct wl_proxy *proxy, uint32_t opcode, ...)
>
>        wl_closure_send(closure, proxy->display->connection);
>
> -       if (wl_debug) {
> -               fprintf(stderr, " -> ");
> -               wl_closure_print(closure, &proxy->object);
> -       }
> +       if (wl_debug)
> +               wl_closure_print(closure, &proxy->object, true);
>
>        wl_closure_destroy(closure);
>  }
> @@ -523,7 +522,7 @@ handle_event(struct wl_display *display,
>                                          size, display->objects, message);
>
>        if (wl_debug)
> -               wl_closure_print(closure, &proxy->object);
> +               wl_closure_print(closure, &proxy->object, false);
>
>        wl_closure_invoke(closure, &proxy->object,
>                          proxy->object.implementation[opcode],
> diff --git a/wayland/wayland-server.c b/wayland/wayland-server.c
> index 176859b..d4fdfc7 100644
> --- a/wayland/wayland-server.c
> +++ b/wayland/wayland-server.c
> @@ -27,6 +27,7 @@
>  #include <stddef.h>
>  #include <stdio.h>
>  #include <stdarg.h>
> +#include <stdbool.h>
>  #include <errno.h>
>  #include <string.h>
>  #include <unistd.h>
> @@ -108,10 +109,8 @@ wl_client_post_event(struct wl_client *client, struct wl_object *sender,
>
>        wl_closure_send(closure, client->connection);
>
> -       if (wl_debug) {
> -               fprintf(stderr, " -> ");
> -               wl_closure_print(closure, sender);
> -       }
> +       if (wl_debug)
> +               wl_closure_print(closure, sender, true);
>
>        wl_closure_destroy(closure);
>  }
> @@ -202,7 +201,7 @@ wl_client_connection_data(int fd, uint32_t mask, void *data)
>
>
>                if (wl_debug)
> -                       wl_closure_print(closure, object);
> +                       wl_closure_print(closure, object, false);
>
>                wl_closure_invoke(closure, object,
>                                  object->implementation[opcode], client);
> --
> 1.7.2.2
>
> _______________________________________________
> wayland-devel mailing list
> wayland-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/wayland-devel
>
_______________________________________________
wayland-devel mailing list
wayland-devel at lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/wayland-devel


More information about the wayland-devel mailing list