Changeset 3477 for trunk/src


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).

Location:
trunk/src/kash
Files:
20 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/kash/Makefile.kmk

    r3470 r3477  
    4242kash_DEFS += KASH_SEPARATE_PARSER_ALLOCATOR KASH_ASYNC_CLOSE_HANDLE
    4343endif
    44 kash_DEFS.debug = DEBUG=2
     44kash_DEFS.debug = DEBUG=2 K_STRICT
    4545kash_DEFS.haiku = BSD
    4646kash_DEFS.linux = BSD
  • trunk/src/kash/error.c

    r3438 r3477  
    371371        return psh->errmsg_buf;
    372372}
     373
     374
     375#ifdef K_STRICT
     376
     377KHLP_DECL(void) kHlpAssertMsg1(const char *pszExpr, const char *pszFile, unsigned iLine, const char *pszFunction)
     378{
     379        shinstance *psh = shthread_get_shell();
     380
     381        TRACE((psh,  "Assertion failed in %s --- %s --- %s(%u)\n", pszFunction, pszExpr, pszFile, iLine));
     382        dprintf(psh, "Assertion failed in %s --- %s --- %s(%u)\n", pszFunction, pszExpr, pszFile, iLine);
     383}
     384
     385KHLP_DECL(void) kHlpAssertMsg2(const char *pszFormat, ...)
     386{
     387        shinstance *psh = shthread_get_shell();
     388        va_list va;
     389        va_start(va, pszFormat);
     390        doformat(psh->out2, pszFormat, va);
     391        va_end(va);
     392}
     393
     394#endif /* K_STRICT */
  • trunk/src/kash/eval.c

    r3475 r3477  
    4141#endif
    4242
    43 #include <assert.h>
    4443#include <stddef.h>
    4544#include <stdlib.h>
     
    528527                        break;
    529528                default:
    530                         assert(redir->type == NHERE || redir->type == NXHERE);
     529                        kHlpAssert(redir->type == NHERE || redir->type == NXHERE);
    531530                        expfnames->names[i] = NULL;
    532531                        break;
    533532                }
    534533        }
    535         assert(i == expfnames->count);
     534        kHlpAssert(i == expfnames->count);
    536535
    537536        /* Do the linking at the end, as nesting happens when we expand backtick arguments. */
     
    545544{
    546545        redirexpfnames *expfnames = psh->expfnames;
    547         assert(expfnames == NULL ? depth == 0 : expfnames->depth == depth || expfnames->depth + 1 == depth);
     546        kHlpAssert(expfnames == NULL ? depth == 0 : expfnames->depth == depth || expfnames->depth + 1 == depth);
    548547        while (expfnames && expfnames->depth >= depth)
    549548            expfnames = psh->expfnames = expfnames->prev;
  • trunk/src/kash/exec.c

    r3475 r3477  
    4646#include <stdlib.h>
    4747#include <stddef.h>
    48 #include <assert.h>
    4948
    5049/*
     
    307306                int suffix;
    308307                int isreg = stat_pc_exec_exts(psh, cmd, 0, &suffix);
    309                 assert(isreg > 0);
     308                kHlpAssert(isreg > 0);
    310309        }
    311310#endif
  • trunk/src/kash/expand.c

    r3456 r3477  
    4545#include <stdlib.h>
    4646#include <stdio.h>
    47 #include <assert.h>
    4847
    4948/*
  • trunk/src/kash/main.c

    r3474 r3477  
    4545#endif
    4646
    47 #include <assert.h>
    4847#include <errno.h>
    4948#include <stdio.h>
  • trunk/src/kash/memalloc.c

    r3462 r3477  
    4343#include <stdlib.h>
    4444#include <stddef.h>
    45 #include <assert.h>
    4645
    4746#include "shell.h"
     
    332331        size_t nbytes = (size_t)(end - pstart);
    333332
    334         assert((uintptr_t)end >= (uintptr_t)pstart);
    335         /*assert(end[-1] == '\0'); - not if it's followed by ungrabstrackstr(), sigh. */
    336         assert(SHELL_ALIGN((uintptr_t)pstart) == (uintptr_t)pstart);
    337         assert(stackblocksize(psh) - psh->sstrnleft >= nbytes);
     333        kHlpAssert((uintptr_t)end >= (uintptr_t)pstart);
     334        /*kHlpAssert(end[-1] == '\0'); - not if it's followed by ungrabstrackstr(), sigh. */
     335        kHlpAssert(SHELL_ALIGN((uintptr_t)pstart) == (uintptr_t)pstart);
     336        kHlpAssert(stackblocksize(psh) - psh->sstrnleft >= nbytes);
    338337
    339338        nbytes = SHELL_ALIGN(nbytes);
    340339        psh->stacknxt += nbytes;
    341340        psh->stacknleft -= (int)nbytes;
    342         assert(psh->stacknleft >= 0);
     341        kHlpAssert(psh->stacknleft >= 0);
    343342
    344343        return pstart;
     
    348347ungrabstackstr(shinstance *psh, char *s, char *p)
    349348{
    350         assert((size_t)(psh->stacknxt - p) <= SHELL_SIZE);
    351         assert((uintptr_t)s >= (uintptr_t)&psh->stackp->space[0]);
    352         assert((uintptr_t)p >= (uintptr_t)s);
     349        kHlpAssert((size_t)(psh->stacknxt - p) <= SHELL_SIZE);
     350        kHlpAssert((uintptr_t)s >= (uintptr_t)&psh->stackp->space[0]);
     351        kHlpAssert((uintptr_t)p >= (uintptr_t)s);
    353352
    354353        psh->stacknleft += (int)(psh->stacknxt - s);
     
    374373                        while ((top = pst->top) != &pst->first) {
    375374                                pst->top = top->prev;
    376                                 assert(pst->top);
     375                                kHlpAssert(pst->top);
    377376                                top->prev = NULL;
    378377                                sh_free(psh, top);
     
    393392void pstackpop(shinstance *psh, unsigned target)
    394393{
    395         assert(target <= psh->pstacksize);
     394        kHlpAssert(target <= psh->pstacksize);
    396395        while (target < psh->pstacksize) {
    397396                unsigned idx = --psh->pstacksize;
     
    414413                        if (psh->curpstack == psh->pstack[i])
    415414                                break;
    416                 assert(i < psh->pstacksize);
     415                kHlpAssert(i < psh->pstacksize);
    417416        }
    418417# endif
     
    423422{
    424423        unsigned refs = sh_atomic_inc(&pst->refs);
    425         assert(refs > 1);
    426         assert(refs < 256 /* bogus, but useful */);
     424        kHlpAssert(refs > 1);
     425        kHlpAssert(refs < 256 /* bogus, but useful */);
    427426        return refs;
    428427}
     
    533532        size_t blocksize;
    534533
    535         assert(pst->avail < nbytes); /* only called when we need more space */
    536         assert(tocopy <= pst->avail);
     534        kHlpAssert(pst->avail < nbytes); /* only called when we need more space */
     535        kHlpAssert(tocopy <= pst->avail);
    537536
    538537        /* Double the size used thus far and add some fudge and alignment.  Make
     
    562561                char const * const copysrc = pst->nextbyte;
    563562                pstallocnewblock(psh, pst, nbytes);
    564                 assert(pst->avail >= nbytes);
    565                 assert(pst->avail >= tocopy);
     563                kHlpAssert(pst->avail >= nbytes);
     564                kHlpAssert(pst->avail >= tocopy);
    566565                memcpy(pst->nextbyte, copysrc, tocopy);
    567566        }
     
    646645        size_t const len = end - pst->nextbyte;
    647646
    648         assert(pst->avail - pst->strleft == len);
     647        kHlpAssert(pst->avail - pst->strleft == len);
    649648        TRACE2((psh, "pstmakestrspace: len=%u minbytes=%u (=> %u)\n", len, minbytes, len + minbytes));
    650649
     
    657656        size_t const len = end - stackblock(psh);
    658657
    659         assert(stackblocksize(psh) - psh->sstrnleft == len);
     658        kHlpAssert(stackblocksize(psh) - psh->sstrnleft == len);
    660659        TRACE2((psh, "pstmakestrspace: len=%u minbytes=%u (=> %u)\n", len, minbytes, len + minbytes));
    661660
     
    676675        pst->strleft++;         /* PSTPUTC() already incremented it. */
    677676        end = pstmakestrspace(psh, 1, end);
    678         assert(pst->strleft > 0);
     677        kHlpAssert(pst->strleft > 0);
    679678        pst->strleft--;
    680679#else
    681680        psh->sstrnleft++;       /* PSTPUTC() already incremented it. */
    682681        end = pstmakestrspace(psh, 1, end);
    683         assert(psh->sstrnleft > 0);
     682        kHlpAssert(psh->sstrnleft > 0);
    684683        psh->sstrnleft--;
    685684#endif
     
    696695        size_t nbytes = (size_t)(end - pstart);
    697696
    698         assert((uintptr_t)end > (uintptr_t)pstart);
    699         assert(end[-1] == '\0');
    700         assert(SHELL_ALIGN((uintptr_t)pstart) == (uintptr_t)pstart);
    701         assert(pst->avail - pst->strleft >= nbytes);
     697        kHlpAssert((uintptr_t)end > (uintptr_t)pstart);
     698        kHlpAssert(end[-1] == '\0');
     699        kHlpAssert(SHELL_ALIGN((uintptr_t)pstart) == (uintptr_t)pstart);
     700        kHlpAssert(pst->avail - pst->strleft >= nbytes);
    702701
    703702        nbytes = SHELL_ALIGN(nbytes); /** @todo don't align strings, align the other allocations. */
     
    712711        size_t nbytes = (size_t)(end - pstart);
    713712
    714         assert((uintptr_t)end > (uintptr_t)pstart);
    715         assert(end[-1] == '\0');
    716         assert(SHELL_ALIGN((uintptr_t)pstart) == (uintptr_t)pstart);
    717         assert(stackblocksize(psh) - psh->sstrnleft >= nbytes);
     713        kHlpAssert((uintptr_t)end > (uintptr_t)pstart);
     714        kHlpAssert(end[-1] == '\0');
     715        kHlpAssert(SHELL_ALIGN((uintptr_t)pstart) == (uintptr_t)pstart);
     716        kHlpAssert(stackblocksize(psh) - psh->sstrnleft >= nbytes);
    718717
    719718        nbytes = SHELL_ALIGN(nbytes); /** @todo don't align strings, align the other allocations. */
  • trunk/src/kash/memalloc.h

    r3461 r3477  
    7474#define STPUTC(psh, c, p)           (--(psh)->sstrnleft >= 0? (*p++ = (c)) : (p = growstackstr(psh), *p++ = (c)))
    7575#define CHECKSTRSPACE(psh, n, p)    { if ((psh)->sstrnleft < n) p = makestrspace(psh); }
    76 #define USTPUTC(psh, c, p)          do { assert((psh)->sstrnleft > 0); \
    77                                          assert(p - (char *)stackblock(psh) == stackblocksize(psh) - (psh)->sstrnleft); \
     76#define USTPUTC(psh, c, p)          do { kHlpAssert((psh)->sstrnleft > 0); \
     77                                         kHlpAssert(p - (char *)stackblock(psh) == stackblocksize(psh) - (psh)->sstrnleft); \
    7878                                         --(psh)->sstrnleft; *p++ = (c); } while (0)
    7979#define STACKSTRNUL(psh, p)         ((psh)->sstrnleft == 0? (p = growstackstr(psh), *p = '\0') : (*p = '\0'))
     
    114114# define PSTCHECKSTRSPACE(psh, n, p) do { \
    115115        if ((psh)->curpstack->strleft >= (n)) {/*likely*/} \
    116         else { (p) = pstmakestrspace(psh, (n), (p)); assert((psh)->curpstack->strleft >= (n)); } \
     116        else { (p) = pstmakestrspace(psh, (n), (p)); kHlpAssert((psh)->curpstack->strleft >= (n)); } \
    117117    } while (0)
    118118# define PSTUPUTC(psh, c, p) do { \
    119         assert((psh)->curpstack->strleft > 0); \
     119        kHlpAssert((psh)->curpstack->strleft > 0); \
    120120        (psh)->curpstack->strleft -= 1; \
    121121        *(p)++ = (c); \
     
    137137# define PSTARTSTACKSTR(psh, p)      do { (p) = (psh)->stacknxt; (psh)->sstrnleft = (psh)->stacknleft; } while (0)
    138138# define PSTCHECKSTRSPACE(psh, n, p) do { if ((psh)->sstrnleft >= (n)) {/*likely*/} \
    139                                          else { (p) = pstmakestrspace(psh, (n), (p)); assert((psh)->sstrnleft >= (n)); } } while (0)
    140 # define PSTUPUTC(psh, c, p)         do { assert((psh)->sstrnleft > 0); --(psh)->sstrnleft; *(p)++ = (c); } while (0)
     139                                         else { (p) = pstmakestrspace(psh, (n), (p)); kHlpAssert((psh)->sstrnleft >= (n)); } } while (0)
     140# define PSTUPUTC(psh, c, p)         do { kHlpAssert((psh)->sstrnleft > 0); --(psh)->sstrnleft; *(p)++ = (c); } while (0)
    141141# define PSTPUTC(psh, c, p)          do { if (--(psh)->sstrnleft >= 0) *(p)++ = (c); else (p) = pstputcgrow(psh, (p), (c)); } while (0)
    142142# define PSTPUTSTRN(psh, str, n, p)  do { if ((psh)->sstrnleft >= (n)) {/*likely?*/} else (p) = pstmakestrspace(psh, (n), (p)); \
  • trunk/src/kash/options.c

    r3445 r3477  
    4141#endif
    4242
    43 #include <assert.h>
    4443#include <stdlib.h>
    4544
     
    109108            i++;
    110109        }
    111         assert(psh->arg0 != NULL);
     110        kHlpAssert(psh->arg0 != NULL);
    112111    }
    113112
     
    131130    psh->shellparam.reset  = inherit->shellparam.reset;
    132131    psh->shellparam.nparam = left = inherit->shellparam.nparam;
    133     assert(left >= 0);
     132    kHlpAssert(left >= 0);
    134133    psh->shellparam.p = (char **)ckmalloc(psh, (left + 1) * sizeof(psh->shellparam.p[0]));
    135134    psh->shellparam.p[left] = NULL;
     
    142141    if (inherit->shellparam.optnext) {
    143142        size_t idx = (size_t)(inherit->shellparam.optnext - inherit->shellparam.p);
    144         assert(idx <= inherit->shellparam.nparam);
     143        kHlpAssert(idx <= inherit->shellparam.nparam);
    145144        if (idx <= inherit->shellparam.nparam)
    146145            psh->shellparam.optnext = &psh->shellparam.p[idx];
     
    169168            off--;
    170169        }
    171         assert(psh->shellparam.optptr != NULL);
     170        kHlpAssert(psh->shellparam.optptr != NULL);
    172171    }
    173172
     
    225224        psh->shellparam.p = psh->argptr;
    226225        psh->shellparam.reset = 1;
    227         /* assert(shellparam.malloc == 0 && shellparam.nparam == 0); */
     226        /* kHlpAssert(shellparam.malloc == 0 && shellparam.nparam == 0); */
    228227        while (*psh->argptr) {
    229228                psh->shellparam.nparam++;
  • trunk/src/kash/parser.c

    r3461 r3477  
    4343#define SH_MEMALLOC_NO_STACK
    4444#include <stdlib.h>
    45 #include <assert.h>
    4645
    4746#include "shell.h"
  • trunk/src/kash/redir.c

    r3473 r3477  
    4343#include <sys/types.h>
    4444#include <limits.h>         /* PIPE_BUF */
    45 #include <assert.h>
    4645#include <string.h>
    4746#include <errno.h>
     
    158157        idxexpfname = 0;
    159158        for (n = redir, idxexpfname = 0 ; n ; n = n->nfile.next, idxexpfname++) {
    160                 assert(idxexpfname < psh->expfnames->count);
     159                kHlpAssert(idxexpfname < psh->expfnames->count);
    161160                fd = n->nfile.fd;
    162161                try = 0;
     
    196195                        openredirect(psh, n, memory, flags, psh->expfnames->names[idxexpfname]);
    197196        }
    198         assert(!redir || idxexpfname == psh->expfnames->count);
     197        kHlpAssert(!redir || idxexpfname == psh->expfnames->count);
    199198        if (memory[1])
    200199                psh->out1 = &psh->memout;
  • trunk/src/kash/setmode.c

    r2498 r3477  
    4444#include <sys/stat.h>
    4545
    46 #include <assert.h>
    4746#include <ctype.h>
    4847#include <errno.h>
     
    7675
    7776#ifndef _DIAGASSERT
    78 # define _DIAGASSERT assert
     77# define _DIAGASSERT kHlpAssert
    7978#endif
    8079
  • trunk/src/kash/shfile.c

    r3473 r3477  
    3333#include <stdio.h>
    3434#include <string.h>
    35 #include <assert.h>
    3635
    3736#if K_OS == K_OS_WINDOWS
     
    235234        if (decrement_pending)
    236235        {
    237             assert(g_shfile_async_close.num_pending > 0);
     236            kHlpAssert(g_shfile_async_close.num_pending > 0);
    238237            g_shfile_async_close.num_pending -= 1;
    239238        }
     
    242241        if (idx != g_shfile_async_close.idx_write % K_ELEMENTS(g_shfile_async_close.handles))
    243242        {
    244             assert(g_shfile_async_close.num_pending > 0);
     243            kHlpAssert(g_shfile_async_close.num_pending > 0);
    245244            toclose = g_shfile_async_close.handles[idx];
    246             assert(toclose);
     245            kHlpAssert(toclose);
    247246            g_shfile_async_close.handles[idx] = NULL;
    248247            g_shfile_async_close.idx_read = (idx + 1) % K_ELEMENTS(g_shfile_async_close.handles);
     
    254253            {
    255254                BOOL rc = SetEvent(g_shfile_async_close.evt_sync);
    256                 assert(rc);
     255                kHlpAssert(rc);
    257256                g_shfile_async_close.signal_sync = FALSE;
    258257            }
     
    265264        {
    266265            BOOL rc = CloseHandle(toclose);
    267             assert(rc);
     266            kHlpAssert(rc);
    268267            decrement_pending = K_TRUE;
    269268        }
     
    271270        {
    272271            DWORD dwRet = WaitForSingleObject(g_shfile_async_close.evt_workers, 10000 /*ms*/);
    273             assert(dwRet == WAIT_OBJECT_0 || dwRet == WAIT_TIMEOUT);
     272            kHlpAssert(dwRet == WAIT_OBJECT_0 || dwRet == WAIT_TIMEOUT);
    274273            decrement_pending = K_FALSE;
    275274        }
     
    303302    {
    304303        /* Write the handle to the ring buffer: */
    305         assert(g_shfile_async_close.handles[idx] == NULL);
     304        kHlpAssert(g_shfile_async_close.handles[idx] == NULL);
    306305        g_shfile_async_close.handles[idx] = toclose;
    307306        g_shfile_async_close.idx_write    = idx_next;
     
    311310
    312311        ret = SetEvent(g_shfile_async_close.evt_workers);
    313         assert(ret);
     312        kHlpAssert(ret);
    314313        if (ret)
    315314        {
     
    322321                intptr_t hThread = _beginthreadex(NULL /*security*/, 0 /*stack_size*/, shfile_async_close_handle_thread,
    323322                                                  NULL /*arg*/, 0 /*initflags*/, &tid);
    324                 assert(hThread != -1);
     323                kHlpAssert(hThread != -1);
    325324                if (hThread != -1)
    326325                {
     
    375374        {
    376375            BOOL rc = ResetEvent(g_shfile_async_close.evt_sync);
    377             assert(rc); K_NOREF(rc);
     376            kHlpAssert(rc); K_NOREF(rc);
    378377
    379378            g_shfile_async_close.signal_sync = K_TRUE;
     
    384383        TRACE2((NULL, "shfile_async_close_sync: Calling WaitForSingleObject...\n"));
    385384        dwRet = WaitForSingleObject(g_shfile_async_close.evt_sync, 10000 /*ms*/);
    386         assert(dwRet == WAIT_OBJECT_0);
    387         assert(g_shfile_async_close.num_pending == 0);
     385        kHlpAssert(dwRet == WAIT_OBJECT_0);
     386        kHlpAssert(g_shfile_async_close.num_pending == 0);
    388387        TRACE2((NULL, "shfile_async_close_sync: WaitForSingleObject returned %u...\n", dwRet));
    389388    }
     
    441440    KU64 ns = shfile_nano_ts();
    442441    BOOL fRc = CloseHandle((HANDLE)native);
    443     assert(fRc); K_NOREF(fRc);
     442    kHlpAssert(fRc); K_NOREF(fRc);
    444443    ns = shfile_nano_ts() - ns;
    445444    if (ns > 1000000)
     
    448447#  else
    449448    BOOL fRc = CloseHandle((HANDLE)native);
    450     assert(fRc); K_NOREF(fRc);
     449    kHlpAssert(fRc); K_NOREF(fRc);
    451450#  endif
    452451    }
     
    656655{
    657656    shmtx_leave(&pfdtab->mtx, ptmp);
    658     assert(file);
     657    kHlpAssert(file);
    659658    (void)file;
    660659}
     
    10691068
    10701069                            fd2 = shfile_insert(pfdtab, (intptr_t)h, fFlags, fFlags2, i, "shtab_init", NULL);
    1071                             assert(fd2 == i); (void)fd2;
     1070                            kHlpAssert(fd2 == i); (void)fd2;
    10721071                            if (fd2 != i)
    10731072                                rc = -1;
     
    10951094                                fFlags2 = SHFILE_FLAGS_FILE;
    10961095                            fd2 = shfile_insert(pfdtab, (intptr_t)hFile, fFlags, fFlags2, i, "shtab_init", NULL);
    1097                             assert(fd2 == i); (void)fd2;
     1096                            kHlpAssert(fd2 == i); (void)fd2;
    10981097                            if (fd2 != i)
    10991098                                rc = -1;
     
    11361135                                native = fd;
    11371136                            fd2 = shfile_insert(pfdtab, native, oflags, fFlags2, fd, "shtab_init", NULL);
    1138                             assert(fd2 == fd); (void)fd2;
     1137                            kHlpAssert(fd2 == fd); (void)fd2;
    11391138                            if (fd2 != fd)
    11401139                                rc = -1;
     
    12681267#if K_OS == K_OS_WINDOWS
    12691268                    BOOL rc = CloseHandle((HANDLE)pfd->native);
    1270                     assert(rc == TRUE); K_NOREF(rc);
     1269                    kHlpAssert(rc == TRUE); K_NOREF(rc);
    12711270#else
    12721271                    int rc = close((int)pfd->native);
    1273                     assert(rc == 0); K_NOREF(rc);
     1272                    kHlpAssert(rc == 0); K_NOREF(rc);
    12741273#endif
    12751274                    pfd->fd     = -1;
     
    13301329            TRACE2((NULL, "shfile_set_inherit_win: %p -> %p (set=%d)\n", pfd->native, hFile, set));
    13311330            if (!CloseHandle((HANDLE)pfd->native))
    1332                 assert(0);
     1331                kHlpAssert(0);
    13331332            pfd->native = (intptr_t)hFile;
    13341333        }
     
    13361335        {
    13371336            err = GetLastError();
    1338             assert(0);
     1337            kHlpAssert(0);
    13391338            hFile = (HANDLE)pfd->native;
    13401339        }
     
    20432042    {
    20442043# if K_OS == K_OS_WINDOWS
    2045         assert(SEEK_SET == FILE_BEGIN);
    2046         assert(SEEK_CUR == FILE_CURRENT);
    2047         assert(SEEK_END == FILE_END);
     2044        kHlpAssert(SEEK_SET == FILE_BEGIN);
     2045        kHlpAssert(SEEK_CUR == FILE_CURRENT);
     2046        kHlpAssert(SEEK_END == FILE_END);
    20482047        rc = SetFilePointer((HANDLE)file->native, off, NULL, whench);
    20492048        if (rc == INVALID_SET_FILE_POINTER)
     
    20962095                {
    20972096# if K_OS == K_OS_WINDOWS
    2098                     assert(0);
     2097                    kHlpAssert(0);
    20992098                    errno = EINVAL;
    21002099                    rc = -1;
  • trunk/src/kash/shfork-win.c

    r3468 r3477  
    66#include <string.h>
    77#include <locale.h>
    8 #include <assert.h>
    98#include "shinstance.h"
    109#include <Windows.h>
     
    8584    g_stack_base  = shfork_string_to_ptr(argv[5], argv[0], "--stack-base");
    8685    g_stack_limit = shfork_string_to_ptr(argv[7], argv[0], "--stack-limit");
    87     assert((uintptr_t)stack_ptr < (uintptr_t)g_stack_base);
    88     assert((uintptr_t)stack_ptr > (uintptr_t)g_stack_limit);
     86    kHlpAssert((uintptr_t)stack_ptr < (uintptr_t)g_stack_base);
     87    kHlpAssert((uintptr_t)stack_ptr > (uintptr_t)g_stack_limit);
    8988
    9089    /*
     
    183182    int rc = 0;
    184183
    185     assert((uintptr_t)stack_ptr < (uintptr_t)g_stack_base);
    186     assert((uintptr_t)stack_ptr > (uintptr_t)g_stack_limit);
     184    kHlpAssert((uintptr_t)stack_ptr < (uintptr_t)g_stack_base);
     185    kHlpAssert((uintptr_t)stack_ptr > (uintptr_t)g_stack_limit);
    187186
    188187    /*
  • trunk/src/kash/shheap.c

    r3451 r3477  
    3232#include <string.h>
    3333#include <stdlib.h>
    34 #include <assert.h>
    3534#include "shinstance.h"
    3635
     
    105104# define SHHEAP_CHECK()         shheap_check()
    106105# define SHHEAP_CHECK_2()       shheap_check()
    107 # define SHHEAP_ASSERT(expr)    assert(expr)
     106# define SHHEAP_ASSERT(expr)    kHlpAssert(expr)
    108107# define SHHEAP_POISON_PSH(p,v) ((shinstance *)(v))
    109108# define SHHEAP_POISON_NULL(v)  ((void *)(v))
  • 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;
  • trunk/src/kash/show.c

    r3444 r3477  
    4444#include <stdarg.h>
    4545#include <stdlib.h>
    46 #include <assert.h>
    4746
    4847#include "shell.h"
     
    293292        if (pos > sizeof(psh->tracebuf)) {
    294293                char *end;
    295                 assert(0);
     294                kHlpAssert(0);
    296295                end = memchr(psh->tracebuf, '\0', sizeof(psh->tracebuf));
    297296                pos = end ? end - &psh->tracebuf[0] : 0;
  • trunk/src/kash/shthread.c

    r2498 r3477  
    2727#include "shthread.h"
    2828#include "shinstance.h"
    29 #include <assert.h>
    3029
    3130#if K_OS == K_OS_WINDOWS
     
    6665    {
    6766        sh_tls = TlsAlloc();
    68         assert(sh_tls != TLS_OUT_OF_INDEXES);
     67        kHlpAssert(sh_tls != TLS_OUT_OF_INDEXES);
    6968    }
    7069    if (!TlsSetValue(sh_tls, psh))
    71         assert(0);
     70        kHlpAssert(0);
    7271
    7372#elif K_OS == K_OS_OS2
     
    7574    {
    7675        sh_tls = __libc_TLSAlloc();
    77         assert(sh_tls != -1);
     76        kHlpAssert(sh_tls != -1);
    7877    }
    7978    if (__libc_TLSSet(sh_tls, psh) == -1)
    80         assert(0);
     79        kHlpAssert(0);
    8180#else
    8281    if (!sh_tls_inited)
    8382    {
    8483        if (pthread_key_create(&sh_tls, NULL) != 0)
    85             assert(0);
     84            kHlpAssert(0);
    8685        sh_tls_inited = 1;
    8786    }
    8887    if (pthread_setspecific(sh_tls, psh) != 0)
    89         assert(0);
     88        kHlpAssert(0);
    9089#endif
    9190}
  • trunk/src/kash/shtypes.h

    r3438 r3477  
    3030
    3131#include "k/kTypes.h" /* Use these, not the ones below. */
     32#include "k/kHlpAssert.h"
    3233
    3334#include <sys/types.h>
  • trunk/src/kash/var.c

    r3438 r3477  
    4141#endif
    4242
    43 #include <assert.h>
    4443#include <stddef.h>
    4544#include <stdlib.h>
     
    303302                                                } else
    304303                                                        break;
    305                                         assert(left < 256 /*whatever, just no rollover*/);
     304                                        kHlpAssert(left < 256 /*whatever, just no rollover*/);
    306305                                }
    307306                                *dst = *vsrc;
     
    336335
    337336                        dst->vp = find_var(psh, vsrc->vp->text, NULL, NULL);
    338                         assert(dst->vp);
     337                        kHlpAssert(dst->vp);
    339338
    340339                        *ppdst = dst;
Note: See TracChangeset for help on using the changeset viewer.