]> git.ipfire.org Git - thirdparty/bird.git/commitdiff
Resource dumps also write out block addresses
authorMaria Matejka <mq@ucw.cz>
Tue, 28 Feb 2023 09:42:47 +0000 (10:42 +0100)
committerMaria Matejka <mq@ucw.cz>
Tue, 4 Apr 2023 15:00:59 +0000 (17:00 +0200)
14 files changed:
lib/event.c
lib/mempool.c
lib/resource.c
lib/resource.h
lib/slab.c
lib/timer.c
nest/config.Y
nest/locks.c
nest/rt-attr.c
nest/rt-table.c
proto/bfd/bfd.c
proto/bgp/attrs.c
sysdep/unix/io.c
sysdep/unix/main.c

index 55e7f4461786a2b0ccba7a6595819f8728cc5bec..68888a4cdef57a7445d2793f425c72099afc19dd 100644 (file)
@@ -168,7 +168,7 @@ ev_postpone(event *e)
 }
 
 static void
-ev_dump(resource *r)
+ev_dump(resource *r, unsigned indent UNUSED)
 {
   event *e = (event *) r;
 
index d10f8f1c218873653cbf306ee1ee4f3a4dd8f415..5200f5e7e2b78f519090a3b1bc77cafe5d591715 100644 (file)
@@ -42,7 +42,7 @@ struct linpool {
 };
 
 static void lp_free(resource *);
-static void lp_dump(resource *);
+static void lp_dump(resource *, unsigned);
 static resource *lp_lookup(resource *, unsigned long);
 static struct resmem lp_memsize(resource *r);
 
@@ -262,11 +262,12 @@ lp_free(resource *r)
 }
 
 static void
-lp_dump(resource *r)
+lp_dump(resource *r, unsigned indent)
 {
   linpool *m = (linpool *) r;
   struct lp_chunk *c;
   int cnt, cntl;
+  char x[32];
 
   for(cnt=0, c=m->first; c; c=c->next, cnt++)
     ;
@@ -277,6 +278,14 @@ lp_dump(resource *r)
        cntl,
        m->total,
        m->total_large);
+
+  bsprintf(x, "%%%dschunk %%p\n", indent + 2);
+  for (c=m->first; c; c=c->next)
+    debug(x, "", c);
+
+  bsprintf(x, "%%%dslarge %%p\n", indent + 2);
+  for (c=m->first_large; c; c=c->next)
+    debug(x, "", c);
 }
 
 static struct resmem
index 2e3671323cb4820812cde62a675429200db35022..94b8d019ecf424efe1afd91742c7fb76367d45fb 100644 (file)
@@ -30,7 +30,7 @@
  * is freed upon shutdown of the module.
  */
 
-static void pool_dump(resource *);
+static void pool_dump(resource *, unsigned);
 static void pool_free(resource *);
 static resource *pool_lookup(resource *, unsigned long);
 static struct resmem pool_memsize(resource *P);
