* Added thread block type constant for rw_locks, so that they are listed
correctly by the "thread" and "threads" debugger commands. * Added "rwlock" debugger command. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26703 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
0f9aa9c245
commit
12c9f1761f
@ -57,6 +57,7 @@ enum {
|
||||
THREAD_BLOCK_TYPE_SNOOZE = 2,
|
||||
THREAD_BLOCK_TYPE_SIGNAL = 3,
|
||||
THREAD_BLOCK_TYPE_MUTEX = 4,
|
||||
THREAD_BLOCK_TYPE_RW_LOCK = 5,
|
||||
|
||||
THREAD_BLOCK_TYPE_OTHER = 9999,
|
||||
THREAD_BLOCK_TYPE_USER_BASE = 10000
|
||||
|
@ -168,7 +168,7 @@ rw_lock_wait(rw_lock* lock, bool writer)
|
||||
lock->waiters->last = &waiter;
|
||||
|
||||
// block
|
||||
thread_prepare_to_block(waiter.thread, 0, THREAD_BLOCK_TYPE_MUTEX, lock);
|
||||
thread_prepare_to_block(waiter.thread, 0, THREAD_BLOCK_TYPE_RW_LOCK, lock);
|
||||
return thread_block_locked(waiter.thread);
|
||||
}
|
||||
|
||||
@ -381,6 +381,41 @@ rw_lock_write_unlock(rw_lock* lock)
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
dump_rw_lock_info(int argc, char** argv)
|
||||
{
|
||||
if (argc < 2) {
|
||||
print_debugger_command_usage(argv[0]);
|
||||
return 0;
|
||||
}
|
||||
|
||||
rw_lock* lock = (rw_lock*)strtoul(argv[1], NULL, 0);
|
||||
|
||||
if (!IS_KERNEL_ADDRESS(lock)) {
|
||||
kprintf("invalid address: %p\n", lock);
|
||||
return 0;
|
||||
}
|
||||
|
||||
kprintf("rw lock %p:\n", lock);
|
||||
kprintf(" name: %s\n", lock->name);
|
||||
kprintf(" holder: %ld\n", lock->holder);
|
||||
kprintf(" reader count: %ld\n", lock->reader_count);
|
||||
kprintf(" writer count: %ld\n", lock->writer_count);
|
||||
kprintf(" owner count: %ld\n", lock->owner_count);
|
||||
kprintf(" flags: %#lx\n", lock->flags);
|
||||
|
||||
kprintf(" waiting threads:");
|
||||
rw_lock_waiter* waiter = lock->waiters;
|
||||
while (waiter != NULL) {
|
||||
kprintf(" %ld/%c", waiter->thread->id, waiter->writer ? 'w' : 'r');
|
||||
waiter = waiter->next;
|
||||
}
|
||||
kputs("\n");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
// #pragma mark -
|
||||
|
||||
|
||||
@ -623,4 +658,9 @@ lock_debug_init()
|
||||
"<mutex>\n"
|
||||
"Prints info about the specified mutex.\n"
|
||||
" <mutex> - pointer to the mutex to print the info for.\n", 0);
|
||||
add_debugger_command_etc("rwlock", &dump_rw_lock_info,
|
||||
"Dump info about an rw lock",
|
||||
"<lock>\n"
|
||||
"Prints info about the specified rw lock.\n"
|
||||
" <lock> - pointer to the rw lock to print the info for.\n", 0);
|
||||
}
|
||||
|
@ -1050,9 +1050,9 @@ _dump_thread_info(struct thread *thread)
|
||||
thread->sig_block_mask);
|
||||
kprintf("in_kernel: %d\n", thread->in_kernel);
|
||||
|
||||
kprintf("waiting for: ");
|
||||
|
||||
if (thread->state == B_THREAD_WAITING) {
|
||||
kprintf("waiting for: ");
|
||||
|
||||
switch (thread->wait.type) {
|
||||
case THREAD_BLOCK_TYPE_SEMAPHORE:
|
||||
{
|
||||
@ -1080,6 +1080,10 @@ _dump_thread_info(struct thread *thread)
|
||||
kprintf("mutex %p\n", thread->wait.object);
|
||||
break;
|
||||
|
||||
case THREAD_BLOCK_TYPE_RW_LOCK:
|
||||
kprintf("rwlock %p\n", thread->wait.object);
|
||||
break;
|
||||
|
||||
case THREAD_BLOCK_TYPE_OTHER:
|
||||
kprintf("other (%s)\n", (char*)thread->wait.object);
|
||||
break;
|
||||
@ -1209,7 +1213,7 @@ dump_thread_list(int argc, char **argv)
|
||||
kprintf("ignoring invalid team argument.\n");
|
||||
}
|
||||
|
||||
kprintf("thread id state wait for object cpu pri stack "
|
||||
kprintf("thread id state wait for object cpu pri stack "
|
||||
" team name\n");
|
||||
|
||||
hash_open(sThreadHash, &i);
|
||||
@ -1233,14 +1237,14 @@ dump_thread_list(int argc, char **argv)
|
||||
{
|
||||
sem_id sem = (sem_id)(addr_t)thread->wait.object;
|
||||
if (sem == thread->msg.read_sem)
|
||||
kprintf(" ");
|
||||
kprintf(" ");
|
||||
else
|
||||
kprintf("sem %12ld ", sem);
|
||||
kprintf("sem %12ld ", sem);
|
||||
break;
|
||||
}
|
||||
|
||||
case THREAD_BLOCK_TYPE_CONDITION_VARIABLE:
|
||||
kprintf("cvar %p ", thread->wait.object);
|
||||
kprintf("cvar %p ", thread->wait.object);
|
||||
break;
|
||||
|
||||
case THREAD_BLOCK_TYPE_SNOOZE:
|
||||
@ -1248,23 +1252,27 @@ dump_thread_list(int argc, char **argv)
|
||||
break;
|
||||
|
||||
case THREAD_BLOCK_TYPE_SIGNAL:
|
||||
kprintf("signal ");
|
||||
kprintf("signal ");
|
||||
break;
|
||||
|
||||
case THREAD_BLOCK_TYPE_MUTEX:
|
||||
kprintf("mutex %p ", thread->wait.object);
|
||||
kprintf("mutex %p ", thread->wait.object);
|
||||
break;
|
||||
|
||||
case THREAD_BLOCK_TYPE_RW_LOCK:
|
||||
kprintf("rwlock %p ", thread->wait.object);
|
||||
break;
|
||||
|
||||
case THREAD_BLOCK_TYPE_OTHER:
|
||||
kprintf("other ");
|
||||
kprintf("other ");
|
||||
break;
|
||||
|
||||
default:
|
||||
kprintf("??? %p ", thread->wait.object);
|
||||
kprintf("??? %p ", thread->wait.object);
|
||||
break;
|
||||
}
|
||||
} else
|
||||
kprintf(" - ");
|
||||
kprintf(" - ");
|
||||
|
||||
// on which CPU does it run?
|
||||
if (thread->cpu)
|
||||
|
Loading…
Reference in New Issue
Block a user