home *** CD-ROM | disk | FTP | other *** search
/ IRIX Base Documentation 2001 May / SGI IRIX Base Documentation 2001 May.iso / usr / share / catman / p_man / cat4 / proc.z / proc
Encoding:
Text File  |  2001-04-17  |  90.2 KB  |  1,651 lines

  1.  
  2.  
  3.  
  4. pppprrrroooocccc((((4444))))                                                                pppprrrroooocccc((((4444))))
  5.  
  6.  
  7.  
  8. NNNNAAAAMMMMEEEE
  9.      proc - process (debug) filesystem
  10.  
  11. SSSSYYYYNNNNOOOOPPPPSSSSIIIISSSS
  12.      ####iiiinnnncccclllluuuuddddeeee <<<<ssssyyyyssss////pppprrrrooooccccffffssss....hhhh>>>>
  13.  
  14. DDDDEEEESSSSCCCCRRRRIIIIPPPPTTTTIIIIOOOONNNN
  15.      /_p_r_o_c is a filesystem that provides access to the image of each active
  16.      process in the system.  This was historically mounted as /_d_e_b_u_g.  /_p_r_o_c
  17.      does not consume any disk resources.  This interface provides a richer
  18.      set of functionality and replaces the now obsolete _d_b_g(4), _d_e_b_u_g(4)
  19.      interface.  The "files" of this filesystem are of the form /_p_r_o_c/_n_n_n_n_n
  20.      and /_p_r_o_c/_p_i_n_f_o/_n_n_n_n_n, where _n_n_n_n_n is a decimal number corresponding to
  21.      the process-ID.  These files actually consume no disk space, and are only
  22.      convenient handles by which a debugger can attach to a process.  The
  23.      owner of each ``file'' is determined by the process's user-ID.  Files of
  24.      the form /_p_r_o_c/_n_n_n_n_n have permission mode 0600 while files of the form
  25.      /_p_r_o_c/_p_i_n_f_o/_n_n_n_n_n have permission mode 0444.  The /_p_r_o_c/_p_i_n_f_o files are
  26.      intended for use by unprivileged programs that wish to access
  27.      miscellaneous process information such as that provided by _p_s(1) and
  28.      _t_o_p(1).
  29.  
  30.      The _s_t_a_t_f_s(2) system call will return valid information concerning the
  31.      pppprrrroooocccc filesystem.  The total and free blocks as reported by _d_f(1)
  32.      respectively represent the total virtual memory (real memory plus swap
  33.      space) available and currently free.
  34.  
  35.      Standard system call interfaces are used to access /_p_r_o_c files:  _o_p_e_n(2),
  36.      _c_l_o_s_e(2), _r_e_a_d(2), _w_r_i_t_e(2), and _i_o_c_t_l(2).  Note that _r_e_a_d(2) and
  37.      _w_r_i_t_e(2) are not allowed for /_p_r_o_c/_p_i_n_f_o files.  Furthermore only the
  38.      PPPPIIIIOOOOCCCCAAAACCCCIIIINNNNFFFFOOOO, PPPPIIIIOOOOCCCCPPPPSSSSIIIINNNNFFFFOOOO, PPPPIIIIOOOOCCCCUUUUSSSSAAAAGGGGEEEE, PPPPIIIIOOOOCCCCGGGGEEEETTTTPPPPTTTTIIIIMMMMEEEERRRR and PPPPIIIIOOOOCCCCCCCCRRRREEEEDDDD commands
  39.      may be specified to _i_o_c_t_l(2) for /_p_r_o_c/_p_i_n_f_o files.  An open for reading
  40.      and writing enables process control; a read-only open allows inspection
  41.      but not control.  As with ordinary files, more than one process can open
  42.      the same /_p_r_o_c file at the same time.  _E_x_c_l_u_s_i_v_e _o_p_e_n is provided to
  43.      allow controlling processes to avoid collisions:  an _o_p_e_n(2) for writing
  44.      that specifies O_EXCL fails if the file is already open for writing; if
  45.      such an exclusive open succeeds, subsequent attempts to open the file for
  46.      writing, with or without the O_EXCL flag, fail until the exclusively-
  47.      opened file descriptor is closed.  (Exception: a superuser _o_p_e_n(2) that
  48.      does not specify O_EXCL succeeds even if the file is exclusively opened.)
  49.      There can be any number of read-only opens, even when an exclusive write
  50.      open is in effect on the file.  On a successful open the inherit-on-fork
  51.      (PR_FORK) and run-on-last-close (PR_RLC) flags are set by default, if no
  52.      other process has the file open.  On the last close for writing, if the
  53.      kill-on-last-close (PR_KLC) or the PR_RLC flags are set, then all the
  54.      controlling flags are cleared and either a SIGKILL is sent to the process
  55.      or the process is set running again.  If neither of the above two flags
  56.      are set, the controlling flags are not cleared.
  57.  
  58.  
  59.  
  60.  
  61.  
  62.  
  63.                                                                         PPPPaaaaggggeeee 1111
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70. pppprrrroooocccc((((4444))))                                                                pppprrrroooocccc((((4444))))
  71.  
  72.  
  73.  
  74.      Data may be transferred from or to any locations in the traced process's
  75.      address space by applying _l_s_e_e_k(2) to position the file at the virtual
  76.      address of interest followed by _r_e_a_d(2) or _w_r_i_t_e(2).  The PIOCMAP
  77.      operation can be applied to determine the accessible areas (mappings) of
  78.      the address space.  A contiguous area of the address space may appear as
  79.      multiple mappings due to varying read/write/execute permissions.  I/O
  80.      transfers may span contiguous mappings.  An I/O request extending into an
  81.      unmapped area is truncated at the boundary.
  82.  
  83.      Information and control operations are provided through _i_o_c_t_l(2).  These
  84.      have the form:
  85.  
  86.           #include <sys/types.h>
  87.           #include <sys/signal.h>
  88.           #include <sys/fault.h>
  89.           #include <sys/syscall.h>
  90.           #include <sys/procfs.h>
  91.           void *p;
  92.           retval = ioctl(fildes, code, p);
  93.  
  94.      The argument _p is a generic pointer whose type depends on the specific
  95.      _i_o_c_t_l code.  Where not specifically mentioned below, its value should be
  96.      zero.  <_s_y_s/_p_r_o_c_f_s._h> contains definitions of _i_o_c_t_l codes and data
  97.      structures used by the operations.
  98.  
  99.      Process information and control operations involve the use of sets of
  100.      flags.  The set types ssssiiiiggggsssseeeetttt____tttt, ffffllllttttsssseeeetttt____tttt, and ssssyyyysssssssseeeetttt____tttt correspond,
  101.      respectively, to signal, fault, and system call enumerations defined in
  102.      <_s_y_s/_s_i_g_n_a_l._h>, <_s_y_s/_f_a_u_l_t._h>, and <_s_y_s/_s_y_s_c_a_l_l._h>.  Each set type is
  103.      large enough to hold flags for its own enumeration.  Although they are of
  104.      different sizes, they have a common structure and can be manipulated by
  105.      these macros:
  106.  
  107.           prfillset(&set);              /* turn on all flags in set */
  108.           premptyset(&set);             /* turn off all flags in set */
  109.           praddset(&set, flag);         /* turn on the specified flag */
  110.           prdelset(&set, flag);         /* turn off the specified flag */
  111.           r = prismember(&set, flag);   /* != 0 iff flag is turned on */
  112.  
  113.  
  114.      One of pppprrrrffffiiiillllllllsssseeeetttt() or pppprrrreeeemmmmppppttttyyyysssseeeetttt() must be used to initialize sssseeeetttt before
  115.      it is used in any other operation.  ffffllllaaaagggg must be a member of the
  116.      enumeration corresponding to sssseeeetttt.
  117.  
  118. IIIIOOOOCCCCTTTTLLLL CCCCOOOODDDDEEEESSSS
  119.      The allowable _i_o_c_t_l codes follow.  Certain of these can be used only if
  120.      the process file descriptor is open for writing; these include all
  121.      operations that affect process control.  Those requiring write access are
  122.      marked with an asterisk (*).  Except where noted, an _i_o_c_t_l to a process
  123.      that has terminated elicits the error ENOENT.
  124.  
  125.  
  126.  
  127.  
  128.  
  129.                                                                         PPPPaaaaggggeeee 2222
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136. pppprrrroooocccc((((4444))))                                                                pppprrrroooocccc((((4444))))
  137.  
  138.  
  139.  
  140.    PPPPIIIIOOOOCCCCSSSSTTTTAAAATTTTUUUUSSSS
  141.      PIOCSTATUS returns status information for the process; _p is a pointer to
  142.      a pppprrrrssssttttaaaattttuuuussss structure containing at least the following fields:
  143.  
  144.           typedef struct prstatus {
  145.                long pr_flags;           /* Flags */
  146.                short     pr_why;        /* Reason for stop (if stopped) */
  147.                short     pr_what;       /* More detailed reason */
  148.                short     pr_cursig;     /* Current signal */
  149.                sigset_t  pr_sigpend;    /* Set of pending signals */
  150.                sigset_t  pr_sighold;    /* Set of held signals */
  151.                struct siginfo pr_info;  /* Info associated with signal/fault */
  152.                struct sigaltstack pr_altstack; /* Alternate signal stack info */
  153.                struct sigaction pr_action;/* Signal action for current signal */
  154.                short     pr_syscall;    /* System call # (if in syscall) */
  155.                short     pr_nsysarg;    /* # of arguments to this syscall */
  156.                long pr_errno;           /* Error number from system call */
  157.                long pr_rval1;           /* System call return value 1 */
  158.                long pr_rval2;           /* System call return value 2 */
  159.                long pr_sysarg[PRSYSARGS];    /* Arguments to this syscall */
  160.                pid_t     pr_pid;        /* Process id */
  161.                pid_t     pr_ppid;       /* Parent process id */
  162.                pid_t     pr_pgrp;       /* Process group id */
  163.                pid_t     pr_sid;        /* Session id */
  164.                timespec_t     pr_utime; /* Process user cpu time */
  165.                timespec_t     pr_stime; /* Process system cpu time */
  166.                timespec_t     pr_cutime; /* Sum of children's user times */
  167.                timespec_t     pr_cstime; /* Sum of children's system times */
  168.                char pr_clname[8];       /* Scheduling class name */
  169.                long pr_instr;           /* Current instruction */
  170.                gregset_t pr_reg;        /* General registers */
  171.           } prstatus_t;
  172.  
  173.      pppprrrr____ffffllllaaaaggggssss is a bit-mask holding these flags:
  174.  
  175.           PPPPRRRR____SSSSTTTTOOOOPPPPPPPPEEEEDDDD      Process is stopped
  176.  
  177.           PPPPRRRR____IIIISSSSTTTTOOOOPPPP        Process is stopped on an event of interest (see
  178.                           PIOCSTOP).
  179.  
  180.           PPPPRRRR____DDDDSSSSTTTTOOOOPPPP        Process has a stop directive in effect (see
  181.                           PIOCSTOP).
  182.  
  183.           PPPPRRRR____SSSSTTTTEEEEPPPP         Process has a single-step directive in effect (see
  184.                           PIOCRUN).
  185.  
  186.           PPPPRRRR____AAAASSSSLLLLEEEEEEEEPPPP       Process is in an interruptible sleep within a system
  187.                           call.
  188.  
  189.           PPPPRRRR____PPPPCCCCIIIINNNNVVVVAAAALLLL      Process's current instruction (pppprrrr____iiiinnnnssssttttrrrr) is
  190.                           undefined.
  191.  
  192.  
  193.  
  194.  
  195.                                                                         PPPPaaaaggggeeee 3333
  196.  
  197.  
  198.  
  199.  
  200.  
  201.  
  202. pppprrrroooocccc((((4444))))                                                                pppprrrroooocccc((((4444))))
  203.  
  204.  
  205.  
  206.           PPPPRRRR____IIIISSSSSSSSYYYYSSSS        Process is a system process (see PIOCSTOP).
  207.  
  208.           PPPPRRRR____FFFFOOOORRRRKKKK         Process has its inherit-on-fork flag set (see
  209.                           PIOCSET).
  210.  
  211.           PPPPRRRR____RRRRLLLLCCCC          Process has its run-on-last-close flag set (see
  212.                           PIOCSET).
  213.  
  214.           PPPPRRRR____KKKKLLLLCCCC          Process has its kill-on-last-close flag set (see
  215.                           PIOCSET).
  216.  
  217.           PPPPRRRR____PPPPTTTTRRRRAAAACCCCEEEE       Process is being traced via _p_t_r_a_c_e(2).
  218.  
  219.      pppprrrr____wwwwhhhhyyyy and pppprrrr____wwwwhhhhaaaatttt together describe, for a stopped process, the reason
  220.      that the process is stopped.  Possible values of pppprrrr____wwwwhhhhyyyy are:
  221.  
  222.           PPPPRRRR____RRRREEEEQQQQUUUUEEEESSSSTTTTEEEEDDDD    The stop occurred in response to a stop directive,
  223.                           normally because PIOCSTOP was applied.  pppprrrr____wwwwhhhhaaaatttt is
  224.                           unused in this case.
  225.  
  226.           PPPPRRRR____SSSSIIIIGGGGNNNNAAAALLLLLLLLEEEEDDDD    The process stopped on receipt of a signal (see
  227.                           PIOCSTRACE); pppprrrr____wwwwhhhhaaaatttt holds the signal number that
  228.                           caused the stop (for a newly-stopped process, the
  229.                           same value is in pppprrrr____ccccuuuurrrrssssiiiigggg).
  230.  
  231.           PPPPRRRR____FFFFAAAAUUUULLLLTTTTEEEEDDDD      The process stopped on incurring a hardware fault
  232.                           (see PIOCSFAULT); pppprrrr____wwwwhhhhaaaatttt holds the fault number
  233.                           that caused the stop.
  234.  
  235.           PPPPRRRR____SSSSYYYYSSSSEEEENNNNTTTTRRRRYYYY and PPPPRRRR____SSSSYYYYSSSSEEEEXXXXIIIITTTT
  236.                           A stop on entry to or exit from a system call (see
  237.                           PIOCSENTRY and PIOCSEXIT); pppprrrr____wwwwhhhhaaaatttt holds the system
  238.                           call number.
  239.  
  240.           PPPPRRRR____JJJJOOOOBBBBCCCCOOOONNNNTTTTRRRROOOOLLLL   The process stopped due to the default action of a
  241.                           job control stop signal (see _s_i_g_a_c_t_i_o_n(2)); pppprrrr____wwwwhhhhaaaatttt
  242.                           holds the stopping signal number.
  243.  
  244.      pppprrrr____ccccuuuurrrrssssiiiigggg names the current signal, that is, the next signal to be
  245.      delivered to the process.  pppprrrr____ssssiiiiggggppppeeeennnndddd identifies any other signals
  246.      pending for the process.  pppprrrr____ssssiiiigggghhhhoooolllldddd identifies those signals whose
  247.      delivery is being delayed if sent to the process.
  248.  
  249.      pppprrrr____iiiinnnnffffoooo, when the process is in a PR_SIGNALLED or PR_FAULTED stop,
  250.      contains additional information pertinent to the particular signal or
  251.      fault (see <_s_y_s/_s_i_g_i_n_f_o._h>).
  252.  
  253.      pppprrrr____aaaallllttttssssttttaaaacccckkkk contains the alternate signal stack information for the
  254.      process (see _s_i_g_a_l_t_s_t_a_c_k(2)).  pppprrrr____aaaaccccttttiiiioooonnnn contains the signal action
  255.      information pertaining to the current signal (see _s_i_g_a_c_t_i_o_n(2)); it is
  256.      undefined if pppprrrr____ccccuuuurrrrssssiiiigggg is zero.
  257.  
  258.  
  259.  
  260.  
  261.                                                                         PPPPaaaaggggeeee 4444
  262.  
  263.  
  264.  
  265.  
  266.  
  267.  
  268. pppprrrroooocccc((((4444))))                                                                pppprrrroooocccc((((4444))))
  269.  
  270.  
  271.  
  272.      pppprrrr____ssssyyyyssssccccaaaallllllll is the number of the system call, if any, being executed by
  273.      the traced process; it is non-zero if the process is stopped on
  274.      PR_SYSENTRY or PR_SYSEXIT, is asleep within a system call (PR_ASLEEP is
  275.      set), or is stopped on a watchpoint trap incurred within a system call
  276.      (see PIOCSWATCH).  If pppprrrr____ssssyyyyssssccccaaaallllllll is non-zero, pppprrrr____nnnnssssyyyyssssaaaarrrrgggg is the number of
  277.      arguments to the system call and the pppprrrr____ssssyyyyssssaaaarrrrgggg array contains the actual
  278.      arguments; pppprrrr____eeeerrrrrrrrnnnnoooo contains the value of eeeerrrrrrrrnnnnoooo returned at the last
  279.      system call; and pppprrrr____rrrrvvvvaaaallll1111 and pppprrrr____rrrrvvvvaaaallll2222 contain the return values from the
  280.      last system call.
  281.  
  282.      pppprrrr____ppppiiiidddd, pppprrrr____ppppppppiiiidddd, pppprrrr____ppppggggrrrrpppp, and pppprrrr____ssssiiiidddd are, respectively, the process id,
  283.      the id of the process's parent, the process's process group id, and the
  284.      process's session id.
  285.  
  286.      pppprrrr____uuuuttttiiiimmmmeeee, pppprrrr____ssssttttiiiimmmmeeee, pppprrrr____ccccuuuuttttiiiimmmmeeee, and pppprrrr____ccccssssttttiiiimmmmeeee are, respectively, the user
  287.      CPU and system CPU time consumed by the process, and the cumulative user
  288.      CPU and system CPU time consumed by the process's children, in seconds
  289.      and nanoseconds.
  290.  
  291.      pppprrrr____ccccllllnnnnaaaammmmeeee contains the name of the process's scheduling class.
  292.  
  293.      pppprrrr____iiiinnnnssssttttrrrr contains the machine instruction to which the program counter
  294.      refers.  The amount of data retrieved from the process is machine-
  295.      dependent; on SGI machines, it is a 32-bit word.  In general, the size is
  296.      that of the machine's smallest instruction.  If PR_PCINVAL is set,
  297.      pppprrrr____iiiinnnnssssttttrrrr is undefined; this occurs whenever the process is not stopped or
  298.      when the program counter refers to an invalid address.
  299.  
  300.      pppprrrr____rrrreeeegggg is an array holding the contents of the general registers for a
  301.      stopped process.  For SGI machines the structure ggggrrrreeeeggggsssseeeetttt____tttt is defined in
  302.      <_s_y_s/_u_c_o_n_t_e_x_t._h>.  If the process is not stopped, register values are
  303.      undefined.
  304.  
  305.    ****PPPPIIIIOOOOCCCCSSSSTTTTOOOOPPPP PPPPIIIIOOOOCCCCWWWWSSSSTTTTOOOOPPPP
  306.      PIOCSTOP directs the process to stop and waits until it has stopped;
  307.      PIOCWSTOP simply waits for the process to stop.  These operations
  308.      complete when the process stops on an event of interest, immediately if
  309.      already so stopped.  If _p is non-zero it points to an instance of
  310.      pppprrrrssssttttaaaattttuuuussss____tttt to be filled with status information for the stopped process.
  311.  
  312.      An ``event of interest'' is either a PR_REQUESTED stop or a stop that has
  313.      been specified in the process's tracing flags (set by PIOCSTRACE,
  314.      PIOCSFAULT, PIOCSENTRY, and PIOCSEXIT).  A PR_JOBCONTROL stop is
  315.      specifically not an event of interest.  (A process may stop twice due to
  316.      a stop signal, first showing PR_SIGNALLED if the signal is traced and
  317.      again showing PR_JOBCONTROL if the process is set running without
  318.      clearing the signal.)  If the process is controlled by _p_t_r_a_c_e(2), it
  319.      comes to a PR_SIGNALLED stop on receipt of any signal; this is an event
  320.      of interest only if the signal is in the traced signal set.  If PIOCSTOP
  321.      is applied to a process that is stopped, but not on an event of interest,
  322.      the stop directive takes effect when the process is restarted by the
  323.      competing mechanism; at that time the process enters a PR_REQUESTED stop
  324.  
  325.  
  326.  
  327.                                                                         PPPPaaaaggggeeee 5555
  328.  
  329.  
  330.  
  331.  
  332.  
  333.  
  334. pppprrrroooocccc((((4444))))                                                                pppprrrroooocccc((((4444))))
  335.  
  336.  
  337.  
  338.      before executing any user-level code.
  339.  
  340.      _i_o_c_t_l()s are interruptible by signals so that, for example, an _a_l_a_r_m(2)
  341.      can be set to avoid waiting forever for a process that may never stop on
  342.      an event of interest.  If PIOCSTOP is interrupted, the stop directive
  343.      remains in effect even though the _i_o_c_t_l() returns an error.
  344.  
  345.      A system process (indicated by the PR_ISSYS flag) never executes at user
  346.      level, has no user-level address space visible through /_p_r_o_c, and cannot
  347.      be stopped.  Applying PIOCSTOP or PIOCWSTOP to a system process elicits
  348.      the error EBUSY.
  349.  
  350.    ****PPPPIIIIOOOOCCCCRRRRUUUUNNNN
  351.      The traced process is made runnable again after a stop.  If _p is non-zero
  352.      it points to a pppprrrrrrrruuuunnnn structure describing additional actions to be
  353.      performed.  The pppprrrrrrrruuuunnnn structure contains at least the following fields:
  354.  
  355.           typedef struct prrun {
  356.                long      pr_flags;      /* Flags */
  357.                sigset_t  pr_trace;      /* Set of signals to be traced */
  358.                sigset_t  pr_sighold;    /* Set of signals to be held */
  359.                fltset_t  pr_fault;      /* Set of faults to be traced */
  360.                caddr_t   pr_vaddr;      /* Virtual address at which to resume */
  361.           } prrun_t;
  362.  
  363.      pppprrrr____ffffllllaaaaggggssss is a bit-mask describing optional actions; the remainder of the
  364.      entries are meaningful only if the appropriate bits are set in pppprrrr____ffffllllaaaaggggssss.
  365.      Flag definitions:
  366.  
  367.           PPPPRRRRCCCCSSSSIIIIGGGG          Clears the current signal, if any (see PIOCSSIG).
  368.  
  369.           PPPPRRRRCCCCFFFFAAAAUUUULLLLTTTT        Clears the current fault, if any (see PIOCCFAULT).
  370.  
  371.           PPPPRRRRSSSSTTTTRRRRAAAACCCCEEEE        Sets the traced signal set to pppprrrr____ttttrrrraaaacccceeee (see
  372.                           PIOCSTRACE).
  373.  
  374.           PPPPRRRRSSSSHHHHOOOOLLLLDDDD         Sets the held signal set to pppprrrr____ssssiiiigggghhhhoooolllldddd (see
  375.                           PIOCSHOLD).
  376.  
  377.           PPPPRRRRSSSSFFFFAAAAUUUULLLLTTTT        Sets the traced fault set to pppprrrr____ffffaaaauuuulllltttt (see
  378.                           PIOCSFAULT).
  379.  
  380.           PPPPRRRRSSSSVVVVAAAADDDDDDDDRRRR        Sets the address at which execution resumes to
  381.                           pppprrrr____vvvvaaaaddddddddrrrr.
  382.  
  383.           PPPPRRRRSSSSTTTTEEEEPPPP          Directs the process to single-step, that is, to run
  384.                           and to execute a single machine instruction.  On
  385.                           completion of the instruction, a trace trap occurs.
  386.                           If FLTTRACE is being traced, the process stops,
  387.                           otherwise it is sent SIGTRAP; if SIGTRAP is being
  388.                           traced and not held, the process stops.  This
  389.                           operation requires hardware and operating system
  390.  
  391.  
  392.  
  393.                                                                         PPPPaaaaggggeeee 6666
  394.  
  395.  
  396.  
  397.  
  398.  
  399.  
  400. pppprrrroooocccc((((4444))))                                                                pppprrrroooocccc((((4444))))
  401.  
  402.  
  403.  
  404.                           support and may not be implemented on all
  405.                           processors.  It is implemented on SGI machines.
  406.  
  407.           PPPPRRRRCCCCSSSSTTTTEEEEPPPP         Cancels any outstanding single-step directive and
  408.                           any PPPPRRRRSSSSTTTTEEEEPPPP directive set in the current request.
  409.  
  410.           PPPPRRRRSSSSAAAABBBBOOOORRRRTTTT        Meaningful only if the process is in a PR_SYSENTRY
  411.                           stop or is marked PR_ASLEEP; it instructs the
  412.                           process to abort execution of the system call (see
  413.                           PIOCSENTRY, PIOCSEXIT).
  414.  
  415.           PPPPRRRRSSSSTTTTOOOOPPPP          Directs the process to stop again as soon as
  416.                           possible after resuming execution (see PIOCSTOP).
  417.                           In particular if the process is stopped on
  418.                           PR_SIGNALLED or PR_FAULTED, the next stop will show
  419.                           PR_REQUESTED, no other stop will have intervened,
  420.                           and the process will not have executed any user-
  421.                           level code.
  422.  
  423.           PIOCRUN fails (EBUSY) if applied to a process that is not stopped on
  424.           an event of interest.  Once PIOCRUN has been applied, the process is
  425.           no longer stopped on an event of interest even if, due to a
  426.           competing mechanism, it remains stopped.
  427.  
  428.    ****PPPPIIIIOOOOCCCCSSSSTTTTRRRRAAAACCCCEEEE
  429.      This defines a set of signals to be traced:  the receipt of one of these
  430.      signals causes the traced process to stop.  The set of signals is defined
  431.      via an instance of ssssiiiiggggsssseeeetttt____tttt addressed by _p.  Receipt of SIGKILL cannot be
  432.      traced.
  433.  
  434.      If a signal that is included in the held signal set is sent to the traced
  435.      process, the signal is not received and does not cause a process stop
  436.      until it is removed from the held signal set, either by the process
  437.      itself or by setting the held signal set with PIOCSHOLD or the PRSHOLD
  438.      option of PIOCRUN.
  439.  
  440.    PPPPIIIIOOOOCCCCGGGGTTTTRRRRAAAACCCCEEEE
  441.      The current traced signal set is returned in an instance of ssssiiiiggggsssseeeetttt____tttt
  442.      addressed by _p.
  443.  
  444.    ****PPPPIIIIOOOOCCCCSSSSSSSSIIIIGGGG
  445.      The current signal and its associated signal information are set
  446.      according to the contents of the ssssiiiiggggiiiinnnnffffoooo structure addressed by _p (see
  447.      <_s_y_s/_s_i_g_i_n_f_o._h>).  If the specified signal number is zero or if _p is
  448.      zero, the current signal is cleared.  Setting the current signal to
  449.      SIGKILL terminates the process immediately, even if it is stopped.  All
  450.      other signals will be sent after the process is made runnable, if it is
  451.      currently stopped.
  452.  
  453.    ****PPPPIIIIOOOOCCCCKKKKIIIILLLLLLLL
  454.      A signal is sent to the process with semantics identical to those of
  455.      _k_i_l_l(2).  _p points to an _i_n_t naming the signal.  Sending SIGKILL
  456.  
  457.  
  458.  
  459.                                                                         PPPPaaaaggggeeee 7777
  460.  
  461.  
  462.  
  463.  
  464.  
  465.  
  466. pppprrrroooocccc((((4444))))                                                                pppprrrroooocccc((((4444))))
  467.  
  468.  
  469.  
  470.      terminates the process immediately.
  471.  
  472.    ****PPPPIIIIOOOOCCCCUUUUNNNNKKKKIIIILLLLLLLL
  473.      A signal is deleted, that is, it is removed from the set of pending
  474.      signals.  The current signal (if any) is unaffected.  _p points to an _i_n_t
  475.      naming the signal.  It is an error to attempt to delete SIGKILL.
  476.  
  477.    PPPPIIIIOOOOCCCCGGGGHHHHOOOOLLLLDDDD ****PPPPIIIIOOOOCCCCSSSSHHHHOOOOLLLLDDDD
  478.      PIOCGHOLD returns the set of held signals (signals whose delivery will be
  479.      delayed if sent to the process) in an instance of ssssiiiiggggsssseeeetttt____tttt addressed by
  480.      _p.  PIOCSHOLD correspondingly sets the held signal set but does not allow
  481.      SIGKILL or SIGSTOP to be held.
  482.  
  483.    PPPPIIIIOOOOCCCCMMMMAAAAXXXXSSSSIIIIGGGG PPPPIIIIOOOOCCCCAAAACCCCTTTTIIIIOOOONNNN
  484.      These operations provide information about the signal actions associated
  485.      with the traced process (see _s_i_g_a_c_t_i_o_n(2)).  PIOCMAXSIG returns, in the
  486.      _i_n_t addressed by _p, the maximum signal number understood by the system.
  487.      This can be used to allocate storage for use with the PIOCACTION
  488.      operation, which returns the traced process's signal actions in an array
  489.      of ssssiiiiggggaaaaccccttttiiiioooonnnn structures addressed by _p.  Signal numbers are displaced by
  490.      1 from array indices, so that the action for signal number _n appears in
  491.      position _n-1 of the array.
  492.  
  493.    ****PPPPIIIIOOOOCCCCSSSSFFFFAAAAUUUULLLLTTTT
  494.      This defines a set of hardware faults to be traced:  on incurring one of
  495.      these faults the traced process stops.  The set is defined via an
  496.      instance of ffffllllttttsssseeeetttt____tttt addressed by _p.  Fault names are defined in
  497.      <_s_y_s/_f_a_u_l_t._h> and include the following.  Some of these may not occur on
  498.      all processors; there may be processor-specific faults in addition to
  499.      these.
  500.  
  501.           FFFFLLLLTTTTIIIILLLLLLLL          illegal instruction
  502.           FFFFLLLLTTTTPPPPRRRRIIIIVVVV         privileged instruction
  503.           FFFFLLLLTTTTBBBBPPPPTTTT          breakpoint trap
  504.           FFFFLLLLTTTTTTTTRRRRAAAACCCCEEEE        trace trap
  505.           FFFFLLLLTTTTWWWWAAAATTTTCCCCHHHH        watchpoint trap
  506.           FFFFLLLLTTTTKKKKWWWWAAAATTTTCCCCHHHH       kernel watchpoint trap
  507.           FFFFLLLLTTTTAAAACCCCCCCCEEEESSSSSSSS       memory access fault
  508.           FFFFLLLLTTTTBBBBOOOOUUUUNNNNDDDDSSSS       memory bounds violation
  509.           FFFFLLLLTTTTIIIIOOOOVVVVFFFF         integer overflow
  510.           FFFFLLLLTTTTIIIIZZZZDDDDIIIIVVVV        integer zero divide
  511.           FFFFLLLLTTTTFFFFPPPPEEEE          floating-point exception
  512.           FFFFLLLLTTTTSSSSTTTTAAAACCCCKKKK        unrecoverable stack fault
  513.           FFFFLLLLTTTTPPPPAAAAGGGGEEEE         recoverable page fault
  514.  
  515.      When not traced, a fault normally results in the posting of a signal to
  516.      the process that incurred the fault.  If the process stops on a fault,
  517.      the signal is posted to the process when execution is resumed unless the
  518.      fault is cleared by PIOCCFAULT or by the PRCFAULT option of PIOCRUN.
  519.      FLTPAGE and FLTKWATCH are exceptions; no signal is posted.  There may be
  520.      additional processor-specific faults like this.  pppprrrr____iiiinnnnffffoooo in the pppprrrrssssttttaaaattttuuuussss
  521.      structure identifies the signal to be sent and contains machine-specific
  522.  
  523.  
  524.  
  525.                                                                         PPPPaaaaggggeeee 8888
  526.  
  527.  
  528.  
  529.  
  530.  
  531.  
  532. pppprrrroooocccc((((4444))))                                                                pppprrrroooocccc((((4444))))
  533.  
  534.  
  535.  
  536.      information about the fault.
  537.  
  538.    PPPPIIIIOOOOCCCCGGGGFFFFAAAAUUUULLLLTTTT
  539.      The current traced fault set is returned in an instance of ffffllllttttsssseeeetttt____tttt
  540.      addressed by _p.
  541.  
  542.    ****PPPPIIIIOOOOCCCCCCCCFFFFAAAAUUUULLLLTTTT
  543.      The current fault (if any) is cleared; the associated signal is not sent
  544.      to the process.
  545.  
  546.    ****PPPPIIIIOOOOCCCCSSSSEEEENNNNTTTTRRRRYYYY ****PPPPIIIIOOOOCCCCSSSSEEEEXXXXIIIITTTT
  547.      These operations instruct the process to stop on entry to or exit from
  548.      specified system calls.  The set of system calls to be traced is defined
  549.      via an instance of ssssyyyysssssssseeeetttt____tttt addressed by _p.
  550.  
  551.      When entry to a system call is being traced, the traced process stops
  552.      after having begun the call to the system but before the system call
  553.      arguments have been fetched from the process.  When exit from a system
  554.      call is being traced, the traced process stops on completion of the
  555.      system call just prior to checking for signals and returning to user
  556.      level.  At this point all return values have been stored into the traced
  557.      process's registers.
  558.  
  559.      If the traced process is stopped on entry to a system call (PR_SYSENTRY)
  560.      or when sleeping in an interruptible system call (PR_ASLEEP is set), it
  561.      may be instructed to go directly to system call exit by specifying the
  562.      PRSABORT flag in a PIOCRUN request.  Unless exit from the system call is
  563.      being traced the process returns to user level showing error EINTR.
  564.  
  565.    PPPPIIIIOOOOCCCCGGGGEEEENNNNTTTTRRRRYYYY PPPPIIIIOOOOCCCCGGGGEEEEXXXXIIIITTTT
  566.      These return the current traced system call entry or exit set in an
  567.      instance of ssssyyyysssssssseeeetttt____tttt addressed by _p.
  568.  
  569.    PPPPIIIIOOOOCCCCNNNNWWWWAAAATTTTCCCCHHHH
  570.      PIOCNWATCH returns, in the _i_n_t addressed by _p, the number of watched
  571.      areas supported by the system.  This can be used to allocate storage for
  572.      use with the PIOCSWATCH and PIOCGWATCH operations, each of which must
  573.      provide an array whose number of elements equals the supported number of
  574.      watched areas.
  575.  
  576.    ****PPPPIIIIOOOOCCCCSSSSWWWWAAAATTTTCCCCHHHH
  577.      PIOCSWATCH establishes or clears a set of watched areas in the traced
  578.      process; _p points to pppprrrrwwwwaaaattttcccchhhh structure containing at least the following
  579.      fields:
  580.  
  581.           typedef struct prwatch {
  582.                caddr_t   pr_vaddr; /* Virtual address of watched area */
  583.                u_long    pr_size;  /* Size of watched area in bytes */
  584.                long pr_wflags;     /* Watch type flags */
  585.           } prwatch_t;
  586.  
  587.      pppprrrr____vvvvaaaaddddddddrrrr specifies the virtual address of an area of memory to be watched
  588.  
  589.  
  590.  
  591.                                                                         PPPPaaaaggggeeee 9999
  592.  
  593.  
  594.  
  595.  
  596.  
  597.  
  598. pppprrrroooocccc((((4444))))                                                                pppprrrroooocccc((((4444))))
  599.  
  600.  
  601.  
  602.      in the traced process.  pppprrrr____ssssiiiizzzzeeee specifies the size of the area, in bytes.
  603.      pppprrrr____wwwwffffllllaaaaggggssss specifies the type of memory access to be monitored as a bit-
  604.      mask of one or more of the following flags (see also PIOCMAP):
  605.  
  606.           MMMMAAAA____RRRREEEEAAAADDDD         read access
  607.           MMMMAAAA____WWWWRRRRIIIITTTTEEEE        write access
  608.           MMMMAAAA____EEEEXXXXEEEECCCC         execution access
  609.  
  610.      An entry with a zero value for pppprrrr____ssssiiiizzzzeeee clears any previously-established
  611.      watched area starting at the specified virtual address.  An entry with a
  612.      non-empty pppprrrr____wwwwffffllllaaaaggggssss bit-mask establishes a watched area for the virtual
  613.      address range specified by pppprrrr____vvvvaaaaddddddddrrrr and pppprrrr____ssssiiiizzzzeeee.  An entry with an empty
  614.      pppprrrr____wwwwffffllllaaaaggggssss bit-mask is ignored.
  615.  
  616.      A watchpoint is triggered when the traced process makes a memory
  617.      reference that covers at least one byte of a watched area and the memory
  618.      reference is a mode of interest as specified in pppprrrr____wwwwffffllllaaaaggggssss.  When a
  619.      watchpoint is triggered, the process incurs a watchpoint trap.  If
  620.      FLTWATCH is being traced, the process stops; otherwise it is sent
  621.      SIGTRAP; if SIGTRAP is being traced and not held, the process stops.  If
  622.      the access is a write access, the memory is not modified.  If the process
  623.      stops, its program counter refers to the instruction that triggered the
  624.      watchpoint.  pppprrrr____iiiinnnnffffoooo in the pppprrrrssssttttaaaattttuuuussss structure contains information
  625.      pertinent to the watchpoint trap.  In particular, the ssssiiii____aaaaddddddddrrrr field
  626.      contains the virtual address of the memory reference that triggered the
  627.      watchpoint and the ssssiiii____ccccooooddddeeee field contains one of MMMMAAAA____RRRREEEEAAAADDDD, MMMMAAAA____WWWWRRRRIIIITTTTEEEE, or
  628.      MMMMAAAA____EEEEXXXXEEEECCCC, indicating read, write or execute access, respectively.
  629.  
  630.      A watchpoint may be triggered while executing a system call that makes
  631.      reference to the traced process's memory.  Such a system call completes
  632.      normally; a kernel watchpoint fault is taken after the system call
  633.      completes but before the process returns to user level.  If more than one
  634.      watchpoint would be triggered by the system call, the first one
  635.      encountered is the one reported.
  636.  
  637.      PIOCSWATCH fails with EINVAL if an attempt is made to specify overlapping
  638.      watched areas or to specify a watchpoint whose virtual address range
  639.      includes invalid virtual addresses in the traced process.  PIOCSWATCH
  640.      fails with E2BIG if an attempt is made to establish more than the
  641.      supported number of watched areas and with ESRCH if an attempt is made to
  642.      delete a non-existent watchpoint.  An attempt to delete watchpoints on a
  643.      running process could result in failure with errno set to EBUSY.  This is
  644.      a temporary condition that occurs when the kernel is stepping over a
  645.      watchpoint and a later subsequent attempt should succeed.  This does not
  646.      happen if the process is stopped.
  647.  
  648.      Access to a process's memory through /_p_r_o_c will not trigger a watchpoint,
  649.      even if the access is from the process itself (which must have opened its
  650.      own /_p_r_o_c entry).
  651.  
  652.  
  653.  
  654.  
  655.  
  656.  
  657.                                                                        PPPPaaaaggggeeee 11110000
  658.  
  659.  
  660.  
  661.  
  662.  
  663.  
  664. pppprrrroooocccc((((4444))))                                                                pppprrrroooocccc((((4444))))
  665.  
  666.  
  667.  
  668.    PPPPIIIIOOOOCCCCGGGGWWWWAAAATTTTCCCCHHHH
  669.      PIOCGWATCH returns, in the array of pppprrrrwwwwaaaattttcccchhhh structures addressed by _p,
  670.      the set of watched areas currently in effect.  Elements beyond the number
  671.      of actually established watched areas are filled with zeros.
  672.  
  673.    ****PPPPIIIIOOOOCCCCSSSSEEEETTTT ****PPPPIIIIOOOOCCCCRRRREEEESSSSEEEETTTT
  674.      PIOCSET sets one or more modes of operation for the traced process.
  675.      PIOCRESET resets these modes.  The modes to be set or reset are specified
  676.      by flags in a _l_o_n_g addressed by _p:
  677.  
  678.           PPPPRRRR____FFFFOOOORRRRKKKK         (inherit-on-fork)  When set, the process's tracing
  679.                           flags are inherited by the child of a _f_o_r_k(2).  When
  680.                           reset, child processes start with all tracing flags
  681.                           cleared.
  682.  
  683.           PPPPRRRR____RRRRLLLLCCCC          (run-on-last-close)  When set and the last writable
  684.                           /_p_r_o_c file descriptor referring to the traced
  685.                           process is closed, all of the process's tracing
  686.                           flags are cleared, any outstanding stop directive is
  687.                           canceled, and if the process is stopped, it is set
  688.                           running as though PIOCRUN had been applied to it.
  689.                           When reset, the process's tracing flags are retained
  690.                           and the process is not set running on last close.
  691.  
  692.           PPPPRRRR____KKKKLLLLCCCC          (kill-on-last-close)  When set and the last writable
  693.                           /_p_r_o_c file descriptor referring to the traced
  694.                           process is closed, the process is terminated with
  695.                           SIGKILL.
  696.  
  697.      It is an error (EINVAL) to specify flags other than those described above
  698.      or to apply these operations to a system process.  The current modes are
  699.      reported in the pppprrrrssssttttaaaattttuuuussss structure (see PIOCSTATUS).
  700.  
  701.      Note that a processes using /_p_r_o_c can not assume any default settings for
  702.      these flags, as some other process may have attached to the target
  703.      earlier and reset the flags and then detached.
  704.  
  705.    PPPPIIIIOOOOCCCCGGGGRRRREEEEGGGG ****PPPPIIIIOOOOCCCCSSSSRRRREEEEGGGG
  706.      These operations respectively get and set the process general registers
  707.      into or out of an array addressed by _p; the array has type ggggrrrreeeeggggsssseeeetttt____tttt.
  708.      Register contents are accessible using a set of predefined indices (see
  709.      PIOCSTATUS).  No bits of the processor-status register (PSR) or other
  710.      privileged registers can be modified by PIOCSREG.
  711.  
  712.      PIOCSREG fails (EBUSY) if applied to a process that is not stopped on an
  713.      event of interest.  If the process is not stopped, the register values
  714.      returned by PIOCGREG are undefined.
  715.  
  716.    PPPPIIIIOOOOCCCCGGGGFFFFPPPPRRRREEEEGGGG ****PPPPIIIIOOOOCCCCSSSSFFFFPPPPRRRREEEEGGGG
  717.      These operations respectively get and set the process floating-point
  718.      registers into or out of a structure addressed by _p; the structure has
  719.      type ffffpppprrrreeeeggggsssseeeetttt____tttt.  An error (EINVAL) is returned if there is no floating-
  720.  
  721.  
  722.  
  723.                                                                        PPPPaaaaggggeeee 11111111
  724.  
  725.  
  726.  
  727.  
  728.  
  729.  
  730. pppprrrroooocccc((((4444))))                                                                pppprrrroooocccc((((4444))))
  731.  
  732.  
  733.  
  734.      point hardware on the machine.  PIOCSFPREG fails (EBUSY) if applied to a
  735.      process that is not stopped on an event of interest.  If the process is
  736.      not stopped, the register values returned by PIOCGFPREG are undefined.
  737.  
  738.    ****PPPPIIIIOOOOCCCCNNNNIIIICCCCEEEE
  739.      The traced process's _n_i_c_e(2) priority is incremented by the amount
  740.      contained in the _i_n_t addressed by _p.  Only the superuser may better a
  741.      process's priority in this way, but any user may make the priority worse.
  742.  
  743.    PPPPIIIIOOOOCCCCPPPPSSSSIIIINNNNFFFFOOOO
  744.      This returns miscellaneous process information such as that reported by
  745.      _p_s(1).  _p is a pointer to a pppprrrrppppssssiiiinnnnffffoooo structure containing at least the
  746.      following fields:
  747.  
  748.           typedef struct prpsinfo {
  749.                char pr_state; /* numeric process state (see pr_sname) */
  750.                char pr_sname; /* printable character representing pr_state */
  751.                char pr_zomb;  /* !=0: process terminated but not waited for */
  752.                char pr_nice;  /* nice for cpu usage */
  753.                u_long pr_flag;     /* process flags */
  754.                uid_t pr_uid;  /* real user id */
  755.                gid_t pr_gid;  /* real group id */
  756.                pid_t pr_pid;  /* unique process id */
  757.                pid_t pr_ppid; /* process id of parent */
  758.                pid_t pr_pgrp; /* pid of process group leader */
  759.                pid_t pr_sid;  /* session id */
  760.                caddr_t pr_addr;    /* physical address of process */
  761.                long pr_size;  /* size of process image in pages */
  762.                long pr_rssize;     /* resident set size in pages */
  763.                long pr_pagesize;   /* system page size, in bytes */
  764.                caddr_t pr_wchan;   /* wait addr for sleeping process */
  765.                timespec_t pr_start;     /* process start time, sec+nsec since epoch */
  766.                timespec_t pr_time; /* usr+sys cpu time for this process */
  767.                long pr_pri;        /* priority, high value is high priority */
  768.                char pr_oldpri;     /* pre-SVR4, low value is high priority */
  769.                char pr_cpu;        /* pre-SVR4, cpu usage for scheduling */
  770.                dev_t pr_ttydev;   /* controlling tty device (PRNODEV if none) */
  771.                char pr_clname[8];       /* Scheduling class name */
  772.                char pr_fname[PRCOMSIZ]; /* last component of exec()ed pathname */
  773.                char pr_psargs[PRARGSZ]; /* initial characters of arg list */
  774.                u_int pr_pset;      /* associated processor set name */
  775.                cpuid_t pr_sonproc; /* processor running on */
  776.                timespec_t pr_ctime;     /* usr+sys cpu time for all children */
  777.           } prpsinfo_t;
  778.  
  779.      Some of the entries in pppprrrrppppssssiiiinnnnffffoooo, such as pppprrrr____ssssttttaaaatttteeee and pppprrrr____ffffllllaaaagggg, are
  780.      system-specific and should not be expected to retain their meanings
  781.      across different versions of the operating system.  pppprrrr____aaaaddddddddrrrr is a vestige
  782.      of the past and has no real meaning in current systems.
  783.  
  784.  
  785.  
  786.  
  787.  
  788.  
  789.                                                                        PPPPaaaaggggeeee 11112222
  790.  
  791.  
  792.  
  793.  
  794.  
  795.  
  796. pppprrrroooocccc((((4444))))                                                                pppprrrroooocccc((((4444))))
  797.  
  798.  
  799.  
  800.      PIOCPSINFO can be applied to a _z_o_m_b_i_e process (one that has terminated
  801.      but whose parent has not yet performed a _w_a_i_t(2) on it).
  802.  
  803.    PPPPIIIIOOOOCCCCNNNNMMMMAAAAPPPP PPPPIIIIOOOOCCCCMMMMAAAAPPPP
  804.      These operations provide information about the memory mappings (virtual
  805.      address ranges) associated with the traced process.  PIOCNMAP returns, in
  806.      the _i_n_t addressed by _p, the number of mappings that are currently active.
  807.      The PIOCMAP operation may be used to obtain the list of currently active
  808.      mappings, which is an array of structures of type pppprrrrmmmmaaaapppp____tttt.  The PIOCNMAP
  809.      may be used to determine the minimum amount of storage that needs to be
  810.      allocated to receive these structures, but the programmer should not
  811.      assume that it is the maximum amount needed.  If the PIOCNMAP and PIOCMAP
  812.      calls are made on a process that is not stopped, the number of maps could
  813.      change between the two ioctl calls and caller could fault if too few maps
  814.      were allocated to hold the results of PIOCMAP.  Note: for a better
  815.      interface, see PIOCMAP_SGI below.  For PIOCMAP, _p addresses an array of
  816.      elements of type pppprrrrmmmmaaaapppp____tttt; one array element (one structure) is returned
  817.      for each mapping, plus an additional element containing all zeros to mark
  818.      the end of the list.  The pppprrrrmmmmaaaapppp structure contains at least the following
  819.      fields:
  820.  
  821.           typedef struct prmap {
  822.                caddr_t pr_vaddr;   /* Virtual address */
  823.                u_long    pr_size;  /* Size of mapping in bytes */
  824.                off_t     pr_off;   /* Offset into mapped object, if any */
  825.                long pr_mflags;     /* Protection and attribute flags */
  826.           } prmap_t;
  827.  
  828.      pppprrrr____vvvvaaaaddddddddrrrr is the virtual address of the mapping within the traced process
  829.      and pppprrrr____ssssiiiizzzzeeee is its size in bytes.  pppprrrr____ooooffffffff is the offset within the mapped
  830.      object (if any) to which the virtual address is mapped.
  831.  
  832.      pppprrrr____mmmmffffllllaaaaggggssss is a bit-mask of protection and attribute flags:
  833.  
  834.           MMMMAAAA____RRRREEEEAAAADDDD         mapping is readable by the traced process
  835.           MMMMAAAA____WWWWRRRRIIIITTTTEEEE        mapping is writable by the traced process
  836.           MMMMAAAA____EEEEXXXXEEEECCCC         mapping is executable by the traced process
  837.           MMMMAAAA____SSSSHHHHAAAARRRREEEEDDDD       mapping changes are shared by the mapped object
  838.           MMMMAAAA____BBBBRRRREEEEAAAAKKKK        mapping is grown by the _b_r_k(2) system call
  839.           MMMMAAAA____SSSSTTTTAAAACCCCKKKK        mapping is grown automatically on stack faults
  840.           MMMMAAAA____PPPPHHHHYYYYSSSS         mapping corresponds to a physical device mapping
  841.  
  842.    PPPPIIIIOOOOCCCCMMMMAAAAPPPP____SSSSGGGGIIII
  843.      This operation provides detailed information about the memory mappings
  844.      (virtual address ranges) associated with the traced process.  In effect
  845.      it performs both a PIOCNMAP and a PIOCMAP call (with additional
  846.      information) with one ioctl.  The PIOCMAP_SGI operation may be used to
  847.      obtain the list of currently active mappings, which is an array of
  848.      structures of type pppprrrrmmmmaaaapppp____ssssggggiiii____tttt.  The user must preallocate an array of
  849.      the maximum number of mapping structures they are willing to receive.
  850.      One array element (one structure) is returned for each mapping, plus an
  851.      additional element containing all zeros that also marks the end of the
  852.  
  853.  
  854.  
  855.                                                                        PPPPaaaaggggeeee 11113333
  856.  
  857.  
  858.  
  859.  
  860.  
  861.  
  862. pppprrrroooocccc((((4444))))                                                                pppprrrroooocccc((((4444))))
  863.  
  864.  
  865.  
  866.      list.  There is an upper limit to the number of memory mappings that can
  867.      be returned by this call, which is defined as PRMAPMAX in the procfs.h
  868.      header file. Attempts to request more than the PRMAPMAX number of
  869.      mappings results in only PRMAPMAX mappings returned.  PIOCMAP_SGI returns
  870.      either -1 or the number of mappings that are currently active.
  871.  
  872.      For PIOCMAP_SGI, _p addresses a pointer to a structure called
  873.      pppprrrrmmmmaaaapppp____ssssggggiiii____aaaarrrrgggg____tttt.  It contains the following fields:
  874.  
  875.           typedef struct prmap_sgi_arg {
  876.                caddr_t pr_vaddr;   /* Base of map buffer */
  877.                ulong_t pr_size;    /* Size of buffer in bytes */
  878.           } prmap_sgi_arg_t;
  879.  
  880.      pppprrrr____vvvvaaaaddddddddrrrr is the virtual address of the buffer to hold the mappings for
  881.      the traced process and pppprrrr____ssssiiiizzzzeeee is its size in bytes.  The pppprrrrmmmmaaaapppp____ssssggggiiii____tttt
  882.      structure contains at least the following fields:
  883.  
  884.           typedef struct prmap_sgi {
  885.                caddr_t pr_vaddr;   /* Virtual base address */
  886.                ulong_t pr_size;    /* Size of mapping in bytes */
  887.                off_t     pr_off;   /* Offset into mapped object, if any */
  888.                ulong_t pr_mflags;  /* Protection and attribute flags */
  889.                pgno_t    pr_vsize; /* # valid pages in this segment */
  890.                pgno_t    pr_psize; /* # private pages in this segment */
  891.                pgno_t    pr_wsize; /* Cost for this proc weighted base 256 */
  892.                pgno_t    pr_rsize; /* # referenced pages in this segment */
  893.                pgno_t    pr_msize; /* # modified pages in this segment */
  894.                dev_t     pr_dev;   /* Device # of segment iff mapped */
  895.                ino_t     pr_ino;   /* Inode # of segment iff mapped */
  896.           } prmap_sgi_t;
  897.  
  898.      pppprrrr____vvvvaaaaddddddddrrrr is the virtual address of the mapping within the traced process
  899.      and pppprrrr____ssssiiiizzzzeeee is its size in bytes.  pppprrrr____ooooffffffff is the offset within the mapped
  900.      object (if any) to which the virtual address is mapped.  pppprrrr____vvvvssssiiiizzzzeeee,
  901.      pppprrrr____ppppssssiiiizzzzeeee, pppprrrr____wwwwssssiiiizzzzeeee, pppprrrr____rrrrssssiiiizzzzeeee, pppprrrr____mmmmssssiiiizzzzeeee are page counts for the virtual
  902.      mapping.  pppprrrr____ddddeeeevvvv and pppprrrr____ddddeeeevvvv identify the filesystem resident object from
  903.      which the mapping originates (if one exists).
  904.  
  905.      pppprrrr____mmmmffffllllaaaaggggssss is a bit-mask of protection and attribute flags:
  906.  
  907.           MMMMAAAA____RRRREEEEAAAADDDD         mapping is readable by the traced process
  908.           MMMMAAAA____WWWWRRRRIIIITTTTEEEE        mapping is writable by the traced process
  909.           MMMMAAAA____EEEEXXXXEEEECCCC         mapping is executable by the traced process
  910.           MMMMAAAA____SSSSHHHHAAAARRRREEEEDDDD       mapping changes are shared by the mapped object
  911.           MMMMAAAA____BBBBRRRREEEEAAAAKKKK        mapping is grown by the _b_r_k(2) system call
  912.           MMMMAAAA____SSSSTTTTAAAACCCCKKKK        mapping is grown automatically on stack faults
  913.           MMMMAAAA____PPPPHHHHYYYYSSSS         mapping corresponds to a physical device mapping
  914.           MMMMAAAA____PPPPRRRRIIIIMMMMAAAARRRRYYYY      mapping is one of the processes core segments
  915.           MMMMAAAA____CCCCOOOOWWWW          mapping corresponds to a copy on write segment
  916.  
  917.  
  918.  
  919.  
  920.  
  921.                                                                        PPPPaaaaggggeeee 11114444
  922.  
  923.  
  924.  
  925.  
  926.  
  927.  
  928. pppprrrroooocccc((((4444))))                                                                pppprrrroooocccc((((4444))))
  929.  
  930.  
  931.  
  932.           MMMMAAAA____NNNNOOOOTTTTCCCCAAAACCCCHHHHEEEEDDDD    mapped address segment is not cached
  933.           MMMMAAAA____SSSSHHHHMMMMEEEEMMMM        mapping corresponds to a shared memory mapping
  934.           MMMMAAAA____RRRREEEEFFFFCCCCNNNNTTTT____SSSSHHHHIIIIFFFFTTTT amount to shift right mflags to get reference count
  935.  
  936.    PPPPIIIIOOOOCCCCPPPPGGGGDDDD____SSSSGGGGIIII
  937.      This operation provides information about the interior of a memory
  938.      mappings (virtual address ranges) associated with the traced process.
  939.      The PIOCPGD_SGI operation is be used to obtain the list of page
  940.      descriptors, which is an array of structures of type ppppggggdddd____tttt.  The
  941.      PIOCMAP_SGI ioctl may be used to determine the amount of storage that
  942.      needs to be allocated to receive these structures.  For PIOCPGD_SGI, _p
  943.      addresses a pointer to a pppprrrrppppggggdddd____ssssggggiiii____tttt structure that contains an array of
  944.      elements of type pppprrrrppppggggdddd____tttt.  The ppppggggdddd____tttt structure contains at least the
  945.      following fields:
  946.  
  947.           typedef struct pgd {     /* per-page data */
  948.                short pr_flags;     /* flags */
  949.                short pr_value;     /* page count/fault offset */
  950.           } pgd_t;
  951.  
  952.      The pppprrrrppppggggdddd____ssssggggiiii____tttt structure contains at least the following fields:
  953.  
  954.           typedef struct prpgd_sgi {
  955.                caddr_t pr_vaddr;   /* virtual base address of region to stat */
  956.                pgno_t    pr_pglen; /* number of pages in data list... */
  957.                pgd_t     pr_data[1]; /* variable length array of page flags */
  958.           } prpgd_sgi_t;
  959.  
  960.      pppprrrr____vvvvaaaaddddddddrrrr is the virtual address of the mapping within the traced process
  961.      and pppprrrr____ppppgggglllleeeennnn is length of the pppprrrr____ddddaaaattttaaaa array.
  962.  
  963.      The pppprrrr____ffffllllaaaaggggssss field for each page contains the following flags:
  964.  
  965.           PPPPGGGGFFFF____RRRREEEEFFFFEEEERRRREEEENNNNCCCCEEEEDDDD  page is currently valid in system page table
  966.           PPPPGGGGFFFF____GGGGLLLLOOOOBBBBAAAALLLL      page is marked global in system page table
  967.           PPPPGGGGFFFF____WWWWRRRRIIIITTTTEEEEAAAABBBBLLLLEEEE   page is currently writeable in system page table
  968.           PPPPGGGGFFFF____NNNNOOOOTTTTCCCCAAAACCCCHHHHEEEEDDDD   page is marked non-cacheable in system page table
  969.           PPPPGGGGFFFF____IIIISSSSVVVVAAAALLLLIIIIDDDD     page is marked valid for this process
  970.           PPPPGGGGFFFF____IIIISSSSDDDDIIIIRRRRTTTTYYYY     page is marked dirty for this process
  971.           PPPPGGGGFFFF____PPPPRRRRIIIIVVVVAAAATTTTEEEE     page is marked private to this process
  972.           PPPPGGGGFFFF____FFFFAAAAUUUULLLLTTTT       the pr_value field contains a fault offset
  973.           PPPPGGGGFFFF____UUUUSSSSRRRRHHHHIIIISSSSTTTTOOOORRRRYYYY  accumulating history flag for caller
  974.           PPPPGGGGFFFF____RRRREEEEFFFFHHHHIIIISSSSTTTTOOOORRRRYYYY  page has been marked referenced
  975.           PPPPGGGGFFFF____WWWWRRRRTTTTHHHHIIIISSSSTTTTOOOORRRRYYYY  page has been marked dirty
  976.           PPPPGGGGFFFF____VVVVAAAALLLLHHHHIIIISSSSTTTTOOOORRRRYYYY  page has been marked valid
  977.           PPPPGGGGFFFF____CCCCLLLLEEEEAAAARRRR       clear valid & writeable bits in page table
  978.  
  979.      The pppprrrr____vvvvaaaalllluuuueeee field for each page contains either a reference count or a
  980.      fault offset value if the PPPPGGGGFFFF____CCCCLLLLEEEEAAAARRRR operation was set on a previous call.
  981.      This can be used to determine what function or variable inside a page
  982.      that the process references or writes frequently.
  983.  
  984.  
  985.  
  986.  
  987.                                                                        PPPPaaaaggggeeee 11115555
  988.  
  989.  
  990.  
  991.  
  992.  
  993.  
  994. pppprrrroooocccc((((4444))))                                                                pppprrrroooocccc((((4444))))
  995.  
  996.  
  997.  
  998.    PPPPIIIIOOOOCCCCOOOOPPPPEEEENNNNMMMM
  999.      The return value _r_e_t_v_a_l provides a read-only file descriptor for a mapped
  1000.      object associated with the traced process.  If _p is zero the traced
  1001.      process's _e_x_e_c(2)ed file is found.  This enables a debugger to find the
  1002.      object file symbol table without having to know the pathname of the
  1003.      executable file.  If _p is non-zero it points to a ccccaaaaddddddddrrrr____tttt containing a
  1004.      virtual address within the traced process and the mapped object, if any,
  1005.      associated with that address is found; this can be used to get a file
  1006.      descriptor for a shared library that is attached to the process.  On
  1007.      error (invalid address, physical device mapping, or no mapped object for
  1008.      the designated address), -1 is returned and errno is set to EINVAL.
  1009.  
  1010.    PPPPIIIIOOOOCCCCCCCCRRRREEEEDDDD
  1011.      Fetch the set of credentials associated with the process.  _p points to an
  1012.      instance of pppprrrrccccrrrreeeedddd____tttt that is filled by the operation.  The pppprrrrccccrrrreeeedddd
  1013.      structure contains at least the following fields:
  1014.  
  1015.           typedef struct prcred {
  1016.                uid_t     pr_euid;       /* Effective user id */
  1017.                uid_t     pr_ruid;       /* Real user id */
  1018.                uid_t     pr_suid;       /* Saved user id (from exec) */
  1019.                gid_t     pr_egid;       /* Effective group id */
  1020.                gid_t     pr_rgid;       /* Real group id */
  1021.                gid_t     pr_sgid;       /* Saved group id (from exec) */
  1022.                u_int     pr_ngroups;    /* Number of supplementary groups */
  1023.           } prcred_t;
  1024.  
  1025.  
  1026.    PPPPIIIIOOOOCCCCGGGGRRRROOOOUUUUPPPPSSSS
  1027.      Fetch the set of supplementary group IDs associated with the process.  _p
  1028.      points to an array of elements of type ggggiiiidddd____tttt, that will be filled by the
  1029.      operation.  PIOCCRED can be applied beforehand to determine the number of
  1030.      groups (pppprrrr____nnnnggggrrrroooouuuuppppssss) that will be returned and the amount of storage that
  1031.      should be allocated to hold them.
  1032.  
  1033.    PPPPIIIIOOOOCCCCTTTTLLLLBBBBMMMMIIIISSSSSSSS
  1034.      Enable special user TLB handling.  The TLB is a hardware coprocessor that
  1035.      makes virtual-to-physical address translations.  _p points to an integer
  1036.      that specifies the handling desired.  If the value is TTTTLLLLBBBB____CCCCOOOOUUUUNNNNTTTT, a record
  1037.      will be kept of every virtual-address TLB refill that occurs while the
  1038.      process mapped by _f_i_l_d_e_s is running.  If the value is TTTTLLLLBBBB____SSSSTTTTDDDD, counting
  1039.      will be disabled (the default mode).  It is important to note that
  1040.      monitoring TLB efficiency can be a useful tool, but the performance of
  1041.      the code that refills the TLB will be degraded.
  1042.  
  1043.      The TLB refill counts can be obtained by PPPPIIIIOOOOCCCCUUUUSSSSAAAAGGGGEEEE.  The ssssttttrrrruuuucccctttt pppprrrruuuussssaaaaggggeeee
  1044.      field ppppuuuu____uuuuttttllllbbbb accounts for TLB refills that occurred while the process
  1045.      was running in user mode, and the field ppppuuuu____kkkkttttllllbbbb accounts for refills that
  1046.      occurred while executing system calls on behalf of the user or while
  1047.      handling hardware interrupt code while the user process was scheduled.
  1048.  
  1049.  
  1050.  
  1051.  
  1052.  
  1053.                                                                        PPPPaaaaggggeeee 11116666
  1054.  
  1055.  
  1056.  
  1057.  
  1058.  
  1059.  
  1060. pppprrrroooocccc((((4444))))                                                                pppprrrroooocccc((((4444))))
  1061.  
  1062.  
  1063.  
  1064.    PPPPIIIIOOOOCCCCUUUUSSSSAAAAGGGGEEEE
  1065.      PIOCUSAGE returns process usage information.  _p points to a pppprrrruuuussssaaaaggggeeee
  1066.      structure that is filled by the operation.  The fields in a pppprrrruuuussssaaaaggggeeee
  1067.      structure are implementation dependent; no application can assume
  1068.      portability in this area.  See <_s_y_s/_p_r_o_c_f_s._h> for the exact definition
  1069.      for a particular implementation.
  1070.  
  1071.      The SGI implementation supports the following fields:
  1072.  
  1073.           typedef struct prusage {
  1074.                timespec_t  pu_tstamp;   /* time stamp */
  1075.                timespec_t  pu_starttime;     /* process start time */
  1076.                timespec_t  pu_utime;    /* user CPU time */
  1077.                timespec_t  pu_stime;    /* system CPU time */
  1078.                u_long    pu_minf;       /* minor (mapping) page faults */
  1079.                u_long    pu_majf;       /* major (disk) page faults */
  1080.                u_long    pu_utlb;       /* user TLB misses */
  1081.                u_long    pu_nswap;      /* number of swaps */
  1082.                u_long    pu_gbread;     /* gigabytes ... */
  1083.                u_long    pu_bread;      /*         and bytes read */
  1084.                u_long    pu_gbwrit;     /* gigabytes ... */
  1085.                u_long    pu_bwrit;      /*         and bytes written */
  1086.                u_long    pu_sigs;       /* signals received */
  1087.                u_long    pu_vctx;       /* voluntary context switches */
  1088.                u_long    pu_ictx;       /* involuntary context switches */
  1089.                u_long    pu_sysc;       /* system calls */
  1090.                u_long    pu_syscr;      /* read() system calls */
  1091.                u_long    pu_syscw;      /* write() system calls */
  1092.                u_long    pu_syscps;     /* poll() or select() system calls */
  1093.                u_long    pu_sysci;      /* ioctl() system calls */
  1094.                u_long    pu_graphfifo;  /* graphics pipeline stalls */
  1095.                u_long    pu_graph_req[8];    /* graphics resource requests */
  1096.                u_long    pu_graph_wait[8];   /* graphics resource waits */
  1097.                u_long    pu_size;       /* size of swappable image in pages */
  1098.                u_long    pu_rss;        /* resident size of swappable image */
  1099.                u_long    pu_inblock;    /* block input operations */
  1100.                u_long    pu_oublock;    /* block output operations */
  1101.                u_long    pu_vfault;     /* total number of vfaults */
  1102.                u_long    pu_ktlb;       /* kernel TLB misses */
  1103.           } prusage_t;
  1104.  
  1105.  
  1106.    PPPPIIIIOOOOCCCCGGGGEEEETTTTPPPPTTTTIIIIMMMMEEEERRRR
  1107.      PIOCGETPTIMER returns an array of timers indicating the amount of time
  1108.      the process has spent in each of the following states:
  1109.  
  1110.           #include <time.h>
  1111.           #include <sys/timers.h>
  1112.  
  1113.           struct timespec ptime[MAX_PROCTIMER];
  1114.  
  1115.  
  1116.  
  1117.  
  1118.  
  1119.                                                                        PPPPaaaaggggeeee 11117777
  1120.  
  1121.  
  1122.  
  1123.  
  1124.  
  1125.  
  1126. pppprrrroooocccc((((4444))))                                                                pppprrrroooocccc((((4444))))
  1127.  
  1128.  
  1129.  
  1130.           AAAASSSS____UUUUSSSSRRRR____RRRRUUUUNNNN      running in user mode
  1131.           AAAASSSS____SSSSYYYYSSSS____RRRRUUUUNNNN      running in system mode
  1132.           AAAASSSS____IIIINNNNTTTT____RRRRUUUUNNNN      running in interrupt mode
  1133.           AAAASSSS____BBBBIIIIOOOO____WWWWAAAAIIIITTTT     waiting for block I/O
  1134.           AAAASSSS____MMMMEEEEMMMM____WWWWAAAAIIIITTTT     waiting for memory
  1135.           AAAASSSS____SSSSEEEELLLLEEEECCCCTTTT____WWWWAAAAIIIITTTT  waiting in select
  1136.           AAAASSSS____JJJJCCCCLLLL____WWWWAAAAIIIITTTT     stopped because of job control
  1137.           AAAASSSS____RRRRUUUUNNNNQQQQ____WWWWAAAAIIIITTTT    waiting to run on run queue
  1138.           AAAASSSS____SSSSLLLLEEEEEEEEPPPP____WWWWAAAAIIIITTTT   waiting for resource
  1139.           AAAASSSS____SSSSTTTTRRRRMMMMOOOONNNN____WWWWAAAAIIIITTTT  waiting for the stream monitor
  1140.           AAAASSSS____PPPPHHHHYYYYSSSSIIIIOOOO____WWWWAAAAIIIITTTT  waiting for raw I/O
  1141.  
  1142.      _p is a pointer to an array of MMMMAAAAXXXX____PPPPRRRROOOOCCCCTTTTIIIIMMMMEEEERRRR ttttiiiimmmmeeeessssppppeeeecccc structures.
  1143.  
  1144.    PPPPIIIIOOOOCCCCOOOOPPPPEEEENNNNPPPPDDDD
  1145.      PIOCOPENPD is not currently implemented on SGI machines.  It is under
  1146.      consideration for future releases.
  1147.  
  1148.      The return value _r_e_t_v_a_l provides a read-only file descriptor for a ``page
  1149.      data file'', enabling tracking of address space references and
  1150.      modifications on a per-page basis.
  1151.  
  1152.      A _r_e_a_d(2) of the page data file descriptor returns structured page data
  1153.      and atomically clears the page data maintained for the file by the
  1154.      system.  That is to say, each read returns data collected since the last
  1155.      read; the first read returns data collected since the file was opened.
  1156.      When the call completes, the read buffer contains the following structure
  1157.      as its header and thereafter contains a number of variable length
  1158.      structures that must be accessed by walking linearly through the buffer.
  1159.  
  1160.           typedef struct prpageheader {
  1161.                timespec_t tstamp;  /* real time time stamp */
  1162.                u_long    nmap;     /* number of address space mappings */
  1163.                u_long    npage;    /* total number of pages */
  1164.           } prpageheader_t;
  1165.  
  1166.      The header is followed by nnnnmmmmaaaapppp variable-length pppprrrraaaassssmmmmaaaapppp structures:
  1167.  
  1168.           typedef struct prasmap {
  1169.                caddr_t   vaddr;    /* virtual address */
  1170.                u_long    npage;    /* number of pages in mapping */
  1171.                u_char    data[1];  /* referenced, modified, present flags */
  1172.           } prasmap_t;
  1173.  
  1174.      The ddddaaaattttaaaa[[[[]]]] array is of variable length, with one entry for each page in
  1175.      the mapping, nnnnppppaaaaggggeeee entries altogether, rounded up with empty entries at
  1176.      the end so that the structure size is an integral numbers of long's.
  1177.      ddddaaaattttaaaa[[[[]]]] entries may contain these flags:
  1178.  
  1179.           PPPPGGGG____PPPPRRRREEEESSSSEEEENNNNTTTT      page is resident in memory now
  1180.  
  1181.  
  1182.  
  1183.  
  1184.  
  1185.                                                                        PPPPaaaaggggeeee 11118888
  1186.  
  1187.  
  1188.  
  1189.  
  1190.  
  1191.  
  1192. pppprrrroooocccc((((4444))))                                                                pppprrrroooocccc((((4444))))
  1193.  
  1194.  
  1195.  
  1196.           PPPPGGGG____RRRREEEEFFFFEEEERRRREEEENNNNCCCCEEEEDDDD   page has been referenced since last read
  1197.           PPPPGGGG____MMMMOOOODDDDIIIIFFFFIIIIEEEEDDDD     page has been modified since last read
  1198.  
  1199.      If the read buffer is not large enough to contain all of the page data,
  1200.      the read fails with E2BIG and the page data is not cleared.  The required
  1201.      size of the read buffer can be determined through _f_s_t_a_t(2).  Application
  1202.      of _l_s_e_e_k(2) to the page data file descriptor is ineffective.  Closing the
  1203.      page data file terminates the system overhead associated with collecting
  1204.      the data.
  1205.  
  1206.    PPPPIIIIOOOOCCCCGGGGEEEETTTTPPPPRRRR PPPPIIIIOOOOCCCCGGGGEEEETTTTUUUU
  1207.      These operations copy, respectively, the traced process's _p_r_o_c structure
  1208.      and _u_s_e_r _a_r_e_a into the buffer addressed by _p.  They are provided for
  1209.      completeness but it should be unnecessary to access either of these
  1210.      structures directly since relevant status information is available
  1211.      through other control operations.  Their use is discouraged because a
  1212.      program making use of them is tied to a particular version of the
  1213.      operating system.
  1214.  
  1215.      PIOCGETPR can be applied to a _z_o_m_b_i_e process (see PIOCPSINFO).
  1216.  
  1217.    PPPPIIIIOOOOCCCCAAAACCCCIIIINNNNFFFFOOOO
  1218.      PIOCACINFO returns the currently accumulated accounting information for
  1219.      the process.  _p points to a pppprrrraaaacccciiiinnnnffffoooo structure that is filled in by the
  1220.      operation.  The fields in pppprrrraaaacccciiiinnnnffffoooo are implementation dependent; no
  1221.      application can assume portability in this area.  See <_s_y_s/_p_r_o_c_f_s._h> and
  1222.      <_s_y_s/_e_x_t_a_c_c_t._h> for the exact definition of a particular implementation.
  1223.  
  1224.      The SGI implementation supports the following fields:
  1225.  
  1226.           typedef struct pracinfo {
  1227.                char      pr_version;    /* Accounting data version */
  1228.                char      pr_flag;       /* Miscellaneous flags */
  1229.                char      pr_nice;       /* Nice value */
  1230.                unchar    pr_sched;      /* Scheduling discipline */
  1231.                                         /* (see sys/schedctl.h) */
  1232.                __int32_t pr_spare1;     /* reserved */
  1233.                ash_t     pr_ash;        /* Array session handle */
  1234.                prid_t    pr_prid;       /* Project ID */
  1235.                time_t    pr_btime;      /* Begin time (in secs since 1970)*/
  1236.                time_t    pr_etime;      /* Elapsed time (in HZ) */
  1237.                __int32_t pr_spare2[2];  /* reserved */
  1238.                struct acct_timers  pr_timers; /* Assorted timers: see extacct.h */
  1239.                struct acct_counts  pr_counts; /* Assorted counters: (ditto) */
  1240.                __int64_t pr_spare3[8];  /* reserved */
  1241.           } pracinfo_t;
  1242.  
  1243.  
  1244.    PPPPIIIIOOOOCCCCGGGGEEEETTTTSSSSNNNN0000EEEEXXXXTTTTRRRREEEEFFFFCCCCNNNNTTTTRRRRSSSS PPPPIIIIOOOOCCCCGGGGEEEETTTTSSSSNNNN0000RRRREEEEFFFFCCCCNNNNTTTTRRRRSSSS
  1245.      PIOCGETSN0EXTREFCNTRS returns the extended memory reference counter
  1246.      values in an Origin system for a specified virtual address space range.
  1247.      See refcnt(5).
  1248.  
  1249.  
  1250.  
  1251.                                                                        PPPPaaaaggggeeee 11119999
  1252.  
  1253.  
  1254.  
  1255.  
  1256.  
  1257.  
  1258. pppprrrroooocccc((((4444))))                                                                pppprrrroooocccc((((4444))))
  1259.  
  1260.  
  1261.  
  1262.      The third argument is used to specify the virtual address space range and
  1263.      the user buffer where to store the counter values. This argument is of
  1264.      type sn0_refcnt_args_t, as defined in <sys/SN/hwcntrs.h>:
  1265.  
  1266.           typedef struct sn0_refcnt_args {
  1267.                   caddr_t             vaddr;
  1268.                   long                len;
  1269.                   sn0_refcnt_buf_t*   buf;
  1270.           } sn0_refcnt_args_t;
  1271.  
  1272.  
  1273.      The first field vvvvaaaaddddddddrrrr is the base of the virtual address space range, the
  1274.      field lllleeeennnn is the corresponding length in bytes, and the field bbbbuuuuffff is a
  1275.      pointer to a user buffer where the system will store the counter values
  1276.      and additional information. This buffer is an array of elements of type
  1277.      sn0_refcnt_buf_t, where each element corresponds to the counter
  1278.      information associated with one hardware page:
  1279.  
  1280.           typedef struct sn0_refcnt_buf {
  1281.                sn0_refcnt_set_t   refcnt_set;
  1282.                __uint64_t         paddr;
  1283.                   __uint64_t         page_size;
  1284.                   cnodeid_t          cnodeid;
  1285.           } sn0_refcnt_buf_t;
  1286.  
  1287.  
  1288.      The field rrrreeeeffffccccnnnntttt____sssseeeetttt contains the set of counters associated with the
  1289.      virtual address passed via ssssnnnn0000____rrrreeeeffffccccnnnntttt____aaaarrrrggggssss, ppppaaaaddddddddrrrr is the address of the
  1290.      physical page associated with this virtual address, ppppaaaaggggeeee____ssssiiiizzzzeeee is the page
  1291.      size being used to map it, and ccccnnnnooooddddeeeeiiiidddd is the physical page home node,
  1292.      expressed in terms of _C_o_m_p_a_c_t _N_o_d_e _I_d_e_n_t_i_f_i_e_r_s which can be mapped back
  1293.      to node names using the command topology(1).  The rrrreeeeffffccccnnnntttt____sssseeeetttt type is
  1294.      defined by
  1295.  
  1296.           typedef struct sn0_refcnt_set {
  1297.                   refcnt_t    refcnt[SN0_REFCNT_MAX_COUNTERS];
  1298.                   __uint64_t  flags;
  1299.           } sn0_refcnt_set_t;
  1300.  
  1301.  
  1302.      The field rrrreeeeffffccccnnnntttt is the actual set of counters (one counter per node),
  1303.      and ffffllllaaaaggggssss is a state vector reserved for future use.  The counters in
  1304.      rrrreeeeffffccccnnnntttt are ordered according to the _C_o_m_p_a_c_t _N_o_d_e _I_d_e_n_t_i_f_i_e_r_s, also known
  1305.      as ccccnnnnooooddddeeeeiiiiddddssss (numa(5)).
  1306.  
  1307.  
  1308.      PIOCGETSN0REFCNTRS instructs the system to return the actual hardware
  1309.      counter values instead of the extended software counter values returned
  1310.      by PIOCGETSN0EXTREFCNTRS.
  1311.  
  1312.  
  1313.  
  1314.  
  1315.  
  1316.  
  1317.                                                                        PPPPaaaaggggeeee 22220000
  1318.  
  1319.  
  1320.  
  1321.  
  1322.  
  1323.  
  1324. pppprrrroooocccc((((4444))))                                                                pppprrrroooocccc((((4444))))
  1325.  
  1326.  
  1327.  
  1328.      The following section of code shows an example of use for this interface:
  1329.  
  1330.           #include <sys/types.h>
  1331.           #include <stdio.h>
  1332.           #include <malloc.h>
  1333.           #include <sys/stat.h>
  1334.           #include <fcntl.h>
  1335.           #include <sys/prctl.h>
  1336.           #include <procfs/procfs.h>
  1337.           #include <sys/syssgi.h>
  1338.           #include <sys/sysmp.h>
  1339.           #include <sys/SN/hwcntrs.h>
  1340.  
  1341.           /*
  1342.            * This routine makes two assumptions that may not
  1343.            * be true in all systems:
  1344.            * Length of hardware page (counter granularity): 0x1000 bytes
  1345.            * Length of base software page (smallest mappable memory area): 0x4000 bytes
  1346.            */
  1347.  
  1348.           void
  1349.           print_refcounters(char* vaddr, int len)
  1350.           {
  1351.                   pid_t pid = getpid();
  1352.                   char  pfile[256];
  1353.                   int fd;
  1354.                   sn0_refcnt_buf_t* refcnt_buffer;
  1355.                   sn0_refcnt_buf_t* direct_refcnt_buffer;
  1356.                   sn0_refcnt_args_t* refcnt_args;
  1357.                   int npages;
  1358.                   int gen_start;
  1359.                   int numnodes;
  1360.                   int page;
  1361.                   int node;
  1362.  
  1363.                   sprintf(pfile, "/proc/%05d", pid);
  1364.                   if ((fd = open(pfile, O_RDONLY)) < 0) {
  1365.                     fprintf(stderr,"Can't open /proc/%d", pid);
  1366.                     exit(1);
  1367.                }
  1368.  
  1369.                   vaddr = (char *)( (unsigned long)vaddr & ~0xfff );
  1370.                   npages = (len + 0xfff) >> 12;
  1371.  
  1372.                   if ((refcnt_buffer = malloc(sizeof(sn0_refcnt_buf_t) * npages)) == NULL) {
  1373.                           perror("malloc refcnt_buffer");
  1374.                           exit(1);
  1375.                   }
  1376.  
  1377.                   if ((direct_refcnt_buffer = malloc(sizeof(sn0_refcnt_buf_t) * npages)) == NULL) {
  1378.                           perror("malloc refcnt_buffer");
  1379.                           exit(1);
  1380.  
  1381.  
  1382.  
  1383.                                                                        PPPPaaaaggggeeee 22221111
  1384.  
  1385.  
  1386.  
  1387.  
  1388.  
  1389.  
  1390. pppprrrroooocccc((((4444))))                                                                pppprrrroooocccc((((4444))))
  1391.  
  1392.  
  1393.  
  1394.                   }
  1395.  
  1396.                   if ((refcnt_args = malloc(sizeof(sn0_refcnt_args_t))) == NULL) {
  1397.                           perror("malloc refcnt_args");
  1398.                           exit(1);
  1399.                   }
  1400.  
  1401.                   refcnt_args->vaddr = vaddr;
  1402.                   refcnt_args->len = len;
  1403.                   refcnt_args->buf = refcnt_buffer;
  1404.  
  1405.                   if ((gen_start = ioctl(fd, PIOCGETSN0EXTREFCNTRS, (void *)refcnt_args)) < 0) {
  1406.                     perror("ioctl  PIOCGETSN0EXTREFCNTRS returns error");
  1407.                     exit(1);
  1408.                }
  1409.  
  1410.                   refcnt_args->vaddr = vaddr;
  1411.                   refcnt_args->len = len;
  1412.                   refcnt_args->buf = direct_refcnt_buffer;
  1413.                   if ((gen_start = ioctl(fd, PIOCGETSN0REFCNTRS, (void *)refcnt_args)) < 0) {
  1414.                     perror("ioctl  PIOCGETSN0REFCNTRS returns error");
  1415.                     exit(1);
  1416.                }
  1417.  
  1418.                   if ((numnodes = sysmp(MP_NUMNODES)) < 0) {
  1419.                           perror("sysmp MP_NUMNODES");
  1420.                           exit(1);
  1421.                   }
  1422.  
  1423.                   for (page = 0; page < npages; page++) {
  1424.                           printf("page[%05d, 0x%lx, 0x%llx (0x%llx)]:",
  1425.                                  page,
  1426.                                  vaddr + page*0x1000,
  1427.                                  refcnt_buffer[page].paddr,
  1428.                                  refcnt_buffer[page].paddr >> 14);
  1429.                           for (node = 0; node < numnodes; node++) {
  1430.                                   printf(" %05lld (%06lld)",
  1431.                                          refcnt_buffer[page].refcnt_set.refcnt[node],
  1432.                                          direct_refcnt_buffer[page].refcnt_set.refcnt[node]);
  1433.                           }
  1434.                           printf("0);
  1435.                   }
  1436.  
  1437.                   close(fd);
  1438.                   free(refcnt_args);
  1439.                   free(refcnt_buffer);
  1440.           }
  1441.  
  1442.  
  1443.    PPPPIIIIOOOOCCCCGGGGEEEETTTTIIIINNNNOOOODDDDEEEE
  1444.      PIOCGETINODE returns information about an open file for the process.  _p
  1445.      points to a pppprrrriiiinnnnooooddddeeeeiiiinnnnffffoooo structure containing the file descriptor of
  1446.  
  1447.  
  1448.  
  1449.                                                                        PPPPaaaaggggeeee 22222222
  1450.  
  1451.  
  1452.  
  1453.  
  1454.  
  1455.  
  1456. pppprrrroooocccc((((4444))))                                                                pppprrrroooocccc((((4444))))
  1457.  
  1458.  
  1459.  
  1460.      interest (in ppppiiii____ffffdddd).  On return ppppiiii____ddddeeeevvvv, ppppiiii____iiiinnnnuuuummmm, and ppppiiii____ggggeeeennnn contain the
  1461.      filesystem device, inode number, and inode generation number
  1462.      respectively.  Further information about the file can then be obtained
  1463.      through _s_y_s_s_g_i(SSSSGGGGIIII____FFFFSSSS____BBBBUUUULLLLKKKKSSSSTTTTAAAATTTT), for instance.  The ppppiiii____ddddeeeevvvv value matches
  1464.      that returned by _s_t_a_t_v_f_s (ffff____ffffssssiiiidddd) and _s_t_a_t (sssstttt____ddddeeeevvvv).  Bad values for
  1465.      ppppiiii____ffffdddd result in EBADF errors; if the referenced file is actually a socket
  1466.      then errno is set to EINVAL.  Filesystems other than XFS and EFS return 0
  1467.      for the ppppiiii____ggggeeeennnn value.
  1468.  
  1469. NNNNOOOOTTTTEEEESSSS
  1470.      Each operation (_i_o_c_t_l or I/O) is guaranteed to be atomic with respect to
  1471.      the traced process, except when applied to a system process.
  1472.  
  1473.      To wait for one or more of a set of processes to stop, /_p_r_o_c file
  1474.      descriptors can be used in a _p_o_l_l(2) system call.  On successful return,
  1475.      the polling event POLLPRI indicates that the process has stopped on an
  1476.      ``event of interest'' (see PPPPIIIIOOOOCCCCSSSSTTTTOOOOPPPP above).  Although they cannot be
  1477.      requested, the polling events POLLHUP, POLLERR and POLLNVAL may be
  1478.      returned.  POLLHUP indicates that the process has terminated.  POLLERR
  1479.      indicates that the file descriptor has become invalid.  POLLNVAL is
  1480.      returned immediately if POLLPRI is requested on a file descriptor
  1481.      referring to either itself or a system process (see PIOCSTOP).  /_p_r_o_c
  1482.      file descriptors may also be used in a _s_e_l_e_c_t(2) system call.  Selecting
  1483.      for an exceptional event has the same semantics as polling for POLLPRI.
  1484.      Selecting for reading or writing or polling for POLLIN or POLLOUT will
  1485.      always return true.  See the _p_o_l_l(2) and _s_e_l_e_c_t(2) man pages for further
  1486.      details.
  1487.  
  1488.      _p_o_l_l() or _s_e_l_e_c_t() may not be used on the /proc directory itself.
  1489.  
  1490.      For security reasons, except for the superuser, an open of a /_p_r_o_c file
  1491.      fails unless both the user-ID and group-ID of the caller match those of
  1492.      the traced process and the process's object file is readable by the
  1493.      caller.  Files corresponding to setuid and setgid processes can be opened
  1494.      only by the superuser.  Even if held by the superuser, an open process
  1495.      file descriptor becomes invalid if the traced process performs an _e_x_e_c()
  1496.      of a setuid/setgid object file or an object file that it cannot read.
  1497.      Any operation performed on an invalid file descriptor, except _c_l_o_s_e(2),
  1498.      fails with EAGAIN.  In this situation, if any tracing flags are set and
  1499.      the process file descriptor is open for writing, the process will have
  1500.      been directed to stop and its run-on-last-close flag will have been set
  1501.      (see PIOCSET).  This enables a controlling process (if it has permission)
  1502.      to reopen the process file to get a new valid file descriptor, close the
  1503.      invalid file descriptor, and proceed.  Just closing the invalid file
  1504.      descriptor causes the traced process to resume execution with no tracing
  1505.      flags set.  Any process not currently open for writing via /_p_r_o_c but that
  1506.      has left-over tracing flags from a previous open and that _e_x_e_cs a
  1507.      setuid/setgid or unreadable object file will not be stopped but will have
  1508.      all its tracing flags cleared.
  1509.  
  1510.  
  1511.  
  1512.  
  1513.  
  1514.  
  1515.                                                                        PPPPaaaaggggeeee 22223333
  1516.  
  1517.  
  1518.  
  1519.  
  1520.  
  1521.  
  1522. pppprrrroooocccc((((4444))))                                                                pppprrrroooocccc((((4444))))
  1523.  
  1524.  
  1525.  
  1526.      Descriptions of structures in this document include only interesting
  1527.      structure elements, not filler and padding fields, and may show elements
  1528.      out of order for descriptive clarity.  The actual structure definitions
  1529.      are contained in <_s_y_s/_p_r_o_c_f_s._h>.
  1530.  
  1531.      For reasons of symmetry and efficiency there are more control operations
  1532.      than strictly necessary.
  1533.  
  1534.      Programs compiled with the old 32-bit abi calling convention can perform
  1535.      ioctls on programs compiled with the new 32-bit abi or 64-bit abi calling
  1536.      conventions by "or'ing" the ioctl with PIOC_IRIX5_N32 or PIOC_IRIX5_64,
  1537.      respectively, and passing in a pointer to a buffer that is big enough to
  1538.      hold the larger structure.
  1539.  
  1540. FFFFIIIILLLLEEEESSSS
  1541.      /proc           directory (list of active processes)
  1542.      /proc/_n_n_n_n_n     process image
  1543.  
  1544. SSSSEEEEEEEE AAAALLLLSSSSOOOO
  1545.      mntproc(1M), ioctl(2), open(2), poll(2), ptrace(2), sigaction(2),
  1546.      signal(2), stat(2), statvfs(2), syssgi(2), siginfo(5), signal(5).
  1547.  
  1548. DDDDIIIIAAAAGGGGNNNNOOOOSSSSTTTTIIIICCCCSSSS
  1549.      Errors that can occur in addition to the errors normally associated with
  1550.      filesystem access:
  1551.  
  1552.      ENOENT          The traced process has terminated after being opened.
  1553.  
  1554.      EIO             I/O was attempted at an illegal address in the traced
  1555.                      process.
  1556.  
  1557.      ENXIO           I/O was attempted to an isolated processes address space.
  1558.  
  1559.      EBADF           An I/O or _i_o_c_t_l operation requiring write access was
  1560.                      attempted on a file descriptor not open for writing;
  1561.                      PIOCGETINODE was applied to a process file which was not
  1562.                      open.
  1563.  
  1564.      EBUSY           PIOCSTOP or PIOCWSTOP was applied to a system process; an
  1565.                      exclusive _o_p_e_n(2) was attempted on a process file already
  1566.                      open for writing; an _o_p_e_n(2) for writing was attempted
  1567.                      and an exclusive open is in effect on the process file;
  1568.                      PIOCRUN, PIOCSREG or PIOCSFPREG was applied to a process
  1569.                      not stopped on an event of interest; an attempt was made
  1570.                      to mount /_p_r_o_c when it is already mounted.
  1571.  
  1572.      EPERM           Someone other than the superuser attempted to better a
  1573.                      process's priority by issuing PIOCNICE.
  1574.  
  1575.      ENOSYS          An attempt was made to perform an unsupported operation
  1576.                      (such as create, remove, link, or unlink) on an entry in
  1577.                      /_p_r_o_c.
  1578.  
  1579.  
  1580.  
  1581.                                                                        PPPPaaaaggggeeee 22224444
  1582.  
  1583.  
  1584.  
  1585.  
  1586.  
  1587.  
  1588. pppprrrroooocccc((((4444))))                                                                pppprrrroooocccc((((4444))))
  1589.  
  1590.  
  1591.  
  1592.      EFAULT          An I/O or _i_o_c_t_l request referred to an invalid address in
  1593.                      the controlling process.
  1594.  
  1595.      EINVAL          In general this means that some invalid argument was
  1596.                      supplied to a system call.  The list of conditions
  1597.                      eliciting this error includes:  the _i_o_c_t_l code is
  1598.                      undefined; the _i_o_c_t_l code is not implemented; an _i_o_c_t_l
  1599.                      operation was issued on a file descriptor referring to
  1600.                      the /_p_r_o_c directory; an out-of-range signal number was
  1601.                      specified with PIOCSSIG, PIOCKILL, or PIOCUNKILL; SIGKILL
  1602.                      was specified with PIOCUNKILL; an illegal virtual address
  1603.                      was specified in a PIOCOPENM request; overlapping watched
  1604.                      areas were specified in a PIOCSWATCH request; an attempt
  1605.                      was made to establish more than the supported number of
  1606.                      watched areas in a PIOCSWATCH request; PIOCGFPREG or
  1607.                      PIOCSFPREG was issued on a machine without floating-point
  1608.                      hardware; the file specified to PIOCGETINODE is a socket.
  1609.  
  1610.      E2BIG           Data to be returned in a _r_e_a_d(2) of the page data file
  1611.                      exceeds the size of the read buffer provided by the
  1612.                      caller.
  1613.  
  1614.      EINTR           A signal was received by the controlling process while
  1615.                      waiting for the traced process to stop via PIOCSTOP or
  1616.                      PIOCWSTOP.
  1617.  
  1618.      EAGAIN          The traced process has performed an _e_x_e_c of a
  1619.                      setuid/setgid object file or of an object file that it
  1620.                      cannot read; all further operations on the process file
  1621.                      descriptor (except _c_l_o_s_e(2)) elicit this error.
  1622.  
  1623. BBBBUUUUGGGGSSSS
  1624.      When a signal is sent to the target process, but it is cleared (either by
  1625.      PIOCUNKILL or by using the PRCSIG flag to PIOCRUN), most system calls
  1626.      complete normally and do not return EINTR.  However, the specific system
  1627.      calls _m_s_g_s_n_d(2), _m_s_g_r_c_v(2), _s_e_m_o_p(2), _u_s_p_s_e_m_a(3P), _p_o_l_l(2) and _i_o_c_t_l(2)
  1628.      to the _i_m_o_n(7M) device are interrupted and do return EINTR.
  1629.  
  1630.  
  1631.  
  1632.  
  1633.  
  1634.  
  1635.  
  1636.  
  1637.  
  1638.  
  1639.  
  1640.  
  1641.  
  1642.  
  1643.  
  1644.  
  1645.  
  1646.  
  1647.                                                                        PPPPaaaaggggeeee 22225555
  1648.  
  1649.  
  1650.  
  1651.