From 387ca9ba89f6ae2e5712a13d5ffbb87536696454 Mon Sep 17 00:00:00 2001 From: Richard Cohen Date: Thu, 7 Aug 2003 02:56:35 +0000 Subject: [PATCH] - Print short ASCII strings without the "..." - Make printing for Unicode strings more similar to ASCII. --- programs/winedbg/memory.c | 47 ++++++++++++++++++++++----------------- programs/winedbg/types.c | 13 +++-------- 2 files changed, 30 insertions(+), 30 deletions(-) diff --git a/programs/winedbg/memory.c b/programs/winedbg/memory.c index 10bc8fbf6f0..9e0a8ad36ff 100644 --- a/programs/winedbg/memory.c +++ b/programs/winedbg/memory.c @@ -336,6 +336,8 @@ void DEBUG_ExamineMemory( const DBG_VALUE *_value, int count, char format ) } } +#define CHARBUFSIZE 16 + /****************************************************************** * DEBUG_PrintStringA * @@ -346,38 +348,43 @@ void DEBUG_ExamineMemory( const DBG_VALUE *_value, int count, char format ) int DEBUG_PrintStringA(int chnl, const DBG_ADDR* address, int len) { char* lin = (void*)DEBUG_ToLinear(address); - char ach[16+1]; - int i, l; + char ch[CHARBUFSIZE+1]; + int written = 0; if (len == -1) len = 32767; /* should be big enough */ - for (i = len; i > 0; i -= l) + while (written < len) { - l = min(sizeof(ach) - 1, i); - DEBUG_READ_MEM_VERBOSE(lin, ach, l); - ach[l] = '\0'; /* protect from displaying junk */ - l = strlen(ach); - DEBUG_OutputA(chnl, ach, l); - if (l < sizeof(ach) - 1) break; - lin += l; + int to_write = min(CHARBUFSIZE, len - written ); + if (!DEBUG_READ_MEM_VERBOSE(lin, ch, to_write)) break; + ch[to_write] = '\0'; /* protect from displaying junk */ + to_write = lstrlenA(ch); + DEBUG_OutputA(chnl, ch, to_write); + lin += to_write; + written += to_write; + if (to_write < CHARBUFSIZE) break; } - return len - i; /* number of actually written chars */ + return written; /* number of actually written chars */ } int DEBUG_PrintStringW(int chnl, const DBG_ADDR* address, int len) { char* lin = (void*)DEBUG_ToLinear(address); - WCHAR wch; - int ret = 0; + WCHAR ch[CHARBUFSIZE+1]; + int written = 0; if (len == -1) len = 32767; /* should be big enough */ - while (len--) + + while (written < len) { - if (!DEBUG_READ_MEM_VERBOSE(lin, &wch, sizeof(wch)) || !wch) - break; - lin += sizeof(wch); - DEBUG_OutputW(chnl, &wch, 1); - ret++; + int to_write = min(CHARBUFSIZE, len - written ); + if (!DEBUG_READ_MEM_VERBOSE(lin, ch, to_write * sizeof(WCHAR))) break; + ch[to_write] = 0; /* protect from displaying junk */ + to_write = lstrlenW(ch); + DEBUG_OutputW(chnl, ch, to_write); + lin += to_write; + written += to_write; + if (to_write < CHARBUFSIZE) break; } - return ret; + return written; /* number of actually written chars */ } diff --git a/programs/winedbg/types.c b/programs/winedbg/types.c index 052d3fbaa3e..d816110812e 100644 --- a/programs/winedbg/types.c +++ b/programs/winedbg/types.c @@ -36,7 +36,7 @@ #define NR_TYPE_HASH 521 int DEBUG_nchar; -static int DEBUG_maxchar = 1024; +static const int DEBUG_maxchar = 1024; struct en_values { @@ -890,20 +890,14 @@ DEBUG_Print( const DBG_VALUE *value, int count, char format, int level ) switch (value->cookie) { case DV_TARGET: - clen = DEBUG_PrintStringA(DBG_CHN_MESG, &value->addr, clen); + DEBUG_nchar += DEBUG_PrintStringA(DBG_CHN_MESG, &value->addr, clen); break; case DV_HOST: DEBUG_OutputA(DBG_CHN_MESG, pnt, clen); break; default: assert(0); } - DEBUG_nchar += clen; - if (clen != len) - { - DEBUG_Printf(DBG_CHN_MESG, "...\""); - goto leave; - } - DEBUG_nchar += DEBUG_Printf(DBG_CHN_MESG, "\""); + DEBUG_nchar += DEBUG_Printf(DBG_CHN_MESG, (len > clen) ? "...\"" : "\""); break; } val1 = *value; @@ -943,7 +937,6 @@ leave: { DEBUG_nchar += DEBUG_Printf(DBG_CHN_MESG, "\n"); } - return; } static void DEBUG_DumpAType(struct datatype* dt, BOOL deep)