sl@0: // Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of the License "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // Helper functions for HCR debug sl@0: sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: sl@0: sl@0: #include "hcr_debug.h" sl@0: sl@0: #ifdef HCR_TRACE sl@0: /** sl@0: Make a classic hexadecimal dump of the content of an memory region. Do not sl@0: call directly but used the macros: HCR_HEX_DUMP_ABS(), HCR_HEX_DUMP_REL() sl@0: sl@0: @param aStartAddress Pointer of the first byte of the region sl@0: aLength Size of the region sl@0: aAbsolute If it is TRUE then it displays absolute address where the aStartAddress points sl@0: If it is FALSE then it displays reltive address from aStartAddress sl@0: sl@0: @pre Call from thread context (neither NULL, DFC0, DFC1 threads) sl@0: */ sl@0: sl@0: void HexDump(TUint8* aStartAddress, TUint32 aLength, TBool aAbsolute) sl@0: { sl@0: TUint32 nIndex; sl@0: TBuf<128> printBuf; // Buffer for address and values sl@0: TBuf<32> printBuf2; // Buffer for character representation sl@0: sl@0: TUint32 extLength = ((aLength & 0xf) == 0 ? aLength :(aLength & 0xfffffff0)+0x10); sl@0: sl@0: for(nIndex = 0; nIndex != extLength ; ++nIndex ) sl@0: { sl@0: if(nIndex % 16 == 0) sl@0: { sl@0: // A line is ready compose two buffers and print the line out sl@0: printBuf.Append(_L(" ")); sl@0: printBuf.Append(printBuf2); sl@0: Kern::Printf("%S", &printBuf); sl@0: sl@0: // Start a new line sl@0: printBuf.Zero(); sl@0: printBuf.Append(_L("0x")); sl@0: if(aAbsolute) sl@0: { sl@0: printBuf.AppendNumFixedWidth((TUint)(aStartAddress + nIndex), EHex,8); sl@0: } sl@0: else sl@0: { sl@0: printBuf.AppendNumFixedWidth((TUint)(nIndex), EHex,8); sl@0: } sl@0: sl@0: printBuf.Append(_L(": ")); sl@0: printBuf2.Zero(); sl@0: } sl@0: sl@0: if( nIndex < aLength ) sl@0: { sl@0: // Active content sl@0: // Put the value into buffer sl@0: printBuf.AppendNumFixedWidth(*(aStartAddress + nIndex), EHex,2 ); sl@0: printBuf.Append(TChar(' ')); sl@0: sl@0: // Put the chracter representation into a second buffer sl@0: if( *(aStartAddress + nIndex) < ' ' ) sl@0: { sl@0: printBuf2.Append(TChar('.')); // Control character sl@0: } sl@0: else sl@0: { sl@0: printBuf2.Append(TChar(*(aStartAddress + nIndex))); sl@0: } sl@0: } sl@0: else sl@0: { sl@0: // Fill up content sl@0: printBuf.Append(_L(" ")); // Fill value place with spaces sl@0: printBuf2.Append(TChar(' ')); // Fill char representation place with space sl@0: } sl@0: } sl@0: // Print out the rest of the buffer sl@0: printBuf.Append(_L(" ")); sl@0: printBuf.Append(printBuf2); sl@0: Kern::Printf("%S\n", &printBuf); sl@0: } sl@0: sl@0: #endif // HCR_TRACE