kernel/eka/debug/crashMonitor/src/scmdatasave.cpp
changeset 102 ef2a444a7410
parent 0 a41df078684a
child 271 dc268b18d709
equal deleted inserted replaced
90:947f0dc9f7a8 102:ef2a444a7410
   976  */
   976  */
   977 TInt SCMDataSave::FindKernelHeap(TInt32& aHeapLocation, TInt32& aHeapSize)
   977 TInt SCMDataSave::FindKernelHeap(TInt32& aHeapLocation, TInt32& aHeapSize)
   978 	{
   978 	{
   979 	LOG_CONTEXT
   979 	LOG_CONTEXT
   980 	
   980 	
   981 	//Get Chunk object container
   981 	//Get process object container
   982 	DObjectCon* objectContainer = Kern::Containers()[EChunk];
   982 	DObjectCon* objectContainer = Kern::Containers()[EProcess];
       
   983 	if(objectContainer == NULL)
       
   984 		{		
       
   985 		CLTRACE("\tFailed to get object container for the processes");
       
   986 		return KErrNotFound;
       
   987 		}
       
   988 	
       
   989 	//Must check the mutex on this is ok otherwise the data will be in an inconsistent state
       
   990 	if(objectContainer->Lock()->iHoldCount)
       
   991 		{
       
   992 		CLTRACE("\tChunk Container is in an inconsistant state");
       
   993 		return KErrCorrupt;
       
   994 		}
       
   995 	
       
   996 	TInt numObjects = objectContainer->Count();	
       
   997 	
       
   998 	DProcess* kernelProcess = NULL;
       
   999 	for(TInt cnt = 0; cnt < numObjects; cnt ++)
       
  1000 		{		
       
  1001 		DProcess* candidateProcess = (DProcess*)(*objectContainer)[cnt];
       
  1002 		
       
  1003 		//Get the objects name
       
  1004 		TBuf8<KMaxKernelName> name;
       
  1005 		candidateProcess->TraceAppendFullName(name,EFalse);		
       
  1006 		if(name == KKernelProcessName)
       
  1007 			{
       
  1008 			kernelProcess = candidateProcess;
       
  1009 			}
       
  1010 		}
       
  1011 	if (!kernelProcess)
       
  1012 		return KErrNotFound;
       
  1013 
       
  1014 	//Get chunk object container
       
  1015 	objectContainer = Kern::Containers()[EChunk];
   983 	if(objectContainer == NULL)
  1016 	if(objectContainer == NULL)
   984 		{		
  1017 		{		
   985 		CLTRACE("\tFailed to get object container for the chunks");
  1018 		CLTRACE("\tFailed to get object container for the chunks");
   986 		return KErrNotFound;
  1019 		return KErrNotFound;
   987 		}
  1020 		}
   989 	//Must check the mutex on this is ok otherwise the data will be in an inconsistent state
  1022 	//Must check the mutex on this is ok otherwise the data will be in an inconsistent state
   990 	if(objectContainer->Lock()->iHoldCount)
  1023 	if(objectContainer->Lock()->iHoldCount)
   991 		{
  1024 		{
   992 		CLTRACE("\tChunk Container is in an inconsistant state");
  1025 		CLTRACE("\tChunk Container is in an inconsistant state");
   993 		return KErrCorrupt;
  1026 		return KErrCorrupt;
   994 		}
  1027 		}	
   995 	
  1028 	
   996 	TInt numObjects = objectContainer->Count();	
  1029 	numObjects = objectContainer->Count();
   997 	
  1030 	for(TInt cnt = 0; cnt < numObjects; cnt ++)
   998 	for(TInt cnt = 0; cnt< numObjects; cnt ++)
       
   999 		{		
  1031 		{		
  1000 		DChunk* candidateHeapChunk = (DChunk*)(*objectContainer)[cnt];
  1032 		DChunk* candidateHeapChunk = (DChunk*)(*objectContainer)[cnt];
  1001 		
  1033 		
  1002 		//Get the objects name
  1034 		//Get the objects name
  1003 		TBuf8<KMaxKernelName> name;
  1035 		TBuf8<KMaxKernelName> name;
  1004 		candidateHeapChunk->TraceAppendFullName(name,EFalse);
  1036 		candidateHeapChunk->TraceAppendFullName(name,EFalse);
  1005 		
  1037 		
  1006 		if(name == KKernelHeapChunkName)
  1038 		if(name == KKernelHeapChunkName)
  1007 			{
  1039 			{
  1008 			#ifndef __MEMMODEL_FLEXIBLE__
  1040 			aHeapLocation = (TInt32)candidateHeapChunk->Base(kernelProcess);
  1009 				aHeapLocation = (TInt32)candidateHeapChunk->iBase;
  1041 			aHeapSize = candidateHeapChunk->iSize;
  1010 			#else
       
  1011 				aHeapLocation = (TInt32)candidateHeapChunk->iFixedBase;
       
  1012 			#endif
       
  1013 				
       
  1014 				aHeapSize = candidateHeapChunk->iSize;
       
  1015 				
       
  1016 			return KErrNone;
  1042 			return KErrNone;
  1017 			}
  1043 			}
  1018 		}
  1044 		}
  1019 	
  1045 	
  1020 	return KErrNotFound;
  1046 	return KErrNotFound;