1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
|
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
|