|
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 "MemSpyDriverLogChanStack.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 "MemSpyDriverUtils.h" |
|
31 #include "MemSpyDriverOSAdaption.h" |
|
32 #include "MemSpyDriverSuspensionManager.h" |
|
33 |
|
34 // Constants |
|
35 const TUint32 KMemSpyStackFillPatternUser = 0x29292929; |
|
36 const TUint32 KMemSpyStackFillPatternSupervisor = 0xeeeeeeee; |
|
37 |
|
38 |
|
39 DMemSpyDriverLogChanStack::DMemSpyDriverLogChanStack( DMemSpyDriverDevice& aDevice, DThread& aThread ) |
|
40 : DMemSpyDriverLogChanBase( aDevice, aThread ) |
|
41 { |
|
42 TRACE( Kern::Printf("DMemSpyDriverLogChanStack::DMemSpyDriverLogChanStack() - this: 0x%08x", this )); |
|
43 } |
|
44 |
|
45 |
|
46 DMemSpyDriverLogChanStack::~DMemSpyDriverLogChanStack() |
|
47 { |
|
48 TRACE( Kern::Printf("DMemSpyDriverLogChanStack::~DMemSpyDriverLogChanStack() - START - this: 0x%08x", this )); |
|
49 |
|
50 TRACE( Kern::Printf("DMemSpyDriverLogChanStack::~DMemSpyDriverLogChanStack() - END - this: 0x%08x", this )); |
|
51 } |
|
52 |
|
53 |
|
54 |
|
55 |
|
56 |
|
57 |
|
58 TInt DMemSpyDriverLogChanStack::Request( TInt aFunction, TAny* a1, TAny* a2 ) |
|
59 { |
|
60 TInt r = DMemSpyDriverLogChanBase::Request( aFunction, a1, a2 ); |
|
61 if ( r == KErrNone ) |
|
62 { |
|
63 switch( aFunction ) |
|
64 { |
|
65 case EMemSpyDriverOpCodeStackGetInfo: |
|
66 r = GetStackInfo( (TUint) a1, (TMemSpyDriverStackInfo*) a2 ); |
|
67 break; |
|
68 case EMemSpyDriverOpCodeStackGetData: |
|
69 r = GetStackData( (TMemSpyDriverInternalStackDataParams*) a1 ); |
|
70 break; |
|
71 |
|
72 default: |
|
73 r = KErrNotSupported; |
|
74 break; |
|
75 } |
|
76 } |
|
77 // |
|
78 return r; |
|
79 } |
|
80 |
|
81 |
|
82 TBool DMemSpyDriverLogChanStack::IsHandler( TInt aFunction ) const |
|
83 { |
|
84 return ( aFunction > EMemSpyDriverOpCodeStackBase && aFunction < EMemSpyDriverOpCodeStackEnd ); |
|
85 } |
|
86 |
|
87 |
|
88 |
|
89 |
|
90 |
|
91 |
|
92 |
|
93 |
|
94 |
|
95 TInt DMemSpyDriverLogChanStack::GetStackInfo( TUint aTid, TMemSpyDriverStackInfo* aParams ) |
|
96 { |
|
97 TRACE( Kern::Printf("DMemSpyDriverLogChanStack::GetStackInfo() - START - thread id: %d", aTid)); |
|
98 |
|
99 TMemSpyDriverStackInfo params; |
|
100 TInt r = OpenTempObject( aTid, EThread ); |
|
101 if ( r == KErrNone ) |
|
102 { |
|
103 DThread* thread = (DThread*) TempObject(); |
|
104 |
|
105 // Check the threads in the process are suspended |
|
106 if ( SuspensionManager().IsSuspended( *thread ) ) |
|
107 { |
|
108 DMemSpyDriverOSAdaptionDThread& threadAdaption = OSAdaption().DThread(); |
|
109 // |
|
110 GetStackPointers( thread, params.iSupervisorStackPointer, params.iUserStackPointer ); |
|
111 // |
|
112 params.iUserStackBase = threadAdaption.GetUserStackBase( *thread ); |
|
113 params.iUserStackSize = threadAdaption.GetUserStackSize( *thread ); |
|
114 params.iSupervisorStackBase = threadAdaption.GetSupervisorStackBase( *thread ); |
|
115 params.iSupervisorStackSize = threadAdaption.GetSupervisorStackSize( *thread ); |
|
116 |
|
117 // Try to get watermarks |
|
118 GetStackHighWatermark( *thread, params.iUserStackHighWatermark, EMemSpyDriverDomainUser, KMemSpyStackFillPatternUser ); |
|
119 GetStackHighWatermark( *thread, params.iSupervisorStackHighWatermark, EMemSpyDriverDomainKernel, KMemSpyStackFillPatternSupervisor ) ; |
|
120 |
|
121 #ifdef __WINS__ |
|
122 params.iUserStackPointer = params.iUserStackBase; |
|
123 params.iUserStackHighWatermark = params.iUserStackBase; |
|
124 params.iSupervisorStackPointer = params.iSupervisorStackBase; |
|
125 params.iSupervisorStackHighWatermark = params.iSupervisorStackBase; |
|
126 #endif |
|
127 |
|
128 // Write data to user-side |
|
129 r = Kern::ThreadRawWrite( &ClientThread(), aParams, ¶ms, sizeof(TMemSpyDriverStackInfo) ); |
|
130 } |
|
131 else |
|
132 { |
|
133 TRACE( Kern::Printf("DMemSpyDriverLogChanStack::GetStackInfo - parent process not suspended => KErrAccessDenied")); |
|
134 r = KErrAccessDenied; |
|
135 } |
|
136 |
|
137 CloseTempObject(); |
|
138 } |
|
139 |
|
140 TRACE( Kern::Printf("DMemSpyDriverLogChanStack::GetStackInfo() - END - ret: %d", r)); |
|
141 return r; |
|
142 } |
|
143 |
|
144 |
|
145 TInt DMemSpyDriverLogChanStack::GetStackData( TMemSpyDriverInternalStackDataParams* aParams ) |
|
146 { |
|
147 TRACE( Kern::Printf("DMemSpyDriverLogChanStack::GetStackData() - START")); |
|
148 TMemSpyDriverInternalStackDataParams params; |
|
149 TInt r = Kern::ThreadRawRead( &ClientThread(), aParams, ¶ms, sizeof(TMemSpyDriverInternalStackDataParams) ); |
|
150 if ( r != KErrNone ) |
|
151 { |
|
152 TRACE( Kern::Printf("DMemSpyDriverLogChanStack::GetStackData() - END - params read error: %d", r)); |
|
153 return r; |
|
154 } |
|
155 |
|
156 TRACE( Kern::Printf("DMemSpyDriverLogChanStack::GetStackData - thread id: %d, remaining: %8d", params.iTid, params.iRemaining)); |
|
157 |
|
158 DMemSpyDriverOSAdaptionDThread& threadAdaption = OSAdaption().DThread(); |
|
159 |
|
160 r = OpenTempObject( params.iTid, EThread ); |
|
161 if ( r == KErrNone ) |
|
162 { |
|
163 // Find the correct thread... |
|
164 DThread* thread = (DThread*) TempObject(); |
|
165 DProcess* process = threadAdaption.GetOwningProcess( *thread ); |
|
166 TFullName fullName; |
|
167 thread->FullName( fullName ); |
|
168 TRACE( Kern::Printf("DMemSpyDriverLogChanStack::GetStackData - thread: %lS", &fullName)); |
|
169 |
|
170 // Check the threads in the process are suspended |
|
171 const TBool isSuspended = SuspensionManager().IsSuspended( *process ); |
|
172 TRACE( Kern::Printf("DMemSpyDriverLogChanStack::GetStackData() - isSuspended: %d", isSuspended )); |
|
173 if ( isSuspended ) |
|
174 { |
|
175 TInt stackSize = 0; |
|
176 TUint32 stackBase = 0; |
|
177 TBool stackAvailable = EFalse; |
|
178 // |
|
179 if ( params.iDomain == EMemSpyDriverDomainUser ) |
|
180 { |
|
181 stackSize = threadAdaption.GetUserStackSize( *thread ); |
|
182 stackBase = threadAdaption.GetUserStackBase( *thread ); |
|
183 } |
|
184 else if ( params.iDomain == EMemSpyDriverDomainKernel ) |
|
185 { |
|
186 stackSize = threadAdaption.GetSupervisorStackSize( *thread ); |
|
187 stackBase = threadAdaption.GetSupervisorStackBase( *thread ); |
|
188 } |
|
189 TRACE( Kern::Printf("DMemSpyDriverLogChanStack::GetStackData() - stackAvailable: %d", stackAvailable )); |
|
190 // |
|
191 if ( stackAvailable ) |
|
192 { |
|
193 // Get user side descriptor length info |
|
194 TInt destLen = 0; |
|
195 TInt destMax = 0; |
|
196 TUint8* destPtr = NULL; |
|
197 r = Kern::ThreadGetDesInfo( &ClientThread(), params.iDes, destLen, destMax, destPtr, ETrue ); |
|
198 TRACE( Kern::Printf("DMemSpyDriverLogChanStack::GetStackData - user side descriptor: 0x%08x (0x%08x), len: %8d, maxLen: %8d, r: %d", params.iDes, destPtr, destLen, destMax, r )); |
|
199 |
|
200 if ( r == KErrNone ) |
|
201 { |
|
202 // Calculate stack starting address. If we want to get the entire stack data |
|
203 // then we use the information from DThread. If we only want the data from |
|
204 // the current SP onwards, then we use GetStackPointerByDomain to return |
|
205 // the current SP value. If we are only fetching a portion of the stack, then |
|
206 // the amount of data we will have to read is obviously reduced. |
|
207 TUint32 stackStartingAddress = 0; |
|
208 if ( params.iEntireStack ) |
|
209 { |
|
210 stackStartingAddress = stackBase; |
|
211 } |
|
212 else |
|
213 { |
|
214 stackStartingAddress = GetStackPointerByDomain( thread, params.iDomain ); |
|
215 } |
|
216 TRACE( Kern::Printf("DMemSpyDriverLogChanStack::GetStackData - stackStartingAddress: 0x%08x", stackStartingAddress)); |
|
217 __ASSERT_ALWAYS( stackStartingAddress != 0, MemSpyDriverUtils::Fault( __LINE__ ) ); |
|
218 |
|
219 // Calculate how much data (maximum) there is to read, depending on whether the |
|
220 // client asked for all or just the active part of the stack. |
|
221 TUint stackDataSize = 0; |
|
222 if ( params.iEntireStack ) |
|
223 { |
|
224 stackDataSize = stackSize; |
|
225 } |
|
226 else |
|
227 { |
|
228 stackDataSize = stackBase + stackSize - stackStartingAddress; |
|
229 } |
|
230 TRACE( Kern::Printf("DMemSpyDriverLogChanStack::GetStackData - stackDataSize: %8d", stackDataSize )); |
|
231 |
|
232 // Deal with the initial case - i.e. whereby the client is requesting stack |
|
233 // data for the first time. In this situation, the magic rune for "first |
|
234 // request" is a remaining value of -1. |
|
235 if ( params.iRemaining < 0 ) |
|
236 { |
|
237 params.iRemaining = stackDataSize; |
|
238 } |
|
239 |
|
240 // The remaining number of bytes should allow us to calculate the position |
|
241 // to read from. |
|
242 const TInt amountToRead = Min( params.iRemaining, destMax ); |
|
243 TRACE( Kern::Printf("DMemSpyDriverLogChanStack::GetStackData - amountToRead: %8d", amountToRead)); |
|
244 const TInt readOffset = ( stackDataSize - params.iRemaining ); |
|
245 TRACE( Kern::Printf("DMemSpyDriverLogChanStack::GetStackData - readOffset: %8d", readOffset)); |
|
246 const TAny* readAddress = (const TAny*) ( stackStartingAddress + readOffset ); |
|
247 TRACE( Kern::Printf("DMemSpyDriverLogChanStack::GetStackData - readAddress: 0x%08x", readAddress)); |
|
248 |
|
249 // Do the read into user-space |
|
250 #ifndef __WINS__ |
|
251 if ( params.iDomain == EMemSpyDriverDomainKernel ) |
|
252 { |
|
253 const TPtrC8 pData( (TUint8*) readAddress, amountToRead ); |
|
254 r = Kern::ThreadDesWrite( &Kern::CurrentThread(), params.iDes, pData, 0 ); |
|
255 } |
|
256 else |
|
257 { |
|
258 r = Kern::ThreadRawRead( thread, readAddress, destPtr, amountToRead ); |
|
259 } |
|
260 |
|
261 // Update user-side |
|
262 TRACE( Kern::Printf("DMemSpyDriverLogChanStack::GetStackData - mem. operation result: %d", r)); |
|
263 if ( r == KErrNone ) |
|
264 { |
|
265 // Update remaining bytes and write back to user address space |
|
266 params.iRemaining -= amountToRead; |
|
267 r = Kern::ThreadRawWrite( &ClientThread(), aParams, ¶ms, sizeof(TMemSpyDriverInternalStackDataParams) ); |
|
268 |
|
269 if ( r == KErrNone ) |
|
270 { |
|
271 // Client takes care of updating descriptor length. |
|
272 r = amountToRead; |
|
273 } |
|
274 } |
|
275 else if ( r == KErrBadDescriptor ) |
|
276 { |
|
277 MemSpyDriverUtils::PanicThread( ClientThread(), EPanicBadDescriptor ); |
|
278 } |
|
279 #else |
|
280 (void) destPtr; |
|
281 params.iRemaining -= amountToRead; |
|
282 r = amountToRead; |
|
283 Kern::Printf( "DMemSpyDriverLogChanStack::GetStackData - not reading data on WINS" ); |
|
284 #endif |
|
285 } |
|
286 else |
|
287 { |
|
288 Kern::Printf( "DMemSpyDriverLogChanStack::GetStackData - error getting client descriptor info" ); |
|
289 } |
|
290 } |
|
291 else |
|
292 { |
|
293 Kern::Printf("DMemSpyDriverLogChanStack::GetStackData - stack address or stack length is invalid"); |
|
294 r = KErrArgument; |
|
295 } |
|
296 } |
|
297 else |
|
298 { |
|
299 TRACE( Kern::Printf("DMemSpyDriverLogChanStack::GetStackData - parent process not suspended => KErrAccessDenied")); |
|
300 r = KErrAccessDenied; |
|
301 } |
|
302 |
|
303 CloseTempObject(); |
|
304 } |
|
305 else |
|
306 { |
|
307 Kern::Printf("DMemSpyDriverLogChanStack::GetStackData - thread not found"); |
|
308 } |
|
309 |
|
310 TRACE( Kern::Printf("DMemSpyDriverLogChanStack::GetStackData() - END - ret: %d", r)); |
|
311 return r; |
|
312 } |
|
313 |
|
314 |
|
315 |
|
316 |
|
317 |
|
318 |
|
319 |
|
320 |
|
321 |
|
322 |
|
323 |
|
324 |
|
325 |
|
326 |
|
327 |
|
328 #ifdef __MARM__ |
|
329 |
|
330 #define __INCLUDE_REG_OFFSETS__ // for SP_R13U in nk_plat.h |
|
331 #include "nk_plat.h" |
|
332 #include "arm.h" |
|
333 |
|
334 void DMemSpyDriverLogChanStack::GetStackPointers( DThread* aThread, TUint& aSupSP, TUint& aUsrSP ) |
|
335 { |
|
336 __ASSERT_ALWAYS( aThread != &Kern::CurrentThread(), MemSpyDriverUtils::Fault( __LINE__ ) ); |
|
337 |
|
338 // Get NThread associated with DThread |
|
339 NThread* nThread = OSAdaption().DThread().GetNThread( *aThread ); |
|
340 |
|
341 TMemSpyDriverRegSet regs; |
|
342 MemSpyDriverUtils::GetThreadRegisters( nThread, regs ); |
|
343 // |
|
344 aSupSP = aThread->iNThread.iSavedSP; |
|
345 aUsrSP = regs.iRn[13]; |
|
346 // |
|
347 TRACE( Kern::Printf("DMemSpyDriverLogChanStack::GetStackPointers() - usr: 0x%08x [0x%08x-0x%08x], svc: 0x%08x [0x%08x-0x%08x]", aUsrSP, aThread->iUserStackRunAddress, (TUint) aThread->iUserStackRunAddress + (TUint) aThread->iUserStackSize, aSupSP, aThread->iSupervisorStack, (TUint) aThread->iSupervisorStack + (TUint) aThread->iSupervisorStackSize )); |
|
348 } |
|
349 |
|
350 |
|
351 TLinAddr DMemSpyDriverLogChanStack::GetStackPointerByDomain( DThread* aThread, TMemSpyDriverDomainType aDomainType ) |
|
352 { |
|
353 TUint stackPointer = 0; |
|
354 // |
|
355 if ( aDomainType == EMemSpyDriverDomainUser ) |
|
356 { |
|
357 // Get NThread associated with DThread |
|
358 NThread* nThread = OSAdaption().DThread().GetNThread( *aThread ); |
|
359 |
|
360 TMemSpyDriverRegSet regSet; |
|
361 MemSpyDriverUtils::GetThreadRegisters( nThread, regSet ); |
|
362 stackPointer = regSet.iRn[13]; |
|
363 } |
|
364 else if ( aDomainType == EMemSpyDriverDomainKernel ) |
|
365 { |
|
366 TUint userSPNotUsed = 0; |
|
367 GetStackPointers( aThread, stackPointer, userSPNotUsed ); |
|
368 } |
|
369 // |
|
370 return TLinAddr( stackPointer ); |
|
371 } |
|
372 |
|
373 #else |
|
374 |
|
375 void DMemSpyDriverLogChanStack::GetStackPointers( DThread* /*aThread*/, TUint& aSupSP, TUint& aUsrSP ) |
|
376 { |
|
377 aSupSP = 0; |
|
378 aUsrSP = 0; |
|
379 } |
|
380 |
|
381 |
|
382 TLinAddr DMemSpyDriverLogChanStack::GetStackPointerByDomain( DThread* aThread, TMemSpyDriverDomainType aDomainType ) |
|
383 { |
|
384 // Just return the base address in WINS |
|
385 DMemSpyDriverOSAdaptionDThread& threadAdaption = OSAdaption().DThread(); |
|
386 TUint32 stackPointer = 0; |
|
387 // |
|
388 if ( aDomainType == EMemSpyDriverDomainUser ) |
|
389 { |
|
390 stackPointer = threadAdaption.GetUserStackBase( *aThread ); |
|
391 } |
|
392 else if ( aDomainType == EMemSpyDriverDomainKernel ) |
|
393 { |
|
394 stackPointer = threadAdaption.GetSupervisorStackBase( *aThread ); |
|
395 } |
|
396 // |
|
397 return TLinAddr( stackPointer ); |
|
398 } |
|
399 |
|
400 #endif |
|
401 |
|
402 |
|
403 TInt DMemSpyDriverLogChanStack::GetStackHighWatermark( DThread& aThread, TLinAddr& aHighWatermark, TMemSpyDriverDomainType aDomain, TUint aRune ) |
|
404 { |
|
405 aHighWatermark = 0; |
|
406 const TInt KStackPageSize = 512; |
|
407 |
|
408 TRACE( Kern::Printf("DMemSpyDriverLogChanStack::GetStackHighWatermark() - START - domain: %d, rune: 0x%08x", aDomain, aRune )); |
|
409 |
|
410 DMemSpyDriverOSAdaptionDThread& threadAdaption = OSAdaption().DThread(); |
|
411 |
|
412 const TUint32 baseAddress = aDomain == EMemSpyDriverDomainUser ? threadAdaption.GetUserStackBase( aThread ) : threadAdaption.GetSupervisorStackBase( aThread ); |
|
413 const TInt size = aDomain == EMemSpyDriverDomainUser ? threadAdaption.GetUserStackSize( aThread ) : threadAdaption.GetSupervisorStackSize( aThread ); |
|
414 TRACE( Kern::Printf("DMemSpyDriverLogChanStack::GetStackHighWatermark - baseAddress: 0x%08x, size: %8d", baseAddress, size)); |
|
415 |
|
416 TInt r = KErrNone; |
|
417 // |
|
418 if ( baseAddress && size ) |
|
419 { |
|
420 aHighWatermark = baseAddress; |
|
421 TBuf8<KStackPageSize> stackBuf; |
|
422 TUint8* readAddress = NULL; |
|
423 // |
|
424 while( r == KErrNone ) |
|
425 { |
|
426 // Read a chunk of data |
|
427 r = ReadStackData( aThread, stackBuf, readAddress, aDomain ); |
|
428 |
|
429 // Process the data, looking for the first bytes that aren't 0x29292929 |
|
430 if ( r == KErrNone ) |
|
431 { |
|
432 const TInt readLength = stackBuf.Length(); |
|
433 TRACE_DATA( MemSpyDriverUtils::DataDump("stackdata - %lS", stackBuf.Ptr(), readLength, readLength ) ); |
|
434 |
|
435 TRACE( Kern::Printf("DMemSpyDriverLogChanStack::GetStackHighWatermark - readLength: %d", readLength)); |
|
436 |
|
437 for( TInt readPos = 0; readPos < readLength && ((readLength - readPos) >= 4); readPos += 4, aHighWatermark += 4 ) |
|
438 { |
|
439 const TUint dword = stackBuf[ readPos ] + |
|
440 (stackBuf[ readPos + 1 ] << 8) + |
|
441 (stackBuf[ readPos + 2 ] << 16) + |
|
442 (stackBuf[ readPos + 3 ] << 24); |
|
443 // |
|
444 if ( dword != aRune ) |
|
445 { |
|
446 TRACE( Kern::Printf("DMemSpyDriverLogChanStack::GetStackHighWatermark - found end of uninit. stack!")); |
|
447 TRACE( Kern::Printf("DMemSpyDriverLogChanStack::GetStackHighWatermark - dword: 0x%08x", dword)); |
|
448 TRACE( Kern::Printf("DMemSpyDriverLogChanStack::GetStackHighWatermark - readPos: %8d", readPos)); |
|
449 TRACE( Kern::Printf("DMemSpyDriverLogChanStack::GetStackHighWatermark - aHighWatermark: 0x%08x", aHighWatermark)); |
|
450 TRACE( Kern::Printf("DMemSpyDriverLogChanStack::GetStackHighWatermark() - END")); |
|
451 return KErrNone; |
|
452 } |
|
453 } |
|
454 } |
|
455 } |
|
456 } |
|
457 // |
|
458 aHighWatermark = 0; |
|
459 Kern::Printf("DMemSpyDriverLogChanStack::GetStackHighWatermark() - END - error: %d", r); |
|
460 return r; |
|
461 } |
|
462 |
|
463 |
|
464 TInt DMemSpyDriverLogChanStack::ReadStackData( DThread& aThread, TDes8& aDestination, TUint8*& aReadAddress, TMemSpyDriverDomainType aDomain ) |
|
465 { |
|
466 TRACE( Kern::Printf("DMemSpyDriverLogChanStack::ReadStackData() - START - domain: %d", aDomain )); |
|
467 |
|
468 DMemSpyDriverOSAdaptionDThread& threadAdaption = OSAdaption().DThread(); |
|
469 |
|
470 const TUint32 baseAddress = aDomain == EMemSpyDriverDomainUser ? threadAdaption.GetUserStackBase( aThread ) : threadAdaption.GetSupervisorStackBase( aThread ); |
|
471 const TInt size = aDomain == EMemSpyDriverDomainUser ? threadAdaption.GetUserStackSize( aThread ) : threadAdaption.GetSupervisorStackSize( aThread ); |
|
472 const TUint32 topAddress = ( baseAddress + size ); |
|
473 TRACE( Kern::Printf("DMemSpyDriverLogChanStack::ReadStackData - baseAddress: 0x%08x", baseAddress)); |
|
474 TRACE( Kern::Printf("DMemSpyDriverLogChanStack::ReadStackData - size: 0x%08x", size)); |
|
475 TRACE( Kern::Printf("DMemSpyDriverLogChanStack::ReadStackData - topAddress: 0x%08x", topAddress)); |
|
476 // |
|
477 if ( aReadAddress == NULL ) |
|
478 { |
|
479 aReadAddress = (TUint8*) baseAddress; |
|
480 } |
|
481 |
|
482 // Work out how much we should read |
|
483 TInt readLen = Min( aDestination.MaxLength(), topAddress - (TLinAddr) aReadAddress ); |
|
484 TRACE( Kern::Printf("DMemSpyDriverLogChanStack::ReadStackData - aReadAddress: 0x%08x", aReadAddress)); |
|
485 TRACE( Kern::Printf("DMemSpyDriverLogChanStack::ReadStackData - readLen: %8d", readLen)); |
|
486 |
|
487 TInt r = KErrNotSupported; |
|
488 aDestination.Zero(); |
|
489 |
|
490 #ifndef __WINS__ |
|
491 if ( aDomain == EMemSpyDriverDomainKernel ) |
|
492 { |
|
493 const TPtrC8 pData( (TUint8*) aReadAddress, readLen ); |
|
494 aDestination.Copy( pData ); |
|
495 r = KErrNone; |
|
496 readLen = aDestination.Length(); |
|
497 } |
|
498 else |
|
499 { |
|
500 r = Kern::ThreadRawRead( &aThread, aReadAddress, (TAny*) aDestination.Ptr(), readLen ); |
|
501 } |
|
502 |
|
503 TRACE( Kern::Printf("DMemSpyDriverLogChanStack::ReadStackData - read result: %d", r)); |
|
504 if (r == KErrNone) |
|
505 { |
|
506 aDestination.SetLength( readLen ); |
|
507 aReadAddress += aDestination.Length(); |
|
508 } |
|
509 #else |
|
510 Kern::Printf("DMemSpyDriverLogChanStack::ReadStackData - not reading data on WINS"); |
|
511 #endif |
|
512 |
|
513 TRACE( Kern::Printf("DMemSpyDriverLogChanStack::ReadStackData() - END - ret: %d", r)); |
|
514 return r; |
|
515 } |
|
516 |
|
517 |
|
518 |
|
519 |