Changeset 1444
- Timestamp:
- May 16, 2004, 11:20:36 PM (21 years ago)
- Location:
- trunk/src/emx
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/emx/include/InnoTekLIBC/logstrict.h
-
Property cvs2svn:cvs-rev
changed from
1.3
to1.4
r1443 r1444 4 4 * InnoTek LIBC - Debug Logging and Strict Checking Features. 5 5 * 6 * InnoTek Systemberatung GmbH confidential6 * InnoTek Systemberatung GmbH 7 7 * 8 8 * Copyright (c) 2004 InnoTek Systemberatung GmbH … … 486 486 487 487 /** 488 * Dumps a byte block. 489 * 490 * @param uEnterTS The timestamp returned by LogEnter. 491 * @param pvInstance Logger instance. If NULL the message goes to the 492 * default log instance. 493 * @param fGroupAndFlags Logging group and logging flags. 494 * @param pszFunction Name of the function which was entered. 495 * @param pvData Pointer to the bytes to dump. 496 * @param cbData Number of bytes to dump. 497 * @param pszFormat Format string for the message to log. 498 * @param ... Arguments to the format string. 499 */ 500 extern void __libc_LogDumpHex(unsigned uEnterTS, void *pvInstance, unsigned fGroupAndFlags, const char *pszFunction, void *pvData, unsigned cbData, const char *pszFormat, ...); 501 502 /** 488 503 * Assertion helper. 489 504 * Logs and displays (stderr) an assertion failed message. -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/sys/logstrict.c
-
Property cvs2svn:cvs-rev
changed from
1.8
to1.9
r1443 r1444 93 93 } __LIBC_XCPTREG, *__LIBC_PXCPTREG; 94 94 95 96 /******************************************************************************* 97 * Global Variables * 98 *******************************************************************************/ 99 /** Hex digits. */ 100 static const char gszHexDigits[17] = "0123456789abcdef"; 101 /** Uppercase hex digits. */ 102 static const char gszHexDigitsUpper[17] = "0123456789ABCDEF"; 95 103 96 104 … … 920 928 921 929 /** 930 * Dumps a byte block. 931 * 932 * @param uEnterTS The timestamp returned by LogEnter. 933 * @param pvInstance Logger instance. If NULL the message goes to the 934 * default log instance. 935 * @param fGroupAndFlags Logging group and logging flags. 936 * @param pszFunction Name of the function which was entered. 937 * @param pvData Pointer to the bytes to dump. 938 * @param cbData Number of bytes to dump. 939 * @param pszFormat Format string for the message to log. 940 * @param ... Arguments to the format string. 941 */ 942 void __libc_LogDumpHex(unsigned uEnterTS, void *pvInstance, unsigned fGroupAndFlags, const char *pszFunction, void *pvData, unsigned cbData, const char *pszFormat, ...) 943 { 944 unsigned uTS = getTimestamp(); 945 __LIBC_PTHREAD pThread = __libc_threadCurrentNoAuto(); 946 char *pszMsg; 947 int cch; 948 va_list args; 949 __LIBC_PLOGINST pInst; 950 unsigned cDepth = 0xff; 951 char *pszOffset; 952 char *pbData; 953 unsigned off; 954 955 /* 956 * Check instance, get default. 957 */ 958 if (!pvInstance) 959 { 960 pvInstance = __libc_logDefault(); 961 if (!pvInstance) 962 return; 963 if (pThread) 964 cDepth = pThread->cDefLoggerDepth; 965 } 966 pInst = (__LIBC_PLOGINST)pvInstance; 967 968 /* 969 * Check if this group is enabled. 970 */ 971 if (pInst->pGroups) 972 { 973 int iGroup = __LIBC_LOG_GETGROUP(fGroupAndFlags); 974 if ( iGroup >= 0 975 && iGroup < pInst->pGroups->cGroups 976 && !pInst->pGroups->paGroups[iGroup].fEnabled) 977 return; 978 } 979 980 /* 981 * Allocate logging buffer and format the message. 982 */ 983 pszMsg = alloca(CCHTMPMSGBUFFER); 984 if (!pszMsg) 985 return; 986 987 va_start(args, pszFormat); 988 if (uEnterTS != ~0) 989 cch = __libc_logBuildMsg(pszMsg, pszFormat, args, "%08x %02x %02x %04x Dump %04x %s (%2d ms): ", 990 uTS, getTid(), cDepth, __LIBC_LOG_GETGROUP(fGroupAndFlags), 991 pThread ? pThread->iErrNo : 0xface, pszFunction, uTS - uEnterTS); 992 else 993 cch = __libc_logBuildMsg(pszMsg, pszFormat, args, "%08x %02x %02x %04x Dump %04x %s: ", 994 uTS, getTid(), cDepth, __LIBC_LOG_GETGROUP(fGroupAndFlags), 995 pThread ? pThread->iErrNo : 0xface, pszFunction); 996 va_end(args); 997 998 /* 999 * Write the message. 1000 */ 1001 __libc_logWrite(pInst, fGroupAndFlags, pszMsg, cch, 0); 1002 1003 1004 /* 1005 * Init the dumping. 1006 * (Reusing the first part of the message, skipping past the 'Dump' here.) 1007 */ 1008 pszOffset = pszMsg; 1009 while (pszOffset[0] != 'D' && pszOffset[1] != 'u') 1010 pszOffset++; 1011 pszOffset += 4; 1012 *pszOffset++ = ':'; 1013 *pszOffset++ = ' '; 1014 1015 /* 1016 * Do the dumping. 1017 */ 1018 off = 0; 1019 pbData = (char *)pvData; 1020 while (cbData > 0) 1021 { 1022 char *pszHex, *pszChar, *pszHexEnd; 1023 /* print offsets. */ 1024 pszHex = pszOffset + __libc_logSNPrintf(pszOffset, 64, "%08x %08x ", (unsigned)pvData, off); /* !portability! */ 1025 pszHexEnd = pszChar = pszHex + 16 * 3 + 2; /* 16 chars with on space, two space before chars column. */ 1026 1027 /* output chars. */ 1028 while (cbData > 0) 1029 { 1030 char ch = *pbData++; 1031 cbData--; 1032 *pszHex++ = gszHexDigits[(unsigned)ch >> 4]; 1033 *pszHex++ = gszHexDigits[(unsigned)ch & 4]; 1034 *pszHex++ = ' '; 1035 if (ch < 0x30 /*|| more unprintables */) 1036 *pszChar++ = '.'; 1037 else 1038 *pszChar++ = ch; 1039 } 1040 1041 /* finish it */ 1042 while (pszHex < pszHexEnd) 1043 *pszHex++ = ' '; 1044 pszHexEnd[-(8 * 3)] = '-'; 1045 *pszChar++ = '\n'; 1046 *pszChar = '\0'; 1047 1048 /* write line */ 1049 __libc_logWrite(pInst, fGroupAndFlags, pszMsg, pszChar - pszMsg, 0); 1050 1051 /* next */ 1052 off += 16; 1053 } 1054 } 1055 1056 1057 /** 922 1058 * Assertion helper. 923 1059 * Logs and displays (stderr) an assertion failed message. … … 1227 1363 int cchWidth, int cchPrecision, unsigned int fFlags) 1228 1364 { 1229 c har * achDigits = "0123456789abcdef";1365 const char *pszDigits = gszHexDigits; 1230 1366 int cchValue; 1231 1367 unsigned long ul; … … 1236 1372 return NULL; 1237 1373 if (fFlags & NTSF_CAPITAL) 1238 achDigits = "0123456789ABCDEF";1374 pszDigits = gszHexDigitsUpper; 1239 1375 if (fFlags & NTSF_LEFT) 1240 1376 fFlags &= ~NTSF_ZEROPAD; … … 1297 1433 do 1298 1434 { 1299 psz[i--] = achDigits[lValue % uiBase];1435 psz[i--] = pszDigits[lValue % uiBase]; 1300 1436 lValue /= uiBase; 1301 1437 } while (lValue > 0); … … 1325 1461 int cchWidth, int cchPrecision, unsigned int fFlags) 1326 1462 { 1327 c har * achDigits = "0123456789abcdef";1463 const char *pszDigits = gszHexDigits; 1328 1464 int cchValue; 1329 1465 unsigned long long ull; … … 1334 1470 return NULL; 1335 1471 if (fFlags & NTSF_CAPITAL) 1336 achDigits = "0123456789ABCDEF";1472 pszDigits = gszHexDigitsUpper; 1337 1473 if (fFlags & NTSF_LEFT) 1338 1474 fFlags &= ~NTSF_ZEROPAD; … … 1397 1533 do 1398 1534 { 1399 psz[i--] = achDigits[llValue % uiBase];1535 psz[i--] = pszDigits[llValue % uiBase]; 1400 1536 llValue /= uiBase; 1401 1537 } while (llValue > 0); … … 1421 1557 static int __libc_logVSNPrintf(char *pszBuffer, size_t cchBuffer, const char *pszFormat, va_list args) 1422 1558 { 1423 static const char szHexChars[17] = "0123456789abcdef";1424 1559 int rc; 1425 1560 char *pszBufferIn = pszBuffer; … … 1683 1818 { 1684 1819 char ch = *pb++; 1685 *pszBuffer++ = szHexChars[(unsigned)ch >> 4];1686 *pszBuffer++ = szHexChars[(unsigned)ch & 0xf];1820 *pszBuffer++ = gszHexDigits[(unsigned)ch >> 4]; 1821 *pszBuffer++ = gszHexDigits[(unsigned)ch & 0xf]; 1687 1822 cb--; 1688 1823 cchBuffer -= 2; … … 1694 1829 cb--; 1695 1830 *pszBuffer++ = ' '; 1696 *pszBuffer++ = szHexChars[(unsigned)ch >> 4];1697 *pszBuffer++ = szHexChars[(unsigned)ch & 0xf];1831 *pszBuffer++ = gszHexDigits[(unsigned)ch >> 4]; 1832 *pszBuffer++ = gszHexDigits[(unsigned)ch & 0xf]; 1698 1833 cchBuffer -= 3; 1699 1834 cch += 3; -
Property cvs2svn:cvs-rev
changed from
Note:
See TracChangeset
for help on using the changeset viewer.