analyzetool/commandlineengine/inc/catromsymbol.h
branchRCL_3
changeset 13 da2cedce4920
equal deleted inserted replaced
12:d27dfa8884ad 13:da2cedce4920
       
     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:  Defines CATRomSymbol, RofsBinary classes and Symbol
       
    15 *               structure.
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 #ifndef __CATROMSYMBOL_H__
       
    21 #define __CATROMSYMBOL_H__
       
    22 
       
    23 #include "ATCommonDefines.h"
       
    24 #include "iaddresstoline.h"
       
    25 
       
    26 const string ROM_SYMBOL_IDENTIFY_STRING = "80";
       
    27 const string ROFS_SYMBOL_IDENTIFY_STRING = "00";
       
    28 const int IDENTIFY_MAX_LINES_READ = 20;
       
    29 
       
    30 /**
       
    31 * Represents a single symbol in a binary.
       
    32 */
       
    33 struct Symbol
       
    34 {
       
    35 	unsigned long iStartAddress; /** Start address */
       
    36 	unsigned long iEndAddress; /** End address */
       
    37 	string sFunction; /** Function/Symbol name */
       
    38 	/**
       
    39 	* Default constructor for structure to set default values
       
    40 	*/
       
    41 	Symbol() { iStartAddress=0; iEndAddress=0; sFunction = ""; }
       
    42 	/**
       
    43 	* Empty destructor
       
    44 	*/
       
    45 	~Symbol() {}
       
    46 };
       
    47 
       
    48 
       
    49 /**
       
    50 * Represents a single binary in ROM/ROFS which
       
    51 * contains a collection of Symbols.
       
    52 */
       
    53 class RofsBinary {
       
    54 public:
       
    55 	/**
       
    56 	* Constructor
       
    57 	*/
       
    58 	RofsBinary();
       
    59 	/**
       
    60 	* Constructor
       
    61 	* @param sbinary
       
    62 	*/
       
    63 	RofsBinary( const string& sbinary );
       
    64 	/**
       
    65 	* Destructor
       
    66 	*/
       
    67 	~RofsBinary();
       
    68 
       
    69 	// Members
       
    70 
       
    71 	string m_sBinary; /** Binary / code segment */
       
    72 	vector<Symbol*> vSymbols; /** Collection of symbols */
       
    73 };
       
    74 
       
    75 /**
       
    76 * Implements IAddressToLine interface to acquire symbol information
       
    77 * using memory addresses from rom/rofs symbol files.
       
    78 */
       
    79 class CATRomSymbol : public IAddressToLine
       
    80 {
       
    81 public:
       
    82 	/**
       
    83 	* Constructor.
       
    84 	*/
       
    85 	CATRomSymbol();
       
    86 	/**
       
    87 	* Destructor.
       
    88 	*/
       
    89 	virtual ~CATRomSymbol();
       
    90 	bool m_bShowProgressMessages; /** "Flag" will we show progress when reading files */
       
    91 	/**
       
    92 	* Empty functions does nothing returns false always.
       
    93 	* @param sString
       
    94 	* @param iLong
       
    95 	* @return true if successful.
       
    96 	*/
       
    97 	bool Open( const string& sString, const unsigned long iLong);
       
    98 	/**
       
    99 	* Set symbol files.
       
   100 	* This also checks that files exists and identifies them as rom/rofs.
       
   101 	* @param vSymbols
       
   102 	* @return bool
       
   103 	*/
       
   104 	bool SetSymbols( const vector<string>& vSymbols);
       
   105 	/**
       
   106 	* Get error string. In case of any method failed use this to acquire details on error.
       
   107 	* @return error string.
       
   108 	*/
       
   109 	string GetError( void );
       
   110 	/**
       
   111 	* Close rom symbol file.
       
   112 	* @return true if succesful.
       
   113 	*/
       
   114 	bool Close( void );
       
   115 	/**
       
   116 	* Locates symbol and binary name for given address if found in rom.
       
   117 	* @param result memory address object.
       
   118 	* @return true if successful.
       
   119 	*/
       
   120 	bool AddressToLine( CATMemoryAddress* result );
       
   121 #ifndef MODULE_TEST
       
   122 private:
       
   123 #endif
       
   124 	/**
       
   125 	* Represents the symbol files type
       
   126 	* (content is different / format )
       
   127 	*/
       
   128 	enum SYMBOL_FILE_TYPE {
       
   129 		SYMBOL_FILE_INVALID = 0, /** not valid */
       
   130 		SYMBOL_FILE_ROM, /** rom type */
       
   131 		SYMBOL_FILE_ROFS /** rofs type */
       
   132 	};
       
   133 	/**
       
   134 	* Identify symbol file
       
   135 	* @param sFile
       
   136 	* @return int
       
   137 	*/
       
   138 	int IdentifySymbolFile( const string& sFile );
       
   139 	/**
       
   140 	* Locate symbol and binary name for given address if found in rom.
       
   141 	* @param result
       
   142 	* @return bool
       
   143 	*/
       
   144 	bool AddressToLineRom( CATMemoryAddress* result );
       
   145 	/**
       
   146 	* Locate symbol and binary name for given address if found in rofs.
       
   147 	* @param result
       
   148 	* @return bool
       
   149 	*/
       
   150 	bool AddressToLineRofs( CATMemoryAddress* result );
       
   151 	/**
       
   152 	* Reads rom files.
       
   153 	* @return bool
       
   154 	*/
       
   155 	bool ReadRomFiles();
       
   156 	/**
       
   157 	* Read specified rom file
       
   158 	* @param sFile
       
   159 	* @return bool
       
   160 	*/
       
   161 	bool ReadRomFile( const string& sFile );
       
   162 	/**
       
   163 	* Read rofs files
       
   164 	* @return bool
       
   165 	*/
       
   166 	bool ReadRofsFiles();
       
   167 	/**
       
   168 	* Read specified rofs file
       
   169 	* @param sFile
       
   170 	* @return bool
       
   171 	*/
       
   172 	bool ReadRofsFile( const string& sFile );
       
   173 	/**
       
   174 	* Parse symbol from a line in rom/rofs file.
       
   175 	* @param sLine
       
   176 	* @param pSymbol
       
   177 	*/
       
   178 	void ParseSymbolFromLine( const string& sLine, Symbol* pSymbol );
       
   179 #ifndef MODULE_TEST
       
   180 private:
       
   181 #endif
       
   182 
       
   183 	// Members
       
   184 
       
   185 	bool m_bFilesIdentified; /**  Have we identified symbol file(s) */
       
   186 	bool m_bSymbolsRead; /** Have we read symbol file(s) */
       
   187 	vector<string> m_vRomFiles; /** Rom symbol file(s) */
       
   188 	vector<Symbol*> m_vRomCache; /** Cached rom symbols */
       
   189 	vector<Symbol*> m_vRomSymbols; /** All rom symbols */
       
   190 	unsigned long m_iRomStartAddress; /** Rom start address */
       
   191 	unsigned long m_iRomEndAddress; /** Rom end address */
       
   192 	vector<string> m_vRofsFiles; /** Rofs symbol file(s) */
       
   193 	vector<RofsBinary*> m_vRofsBinaries; /** Rofs binaries */
       
   194 	string m_sErrorMessage; /** Error message */
       
   195 };
       
   196 #endif