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