summaryrefslogtreecommitdiff
path: root/lib/resource.c
diff options
context:
space:
mode:
authorMartin Mares <mj@ucw.cz>2000-05-08 22:33:38 +0000
committerMartin Mares <mj@ucw.cz>2000-05-08 22:33:38 +0000
commitc976342828d5de3d16b59d623f4f7fb03f52acc9 (patch)
tree4c36b20465c2d7d65e248c14e718e778a5efef60 /lib/resource.c
parent0521e4f68490d5ef5cc6ba6b2b4e4edf7cf6aa1a (diff)
Implemented debugging function rlookup() which you can call from gdb
to see what resource does the address given as a parameter belong to.
Diffstat (limited to 'lib/resource.c')
-rw-r--r--lib/resource.c39
1 files changed, 38 insertions, 1 deletions
diff --git a/lib/resource.c b/lib/resource.c
index e67c05a5..3cfd0658 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)
{
@@ -112,6 +126,18 @@ ralloc(pool *p, struct resclass *c)
}
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)
{
root_pool.r.class = &pool_class;
@@ -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 *