Changeset 3413 for trunk/src/kmk


Ignore:
Timestamp:
Aug 20, 2020, 10:20:15 AM (5 years ago)
Author:
bird
Message:

kmk/kSubmit: Only dump history when asked to.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/kmk/kmkbuiltin/kSubmit.c

    r3363 r3413  
    122122#endif
    123123
     124    /** --debug-dump-history-on-failure.   */
     125    int                     fDebugDumpHistoryOnFailure;
    124126    /** Current history index (must mod with aHistory element count). */
    125127    unsigned                iHistory;
     
    15521554        case STATUS_ILLEGAL_INSTRUCTION:        *piSigNo = SIGILL; break;
    15531555    }
    1554     if (pWorker->Result.s.rcExit && 1)
     1556    if (pWorker->Result.s.rcExit && pWorker->fDebugDumpHistoryOnFailure)
    15551557        kSubmitDumpHistory(pCtx, pWorker);
    15561558    if (pWorker->Result.s.bWorkerExiting)
     
    17581760                           "    More verbose execution.\n"
    17591761                           "  --debug-dump-history\n"
    1760                            "    Dump the history as of the submitted command.  Handy for debuging\n"
     1762                           "    Dump the history as of the submitted command.  Handy for debugging\n"
    17611763                           "    trouble caused by a previous job.\n"
     1764                           "  --debug-dump-history-on-failure, --no-debug-dump-history-on-failure\n"
     1765                           "    Dump the history on failure.  Can also be enabled by a non-empty\n"
     1766                           "    KMK_KSUBMIT_DUMP_HISTORY_ON_FAILURE variable (first invocation only).\n"
    17621767                           "  -P|--post-cmd <cmd> ...\n"
    17631768                           "    For running a built-in command on the output, specifying the command\n"
     
    17931798    int             fNoPchCaching       = 0;
    17941799    int             fDebugDumpHistory   = 0;
     1800    static int      s_fDebugDumpHistoryOnFailure = -1;
     1801    int             fDebugDumpHistoryOnFailure = s_fDebugDumpHistoryOnFailure;
    17951802    int             cVerbosity          = 0;
    17961803    size_t const    cbCwdBuf            = GET_PATH_MAX;
     
    18131820    }
    18141821#endif
     1822    if (fDebugDumpHistoryOnFailure != -1)
     1823    { /* likely */ }
     1824    else
     1825    {
     1826        struct variable *pVar = lookup_variable(TUPLE("KMK_KSUBMIT_DUMP_HISTORY_ON_FAILURE"));
     1827        fDebugDumpHistoryOnFailure = pVar && *pVar->value != '\0';
     1828        s_fDebugDumpHistoryOnFailure = fDebugDumpHistoryOnFailure;
     1829    }
    18151830
    18161831    /*
     
    18801895                }
    18811896
     1897                if (strcmp(pszArg, "debug-dump-history-on-failure") == 0)
     1898                {
     1899                    fDebugDumpHistoryOnFailure = 1;
     1900                    continue;
     1901                }
     1902
     1903                if (strcmp(pszArg, "no-debug-dump-history-on-failure") == 0)
     1904                {
     1905                    fDebugDumpHistoryOnFailure = 0;
     1906                    continue;
     1907                }
    18821908
    18831909                /* convert to short. */
     
    20612087#endif
    20622088                output_dump(pCtx->pOut);
     2089            pWorker->fDebugDumpHistoryOnFailure = fDebugDumpHistoryOnFailure;
    20632090            rcExit = kSubmitSendJobMessage(pCtx, pWorker, pvMsg, cbMsg, 0 /*fNoRespawning*/, cVerbosity);
    20642091            if (rcExit == 0)
Note: See TracChangeset for help on using the changeset viewer.