kernel/eka/debug/crashMonitor/src/scmdatasave.cpp
changeset 102 ef2a444a7410
parent 0 a41df078684a
child 271 dc268b18d709
--- a/kernel/eka/debug/crashMonitor/src/scmdatasave.cpp	Fri Apr 16 16:24:37 2010 +0300
+++ b/kernel/eka/debug/crashMonitor/src/scmdatasave.cpp	Mon May 03 13:47:38 2010 +0300
@@ -978,11 +978,11 @@
 	{
 	LOG_CONTEXT
 	
-	//Get Chunk object container
-	DObjectCon* objectContainer = Kern::Containers()[EChunk];
+	//Get process object container
+	DObjectCon* objectContainer = Kern::Containers()[EProcess];
 	if(objectContainer == NULL)
 		{		
-		CLTRACE("\tFailed to get object container for the chunks");
+		CLTRACE("\tFailed to get object container for the processes");
 		return KErrNotFound;
 		}
 	
@@ -995,7 +995,39 @@
 	
 	TInt numObjects = objectContainer->Count();	
 	
-	for(TInt cnt = 0; cnt< numObjects; cnt ++)
+	DProcess* kernelProcess = NULL;
+	for(TInt cnt = 0; cnt < numObjects; cnt ++)
+		{		
+		DProcess* candidateProcess = (DProcess*)(*objectContainer)[cnt];
+		
+		//Get the objects name
+		TBuf8<KMaxKernelName> name;
+		candidateProcess->TraceAppendFullName(name,EFalse);		
+		if(name == KKernelProcessName)
+			{
+			kernelProcess = candidateProcess;
+			}
+		}
+	if (!kernelProcess)
+		return KErrNotFound;
+
+	//Get chunk object container
+	objectContainer = Kern::Containers()[EChunk];
+	if(objectContainer == NULL)
+		{		
+		CLTRACE("\tFailed to get object container for the chunks");
+		return KErrNotFound;
+		}
+	
+	//Must check the mutex on this is ok otherwise the data will be in an inconsistent state
+	if(objectContainer->Lock()->iHoldCount)
+		{
+		CLTRACE("\tChunk Container is in an inconsistant state");
+		return KErrCorrupt;
+		}	
+	
+	numObjects = objectContainer->Count();
+	for(TInt cnt = 0; cnt < numObjects; cnt ++)
 		{		
 		DChunk* candidateHeapChunk = (DChunk*)(*objectContainer)[cnt];
 		
@@ -1005,14 +1037,8 @@
 		
 		if(name == KKernelHeapChunkName)
 			{
-			#ifndef __MEMMODEL_FLEXIBLE__
-				aHeapLocation = (TInt32)candidateHeapChunk->iBase;
-			#else
-				aHeapLocation = (TInt32)candidateHeapChunk->iFixedBase;
-			#endif
-				
-				aHeapSize = candidateHeapChunk->iSize;
-				
+			aHeapLocation = (TInt32)candidateHeapChunk->Base(kernelProcess);
+			aHeapSize = candidateHeapChunk->iSize;
 			return KErrNone;
 			}
 		}