diff options
| -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 d20fd2dd9133..e9cff2eeb5d7 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 |
