add logmem debugging utility

This commit is contained in:
ehouse 2004-10-02 03:53:23 +00:00
parent 4081b11c6f
commit 7097bf321c
2 changed files with 29 additions and 0 deletions

View file

@ -655,4 +655,30 @@ palm_logf( char* format, ... )
logToMemo( buf );
} /* palm_logf */
#define ROWSIZE 8
void
palm_logmem( unsigned char* ptr, int nBytes )
{
XP_U16 nRows = (nBytes + ROWSIZE-1) / ROWSIZE;
char buf[(ROWSIZE*3)+5];
char* bp;
unsigned char* end = ptr + nBytes;
XP_U16 i, j;
for ( i = 0; i < nRows; ++i ) {
bp = buf;
bp += StrPrintF( (Char*)buf, "%3x:", i * ROWSIZE );
for ( j = 0; j < ROWSIZE && ptr < end; ++j ) {
char sbuf[6];
StrPrintF( sbuf, "%x ", (XP_U16)*ptr++ );
StrCat( buf, &sbuf[2] );
bp += 3;
}
logToMemo( buf );
}
}
#endif /* DEBUG */

View file

@ -48,6 +48,7 @@ void palm_assert(Boolean b, int line, char* fileName );
void palm_warnf( char* format, ... );
void palm_logf( char* format, ... );
XP_U16 palm_snprintf( XP_UCHAR* buf, XP_U16 len, XP_UCHAR* format, ... );
void palm_logmem( unsigned char* ptr, int nBytes );
XP_S16 palm_memcmp( XP_U8* p1, XP_U8* p2, XP_U16 nBytes );
XP_U8* palm_realloc(XP_U8* in, XP_U16 size);
@ -100,9 +101,11 @@ XP_U8* palm_realloc(XP_U8* in, XP_U16 size);
#ifdef DEBUG
#define XP_LOGF palm_logf
#define XP_WARNF palm_warnf
#define XP_LOGMEM palm_logmem
#else
#define XP_WARNF if(0)p_ignore
#define XP_LOGF if(0)p_ignore
#define XP_LOGMEM if(0)p_ignore
#endif
/* Assumes big-endian, of course */