memspyui/ui/avkon/src/MemSpyUiUtils.cpp
changeset 31 e7a04a6385be
parent 26 41ebde60981f
equal deleted inserted replaced
30:d8e625c87f33 31:e7a04a6385be
   147 	    	break;  
   147 	    	break;  
   148 		}
   148 		}
   149 	return pType;
   149 	return pType;
   150 	}
   150 	}
   151 
   151 
       
   152 
       
   153 void MemSpyUiUtils::AppendPriority( TDes& aDes, TProcessPriority aPriority )
       
   154 	{
       
   155 	switch( aPriority )
       
   156 		{
       
   157 	    case EPriorityLow:
       
   158 	        aDes += _L("[L]");
       
   159 	        break;
       
   160 	    case EPriorityBackground:
       
   161 	        aDes += _L("[B]");
       
   162 	        break;
       
   163 	    case EPriorityForeground:
       
   164 	        aDes += _L("[F]");
       
   165 	        break;
       
   166 	    case EPriorityHigh:
       
   167 	        aDes += _L("[H]");
       
   168 	        break;
       
   169 	    case EPriorityWindowServer:
       
   170 	        aDes += _L("[WS]");
       
   171 	        break;
       
   172 	    case EPriorityFileServer:
       
   173 	        aDes += _L("[FS]");
       
   174 	        break;
       
   175 	    case EPriorityRealTimeServer:
       
   176 	        aDes += _L("[RTS]");
       
   177 	        break;
       
   178 	    case EPrioritySupervisor:
       
   179 	        aDes += _L("[SUP]");
       
   180 	        break;
       
   181 	    default:
       
   182 	        aDes += _L("[?]");
       
   183 	        break;
       
   184 		}
       
   185 	}
       
   186 
       
   187 void MemSpyUiUtils::AppendExitInfo( TDes& aDes, TExitType aType, TInt aExitReason, const TDesC& aExitCategory  )
       
   188 	{
       
   189     aDes.Append( '[' );
       
   190     const TInt length = aDes.Length();
       
   191     AppendExitType( aDes, aType );
       
   192     aDes.SetLength( length + 1 ); // Remove all but the first letter
       
   193     aDes.Append( ']' );
       
   194     
       
   195     if  ( aType == EExitKill || aType == EExitPending )
       
   196         {
       
   197         // Kill implies "clean" exit. Pending implies not yet dead.
       
   198         }
       
   199     else
       
   200         {
       
   201         TMemSpyTruncateOverflow overflow;
       
   202 
       
   203         // Terminate or Panic implies abnormal exit condition, so
       
   204         // show full exit info.
       
   205         _LIT( KAbnormalFormatSpec, " %S-%d" );
       
   206         aDes.AppendFormat( KAbnormalFormatSpec, &overflow, &aExitCategory, aExitReason );
       
   207         }
       
   208 	}
       
   209 
       
   210 
       
   211 void MemSpyUiUtils::AppendExitType( TDes& aDes, TExitType aType )
       
   212     {
       
   213     _LIT( KExitTypeKilled, "Killed" );
       
   214     _LIT( KExitTypeTerminated, "Terminated" );
       
   215     _LIT( KExitTypePanicked, "Panicked" );
       
   216     _LIT( KExitTypePending, "Pending" );
       
   217     
       
   218     // Panic and Terminate are exceptional exit conditions.
       
   219     // Kill, is ironically, not an exceptional condition.
       
   220     switch( aType )
       
   221         {
       
   222     case EExitKill:
       
   223         aDes += KExitTypeKilled;
       
   224         break;
       
   225     case EExitTerminate:
       
   226         aDes += KExitTypeTerminated;
       
   227         break;
       
   228     case EExitPanic:
       
   229         aDes += KExitTypePanicked;
       
   230         break;
       
   231     default:
       
   232     case EExitPending:
       
   233         aDes += KExitTypePending;
       
   234         break;
       
   235         }
       
   236     }
       
   237 
       
   238 
       
   239 TPtrC MemSpyUiUtils::TypeAsString( TMemSpyDriverContainerType aType )
       
   240     {     
       
   241     TPtrC pType( KTypeUnknown );
       
   242     //
       
   243     switch( aType )
       
   244         {
       
   245     case EMemSpyDriverContainerTypeThread:
       
   246         pType.Set( KTypeThread );
       
   247         break;
       
   248     case EMemSpyDriverContainerTypeProcess:
       
   249         pType.Set( KTypeProcess );
       
   250         break;
       
   251     case EMemSpyDriverContainerTypeChunk:
       
   252         pType.Set( KTypeChunk );
       
   253         break;
       
   254     case EMemSpyDriverContainerTypeLibrary:
       
   255         pType.Set( KTypeLibrary );
       
   256         break;
       
   257     case EMemSpyDriverContainerTypeSemaphore:
       
   258         pType.Set( KTypeSemaphore );
       
   259         break;
       
   260     case EMemSpyDriverContainerTypeMutex:
       
   261         pType.Set( KTypeMutex );
       
   262         break;
       
   263     case EMemSpyDriverContainerTypeTimer:
       
   264         pType.Set( KTypeTimer );
       
   265         break;
       
   266     case EMemSpyDriverContainerTypeServer:
       
   267         pType.Set( KTypeServer );
       
   268         break;
       
   269     case EMemSpyDriverContainerTypeSession:
       
   270         pType.Set( KTypeSession );
       
   271         break;
       
   272     case EMemSpyDriverContainerTypeLogicalDevice:
       
   273         pType.Set( KTypeLogicalDevice );
       
   274         break;
       
   275     case EMemSpyDriverContainerTypePhysicalDevice:
       
   276         pType.Set( KTypePhysicalDevice );
       
   277         break;
       
   278     case EMemSpyDriverContainerTypeLogicalChannel:
       
   279         pType.Set( KTypeLogicalChannel );
       
   280         break;
       
   281     case EMemSpyDriverContainerTypeChangeNotifier:
       
   282         pType.Set( KTypeChangeNotifier );
       
   283         break;
       
   284     case EMemSpyDriverContainerTypeUndertaker:
       
   285         pType.Set( KTypeUndertaker );
       
   286         break;
       
   287     case EMemSpyDriverContainerTypeMsgQueue:
       
   288         pType.Set( KTypeMsgQueue );
       
   289         break;
       
   290     case EMemSpyDriverContainerTypePropertyRef:
       
   291         pType.Set( KTypePropertyRef );
       
   292         break;
       
   293     case EMemSpyDriverContainerTypeCondVar:
       
   294         pType.Set( KTypeCondVar );
       
   295         break;
       
   296         
       
   297     default:
       
   298         break;
       
   299         }
       
   300     //
       
   301     return pType;
       
   302     }
       
   303 
       
   304 TMemSpySizeText MemSpyUiUtils::FormatSizeText( const TInt64& aValue, TInt aDecimalPlaces, TBool aExtraRounding )
       
   305     {
       
   306     _LIT(KFormatKilo, "%dK");
       
   307     _LIT(KFormatMega, "%SM");
       
   308     _LIT(KFormatGiga, "%SG");
       
   309 
       
   310 	TMemSpySizeText buf;
       
   311 	if  ( aValue < 1024000 )					// If < 1000K
       
   312 		{
       
   313 		TInt sizeInK = 0;
       
   314 
       
   315         if  ( aValue != 0 )
       
   316 			{
       
   317 			sizeInK = I64INT( (aValue + 512) >> 10 );
       
   318 			if  (sizeInK < 1)
       
   319                 {
       
   320 				sizeInK = 1;
       
   321                 }
       
   322 			if  (sizeInK > 999)
       
   323                 {
       
   324 				sizeInK = 999;
       
   325                 }
       
   326 			}
       
   327 
       
   328         buf.Format( KFormatKilo, sizeInK );
       
   329 		}
       
   330 	else
       
   331 		{
       
   332 		TReal sizeInM = I64INT( aValue );
       
   333 		sizeInM /= 1048576;
       
   334 		if  ( sizeInM < 1 )
       
   335             {
       
   336 			sizeInM = 1;
       
   337             }
       
   338 
       
   339         TPtrC pFormat( KFormatMega );
       
   340 		if  ( sizeInM >= 1000 )
       
   341 			{
       
   342 			sizeInM /= 1024;				// Size in G
       
   343 			if  (sizeInM < 1)
       
   344                 {
       
   345 				sizeInM = 1;
       
   346                 }
       
   347 			
       
   348             pFormat.Set( KFormatGiga );
       
   349 			}
       
   350 
       
   351         if  ( sizeInM > 999.9)
       
   352             {
       
   353             sizeInM = 999.9;
       
   354             }
       
   355 
       
   356         if  ( aExtraRounding )
       
   357             {
       
   358 			sizeInM += 0.499999;
       
   359             }
       
   360 
       
   361 		TBuf<16> size;
       
   362 		size.Num( sizeInM, TRealFormat( 14, aDecimalPlaces ) );	// Allow for "17179869184.0"G which is 2^64
       
   363         buf.Format( pFormat, &size );
       
   364 		}
       
   365 
       
   366     return buf;
       
   367     }