From owner-p4-projects@FreeBSD.ORG Tue Dec 6 19:11:29 2005 Return-Path: X-Original-To: p4-projects@freebsd.org Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 10B7A16A423; Tue, 6 Dec 2005 19:11:29 +0000 (GMT) X-Original-To: perforce@freebsd.org Delivered-To: perforce@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id D8F6516A420 for ; Tue, 6 Dec 2005 19:11:28 +0000 (GMT) (envelope-from jhb@freebsd.org) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id 5A0DA43D62 for ; Tue, 6 Dec 2005 19:11:28 +0000 (GMT) (envelope-from jhb@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.13.1/8.13.1) with ESMTP id jB6JBSKd065707 for ; Tue, 6 Dec 2005 19:11:28 GMT (envelope-from jhb@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.13.1/8.13.1/Submit) id jB6JBSSi065704 for perforce@freebsd.org; Tue, 6 Dec 2005 19:11:28 GMT (envelope-from jhb@freebsd.org) Date: Tue, 6 Dec 2005 19:11:28 GMT Message-Id: <200512061911.jB6JBSSi065704@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to jhb@freebsd.org using -f From: John Baldwin To: Perforce Change Reviews Cc: Subject: PERFORCE change 87814 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 06 Dec 2005 19:11:30 -0000 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 __FBSDID("$FreeBSD: src/sys/kern/kern_sx.c,v 1.25 2005/01/06 23:35:39 imp Exp $"); +#include "opt_ddb.h" + #include #include #include @@ -44,6 +46,8 @@ #include #include +#include + 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