analyzetool/commandlineengine/inc/catdbghelper.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 the CATDbgHelper class.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include "iaddresstoline.h"
       
    20 // Static variable to represent state of dbghelper api.
       
    21 static bool CDBGHELPER_OPEN = false;
       
    22 static unsigned int CDBGHELPER_CLIENTS = 0;
       
    23 
       
    24 // Used "virtual" offset for all loaded modules and addresses.
       
    25 // This is used so no module is loaded to the binary address range of atool.exe.
       
    26 const unsigned long AT_VIRTUAL_OFFSET_DBGHELPER = 0x1000000;
       
    27 
       
    28 /**
       
    29 * Provides feature to locate code lines using Windows Debug Api. This is done
       
    30 * by using dbghelper library. Implements the IAddressToLine interface.
       
    31 */
       
    32 class CATDbgHelper : public IAddressToLine
       
    33 {
       
    34 
       
    35 public:
       
    36 	
       
    37 	/**
       
    38 	* Constructor
       
    39 	*/
       
    40 	CATDbgHelper();
       
    41 	
       
    42 	/**
       
    43 	* Destructor
       
    44 	*/
       
    45 	~CATDbgHelper();
       
    46 
       
    47 	/**
       
    48 	* Open binary.
       
    49 	* @sString Full filename with path to binary.
       
    50 	* @iLong base address of binary.
       
    51 	* @return true if successful.
       
    52 	*/
       
    53 	bool Open( const string& sString, const unsigned long iLong);
       
    54 	
       
    55 	/**
       
    56 	* Get error string. In case of any method failed use this to acquire details on error.
       
    57 	* @return error string.
       
    58 	*/
       
    59 	string GetError( void );
       
    60 
       
    61 	/**
       
    62 	* Close binary.
       
    63 	* @return true if succesful.
       
    64 	*/
       
    65 	bool Close( void );
       
    66 
       
    67 	/**
       
    68 	* Read map file for function's.
       
    69 	*/
       
    70 	void ReadMapFile( const string sMapFileName );
       
    71 
       
    72 	/**
       
    73 	* Locate code line and file for given address.
       
    74 	* @result
       
    75 	* @return true if successful.
       
    76 	*/
       
    77 	bool AddressToLine( CATMemoryAddress* result );
       
    78 
       
    79 	/**
       
    80 	* Try get function name for address (only when map is read).
       
    81 	* @result
       
    82 	* @return true if succesful.
       
    83 	*/
       
    84 	bool AddressToFunction( CATMemoryAddress* result );
       
    85 
       
    86 #ifndef MODULE_TEST
       
    87 private:
       
    88 #endif
       
    89 	// Base address used.
       
    90 	DWORD64 m_BaseAddress;
       
    91 	// Map file read?
       
    92 	bool m_bMap;
       
    93 	// Map file functions.
       
    94 	vector<MAP_FUNC_INFO> m_vMapFileFuncList;
       
    95 	// Binary in file system.
       
    96 	PSTR m_pBinaryFile;
       
    97 };