parameters: (memdump_contents, lib_name, verbose)
return_statement: return resident_pages
docstring: Parses the memdump output and extracts the resident page set for lib_name.
    Args:
      memdump_contents: Array of strings (lines) of a memdump output.
      lib_name: A string containing the name of the library.so to be matched.
      verbose: Print a verbose header for each mapping matched.
  
    Returns:
      A set of resident pages (the key is the page index) for all the
      mappings matching .*lib_name.
docstring_summary: Parses the memdump output and extracts the resident page set for lib_name.
    Args:
      memdump_contents: Array of strings (lines) of a memdump output.
      lib_name: A string containing the name of the library.so to be matched.
      verbose: Print a verbose header for each mapping matched.
docstring_tokens: Parses the memdump output and extracts the resident page set for lib_name . Args : memdump_contents : Array of strings ( lines ) of a memdump output . lib_name : A string containing the name of the library . so to be matched . verbose : Print a verbose header for each mapping matched .
function: def _GetResidentPagesSet(memdump_contents, lib_name, verbose):
    """Parses the memdump output and extracts the resident page set for lib_name.
    Args:
      memdump_contents: Array of strings (lines) of a memdump output.
      lib_name: A string containing the name of the library.so to be matched.
      verbose: Print a verbose header for each mapping matched.
  
    Returns:
      A set of resident pages (the key is the page index) for all the
      mappings matching .*lib_name.
    """
    resident_pages = set()
    MAP_RX = re.compile(
        r'^([0-9a-f]+)-([0-9a-f]+) ([\w-]+) ([0-9a-f]+) .* "(.*)" \[(.*)\]$')
    for line in memdump_contents:
      line = line.rstrip('\r\n')
      if line.startswith('[ PID'):
        continue
  
      r = MAP_RX.match(line)
      if not r:
        sys.stderr.write('Skipping %s from %s\n' % (line, memdump_file))
        continue
  
      map_start = int(r.group(1), 16)
      map_end = int(r.group(2), 16)
      prot = r.group(3)
      offset = int(r.group(4), 16)
      assert(offset % _PAGE_SIZE == 0)
      lib = r.group(5)
      enc_bitmap = r.group(6)
  
      if not lib.endswith(lib_name):
        continue
  
      bitmap = base64.b64decode(enc_bitmap)
      map_pages_count = (map_end - map_start + 1) / _PAGE_SIZE
      bitmap_pages_count = len(bitmap) * 8
  
      if verbose:
        print 'Found %s: mapped %d pages in mode %s @ offset %s.' % (
              lib, map_pages_count, prot, _HexAddr(offset))
        print ' Map range in the process VA: [%s - %s]. Len: %s' % (
            _HexAddr(map_start),
            _HexAddr(map_end),
            _HexAddr(map_pages_count * _PAGE_SIZE))
        print ' Corresponding addresses in the binary: [%s - %s]. Len: %s' % (
            _HexAddr(offset),
            _HexAddr(offset + map_end - map_start),
            _HexAddr(map_pages_count * _PAGE_SIZE))
        print ' Bitmap: %d pages' % bitmap_pages_count
        print ''
  
      assert(bitmap_pages_count >= map_pages_count)
      for i in xrange(map_pages_count):
        bitmap_idx = i / 8
        bitmap_off = i % 8
        if (bitmap_idx < len(bitmap) and
            _TestBit(ord(bitmap[bitmap_idx]), bitmap_off)):
          resident_pages.add(offset / _PAGE_SIZE + i)
    return resident_pages
function_tokens: def _GetResidentPagesSet ( memdump_contents , lib_name , verbose ) : resident_pages = set ( ) MAP_RX = re . compile ( r'^([0-9a-f]+)-([0-9a-f]+) ([\w-]+) ([0-9a-f]+) .* "(.*)" \[(.*)\]$' ) for line in memdump_contents : line = line . rstrip ( '\r\n' ) if line . startswith ( '[ PID' ) : continue r = MAP_RX . match ( line ) if not r : sys . stderr . write ( 'Skipping %s from %s\n' % ( line , memdump_file ) ) continue map_start = int ( r . group ( 1 ) , 16 ) map_end = int ( r . group ( 2 ) , 16 ) prot = r . group ( 3 ) offset = int ( r . group ( 4 ) , 16 ) assert ( offset % _PAGE_SIZE == 0 ) lib = r . group ( 5 ) enc_bitmap = r . group ( 6 ) if not lib . endswith ( lib_name ) : continue bitmap = base64 . b64decode ( enc_bitmap ) map_pages_count = ( map_end - map_start + 1 ) / _PAGE_SIZE bitmap_pages_count = len ( bitmap ) * 8 if verbose : print 'Found %s: mapped %d pages in mode %s @ offset %s.' % ( lib , map_pages_count , prot , _HexAddr ( offset ) ) print ' Map range in the process VA: [%s - %s]. Len: %s' % ( _HexAddr ( map_start ) , _HexAddr ( map_end ) , _HexAddr ( map_pages_count * _PAGE_SIZE ) ) print ' Corresponding addresses in the binary: [%s - %s]. Len: %s' % ( _HexAddr ( offset ) , _HexAddr ( offset + map_end - map_start ) , _HexAddr ( map_pages_count * _PAGE_SIZE ) ) print ' Bitmap: %d pages' % bitmap_pages_count print '' assert ( bitmap_pages_count >= map_pages_count ) for i in xrange ( map_pages_count ) : bitmap_idx = i / 8 bitmap_off = i % 8 if ( bitmap_idx < len ( bitmap ) and _TestBit ( ord ( bitmap [ bitmap_idx ] ) , bitmap_off ) ) : resident_pages . add ( offset / _PAGE_SIZE + i ) return resident_pages