memana/analyzetoolclient/commandlineengine/internal/inc/catdbghelper.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:  Windows debug api implementation for IAddressToLine interface.
       
    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 class CATDbgHelper : public IAddressToLine
       
    29 {
       
    30 
       
    31 public:
       
    32 	
       
    33 	/**
       
    34 	* Constructor
       
    35 	*/
       
    36 	CATDbgHelper();
       
    37 	
       
    38 	/**
       
    39 	* Destructor
       
    40 	*/
       
    41 	~CATDbgHelper();
       
    42 
       
    43 	/**
       
    44 	* Open binary.
       
    45 	* @sString Full filename with path to binary.
       
    46 	* @iLong base address of binary.
       
    47 	* @return true if successful.
       
    48 	*/
       
    49 	bool Open( const string& sString, const unsigned long iLong);
       
    50 	
       
    51 	/**
       
    52 	* Get error string. In case of any method failed use this to acquire details on error.
       
    53 	* @return error string.
       
    54 	*/
       
    55 	string GetError( void );
       
    56 
       
    57 	/**
       
    58 	* Close binary.
       
    59 	* @return true if succesful.
       
    60 	*/
       
    61 	bool Close( void );
       
    62 
       
    63 	/**
       
    64 	* Read map file for function's.
       
    65 	*/
       
    66 	void ReadMapFile( const string sMapFileName );
       
    67 
       
    68 	/**
       
    69 	* Locate code line and file for given address.
       
    70 	* @result
       
    71 	* @return true if successful.
       
    72 	*/
       
    73 	bool AddressToLine( CATMemoryAddress* result );
       
    74 
       
    75 	/**
       
    76 	* Try get function name for address (only when map is read).
       
    77 	* @result
       
    78 	* @return true if succesful.
       
    79 	*/
       
    80 	bool AddressToFunction( CATMemoryAddress* result );
       
    81 
       
    82 #ifndef MODULE_TEST
       
    83 private:
       
    84 #endif
       
    85 	// Base address used.
       
    86 	DWORD64 m_BaseAddress;
       
    87 	// Map file read?
       
    88 	bool m_bMap;
       
    89 	// Map file functions.
       
    90 	vector<MAP_FUNC_INFO> m_vMapFileFuncList;
       
    91 	// Binary in file system.
       
    92 	PSTR m_pBinaryFile;
       
    93 };