PAPI  5.3.0.0
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
PAPI_get_executable_info.c
Go to the documentation of this file.
1 /*****************************************************************************
2 * This is an example using the low level function PAPI_get_executable_info *
3 * get the executable address space information. This function returns a *
4 * pointer to a structure containing address information about the current *
5 * program. *
6 ******************************************************************************/
7 
8 #include <stdio.h>
9 #include <stdlib.h>
10 #include "papi.h" /* This needs to be included every time you use PAPI */
11 
12 int main()
13 {
14  int i,tmp=0;
15  int retval;
16  const PAPI_exe_info_t *prginfo = NULL;
17 
18  /****************************************************************************
19  * This part initializes the library and compares the version number of the *
20  * header file, to the version of the library, if these don't match then it *
21  * is likely that PAPI won't work correctly.If there is an error, retval *
22  * keeps track of the version number. *
23  ****************************************************************************/
24 
26  {
27  printf("Library initialization error! \n");
28  exit(1);
29  }
30 
31 
32  for(i=0;i<1000;i++)
33  tmp=tmp+i;
34 
35  /* PAPI_get_executable_info returns a NULL if there is an error */
36  if ((prginfo = PAPI_get_executable_info()) == NULL)
37  {
38  printf("PAPI_get_executable_info error! \n");
39  exit(1);
40  }
41 
42 
43  printf("Start text addess of user program is at %p\n",
44  prginfo->address_info.text_start);
45  printf("End text address of user program is at %p\n",
46  prginfo->address_info.text_end);
47 
48  exit(0);
49 }
caddr_t text_end
Definition: papi.h:693
get the executable&#39;s info
Definition: papi.h:702
#define printf
Definition: papi_test.h:125
Return codes and api definitions.
int PAPI_library_init(int version)
Definition: papi.c:495
int i
Definition: fileop.c:140
const PAPI_exe_info_t * PAPI_get_executable_info(void)
Definition: papi.c:5975
caddr_t text_start
Definition: papi.h:692
PAPI_address_map_t address_info
Definition: papi.h:704
#define PAPI_VER_CURRENT
Definition: fpapi.h:14
ssize_t retval
Definition: libasync.c:338
long long tmp
Definition: iozone.c:12031
int main(int argc, char **argv)
List all appio events codes and names.
void exit()