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 changes only. NFC (NC) for any normally ...



details:   https://anonhg.NetBSD.org/src/rev/ecf46c02eaf5
branches:  trunk
changeset: 1025508:ecf46c02eaf5
user:      kre <kre%NetBSD.org@localhost>
date:      Wed Nov 10 15:26:34 2021 +0000

description:
DEBUG mode changes only.   NFC (NC) for any normally compiled shell.

Mostly adding DEBUG mode tracing (when appropriate verbose tracing
is enabled generally) whenever a shell (including sushell) process
exits, so shells that the tracing should indicate why ehslls that
vanish did that.

Note for future investigators: if the relevant tracing is enabled,
and a (sub-)shell still simply seems to have vanished without trace,
the likely cause is that it was killed by a signal - and of those,
the most common that occurs is SIGPIPE.

diffstat:

 bin/sh/error.c  |   5 +++--
 bin/sh/eval.c   |  10 ++++++++--
 bin/sh/expand.c |  13 ++++++++-----
 bin/sh/redir.c  |   6 +++---
 bin/sh/trap.c   |  10 ++++++++--
 5 files changed, 30 insertions(+), 14 deletions(-)

diffs (165 lines):

diff -r 2b5bb898f95c -r ecf46c02eaf5 bin/sh/error.c
--- a/bin/sh/error.c    Wed Nov 10 15:21:43 2021 +0000
+++ b/bin/sh/error.c    Wed Nov 10 15:26:34 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: error.c,v 1.43 2019/02/04 11:16:41 kre Exp $   */
+/*     $NetBSD: error.c,v 1.44 2021/11/10 15:26:34 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.43 2019/02/04 11:16:41 kre Exp $");
+__RCSID("$NetBSD: error.c,v 1.44 2021/11/10 15:26:34 kre Exp $");
 #endif
 #endif /* not lint */
 
@@ -221,6 +221,7 @@
 void
 sh_exit(int rval)
 {
+       VTRACE(DBG_ERRS|DBG_PROCS|DBG_CMDS, ("sh_exit(%d)\n", rval));
        exerrno = rval & 255;
        exraise(EXEXEC);
 }
diff -r 2b5bb898f95c -r ecf46c02eaf5 bin/sh/eval.c
--- a/bin/sh/eval.c     Wed Nov 10 15:21:43 2021 +0000
+++ b/bin/sh/eval.c     Wed Nov 10 15:26:34 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: eval.c,v 1.182 2021/04/04 13:24:07 kre Exp $   */
+/*     $NetBSD: eval.c,v 1.183 2021/11/10 15:26:34 kre Exp $   */
 
 /*-
  * Copyright (c) 1993
@@ -37,7 +37,7 @@
 #if 0
 static char sccsid[] = "@(#)eval.c     8.9 (Berkeley) 6/8/95";
 #else
-__RCSID("$NetBSD: eval.c,v 1.182 2021/04/04 13:24:07 kre Exp $");
+__RCSID("$NetBSD: eval.c,v 1.183 2021/11/10 15:26:34 kre Exp $");
 #endif
 #endif /* not lint */
 
