Date: Fri, 1 Aug 2008 13:28:05 GMT From: Ed Schouten <ed@FreeBSD.org> To: Perforce Change Reviews <perforce@FreeBSD.org> Subject: PERFORCE change 146378 for review Message-ID: <200808011328.m71DS5je001341@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
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 <ddb/ddb.h> +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 */
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200808011328.m71DS5je001341>