@@ -46,8 +46,6 @@ static struct resclass pool_class = {
 
 pool root_pool;
 
-static int indent;
-
 /**
  * rp_new - create a resource pool
  * @p: parent pool
@@ -95,16 +93,14 @@ pool_free(resource *P)
 }
 
 static void
-pool_dump(resource *P)
+pool_dump(resource *P, unsigned indent)
 {
   pool *p = (pool *) P;
   resource *r;
 
   debug("%s\n", p->name);
-  indent += 3;
   WALK_LIST(r, p->inside)
-    rdump(r);
-  indent -= 3;
+    rdump(r, indent + 3);
 }
 
 static struct resmem
@@ -194,7 +190,7 @@ rfree(void *res)
  * It works by calling a class-specific dump function.
  */
 void
-rdump(void *res)
+rdump(void *res, unsigned indent)
 {
   char x[16];
   resource *r = res;
@@ -204,7 +200,7 @@ rdump(void *res)
   if (r)
     {
       debug("%s ", r->class->name);
-      r->class->dump(r);
+      r->class->dump(r, indent);
     }
   else
     debug("NULL\n");
@@ -264,7 +260,7 @@ rlookup(unsigned long a)
 
   debug("Looking up %08lx\n", a);
   if (r = pool_lookup(&root_pool.r, a))
-    rdump(r);
+    rdump(r, 3);
   else
     debug("Not found.\n");
 }
@@ -331,7 +327,7 @@ static void mbl_free(resource *r UNUSED)
 {
 }
 
-static void mbl_debug(resource *r)
+static void mbl_debug(resource *r, unsigned indent UNUSED)
 {
   struct mblock *m = (struct mblock *) r;
 
index 5d9e2165e402687fb787cddc709bdd1afd69a9f9..911b990d6215cc15bbe07a0a1327ab39e4841202 100644 (file)
@@ -30,7 +30,7 @@ struct resclass {
   char *name;                          /* Resource class name */
   unsigned size;                       /* Standard size of single resource */
   void (*free)(resource *);            /* Freeing function */
-  void (*dump)(resource *);            /* Dump to debug output */
+  void (*dump)(resource *, unsigned indent);           /* Dump to debug output */
   resource *(*lookup)(resource *, unsigned long);      /* Look up address (only for debugging) */
   struct resmem (*memsize)(resource *);        /* Return size of memory used by the resource, may be NULL */
 };
@@ -51,7 +51,7 @@ void resource_init(void);
 pool *rp_new(pool *, const char *);    /* Create new pool */
 pool *rp_newf(pool *, const char *, ...);      /* Create a new pool with a formatted string as its name */
 void rfree(void *);                    /* Free single resource */
-void rdump(void *);                    /* Dump to debug output */
+void rdump(void *, unsigned indent);   /* Dump to debug output */
 struct resmem rmemsize(void *res);             /* Return size of memory used by the resource */
 void rlookup(unsigned long);           /* Look up address (only for debugging) */
 void rmove(void *, pool *);            /* Move to a different pool */
index cf2ecc7043b9f2d996e55a045c7ae6ead7cc66c6..23316e82805c2efb1b191db27ddc8b80786a5523 100644 (file)
@@ -41,7 +41,7 @@
 #endif
 
 static void slab_free(resource *r);
-static void slab_dump(resource *r);
+static void slab_dump(resource *r, unsigned indent);
 static resource *slab_lookup(resource *r, unsigned long addr);
 static struct resmem slab_memsize(resource *r);
 
@@ -118,7 +118,7 @@ slab_free(resource *r)
 }
 
 static void
-slab_dump(resource *r)
+slab_dump(resource *r, unsigned indent UNUSED)
 {
   slab *s = (slab *) r;
   int cnt = 0;
@@ -378,7 +378,7 @@ slab_free(resource *r)
 }
 
 static void
-slab_dump(resource *r)
+slab_dump(resource *r, unsigned indent UNUSED)
 {
   slab *s = (slab *) r;
   int ec=0, pc=0, fc=0;
@@ -390,6 +390,15 @@ slab_dump(resource *r)
   WALK_TLIST(sl_head, h, &s->full_heads)
     fc++;
   debug("(%de+%dp+%df blocks per %d objs per %d bytes)\n", ec, pc, fc, s->objs_per_slab, s->obj_size);
+
+  char x[16];
+  bsprintf(x, "%%%ds%%s %%p\n", indent + 2);
+  WALK_TLIST(sl_head, h, &s->full_heads)
+    debug(x, "", "full", h);
+  WALK_TLIST(sl_head, h, &s->partial_heads)
+    debug(x, "", "partial", h);
+  WALK_TLIST(sl_head, h, &s->empty_heads)
+    debug(x, "", "empty", h);
 }
 
 static struct resmem
index ff6975a4a02bd2002720c9a5ccc26f3815d2574b..4e4aa55eb87480085651c6353762e30b86b5041a 100644 (file)
@@ -58,7 +58,7 @@ tm_free(resource *r)
 }
 
 static void
-tm_dump(resource *r)
+tm_dump(resource *r, unsigned indent UNUSED)
 {
   timer *t = (void *) r;
 
index dc174b7bd1f28bf3fdd51c5d1a0d1983a43624a1..8c3ee8ad11bc6b50e99d9aa462c4a66973b4fb66 100644 (file)
@@ -868,7 +868,7 @@ sym_args:
 
 CF_CLI_HELP(DUMP, ..., [[Dump debugging information]])
 CF_CLI(DUMP RESOURCES,,, [[Dump all allocated resource]])
-{ rdump(&root_pool); cli_msg(0, ""); } ;
+{ rdump(&root_pool, 0); cli_msg(0, ""); } ;
 CF_CLI(DUMP SOCKETS,,, [[Dump open sockets]])
 { sk_dump_all(); cli_msg(0, ""); } ;
 CF_CLI(DUMP EVENTS,,, [[Dump event log]])
index fb245cdcb43405aab21a6b95d360c26051c15108..247d0c569cd7b079ba043331a7021542ecb7b3a7 100644 (file)
@@ -107,7 +107,7 @@ olock_free(resource *r)
 }
 
 static void
