Changeset 1323
- Timestamp:
- Mar 21, 2004, 7:32:21 AM (21 years ago)
- 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
to1.3
r1322 r1323 179 179 #define __LIBC_LOG_GRP_ENV 15 180 180 181 /** Backend IO APIs. */ 182 #define __LIBC_LOG_GRP_BACK_IO 26 183 181 184 /** Init/Term APIs and Events. */ 182 185 #define __LIBC_LOG_GRP_INITTERM 27 -
Property cvs2svn:cvs-rev
changed from
-
TabularUnified trunk/src/emx/src/lib/sys/logstrict.c ¶
-
Property cvs2svn:cvs-rev
changed from
1.4
to1.5
r1322 r1323 2 2 /** @file 3 3 * 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. 7 5 * 8 6 * Copyright (c) 2004 InnoTek Systemberatung GmbH 9 7 * Copyright (c) 2004 knut st. osmundsen <bird-srcspam@anduin.net> 10 8 * 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 12 25 * 13 26 */ … … 53 66 #define INCL_FSMACROS 54 67 #include <os2.h> 68 #ifndef HFILE_STDERR 69 #define HFILE_STDERR 2 70 #endif 55 71 56 72 … … 85 101 static void * __libc_logDefault(void); 86 102 static 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 );103 static void __libc_logWrite(__LIBC_PLOGINST pInst, unsigned fGroupAndFlags, const char *pszMsg, size_t cch, int fStdErr); 88 104 static inline unsigned getTimestamp(void); 89 105 static inline unsigned getTid(void); … … 415 431 { 1, "future" }, /* 24 */ 416 432 { 1, "future" }, /* 25 */ 417 { 1, " future" },/* 26 */433 { 1, "BACK_IO" }, /* 26 */ 418 434 { 1, "INITTERM" }, /* 27 */ 419 435 { 1, "BACKEND" }, /* 28 */ … … 500 516 * @param pszMsg String to write. 501 517 * @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 */ 520 static void __libc_logWrite(__LIBC_PLOGINST pInst, unsigned fGroupAndFlags, const char *pszMsg, size_t cch, int fStdErr) 504 521 { 505 522 APIRET rc; … … 542 559 DosReleaseMutexSem(pInst->hmtx); 543 560 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 } 544 599 } 545 600 … … 648 703 * Write the message. 649 704 */ 650 __libc_logWrite(pInst, fGroupAndFlags, pszMsg, cch );705 __libc_logWrite(pInst, fGroupAndFlags, pszMsg, cch, 0); 651 706 return uTS; 652 707 } … … 731 786 * Write the message. 732 787 */ 733 __libc_logWrite(pInst, fGroupAndFlags, pszMsg, cch );788 __libc_logWrite(pInst, fGroupAndFlags, pszMsg, cch, 0); 734 789 } 735 790 … … 803 858 * Write the message. 804 859 */ 805 __libc_logWrite(pInst, fGroupAndFlags, pszMsg, cch );860 __libc_logWrite(pInst, fGroupAndFlags, pszMsg, cch, 0); 806 861 } 807 862 … … 855 910 * Write the message. 856 911 */ 857 __libc_logWrite(pInst, fGroupAndFlags, pszString, cch );912 __libc_logWrite(pInst, fGroupAndFlags, pszString, cch, 0); 858 913 } 859 914 … … 880 935 char *pszMsg; 881 936 int cch; 882 ULONG cb;883 937 va_list args; 884 938 __LIBC_PLOGINST pInst; … … 929 983 * NOTE: This buffer *must* be in low memory!!! 930 984 */ 931 pszMsg = alloca(CCHTMPMSGBUFFER );985 pszMsg = alloca(CCHTMPMSGBUFFER + 1); 932 986 if (!pszMsg) 933 987 return; … … 939 993 va_start(args, pszFormat); /* make compiler happy we do it here. */ 940 994 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 */ 942 1016 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 } 976 1028 } 977 1029 -
Property cvs2svn:cvs-rev
changed from
Note:
See TracChangeset
for help on using the changeset viewer.