Source-Changes-HG archive

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

[src/trunk]: src/bin/sh More DEBUG mode changes. As usual, read the source ...



details:   https://anonhg.NetBSD.org/src/rev/0125cb88daf0
branches:  trunk
changeset: 824256:0125cb88daf0
user:      kre <kre%NetBSD.org@localhost>
date:      Mon May 29 14:03:23 2017 +0000

description:
More DEBUG mode changes.   As usual, read the source if you care.

diffstat:

 bin/sh/Makefile  |   4 ++--
 bin/sh/main.c    |   9 ++++++---
 bin/sh/options.c |   6 +++---
 bin/sh/shell.h   |   7 +++++--
 bin/sh/show.c    |  25 ++++++++++++++++++++-----
 5 files changed, 36 insertions(+), 15 deletions(-)

diffs (178 lines):

diff -r 26799739f575 -r 0125cb88daf0 bin/sh/Makefile
--- a/bin/sh/Makefile   Mon May 29 10:43:27 2017 +0000
+++ b/bin/sh/Makefile   Mon May 29 14:03:23 2017 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: Makefile,v 1.109 2017/05/28 14:14:22 kre Exp $
+#      $NetBSD: Makefile,v 1.110 2017/05/29 14:03:23 kre Exp $
 #      @(#)Makefile    8.4 (Berkeley) 5/5/95
 
 .include <bsd.own.mk>
@@ -25,7 +25,7 @@
 
 CPPFLAGS+=-DSHELL -I. -I${.CURDIR}
 #XXX: For testing only.
-#CPPFLAGS+=-DDEBUG=2
+#CPPFLAGS+=-DDEBUG=3
 #COPTS+=-g
 #CFLAGS+=-funsigned-char
 #TARGET_CHARFLAG?= -DTARGET_CHAR="unsigned char" -funsigned-char
diff -r 26799739f575 -r 0125cb88daf0 bin/sh/main.c
--- a/bin/sh/main.c     Mon May 29 10:43:27 2017 +0000
+++ b/bin/sh/main.c     Mon May 29 14:03:23 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: main.c,v 1.69 2017/05/18 13:28:00 kre Exp $    */
+/*     $NetBSD: main.c,v 1.70 2017/05/29 14:03:23 kre Exp $    */
 
 /*-
  * Copyright (c) 1991, 1993
@@ -42,7 +42,7 @@
 #if 0
 static char sccsid[] = "@(#)main.c     8.7 (Berkeley) 7/19/95";
 #else
-__RCSID("$NetBSD: main.c,v 1.69 2017/05/18 13:28:00 kre Exp $");
+__RCSID("$NetBSD: main.c,v 1.70 2017/05/29 14:03:23 kre Exp $");
 #endif
 #endif /* not lint */
 
@@ -172,11 +172,14 @@
        }
        handler = &jmploc;
 #ifdef DEBUG
-#if DEBUG == 2
+#if DEBUG >= 2
        debug = 1;      /* this may be reset by procargs() later */
 #endif
        opentrace();
        trputs("Shell args:  ");  trargs(argv);
+#if DEBUG >= 3
+       set_debug(((DEBUG)==3 ? "_^" : "++"), 1);
+#endif
 #endif
        rootpid = getpid();
        rootshell = 1;
diff -r 26799739f575 -r 0125cb88daf0 bin/sh/options.c
--- a/bin/sh/options.c  Mon May 29 10:43:27 2017 +0000
+++ b/bin/sh/options.c  Mon May 29 14:03:23 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: options.c,v 1.48 2017/05/18 13:53:18 kre Exp $ */
+/*     $NetBSD: options.c,v 1.49 2017/05/29 14:03:23 kre Exp $ */
 
 /*-
  * Copyright (c) 1991, 1993
@@ -37,7 +37,7 @@
 #if 0
 static char sccsid[] = "@(#)options.c  8.2 (Berkeley) 5/4/95";
 #else
-__RCSID("$NetBSD: options.c,v 1.48 2017/05/18 13:53:18 kre Exp $");
+__RCSID("$NetBSD: options.c,v 1.49 2017/05/29 14:03:23 kre Exp $");
 #endif
 #endif /* not lint */
 
@@ -117,7 +117,7 @@
        if (usefork == 2)
                usefork = 1;
 #endif
-#if DEBUG == 2
+#if DEBUG >= 2
        if (debug == 2)
                debug = 1;
 #endif
