We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
I've got code in my project to dump out a data buffer using printf. STDOUT is redirected to the ULink2/uVision "Debug (printf) viewer".
It should produce output like this:
00000000: 00020400 00000000 5C0C0000 5C0C0000 ........\...\... 00000010: 5C0C0000 5C0C0000 5C0C0000 5C0C0000 \...\...\...\... 00000020: 5C0C0000 5C0C0000 C2030000 5C0C0000 \...\.......\... 00000030: 5C0C0000 B4050000 5C0C0000 5C0C0000 \.......\...\... 00000040: 5C0C0000 F4050000 5C0C0000 5C0C0000 \.......\...\... 00000050: 20060000 5C0C0000 5C0C0000 5C0C0000 ...\...\...\... 00000060: 5C0C0000 5C0C0000 5C0C0000 5C0C0000 \...\...\...\... 00000070: 5C0C0000 5C0C0000 5C0C0000 5C0C0000 \...\...\...\... 00000080: 5C0C0000 5C0C0000 5C0C0000 5C0C0000 \...\...\...\... 00000090: 5C0C0000 5C0C0000 5C0C0000 5C0C0000 \...\...\...\... 000000A0: 5C0C0000 5C0C0000 5C0C0000 5C0C0000 \...\...\...\... 000000B0: 5C0C0000 5C0C0000 5C0C0000 5C0C0000 \...\...\...\... 000000C0: 5C0C0000 5C0C0000 5C0C0000 5C0C0000 \...\...\...\... 000000D0: 5C0C0000 5C0C0000 5C0C0000 5C0C0000 \...\...\...\... 000000E0: 5C0C0000 5C0C0000 5C0C0000 5C0C0000 \...\...\...\... 000000F0: 5C0C0000 5C0C0000 5C0C0000 5C0C0000 \...\...\...\...
but what I get in the debug viewer is this:
0000 5C0C0000 \...\...\...\... 00000050: 5C0C0000 5C0C0000 5C0C0000 5C0C0000 \...\...\...\... 00000060: 5C0C0000 5C0C0000 5C0C0000 5C0C0000 \...\...\...\... 00000070: 5C0C0000 5C0C0000 5C0C0000 5C0C0000 \...\...\...\... 00000080: 5C0C0000 C8020000 5C0C0000 5C0C0000 \.......\...\... FFFFF00 ................
I suspect some form of overrun is occurring. If I step through the code I get all the output as I expect.Code:
void dumpHex(const void* DataPointer, size_t DataLength) { if (NULL != DataPointer) { char StringBuffer[100] = { '\0' }; const unsigned char* p = (const unsigned char*)DataPointer; unsigned char* pd; unsigned char* pa; size_t PointerSize = sizeof(void*); size_t DataOffset = (PointerSize * 2) + 2; size_t AsciiOffset = DataOffset + 38; size_t LineLength = AsciiOffset + 16; size_t index, i; int n; index = 0; while (index < DataLength) { pd = (unsigned char*)StringBuffer + DataOffset; pa = (unsigned char*)StringBuffer + AsciiOffset; memset(StringBuffer, ' ', LineLength); n = snprintf(StringBuffer, sizeof(StringBuffer), "%p", (void*)(index)); StringBuffer[n] = ':'; for (i = 0; (i < 16) && (index < DataLength); i++) { if ((i % 4) == 0) pd++; *pd++ = HEX[*p / 16]; *pd++ = HEX[*p % 16]; *pa++ = (' ' == *p || isgraph(*p)) ? *p : '.'; index++; p++; } printf("%s\n", StringBuffer); } } }
What do I need to do to ensure I get all the output?Thank you, David
BUMP