@@ -1131,6 +1131,12 @@
                                 */
                                SHELL_FORKED();
                                if (setjmp(jmploc.loc)) {
+                                       VTRACE(DBG_EVAL|DBG_ERRS|
+                                         DBG_PROCS|DBG_CMDS|DBG_TRAP,
+                                         ("vfork child exit exception:%d "
+                                          "exitstatus:%d exerrno:%d\n",
+                                          exception, exitstatus, exerrno));
+
                                        if (exception == EXSHELLPROC) {
                                                /*
                                                 * We can't progress with the
diff -r 2b5bb898f95c -r ecf46c02eaf5 bin/sh/expand.c
--- a/bin/sh/expand.c   Wed Nov 10 15:21:43 2021 +0000
+++ b/bin/sh/expand.c   Wed Nov 10 15:26:34 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: expand.c,v 1.139 2021/09/10 22:11:03 rillig Exp $      */
+/*     $NetBSD: expand.c,v 1.140 2021/11/10 15:26:34 kre Exp $ */
 
 /*-
  * Copyright (c) 1991, 1993
@@ -37,7 +37,7 @@
 #if 0
 static char sccsid[] = "@(#)expand.c   8.5 (Berkeley) 5/15/95";
 #else
-__RCSID("$NetBSD: expand.c,v 1.139 2021/09/10 22:11:03 rillig Exp $");
+__RCSID("$NetBSD: expand.c,v 1.140 2021/11/10 15:26:34 kre Exp $");
 #endif
 #endif /* not lint */
 
@@ -148,6 +148,7 @@
 {
        int len;
 
+       VTRACE(DBG_EXPAND|DBG_REDIR, ("expandhere() fd=%d\n", fd));
        herefd = fd;
        expandarg(arg, NULL, 0);
        len = rmescapes(stackblock());
@@ -193,8 +194,9 @@
        argstr(arg->narg.text, flag);
        if (arglist == NULL) {
                STACKSTRNUL(expdest);
-               CTRACE(DBG_EXPAND, ("expandarg: no arglist, done (%d) \"%s\"\n",
-                   expdest - stackblock(), stackblock()));
+               CTRACE(DBG_EXPAND,
+                   ("expandarg: no arglist, done[%d] (len %d) \"%s\"\n",
+                   back_exitstatus, expdest - stackblock(), stackblock()));
                return;                 /* here document expanded */
        }
        STPUTC('\0', expdest);
@@ -698,7 +700,8 @@
                back_exitstatus = waitforjob(in.jp);
        if (quoted == 0)
                recordregion(startloc, dest - stackblock(), 0);
-       CTRACE(DBG_EXPAND, ("evalbackq: size=%d: \"%.*s\"\n",
+       CTRACE(DBG_EXPAND, ("evalbackq: [%d] size=%d: \"%.*s\"\n",
+               back_exitstatus,
                (int)((dest - stackblock()) - startloc),
                (int)((dest - stackblock()) - startloc),
                stackblock() + startloc));
diff -r 2b5bb898f95c -r ecf46c02eaf5 bin/sh/redir.c
--- a/bin/sh/redir.c    Wed Nov 10 15:21:43 2021 +0000
+++ b/bin/sh/redir.c    Wed Nov 10 15:26:34 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: redir.c,v 1.69 2021/09/15 20:21:47 kre Exp $   */
+/*     $NetBSD: redir.c,v 1.70 2021/11/10 15:26:34 kre Exp $   */
 
 /*-
  * Copyright (c) 1991, 1993
@@ -37,7 +37,7 @@
 #if 0
 static char sccsid[] = "@(#)redir.c    8.2 (Berkeley) 5/4/95";
 #else
-__RCSID("$NetBSD: redir.c,v 1.69 2021/09/15 20:21:47 kre Exp $");
+__RCSID("$NetBSD: redir.c,v 1.70 2021/11/10 15:26:34 kre Exp $");
 #endif
 #endif /* not lint */
 
@@ -480,7 +480,7 @@
                        xwrite(pip[1], redir->nhere.doc->narg.text, len);
                else
                        expandhere(redir->nhere.doc, pip[1]);
-               VTRACE(DBG_PROCS|DBG_REDIR, ("wrote here doc.  exiting\n"));
+               VTRACE(DBG_PROCS|DBG_REDIR, ("wrote here doc.  exiting(0)\n"));
                _exit(0);
        }
        VTRACE(DBG_REDIR, ("openhere (closing %d)", pip[1]));
diff -r 2b5bb898f95c -r ecf46c02eaf5 bin/sh/trap.c
--- a/bin/sh/trap.c     Wed Nov 10 15:21:43 2021 +0000
+++ b/bin/sh/trap.c     Wed Nov 10 15:26:34 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: trap.c,v 1.55 2020/08/20 23:09:56 kre Exp $    */
+/*     $NetBSD: trap.c,v 1.56 2021/11/10 15:26:34 kre Exp $    */
 
 /*-
  * Copyright (c) 1991, 1993
@@ -37,7 +37,7 @@
 #if 0
 static char sccsid[] = "@(#)trap.c     8.5 (Berkeley) 6/5/95";
 #else
-__RCSID("$NetBSD: trap.c,v 1.55 2020/08/20 23:09:56 kre Exp $");
+__RCSID("$NetBSD: trap.c,v 1.56 2021/11/10 15:26:34 kre Exp $");
 #endif
 #endif /* not lint */
 
@@ -908,8 +908,14 @@
                sigaddset(&sigs, s);
                sigprocmask(SIG_UNBLOCK, &sigs, NULL);
 
+               VTRACE(DBG_ERRS|DBG_PROCS|DBG_CMDS|DBG_TRAP,
+                   ("exitshell_savedstatus(): pid %d Death by signal %d\n",
+                       getpid(), s));
                kill(getpid(), s);
        }
+       VTRACE(DBG_ERRS|DBG_PROCS|DBG_CMDS|DBG_TRAP,
+           ("exitshell_savedstatus(): pid %d exiting(%d)\n",
+               getpid(), exiting_status));
        _exit(exiting_status);
        /* NOTREACHED */
 }



Home | Main Index | Thread Index | Old Index