Module Name: src Committed By: kre Date: Mon Jan 21 14:29:12 UTC 2019
Modified Files: src/bin/sh: error.c shell.h show.c Log Message: DEBUG mode shell cleanups (NFC for any normal shell). Add an error DEBUG trace in exraise() (when the shell has detected some error or signal, and is aborting what it is doing) Fix an arith error in DEBUG bit assignments (harmless as we haven't reached the limit of flags yet), and add some missing (recently added) debug flags so they are turned on when the user (ie: me) asks for "everything". To generate a diff of this commit: cvs rdiff -u -r1.41 -r1.42 src/bin/sh/error.c cvs rdiff -u -r1.27 -r1.28 src/bin/sh/shell.h cvs rdiff -u -r1.50 -r1.51 src/bin/sh/show.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/bin/sh/error.c diff -u src/bin/sh/error.c:1.41 src/bin/sh/error.c:1.42 --- src/bin/sh/error.c:1.41 Mon Jul 24 12:35:12 2017 +++ src/bin/sh/error.c Mon Jan 21 14:29:12 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: error.c,v 1.41 2017/07/24 12:35:12 kre Exp $ */ +/* $NetBSD: error.c,v 1.42 2019/01/21 14:29:12 kre Exp $ */ /*- * Copyright (c) 1991, 1993 @@ -37,7 +37,7 @@ #if 0 static char sccsid[] = "@(#)error.c 8.2 (Berkeley) 5/4/95"; #else -__RCSID("$NetBSD: error.c,v 1.41 2017/07/24 12:35:12 kre Exp $"); +__RCSID("$NetBSD: error.c,v 1.42 2019/01/21 14:29:12 kre Exp $"); #endif #endif /* not lint */ @@ -82,6 +82,7 @@ static void exverror(int, const char *, void exraise(int e) { + CTRACE(DBG_ERRS, ("exraise(%d)\n", e)); if (handler == NULL) abort(); exception = e; Index: src/bin/sh/shell.h diff -u src/bin/sh/shell.h:1.27 src/bin/sh/shell.h:1.28 --- src/bin/sh/shell.h:1.27 Thu Oct 18 05:28:45 2018 +++ src/bin/sh/shell.h Mon Jan 21 14:29:12 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: shell.h,v 1.27 2018/10/18 05:28:45 kre Exp $ */ +/* $NetBSD: shell.h,v 1.28 2019/01/21 14:29:12 kre Exp $ */ /*- * Copyright (c) 1991, 1993 @@ -97,7 +97,7 @@ extern int ShNest; * be increased, but that both limits the maximum value tha can be * used with DBG_EXTRAS(), and causes problems with verbose option naming. */ -#define DBG_VBOSE_SHIFT 26 +#define DBG_VBOSE_SHIFT 27 #define DBG_EXTRAS(n) ((DBG_VBOSE_SHIFT * 2) + (n)) /* @@ -188,22 +188,22 @@ extern int ShNest; /* use VTRACE(DBG_ALWAYS, (...)) to test this one */ #define DBG_VERBOSE (1LL << DBG_VBOSE_SHIFT) - /* DBG_EXTRAS 0 .. 11 (max) only - non-alpha options (no VTRACE !!) */ + /* DBG_EXTRAS 0 .. 9 (max) only - non-alpha options (no VTRACE !!) */ #define DBG_U0 (1LL << DBG_EXTRAS(0)) /* 0 - ad-hoc extra flags */ #define DBG_U1 (1LL << DBG_EXTRAS(1)) /* 1 - for short term */ -#define DBG_U2 (1LL << DBG_EXTRAS(2)) /* 2 - extra tracing*/ +#define DBG_U2 (1LL << DBG_EXTRAS(2)) /* 2 - extra tracing */ +#define DBG_U3 (1LL << DBG_EXTRAS(3)) /* 3 - when needed */ + /* 4, 5, & 6 currently free */ +#define DBG_LINE (1LL << DBG_EXTRAS(7)) /* @ ($LINENO) */ +#define DBG_PID (1LL << DBG_EXTRAS(8)) /* $ ($$) */ +#define DBG_NEST (1LL << DBG_EXTRAS(9)) /* ^ */ -#define DBG_LINE (1LL << DBG_EXTRAS(9)) /* @ ($LINENO) */ -#define DBG_PID (1LL << DBG_EXTRAS(10)) /* $ ($$) */ -#define DBG_NEST (1LL << DBG_EXTRAS(11)) /* ^ */ +/* 26 lower case, 26 upper case, always, verbose, and 10 extras: 64 bits */ extern void set_debug(const char *, int); #else /* DEBUG */ -#define TRACE(param) /* historic normal trace */ -#define TRACEV(param) /* historic varargs trace */ - #define CTRACE(when, param) /* conditional normal trace */ #define CCTRACE(when, cond, param) /* more conditional normal trace */ #define CTRACEV(when, param) /* conditional varargs trace */ Index: src/bin/sh/show.c diff -u src/bin/sh/show.c:1.50 src/bin/sh/show.c:1.51 --- src/bin/sh/show.c:1.50 Thu Oct 18 04:44:27 2018 +++ src/bin/sh/show.c Mon Jan 21 14:29:12 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: show.c,v 1.50 2018/10/18 04:44:27 kre Exp $ */ +/* $NetBSD: show.c,v 1.51 2019/01/21 14:29:12 kre Exp $ */ /*- * Copyright (c) 1991, 1993 @@ -39,7 +39,7 @@ #if 0 static char sccsid[] = "@(#)show.c 8.3 (Berkeley) 5/4/95"; #else -__RCSID("$NetBSD: show.c,v 1.50 2018/10/18 04:44:27 kre Exp $"); +__RCSID("$NetBSD: show.c,v 1.51 2019/01/21 14:29:12 kre Exp $"); #endif #endif /* not lint */ @@ -1077,20 +1077,21 @@ static struct debug_flag { { '0', DBG_U0 }, /* ad-hoc temp debug flag #0 */ { '1', DBG_U1 }, /* ad-hoc temp debug flag #1 */ { '2', DBG_U2 }, /* ad-hoc temp debug flag #2 */ + { '3', DBG_U3 }, /* ad-hoc temp debug flag #3 */ { '@', DBG_LINE }, /* prefix trace lines with line# */ { '$', DBG_PID }, /* prefix trace lines with sh pid */ { '^', DBG_NEST }, /* show shell nesting level */ /* alpha options only */ - { '_', DBG_PARSE | DBG_EVAL | DBG_EXPAND | DBG_JOBS | + { '_', DBG_PARSE | DBG_EVAL | DBG_EXPAND | DBG_JOBS | DBG_SIG | DBG_PROCS | DBG_REDIR | DBG_CMDS | DBG_ERRS | - DBG_WAIT | DBG_TRAP | DBG_VARS | DBG_MEM | + DBG_WAIT | DBG_TRAP | DBG_VARS | DBG_MEM | DBG_MATCH | DBG_INPUT | DBG_OUTPUT | DBG_ARITH | DBG_HISTORY }, /* { '*', DBG_ALLVERBOSE }, is handled in the code */ - { '#', DBG_U0 | DBG_U1 | DBG_U2 }, + { '#', DBG_U0 | DBG_U1 | DBG_U2 | DBG_U3 }, { 0, 0 } };