Changeset 1323


Ignore:
Timestamp:
Mar 21, 2004, 7:32:21 AM (21 years ago)
Author:
bird
Message:

#992: Another group. More convenient assert.

Location:
trunk/src/emx
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • TabularUnified trunk/src/emx/include/InnoTekLIBC/logstrict.h

    • Property cvs2svn:cvs-rev changed from 1.2 to 1.3
    r1322 r1323  
    179179#define __LIBC_LOG_GRP_ENV          15
    180180
     181/** Backend IO APIs. */
     182#define __LIBC_LOG_GRP_BACK_IO      26
     183
    181184/** Init/Term APIs and Events. */
    182185#define __LIBC_LOG_GRP_INITTERM     27
  • TabularUnified trunk/src/emx/src/lib/sys/logstrict.c

    • Property cvs2svn:cvs-rev changed from 1.4 to 1.5
    r1322 r1323  
    22/** @file
    33 *
    4  * LIBC SYS - Debug Logging and Strict Checking Facilities.
    5  *
    6  * InnoTek Systemberatung GmbH confidential
     4 * LIBC SYS Backend - Debug Logging and Strict Checking Facilities.
    75 *
    86 * Copyright (c) 2004 InnoTek Systemberatung GmbH
    97 * Copyright (c) 2004 knut st. osmundsen <bird-srcspam@anduin.net>
    108 *
    11  * All Rights Reserved
     9 *
     10 * This file is part of InnoTek LIBC.
     11 *
     12 * InnoTek LIBC is free software; you can redistribute it and/or modify
     13 * it under the terms of the GNU Lesser General Public License as published
     14 * by the Free Software Foundation; either version 2 of the License, or
     15 * (at your option) any later version.
     16 *
     17 * InnoTek LIBC is distributed in the hope that it will be useful,
     18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
     19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     20 * GNU Lesser General Public License for more details.
     21 *
     22 * You should have received a copy of the GNU Lesser General Public License
     23 * along with InnoTek LIBC; if not, write to the Free Software
     24 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    1225 *
    1326 */
     
    5366#define INCL_FSMACROS
    5467#include <os2.h>
     68#ifndef HFILE_STDERR
     69#define HFILE_STDERR 2
     70#endif
    5571
    5672
     
    85101static void *   __libc_logDefault(void);
    86102static int      __libc_logBuildMsg(char *pszMsg, const char *pszFormatMsg, va_list args, const char *pszFormatPrefix, ...) __printflike(4, 5);
    87 static void     __libc_logWrite(__LIBC_PLOGINST pInst, unsigned fGroupAndFlags, const char *pszMsg, size_t cch);
     103static void     __libc_logWrite(__LIBC_PLOGINST pInst, unsigned fGroupAndFlags, const char *pszMsg, size_t cch, int fStdErr);
    88104static inline unsigned getTimestamp(void);
    89105static inline unsigned getTid(void);
     
    415431            { 1, "future" },            /* 24 */
    416432            { 1, "future" },            /* 25 */
    417             { 1, "future" },            /* 26 */
     433            { 1, "BACK_IO" },           /* 26 */
    418434            { 1, "INITTERM" },          /* 27 */
    419435            { 1, "BACKEND" },           /* 28 */
     
    500516 * @param   pszMsg          String to write.
    501517 * @param   cch             Length of string.
    502  */
    503 static void __libc_logWrite(__LIBC_PLOGINST pInst, unsigned fGroupAndFlags, const char *pszMsg, size_t cch)
     518 * @param   fStdErr         If set write to standard err too.
     519 */
     520static void __libc_logWrite(__LIBC_PLOGINST pInst, unsigned fGroupAndFlags, const char *pszMsg, size_t cch, int fStdErr)
    504521{
    505522    APIRET  rc;
     
    542559        DosReleaseMutexSem(pInst->hmtx);
    543560    FS_RESTORE();
     561
     562    /*
     563     * Write to stderr too?
     564     */
     565    if (fStdErr)
     566    {
     567        /*
     568         * Need to convert '\n' to '\r\n'.
     569         */
     570        const char *pszNewLine = NULL;
     571        do
     572        {
     573            int cchWrite;
     574
     575            /* look for next new line */
     576            pszNewLine = memchr(pszMsg, '\n', cch);
     577            while (pszNewLine > pszMsg && pszNewLine[-1] == '\r')
     578            {
     579                cchWrite = cch - (pszNewLine - pszMsg + 1);
     580                if (cchWrite <= 0)
     581                {
     582                    pszNewLine = NULL;
     583                    break;
     584                }
     585                pszNewLine = memchr(pszNewLine + 1, '\n', cchWrite);
     586            }
     587            cchWrite = pszNewLine ? pszNewLine - pszMsg : strnlen(pszMsg, cch);
     588            DosWrite(HFILE_STDERR, pszMsg, cchWrite, &cb);
     589
     590            /* Write newline. */
     591            if (!pszNewLine)
     592                break; /* done */
     593            DosWrite(HFILE_STDERR, "\r\n", 2, &cb);
     594            pszMsg = pszNewLine + 1;
     595            cch -= cchWrite + 1;
     596        } while (cch);
     597
     598    }
    544599}
    545600
     
    648703     * Write the message.
    649704     */
    650     __libc_logWrite(pInst, fGroupAndFlags, pszMsg, cch);
     705    __libc_logWrite(pInst, fGroupAndFlags, pszMsg, cch, 0);
    651706    return uTS;
    652707}
     
    731786     * Write the message.
    732787     */
    733     __libc_logWrite(pInst, fGroupAndFlags, pszMsg, cch);
     788    __libc_logWrite(pInst, fGroupAndFlags, pszMsg, cch, 0);
    734789}
    735790
     
    803858     * Write the message.
    804859     */
    805     __libc_logWrite(pInst, fGroupAndFlags, pszMsg, cch);
     860    __libc_logWrite(pInst, fGroupAndFlags, pszMsg, cch, 0);
    806861}
    807862
     
    855910     * Write the message.
    856911     */
    857     __libc_logWrite(pInst, fGroupAndFlags, pszString, cch);
     912    __libc_logWrite(pInst, fGroupAndFlags, pszString, cch, 0);
    858913}
    859914
     
    880935    char           *pszMsg;
    881936    int             cch;
    882     ULONG           cb;
    883937    va_list         args;
    884938    __LIBC_PLOGINST pInst;
     
    929983     * NOTE: This buffer *must* be in low memory!!!
    930984     */
    931     pszMsg = alloca(CCHTMPMSGBUFFER);
     985    pszMsg = alloca(CCHTMPMSGBUFFER + 1);
    932986    if (!pszMsg)
    933987        return;
     
    939993    va_start(args, pszFormat);          /* make compiler happy we do it here. */
    940994    cch = __libc_logBuildMsg(pszMsg, "", args, "%08x %02x %02x %04x Asrt: Assertion Failed!!!\n", uTS, getTid(), cDepth, __LIBC_LOG_GETGROUP(fGroupAndFlags));
    941     __libc_logWrite(pInst, fGroupAndFlags, pszMsg, cch);
     995    __libc_logWrite(pInst, fGroupAndFlags, pszMsg, cch, fEnabled);
     996
     997    cch = __libc_logBuildMsg(pszMsg, "", args, "%08x %02x %02x %04x Asrt: Function: %s\n", uTS, getTid(), cDepth, __LIBC_LOG_GETGROUP(fGroupAndFlags), pszFunction);
     998    __libc_logWrite(pInst, fGroupAndFlags, pszMsg, cch, fEnabled);
     999
     1000    cch = __libc_logBuildMsg(pszMsg, "", args, "%08x %02x %02x %04x Asrt: File:     %s\n", uTS, getTid(), cDepth, __LIBC_LOG_GETGROUP(fGroupAndFlags), pszFile);
     1001    __libc_logWrite(pInst, fGroupAndFlags, pszMsg, cch, fEnabled);
     1002
     1003    cch = __libc_logBuildMsg(pszMsg, "", args, "%08x %02x %02x %04x Asrt: Line:     %d\n", uTS, getTid(), cDepth, __LIBC_LOG_GETGROUP(fGroupAndFlags), uLine);
     1004    __libc_logWrite(pInst, fGroupAndFlags, pszMsg, cch, fEnabled);
     1005
     1006    cch = __libc_logBuildMsg(pszMsg, "", args, "%08x %02x %02x %04x Asrt: Expr:     %s\n", uTS, getTid(), cDepth, __LIBC_LOG_GETGROUP(fGroupAndFlags), pszExpression);
     1007    __libc_logWrite(pInst, fGroupAndFlags, pszMsg, cch, fEnabled);
     1008
     1009    cch = __libc_logBuildMsg(pszMsg, pszFormat, args, "%08x %02x %02x %04x Asrt: ",        uTS, getTid(), cDepth, __LIBC_LOG_GETGROUP(fGroupAndFlags));
     1010    __libc_logWrite(pInst, fGroupAndFlags, pszMsg, cch, fEnabled);
     1011    va_end(args);
     1012
     1013    /*
     1014     * Breakpoint. (IBM debugger: T or Ctrl-T to get to caller)
     1015     */
    9421016    if (fEnabled)
    943         DosWrite(2, pszMsg, cch, &cb);
    944 
    945     cch = __libc_logBuildMsg(pszMsg, "", args, "%08x %02x %02x %04x Asrt: Function: %s\n", uTS, getTid(), cDepth, __LIBC_LOG_GETGROUP(fGroupAndFlags), pszFunction);
    946     __libc_logWrite(pInst, fGroupAndFlags, pszMsg, cch);
    947     if (fEnabled)
    948         DosWrite(2, pszMsg, cch, &cb);
    949 
    950     cch = __libc_logBuildMsg(pszMsg, "", args, "%08x %02x %02x %04x Asrt: File:     %s\n", uTS, getTid(), cDepth, __LIBC_LOG_GETGROUP(fGroupAndFlags), pszFile);
    951     __libc_logWrite(pInst, fGroupAndFlags, pszMsg, cch);
    952     if (fEnabled)
    953         DosWrite(2, pszMsg, cch, &cb);
    954 
    955     cch = __libc_logBuildMsg(pszMsg, "", args, "%08x %02x %02x %04x Asrt: Line:     %d\n", uTS, getTid(), cDepth, __LIBC_LOG_GETGROUP(fGroupAndFlags), uLine);
    956     __libc_logWrite(pInst, fGroupAndFlags, pszMsg, cch);
    957     if (fEnabled)
    958         DosWrite(2, pszMsg, cch, &cb);
    959 
    960     cch = __libc_logBuildMsg(pszMsg, "", args, "%08x %02x %02x %04x Asrt: Expr:     %s\n", uTS, getTid(), cDepth, __LIBC_LOG_GETGROUP(fGroupAndFlags), pszExpression);
    961     __libc_logWrite(pInst, fGroupAndFlags, pszMsg, cch);
    962     if (fEnabled)
    963         DosWrite(2, pszMsg, cch, &cb);
    964 
    965     cch = __libc_logBuildMsg(pszMsg, pszFormat, args, "%08x %02x %02x %04x Asrt: ",        uTS, getTid(), cDepth, __LIBC_LOG_GETGROUP(fGroupAndFlags));
    966     __libc_logWrite(pInst, fGroupAndFlags, pszMsg, cch);
    967     if (fEnabled)
    968         DosWrite(2, pszMsg, cch, &cb);
    969     va_end(args);
    970 
    971     /*
    972      * Breakpoint. (IBM debugger: T or Ctrl-T to get to caller)
    973      */
    974     if (fEnabled)
    975         __asm__ __volatile__("int $3");
     1017    {
     1018        /*
     1019         * Raise a breakpoint here, that's more convenient in the debugger.
     1020         * Just press 'T' and you'll be at the LIBC_ASSERT*.
     1021         */
     1022        EXCEPTIONREPORTRECORD  XRepRec = {0};
     1023        XRepRec.ExceptionNum        = XCPT_BREAKPOINT;
     1024        XRepRec.ExceptionAddress    = (void*)&__libc_LogAssert;
     1025        if (DosRaiseException(&XRepRec))
     1026            __asm__ __volatile__("int $3");
     1027    }
    9761028}
    9771029
Note: See TracChangeset for help on using the changeset viewer.