-olock_dump(resource *r)
+olock_dump(resource *r, unsigned indent UNUSED)
 {
   struct object_lock *l = (struct object_lock *) r;
   static char *olock_states[] = { "free", "locked", "waiting", "event" };
index 761ec0d9321609c635ed411b3233be911434371c..903926f65c0c053f00eccfc12a763fb6df9c5c04 100644 (file)
@@ -550,7 +550,7 @@ ea_class_ref_free(resource *r)
 }
 
 static void
-ea_class_ref_dump(resource *r)
+ea_class_ref_dump(resource *r, unsigned indent UNUSED)
 {
   struct ea_class_ref *ref = SKIP_BACK(struct ea_class_ref, r, r);
   debug("name \"%s\", type=%d\n", ref->class->name, ref->class->type);
index 8323080212d8cff80e41844277865fd581795552..6be474707f9ef8710c4dd0e9cbbfd74765aaeba8 100644 (file)
@@ -2801,12 +2801,19 @@ rt_free(resource *_r)
 }
 
 static void
-rt_res_dump(resource *_r)
+rt_res_dump(resource *_r, unsigned indent)
 {
   struct rtable_private *r = SKIP_BACK(struct rtable_private, r, _r);
 
   debug("name \"%s\", addr_type=%s, rt_count=%u, use_count=%d\n",
       r->name, net_label[r->addr_type], r->rt_count, r->use_count);
+
+  char x[32];
+  bsprintf(x, "%%%dspending export %%p\n", indent + 2);
+
+  node *n;
+  WALK_LIST(n, r->exporter.pending)
+    debug(x, "", n);
 }
 
 static struct resclass rt_class = {
index 59134a22e7e427eb546baa4562fd4b07335a33db..1ef92b189d63a5a7c334965c2ee65170a5a6cd99 100644 (file)
@@ -860,7 +860,7 @@ bfd_request_free(resource *r)
 }
 
 static void
-bfd_request_dump(resource *r)
+bfd_request_dump(resource *r, unsigned indent UNUSED)
 {
   struct bfd_request *req = (struct bfd_request *) r;
 
index 2f72719faba9695c454a371a15ddaf28cbf1bed4..039fdff52df21dfa2a25ba8de4f9d4df10016608 100644 (file)
@@ -1839,7 +1839,7 @@ bgp_pending_tx_rfree(resource *r)
   HASH_WALK_END;
 }
 
-static void bgp_pending_tx_dump(resource *r UNUSED) { debug("\n"); }
+static void bgp_pending_tx_dump(resource *r UNUSED, unsigned indent UNUSED) { debug("\n"); }
 
 static struct resclass bgp_pending_tx_class = {
   .name = "BGP Pending TX",
index fc1586ff74073c4246b5446d87b3d94117894fc1..78908676100697f187583cf3b085578d30c018e3 100644 (file)
@@ -76,7 +76,7 @@ rf_free(resource *r)
 }
 
 static void
-rf_dump(resource *r)
+rf_dump(resource *r, unsigned indent UNUSED)
 {
   struct rfile *a = (struct rfile *) r;
 
@@ -862,7 +862,7 @@ sk_reallocate(sock *s)
 }
 
 static void
-sk_dump(resource *r)
+sk_dump(resource *r, unsigned indent UNUSED)
 {
   sock *s = (sock *) r;
   static char *sk_type_names[] = { "TCP<", "TCP>", "TCP", "UDP", NULL, "IP", NULL, "MAGIC", "UNIX<", "UNIX", "SSH>", "SSH", "DEL!" };
@@ -2053,7 +2053,7 @@ sk_dump_all(void)
   {
     s = SKIP_BACK(sock, n, n);
     debug("%p ", s);
-    sk_dump(&s->r);
+    sk_dump(&s->r, 3);
   }
   debug("\n");
 }
index ab076af6642d64912e6c0c184d75703856cb7ce3..a9ae842ad57299b793198fd0c50215f5d0330219 100644 (file)
@@ -52,7 +52,7 @@ async_dump(void)
 {
   debug("INTERNAL STATE DUMP\n\n");
 
-  rdump(&root_pool);
+  rdump(&root_pool, 0);
   sk_dump_all();
   // XXXX tm_dump_all();
   if_dump_all();