Date: Tue, 6 Dec 2005 19:11:28 GMT From: John Baldwin <jhb@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 87814 for review Message-ID: <200512061911.jB6JBSSi065704@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=87814 Change 87814 by jhb@jhb_slimer on 2005/12/06 19:10:30 Add 'show mutex' and 'show sx' ddb commands. Affected files ... .. //depot/projects/smpng/sys/kern/kern_mutex.c#108 edit .. //depot/projects/smpng/sys/kern/kern_sx.c#25 edit Differences ... ==== //depot/projects/smpng/sys/kern/kern_mutex.c#108 (text+ko) ==== @@ -940,3 +940,50 @@ mtx_init(&devmtx, "cdev", NULL, MTX_DEF); mtx_lock(&Giant); } + +#ifdef DDB +DB_SHOW_COMMAND(mutex, db_show_mutex) +{ + struct thread *td; + struct mtx *m; + int comma; + + if (!have_addr) + return; + m = (struct mtx *)addr; + + if (m->mtx_object.lo_class == &lock_class_mtx_sleep) + db_printf("default mutex:\n"); + else if (m->mtx_object.lo_class == &lock_class_mtx_spin) + db_printf("spin mutex:\n"); + else + return; + db_printf(" name: %s\n", m->mtx_object.lo_name); + if (m->mtx_object.lo_type) + db_printf(" type: %s\n", m->mtx_object.lo_type); + if (m->mtx_object.lo_flags & (LO_RECURSABLE | LO_DUPOK)) { + db_printf(" flags: {"); + comma = 0; + if (m->mtx_object.lo_flags & LO_RECURSABLE) { + db_printf("RECURSE"); + comma++; + } + if (m->mtx_object.lo_flags & LO_DUPOK) { + if (comma) + db_printf(", "); + db_printf("DUPOK"); + } + db_printf("}\n"); + } + db_printf(" owner: "); + if (mtx_unowned(m)) + db_printf("UNOWNED\n"); + else { + td = mtx_owner(m); + db_printf("%p (tid %d, pid %d, \"%s\")\n", td, td->td_tid, + td->td_proc->p_pid, td->td_proc->p_comm); + if (mtx_recursed(m)) + db_printf(" recursed: %d\n", m->mtx_recurse); + } +} +#endif ==== //depot/projects/smpng/sys/kern/kern_sx.c#25 (text+ko) ==== @@ -36,6 +36,8 @@ #include <sys/cdefs.h> __FBSDID("$FreeBSD: src/sys/kern/kern_sx.c,v 1.25 2005/01/06 23:35:39 imp Exp $"); +#include "opt_ddb.h" + #include <sys/param.h> #include <sys/systm.h> #include <sys/ktr.h> @@ -44,6 +46,8 @@ #include <sys/mutex.h> #include <sys/sx.h> +#include <ddb/ddb.h> + struct lock_class lock_class_sx = { "sx", LC_SLEEPLOCK | LC_SLEEPABLE | LC_RECURSABLE | LC_UPGRADABLE @@ -367,3 +371,31 @@ } } #endif /* INVARIANT_SUPPORT */ + +#ifdef DDB +DB_SHOW_COMMAND(sx, db_show_sx) +{ + struct thread *td; + struct sx *sx; + int comma; + + if (!have_addr) + return; + sx = (struct sx *)addr; + + if (sx->sx_object.lo_class != &lock_class_sx) + return; + db_printf(" name: %s\n", sx->sx_object.lo_name); + db_printf(" locked: "); + if (sx->sx_cnt < 0) { + td = sx->sx_xholder; + db_printf(" XLOCK: %p (tid %d, pid %d, \"%s\")\n", td, + td->td_tid, td->td_proc->p_pid, td->td_proc->p_comm); + } else if (sx->sx_cnt > 0) + db_printf(" SLOCK: %d locks\n", sx->sx_cnt); + else + db_printf(" UNLOCKED\n"); + db_printf(" waiters: %d shared, %d exclusive\n", sx->sx_shrd_wcnt, + sx->sx_excl_wcnt); +} +#endif
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200512061911.jB6JBSSi065704>