memana/analyzetoolclient/commandlineengine/internal/inc/catromsymbol.h
changeset 2 6a82cd05fb1e
parent 1 3ff3fecb12fe
equal deleted inserted replaced
1:3ff3fecb12fe 2:6a82cd05fb1e
     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:  Locates symbols/functions for memory addresses
       
    15 *               which are located in given rom/rofs symbol file.
       
    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 // Symbol structure.
       
    31 struct Symbol
       
    32 {
       
    33 	// Start address.
       
    34 	unsigned long iStartAddress;
       
    35 	// End address.
       
    36 	unsigned long iEndAddress;
       
    37 	// Function/Symbol name.
       
    38 	string sFunction;
       
    39 	// Default constructor for structure.
       
    40 	Symbol() { iStartAddress=0; iEndAddress=0; sFunction = ""; }
       
    41 	~Symbol() {}
       
    42 };
       
    43 
       
    44 // Rofs binary item class
       
    45 class RofsBinary {
       
    46 public:
       
    47 	string m_sBinary;
       
    48 	vector<Symbol*> vSymbols;
       
    49 	RofsBinary();
       
    50 	RofsBinary( const string& sbinary );
       
    51 	~RofsBinary();
       
    52 };
       
    53 
       
    54 
       
    55 class CATRomSymbol : public IAddressToLine
       
    56 {
       
    57 public:
       
    58 	/**
       
    59 	* Constructor.
       
    60 	*/
       
    61 	CATRomSymbol();
       
    62 	/**
       
    63 	* Destructor.
       
    64 	*/
       
    65 	virtual ~CATRomSymbol();
       
    66 	/**
       
    67 	* "Flag" will we show progress when reading files.
       
    68 	*/
       
    69 	bool m_bShowProgressMessages;
       
    70 	/**
       
    71 	* Empty functions does nothing returns false always.
       
    72 	* @return true if successful.
       
    73 	*/
       
    74 	bool Open( const string& sString, const unsigned long iLong);
       
    75 	/**
       
    76 	* Set symbol files.
       
    77 	* This also checks that files exists and identifies them as rom/rofs.
       
    78 	* @vSymbols.
       
    79 	*/
       
    80 	bool SetSymbols( const vector<string>& vSymbols);
       
    81 	/**
       
    82 	* Get error string. In case of any method failed use this to acquire details on error.
       
    83 	* @return error string.
       
    84 	*/
       
    85 	string GetError( void );
       
    86 	/**
       
    87 	* Close rom symbol file.
       
    88 	* @return true if succesful.
       
    89 	*/
       
    90 	bool Close( void );
       
    91 	/**
       
    92 	* Locates symbol and binary name for given address if found in rom.
       
    93 	* @result memory address object.
       
    94 	* @return true if successful.
       
    95 	*/
       
    96 	bool AddressToLine( CATMemoryAddress* result );
       
    97 #ifndef MODULE_TEST
       
    98 private:
       
    99 #endif
       
   100 	enum SYMBOL_FILE_TYPE {
       
   101 		SYMBOL_FILE_INVALID = 0,
       
   102 		SYMBOL_FILE_ROM,
       
   103 		SYMBOL_FILE_ROFS
       
   104 	};
       
   105 	// Identify symbol file
       
   106 	int IdentifySymbolFile( const string& sFile );
       
   107 	// Locate symbol and binary name for given address if found in rom.
       
   108 	bool AddressToLineRom( CATMemoryAddress* result );
       
   109 	// Locate symbol and binary name for given address if found in rofs.
       
   110 	bool AddressToLineRofs( CATMemoryAddress* result );
       
   111 	// Reads rom file.
       
   112 	bool ReadRomFiles();
       
   113 	bool ReadRomFile( const string& sFile );
       
   114 	// Read rofs file.
       
   115 	bool ReadRofsFiles();
       
   116 	bool ReadRofsFile( const string& sFile );
       
   117 	// Parse symbol from a line in rom/rofs file.
       
   118 	void ParseSymbolFromLine( const string& sLine, Symbol* pSymbol );
       
   119 #ifndef MODULE_TEST
       
   120 private:
       
   121 #endif
       
   122 	// Have we identified symbol file(s).
       
   123 	bool m_bFilesIdentified;
       
   124 	// Have we read symbol file(s).
       
   125 	bool m_bSymbolsRead;
       
   126 
       
   127 	// Rom symbol file(s).
       
   128 	vector<string> m_vRomFiles;
       
   129 	// Cached rom symbols.
       
   130 	vector<Symbol*> m_vRomCache;
       
   131 	// All rom symbols.
       
   132 	vector<Symbol*> m_vRomSymbols;
       
   133 	// Rom start address.
       
   134 	unsigned long m_iRomStartAddress;
       
   135 	// Rom end address.
       
   136 	unsigned long m_iRomEndAddress;
       
   137 
       
   138 	// Rofs symbol file(s)
       
   139 	vector<string> m_vRofsFiles;
       
   140 	// Rofs binaries
       
   141 	vector<RofsBinary*> m_vRofsBinaries;
       
   142 
       
   143 	// Error message.
       
   144 	string m_sErrorMessage;
       
   145 };
       
   146 #endif