From owner-p4-projects@FreeBSD.ORG Fri Aug 1 13:28:06 2008 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 4CB401065678; Fri, 1 Aug 2008 13:28:06 +0000 (UTC) Delivered-To: perforce@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 0F2871065675 for ; Fri, 1 Aug 2008 13:28:06 +0000 (UTC) (envelope-from ed@FreeBSD.org) Received: from repoman.freebsd.org (repoman.freebsd.org [IPv6:2001:4f8:fff6::29]) by mx1.freebsd.org (Postfix) with ESMTP id F11C08FC1A for ; Fri, 1 Aug 2008 13:28:05 +0000 (UTC) (envelope-from ed@FreeBSD.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.14.2/8.14.2) with ESMTP id m71DS5sS001345 for ; Fri, 1 Aug 2008 13:28:05 GMT (envelope-from ed@FreeBSD.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.14.2/8.14.1/Submit) id m71DS5je001341 for perforce@freebsd.org; Fri, 1 Aug 2008 13:28:05 GMT (envelope-from ed@FreeBSD.org) Date: Fri, 1 Aug 2008 13:28:05 GMT Message-Id: <200808011328.m71DS5je001341@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to ed@FreeBSD.org using -f From: Ed Schouten To: Perforce Change Reviews Cc: Subject: PERFORCE change 146378 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: Fri, 01 Aug 2008 13:28:06 -0000 http://perforce.freebsd.org/chv.cgi?CH=146378 Change 146378 by ed@ed_flippo on 2008/08/01 13:27:07 Various fixes to "show ttys": - Use db_printf() instead of printf(), which seems to be the proper way to do this. - Print proper flags in the "STATE" column, just like pstat(8) normally does. Affected files ... .. //depot/projects/mpsafetty/sys/kern/tty.c#9 edit Differences ... ==== //depot/projects/mpsafetty/sys/kern/tty.c#9 (text+ko) ==== @@ -1688,11 +1688,45 @@ #ifdef DDB #include +static struct { + int flag; + char val; +} ttystates[] = { +#if 0 + { TF_NOPREFIX, 'N' }, +#endif + { TF_INITLOCK, 'I' }, + { TF_CALLOUT, 'C' }, + + /* Keep these together -> 'Oi' and 'Oo' */ + { TF_OPENED, 'O' }, + { TF_OPENED_IN, 'i' }, + { TF_OPENED_OUT,'o' }, + + { TF_GONE, 'G' }, + { TF_OPENCLOSE, 'B' }, + { TF_ASYNC, 'Y' }, + { TF_LITERAL, 'L' }, + + /* Keep these together -> 'Hi' and 'Ho' */ + { TF_HIWAT, 'H' }, + { TF_HIWAT_IN, 'i' }, + { TF_HIWAT_OUT, 'o' }, + + { TF_STOPPED, 'S' }, + { TF_EXCLUDE, 'X' }, + { TF_BYPASS, 'l' }, + { TF_ZOMBIE, 'Z' }, + + { 0, '\0' }, +}; + /* DDB command to show TTY statistics */ DB_SHOW_COMMAND(ttys, db_show_ttys) { struct tty *tp; size_t isiz, osiz; + int i, j; /* Make the output look like `pstat -t' */ db_printf(" LINE INQ CAN LIN LOW OUTQ USE LOW " @@ -1702,9 +1736,8 @@ isiz = tp->t_inq.ti_nblocks * TTYINQ_DATASIZE; osiz = tp->t_outq.to_nblocks * TTYOUTQ_DATASIZE; - printf("%10s %5zu %4u %4u %4zu %5zu %4u %4zu %5u %5d " - "%5d 0x%x\n", - devtoname(tp->t_dev), + db_printf("%10s %5zu %4u %4u %4zu %5zu %4u %4zu %5u %5d %5d ", + tty_devname(tp), isiz, tp->t_inq.ti_linestart - tp->t_inq.ti_begin, tp->t_inq.ti_end - tp->t_inq.ti_linestart, @@ -1714,9 +1747,17 @@ osiz - tp->t_outlow, tp->t_column, tp->t_pgrp ? tp->t_pgrp->pg_id : 0, - tp->t_session ? tp->t_session->s_sid : 0, - tp->t_flags); + tp->t_session ? tp->t_session->s_sid : 0); + /* Flag bits */ + for (i = j = 0; ttystates[i].flag; i++) + if (tp->t_flags & ttystates[i].flag) { + db_printf("%c", ttystates[i].val); + j++; + } + if (j == 0) + db_printf("-"); + db_printf("\n"); } } #endif /* DDB */