mirror of
https://gitlab.labs.nic.cz/labs/bird.git
synced 2024-05-11 16:54:54 +00:00
Implemented debugging function rlookup() which you can call from gdb
to see what resource does the address given as a parameter belong to.
This commit is contained in:
@@ -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 *
|
||||
|
Reference in New Issue
Block a user