Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/bin/sh DEBUG mode shell cleanups (NFC for any normal shell).



details:   https://anonhg.NetBSD.org/src/rev/0a1b11593f97
branches:  trunk
changeset: 447691:0a1b11593f97
user:      kre <kre%NetBSD.org@localhost>
date:      Mon Jan 21 14:29:12 2019 +0000

description:
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".

diffstat:

 bin/sh/error.c |   5 +++--
 bin/sh/shell.h |  20 ++++++++++----------
 bin/sh/show.c  |  11 ++++++-----
 3 files changed, 19 insertions(+), 17 deletions(-)

diffs (118 lines):

diff -r cb95f18894b1 -r 0a1b11593f97 bin/sh/error.c
--- a/bin/sh/error.c    Mon Jan 21 14:24:44 2019 +0000
+++ b/bin/sh/error.c    Mon Jan 21 14:29:12 2019 +0000
@@ -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 @@
 void
 exraise(int e)
 {
+       CTRACE(DBG_ERRS, ("exraise(%d)\n", e));
        if (handler == NULL)
                abort();
        exception = e;
diff -r cb95f18894b1 -r 0a1b11593f97 bin/sh/shell.h
--- a/bin/sh/shell.h    Mon Jan 21 14:24:44 2019 +0000
+++ b/bin/sh/shell.h    Mon Jan 21 14:29:12 2019 +0000
@@ -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 @@
  * 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 @@
        /* 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 */
diff -r cb95f18894b1 -r 0a1b11593f97 bin/sh/show.c
--- a/bin/sh/show.c     Mon Jan 21 14:24:44 2019 +0000
+++ b/bin/sh/show.c     Mon Jan 21 14:29:12 2019 +0000
@@ -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 @@
        { '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               }
 };



Home | Main Index | Thread Index | Old Index