From c976342828d5de3d16b59d623f4f7fb03f52acc9 Mon Sep 17 00:00:00 2001 From: Martin Mares Date: Mon, 8 May 2000 22:33:38 +0000 Subject: Implemented debugging function rlookup() which you can call from gdb to see what resource does the address given as a parameter belong to. --- lib/resource.c | 39 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) (limited to 'lib/resource.c') diff --git a/lib/resource.c b/lib/resource.c index e67c05a..3cfd065 100644 --- a/lib/resource.c +++ b/lib/resource.c @@ -21,12 +21,14 @@ struct pool { static void pool_dump(resource *); static void pool_free(resource *); +static resource *pool_lookup(resource *, unsigned long); static struct resclass pool_class = { "Pool", sizeof(pool), pool_free, - pool_dump + pool_dump, + pool_lookup }; pool root_pool; @@ -70,6 +72,18 @@ pool_dump(resource *P) indent -= 3; } +static resource * +pool_lookup(resource *P, unsigned long a) +{ + pool *p = (pool *) P; + resource *r, *q; + + WALK_LIST(r, p->inside) + if (r->class->lookup && (q = r->class->lookup(r, a))) + return q; + return NULL; +} + void rfree(void *res) { @@ -111,6 +125,18 @@ ralloc(pool *p, struct resclass *c) return r; } +void +rlookup(unsigned long a) +{ + resource *r; + + debug("Looking up %08lx\n", a); + if (r = pool_lookup(&root_pool.r, a)) + rdump(r); + else + debug("Not found.\n"); +} + void resource_init(void) { @@ -140,11 +166,22 @@ static void mbl_debug(resource *r) debug("(size=%d)\n", m->size); } +static resource * +mbl_lookup(resource *r, unsigned long a) +{ + struct mblock *m = (struct mblock *) r; + + if ((unsigned long) m->data <= a && (unsigned long) m->data + m->size > a) + return r; + return NULL; +} + static struct resclass mb_class = { "Memory", 0, mbl_free, mbl_debug, + mbl_lookup }; void * -- cgit v1.2.3