Improved the filter capabilities of the "ports", "port", "sems", and "areas" debugger commands.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@16870 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler 2006-03-24 12:59:23 +00:00
parent 45fd48cd1e
commit 5ba2a3839d
3 changed files with 103 additions and 36 deletions

View File

@ -82,8 +82,8 @@ static spinlock sPortSpinlock = 0;
status_t
port_init(kernel_args *args)
{
int i;
int size = sizeof(struct port_entry) * sMaxPorts;
size_t size = sizeof(struct port_entry) * sMaxPorts;
int32 i;
// create and initialize ports table
sPortArea = create_area("port_table", (void **)&sPorts, B_ANY_KERNEL_ADDRESS,
@ -218,11 +218,29 @@ port_test_thread_func(void *arg)
int
dump_port_list(int argc, char **argv)
{
int i;
const char *name = NULL;
team_id owner = -1;
int32 i;
if (argc > 2) {
if (!strcmp(argv[1], "team") || !strcmp(argv[1], "owner"))
owner = strtoul(argv[2], NULL, 0);
else if (!strcmp(argv[1], "name"))
name = argv[2];
} else if (argc > 1)
owner = strtoul(argv[1], NULL, 0);
kprintf("port id cap r-sem w-sem team name\n");
for (i = 0; i < sMaxPorts; i++) {
if (sPorts[i].id >= 0)
kprintf("%p\tid: 0x%lx\t\tname: '%s'\n", &sPorts[i], sPorts[i].id, sPorts[i].name);
struct port_entry *port = &sPorts[i];
if (port->id < 0
|| (owner != -1 && port->owner != owner)
|| (name != NULL && strstr(port->name, name) == NULL))
continue;
kprintf("%p %6lx %4ld %6lx %6lx %6lx %s\n", port, port->id, port->capacity,
port->read_sem, port->write_sem, port->owner, port->name);
}
return 0;
}
@ -251,41 +269,45 @@ _dump_port_info(struct port_entry *port)
static int
dump_port_info(int argc, char **argv)
{
const char *name = NULL;
sem_id sem = -1;
int i;
if (argc < 2) {
kprintf("usage: port [id|name|address]\n");
kprintf("usage: port [id|name|sem|address]\n");
return 0;
}
// if the argument looks like a number, treat it as such
if (isdigit(argv[1][0])) {
uint32 num = strtoul(argv[1], NULL, 0);
if (num > KERNEL_BASE && num <= (KERNEL_BASE + (KERNEL_SIZE - 1))) {
// XXX semi-hack
// one can use either address or a port_id, since KERNEL_BASE > sMaxPorts assumed
_dump_port_info((struct port_entry *)num);
if (argc > 2) {
if (!strcmp(argv[1], "address")) {
_dump_port_info((struct port_entry *)strtoul(argv[2], NULL, 0));
return 0;
} else {
unsigned slot = num % sMaxPorts;
if (sPorts[slot].id != (int)num) {
kprintf("port 0x%lx doesn't exist!\n", num);
return 0;
}
_dump_port_info(&sPorts[slot]);
} else if (!strcmp(argv[1], "sem"))
sem = strtoul(argv[2], NULL, 0);
else if (!strcmp(argv[1], "name"))
name = argv[2];
} else if (isdigit(argv[1][0])) {
// if the argument looks like a number, treat it as such
uint32 num = strtoul(argv[1], NULL, 0);
uint32 slot = num % sMaxPorts;
if (sPorts[slot].id != (int)num) {
kprintf("port 0x%lx doesn't exist!\n", num);
return 0;
}
}
_dump_port_info(&sPorts[slot]);
return 0;
} else
name = argv[1];
// walk through the ports list, trying to match name
for (i = 0; i < sMaxPorts; i++) {
if (sPorts[i].name != NULL
&& strcmp(argv[1], sPorts[i].name) == 0) {
if ((name != NULL && sPorts[i].name != NULL && !strcmp(name, sPorts[i].name))
|| (sem != -1 && (sPorts[i].read_sem == sem || sPorts[i].write_sem == sem))) {
_dump_port_info(&sPorts[i]);
return 0;
}
}
return 0;
}

View File

@ -44,7 +44,7 @@ struct sem_entry {
union {
// when slot in use
struct {
int count;
int32 count;
struct thread_queue queue;
char *name;
team_id owner; // if set to -1, means owned by a port
@ -81,22 +81,62 @@ static int remove_thread_from_sem(struct thread *thread, struct sem_entry *sem,
struct thread_queue *queue, status_t acquireStatus);
struct sem_timeout_args {
thread_id blocked_thread;
sem_id blocked_sem_id;
int sem_count;
thread_id blocked_thread;
sem_id blocked_sem_id;
int32 sem_count;
};
static int
dump_sem_list(int argc, char **argv)
{
int i;
const char *name = NULL;
team_id owner = -1;
#ifdef DEBUG_LAST_ACQUIRER
thread_id last = -1;
#endif
int32 i;
if (argc > 2) {
if (!strcmp(argv[1], "team") || !strcmp(argv[1], "owner"))
owner = strtoul(argv[2], NULL, 0);
else if (!strcmp(argv[1], "name"))
name = argv[2];
#ifdef DEBUG_LAST_ACQUIRER
else if (!strcmp(argv[1], "last"))
last = strtoul(argv[2], NULL, 0);
#endif
} else if (argc > 1)
owner = strtoul(argv[1], NULL, 0);
kprintf("sem id count team"
#ifdef DEBUG_LAST_ACQUIRER
" last"
#endif
" name\n");
for (i = 0; i < sMaxSems; i++) {
if (sSems[i].id >= 0)
kprintf("%p\tid: 0x%lx\t\tname: '%s'\n", &sSems[i], sSems[i].id,
sSems[i].u.used.name);
struct sem_entry *sem = &sSems[i];
if (sem->id < 0
#ifdef DEBUG_LAST_ACQUIRER
|| (last != -1 && sem->u.used.last_acquirer != last)
#endif
|| (name != NULL && strstr(sem->u.used.name, name) == NULL)
|| (owner != -1 && sem->u.used.owner != owner))
continue;
kprintf("%p %6lx %5ld %6lx "
#ifdef DEBUG_LAST_ACQUIRER
"%6lx "
#endif
" %s\n", sem, sem->id, sem->u.used.count,
sem->u.used.owner,
#ifdef DEBUG_LAST_ACQUIRER
sem->u.used.last_acquirer > 0 ? sem->u.used.last_acquirer : 0,
#endif
sem->u.used.name);
}
return 0;
}
@ -109,7 +149,7 @@ dump_sem(struct sem_entry *sem)
if (sem->id >= 0) {
kprintf("name: '%s'\n", sem->u.used.name);
kprintf("owner: 0x%lx\n", sem->u.used.owner);
kprintf("count: 0x%x\n", sem->u.used.count);
kprintf("count: 0x%lx\n", sem->u.used.count);
kprintf("queue: head %p tail %p\n", sem->u.used.queue.head,
sem->u.used.queue.tail);
#ifdef DEBUG_LAST_ACQUIRER

View File

@ -1946,16 +1946,21 @@ dump_area_list(int argc, char **argv)
{
vm_area *area;
struct hash_iterator iter;
int32 id = -1;
const char *name = NULL;
int32 id = 0;
if (argc > 1)
if (argc > 1) {
id = strtoul(argv[1], NULL, 0);
if (id == 0)
name = argv[1];
}
kprintf("addr id base\t\tsize protect lock name\n");
hash_open(sAreaHash, &iter);
while ((area = (vm_area *)hash_next(sAreaHash, &iter)) != NULL) {
if (id != -1 && area->address_space->id != id)
if (id != 0 && area->address_space->id != id
|| name != NULL && strstr(area->name, name) == NULL)
continue;
kprintf("%p %5lx %p\t%p %4lx\t%4d %s\n", area, area->id, (void *)area->base,