From 12cf4cc389aad578a86d0891ab57d31250fc1d65 Mon Sep 17 00:00:00 2001 From: Justus Winter <4winter@informatik.uni-hamburg.de> Date: Sun, 27 Sep 2015 16:49:32 +0200 Subject: [PATCH hurd 9/9] pflocal: annotate objects managed by libports Label buckets and classes, and provide functions to print a human-readable description of the in use objects. * pflocal/sock.c (sock_user_debug_info): New function. (addr_debug_info): Likewise. (sock_global_init): Label bucket and classes. --- pflocal/sock.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/pflocal/sock.c b/pflocal/sock.c index ef70d2c..c02163a 100644 --- a/pflocal/sock.c +++ b/pflocal/sock.c @@ -181,6 +181,18 @@ sock_user_clean (void *vuser) sock_deref (user->sock); } +/* Provide a human-readable description of the given sock_user object. */ +static error_t +sock_user_debug_info (const void *vuser, char *buffer, size_t size) +{ + struct sock_user *user = vuser; + snprintf (buffer, size, + "bucket: %s, class: %s, sock{refs: %d}", + user->pi.bucket->label, user->pi.class->label, + user->sock->refs); + return 0; +} + /* Return a new user port on SOCK in PORT. */ error_t sock_create_port (struct sock *sock, mach_port_t *port) @@ -252,6 +264,17 @@ addr_clean (void *vaddr) assert (addr->sock == NULL); } +/* Provide a human-readable description of the given sock_user object. */ +static error_t +addr_debug_info (const void *vaddr, char *buffer, size_t size) +{ + struct addr *addr = vaddr; + snprintf (buffer, size, + "bucket: %s, class: %s", + addr->pi.bucket->label, addr->pi.class->label); + return 0; +} + /* Return a new address, not connected to any socket yet, ADDR. */ inline error_t addr_create (struct addr **addr) @@ -491,8 +514,13 @@ error_t sock_global_init () { sock_port_bucket = ports_create_bucket (); + ports_label_bucket (sock_port_bucket, "sock_port_bucket"); sock_user_port_class = ports_create_class (sock_user_clean, NULL); + ports_label_class (sock_user_port_class, "sock_user_port_class", + sock_user_debug_info); addr_port_class = ports_create_class (addr_clean, addr_unbind); + ports_label_class (addr_port_class, "addr_port_class", + addr_debug_info); return 0; } -- 2.1.4