Module Name: src
Committed By: kre
Date: Mon May 29 14:03:23 UTC 2017
Modified Files:
src/bin/sh: Makefile main.c options.c shell.h show.c
Log Message:
More DEBUG mode changes. As usual, read the source if you care.
To generate a diff of this commit:
cvs rdiff -u -r1.109 -r1.110 src/bin/sh/Makefile
cvs rdiff -u -r1.69 -r1.70 src/bin/sh/main.c
cvs rdiff -u -r1.48 -r1.49 src/bin/sh/options.c
cvs rdiff -u -r1.22 -r1.23 src/bin/sh/shell.h
cvs rdiff -u -r1.41 -r1.42 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/Makefile
diff -u src/bin/sh/Makefile:1.109 src/bin/sh/Makefile:1.110
--- src/bin/sh/Makefile:1.109 Sun May 28 14:14:22 2017
+++ src/bin/sh/Makefile Mon May 29 14:03:23 2017
@@ -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 @@ SCRIPT_ENV= \
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
Index: src/bin/sh/main.c
diff -u src/bin/sh/main.c:1.69 src/bin/sh/main.c:1.70
--- src/bin/sh/main.c:1.69 Thu May 18 13:28:00 2017
+++ src/bin/sh/main.c Mon May 29 14:03:23 2017
@@ -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 @@ __COPYRIGHT("@(#) Copyright (c) 1991, 19
#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 @@ main(int argc, char **argv)
}
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;
Index: src/bin/sh/options.c
diff -u src/bin/sh/options.c:1.48 src/bin/sh/options.c:1.49
--- src/bin/sh/options.c:1.48 Thu May 18 13:53:18 2017
+++ src/bin/sh/options.c Mon May 29 14:03:23 2017
@@ -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 @@ procargs(int argc, char **argv)
if (usefork == 2)
usefork = 1;
#endif
-#if DEBUG == 2
+#if DEBUG >= 2
if (debug == 2)
debug = 1;
#endif
Index: src/bin/sh/shell.h
diff -u src/bin/sh/shell.h:1.22 src/bin/sh/shell.h:1.23
--- src/bin/sh/shell.h:1.22 Sat May 27 11:19:57 2017
+++ src/bin/sh/shell.h Mon May 29 14:03:23 2017
@@ -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 @@ extern int ShNest;
#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)) /* ^ */
Index: src/bin/sh/show.c
diff -u src/bin/sh/show.c:1.41 src/bin/sh/show.c:1.42
--- src/bin/sh/show.c:1.41 Thu May 18 15:42:37 2017
+++ src/bin/sh/show.c Mon May 29 14:03:23 2017
@@ -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 @@ __RCSID("$NetBSD: show.c,v 1.41 2017/05/
#include "redir.h"
#include "error.h"
#include "syntax.h"
+#include "input.h"
#include "output.h"
#include "builtins.h"
@@ -924,6 +925,7 @@ trace_id(TFILE *tf)
int i;
char indent[16];
char *p;
+ int lno;
if (DFlags & DBG_NEST) {
if ((unsigned)ShNest >= sizeof indent - 1) {
@@ -941,13 +943,25 @@ trace_id(TFILE *tf)
} 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 @@ static struct debug_flag {
{ '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 */