PAPI  5.0.1.0
PAPI_get_executable_info.c
Go to the documentation of this file.
00001 /*****************************************************************************
00002 * This is an example using the low level function PAPI_get_executable_info   *
00003 * get the executable address space information. This function returns a      *
00004 * pointer to a structure containing address information about the current    *
00005 * program.                                                                   *
00006 ******************************************************************************/
00007 
00008 #include <stdio.h>
00009 #include <stdlib.h>
00010 #include "papi.h" /* This needs to be included every time you use PAPI */
00011 
00012 int main()
00013 {
00014    int i,tmp=0;   
00015    int retval;
00016    const PAPI_exe_info_t *prginfo = NULL;
00017 
00018    /****************************************************************************
00019    *  This part initializes the library and compares the version number of the *
00020    * header file, to the version of the library, if these don't match then it  *
00021    * is likely that PAPI won't work correctly.If there is an error, retval     *
00022    * keeps track of the version number.                                        *
00023    ****************************************************************************/
00024 
00025    if((retval = PAPI_library_init(PAPI_VER_CURRENT)) != PAPI_VER_CURRENT )
00026    {
00027       printf("Library initialization error! \n");
00028       exit(1);
00029    }
00030     
00031 
00032    for(i=0;i<1000;i++)
00033       tmp=tmp+i;
00034     
00035    /* PAPI_get_executable_info returns a NULL if there is an error */    
00036    if ((prginfo = PAPI_get_executable_info()) == NULL)
00037    {
00038       printf("PAPI_get_executable_info error! \n");
00039       exit(1);
00040    }
00041 
00042   
00043    printf("Start text addess of user program is at %p\n",
00044               prginfo->address_info.text_start);
00045    printf("End text address of user program is at %p\n",
00046               prginfo->address_info.text_end);
00047 
00048    exit(0);
00049 }
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines