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:
+42
-20
@@ -82,8 +82,8 @@ static spinlock sPortSpinlock = 0;
|
|||||||
status_t
|
status_t
|
||||||
port_init(kernel_args *args)
|
port_init(kernel_args *args)
|
||||||
{
|
{
|
||||||
int i;
|
size_t size = sizeof(struct port_entry) * sMaxPorts;
|
||||||
int size = sizeof(struct port_entry) * sMaxPorts;
|
int32 i;
|
||||||
|
|
||||||
// create and initialize ports table
|
// create and initialize ports table
|
||||||
sPortArea = create_area("port_table", (void **)&sPorts, B_ANY_KERNEL_ADDRESS,
|
sPortArea = create_area("port_table", (void **)&sPorts, B_ANY_KERNEL_ADDRESS,
|
||||||
@@ -218,11 +218,29 @@ port_test_thread_func(void *arg)
|
|||||||
int
|
int
|
||||||
dump_port_list(int argc, char **argv)
|
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++) {
|
for (i = 0; i < sMaxPorts; i++) {
|
||||||
if (sPorts[i].id >= 0)
|
struct port_entry *port = &sPorts[i];
|
||||||
kprintf("%p\tid: 0x%lx\t\tname: '%s'\n", &sPorts[i], sPorts[i].id, sPorts[i].name);
|
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;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -251,41 +269,45 @@ _dump_port_info(struct port_entry *port)
|
|||||||
static int
|
static int
|
||||||
dump_port_info(int argc, char **argv)
|
dump_port_info(int argc, char **argv)
|
||||||
{
|
{
|
||||||
|
const char *name = NULL;
|
||||||
|
sem_id sem = -1;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
if (argc < 2) {
|
if (argc < 2) {
|
||||||
kprintf("usage: port [id|name|address]\n");
|
kprintf("usage: port [id|name|sem|address]\n");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// if the argument looks like a number, treat it as such
|
if (argc > 2) {
|
||||||
if (isdigit(argv[1][0])) {
|
if (!strcmp(argv[1], "address")) {
|
||||||
uint32 num = strtoul(argv[1], NULL, 0);
|
_dump_port_info((struct port_entry *)strtoul(argv[2], 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);
|
|
||||||
return 0;
|
return 0;
|
||||||
} else {
|
} else if (!strcmp(argv[1], "sem"))
|
||||||
unsigned slot = num % sMaxPorts;
|
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) {
|
if (sPorts[slot].id != (int)num) {
|
||||||
kprintf("port 0x%lx doesn't exist!\n", num);
|
kprintf("port 0x%lx doesn't exist!\n", num);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
_dump_port_info(&sPorts[slot]);
|
_dump_port_info(&sPorts[slot]);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
} else
|
||||||
}
|
name = argv[1];
|
||||||
|
|
||||||
// walk through the ports list, trying to match name
|
// walk through the ports list, trying to match name
|
||||||
for (i = 0; i < sMaxPorts; i++) {
|
for (i = 0; i < sMaxPorts; i++) {
|
||||||
if (sPorts[i].name != NULL
|
if ((name != NULL && sPorts[i].name != NULL && !strcmp(name, sPorts[i].name))
|
||||||
&& strcmp(argv[1], sPorts[i].name) == 0) {
|
|| (sem != -1 && (sPorts[i].read_sem == sem || sPorts[i].write_sem == sem))) {
|
||||||
_dump_port_info(&sPorts[i]);
|
_dump_port_info(&sPorts[i]);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+47
-7
@@ -44,7 +44,7 @@ struct sem_entry {
|
|||||||
union {
|
union {
|
||||||
// when slot in use
|
// when slot in use
|
||||||
struct {
|
struct {
|
||||||
int count;
|
int32 count;
|
||||||
struct thread_queue queue;
|
struct thread_queue queue;
|
||||||
char *name;
|
char *name;
|
||||||
team_id owner; // if set to -1, means owned by a port
|
team_id owner; // if set to -1, means owned by a port
|
||||||
@@ -83,20 +83,60 @@ static int remove_thread_from_sem(struct thread *thread, struct sem_entry *sem,
|
|||||||
struct sem_timeout_args {
|
struct sem_timeout_args {
|
||||||
thread_id blocked_thread;
|
thread_id blocked_thread;
|
||||||
sem_id blocked_sem_id;
|
sem_id blocked_sem_id;
|
||||||
int sem_count;
|
int32 sem_count;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
dump_sem_list(int argc, char **argv)
|
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++) {
|
for (i = 0; i < sMaxSems; i++) {
|
||||||
if (sSems[i].id >= 0)
|
struct sem_entry *sem = &sSems[i];
|
||||||
kprintf("%p\tid: 0x%lx\t\tname: '%s'\n", &sSems[i], sSems[i].id,
|
if (sem->id < 0
|
||||||
sSems[i].u.used.name);
|
#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;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -109,7 +149,7 @@ dump_sem(struct sem_entry *sem)
|
|||||||
if (sem->id >= 0) {
|
if (sem->id >= 0) {
|
||||||
kprintf("name: '%s'\n", sem->u.used.name);
|
kprintf("name: '%s'\n", sem->u.used.name);
|
||||||
kprintf("owner: 0x%lx\n", sem->u.used.owner);
|
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,
|
kprintf("queue: head %p tail %p\n", sem->u.used.queue.head,
|
||||||
sem->u.used.queue.tail);
|
sem->u.used.queue.tail);
|
||||||
#ifdef DEBUG_LAST_ACQUIRER
|
#ifdef DEBUG_LAST_ACQUIRER
|
||||||
|
|||||||
@@ -1946,16 +1946,21 @@ dump_area_list(int argc, char **argv)
|
|||||||
{
|
{
|
||||||
vm_area *area;
|
vm_area *area;
|
||||||
struct hash_iterator iter;
|
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);
|
id = strtoul(argv[1], NULL, 0);
|
||||||
|
if (id == 0)
|
||||||
|
name = argv[1];
|
||||||
|
}
|
||||||
|
|
||||||
kprintf("addr id base\t\tsize protect lock name\n");
|
kprintf("addr id base\t\tsize protect lock name\n");
|
||||||
|
|
||||||
hash_open(sAreaHash, &iter);
|
hash_open(sAreaHash, &iter);
|
||||||
while ((area = (vm_area *)hash_next(sAreaHash, &iter)) != NULL) {
|
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;
|
continue;
|
||||||
|
|
||||||
kprintf("%p %5lx %p\t%p %4lx\t%4d %s\n", area, area->id, (void *)area->base,
|
kprintf("%p %5lx %p\t%p %4lx\t%4d %s\n", area, area->id, (void *)area->base,
|
||||||
|
|||||||
Reference in New Issue
Block a user