51
|
1 |
/*
|
|
2 |
* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
|
3 |
* All rights reserved.
|
|
4 |
* This component and the accompanying materials are made available
|
|
5 |
* under the terms of "Eclipse Public License v1.0"
|
|
6 |
* which accompanies this distribution, and is available
|
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
8 |
*
|
|
9 |
* Initial Contributors:
|
|
10 |
* Nokia Corporation - initial contribution.
|
|
11 |
*
|
|
12 |
* Contributors:
|
|
13 |
*
|
|
14 |
* Description:
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
#include "MemSpyDriverLogChanHeapBase.h"
|
|
19 |
|
|
20 |
// System includes
|
|
21 |
#include <u32hal.h>
|
|
22 |
#include <e32rom.h>
|
|
23 |
#include <memspy/driver/memspydriverobjectsshared.h>
|
|
24 |
|
|
25 |
// Shared includes
|
|
26 |
#include "MemSpyDriverOpCodes.h"
|
|
27 |
#include "MemSpyDriverObjectsInternal.h"
|
|
28 |
|
|
29 |
// User includes
|
|
30 |
#include "MemSpyDriverHeap.h"
|
|
31 |
#include "MemSpyDriverUtils.h"
|
|
32 |
#include "MemSpyDriverDevice.h"
|
|
33 |
#include "MemSpyDriverOSAdaption.h"
|
|
34 |
|
|
35 |
// Constants
|
|
36 |
const TInt KMemSpyDriverLogChanHeapBaseXferBufferSize = 1024 * 16;
|
|
37 |
|
|
38 |
|
|
39 |
DMemSpyDriverLogChanHeapBase::DMemSpyDriverLogChanHeapBase( DMemSpyDriverDevice& aDevice, DThread& aThread )
|
|
40 |
: DMemSpyDriverLogChanBase( aDevice, aThread )
|
|
41 |
{
|
|
42 |
TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::DMemSpyDriverLogChanHeapBase() - this: 0x%08x", this ));
|
|
43 |
}
|
|
44 |
|
|
45 |
|
|
46 |
DMemSpyDriverLogChanHeapBase::~DMemSpyDriverLogChanHeapBase()
|
|
47 |
{
|
|
48 |
}
|
|
49 |
|
|
50 |
|
|
51 |
TInt DMemSpyDriverLogChanHeapBase::Construct()
|
|
52 |
{
|
|
53 |
TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::Construct() - START - this: 0x%08x", this ));
|
|
54 |
|
|
55 |
const TInt ret = BaseConstruct( KMemSpyDriverLogChanHeapBaseXferBufferSize );
|
|
56 |
|
|
57 |
TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::Construct() - END - this: 0x%08x, err: %d", this, ret ));
|
|
58 |
return ret;
|
|
59 |
}
|
|
60 |
|
|
61 |
|
|
62 |
|
|
63 |
|
|
64 |
|
|
65 |
|
|
66 |
|
|
67 |
|
|
68 |
|
|
69 |
|
|
70 |
|
|
71 |
TInt DMemSpyDriverLogChanHeapBase::Request( TInt aFunction, TAny* a1, TAny* a2 )
|
|
72 |
{
|
|
73 |
const TInt r = DMemSpyDriverLogChanBase::Request( aFunction, a1, a2 );
|
|
74 |
return r;
|
|
75 |
}
|
|
76 |
|
|
77 |
|
|
78 |
|
|
79 |
|
|
80 |
|
|
81 |
|
|
82 |
|
|
83 |
|
|
84 |
|
|
85 |
|
|
86 |
|
|
87 |
|
|
88 |
|
|
89 |
DMemSpyDriverLogChanHeapBase::TDrmMatchType DMemSpyDriverLogChanHeapBase::IsDrmThread( DThread& aThread )
|
|
90 |
{
|
|
91 |
TDrmMatchType ret = EMatchTypeNone;
|
|
92 |
//
|
|
93 |
const TUid procUid = aThread.iOwningProcess->iUids.iUid[ 2 ];
|
|
94 |
TRACE( Kern::Printf( "DMemSpyDriverLogChanHeapBase::IsDrmThread() - START - aThread: %O, process uid: 0x%08x", &aThread, procUid.iUid ));
|
|
95 |
|
|
96 |
// Some more rudimentary checks based upon process name and
|
|
97 |
// known uids.
|
|
98 |
TFullName fullName;
|
|
99 |
aThread.FullName( fullName );
|
|
100 |
|
|
101 |
// Exclude threads containing "DRM"
|
|
102 |
_LIT( KDrmThreadMatchText, "*DRM*" );
|
|
103 |
const TInt matchPos = fullName.MatchF( KDrmThreadMatchText );
|
|
104 |
if ( matchPos >= 0 )
|
|
105 |
{
|
|
106 |
TRACE( Kern::Printf( "DMemSpyDriverLogChanHeapBase::IsDrmThread() - found \'DRM\' at pos: %d (%S)", matchPos, &fullName ));
|
|
107 |
ret = EMatchTypeName;
|
|
108 |
}
|
|
109 |
else
|
|
110 |
{
|
|
111 |
// Some known DRM related process UIDs
|
|
112 |
switch( procUid.iUid )
|
|
113 |
{
|
|
114 |
case 0x10005A22: // DRMEncryptor.exe
|
|
115 |
case 0x01105901: // DRMEncryptor.exe
|
|
116 |
case 0x101F85C7: // DRMRightsManager.exe
|
|
117 |
case 0x10205CA8: // DcfRepSrv.exe
|
|
118 |
case 0x101F51F2: // RightsServer.exe
|
|
119 |
case 0x101F6DC5: // DRMHelperServer.exe
|
|
120 |
case 0x10282F1B: // wmdrmserver.exe
|
|
121 |
ret = EMatchTypeUid;
|
|
122 |
break;
|
|
123 |
default:
|
|
124 |
ret = EMatchTypeNone;
|
|
125 |
break;
|
|
126 |
}
|
|
127 |
}
|
|
128 |
|
|
129 |
TRACE( Kern::Printf( "DMemSpyDriverLogChanHeapBase::IsDrmThread() - END - procUid: 0x%08x, matchType: %d", procUid.iUid, ret ));
|
|
130 |
return ret;
|
|
131 |
}
|
|
132 |
|
|
133 |
|
|
134 |
|
|
135 |
|
|
136 |
|
|
137 |
|
|
138 |
|
|
139 |
|
|
140 |
|
|
141 |
|
|
142 |
|
|
143 |
|
|
144 |
|
|
145 |
|
|
146 |
|
|
147 |
|
|
148 |
|
|
149 |
|
|
150 |
|
|
151 |
|
|
152 |
|
|
153 |
|
|
154 |
|
|
155 |
|
|
156 |
|
|
157 |
|
|
158 |
|
|
159 |
|
|
160 |
|
|
161 |
|
|
162 |
|
|
163 |
|
|
164 |
|
|
165 |
|
|
166 |
|
|
167 |
|
|
168 |
|
|
169 |
void DMemSpyDriverLogChanHeapBase::PrintHeapInfo( const TMemSpyHeapInfo& aInfo )
|
|
170 |
{
|
|
171 |
const TMemSpyHeapInfoRHeap& rHeapInfo = aInfo.AsRHeap();
|
|
172 |
//const TMemSpyHeapObjectDataRHeap& rHeapObjectData = rHeapInfo.ObjectData();
|
|
173 |
const TMemSpyHeapStatisticsRHeap& rHeapStats = rHeapInfo.Statistics();
|
|
174 |
const TMemSpyHeapMetaDataRHeap& rHeapMetaData = rHeapInfo.MetaData();
|
|
175 |
|
|
176 |
TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::PrintHeapInfo() ---------------------------------------------------" ) );
|
|
177 |
TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::PrintHeapInfo() - Stats (Free) -" ) );
|
|
178 |
TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::PrintHeapInfo() ---------------------------------------------------" ) );
|
|
179 |
TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::PrintHeapInfo() - cell count: %d", rHeapStats.StatsFree().TypeCount() ) );
|
|
180 |
TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::PrintHeapInfo() - cell size: %d", rHeapStats.StatsFree().TypeSize() ) );
|
|
181 |
TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::PrintHeapInfo() - cell largest: 0x%08x", rHeapStats.StatsFree().LargestCellAddress() ) );
|
|
182 |
TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::PrintHeapInfo() - cell largest size: %d", rHeapStats.StatsFree().LargestCellSize() ) );
|
|
183 |
TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::PrintHeapInfo() - slack: 0x%08x", rHeapStats.StatsFree().SlackSpaceCellAddress() ) );
|
|
184 |
TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::PrintHeapInfo() - slack size: %d", rHeapStats.StatsFree().SlackSpaceCellSize() ) );
|
|
185 |
TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::PrintHeapInfo() - checksum: 0x%08x", rHeapStats.StatsFree().Checksum() ) );
|
|
186 |
TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::PrintHeapInfo() - " ) );
|
|
187 |
|
|
188 |
TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::PrintHeapInfo() ---------------------------------------------------" ) );
|
|
189 |
TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::PrintHeapInfo() - Stats (Alloc) -" ) );
|
|
190 |
TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::PrintHeapInfo() ---------------------------------------------------" ) );
|
|
191 |
TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::PrintHeapInfo() - cell count: %d", rHeapStats.StatsAllocated().TypeCount() ) );
|
|
192 |
TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::PrintHeapInfo() - cell size: %d", rHeapStats.StatsAllocated().TypeSize() ) );
|
|
193 |
TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::PrintHeapInfo() - cell largest: 0x%08x", rHeapStats.StatsAllocated().LargestCellAddress() ) );
|
|
194 |
TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::PrintHeapInfo() - cell largest size: %d", rHeapStats.StatsAllocated().LargestCellSize() ) );
|
|
195 |
TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::PrintHeapInfo() - " ) );
|
|
196 |
|
|
197 |
TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::PrintHeapInfo() ---------------------------------------------------" ) );
|
|
198 |
TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::PrintHeapInfo() - Misc. Info -" ) );
|
|
199 |
TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::PrintHeapInfo() ---------------------------------------------------" ) );
|
|
200 |
TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::PrintHeapInfo() - chunk size: %d", rHeapMetaData.ChunkSize() ) );
|
|
201 |
TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::PrintHeapInfo() - chunk handle: 0x%08x", rHeapMetaData.ChunkHandle() ) );
|
|
202 |
TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::PrintHeapInfo() - chunk base address: 0x%08x", rHeapMetaData.ChunkBaseAddress() ) );
|
|
203 |
TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::PrintHeapInfo() - debug allocator: %d", rHeapMetaData.IsDebugAllocator() ) );
|
|
204 |
TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::PrintHeapInfo() - shared heap: %d", rHeapMetaData.IsSharedHeap() ) );
|
|
205 |
TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::PrintHeapInfo() - user thread: %d", rHeapMetaData.IsUserThread() ) );
|
|
206 |
//TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::PrintHeapInfo() - cell header size (free): %d", rHeapMetaData.HeaderSizeFree() ) );
|
|
207 |
//TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::PrintHeapInfo() - cell header size (alloc): %d", rHeapMetaData.HeaderSizeAllocated() ) );
|
|
208 |
TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::PrintHeapInfo() - heap vTable: 0x%08x", rHeapMetaData.VTable() ) );
|
|
209 |
//TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::PrintHeapInfo() - heap object size: %d", rHeapMetaData.ClassSize() ) );
|
|
210 |
TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::PrintHeapInfo() - heap size: %d", rHeapMetaData.iHeapSize ) );
|
|
211 |
TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::PrintHeapInfo() - allocator address: 0x%08x", rHeapMetaData.iAllocatorAddress ) );
|
|
212 |
TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::PrintHeapInfo() - min heap size: %d", rHeapMetaData.iMinHeapSize ) );
|
|
213 |
TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::PrintHeapInfo() - max heap size: %d", rHeapMetaData.iMaxHeapSize ) );
|
|
214 |
}
|
|
215 |
|
52
|
216 |
// TODO remove this? how is it actually being used?
|
51
|
217 |
TBool DMemSpyDriverLogChanHeapBase::HandleHeapCell(TMemSpyDriverCellType aCellType, TAny* aCellAddress, TInt aLength, TInt /*aNestingLevel*/, TInt /*aAllocNumber*/)
|
|
218 |
{
|
|
219 |
TInt error = KErrNone;
|
|
220 |
//
|
|
221 |
if (aCellType & EMemSpyDriverFreeCellMask)
|
|
222 |
{
|
|
223 |
if ( iStackStream )
|
|
224 |
{
|
|
225 |
if ( !iStackStream->IsFull() )
|
|
226 |
{
|
|
227 |
++iFreeCellCount;
|
|
228 |
TRACE_KH( Kern::Printf("DMemSpyDriverLogChanHeapBase::HandleHeapCell - writing free cell %d @ 0x%08x, space left: %u", iFreeCellCount, aCellAddress, iStackStream->Remaining() ));
|
|
229 |
//
|
|
230 |
iStackStream->WriteInt32( aCellType );
|
|
231 |
iStackStream->WriteUint32( reinterpret_cast<TUint32>( aCellAddress ) );
|
|
232 |
iStackStream->WriteInt32( aLength );
|
|
233 |
}
|
|
234 |
else
|
|
235 |
{
|
|
236 |
Kern::Printf( "DMemSpyDriverLogChanHeapBase::HandleHeapCell - Kernel Free Cell stack stream IS FULL!" );
|
|
237 |
error = KErrAbort;
|
|
238 |
}
|
|
239 |
}
|
|
240 |
}
|
|
241 |
//
|
|
242 |
return ( error == KErrNone );
|
|
243 |
}
|
|
244 |
|
|
245 |
|
|
246 |
void DMemSpyDriverLogChanHeapBase::HandleHeapWalkInit()
|
|
247 |
{
|
|
248 |
iFreeCellCount = 0;
|
|
249 |
}
|
|
250 |
|
|
251 |
|
|
252 |
|
|
253 |
|