Add protocol debugging facility

dev
Kristian Høgsberg 14 years ago
parent b6eb39710d
commit f1e7bd384c
  1. 43
      connection.c
  2. 2
      connection.h
  3. 11
      wayland-server.c

@ -563,6 +563,49 @@ wl_closure_invoke(struct wl_closure *closure,
ffi_call(&closure->cif, func, &result, closure->args);
}
void
wl_closure_print(struct wl_closure *closure, struct wl_object *target)
{
struct wl_object *object;
int i;
fprintf(stderr, "%s(%d).%s(",
target->interface->name, target->id,
closure->message->name);
for (i = 2; i < closure->count; i++) {
if (i > 2)
fprintf(stderr, ", ");
switch (closure->message->signature[i - 2]) {
case 'u':
fprintf(stderr, "%u", closure->values[i].uint32);
break;
case 'i':
fprintf(stderr, "%d", closure->values[i].uint32);
break;
case 's':
fprintf(stderr, "\"%s\"", closure->values[i].string);
break;
case 'o':
object = closure->values[i].object;
fprintf(stderr, "object %u", object ? object->id : 0);
break;
case 'n':
fprintf(stderr, "new id %u",
closure->values[i].uint32);
break;
case 'a':
fprintf(stderr, "array");
break;
case 'h':
fprintf(stderr, "fd %d", closure->values[i].uint32);
break;
}
}
fprintf(stderr, ")\n");
}
void
wl_closure_destroy(struct wl_closure *closure)
{

@ -58,6 +58,8 @@ void
wl_closure_invoke(struct wl_closure *closure,
struct wl_object *target, void (*func)(void), void *data);
void
wl_closure_print(struct wl_closure *closure, struct wl_object *target);
void
wl_closure_destroy(struct wl_closure *closure);
#endif

@ -73,6 +73,8 @@ struct wl_global {
WL_EXPORT struct wl_surface wl_grab_surface;
static int wl_debug = 0;
WL_EXPORT void
wl_client_post_event(struct wl_client *client, struct wl_object *sender,
uint32_t opcode, ...)
@ -149,6 +151,10 @@ wl_client_connection_data(int fd, uint32_t mask, void *data)
continue;
}
if (wl_debug)
wl_closure_print(closure, object);
wl_closure_invoke(closure, object,
object->implementation[opcode], client);
@ -331,6 +337,11 @@ WL_EXPORT struct wl_display *
wl_display_create(void)
{
struct wl_display *display;
const char *debug;
debug = getenv("WAYLAND_DEBUG");
if (debug)
wl_debug = 1;
display = malloc(sizeof *display);
if (display == NULL)

Loading…
Cancel
Save