diff -r 26799739f575 -r 0125cb88daf0 bin/sh/shell.h
--- a/bin/sh/shell.h    Mon May 29 10:43:27 2017 +0000
+++ b/bin/sh/shell.h    Mon May 29 14:03:23 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: shell.h,v 1.22 2017/05/27 11:19:57 kre Exp $   */
+/*     $NetBSD: shell.h,v 1.23 2017/05/29 14:03:23 kre Exp $   */
 
 /*-
  * Copyright (c) 1991, 1993
@@ -40,7 +40,9 @@
  *     define BSD if you are running 4.2 BSD or later.
  *     define SYSV if you are running under System V.
  *     define DEBUG=1 to compile in debugging ('set -o debug' to turn on)
- *     define DEBUG=2 to compile in and turn on debugging.
+ *     define DEBUG=2 to compile in and enable debugging.
+ *     define DEBUG=3 for DEBUG==2 + enable most standard debug output
+ *     define DEBUG=4 for DEBUG==2 + enable absolutely everything
  *     define DO_SHAREDVFORK to indicate that vfork(2) shares its address
  *            with its parent.
  *     define BOGUS_NOT_COMMAND to allow ! reserved words in weird places
@@ -190,6 +192,7 @@
 #define        DBG_U1          (1LL << DBG_EXTRAS(1))  /* 1 - for short term */
 #define        DBG_U2          (1LL << DBG_EXTRAS(2))  /* 2 - extra tracing*/
 
+#define        DBG_LINE        (1LL << DBG_EXTRAS(9))  /* @ ($LINENO) */
 #define        DBG_PID         (1LL << DBG_EXTRAS(10)) /* $ ($$) */
 #define        DBG_NEST        (1LL << DBG_EXTRAS(11)) /* ^ */
 
diff -r 26799739f575 -r 0125cb88daf0 bin/sh/show.c
--- a/bin/sh/show.c     Mon May 29 10:43:27 2017 +0000
+++ b/bin/sh/show.c     Mon May 29 14:03:23 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: show.c,v 1.41 2017/05/18 15:42:37 kre Exp $    */
+/*     $NetBSD: show.c,v 1.42 2017/05/29 14:03:23 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.41 2017/05/18 15:42:37 kre Exp $");
+__RCSID("$NetBSD: show.c,v 1.42 2017/05/29 14:03:23 kre Exp $");
 #endif
 #endif /* not lint */
 
@@ -63,6 +63,7 @@
 #include "redir.h"
 #include "error.h"
 #include "syntax.h"
+#include "input.h"
 #include "output.h"
 #include "builtins.h"
 
@@ -924,6 +925,7 @@
        int i;
        char indent[16];
        char *p;
+       int lno;
 
        if (DFlags & DBG_NEST) {
                if ((unsigned)ShNest >= sizeof indent - 1) {
@@ -941,13 +943,25 @@
        } else
                indent[0] = '\0';
 
+       lno = plinno;   /* only approximate for now - as good as we can do */
+
        if (DFlags & DBG_PID) {
                i = getpid();
-               (void) asprintf(&p, "%5d%c%s\t", i,
-                   i == tf->pid ? ':' : '=', indent);
+               if (DFlags & DBG_LINE)
+                       (void) asprintf(&p, "%5d%c%s\t%4d @\t", i,
+                           i == tf->pid ? ':' : '=', indent, lno);
+               else
+                       (void) asprintf(&p, "%5d%c%s\t", i,
+                           i == tf->pid ? ':' : '=', indent);
                return p;
        } else if (DFlags & DBG_NEST) {
-               (void) asprintf(&p, "%s\t", indent);
+               if (DFlags & DBG_LINE)
+                       (void) asprintf(&p, "%s\t%4d @\t", indent, lno);
+               else
+                       (void) asprintf(&p, "%s\t", indent);
+               return p;
+       } else if (DFlags & DBG_LINE) {
+               (void) asprintf(&p, "%4d @\t", lno);
                return p;
        }
        return NULL;
@@ -1050,6 +1064,7 @@
        { '1',  DBG_U1          },      /* ad-hoc temp debug flag #1 */
        { '2',  DBG_U2          },      /* ad-hoc temp debug flag #2 */
  
+       { '@',  DBG_LINE        },      /* prefix trace lines with line# */
        { '$',  DBG_PID         },      /* prefix trace lines with sh pid */
        { '^',  DBG_NEST        },      /* show shell nesting level */
 



Home | Main Index | Thread Index | Old Index