sl@0
|
1 |
// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
|
sl@0
|
2 |
// All rights reserved.
|
sl@0
|
3 |
// This component and the accompanying materials are made available
|
sl@0
|
4 |
// under the terms of the License "Eclipse Public License v1.0"
|
sl@0
|
5 |
// which accompanies this distribution, and is available
|
sl@0
|
6 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
sl@0
|
7 |
//
|
sl@0
|
8 |
// Initial Contributors:
|
sl@0
|
9 |
// Nokia Corporation - initial contribution.
|
sl@0
|
10 |
//
|
sl@0
|
11 |
// Contributors:
|
sl@0
|
12 |
//
|
sl@0
|
13 |
// Description:
|
sl@0
|
14 |
// Helper functions for HCR debug
|
sl@0
|
15 |
|
sl@0
|
16 |
#include <e32err.h>
|
sl@0
|
17 |
#include <e32const.h>
|
sl@0
|
18 |
#include <e32def.h>
|
sl@0
|
19 |
#include <e32cmn.h>
|
sl@0
|
20 |
#include <e32des8.h>
|
sl@0
|
21 |
#include <kernel/kernel.h>
|
sl@0
|
22 |
|
sl@0
|
23 |
|
sl@0
|
24 |
#include "hcr_debug.h"
|
sl@0
|
25 |
|
sl@0
|
26 |
#ifdef HCR_TRACE
|
sl@0
|
27 |
/**
|
sl@0
|
28 |
Make a classic hexadecimal dump of the content of an memory region. Do not
|
sl@0
|
29 |
call directly but used the macros: HCR_HEX_DUMP_ABS(), HCR_HEX_DUMP_REL()
|
sl@0
|
30 |
|
sl@0
|
31 |
@param aStartAddress Pointer of the first byte of the region
|
sl@0
|
32 |
aLength Size of the region
|
sl@0
|
33 |
aAbsolute If it is TRUE then it displays absolute address where the aStartAddress points
|
sl@0
|
34 |
If it is FALSE then it displays reltive address from aStartAddress
|
sl@0
|
35 |
|
sl@0
|
36 |
@pre Call from thread context (neither NULL, DFC0, DFC1 threads)
|
sl@0
|
37 |
*/
|
sl@0
|
38 |
|
sl@0
|
39 |
void HexDump(TUint8* aStartAddress, TUint32 aLength, TBool aAbsolute)
|
sl@0
|
40 |
{
|
sl@0
|
41 |
TUint32 nIndex;
|
sl@0
|
42 |
TBuf<128> printBuf; // Buffer for address and values
|
sl@0
|
43 |
TBuf<32> printBuf2; // Buffer for character representation
|
sl@0
|
44 |
|
sl@0
|
45 |
TUint32 extLength = ((aLength & 0xf) == 0 ? aLength :(aLength & 0xfffffff0)+0x10);
|
sl@0
|
46 |
|
sl@0
|
47 |
for(nIndex = 0; nIndex != extLength ; ++nIndex )
|
sl@0
|
48 |
{
|
sl@0
|
49 |
if(nIndex % 16 == 0)
|
sl@0
|
50 |
{
|
sl@0
|
51 |
// A line is ready compose two buffers and print the line out
|
sl@0
|
52 |
printBuf.Append(_L(" "));
|
sl@0
|
53 |
printBuf.Append(printBuf2);
|
sl@0
|
54 |
Kern::Printf("%S", &printBuf);
|
sl@0
|
55 |
|
sl@0
|
56 |
// Start a new line
|
sl@0
|
57 |
printBuf.Zero();
|
sl@0
|
58 |
printBuf.Append(_L("0x"));
|
sl@0
|
59 |
if(aAbsolute)
|
sl@0
|
60 |
{
|
sl@0
|
61 |
printBuf.AppendNumFixedWidth((TUint)(aStartAddress + nIndex), EHex,8);
|
sl@0
|
62 |
}
|
sl@0
|
63 |
else
|
sl@0
|
64 |
{
|
sl@0
|
65 |
printBuf.AppendNumFixedWidth((TUint)(nIndex), EHex,8);
|
sl@0
|
66 |
}
|
sl@0
|
67 |
|
sl@0
|
68 |
printBuf.Append(_L(": "));
|
sl@0
|
69 |
printBuf2.Zero();
|
sl@0
|
70 |
}
|
sl@0
|
71 |
|
sl@0
|
72 |
if( nIndex < aLength )
|
sl@0
|
73 |
{
|
sl@0
|
74 |
// Active content
|
sl@0
|
75 |
// Put the value into buffer
|
sl@0
|
76 |
printBuf.AppendNumFixedWidth(*(aStartAddress + nIndex), EHex,2 );
|
sl@0
|
77 |
printBuf.Append(TChar(' '));
|
sl@0
|
78 |
|
sl@0
|
79 |
// Put the chracter representation into a second buffer
|
sl@0
|
80 |
if( *(aStartAddress + nIndex) < ' ' )
|
sl@0
|
81 |
{
|
sl@0
|
82 |
printBuf2.Append(TChar('.')); // Control character
|
sl@0
|
83 |
}
|
sl@0
|
84 |
else
|
sl@0
|
85 |
{
|
sl@0
|
86 |
printBuf2.Append(TChar(*(aStartAddress + nIndex)));
|
sl@0
|
87 |
}
|
sl@0
|
88 |
}
|
sl@0
|
89 |
else
|
sl@0
|
90 |
{
|
sl@0
|
91 |
// Fill up content
|
sl@0
|
92 |
printBuf.Append(_L(" ")); // Fill value place with spaces
|
sl@0
|
93 |
printBuf2.Append(TChar(' ')); // Fill char representation place with space
|
sl@0
|
94 |
}
|
sl@0
|
95 |
}
|
sl@0
|
96 |
// Print out the rest of the buffer
|
sl@0
|
97 |
printBuf.Append(_L(" "));
|
sl@0
|
98 |
printBuf.Append(printBuf2);
|
sl@0
|
99 |
Kern::Printf("%S\n", &printBuf);
|
sl@0
|
100 |
}
|
sl@0
|
101 |
|
sl@0
|
102 |
#endif // HCR_TRACE
|