1 PMAPPING_ITER(3PROC)   Process Control Library Functions  PMAPPING_ITER(3PROC)
   2 
   3 NAME
   4      Pmapping_iter, Pmapping_iter_resolved, Pobject_iter,
   5      Pobject_iter_resolved - iterate over process mappings and objects
   6 
   7 LIBRARY
   8      Process Control Library (libproc, -lproc)
   9 
  10 SYNOPSIS
  11      #include <libproc.h>
  12 
  13      int
  14      Pmapping_iter(struct ps_prochandle *P, proc_map_f *func, void *data);
  15 
  16      int
  17      Pmapping_iter_resolved(struct ps_prochandle *P, proc_map_f *func,
  18          void *data);
  19 
  20      int
  21      Pobject_iter(struct ps_prochandle *P, proc_map_f *func, void *data);
  22 
  23      int
  24      Pobject_iter_resolved(struct ps_prochandle *P, proc_map_f *func,
  25          void *data);
  26 
  27 DESCRIPTION
  28      The Pmapping_iter() and Pmapping_iter_resolved() functions iterate over
  29      the memory mappings in the process represented by P.
  30 
  31      For each memory mapping, the callback function func will be invoked and
  32      it will be passed the data argument, the prmap_t structure defined from
  33      proc(4), and a name of the mapping.  The way that the name is obtained
  34      varies based on whether one calls Pmapping_iter() or
  35      Pmapping_iter_resolved().  In both cases, the dynamic linker is consulted
  36      to determine the file name for the mapping, if it's known.  If the name
  37      is unknown, for example an anonymous mapping, then the NULL pointer is
  38      passed in for the name.  In the case of the Pmapping_iter_resolved()
  39      function the system tries to resolve it to a complete file system path.
  40      If that fails, it falls back to the information from the dynamic linker,
  41      before returning NULL in the case of not being able to find any name.
  42      For more information on the signature of the proc_map_f, see
  43      libproc(3LIB).
  44 
  45      The return value of func controls whether or not iteration continues.  If
  46      func returns 0 then iteration continues.  If func returns non-zero then
  47      iteration will halt and the value will be returned to the caller.
  48      Because -1 indicates internal failure, it is recommended that the
  49      callback function not return -1 to indicate an error itself.  This allows
  50      the caller to distinguish between failure of the callback function versus
  51      failure of the Pmapping_iter() and Pmapping_iter_resolved() functions.
  52 
  53      The Pobject_iter() and Pobject_iter_resolved() functions are similar to
  54      the Pmapping_iter() and Pmapping_iter_resolved() functions.  Except,
  55      rather than iterating over every mapping, they iterate over the objects
  56      that the process has loaded by the dynamic linker.  For example, an
  57      anonymous mapping will show up when iterating mappings, but will not show
  58      up when iterating objects.  Further, while most dynamic shared objects
  59      have multiple mappings for the text and data sections, there will only be
  60      a single object that is iterated over.
  61 
  62      The distinction between the Pobject_iter() and Pobject_iter_resolved()
  63      functions is identical to the difference in name resolution between the
  64      Pmapping_iter() and Pmapping_iter_resolved() functions.
  65 
  66 RETURN VALUES
  67      Upon successful completion, the Pmapping_iter(), Pmapping_iter_resolved()
  68      Pobject_iter(), and Pobject_iter_resolved() functions return 0.
  69      Otherwise, if there was an internal error then -1 is returned.
  70      Otherwise, if the callback function func returns non-zero, then its
  71      return value will be returned instead.
  72 
  73 INTERFACE STABILITY
  74      Uncommitted
  75 
  76 MT-LEVEL
  77      See LOCKING in libproc(3LIB).
  78 
  79 SEE ALSO
  80      libproc(3LIB), proc(4)
  81 
  82 illumos                          May 11, 2016                          illumos