CVS commit: src/games/gomoku
Module Name:src Committed By: dholland Date: Thu Jun 4 06:27:47 UTC 2009 Modified Files: src/games/gomoku: gomoku.h main.c pickmove.c Log Message: Make a couple of the logging/printing functions printf-alikes. This removes most of the calls to sprintf. To generate a diff of this commit: cvs rdiff -u -r1.12 -r1.13 src/games/gomoku/gomoku.h cvs rdiff -u -r1.15 -r1.16 src/games/gomoku/main.c \ src/games/gomoku/pickmove.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/games/gomoku/gomoku.h diff -u src/games/gomoku/gomoku.h:1.12 src/games/gomoku/gomoku.h:1.13 --- src/games/gomoku/gomoku.h:1.12 Thu Jun 4 05:52:30 2009 +++ src/games/gomoku/gomoku.h Thu Jun 4 06:27:47 2009 @@ -1,4 +1,4 @@ -/* $NetBSD: gomoku.h,v 1.12 2009/06/04 05:52:30 dholland Exp $ */ +/* $NetBSD: gomoku.h,v 1.13 2009/06/04 06:27:47 dholland Exp $ */ /* * Copyright (c) 1994 @@ -272,9 +272,9 @@ void cursfini(void); void cursinit(void); void bdwho(int); -void panic(const char *) __dead; -void glog(const char *); -void dlog(const char *); +void panic(const char *, ...) __printflike(1, 2) __dead; +void misclog(const char *, ...) __printflike(1, 2); +void debuglog(const char *, ...) __printflike(1, 2); void quit(void) __dead; void quitsig(int) __dead; void whatsup(int); Index: src/games/gomoku/main.c diff -u src/games/gomoku/main.c:1.15 src/games/gomoku/main.c:1.16 --- src/games/gomoku/main.c:1.15 Thu Jun 4 05:27:04 2009 +++ src/games/gomoku/main.c Thu Jun 4 06:27:47 2009 @@ -1,4 +1,4 @@ -/* $NetBSD: main.c,v 1.15 2009/06/04 05:27:04 dholland Exp $ */ +/* $NetBSD: main.c,v 1.16 2009/06/04 06:27:47 dholland Exp $ */ /* * Copyright (c) 1994 @@ -42,13 +42,14 @@ #if 0 static char sccsid[] = @(#)main.c 8.4 (Berkeley) 5/4/95; #else -__RCSID($NetBSD: main.c,v 1.15 2009/06/04 05:27:04 dholland Exp $); +__RCSID($NetBSD: main.c,v 1.16 2009/06/04 06:27:47 dholland Exp $); #endif #endif /* not lint */ #include curses.h #include err.h #include signal.h +#include stdarg.h #include stdlib.h #include string.h #include time.h @@ -176,10 +177,8 @@ else if (strcmp(buf, white) == 0) color = WHITE; else { - sprintf(fmtbuf, - Huh? Expected `black' or `white', got `%s'\n, + panic(Huh? Expected `black' or `white', got `%s'\n, buf); - panic(fmtbuf); } } @@ -256,7 +255,7 @@ ask(save file name? ); (void)getline(buf, sizeof(buf)); if ((fp = fopen(buf, w)) == NULL) { - glog(cannot create save file); + misclog(cannot create save file); goto getinput; } for (i = 0; i movenum - 1; i++) @@ -267,7 +266,7 @@ } if (curmove != RESIGN board[curmove].s_occ != EMPTY) { - glog(Illegal move); + misclog(Illegal move); goto getinput; } } @@ -278,8 +277,7 @@ break; } if (interactive) { - sprintf(fmtbuf, fmt[color], movenum, stoc(curmove)); - glog(fmtbuf); + misclog(fmt[color], movenum, stoc(curmove)); } if ((i = makemove(color, curmove)) != MOVEOK) break; @@ -316,7 +314,7 @@ ask(save file name? ); (void)getline(buf, sizeof(buf)); if ((fp = fopen(buf, w)) == NULL) { - glog(cannot create save file); + misclog(cannot create save file); goto replay; } for (i = 0; i movenum - 1; i++) @@ -372,8 +370,7 @@ quit(); case 'd': /* set debug level */ debug = fmtbuf[1] - '0'; - sprintf(fmtbuf, Debug set to %d, debug); - dlog(fmtbuf); + debuglog(Debug set to %d, debug); sleep(1); case 'c': break; @@ -386,9 +383,8 @@ goto top; case 's': /* suggest a move */ i = fmtbuf[1] == 'b' ? BLACK : WHITE; - sprintf(fmtbuf, suggest %c %s, i == BLACK ? 'B' : 'W', + debuglog(suggest %c %s, i == BLACK ? 'B' : 'W', stoc(pickmove(i))); - dlog(fmtbuf); goto top; case 'f': /* go forward a move */ board[movelog[movenum - 1]].s_occ = movenum 1 ? BLACK : WHITE; @@ -398,7 +394,7 @@ case 'l': /* print move history */ if (fmtbuf[1] == '\0') { for (i = 0; i movenum - 1; i++) -dlog(stoc(movelog[i])); +debuglog(%s, stoc(movelog[i])); goto top; } if ((fp = fopen(fmtbuf + 1, w)) == NULL) @@ -433,28 +429,22 @@ if (str[-1] == pdir[d2]) break; n += sp-s_frame[d2] - frames; - str = fmtbuf; - sprintf(str, overlap %s%c,, stoc(s1), pdir[d1]); - str += strlen(str); - sprintf(str, %s%c = %x, stoc(s2), pdir[d2], overlap[n]); - dlog(fmtbuf); + debuglog(overlap %s%c,%s%c = %x, stoc(s1), pdir[d1], + stoc(s2), pdir[d2], overlap[n]); goto top; case 'p': sp = board[i = ctos(fmtbuf + 1)]; - sprintf(fmtbuf, V %s %x/%d %d %x/%d %d %d %x, stoc(i), + debuglog(V %s %x/%d %d %x/%d %d %d %x, stoc(i), sp-s_combo[BLACK].s, sp-s_level[BLACK], sp-s_nforce[BLACK], sp-s_combo[WHITE].s, sp-s_level[WHITE], sp-s_nforce[WHITE], sp-s_wval, sp-s_flg); - dlog(fmtbuf); - sprintf(fmtbuf, FB %s %x %x %x
CVS commit: src/games/gomoku
Module Name:src Committed By: dholland Date: Thu Jun 4 06:47:36 UTC 2009 Modified Files: src/games/gomoku: gomoku.h main.c Log Message: Remove global scratch string buffer. Don't zoom off the end while reading user input, either. To generate a diff of this commit: cvs rdiff -u -r1.14 -r1.15 src/games/gomoku/gomoku.h cvs rdiff -u -r1.16 -r1.17 src/games/gomoku/main.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/games/gomoku/gomoku.h diff -u src/games/gomoku/gomoku.h:1.14 src/games/gomoku/gomoku.h:1.15 --- src/games/gomoku/gomoku.h:1.14 Thu Jun 4 06:41:50 2009 +++ src/games/gomoku/gomoku.h Thu Jun 4 06:47:36 2009 @@ -1,4 +1,4 @@ -/* $NetBSD: gomoku.h,v 1.14 2009/06/04 06:41:50 dholland Exp $ */ +/* $NetBSD: gomoku.h,v 1.15 2009/06/04 06:47:36 dholland Exp $ */ /* * Copyright (c) 1994 @@ -246,7 +246,6 @@ }; extern const char *letters; -extern char fmtbuf[]; extern const char pdir[]; extern const int dd[4]; Index: src/games/gomoku/main.c diff -u src/games/gomoku/main.c:1.16 src/games/gomoku/main.c:1.17 --- src/games/gomoku/main.c:1.16 Thu Jun 4 06:27:47 2009 +++ src/games/gomoku/main.c Thu Jun 4 06:47:36 2009 @@ -1,4 +1,4 @@ -/* $NetBSD: main.c,v 1.16 2009/06/04 06:27:47 dholland Exp $ */ +/* $NetBSD: main.c,v 1.17 2009/06/04 06:47:36 dholland Exp $ */ /* * Copyright (c) 1994 @@ -42,7 +42,7 @@ #if 0 static char sccsid[] = @(#)main.c 8.4 (Berkeley) 5/4/95; #else -__RCSID($NetBSD: main.c,v 1.16 2009/06/04 06:27:47 dholland Exp $); +__RCSID($NetBSD: main.c,v 1.17 2009/06/04 06:47:36 dholland Exp $); #endif #endif /* not lint */ @@ -69,7 +69,6 @@ FILE *inputfp; /* file for debug input */ const char pdir[4] = -\\|/; -char fmtbuf[128]; struct spotstr board[BAREA]; /* info for board */ struct combostr frames[FAREA]; /* storage for all frames */ @@ -333,14 +332,15 @@ int readinput(FILE *fp) { - char *cp; int c; + char buf[128]; + size_t pos; - cp = fmtbuf; - while ((c = getc(fp)) != EOF c != '\n') - *cp++ = c; - *cp = '\0'; - return (ctos(fmtbuf)); + pos = 0; + while ((c = getc(fp)) != EOF c != '\n' pos sizeof(buf) - 1) + buf[pos++] = c; + buf[pos] = '\0'; + return ctos(buf); } #ifdef DEBUG
CVS commit: src/games/ching
Module Name:src Committed By: dholland Date: Thu Jun 4 06:51:11 UTC 2009 Modified Files: src/games/ching: Makefile.inc Log Message: Set WARNS=4 here. This got missed on my previous WARNS sweep in games. Everything appears to compile ok with WARNS=4 anyway though. To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/games/ching/Makefile.inc Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/games/ching/Makefile.inc diff -u src/games/ching/Makefile.inc:1.1 src/games/ching/Makefile.inc:1.2 --- src/games/ching/Makefile.inc:1.1 Thu Jun 30 13:30:33 2005 +++ src/games/ching/Makefile.inc Thu Jun 4 06:51:11 2009 @@ -1,5 +1,5 @@ -# $NetBSD: Makefile.inc,v 1.1 2005/06/30 13:30:33 perry Exp $ +# $NetBSD: Makefile.inc,v 1.2 2009/06/04 06:51:11 dholland Exp $ CPPFLAGS+=-I${.CURDIR}/../include BINDIR?=/usr/games -WARNS=2 +WARNS?=4
CVS commit: src/games/gomoku
Module Name:src Committed By: dholland Date: Thu Jun 4 07:01:16 UTC 2009 Modified Files: src/games/gomoku: main.c pickmove.c Log Message: Rectify non-compiling code that appears when DEBUG is defined. To generate a diff of this commit: cvs rdiff -u -r1.17 -r1.18 src/games/gomoku/main.c \ src/games/gomoku/pickmove.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/games/gomoku/main.c diff -u src/games/gomoku/main.c:1.17 src/games/gomoku/main.c:1.18 --- src/games/gomoku/main.c:1.17 Thu Jun 4 06:47:36 2009 +++ src/games/gomoku/main.c Thu Jun 4 07:01:16 2009 @@ -1,4 +1,4 @@ -/* $NetBSD: main.c,v 1.17 2009/06/04 06:47:36 dholland Exp $ */ +/* $NetBSD: main.c,v 1.18 2009/06/04 07:01:16 dholland Exp $ */ /* * Copyright (c) 1994 @@ -42,7 +42,7 @@ #if 0 static char sccsid[] = @(#)main.c 8.4 (Berkeley) 5/4/95; #else -__RCSID($NetBSD: main.c,v 1.17 2009/06/04 06:47:36 dholland Exp $); +__RCSID($NetBSD: main.c,v 1.18 2009/06/04 07:01:16 dholland Exp $); #endif #endif /* not lint */ @@ -350,26 +350,28 @@ void whatsup(int signum) { - int i, pnum, n, s1, s2, d1, d2; + int i, n, s1, s2, d1, d2; struct spotstr *sp; FILE *fp; char *str; struct elist *ep; struct combostr *cbp; + char input[128]; + char tmp[128]; if (!interactive) quit(); top: ask(cmd? ); - if (!getline(fmtbuf, sizeof(fmtbuf))) + if (!getline(input, sizeof(input))) quit(); - switch (*fmtbuf) { + switch (*input) { case '\0': goto top; case 'q': /* conservative quit */ quit(); case 'd': /* set debug level */ - debug = fmtbuf[1] - '0'; + debug = input[1] - '0'; debuglog(Debug set to %d, debug); sleep(1); case 'c': @@ -382,7 +384,7 @@ } goto top; case 's': /* suggest a move */ - i = fmtbuf[1] == 'b' ? BLACK : WHITE; + i = input[1] == 'b' ? BLACK : WHITE; debuglog(suggest %c %s, i == BLACK ? 'B' : 'W', stoc(pickmove(i))); goto top; @@ -392,12 +394,12 @@ bdisp(); goto top; case 'l': /* print move history */ - if (fmtbuf[1] == '\0') { + if (input[1] == '\0') { for (i = 0; i movenum - 1; i++) debuglog(%s, stoc(movelog[i])); goto top; } - if ((fp = fopen(fmtbuf + 1, w)) == NULL) + if ((fp = fopen(input + 1, w)) == NULL) goto top; for (i = 0; i movenum - 1; i++) { fprintf(fp, %s, stoc(movelog[i])); @@ -410,14 +412,17 @@ fclose(fp); goto top; case 'o': + /* avoid use w/o initialization on invalid input */ + d1 = s1 = 0; + n = 0; - for (str = fmtbuf + 1; *str; str++) + for (str = input + 1; *str; str++) if (*str == ',') { for (d1 = 0; d1 4; d1++) if (str[-1] == pdir[d1]) break; str[-1] = '\0'; -sp = board[s1 = ctos(fmtbuf + 1)]; +sp = board[s1 = ctos(input + 1)]; n = (sp-s_frame[d1] - frames) * FAREA; *str++ = '\0'; break; @@ -433,12 +438,12 @@ stoc(s2), pdir[d2], overlap[n]); goto top; case 'p': - sp = board[i = ctos(fmtbuf + 1)]; + sp = board[i = ctos(input + 1)]; debuglog(V %s %x/%d %d %x/%d %d %d %x, stoc(i), sp-s_combo[BLACK].s, sp-s_level[BLACK], sp-s_nforce[BLACK], sp-s_combo[WHITE].s, sp-s_level[WHITE], - sp-s_nforce[WHITE], sp-s_wval, sp-s_flg); + sp-s_nforce[WHITE], sp-s_wval, sp-s_flags); debuglog(FB %s %x %x %x %x, stoc(i), sp-s_fval[BLACK][0].s, sp-s_fval[BLACK][1].s, sp-s_fval[BLACK][2].s, sp-s_fval[BLACK][3].s); @@ -447,7 +452,7 @@ sp-s_fval[WHITE][2].s, sp-s_fval[WHITE][3].s); goto top; case 'e': /* e {b|w} [0-9] spot */ - str = fmtbuf + 1; + str = input + 1; if (*str = '0' *str = '9') n = *str++ - '0'; else @@ -461,12 +466,11 @@ if (cbp-c_nframes != n) break; } - printcombo(cbp, fmtbuf); - debuglog(%s, fmtbuf); + printcombo(cbp, tmp, sizeof(tmp)); + debuglog(%s, tmp); } goto top; default: -syntax: debuglog(Options are:); debuglog(q- quit); debuglog(c- continue); Index: src/games/gomoku/pickmove.c diff -u src/games/gomoku/pickmove.c:1.17 src/games/gomoku/pickmove.c:1.18 --- src/games/gomoku/pickmove.c:1.17 Thu Jun 4 06:41:50 2009 +++ src/games/gomoku/pickmove.c Thu Jun 4 07:01:16 2009 @@ -1,4 +1,4 @@ -/* $NetBSD: pickmove.c,v 1.17 2009/06/04 06:41:50 dholland Exp $ */ +/* $NetBSD: pickmove.c,v 1.18 2009/06/04 07:01:16 dholland Exp $ */ /* * Copyright (c) 1994 @@ -37,7 +37,7 @@ #if 0 static char sccsid[] = @(#)pickmove.c 8.2 (Berkeley) 5/3/95; #else -__RCSID($NetBSD: pickmove.c,v 1.17 2009/06/04 06:41:50 dholland Exp $); +__RCSID($NetBSD: pickmove.c,v 1.18 2009/06/04 07:01:16 dholland Exp $); #endif #endif /* not lint */ @@ -515,7 +515,7 @@ combocnt--; } #ifdef DEBUG - if (c == 1 debug 1 || debug 5) { + if ((c == 1 debug 1) || debug 5) { markcombo(ncbp); bdisp(); whatsup(0); @@ -758,7 +758,7 @@ updatecombo(ncbp, curcolor); } #ifdef DEBUG - if (c == 1 debug 1 ||
CVS commit: src/usr.sbin/crash
Module Name:src Committed By: christos Date: Thu Jun 4 12:19:35 UTC 2009 Modified Files: src/usr.sbin/crash: Makefile Log Message: Avoid -mcmodel=kernel so that we can build in PIC mode. To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/usr.sbin/crash/Makefile Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.sbin/crash/Makefile diff -u src/usr.sbin/crash/Makefile:1.2 src/usr.sbin/crash/Makefile:1.3 --- src/usr.sbin/crash/Makefile:1.2 Wed Apr 22 11:23:02 2009 +++ src/usr.sbin/crash/Makefile Thu Jun 4 08:19:35 2009 @@ -1,7 +1,8 @@ -# $NetBSD: Makefile,v 1.2 2009/04/22 15:23:02 lukem Exp $ +# $NetBSD: Makefile,v 1.3 2009/06/04 12:19:35 christos Exp $ PROG= crash MAN= crash.8 +RUMPKERNEL= yes # XXX: Avoid -mcmodel=kernel LDADD+= -lkvm -ledit -ltermcap DPADD+= ${LIBKVM} ${LIBEDIT} ${LIBTERMCAP}
CVS commit: src/sys/compat/linux32
Module Name:src Committed By: njoly Date: Thu Jun 4 17:59:30 UTC 2009 Modified Files: src/sys/compat/linux32/arch/amd64: syscalls.master src/sys/compat/linux32/common: linux32_stat.c Log Message: Add stat/lstat/fstat syscalls. To generate a diff of this commit: cvs rdiff -u -r1.51 -r1.52 src/sys/compat/linux32/arch/amd64/syscalls.master cvs rdiff -u -r1.15 -r1.16 src/sys/compat/linux32/common/linux32_stat.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/compat/linux32/arch/amd64/syscalls.master diff -u src/sys/compat/linux32/arch/amd64/syscalls.master:1.51 src/sys/compat/linux32/arch/amd64/syscalls.master:1.52 --- src/sys/compat/linux32/arch/amd64/syscalls.master:1.51 Tue Jun 2 16:54:39 2009 +++ src/sys/compat/linux32/arch/amd64/syscalls.master Thu Jun 4 17:59:30 2009 @@ -1,4 +1,4 @@ - $NetBSD: syscalls.master,v 1.51 2009/06/02 16:54:39 njoly Exp $ + $NetBSD: syscalls.master,v 1.52 2009/06/04 17:59:30 njoly Exp $ ; NetBSD i386 COMPAT_LINUX32 system call name/number master file. ; (See syscalls.conf to see what it is processed into.) @@ -204,9 +204,12 @@ netbsd32_itimerval50p_t itv, netbsd32_itimerval50p_t oitv); } 105 NOARGS { int|compat_50_netbsd32||getitimer(int which, \ netbsd32_itimerval50p_t itv); } -106 UNIMPL stat -107 UNIMPL lstat -108 UNIMPL fstat +106 STD { int|linux32_sys||stat(netbsd32_charp path, \ + linux32_statp sp); } +107 STD { int|linux32_sys||lstat(netbsd32_charp path, \ + linux32_statp sp); } +108 STD { int|linux32_sys||fstat(int fd, \ + linux32_statp sp); } 109 STD { int|linux32_sys||olduname(linux32_oldutsnamep_t up); } 110 UNIMPL iopl 111 UNIMPL vhangup Index: src/sys/compat/linux32/common/linux32_stat.c diff -u src/sys/compat/linux32/common/linux32_stat.c:1.15 src/sys/compat/linux32/common/linux32_stat.c:1.16 --- src/sys/compat/linux32/common/linux32_stat.c:1.15 Wed Jun 3 15:13:26 2009 +++ src/sys/compat/linux32/common/linux32_stat.c Thu Jun 4 17:59:30 2009 @@ -1,4 +1,4 @@ -/* $NetBSD: linux32_stat.c,v 1.15 2009/06/03 15:13:26 njoly Exp $ */ +/* $NetBSD: linux32_stat.c,v 1.16 2009/06/04 17:59:30 njoly Exp $ */ /*- * Copyright (c) 2006 Emmanuel Dreyfus, all rights reserved. @@ -33,7 +33,7 @@ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: linux32_stat.c,v 1.15 2009/06/03 15:13:26 njoly Exp $); +__KERNEL_RCSID(0, $NetBSD: linux32_stat.c,v 1.16 2009/06/04 17:59:30 njoly Exp $); #include sys/types.h #include sys/param.h @@ -74,11 +74,39 @@ #include compat/linux32/common/linux32_socketcall.h #include compat/linux32/linux32_syscallargs.h +static inline void bsd_to_linux32_stat(struct stat *, struct linux32_stat *); static inline void bsd_to_linux32_stat64(struct stat *, struct linux32_stat64 *); #define linux_fakedev(x,y) (x) static inline void +bsd_to_linux32_stat(struct stat *st, struct linux32_stat *st32) +{ + memset(st32, 0, sizeof(*st32)); + st32-lst_dev = linux_fakedev(st-st_dev, 0); + st32-lst_ino = st-st_ino; + st32-lst_mode = st-st_mode; + if (st-st_nlink = (1 15)) + st32-lst_nlink = (1 15) - 1; + else + st32-lst_nlink = st-st_nlink; + st32-lst_uid = st-st_uid; + st32-lst_gid = st-st_gid; + st32-lst_rdev = linux_fakedev(st-st_rdev, 0); + st32-lst_size = st-st_size; + st32-lst_blksize = st-st_blksize; + st32-lst_blocks = st-st_blocks; + st32-lst_atime = st-st_atime; + st32-lst_mtime = st-st_mtime; + st32-lst_ctime = st-st_ctime; +#ifdef LINUX32_STAT_HAS_NSEC + st32-lst_atime_nsec = st-st_atimensec; + st32-lst_mtime_nsec = st-st_mtimensec; + st32-lst_ctime_nsec = st-st_ctimensec; +#endif +} + +static inline void bsd_to_linux32_stat64(struct stat *st, struct linux32_stat64 *st32) { memset(st32, 0, sizeof(*st32)); @@ -109,6 +137,63 @@ } int +linux32_sys_stat(struct lwp *l, const struct linux32_sys_stat_args *uap, register_t *retval) +{ + /* { + syscallarg(netbsd32_charp) path; + syscallarg(linux32_statp) sp; + } */ + int error; + struct stat st; + struct linux32_stat st32; + + error = do_sys_stat(SCARG_P32(uap, path), FOLLOW, st); + if (error != 0) + return error; + + bsd_to_linux32_stat(st, st32); + return copyout(st32, SCARG_P32(uap, sp), sizeof(st32)); +} + +int +linux32_sys_lstat(struct lwp *l, const struct linux32_sys_lstat_args *uap, register_t *retval) +{ + /* { + syscallarg(netbsd32_charp) path; + syscallarg(linux32_statp) sp; + } */ + int error; + struct stat st; + struct linux32_stat st32; + + error = do_sys_stat(SCARG_P32(uap, path), NOFOLLOW, st); + if (error != 0) + return error; + + bsd_to_linux32_stat(st, st32); + return copyout(st32, SCARG_P32(uap, sp), sizeof(st32)); +} + +int +linux32_sys_fstat(struct lwp *l, const struct linux32_sys_fstat_args *uap, register_t *retval) +{ + /* { + syscallarg(int) fd; + syscallarg(linux32_statp) sp; + } */ + int error; + struct stat st; + struct linux32_stat st32; + +
CVS commit: src/sys/ddb
Module Name:src Committed By: mrg Date: Fri Jun 5 04:31:47 UTC 2009 Modified Files: src/sys/ddb: db_command.c Log Message: extend 'show event' to take /i /t and /m modifiers, to select interrupt, trap or misc event types. you can mix them with /f as well, to show all including zero events for traps and misc, show event/ftm To generate a diff of this commit: cvs rdiff -u -r1.131 -r1.132 src/sys/ddb/db_command.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/ddb/db_command.c diff -u src/sys/ddb/db_command.c:1.131 src/sys/ddb/db_command.c:1.132 --- src/sys/ddb/db_command.c:1.131 Sat Mar 21 13:06:39 2009 +++ src/sys/ddb/db_command.c Fri Jun 5 04:31:47 2009 @@ -1,4 +1,4 @@ -/* $NetBSD: db_command.c,v 1.131 2009/03/21 13:06:39 ad Exp $ */ +/* $NetBSD: db_command.c,v 1.132 2009/06/05 04:31:47 mrg Exp $ */ /* * Copyright (c) 1996, 1997, 1998, 1999, 2002, 2009 The NetBSD Foundation, Inc. @@ -60,7 +60,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: db_command.c,v 1.131 2009/03/21 13:06:39 ad Exp $); +__KERNEL_RCSID(0, $NetBSD: db_command.c,v 1.132 2009/06/05 04:31:47 mrg Exp $); #ifdef _KERNEL_OPT #include opt_aio.h @@ -238,7 +238,7 @@ { DDB_ADD_CMD(buf, db_buf_print_cmd, 0, Print the struct buf at address., [/f] address,NULL) }, { DDB_ADD_CMD(event, db_event_print_cmd, 0, - Print all the non-zero evcnt(9) event counters., [/f],NULL) }, + Print all the non-zero evcnt(9) event counters., [/fitm],NULL) }, { DDB_ADD_CMD(files, db_show_files_cmd, 0, Print the files open by process at address, [/f] address, NULL) }, @@ -1059,18 +1059,51 @@ db_event_print_cmd(db_expr_t addr, bool have_addr, db_expr_t count, const char *modif) { - bool full = false; + bool showzero = false; + bool showall = true; + bool showintr = false; + bool showtrap = false; + bool showmisc = false; struct evcnt ev, *evp; char buf[80]; + int i; - if (modif[0] == 'f') - full = true; + i = 0; + while (modif[i]) { + switch (modif[i]) { + case 'f': + showzero = true; + break; + case 'i': + showintr = true; + showall = false; + break; + case 't': + showtrap = true; + showall = false; + break; + case 'm': + showmisc = true; + showall = false; + break; + } + i++; + } + + if (showall) + showmisc = showintr = showtrap = true; evp = (struct evcnt *)db_read_ptr(allevents); while (evp != NULL) { db_read_bytes((db_addr_t)evp, sizeof(ev), (char *)ev); evp = ev.ev_list.tqe_next; - if (ev.ev_count == 0 !full) + if (ev.ev_count == 0 !showzero) + continue; + if (ev.ev_type == EVCNT_TYPE_INTR !showintr) + continue; + if (ev.ev_type == EVCNT_TYPE_TRAP !showtrap) + continue; + if (ev.ev_type == EVCNT_TYPE_MISC !showmisc) continue; db_read_bytes((db_addr_t)ev.ev_group, ev.ev_grouplen + 1, buf); db_printf(evcnt type %d: %s , ev.ev_type, buf);
CVS commit: src/share/man/man4
Module Name:src Committed By: mrg Date: Fri Jun 5 04:40:23 UTC 2009 Modified Files: src/share/man/man4: ddb.4 Log Message: extend 'show event' to take /i /t and /m modifiers, to select interrupt, trap or misc event types. you can mix them with /f as well, to show all including zero events for traps and misc, show event/ftm To generate a diff of this commit: cvs rdiff -u -r1.125 -r1.126 src/share/man/man4/ddb.4 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/share/man/man4/ddb.4 diff -u src/share/man/man4/ddb.4:1.125 src/share/man/man4/ddb.4:1.126 --- src/share/man/man4/ddb.4:1.125 Fri Apr 10 15:16:06 2009 +++ src/share/man/man4/ddb.4 Fri Jun 5 04:40:23 2009 @@ -1,4 +1,4 @@ -.\ $NetBSD: ddb.4,v 1.125 2009/04/10 15:16:06 joerg Exp $ +.\ $NetBSD: ddb.4,v 1.126 2009/06/05 04:40:23 mrg Exp $ .\ .\ Copyright (c) 1997 - 2009 The NetBSD Foundation, Inc. .\ All rights reserved. @@ -593,13 +593,33 @@ The .Cm /f does nothing at this time. -.It Ic show event Ns Op Cm /f +.It Ic show event Ns Oo Cm /f Oc Ns Oo Cm /i Oc Ns Oo Cm /m Oc Ns \ +Oo Cm /t Oc Print all the non-zero .Xr evcnt 9 event counters. -If -.Cm /f -is specified, all event counters with a count of zero are printed as well. +Valid modifiers: +.Bl -tag -width 3n +.It Cm /f +event counters with a count of zero are printed as well. +.It Cm /i +interrupted counters will be displayed. +.It Cm /m +is specified, misc counters will be displayed. +.It Cm /t +is specified, trap counters will be displayed. +.El +.Pp +If none of +.Cm /i , +.Cm /m +or +.Cm /t +are specified, all are shown. +You can combine any of these. +For example, the modifier +.Cm /itf +will select both interrupt and trap events, including those that are non-zero. .It Ic show files Ar address Display information about the vnodes of the files that are currently open by the process associated with the proc structure at