Ignore:
Timestamp:
Sep 17, 2020, 11:52:16 PM (5 years ago)
Author:
bird
Message:

kash: Use kHlpAssert instead of assert.h (debugger stops on the assertion rather than at exit process code).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/kash/shinstance.c

    r3476 r3477  
    3232#include <string.h>
    3333#include <stdlib.h>
    34 #include <assert.h>
    3534#ifdef _MSC_VER
    3635# include <process.h>
     
    174173{
    175174#if K_OS == K_OS_WINDOWS
    176     assert(ptmp->i == 0x42);
     175    kHlpAssert(ptmp->i == 0x42);
    177176    LeaveCriticalSection((CRITICAL_SECTION *)pmtx);
    178177    ptmp->i = 0x21;
     
    190189void sh_init_globals(void)
    191190{
    192     assert(g_sh_mtx.au64[SHMTX_MAGIC_IDX] != SHMTX_MAGIC);
     191    kHlpAssert(g_sh_mtx.au64[SHMTX_MAGIC_IDX] != SHMTX_MAGIC);
    193192    shmtx_init(&g_sh_mtx);
    194193#ifndef SH_FORKED_MODE
     
    317316    sh_free(psh, psh->threadarg);
    318317    psh->threadarg = NULL;
    319     assert(!psh->subshellstatus);
     318    kHlpAssert(!psh->subshellstatus);
    320319    if (psh->subshellstatus)
    321320    {
     
    910909                else
    911910                {
    912                     assert(old.sa_handler == SIG_IGN);
     911                    kHlpAssert(old.sa_handler == SIG_IGN);
    913912                    shold.sh_handler = SH_SIG_IGN;
    914913                }
     
    919918                /* fake */
    920919#ifndef _MSC_VER
    921                 assert(0);
     920                kHlpAssert(0);
    922921                old.sa_handler = SIG_DFL;
    923922                old.sa_flags = 0;
     
    945944            for (cur = g_sh_head; cur; cur = cur->next)
    946945            {
    947                 assert(cur->sigactions[signo].sh_handler == SH_SIG_UNK);
     946                kHlpAssert(cur->sigactions[signo].sh_handler == SH_SIG_UNK);
    948947                cur->sigactions[signo] = shold;
    949948            }
     
    988987    else
    989988    {
    990         assert(pfn != SH_SIG_ERR);
     989        kHlpAssert(pfn != SH_SIG_ERR);
    991990        pfn(pshDst, signo);
    992991    }
     
    11251124                && signo != SIGTTOU
    11261125                && signo != SIGCONT)
    1127                 assert(0);
     1126                kHlpAssert(0);
    11281127        }
    11291128#else
    11301129        if (sigaction(signo, &g_sig_state[signo].sa, NULL))
    1131             assert(0);
     1130            kHlpAssert(0);
    11321131#endif
    11331132
     
    14171416{
    14181417    unsigned refs = sh_atomic_dec(&sts->refs);
    1419     assert(refs > 1);
    1420     assert(refs < 16);
     1418    kHlpAssert(refs > 1);
     1419    kHlpAssert(refs < 16);
    14211420    return refs;
    14221421}
     
    14281427{
    14291428    unsigned refs = sh_atomic_dec(&sts->refs);
    1430     assert(refs < ~(unsigned)0/4);
     1429    kHlpAssert(refs < ~(unsigned)0/4);
    14311430    if (refs == 0)
    14321431    {
     
    14631462# if K_OS == K_OS_WINDOWS
    14641463        BOOL rc = ResetEvent((HANDLE)sts->towaiton);
    1465         assert(rc); K_NOREF(rc);
     1464        kHlpAssert(rc); K_NOREF(rc);
    14661465# endif
    14671466    }
     
    14771476        if (!sts->towaiton)
    14781477        {
    1479             assert(0);
     1478            kHlpAssert(0);
    14801479            sh_free(psh, sts);
    14811480            return NULL;
     
    15081507        sts->status = W_EXITCODE(iExit, 0);
    15091508        sts->done   = K_TRUE;
    1510         rc = SetEvent((HANDLE)sts->towaiton); assert(rc); K_NOREF(rc);
     1509        rc = SetEvent((HANDLE)sts->towaiton); kHlpAssert(rc); K_NOREF(rc);
    15111510
    15121511        hThread = (HANDLE)sts->hThread;
    15131512        sts->hThread = 0;
    1514         rc = CloseHandle(hThread); assert(rc);
     1513        rc = CloseHandle(hThread); kHlpAssert(rc);
    15151514
    15161515        shsubshellstatus_release(psh, sts);
     
    17811780            {
    17821781                rc = psh->children[i].subshellstatus->done;
    1783                 assert(rc);
     1782                kHlpAssert(rc);
    17841783                if (rc)
    17851784                {
     
    18121811        {
    18131812            rc = CloseHandle(psh->children[i].hChild);
    1814             assert(rc);
     1813            kHlpAssert(rc);
    18151814        }
    18161815
     
    21152114                 */
    21162115                dwErr = WaitForSingleObject(ProcInfo.hProcess, INFINITE);
    2117                 assert(dwErr == WAIT_OBJECT_0);
     2116                kHlpAssert(dwErr == WAIT_OBJECT_0);
    21182117
    21192118                if (GetExitCodeProcess(ProcInfo.hProcess, &dwExitCode))
     
    21292128                /* this shouldn't happen... */
    21302129                TRACE2((psh, "sh_execve: GetExitCodeProcess failed: %u\n", GetLastError()));
    2131                 assert(0);
     2130                kHlpAssert(0);
    21322131                errno = EINVAL;
    21332132            }
     
    22262225    shpid pgid = psh->pgid;
    22272226#ifndef _MSC_VER
    2228     assert(pgid == getpgrp());
     2227    kHlpAssert(pgid == getpgrp());
    22292228#endif
    22302229
     
    22442243        shpid pgid = psh->pgid;
    22452244#ifndef _MSC_VER
    2246         assert(pgid == getpgrp());
     2245        kHlpAssert(pgid == getpgrp());
    22472246#endif
    22482247    }
    22492248    else
    22502249    {
    2251         assert(0);
     2250        kHlpAssert(0);
    22522251        errno = ESRCH;
    22532252        pgid = -1;
Note: See TracChangeset for help on using the changeset viewer.