diff options
author | jhb <jhb@FreeBSD.org> | 2006-08-15 16:42:16 +0000 |
---|---|---|
committer | jhb <jhb@FreeBSD.org> | 2006-08-15 16:42:16 +0000 |
commit | 9810a59f6de75a17e9e37af541c35dd063995815 (patch) | |
tree | b6537288e5fef06485d188a49c2d26b6ccf906b4 /sys | |
parent | 250b1cf39906d95f6f2fbfedd093eedd894a032d (diff) | |
download | FreeBSD-src-9810a59f6de75a17e9e37af541c35dd063995815.zip FreeBSD-src-9810a59f6de75a17e9e37af541c35dd063995815.tar.gz |
Add a 'show lockmgr' command that dumps the relevant details of a lockmgr
lock.
Diffstat (limited to 'sys')
-rw-r--r-- | sys/kern/kern_lock.c | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/sys/kern/kern_lock.c b/sys/kern/kern_lock.c index d20fd2d..e9cff2e 100644 --- a/sys/kern/kern_lock.c +++ b/sys/kern/kern_lock.c @@ -43,6 +43,8 @@ #include <sys/cdefs.h> __FBSDID("$FreeBSD$"); +#include "opt_ddb.h" + #include <sys/param.h> #include <sys/kdb.h> #include <sys/kernel.h> @@ -56,6 +58,10 @@ __FBSDID("$FreeBSD$"); #include <sys/stack.h> #endif +#ifdef DDB +#include <ddb/ddb.h> +#endif + /* * Locking primitives implementation. * Locks provide shared/exclusive sychronization. @@ -581,3 +587,29 @@ lockmgr_printinfo(lkp) stack_print(&lkp->lk_stack); #endif } + +#ifdef DDB +DB_SHOW_COMMAND(lockmgr, db_show_lockmgr) +{ + struct thread *td; + struct lock *lkp; + + if (!have_addr) + return; + lkp = (struct lock *)addr; + + db_printf("lock type: %s\n", lkp->lk_wmesg); + db_printf("state: "); + if (lkp->lk_sharecount) + db_printf("SHARED (count %d)\n", lkp->lk_sharecount); + else if (lkp->lk_flags & LK_HAVE_EXCL) { + td = lkp->lk_lockholder; + db_printf("EXCL (count %d) %p ", lkp->lk_exclusivecount, td); + db_printf("(tid %d, pid %d, \"%s\")\n", td->td_tid, + td->td_proc->p_pid, td->td_proc->p_comm); + } else + db_printf("UNLOCKED\n"); + if (lkp->lk_waitcount > 0) + db_printf("waiters: %d\n", lkp->lk_waitcount); +} +#endif |