1481{
1482
1484 unsigned long t_index = 0, d_index = 0, b_index = 0, counting = 1;
1487 unsigned long begin = 0, end = 0, size = 0, inode = 0, foo = 0;
1490
1491 memset( fname, 0x0, sizeof ( fname ) );
1492 memset(
buf, 0x0,
sizeof (
buf ) );
1493 memset(
perm, 0x0,
sizeof (
perm ) );
1494 memset( dev, 0x0, sizeof ( dev ) );
1495 memset( mapname, 0x0, sizeof ( mapname ) );
1496 memset( lastmapname, 0x0, sizeof ( lastmapname ) );
1497
1498 sprintf( fname,
"/proc/%ld/maps", (
long ) mdi->
pid );
1499 f = fopen( fname,
"r" );
1500
1502 PAPIERROR(
"fopen(%s) returned < 0", fname );
1504 }
1505
1506 again:
1507 while ( !feof(
f ) ) {
1508 begin = end = size = inode = foo = 0;
1509 if ( fgets(
buf,
sizeof (
buf ),
f ) == 0 )
1510 break;
1511
1512 if ( strlen( mapname ) )
1513 strcpy( lastmapname, mapname );
1514 else
1515 lastmapname[0] = '\0';
1516
1517 mapname[0] = '\0';
1518 sscanf(
buf,
"%lx-%lx %4s %lx %s %ld %s", &begin, &end,
perm, &foo, dev,
1519 &inode, mapname );
1520 size = end - begin;
1521
1522
1523
1524
1525
1526 if ( counting ) {
1527 if ( (
perm[2] ==
'x' ) && (
perm[0] ==
'r' ) && ( inode != 0 ) ) {
1529 == 0 ) {
1533 (
vptr_t ) ( begin + size );
1534 }
1535 t_index++;
1536 }
else if ( (
perm[0] ==
'r' ) && (
perm[1] ==
'w' ) &&
1537 ( inode != 0 )
1538 &&
1539 ( strcmp
1541 mapname ) == 0 ) ) {
1545 (
vptr_t ) ( begin + size );
1546 d_index++;
1547 }
else if ( (
perm[0] ==
'r' ) && (
perm[1] ==
'w' ) &&
1548 ( inode == 0 )
1549 &&
1550 ( strcmp
1552 lastmapname ) == 0 ) ) {
1556 (
vptr_t ) ( begin + size );
1557 b_index++;
1558 }
1559 } else if ( !counting ) {
1560 if ( (
perm[2] ==
'x' ) && (
perm[0] ==
'r' ) && ( inode != 0 ) ) {
1562 != 0 ) {
1563 t_index++;
1564 tmp[t_index - 1].text_start = (
vptr_t ) begin;
1565 tmp[t_index - 1].text_end = (
vptr_t ) ( begin + size );
1568 }
1569 }
else if ( (
perm[0] ==
'r' ) && (
perm[1] ==
'w' ) &&
1570 ( inode != 0 ) ) {
1571 if ( ( strcmp
1573 mapname ) != 0 )
1574 && ( t_index > 0 ) &&
1575 (
tmp[t_index - 1].data_start == 0 ) ) {
1576 tmp[t_index - 1].data_start = (
vptr_t ) begin;
1577 tmp[t_index - 1].data_end = (
vptr_t ) ( begin + size );
1578 }
1579 }
else if ( (
perm[0] ==
'r' ) && (
perm[1] ==
'w' ) &&
1580 ( inode == 0 ) ) {
1581 if ( ( t_index > 0 ) && (
tmp[t_index - 1].bss_start == 0 ) ) {
1582 tmp[t_index - 1].bss_start = (
vptr_t ) begin;
1583 tmp[t_index - 1].bss_end = (
vptr_t ) ( begin + size );
1584 }
1585 }
1586 }
1587 }
1588
1589 if ( counting ) {
1590
1591
1592
1595 sizeof
1597 if (
tmp == NULL ) {
1598 PAPIERROR(
"Error allocating shared library address map" );
1601 }
1602 t_index = 0;
1604 counting = 0;
1605 goto again;
1606 } else {
1611
1613 }
1614
1616}
volatile int buf[CACHE_FLUSH_BUFFER_SIZE_INTS]
#define PAPI_HUGE_STR_LEN
#define papi_calloc(a, b)
get the executable's address space info
char fullname[PAPI_HUGE_STR_LEN]
PAPI_address_map_t address_info
PAPI_shlib_info_t shlib_info