imgtools/imgcheck/src/dbgflagchecker.cpp
changeset 0 044383f39525
child 590 360bd6b35136
equal deleted inserted replaced
-1:000000000000 0:044383f39525
       
     1 /*
       
     2 * Copyright (c) 2008-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 the License "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 * DbgFlagChecker class is to 
       
    16 * 1. extract all Debuggable flag from all executables present in ROM/ROFS sections.
       
    17 * 2. Validate them.
       
    18 * 3. Put the validated data into Reporter class Instance.
       
    19 *
       
    20 */
       
    21 
       
    22 
       
    23 /**
       
    24  @file
       
    25  @internalComponent
       
    26  @released
       
    27 */
       
    28 #include "dbgflagchecker.h"
       
    29 
       
    30 /** 
       
    31 Constructor intializes the iDbgFlag member.
       
    32 
       
    33 @internalComponent
       
    34 @released
       
    35 
       
    36 @param aCmdPtr - pointer to an processed CmdLineHandler object
       
    37 @param aImageReaderList - List of ImageReader insatance pointers
       
    38 */
       
    39 DbgFlagChecker::DbgFlagChecker(CmdLineHandler* aCmdPtr, ImageReaderPtrList& aImageReaderList)
       
    40 :Checker(aCmdPtr, aImageReaderList)
       
    41 {
       
    42 	iUserDefinedDbgFlag = iCmdLine->DebuggableFlagVal();
       
    43 }
       
    44 
       
    45 /**
       
    46 Destructor
       
    47 
       
    48 @internalComponent
       
    49 @released
       
    50 */
       
    51 DbgFlagChecker::~DbgFlagChecker()
       
    52 {
       
    53 }
       
    54 
       
    55 /**
       
    56 Fucntion responsible to Prepare the E32 executables Debuggable flag data
       
    57 
       
    58 @internalComponent
       
    59 @released
       
    60 
       
    61 @param ImgVsExeStatus - Global integrated container which contains image, exes and attribute value status.
       
    62 */
       
    63 void DbgFlagChecker::Check(ImgVsExeStatus& aImgVsExeStatus)
       
    64 {
       
    65 	ImageReaderPtrList::iterator begin = iImageReaderList.begin();
       
    66 	ImageReaderPtrList::iterator end = iImageReaderList.end();
       
    67 	ExeVsIdDataMap exeVsIdDataMap;
       
    68 	ExeVsIdDataMap::iterator exeBegin;
       
    69 	ExeVsIdDataMap::iterator exeEnd;
       
    70 	ExeVsIdDataMap::iterator exeTemp;
       
    71 	ImageReader* imageReader = KNull;
       
    72 	String imageName;
       
    73 	while(begin != end)
       
    74 	{
       
    75 		imageReader = *begin;
       
    76 		imageName = imageReader->ImageName();
       
    77 		ExceptionReporter(GATHERINGIDDATA, (char*)KDbgFlag.c_str(),(char*)imageName.c_str()).Log();
       
    78 		imageReader->PrepareExeVsIdMap();
       
    79 		
       
    80 		exeVsIdDataMap = imageReader->GetExeVsIdMap();
       
    81 		exeBegin = exeVsIdDataMap.begin();
       
    82 		exeEnd = exeVsIdDataMap.end();
       
    83 		if((aImgVsExeStatus[imageName].size() == 0) 
       
    84 			|| (aImgVsExeStatus[imageName][exeBegin->first].iIdData == KNull))
       
    85 		{
       
    86 			while(exeBegin != exeEnd)
       
    87 			{
       
    88 				aImgVsExeStatus[imageName][exeBegin->first].iIdData = exeBegin->second;
       
    89 				aImgVsExeStatus[imageName][exeBegin->first].iExeName = exeBegin->first;
       
    90 				++exeBegin;
       
    91 			}
       
    92 		}
       
    93 		++begin;
       
    94 	}
       
    95 }
       
    96 
       
    97 /**
       
    98 Function responsible to Validate and write the debuggable flag data into Reporter.
       
    99 
       
   100 @internalComponent
       
   101 @released
       
   102 
       
   103 @param aExeContainer - Global integrated container which contains all the attribute, values and the status.
       
   104 */
       
   105 void DbgFlagChecker::PrepareAndWriteData(ExeContainer* aExeContainer)
       
   106 {
       
   107 	ExeAttribute* exeAtt = KNull;
       
   108 	IdData* idData = KNull;
       
   109 	
       
   110 	idData = aExeContainer->iIdData;
       
   111 	exeAtt = new ExeAttribute;
       
   112 	if(!exeAtt)
       
   113 	{
       
   114 		throw ExceptionReporter(NOMEMORY, __FILE__, __LINE__);
       
   115 	}
       
   116 	exeAtt->iAttName = KDbgFlag;
       
   117 	exeAtt->iAttValue = (idData->iDbgFlag)? String("true") : String("false");
       
   118 	if(!iNoCheck)
       
   119 	{
       
   120 		idData->iDbgFlagStatus = (iUserDefinedDbgFlag == idData->iDbgFlag) ? KDbgMatching : KDbgNotMatching;
       
   121 		exeAtt->iAttStatus = idData->iDbgFlagStatus;		
       
   122 	}
       
   123 	else
       
   124 	{
       
   125 		exeAtt->iAttStatus = KNull;
       
   126 	}
       
   127 	if(iAllExecutables || (exeAtt->iAttStatus == KDbgNotMatching) || iNoCheck)
       
   128 	{
       
   129 		aExeContainer->iExeAttList.push_back(exeAtt);
       
   130 	}
       
   131 }