home *** CD-ROM | disk | FTP | other *** search
/ IRIX Base Documentation 2002 November / SGI IRIX Base Documentation 2002 November.iso / usr / share / catman / p_man / cat4 / proc.z / proc
Encoding:
Text File  |  2002-10-03  |  99.3 KB  |  1,849 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.    PPPPIIIIOOOOCCCCTTTTHHHHRRRREEEEAAAADDDD
  306.      PIOCTHREAD returns thread-specific information.  _p is a pointer to a
  307.      pppprrrrtttthhhhrrrreeeeaaaaddddccccttttllll____tttt structure containing the following fields:
  308.  
  309.           typedef struct prthreadctl {
  310.                tid_t           pt_tid;       /* Id of the designated thread */
  311.                int             pt_cmd;       /* Command value for ioctl */
  312.                int             pt_flags;     /* Flags governing use of pt tid */
  313.                caddr_t         pt_data; /* Data pointer for command. */
  314.           } prthreadctl_t;
  315.  
  316.      Possible values of pppptttt____ccccmmmmdddd are:
  317.  
  318.           PPPPIIIIOOOOCCCCGGGGRRRREEEEGGGG        get general registers
  319.  
  320.           PPPPIIIIOOOOCCCCSSSSRRRREEEEGGGG        set general registers
  321.  
  322.  
  323.  
  324.  
  325.  
  326.  
  327.                                                                         PPPPaaaaggggeeee 5555
  328.  
  329.  
  330.  
  331.  
  332.  
  333.  
  334. pppprrrroooocccc((((4444))))                                                                pppprrrroooocccc((((4444))))
  335.  
  336.  
  337.  
  338.           PPPPIIIIOOOOCCCCGGGGFFFFPPPPRRRREEEEGGGG      get floating-point registers
  339.  
  340.           PPPPIIIIOOOOCCCCSSSSFFFFPPPPRRRREEEEGGGG      set floating-point registers
  341.  
  342.           PPPPIIIIOOOOCCCCSSSSTTTTAAAATTTTUUUUSSSS      get process status
  343.  
  344.           PPPPIIIIOOOOCCCCPPPPSSSSIIIINNNNFFFFOOOO      get ps(1) information
  345.  
  346.           PPPPIIIIOOOOCCCCSSSSTTTTOOOOPPPP        stop process thread(s) from running
  347.  
  348.           PPPPIIIIOOOOCCCCWWWWSSSSTTTTOOOOPPPP       wait for process thread(s) to stop
  349.  
  350.           PPPPIIIIOOOOCCCCRRRRUUUUNNNN         make process runnable
  351.  
  352.           PPPPIIIIOOOOCCCCSSSSSSSSIIIIGGGG        set current signal
  353.  
  354.           PPPPIIIIOOOOCCCCOOOOPPPPEEEENNNNMMMM       open mapped object for reading
  355.  
  356.           PPPPIIIIOOOOCCCCNNNNMMMMAAAAPPPP        get number of memory mappings
  357.  
  358.           PPPPIIIIOOOOCCCCMMMMAAAAPPPP         get memory map information
  359.  
  360.           PPPPIIIIOOOOCCCCMMMMAAAAPPPP____SSSSGGGGIIII     get extended memory map information
  361.  
  362.           PPPPIIIIOOOOCCCCPPPPGGGGDDDD____SSSSGGGGIIII     get page table information
  363.  
  364.           PPPPIIIIOOOOCCCCNNNNWWWWAAAATTTTCCCCHHHH      get number of watch points
  365.  
  366.           PPPPIIIIOOOOCCCCSSSSWWWWAAAATTTTCCCCHHHH      set watch point
  367.  
  368.           PPPPIIIIOOOOCCCCTTTTLLLLBBBBMMMMIIIISSSSSSSS     turn utlbmiss counting on/off
  369.  
  370.           PPPPIIIIOOOOCCCCGGGGUUUUTTTTIIIIDDDD       get uthread id(s)
  371.  
  372.           PPPPIIIIOOOOCCCCGGGGHHHHOOOOLLLLDDDD       get signal-hold mask
  373.  
  374.           PPPPIIIIOOOOCCCCSSSSHHHHOOOOLLLLDDDD       set signal-hold mask
  375.  
  376.           PPPPIIIIOOOOCCCCUUUUNNNNKKKKIIIILLLLLLLL      delete a signal
  377.  
  378.           PPPPIIIIOOOOCCCCCCCCFFFFAAAAUUUULLLLTTTT      clear current fault
  379.  
  380.           PPPPIIIIOOOOCCCCRRRREEEEAAAADDDD        read from target address space
  381.  
  382.           PPPPIIIIOOOOCCCCEEEENNNNEEEEVVVVCCCCTTTTRRRRTTTTHHHHRRRREEEEAAAADDDDSSSS
  383.                           enable event counters for uthread; only for
  384.                           R10000/R12000 event counters.
  385.  
  386.           PPPPIIIIOOOOCCCCGGGGEEEETTTTEEEEVVVVCCCCTTTTRRRRTTTTHHHHRRRREEEEAAAADDDDSSSS
  387.                           dump out the counters for uthread; only for
  388.                           R10000/R12000 event counters.
  389.  
  390.  
  391.  
  392.  
  393.                                                                         PPPPaaaaggggeeee 6666
  394.  
  395.  
  396.  
  397.  
  398.  
  399.  
  400. pppprrrroooocccc((((4444))))                                                                pppprrrroooocccc((((4444))))
  401.  
  402.  
  403.  
  404.           PPPPIIIIOOOOCCCCSSSSEEEETTTTEEEEVVVVCCCCTTTTRRRRTTTTHHHHRRRREEEEAAAADDDDSSSS
  405.                           set event counters for uthread; only for
  406.                           R10000/R12000 event counters.
  407.  
  408.           PPPPIIIIOOOOCCCCRRRREEEELLLLEEEEVVVVCCCCTTTTRRRRTTTTHHHHRRRREEEEAAAADDDDSSSS
  409.                           release/stop event counters for thread; only for
  410.                           R10000/R12000 event counters.
  411.  
  412.      pppptttt____ffffllllaaaaggggssss is a bit-mask holding these flags:
  413.  
  414.           PPPPTTTTFFFF____DDDDIIIIRRRR         Flags giving direction.
  415.  
  416.           PPPPTTTTFFFF____SSSSEEEETTTT         Flags defining set of threads.
  417.  
  418.           PPPPTTTTFFFFDDDD____EEEEQQQQLLLL        Only threads with exact tid.
  419.  
  420.           PPPPTTTTFFFFDDDD____GGGGEEEEQQQQ        Only threads with equal or greater tid.
  421.  
  422.           PPPPTTTTFFFFDDDD____GGGGTTTTRRRR        Only threads with greater tid.
  423.  
  424.           PPPPTTTTFFFFDDDD____MMMMAAAAXXXX        Max valid direction.
  425.  
  426.           PPPPTTTTFFFFSSSS____AAAALLLLLLLL        Set includes all threads.
  427.  
  428.           PPPPTTTTFFFFSSSS____SSSSTTTTOOOOPPPPPPPPEEEEDDDD    Set includes stopped threads.
  429.  
  430.           PPPPTTTTFFFFSSSS____EEEEVVVVEEEENNNNTTTTSSSS     Set includes threads with new events.
  431.  
  432.           PPPPTTTTFFFFSSSS____MMMMAAAAXXXX        Max valid set of threads.
  433.  
  434.      pppptttt____ttttiiiidddd is the thread id.
  435.  
  436.      pppptttt____ddddaaaattttaaaa describes the data to be returned by the ioctl cmd.
  437.  
  438.      The following section of code shows an example of use for this interface:
  439.  
  440.           #include <stdio.h>
  441.           #include <errno.h>
  442.           #include <sys/hwperfmacros.h>
  443.           #include <sys/fcntl.h>
  444.           #include <sys/hwperftypes.h>
  445.           #include <sys/procfs.h>
  446.           #include <sys/pthread.h>
  447.  
  448.           static int fd;
  449.           void *function1(void *arg);
  450.  
  451.           main() {
  452.                pid_t     pid = getpid();
  453.                pthread_t tid[3];
  454.                char pname[32];
  455.                pthread_attr_t pthread_attr;
  456.  
  457.  
  458.  
  459.                                                                         PPPPaaaaggggeeee 7777
  460.  
  461.  
  462.  
  463.  
  464.  
  465.  
  466. pppprrrroooocccc((((4444))))                                                                pppprrrroooocccc((((4444))))
  467.  
  468.  
  469.  
  470.               int   status;
  471.  
  472.                sprintf(pname, "/proc/%010d", pid);
  473.                if ((fd = open(pname, O_RDONLY)) < 0) {
  474.                     perror("open");
  475.                     exit(-1);
  476.                }
  477.                /* Initializes the thread attributes to default */
  478.                status = pthread_attr_init(&pthread_attr);
  479.                if (status) {
  480.                     perror("pthread_attr_init()");
  481.                     exit(-1);
  482.                }
  483.                /* create one pthread -- tid 0 */
  484.                if (pthread_create(&tid[0],  &pthread_attr,
  485.                                    function1, (void*)0)) {
  486.                     perror("pthread_create");
  487.                     exit(-1);
  488.                }
  489.                /* wait for pthread to finish */
  490.                pthread_join(tid[0], NULL);
  491.           }
  492.           void *
  493.           function1(void *arg)
  494.           {
  495.                prthreadctl_t  ptc;
  496.                hwperf_profevctrarg_t evctr_args;
  497.                hwperf_cntr_t   cnts;
  498.                int i;
  499.  
  500.                ptc.pt_tid = (int)arg;             /* thread id 0 */
  501.                ptc.pt_flags = PTFD_GEQ | PTFS_ALL;
  502.                ptc.pt_cmd = PIOCENEVCTRTHREADS;   /* enable event counters */
  503.                ptc.pt_data = (caddr_t)&evctr_args;
  504.                if (ioctl(fd, PIOCTHREAD, &ptc) < 0) {
  505.                     perror("PIOCENEVCTRTHREADS");
  506.                     exit(-1);
  507.                }
  508.                ptc.pt_cmd = PIOCGETEVCTRTHREADS;  /* read event counters */
  509.                ptc.pt_data = (caddr_t)&cnts;
  510.                if ((ioctl(fd, PIOCTHREAD, (void *)&ptc)) < 0) {
  511.                     perror("PIOCGETEVCTRTHREADS");
  512.                     ptc.pt_cmd = PIOCRELEVCTRTHREADS;
  513.                     ioctl(fd, PIOCTHREAD, (void *)&ptc);
  514.                     exit(-1);
  515.                }
  516.  
  517.                /* print event counters */
  518.                for(i = 0; i < HWPERF_EVENTMAX; i++) {
  519.                     printf("cnts.hwp_evctr[%d] %lld0, i, cnts.hwp_evctr[i]);
  520.                }
  521.                ptc.pt_cmd = PIOCRELEVCTRTHREADS;  /* release event counters */
  522.  
  523.  
  524.  
  525.                                                                         PPPPaaaaggggeeee 8888
  526.  
  527.  
  528.  
  529.  
  530.  
  531.  
  532. pppprrrroooocccc((((4444))))                                                                pppprrrroooocccc((((4444))))
  533.  
  534.  
  535.  
  536.               ioctl(fd, PIOCTHREAD, (void *)&ptc);
  537.                return(0);
  538.           }
  539.  
  540.  
  541.    ****PPPPIIIIOOOOCCCCSSSSTTTTOOOOPPPP PPPPIIIIOOOOCCCCWWWWSSSSTTTTOOOOPPPP
  542.      PIOCSTOP directs the process to stop and waits until it has stopped;
  543.      PIOCWSTOP simply waits for the process to stop.  These operations
  544.      complete when the process stops on an event of interest, immediately if
  545.      already so stopped.  If _p is non-zero it points to an instance of
  546.      pppprrrrssssttttaaaattttuuuussss____tttt to be filled with status information for the stopped process.
  547.  
  548.      An ``event of interest'' is either a PR_REQUESTED stop or a stop that has
  549.      been specified in the process's tracing flags (set by PIOCSTRACE,
  550.      PIOCSFAULT, PIOCSENTRY, and PIOCSEXIT).  A PR_JOBCONTROL stop is
  551.      specifically not an event of interest.  (A process may stop twice due to
  552.      a stop signal, first showing PR_SIGNALLED if the signal is traced and
  553.      again showing PR_JOBCONTROL if the process is set running without
  554.      clearing the signal.)  If the process is controlled by _p_t_r_a_c_e(2), it
  555.      comes to a PR_SIGNALLED stop on receipt of any signal; this is an event
  556.      of interest only if the signal is in the traced signal set.  If PIOCSTOP
  557.      is applied to a process that is stopped, but not on an event of interest,
  558.      the stop directive takes effect when the process is restarted by the
  559.      competing mechanism; at that time the process enters a PR_REQUESTED stop
  560.      before executing any user-level code.
  561.  
  562.      _i_o_c_t_l()s are interruptible by signals so that, for example, an _a_l_a_r_m(2)
  563.      can be set to avoid waiting forever for a process that may never stop on
  564.      an event of interest.  If PIOCSTOP is interrupted, the stop directive
  565.      remains in effect even though the _i_o_c_t_l() returns an error.
  566.  
  567.      A system process (indicated by the PR_ISSYS flag) never executes at user
  568.      level, has no user-level address space visible through /_p_r_o_c, and cannot
  569.      be stopped.  Applying PIOCSTOP or PIOCWSTOP to a system process elicits
  570.      the error EBUSY.
  571.  
  572.    ****PPPPIIIIOOOOCCCCRRRRUUUUNNNN
  573.      The traced process is made runnable again after a stop.  If _p is non-zero
  574.      it points to a pppprrrrrrrruuuunnnn structure describing additional actions to be
  575.      performed.  The pppprrrrrrrruuuunnnn structure contains at least the following fields:
  576.  
  577.           typedef struct prrun {
  578.                long      pr_flags;      /* Flags */
  579.                sigset_t  pr_trace;      /* Set of signals to be traced */
  580.                sigset_t  pr_sighold;    /* Set of signals to be held */
  581.                fltset_t  pr_fault;      /* Set of faults to be traced */
  582.                caddr_t   pr_vaddr;      /* Virtual address at which to resume */
  583.           } prrun_t;
  584.  
  585.      pppprrrr____ffffllllaaaaggggssss is a bit-mask describing optional actions; the remainder of the
  586.      entries are meaningful only if the appropriate bits are set in pppprrrr____ffffllllaaaaggggssss.
  587.      Flag definitions:
  588.  
  589.  
  590.  
  591.                                                                         PPPPaaaaggggeeee 9999
  592.  
  593.  
  594.  
  595.  
  596.  
  597.  
  598. pppprrrroooocccc((((4444))))                                                                pppprrrroooocccc((((4444))))
  599.  
  600.  
  601.  
  602.           PPPPRRRRCCCCSSSSIIIIGGGG          Clears the current signal, if any (see PIOCSSIG).
  603.  
  604.           PPPPRRRRCCCCFFFFAAAAUUUULLLLTTTT        Clears the current fault, if any (see PIOCCFAULT).
  605.  
  606.           PPPPRRRRSSSSTTTTRRRRAAAACCCCEEEE        Sets the traced signal set to pppprrrr____ttttrrrraaaacccceeee (see
  607.                           PIOCSTRACE).
  608.  
  609.           PPPPRRRRSSSSHHHHOOOOLLLLDDDD         Sets the held signal set to pppprrrr____ssssiiiigggghhhhoooolllldddd (see
  610.                           PIOCSHOLD).
  611.  
  612.           PPPPRRRRSSSSFFFFAAAAUUUULLLLTTTT        Sets the traced fault set to pppprrrr____ffffaaaauuuulllltttt (see
  613.                           PIOCSFAULT).
  614.  
  615.           PPPPRRRRSSSSVVVVAAAADDDDDDDDRRRR        Sets the address at which execution resumes to
  616.                           pppprrrr____vvvvaaaaddddddddrrrr.
  617.  
  618.           PPPPRRRRSSSSTTTTEEEEPPPP          Directs the process to single-step, that is, to run
  619.                           and to execute a single machine instruction.  On
  620.                           completion of the instruction, a trace trap occurs.
  621.                           If FLTTRACE is being traced, the process stops,
  622.                           otherwise it is sent SIGTRAP; if SIGTRAP is being
  623.                           traced and not held, the process stops.  This
  624.                           operation requires hardware and operating system
  625.                           support and may not be implemented on all
  626.                           processors.  It is implemented on SGI machines.
  627.  
  628.           PPPPRRRRCCCCSSSSTTTTEEEEPPPP         Cancels any outstanding single-step directive and
  629.                           any PPPPRRRRSSSSTTTTEEEEPPPP directive set in the current request.
  630.  
  631.           PPPPRRRRSSSSAAAABBBBOOOORRRRTTTT        Meaningful only if the process is in a PR_SYSENTRY
  632.                           stop or is marked PR_ASLEEP; it instructs the
  633.                           process to abort execution of the system call (see
  634.                           PIOCSENTRY, PIOCSEXIT).
  635.  
  636.           PPPPRRRRSSSSTTTTOOOOPPPP          Directs the process to stop again as soon as
  637.                           possible after resuming execution (see PIOCSTOP).
  638.                           In particular if the process is stopped on
  639.                           PR_SIGNALLED or PR_FAULTED, the next stop will show
  640.                           PR_REQUESTED, no other stop will have intervened,
  641.                           and the process will not have executed any user-
  642.                           level code.
  643.  
  644.           PIOCRUN fails (EBUSY) if applied to a process that is not stopped on
  645.           an event of interest.  Once PIOCRUN has been applied, the process is
  646.           no longer stopped on an event of interest even if, due to a
  647.           competing mechanism, it remains stopped.
  648.  
  649.    ****PPPPIIIIOOOOCCCCSSSSTTTTRRRRAAAACCCCEEEE
  650.      This defines a set of signals to be traced:  the receipt of one of these
  651.      signals causes the traced process to stop.  The set of signals is defined
  652.      via an instance of ssssiiiiggggsssseeeetttt____tttt addressed by _p.  Receipt of SIGKILL cannot be
  653.      traced.
  654.  
  655.  
  656.  
  657.                                                                        PPPPaaaaggggeeee 11110000
  658.  
  659.  
  660.  
  661.  
  662.  
  663.  
  664. pppprrrroooocccc((((4444))))                                                                pppprrrroooocccc((((4444))))
  665.  
  666.  
  667.  
  668.      If a signal that is included in the held signal set is sent to the traced
  669.      process, the signal is not received and does not cause a process stop
  670.      until it is removed from the held signal set, either by the process
  671.      itself or by setting the held signal set with PIOCSHOLD or the PRSHOLD
  672.      option of PIOCRUN.
  673.  
  674.    PPPPIIIIOOOOCCCCGGGGTTTTRRRRAAAACCCCEEEE
  675.      The current traced signal set is returned in an instance of ssssiiiiggggsssseeeetttt____tttt
  676.      addressed by _p.
  677.  
  678.    ****PPPPIIIIOOOOCCCCSSSSSSSSIIIIGGGG
  679.      The current signal and its associated signal information are set
  680.      according to the contents of the ssssiiiiggggiiiinnnnffffoooo structure addressed by _p (see
  681.      <_s_y_s/_s_i_g_i_n_f_o._h>).  If the specified signal number is zero or if _p is
  682.      zero, the current signal is cleared.  Setting the current signal to
  683.      SIGKILL terminates the process immediately, even if it is stopped.  All
  684.      other signals will be sent after the process is made runnable, if it is
  685.      currently stopped.
  686.  
  687.    ****PPPPIIIIOOOOCCCCKKKKIIIILLLLLLLL
  688.      A signal is sent to the process with semantics identical to those of
  689.      _k_i_l_l(2).  _p points to an _i_n_t naming the signal.  Sending SIGKILL
  690.      terminates the process immediately.
  691.  
  692.    ****PPPPIIIIOOOOCCCCUUUUNNNNKKKKIIIILLLLLLLL
  693.      A signal is deleted, that is, it is removed from the set of pending
  694.      signals.  The current signal (if any) is unaffected.  _p points to an _i_n_t
  695.      naming the signal.  It is an error to attempt to delete SIGKILL.
  696.  
  697.    PPPPIIIIOOOOCCCCGGGGHHHHOOOOLLLLDDDD ****PPPPIIIIOOOOCCCCSSSSHHHHOOOOLLLLDDDD
  698.      PIOCGHOLD returns the set of held signals (signals whose delivery will be
  699.      delayed if sent to the process) in an instance of ssssiiiiggggsssseeeetttt____tttt addressed by
  700.      _p.  PIOCSHOLD correspondingly sets the held signal set but does not allow
  701.      SIGKILL or SIGSTOP to be held.
  702.  
  703.    PPPPIIIIOOOOCCCCMMMMAAAAXXXXSSSSIIIIGGGG PPPPIIIIOOOOCCCCAAAACCCCTTTTIIIIOOOONNNN
  704.      These operations provide information about the signal actions associated
  705.      with the traced process (see _s_i_g_a_c_t_i_o_n(2)).  PIOCMAXSIG returns, in the
  706.      _i_n_t addressed by _p, the maximum signal number understood by the system.
  707.      This can be used to allocate storage for use with the PIOCACTION
  708.      operation, which returns the traced process's signal actions in an array
  709.      of ssssiiiiggggaaaaccccttttiiiioooonnnn structures addressed by _p.  Signal numbers are displaced by
  710.      1 from array indices, so that the action for signal number _n appears in
  711.      position _n-1 of the array.
  712.  
  713.    ****PPPPIIIIOOOOCCCCSSSSFFFFAAAAUUUULLLLTTTT
  714.      This defines a set of hardware faults to be traced:  on incurring one of
  715.      these faults the traced process stops.  The set is defined via an
  716.      instance of ffffllllttttsssseeeetttt____tttt addressed by _p.  Fault names are defined in
  717.      <_s_y_s/_f_a_u_l_t._h> and include the following.  Some of these may not occur on
  718.      all processors; there may be processor-specific faults in addition to
  719.      these.
  720.  
  721.  
  722.  
  723.                                                                        PPPPaaaaggggeeee 11111111
  724.  
  725.  
  726.  
  727.  
  728.  
  729.  
  730. pppprrrroooocccc((((4444))))                                                                pppprrrroooocccc((((4444))))
  731.  
  732.  
  733.  
  734.           FFFFLLLLTTTTIIIILLLLLLLL          illegal instruction
  735.           FFFFLLLLTTTTPPPPRRRRIIIIVVVV         privileged instruction
  736.           FFFFLLLLTTTTBBBBPPPPTTTT          breakpoint trap
  737.           FFFFLLLLTTTTTTTTRRRRAAAACCCCEEEE        trace trap
  738.           FFFFLLLLTTTTWWWWAAAATTTTCCCCHHHH        watchpoint trap
  739.           FFFFLLLLTTTTKKKKWWWWAAAATTTTCCCCHHHH       kernel watchpoint trap
  740.           FFFFLLLLTTTTAAAACCCCCCCCEEEESSSSSSSS       memory access fault
  741.           FFFFLLLLTTTTBBBBOOOOUUUUNNNNDDDDSSSS       memory bounds violation
  742.           FFFFLLLLTTTTIIIIOOOOVVVVFFFF         integer overflow
  743.           FFFFLLLLTTTTIIIIZZZZDDDDIIIIVVVV        integer zero divide
  744.           FFFFLLLLTTTTFFFFPPPPEEEE          floating-point exception
  745.           FFFFLLLLTTTTSSSSTTTTAAAACCCCKKKK        unrecoverable stack fault
  746.           FFFFLLLLTTTTPPPPAAAAGGGGEEEE         recoverable page fault
  747.  
  748.      When not traced, a fault normally results in the posting of a signal to
  749.      the process that incurred the fault.  If the process stops on a fault,
  750.      the signal is posted to the process when execution is resumed unless the
  751.      fault is cleared by PIOCCFAULT or by the PRCFAULT option of PIOCRUN.
  752.      FLTPAGE and FLTKWATCH are exceptions; no signal is posted.  There may be
  753.      additional processor-specific faults like this.  pppprrrr____iiiinnnnffffoooo in the pppprrrrssssttttaaaattttuuuussss
  754.      structure identifies the signal to be sent and contains machine-specific
  755.      information about the fault.
  756.  
  757.    PPPPIIIIOOOOCCCCGGGGFFFFAAAAUUUULLLLTTTT
  758.      The current traced fault set is returned in an instance of ffffllllttttsssseeeetttt____tttt
  759.      addressed by _p.
  760.  
  761.    ****PPPPIIIIOOOOCCCCCCCCFFFFAAAAUUUULLLLTTTT
  762.      The current fault (if any) is cleared; the associated signal is not sent
  763.      to the process.
  764.  
  765.    ****PPPPIIIIOOOOCCCCSSSSEEEENNNNTTTTRRRRYYYY ****PPPPIIIIOOOOCCCCSSSSEEEEXXXXIIIITTTT
  766.      These operations instruct the process to stop on entry to or exit from
  767.      specified system calls.  The set of system calls to be traced is defined
  768.      via an instance of ssssyyyysssssssseeeetttt____tttt addressed by _p.
  769.  
  770.      When entry to a system call is being traced, the traced process stops
  771.      after having begun the call to the system but before the system call
  772.      arguments have been fetched from the process.  When exit from a system
  773.      call is being traced, the traced process stops on completion of the
  774.      system call just prior to checking for signals and returning to user
  775.      level.  At this point all return values have been stored into the traced
  776.      process's registers.
  777.  
  778.      If the traced process is stopped on entry to a system call (PR_SYSENTRY)
  779.      or when sleeping in an interruptible system call (PR_ASLEEP is set), it
  780.      may be instructed to go directly to system call exit by specifying the
  781.      PRSABORT flag in a PIOCRUN request.  Unless exit from the system call is
  782.      being traced the process returns to user level showing error EINTR.
  783.  
  784.  
  785.  
  786.  
  787.  
  788.  
  789.                                                                        PPPPaaaaggggeeee 11112222
  790.  
  791.  
  792.  
  793.  
  794.  
  795.  
  796. pppprrrroooocccc((((4444))))                                                                pppprrrroooocccc((((4444))))
  797.  
  798.  
  799.  
  800.    PPPPIIIIOOOOCCCCGGGGEEEENNNNTTTTRRRRYYYY PPPPIIIIOOOOCCCCGGGGEEEEXXXXIIIITTTT
  801.      These return the current traced system call entry or exit set in an
  802.      instance of ssssyyyysssssssseeeetttt____tttt addressed by _p.
  803.  
  804.    PPPPIIIIOOOOCCCCNNNNWWWWAAAATTTTCCCCHHHH
  805.      PIOCNWATCH returns, in the _i_n_t addressed by _p, the number of watched
  806.      areas supported by the system.  This can be used to allocate storage for
  807.      use with the PIOCSWATCH and PIOCGWATCH operations, each of which must
  808.      provide an array whose number of elements equals the supported number of
  809.      watched areas.
  810.  
  811.    ****PPPPIIIIOOOOCCCCSSSSWWWWAAAATTTTCCCCHHHH
  812.      PIOCSWATCH establishes or clears a set of watched areas in the traced
  813.      process; _p points to pppprrrrwwwwaaaattttcccchhhh structure containing at least the following
  814.      fields:
  815.  
  816.           typedef struct prwatch {
  817.                caddr_t   pr_vaddr; /* Virtual address of watched area */
  818.                u_long    pr_size;  /* Size of watched area in bytes */
  819.                long pr_wflags;     /* Watch type flags */
  820.           } prwatch_t;
  821.  
  822.      pppprrrr____vvvvaaaaddddddddrrrr specifies the virtual address of an area of memory to be watched
  823.      in the traced process.  pppprrrr____ssssiiiizzzzeeee specifies the size of the area, in bytes.
  824.      pppprrrr____wwwwffffllllaaaaggggssss specifies the type of memory access to be monitored as a bit-
  825.      mask of one or more of the following flags (see also PIOCMAP):
  826.  
  827.           MMMMAAAA____RRRREEEEAAAADDDD         read access
  828.           MMMMAAAA____WWWWRRRRIIIITTTTEEEE        write access
  829.           MMMMAAAA____EEEEXXXXEEEECCCC         execution access
  830.  
  831.      An entry with a zero value for pppprrrr____ssssiiiizzzzeeee clears any previously-established
  832.      watched area starting at the specified virtual address.  An entry with a
  833.      non-empty pppprrrr____wwwwffffllllaaaaggggssss bit-mask establishes a watched area for the virtual
  834.      address range specified by pppprrrr____vvvvaaaaddddddddrrrr and pppprrrr____ssssiiiizzzzeeee.  An entry with an empty
  835.      pppprrrr____wwwwffffllllaaaaggggssss bit-mask is ignored.
  836.  
  837.      A watchpoint is triggered when the traced process makes a memory
  838.      reference that covers at least one byte of a watched area and the memory
  839.      reference is a mode of interest as specified in pppprrrr____wwwwffffllllaaaaggggssss.  When a
  840.      watchpoint is triggered, the process incurs a watchpoint trap.  If
  841.      FLTWATCH is being traced, the process stops; otherwise it is sent
  842.      SIGTRAP; if SIGTRAP is being traced and not held, the process stops.  If
  843.      the access is a write access, the memory is not modified.  If the process
  844.      stops, its program counter refers to the instruction that triggered the
  845.      watchpoint.  pppprrrr____iiiinnnnffffoooo in the pppprrrrssssttttaaaattttuuuussss structure contains information
  846.      pertinent to the watchpoint trap.  In particular, the ssssiiii____aaaaddddddddrrrr field
  847.      contains the virtual address of the memory reference that triggered the
  848.      watchpoint and the ssssiiii____ccccooooddddeeee field contains one of MMMMAAAA____RRRREEEEAAAADDDD, MMMMAAAA____WWWWRRRRIIIITTTTEEEE, or
  849.      MMMMAAAA____EEEEXXXXEEEECCCC, indicating read, write or execute access, respectively.
  850.  
  851.  
  852.  
  853.  
  854.  
  855.                                                                        PPPPaaaaggggeeee 11113333
  856.  
  857.  
  858.  
  859.  
  860.  
  861.  
  862. pppprrrroooocccc((((4444))))                                                                pppprrrroooocccc((((4444))))
  863.  
  864.  
  865.  
  866.      A watchpoint may be triggered while executing a system call that makes
  867.      reference to the traced process's memory.  Such a system call completes
  868.      normally; a kernel watchpoint fault is taken after the system call
  869.      completes but before the process returns to user level.  If more than one
  870.      watchpoint would be triggered by the system call, the first one
  871.      encountered is the one reported.
  872.  
  873.      PIOCSWATCH fails with EINVAL if an attempt is made to specify overlapping
  874.      watched areas or to specify a watchpoint whose virtual address range
  875.      includes invalid virtual addresses in the traced process.  PIOCSWATCH
  876.      fails with E2BIG if an attempt is made to establish more than the
  877.      supported number of watched areas and with ESRCH if an attempt is made to
  878.      delete a non-existent watchpoint.  An attempt to delete watchpoints on a
  879.      running process could result in failure with errno set to EBUSY.  This is
  880.      a temporary condition that occurs when the kernel is stepping over a
  881.      watchpoint and a later subsequent attempt should succeed.  This does not
  882.      happen if the process is stopped.
  883.  
  884.      Access to a process's memory through /_p_r_o_c will not trigger a watchpoint,
  885.      even if the access is from the process itself (which must have opened its
  886.      own /_p_r_o_c entry).
  887.  
  888.    PPPPIIIIOOOOCCCCGGGGWWWWAAAATTTTCCCCHHHH
  889.      PIOCGWATCH returns, in the array of pppprrrrwwwwaaaattttcccchhhh structures addressed by _p,
  890.      the set of watched areas currently in effect.  Elements beyond the number
  891.      of actually established watched areas are filled with zeros.
  892.  
  893.    ****PPPPIIIIOOOOCCCCSSSSEEEETTTT ****PPPPIIIIOOOOCCCCRRRREEEESSSSEEEETTTT
  894.      PIOCSET sets one or more modes of operation for the traced process.
  895.      PIOCRESET resets these modes.  The modes to be set or reset are specified
  896.      by flags in a _l_o_n_g addressed by _p:
  897.  
  898.           PPPPRRRR____FFFFOOOORRRRKKKK         (inherit-on-fork)  When set, the process's tracing
  899.                           flags are inherited by the child of a _f_o_r_k(2).  When
  900.                           reset, child processes start with all tracing flags
  901.                           cleared.
  902.  
  903.           PPPPRRRR____RRRRLLLLCCCC          (run-on-last-close)  When set and the last writable
  904.                           /_p_r_o_c file descriptor referring to the traced
  905.                           process is closed, all of the process's tracing
  906.                           flags are cleared, any outstanding stop directive is
  907.                           canceled, and if the process is stopped, it is set
  908.                           running as though PIOCRUN had been applied to it.
  909.                           When reset, the process's tracing flags are retained
  910.                           and the process is not set running on last close.
  911.  
  912.           PPPPRRRR____KKKKLLLLCCCC          (kill-on-last-close)  When set and the last writable
  913.                           /_p_r_o_c file descriptor referring to the traced
  914.                           process is closed, the process is terminated with
  915.                           SIGKILL.
  916.  
  917.  
  918.  
  919.  
  920.  
  921.                                                                        PPPPaaaaggggeeee 11114444
  922.  
  923.  
  924.  
  925.  
  926.  
  927.  
  928. pppprrrroooocccc((((4444))))                                                                pppprrrroooocccc((((4444))))
  929.  
  930.  
  931.  
  932.      It is an error (EINVAL) to specify flags other than those described above
  933.      or to apply these operations to a system process.  The current modes are
  934.      reported in the pppprrrrssssttttaaaattttuuuussss structure (see PIOCSTATUS).
  935.  
  936.      Note that a processes using /_p_r_o_c can not assume any default settings for
  937.      these flags, as some other process may have attached to the target
  938.      earlier and reset the flags and then detached.
  939.  
  940.    PPPPIIIIOOOOCCCCGGGGRRRREEEEGGGG ****PPPPIIIIOOOOCCCCSSSSRRRREEEEGGGG
  941.      These operations respectively get and set the process general registers
  942.      into or out of an array addressed by _p; the array has type ggggrrrreeeeggggsssseeeetttt____tttt.
  943.      Register contents are accessible using a set of predefined indices (see
  944.      PIOCSTATUS).  No bits of the processor-status register (PSR) or other
  945.      privileged registers can be modified by PIOCSREG.
  946.  
  947.      PIOCSREG fails (EBUSY) if applied to a process that is not stopped on an
  948.      event of interest.  If the process is not stopped, the register values
  949.      returned by PIOCGREG are undefined.
  950.  
  951.    PPPPIIIIOOOOCCCCGGGGFFFFPPPPRRRREEEEGGGG ****PPPPIIIIOOOOCCCCSSSSFFFFPPPPRRRREEEEGGGG
  952.      These operations respectively get and set the process floating-point
  953.      registers into or out of a structure addressed by _p; the structure has
  954.      type ffffpppprrrreeeeggggsssseeeetttt____tttt.  An error (EINVAL) is returned if there is no floating-
  955.      point hardware on the machine.  PIOCSFPREG fails (EBUSY) if applied to a
  956.      process that is not stopped on an event of interest.  If the process is
  957.      not stopped, the register values returned by PIOCGFPREG are undefined.
  958.  
  959.    ****PPPPIIIIOOOOCCCCNNNNIIIICCCCEEEE
  960.      The traced process's _n_i_c_e(2) priority is incremented by the amount
  961.      contained in the _i_n_t addressed by _p.  Only the superuser may better a
  962.      process's priority in this way, but any user may make the priority worse.
  963.  
  964.    PPPPIIIIOOOOCCCCPPPPSSSSIIIINNNNFFFFOOOO
  965.      This returns miscellaneous process information such as that reported by
  966.      _p_s(1).  _p is a pointer to a pppprrrrppppssssiiiinnnnffffoooo structure containing at least the
  967.      following fields:
  968.  
  969.           typedef struct prpsinfo {
  970.                char pr_state; /* numeric process state (see pr_sname) */
  971.                char pr_sname; /* printable character representing pr_state */
  972.                char pr_zomb;  /* !=0: process terminated but not waited for */
  973.                char pr_nice;  /* nice for cpu usage */
  974.                u_long pr_flag;     /* process flags */
  975.                uid_t pr_uid;  /* real user id */
  976.                gid_t pr_gid;  /* real group id */
  977.                pid_t pr_pid;  /* unique process id */
  978.                pid_t pr_ppid; /* process id of parent */
  979.                pid_t pr_pgrp; /* pid of process group leader */
  980.                pid_t pr_sid;  /* session id */
  981.                caddr_t pr_addr;    /* physical address of process */
  982.                long pr_size;  /* size of process image in pages */
  983.                long pr_rssize;     /* resident set size in pages */
  984.  
  985.  
  986.  
  987.                                                                        PPPPaaaaggggeeee 11115555
  988.  
  989.  
  990.  
  991.  
  992.  
  993.  
  994. pppprrrroooocccc((((4444))))                                                                pppprrrroooocccc((((4444))))
  995.  
  996.  
  997.  
  998.               long pr_pagesize;    /* system page size, in bytes */
  999.                caddr_t pr_wchan;   /* wait addr for sleeping process */
  1000.                timespec_t pr_start;     /* process start time, sec+nsec since epoch */
  1001.                timespec_t pr_time; /* usr+sys cpu time for this process */
  1002.                long pr_pri;        /* priority, high value is high priority */
  1003.                char pr_oldpri;     /* pre-SVR4, low value is high priority */
  1004.                char pr_cpu;        /* pre-SVR4, cpu usage for scheduling */
  1005.                dev_t pr_ttydev;   /* controlling tty device (PRNODEV if none) */
  1006.                char pr_clname[8];       /* Scheduling class name */
  1007.                char pr_fname[PRCOMSIZ]; /* last component of exec()ed pathname */
  1008.                char pr_psargs[PRARGSZ]; /* initial characters of arg list */
  1009.                u_int pr_pset;      /* associated processor set name */
  1010.                cpuid_t pr_sonproc; /* processor running on */
  1011.                timespec_t pr_ctime;     /* usr+sys cpu time for all children */
  1012.           } prpsinfo_t;
  1013.  
  1014.      Some of the entries in pppprrrrppppssssiiiinnnnffffoooo, such as pppprrrr____ssssttttaaaatttteeee and pppprrrr____ffffllllaaaagggg, are
  1015.      system-specific and should not be expected to retain their meanings
  1016.      across different versions of the operating system.  pppprrrr____aaaaddddddddrrrr is a vestige
  1017.      of the past and has no real meaning in current systems.
  1018.  
  1019.      PIOCPSINFO can be applied to a _z_o_m_b_i_e process (one that has terminated
  1020.      but whose parent has not yet performed a _w_a_i_t(2) on it).
  1021.  
  1022.    PPPPIIIIOOOOCCCCNNNNMMMMAAAAPPPP PPPPIIIIOOOOCCCCMMMMAAAAPPPP
  1023.      These operations provide information about the memory mappings (virtual
  1024.      address ranges) associated with the traced process.  PIOCNMAP returns, in
  1025.      the _i_n_t addressed by _p, the number of mappings that are currently active.
  1026.      The PIOCMAP operation may be used to obtain the list of currently active
  1027.      mappings, which is an array of structures of type pppprrrrmmmmaaaapppp____tttt.  The PIOCNMAP
  1028.      may be used to determine the minimum amount of storage that needs to be
  1029.      allocated to receive these structures, but the programmer should not
  1030.      assume that it is the maximum amount needed.  If the PIOCNMAP and PIOCMAP
  1031.      calls are made on a process that is not stopped, the number of maps could
  1032.      change between the two ioctl calls and caller could fault if too few maps
  1033.      were allocated to hold the results of PIOCMAP.  Note: for a better
  1034.      interface, see PIOCMAP_SGI below.  For PIOCMAP, _p addresses an array of
  1035.      elements of type pppprrrrmmmmaaaapppp____tttt; one array element (one structure) is returned
  1036.      for each mapping, plus an additional element containing all zeros to mark
  1037.      the end of the list.  The pppprrrrmmmmaaaapppp structure contains at least the following
  1038.      fields:
  1039.  
  1040.           typedef struct prmap {
  1041.                caddr_t pr_vaddr;   /* Virtual address */
  1042.                u_long    pr_size;  /* Size of mapping in bytes */
  1043.                off_t     pr_off;   /* Offset into mapped object, if any */
  1044.                long pr_mflags;     /* Protection and attribute flags */
  1045.           } prmap_t;
  1046.  
  1047.      pppprrrr____vvvvaaaaddddddddrrrr is the virtual address of the mapping within the traced process
  1048.      and pppprrrr____ssssiiiizzzzeeee is its size in bytes.  pppprrrr____ooooffffffff is the offset within the mapped
  1049.      object (if any) to which the virtual address is mapped.
  1050.  
  1051.  
  1052.  
  1053.                                                                        PPPPaaaaggggeeee 11116666
  1054.  
  1055.  
  1056.  
  1057.  
  1058.  
  1059.  
  1060. pppprrrroooocccc((((4444))))                                                                pppprrrroooocccc((((4444))))
  1061.  
  1062.  
  1063.  
  1064.      pppprrrr____mmmmffffllllaaaaggggssss is a bit-mask of protection and attribute flags:
  1065.  
  1066.           MMMMAAAA____RRRREEEEAAAADDDD         mapping is readable by the traced process
  1067.           MMMMAAAA____WWWWRRRRIIIITTTTEEEE        mapping is writable by the traced process
  1068.           MMMMAAAA____EEEEXXXXEEEECCCC         mapping is executable by the traced process
  1069.           MMMMAAAA____SSSSHHHHAAAARRRREEEEDDDD       mapping changes are shared by the mapped object
  1070.           MMMMAAAA____BBBBRRRREEEEAAAAKKKK        mapping is grown by the _b_r_k(2) system call
  1071.           MMMMAAAA____SSSSTTTTAAAACCCCKKKK        mapping is grown automatically on stack faults
  1072.           MMMMAAAA____PPPPHHHHYYYYSSSS         mapping corresponds to a physical device mapping
  1073.  
  1074.    PPPPIIIIOOOOCCCCMMMMAAAAPPPP____SSSSGGGGIIII
  1075.      This operation provides detailed information about the memory mappings
  1076.      (virtual address ranges) associated with the traced process.  In effect
  1077.      it performs both a PIOCNMAP and a PIOCMAP call (with additional
  1078.      information) with one ioctl.  The PIOCMAP_SGI operation may be used to
  1079.      obtain the list of currently active mappings, which is an array of
  1080.      structures of type pppprrrrmmmmaaaapppp____ssssggggiiii____tttt.  The user must preallocate an array of
  1081.      the maximum number of mapping structures they are willing to receive.
  1082.      One array element (one structure) is returned for each mapping, plus an
  1083.      additional element containing all zeros that also marks the end of the
  1084.      list.  There is an upper limit to the number of memory mappings that can
  1085.      be returned by this call, which is defined as PRMAPMAX in the procfs.h
  1086.      header file. Attempts to request more than the PRMAPMAX number of
  1087.      mappings results in only PRMAPMAX mappings returned.  PIOCMAP_SGI returns
  1088.      either -1 or the number of mappings that are currently active.
  1089.  
  1090.      For PIOCMAP_SGI, _p addresses a pointer to a structure called
  1091.      pppprrrrmmmmaaaapppp____ssssggggiiii____aaaarrrrgggg____tttt.  It contains the following fields:
  1092.  
  1093.           typedef struct prmap_sgi_arg {
  1094.                caddr_t pr_vaddr;   /* Base of map buffer */
  1095.                ulong_t pr_size;    /* Size of buffer in bytes */
  1096.           } prmap_sgi_arg_t;
  1097.  
  1098.      pppprrrr____vvvvaaaaddddddddrrrr is the virtual address of the buffer to hold the mappings for
  1099.      the traced process and pppprrrr____ssssiiiizzzzeeee is its size in bytes.  The pppprrrrmmmmaaaapppp____ssssggggiiii____tttt
  1100.      structure contains at least the following fields:
  1101.  
  1102.           typedef struct prmap_sgi {
  1103.                caddr_t pr_vaddr;   /* Virtual base address */
  1104.                ulong_t pr_size;    /* Size of mapping in bytes */
  1105.                off_t     pr_off;   /* Offset into mapped object, if any */
  1106.                ulong_t pr_mflags;  /* Protection and attribute flags */
  1107.                pgno_t    pr_vsize; /* # valid pages in this segment */
  1108.                pgno_t    pr_psize; /* # private pages in this segment */
  1109.                pgno_t    pr_wsize; /* Cost for this proc weighted base 256 */
  1110.                pgno_t    pr_rsize; /* # referenced pages in this segment */
  1111.                pgno_t    pr_msize; /* # modified pages in this segment */
  1112.                dev_t     pr_dev;   /* Device # of segment iff mapped */
  1113.                ino_t     pr_ino;   /* Inode # of segment iff mapped */
  1114.           } prmap_sgi_t;
  1115.  
  1116.  
  1117.  
  1118.  
  1119.                                                                        PPPPaaaaggggeeee 11117777
  1120.  
  1121.  
  1122.  
  1123.  
  1124.  
  1125.  
  1126. pppprrrroooocccc((((4444))))                                                                pppprrrroooocccc((((4444))))
  1127.  
  1128.  
  1129.  
  1130.      pppprrrr____vvvvaaaaddddddddrrrr is the virtual address of the mapping within the traced process
  1131.      and pppprrrr____ssssiiiizzzzeeee is its size in bytes.  pppprrrr____ooooffffffff is the offset within the mapped
  1132.      object (if any) to which the virtual address is mapped.  pppprrrr____vvvvssssiiiizzzzeeee,
  1133.      pppprrrr____ppppssssiiiizzzzeeee, pppprrrr____wwwwssssiiiizzzzeeee, pppprrrr____rrrrssssiiiizzzzeeee, pppprrrr____mmmmssssiiiizzzzeeee are page counts for the virtual
  1134.      mapping.  pppprrrr____ddddeeeevvvv and pppprrrr____ddddeeeevvvv identify the filesystem resident object from
  1135.      which the mapping originates (if one exists).
  1136.  
  1137.      pppprrrr____mmmmffffllllaaaaggggssss is a bit-mask of protection and attribute flags:
  1138.  
  1139.           MMMMAAAA____RRRREEEEAAAADDDD         mapping is readable by the traced process
  1140.           MMMMAAAA____WWWWRRRRIIIITTTTEEEE        mapping is writable by the traced process
  1141.           MMMMAAAA____EEEEXXXXEEEECCCC         mapping is executable by the traced process
  1142.           MMMMAAAA____SSSSHHHHAAAARRRREEEEDDDD       mapping changes are shared by the mapped object
  1143.           MMMMAAAA____BBBBRRRREEEEAAAAKKKK        mapping is grown by the _b_r_k(2) system call
  1144.           MMMMAAAA____SSSSTTTTAAAACCCCKKKK        mapping is grown automatically on stack faults
  1145.           MMMMAAAA____PPPPHHHHYYYYSSSS         mapping corresponds to a physical device mapping
  1146.           MMMMAAAA____PPPPRRRRIIIIMMMMAAAARRRRYYYY      mapping is one of the processes core segments
  1147.           MMMMAAAA____CCCCOOOOWWWW          mapping corresponds to a copy on write segment
  1148.           MMMMAAAA____NNNNOOOOTTTTCCCCAAAACCCCHHHHEEEEDDDD    mapped address segment is not cached
  1149.           MMMMAAAA____SSSSHHHHMMMMEEEEMMMM        mapping corresponds to a shared memory mapping
  1150.           MMMMAAAA____RRRREEEEFFFFCCCCNNNNTTTT____SSSSHHHHIIIIFFFFTTTT amount to shift right mflags to get reference count
  1151.  
  1152.    PPPPIIIIOOOOCCCCPPPPGGGGDDDD____SSSSGGGGIIII
  1153.      This operation provides information about the interior of a memory
  1154.      mappings (virtual address ranges) associated with the traced process.
  1155.      The PIOCPGD_SGI operation is be used to obtain the list of page
  1156.      descriptors, which is an array of structures of type ppppggggdddd____tttt.  The
  1157.      PIOCMAP_SGI ioctl may be used to determine the amount of storage that
  1158.      needs to be allocated to receive these structures.  For PIOCPGD_SGI, _p
  1159.      addresses a pointer to a pppprrrrppppggggdddd____ssssggggiiii____tttt structure that contains an array of
  1160.      elements of type pppprrrrppppggggdddd____tttt.  The ppppggggdddd____tttt structure contains at least the
  1161.      following fields:
  1162.  
  1163.           typedef struct pgd {     /* per-page data */
  1164.                short pr_flags;     /* flags */
  1165.                short pr_value;     /* page count/fault offset */
  1166.           } pgd_t;
  1167.  
  1168.      The pppprrrrppppggggdddd____ssssggggiiii____tttt structure contains at least the following fields:
  1169.  
  1170.           typedef struct prpgd_sgi {
  1171.                caddr_t pr_vaddr;   /* virtual base address of region to stat */
  1172.                pgno_t    pr_pglen; /* number of pages in data list... */
  1173.                pgd_t     pr_data[1]; /* variable length array of page flags */
  1174.           } prpgd_sgi_t;
  1175.  
  1176.      pppprrrr____vvvvaaaaddddddddrrrr is the virtual address of the mapping within the traced process
  1177.      and pppprrrr____ppppgggglllleeeennnn is length of the pppprrrr____ddddaaaattttaaaa array.
  1178.  
  1179.      The pppprrrr____ffffllllaaaaggggssss field for each page contains the following flags:
  1180.  
  1181.  
  1182.  
  1183.  
  1184.  
  1185.                                                                        PPPPaaaaggggeeee 11118888
  1186.  
  1187.  
  1188.  
  1189.  
  1190.  
  1191.  
  1192. pppprrrroooocccc((((4444))))                                                                pppprrrroooocccc((((4444))))
  1193.  
  1194.  
  1195.  
  1196.           PPPPGGGGFFFF____RRRREEEEFFFFEEEERRRREEEENNNNCCCCEEEEDDDD  page is currently valid in system page table
  1197.           PPPPGGGGFFFF____GGGGLLLLOOOOBBBBAAAALLLL      page is marked global in system page table
  1198.           PPPPGGGGFFFF____WWWWRRRRIIIITTTTEEEEAAAABBBBLLLLEEEE   page is currently writeable in system page table
  1199.           PPPPGGGGFFFF____NNNNOOOOTTTTCCCCAAAACCCCHHHHEEEEDDDD   page is marked non-cacheable in system page table
  1200.           PPPPGGGGFFFF____IIIISSSSVVVVAAAALLLLIIIIDDDD     page is marked valid for this process
  1201.           PPPPGGGGFFFF____IIIISSSSDDDDIIIIRRRRTTTTYYYY     page is marked dirty for this process
  1202.           PPPPGGGGFFFF____PPPPRRRRIIIIVVVVAAAATTTTEEEE     page is marked private to this process
  1203.           PPPPGGGGFFFF____FFFFAAAAUUUULLLLTTTT       the pr_value field contains a fault offset
  1204.           PPPPGGGGFFFF____UUUUSSSSRRRRHHHHIIIISSSSTTTTOOOORRRRYYYY  accumulating history flag for caller
  1205.           PPPPGGGGFFFF____RRRREEEEFFFFHHHHIIIISSSSTTTTOOOORRRRYYYY  page has been marked referenced
  1206.           PPPPGGGGFFFF____WWWWRRRRTTTTHHHHIIIISSSSTTTTOOOORRRRYYYY  page has been marked dirty
  1207.           PPPPGGGGFFFF____VVVVAAAALLLLHHHHIIIISSSSTTTTOOOORRRRYYYY  page has been marked valid
  1208.           PPPPGGGGFFFF____CCCCLLLLEEEEAAAARRRR       clear valid & writeable bits in page table
  1209.  
  1210.      The pppprrrr____vvvvaaaalllluuuueeee field for each page contains either a reference count or a
  1211.      fault offset value if the PPPPGGGGFFFF____CCCCLLLLEEEEAAAARRRR operation was set on a previous call.
  1212.      This can be used to determine what function or variable inside a page
  1213.      that the process references or writes frequently.
  1214.  
  1215.    PPPPIIIIOOOOCCCCOOOOPPPPEEEENNNNMMMM
  1216.      The return value _r_e_t_v_a_l provides a read-only file descriptor for a mapped
  1217.      object associated with the traced process.  If _p is zero the traced
  1218.      process's _e_x_e_c(2)ed file is found.  This enables a debugger to find the
  1219.      object file symbol table without having to know the pathname of the
  1220.      executable file.  If _p is non-zero it points to a ccccaaaaddddddddrrrr____tttt containing a
  1221.      virtual address within the traced process and the mapped object, if any,
  1222.      associated with that address is found; this can be used to get a file
  1223.      descriptor for a shared library that is attached to the process.  On
  1224.      error (invalid address, physical device mapping, or no mapped object for
  1225.      the designated address), -1 is returned and errno is set to EINVAL.
  1226.  
  1227.    PPPPIIIIOOOOCCCCCCCCRRRREEEEDDDD
  1228.      Fetch the set of credentials associated with the process.  _p points to an
  1229.      instance of pppprrrrccccrrrreeeedddd____tttt that is filled by the operation.  The pppprrrrccccrrrreeeedddd
  1230.      structure contains at least the following fields:
  1231.  
  1232.           typedef struct prcred {
  1233.                uid_t     pr_euid;       /* Effective user id */
  1234.                uid_t     pr_ruid;       /* Real user id */
  1235.                uid_t     pr_suid;       /* Saved user id (from exec) */
  1236.                gid_t     pr_egid;       /* Effective group id */
  1237.                gid_t     pr_rgid;       /* Real group id */
  1238.                gid_t     pr_sgid;       /* Saved group id (from exec) */
  1239.                u_int     pr_ngroups;    /* Number of supplementary groups */
  1240.           } prcred_t;
  1241.  
  1242.  
  1243.    PPPPIIIIOOOOCCCCGGGGRRRROOOOUUUUPPPPSSSS
  1244.      Fetch the set of supplementary group IDs associated with the process.  _p
  1245.      points to an array of elements of type ggggiiiidddd____tttt, that will be filled by the
  1246.      operation.  PIOCCRED can be applied beforehand to determine the number of
  1247.      groups (pppprrrr____nnnnggggrrrroooouuuuppppssss) that will be returned and the amount of storage that
  1248.  
  1249.  
  1250.  
  1251.                                                                        PPPPaaaaggggeeee 11119999
  1252.  
  1253.  
  1254.  
  1255.  
  1256.  
  1257.  
  1258. pppprrrroooocccc((((4444))))                                                                pppprrrroooocccc((((4444))))
  1259.  
  1260.  
  1261.  
  1262.      should be allocated to hold them.
  1263.  
  1264.    PPPPIIIIOOOOCCCCTTTTLLLLBBBBMMMMIIIISSSSSSSS
  1265.      Enable special user TLB handling.  The TLB is a hardware coprocessor that
  1266.      makes virtual-to-physical address translations.  _p points to an integer
  1267.      that specifies the handling desired.  If the value is TTTTLLLLBBBB____CCCCOOOOUUUUNNNNTTTT, a record
  1268.      will be kept of every virtual-address TLB refill that occurs while the
  1269.      process mapped by _f_i_l_d_e_s is running.  If the value is TTTTLLLLBBBB____SSSSTTTTDDDD, counting
  1270.      will be disabled (the default mode).  It is important to note that
  1271.      monitoring TLB efficiency can be a useful tool, but the performance of
  1272.      the code that refills the TLB will be degraded.
  1273.  
  1274.      The TLB refill counts can be obtained by PPPPIIIIOOOOCCCCUUUUSSSSAAAAGGGGEEEE.  The ssssttttrrrruuuucccctttt pppprrrruuuussssaaaaggggeeee
  1275.      field ppppuuuu____uuuuttttllllbbbb accounts for TLB refills that occurred while the process
  1276.      was running in user mode, and the field ppppuuuu____kkkkttttllllbbbb accounts for refills that
  1277.      occurred while executing system calls on behalf of the user or while
  1278.      handling hardware interrupt code while the user process was scheduled.
  1279.  
  1280.    PPPPIIIIOOOOCCCCUUUUSSSSAAAAGGGGEEEE
  1281.      PIOCUSAGE returns process usage information.  _p points to a pppprrrruuuussssaaaaggggeeee
  1282.      structure that is filled by the operation.  The fields in a pppprrrruuuussssaaaaggggeeee
  1283.      structure are implementation dependent; no application can assume
  1284.      portability in this area.  See <_s_y_s/_p_r_o_c_f_s._h> for the exact definition
  1285.      for a particular implementation.
  1286.  
  1287.      The SGI implementation supports the following fields:
  1288.  
  1289.           typedef struct prusage {
  1290.                timespec_t  pu_tstamp;   /* time stamp */
  1291.                timespec_t  pu_starttime;     /* process start time */
  1292.                timespec_t  pu_utime;    /* user CPU time */
  1293.                timespec_t  pu_stime;    /* system CPU time */
  1294.                u_long    pu_minf;       /* minor (mapping) page faults */
  1295.                u_long    pu_majf;       /* major (disk) page faults */
  1296.                u_long    pu_utlb;       /* user TLB misses */
  1297.                u_long    pu_nswap;      /* number of swaps */
  1298.                u_long    pu_gbread;     /* gigabytes ... */
  1299.                u_long    pu_bread;      /*         and bytes read */
  1300.                u_long    pu_gbwrit;     /* gigabytes ... */
  1301.                u_long    pu_bwrit;      /*         and bytes written */
  1302.                u_long    pu_sigs;       /* signals received */
  1303.                u_long    pu_vctx;       /* voluntary context switches */
  1304.                u_long    pu_ictx;       /* involuntary context switches */
  1305.                u_long    pu_sysc;       /* system calls */
  1306.                u_long    pu_syscr;      /* read() system calls */
  1307.                u_long    pu_syscw;      /* write() system calls */
  1308.                u_long    pu_syscps;     /* poll() or select() system calls */
  1309.                u_long    pu_sysci;      /* ioctl() system calls */
  1310.                u_long    pu_graphfifo;  /* graphics pipeline stalls */
  1311.                u_long    pu_graph_req[8];    /* graphics resource requests */
  1312.                u_long    pu_graph_wait[8];   /* graphics resource waits */
  1313.                u_long    pu_size;       /* size of swappable image in pages */
  1314.  
  1315.  
  1316.  
  1317.                                                                        PPPPaaaaggggeeee 22220000
  1318.  
  1319.  
  1320.  
  1321.  
  1322.  
  1323.  
  1324. pppprrrroooocccc((((4444))))                                                                pppprrrroooocccc((((4444))))
  1325.  
  1326.  
  1327.  
  1328.               u_long     pu_rss;        /* resident size of swappable image */
  1329.                u_long    pu_inblock;    /* block input operations */
  1330.                u_long    pu_oublock;    /* block output operations */
  1331.                u_long    pu_vfault;     /* total number of vfaults */
  1332.                u_long    pu_ktlb;       /* kernel TLB misses */
  1333.           } prusage_t;
  1334.  
  1335.  
  1336.    PPPPIIIIOOOOCCCCGGGGEEEETTTTPPPPTTTTIIIIMMMMEEEERRRR
  1337.      PIOCGETPTIMER returns an array of timers indicating the amount of time
  1338.      the process has spent in each of the following states:
  1339.  
  1340.           #include <time.h>
  1341.           #include <sys/timers.h>
  1342.  
  1343.           struct timespec ptime[MAX_PROCTIMER];
  1344.  
  1345.  
  1346.           AAAASSSS____UUUUSSSSRRRR____RRRRUUUUNNNN      running in user mode
  1347.           AAAASSSS____SSSSYYYYSSSS____RRRRUUUUNNNN      running in system mode
  1348.           AAAASSSS____IIIINNNNTTTT____RRRRUUUUNNNN      running in interrupt mode
  1349.           AAAASSSS____BBBBIIIIOOOO____WWWWAAAAIIIITTTT     waiting for block I/O
  1350.           AAAASSSS____MMMMEEEEMMMM____WWWWAAAAIIIITTTT     waiting for memory
  1351.           AAAASSSS____SSSSEEEELLLLEEEECCCCTTTT____WWWWAAAAIIIITTTT  waiting in select
  1352.           AAAASSSS____JJJJCCCCLLLL____WWWWAAAAIIIITTTT     stopped because of job control
  1353.           AAAASSSS____RRRRUUUUNNNNQQQQ____WWWWAAAAIIIITTTT    waiting to run on run queue
  1354.           AAAASSSS____SSSSLLLLEEEEEEEEPPPP____WWWWAAAAIIIITTTT   waiting for resource
  1355.           AAAASSSS____SSSSTTTTRRRRMMMMOOOONNNN____WWWWAAAAIIIITTTT  waiting for the stream monitor
  1356.           AAAASSSS____PPPPHHHHYYYYSSSSIIIIOOOO____WWWWAAAAIIIITTTT  waiting for raw I/O
  1357.  
  1358.      _p is a pointer to an array of MMMMAAAAXXXX____PPPPRRRROOOOCCCCTTTTIIIIMMMMEEEERRRR ttttiiiimmmmeeeessssppppeeeecccc structures.
  1359.  
  1360.    PPPPIIIIOOOOCCCCOOOOPPPPEEEENNNNPPPPDDDD
  1361.      PIOCOPENPD is not currently implemented on SGI machines.  It is under
  1362.      consideration for future releases.
  1363.  
  1364.      The return value _r_e_t_v_a_l provides a read-only file descriptor for a ``page
  1365.      data file'', enabling tracking of address space references and
  1366.      modifications on a per-page basis.
  1367.  
  1368.      A _r_e_a_d(2) of the page data file descriptor returns structured page data
  1369.      and atomically clears the page data maintained for the file by the
  1370.      system.  That is to say, each read returns data collected since the last
  1371.      read; the first read returns data collected since the file was opened.
  1372.      When the call completes, the read buffer contains the following structure
  1373.      as its header and thereafter contains a number of variable length
  1374.      structures that must be accessed by walking linearly through the buffer.
  1375.  
  1376.           typedef struct prpageheader {
  1377.                timespec_t tstamp;  /* real time time stamp */
  1378.                u_long    nmap;     /* number of address space mappings */
  1379.                u_long    npage;    /* total number of pages */
  1380.  
  1381.  
  1382.  
  1383.                                                                        PPPPaaaaggggeeee 22221111
  1384.  
  1385.  
  1386.  
  1387.  
  1388.  
  1389.  
  1390. pppprrrroooocccc((((4444))))                                                                pppprrrroooocccc((((4444))))
  1391.  
  1392.  
  1393.  
  1394.           } prpageheader_t;
  1395.  
  1396.      The header is followed by nnnnmmmmaaaapppp variable-length pppprrrraaaassssmmmmaaaapppp structures:
  1397.  
  1398.           typedef struct prasmap {
  1399.                caddr_t   vaddr;    /* virtual address */
  1400.                u_long    npage;    /* number of pages in mapping */
  1401.                u_char    data[1];  /* referenced, modified, present flags */
  1402.           } prasmap_t;
  1403.  
  1404.      The ddddaaaattttaaaa[[[[]]]] array is of variable length, with one entry for each page in
  1405.      the mapping, nnnnppppaaaaggggeeee entries altogether, rounded up with empty entries at
  1406.      the end so that the structure size is an integral numbers of long's.
  1407.      ddddaaaattttaaaa[[[[]]]] entries may contain these flags:
  1408.  
  1409.           PPPPGGGG____PPPPRRRREEEESSSSEEEENNNNTTTT      page is resident in memory now
  1410.           PPPPGGGG____RRRREEEEFFFFEEEERRRREEEENNNNCCCCEEEEDDDD   page has been referenced since last read
  1411.           PPPPGGGG____MMMMOOOODDDDIIIIFFFFIIIIEEEEDDDD     page has been modified since last read
  1412.  
  1413.      If the read buffer is not large enough to contain all of the page data,
  1414.      the read fails with E2BIG and the page data is not cleared.  The required
  1415.      size of the read buffer can be determined through _f_s_t_a_t(2).  Application
  1416.      of _l_s_e_e_k(2) to the page data file descriptor is ineffective.  Closing the
  1417.      page data file terminates the system overhead associated with collecting
  1418.      the data.
  1419.  
  1420.    PPPPIIIIOOOOCCCCGGGGEEEETTTTPPPPRRRR PPPPIIIIOOOOCCCCGGGGEEEETTTTUUUU
  1421.      These operations copy, respectively, the traced process's _p_r_o_c structure
  1422.      and _u_s_e_r _a_r_e_a into the buffer addressed by _p.  They are provided for
  1423.      completeness but it should be unnecessary to access either of these
  1424.      structures directly since relevant status information is available
  1425.      through other control operations.  Their use is discouraged because a
  1426.      program making use of them is tied to a particular version of the
  1427.      operating system.
  1428.  
  1429.      PIOCGETPR can be applied to a _z_o_m_b_i_e process (see PIOCPSINFO).
  1430.  
  1431.    PPPPIIIIOOOOCCCCAAAACCCCIIIINNNNFFFFOOOO
  1432.      PIOCACINFO returns the currently accumulated accounting information for
  1433.      the process.  _p points to a pppprrrraaaacccciiiinnnnffffoooo structure that is filled in by the
  1434.      operation.  The fields in pppprrrraaaacccciiiinnnnffffoooo are implementation dependent; no
  1435.      application can assume portability in this area.  See <_s_y_s/_p_r_o_c_f_s._h> and
  1436.      <_s_y_s/_e_x_t_a_c_c_t._h> for the exact definition of a particular implementation.
  1437.  
  1438.      The SGI implementation supports the following fields:
  1439.  
  1440.           typedef struct pracinfo {
  1441.                char      pr_version;    /* Accounting data version */
  1442.                char      pr_flag;       /* Miscellaneous flags */
  1443.                char      pr_nice;       /* Nice value */
  1444.                unchar    pr_sched;      /* Scheduling discipline */
  1445.                                         /* (see sys/schedctl.h) */
  1446.  
  1447.  
  1448.  
  1449.                                                                        PPPPaaaaggggeeee 22222222
  1450.  
  1451.  
  1452.  
  1453.  
  1454.  
  1455.  
  1456. pppprrrroooocccc((((4444))))                                                                pppprrrroooocccc((((4444))))
  1457.  
  1458.  
  1459.  
  1460.               __int32_t  pr_spare1;     /* reserved */
  1461.                ash_t     pr_ash;        /* Array session handle */
  1462.                prid_t    pr_prid;       /* Project ID */
  1463.                time_t    pr_btime;      /* Begin time (in secs since 1970)*/
  1464.                time_t    pr_etime;      /* Elapsed time (in HZ) */
  1465.                __int32_t pr_spare2[2];  /* reserved */
  1466.                struct acct_timers  pr_timers; /* Assorted timers: see extacct.h */
  1467.                struct acct_counts  pr_counts; /* Assorted counters: (ditto) */
  1468.                __int64_t pr_spare3[8];  /* reserved */
  1469.           } pracinfo_t;
  1470.  
  1471.  
  1472.    PPPPIIIIOOOOCCCCGGGGEEEETTTTSSSSNNNN0000EEEEXXXXTTTTRRRREEEEFFFFCCCCNNNNTTTTRRRRSSSS PPPPIIIIOOOOCCCCGGGGEEEETTTTSSSSNNNN0000RRRREEEEFFFFCCCCNNNNTTTTRRRRSSSS
  1473.      PIOCGETSN0EXTREFCNTRS returns the extended memory reference counter
  1474.      values in an Origin system for a specified virtual address space range.
  1475.      See refcnt(5).
  1476.  
  1477.      The third argument is used to specify the virtual address space range and
  1478.      the user buffer where to store the counter values. This argument is of
  1479.      type sn0_refcnt_args_t, as defined in <sys/SN/hwcntrs.h>:
  1480.  
  1481.           typedef struct sn0_refcnt_args {
  1482.                   caddr_t             vaddr;
  1483.                   long                len;
  1484.                   sn0_refcnt_buf_t*   buf;
  1485.           } sn0_refcnt_args_t;
  1486.  
  1487.  
  1488.      The first field vvvvaaaaddddddddrrrr is the base of the virtual address space range, the
  1489.      field lllleeeennnn is the corresponding length in bytes, and the field bbbbuuuuffff is a
  1490.      pointer to a user buffer where the system will store the counter values
  1491.      and additional information. This buffer is an array of elements of type
  1492.      sn0_refcnt_buf_t, where each element corresponds to the counter
  1493.      information associated with one hardware page:
  1494.  
  1495.           typedef struct sn0_refcnt_buf {
  1496.                sn0_refcnt_set_t   refcnt_set;
  1497.                __uint64_t         paddr;
  1498.                   __uint64_t         page_size;
  1499.                   cnodeid_t          cnodeid;
  1500.           } sn0_refcnt_buf_t;
  1501.  
  1502.  
  1503.      The field rrrreeeeffffccccnnnntttt____sssseeeetttt contains the set of counters associated with the
  1504.      virtual address passed via ssssnnnn0000____rrrreeeeffffccccnnnntttt____aaaarrrrggggssss, ppppaaaaddddddddrrrr is the address of the
  1505.      physical page associated with this virtual address, ppppaaaaggggeeee____ssssiiiizzzzeeee is the page
  1506.      size being used to map it, and ccccnnnnooooddddeeeeiiiidddd is the physical page home node,
  1507.      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
  1508.      to node names using the command topology(1).  The rrrreeeeffffccccnnnntttt____sssseeeetttt type is
  1509.      defined by
  1510.  
  1511.  
  1512.  
  1513.  
  1514.  
  1515.                                                                        PPPPaaaaggggeeee 22223333
  1516.  
  1517.  
  1518.  
  1519.  
  1520.  
  1521.  
  1522. pppprrrroooocccc((((4444))))                                                                pppprrrroooocccc((((4444))))
  1523.  
  1524.  
  1525.  
  1526.           typedef struct sn0_refcnt_set {
  1527.                   refcnt_t    refcnt[SN0_REFCNT_MAX_COUNTERS];
  1528.                   __uint64_t  flags;
  1529.           } sn0_refcnt_set_t;
  1530.  
  1531.  
  1532.      The field rrrreeeeffffccccnnnntttt is the actual set of counters (one counter per node),
  1533.      and ffffllllaaaaggggssss is a state vector reserved for future use.  The counters in
  1534.      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
  1535.      as ccccnnnnooooddddeeeeiiiiddddssss (numa(5)).
  1536.  
  1537.  
  1538.      PIOCGETSN0REFCNTRS instructs the system to return the actual hardware
  1539.      counter values instead of the extended software counter values returned
  1540.      by PIOCGETSN0EXTREFCNTRS.
  1541.  
  1542.      The following section of code shows an example of use for this interface:
  1543.  
  1544.           #include <sys/types.h>
  1545.           #include <stdio.h>
  1546.           #include <malloc.h>
  1547.           #include <sys/stat.h>
  1548.           #include <fcntl.h>
  1549.           #include <sys/prctl.h>
  1550.           #include <procfs/procfs.h>
  1551.           #include <sys/syssgi.h>
  1552.           #include <sys/sysmp.h>
  1553.           #include <sys/SN/hwcntrs.h>
  1554.  
  1555.           /*
  1556.            * This routine makes two assumptions that may not
  1557.            * be true in all systems:
  1558.            * Length of hardware page (counter granularity): 0x1000 bytes
  1559.            * Length of base software page (smallest mappable memory area): 0x4000 bytes
  1560.            */
  1561.  
  1562.           void
  1563.           print_refcounters(char* vaddr, int len)
  1564.           {
  1565.                   pid_t pid = getpid();
  1566.                   char  pfile[256];
  1567.                   int fd;
  1568.                   sn0_refcnt_buf_t* refcnt_buffer;
  1569.                   sn0_refcnt_buf_t* direct_refcnt_buffer;
  1570.                   sn0_refcnt_args_t* refcnt_args;
  1571.                   int npages;
  1572.                   int gen_start;
  1573.                   int numnodes;
  1574.                   int page;
  1575.                   int node;
  1576.  
  1577.                   sprintf(pfile, "/proc/%05d", pid);
  1578.  
  1579.  
  1580.  
  1581.                                                                        PPPPaaaaggggeeee 22224444
  1582.  
  1583.  
  1584.  
  1585.  
  1586.  
  1587.  
  1588. pppprrrroooocccc((((4444))))                                                                pppprrrroooocccc((((4444))))
  1589.  
  1590.  
  1591.  
  1592.                   if ((fd = open(pfile, O_RDONLY)) < 0) {
  1593.                     fprintf(stderr,"Can't open /proc/%d", pid);
  1594.                     exit(1);
  1595.                }
  1596.  
  1597.                   vaddr = (char *)( (unsigned long)vaddr & ~0xfff );
  1598.                   npages = (len + 0xfff) >> 12;
  1599.  
  1600.                   if ((refcnt_buffer = malloc(sizeof(sn0_refcnt_buf_t) * npages)) == NULL) {
  1601.                           perror("malloc refcnt_buffer");
  1602.                           exit(1);
  1603.                   }
  1604.  
  1605.                   if ((direct_refcnt_buffer = malloc(sizeof(sn0_refcnt_buf_t) * npages)) == NULL) {
  1606.                           perror("malloc refcnt_buffer");
  1607.                           exit(1);
  1608.                   }
  1609.  
  1610.                   if ((refcnt_args = malloc(sizeof(sn0_refcnt_args_t))) == NULL) {
  1611.                           perror("malloc refcnt_args");
  1612.                           exit(1);
  1613.                   }
  1614.  
  1615.                   refcnt_args->vaddr = vaddr;
  1616.                   refcnt_args->len = len;
  1617.                   refcnt_args->buf = refcnt_buffer;
  1618.  
  1619.                   if ((gen_start = ioctl(fd, PIOCGETSN0EXTREFCNTRS, (void *)refcnt_args)) < 0) {
  1620.                     perror("ioctl  PIOCGETSN0EXTREFCNTRS returns error");
  1621.                     exit(1);
  1622.                }
  1623.  
  1624.                   refcnt_args->vaddr = vaddr;
  1625.                   refcnt_args->len = len;
  1626.                   refcnt_args->buf = direct_refcnt_buffer;
  1627.                   if ((gen_start = ioctl(fd, PIOCGETSN0REFCNTRS, (void *)refcnt_args)) < 0) {
  1628.                     perror("ioctl  PIOCGETSN0REFCNTRS returns error");
  1629.                     exit(1);
  1630.                }
  1631.  
  1632.                   if ((numnodes = sysmp(MP_NUMNODES)) < 0) {
  1633.                           perror("sysmp MP_NUMNODES");
  1634.                           exit(1);
  1635.                   }
  1636.  
  1637.                   for (page = 0; page < npages; page++) {
  1638.                           printf("page[%05d, 0x%lx, 0x%llx (0x%llx)]:",
  1639.                                  page,
  1640.                                  vaddr + page*0x1000,
  1641.                                  refcnt_buffer[page].paddr,
  1642.                                  refcnt_buffer[page].paddr >> 14);
  1643.                           for (node = 0; node < numnodes; node++) {
  1644.  
  1645.  
  1646.  
  1647.                                                                        PPPPaaaaggggeeee 22225555
  1648.  
  1649.  
  1650.  
  1651.  
  1652.  
  1653.  
  1654. pppprrrroooocccc((((4444))))                                                                pppprrrroooocccc((((4444))))
  1655.  
  1656.  
  1657.  
  1658.                                   printf(" %05lld (%06lld)",
  1659.                                          refcnt_buffer[page].refcnt_set.refcnt[node],
  1660.                                          direct_refcnt_buffer[page].refcnt_set.refcnt[node]);
  1661.                           }
  1662.                           printf("0);
  1663.                   }
  1664.  
  1665.                   close(fd);
  1666.                   free(refcnt_args);
  1667.                   free(refcnt_buffer);
  1668.           }
  1669.  
  1670.  
  1671.    PPPPIIIIOOOOCCCCGGGGEEEETTTTIIIINNNNOOOODDDDEEEE
  1672.      PIOCGETINODE returns information about an open file for the process.  _p
  1673.      points to a pppprrrriiiinnnnooooddddeeeeiiiinnnnffffoooo structure containing the file descriptor of
  1674.      interest (in ppppiiii____ffffdddd).  On return ppppiiii____ddddeeeevvvv, ppppiiii____iiiinnnnuuuummmm, and ppppiiii____ggggeeeennnn contain the
  1675.      filesystem device, inode number, and inode generation number
  1676.      respectively.  Further information about the file can then be obtained
  1677.      through _s_y_s_s_g_i(SSSSGGGGIIII____FFFFSSSS____BBBBUUUULLLLKKKKSSSSTTTTAAAATTTT), for instance.  The ppppiiii____ddddeeeevvvv value matches
  1678.      that returned by _s_t_a_t_v_f_s (ffff____ffffssssiiiidddd) and _s_t_a_t (sssstttt____ddddeeeevvvv).  Bad values for
  1679.      ppppiiii____ffffdddd result in EBADF errors; if the referenced file is actually a socket
  1680.      then errno is set to EINVAL.  Filesystems other than XFS and EFS return 0
  1681.      for the ppppiiii____ggggeeeennnn value.
  1682.  
  1683. NNNNOOOOTTTTEEEESSSS
  1684.      Each operation (_i_o_c_t_l or I/O) is guaranteed to be atomic with respect to
  1685.      the traced process, except when applied to a system process.
  1686.  
  1687.      To wait for one or more of a set of processes to stop, /_p_r_o_c file
  1688.      descriptors can be used in a _p_o_l_l(2) system call.  On successful return,
  1689.      the polling event POLLPRI indicates that the process has stopped on an
  1690.      ``event of interest'' (see PPPPIIIIOOOOCCCCSSSSTTTTOOOOPPPP above).  Although they cannot be
  1691.      requested, the polling events POLLHUP, POLLERR and POLLNVAL may be
  1692.      returned.  POLLHUP indicates that the process has terminated.  POLLERR
  1693.      indicates that the file descriptor has become invalid.  POLLNVAL is
  1694.      returned immediately if POLLPRI is requested on a file descriptor
  1695.      referring to either itself or a system process (see PIOCSTOP).  /_p_r_o_c
  1696.      file descriptors may also be used in a _s_e_l_e_c_t(2) system call.  Selecting
  1697.      for an exceptional event has the same semantics as polling for POLLPRI.
  1698.      Selecting for reading or writing or polling for POLLIN or POLLOUT will
  1699.      always return true.  See the _p_o_l_l(2) and _s_e_l_e_c_t(2) man pages for further
  1700.      details.
  1701.  
  1702.      _p_o_l_l() or _s_e_l_e_c_t() may not be used on the /proc directory itself.
  1703.  
  1704.      For security reasons, except for the superuser, an open of a /_p_r_o_c file
  1705.      fails unless both the user-ID and group-ID of the caller match those of
  1706.      the traced process and the process's object file is readable by the
  1707.      caller.  Files corresponding to setuid and setgid processes can be opened
  1708.      only by the superuser.  Even if held by the superuser, an open process
  1709.      file descriptor becomes invalid if the traced process performs an _e_x_e_c()
  1710.  
  1711.  
  1712.  
  1713.                                                                        PPPPaaaaggggeeee 22226666
  1714.  
  1715.  
  1716.  
  1717.  
  1718.  
  1719.  
  1720. pppprrrroooocccc((((4444))))                                                                pppprrrroooocccc((((4444))))
  1721.  
  1722.  
  1723.  
  1724.      of a setuid/setgid object file or an object file that it cannot read.
  1725.      Any operation performed on an invalid file descriptor, except _c_l_o_s_e(2),
  1726.      fails with EAGAIN.  In this situation, if any tracing flags are set and
  1727.      the process file descriptor is open for writing, the process will have
  1728.      been directed to stop and its run-on-last-close flag will have been set
  1729.      (see PIOCSET).  This enables a controlling process (if it has permission)
  1730.      to reopen the process file to get a new valid file descriptor, close the
  1731.      invalid file descriptor, and proceed.  Just closing the invalid file
  1732.      descriptor causes the traced process to resume execution with no tracing
  1733.      flags set.  Any process not currently open for writing via /_p_r_o_c but that
  1734.      has left-over tracing flags from a previous open and that _e_x_e_cs a
  1735.      setuid/setgid or unreadable object file will not be stopped but will have
  1736.      all its tracing flags cleared.
  1737.  
  1738.      Descriptions of structures in this document include only interesting
  1739.      structure elements, not filler and padding fields, and may show elements
  1740.      out of order for descriptive clarity.  The actual structure definitions
  1741.      are contained in <_s_y_s/_p_r_o_c_f_s._h>.
  1742.  
  1743.      For reasons of symmetry and efficiency there are more control operations
  1744.      than strictly necessary.
  1745.  
  1746.      Programs compiled with the old 32-bit abi calling convention can perform
  1747.      ioctls on programs compiled with the new 32-bit abi or 64-bit abi calling
  1748.      conventions by "or'ing" the ioctl with PIOC_IRIX5_N32 or PIOC_IRIX5_64,
  1749.      respectively, and passing in a pointer to a buffer that is big enough to
  1750.      hold the larger structure.
  1751.  
  1752. FFFFIIIILLLLEEEESSSS
  1753.      /proc           directory (list of active processes)
  1754.      /proc/_n_n_n_n_n     process image
  1755.  
  1756. SSSSEEEEEEEE AAAALLLLSSSSOOOO
  1757.      mntproc(1M), ioctl(2), open(2), poll(2), ptrace(2), sigaction(2),
  1758.      signal(2), stat(2), statvfs(2), syssgi(2), siginfo(5), signal(5).
  1759.  
  1760. DDDDIIIIAAAAGGGGNNNNOOOOSSSSTTTTIIIICCCCSSSS
  1761.      Errors that can occur in addition to the errors normally associated with
  1762.      filesystem access:
  1763.  
  1764.      ENOENT          The traced process has terminated after being opened.
  1765.  
  1766.      EIO             I/O was attempted at an illegal address in the traced
  1767.                      process.
  1768.  
  1769.      ENXIO           I/O was attempted to an isolated processes address space.
  1770.  
  1771.      EBADF           An I/O or _i_o_c_t_l operation requiring write access was
  1772.                      attempted on a file descriptor not open for writing;
  1773.                      PIOCGETINODE was applied to a process file which was not
  1774.                      open.
  1775.  
  1776.  
  1777.  
  1778.  
  1779.                                                                        PPPPaaaaggggeeee 22227777
  1780.  
  1781.  
  1782.  
  1783.  
  1784.  
  1785.  
  1786. pppprrrroooocccc((((4444))))                                                                pppprrrroooocccc((((4444))))
  1787.  
  1788.  
  1789.  
  1790.      EBUSY           PIOCSTOP or PIOCWSTOP was applied to a system process; an
  1791.                      exclusive _o_p_e_n(2) was attempted on a process file already
  1792.                      open for writing; an _o_p_e_n(2) for writing was attempted
  1793.                      and an exclusive open is in effect on the process file;
  1794.                      PIOCRUN, PIOCSREG or PIOCSFPREG was applied to a process
  1795.                      not stopped on an event of interest; an attempt was made
  1796.                      to mount /_p_r_o_c when it is already mounted.
  1797.  
  1798.      EPERM           Someone other than the superuser attempted to better a
  1799.                      process's priority by issuing PIOCNICE.
  1800.  
  1801.      ENOSYS          An attempt was made to perform an unsupported operation
  1802.                      (such as create, remove, link, or unlink) on an entry in
  1803.                      /_p_r_o_c.
  1804.  
  1805.      EFAULT          An I/O or _i_o_c_t_l request referred to an invalid address in
  1806.                      the controlling process.
  1807.  
  1808.      EINVAL          In general this means that some invalid argument was
  1809.                      supplied to a system call.  The list of conditions
  1810.                      eliciting this error includes:  the _i_o_c_t_l code is
  1811.                      undefined; the _i_o_c_t_l code is not implemented; an _i_o_c_t_l
  1812.                      operation was issued on a file descriptor referring to
  1813.                      the /_p_r_o_c directory; an out-of-range signal number was
  1814.                      specified with PIOCSSIG, PIOCKILL, or PIOCUNKILL; SIGKILL
  1815.                      was specified with PIOCUNKILL; an illegal virtual address
  1816.                      was specified in a PIOCOPENM request; overlapping watched
  1817.                      areas were specified in a PIOCSWATCH request; an attempt
  1818.                      was made to establish more than the supported number of
  1819.                      watched areas in a PIOCSWATCH request; PIOCGFPREG or
  1820.                      PIOCSFPREG was issued on a machine without floating-point
  1821.                      hardware; the file specified to PIOCGETINODE is a socket.
  1822.  
  1823.      E2BIG           Data to be returned in a _r_e_a_d(2) of the page data file
  1824.                      exceeds the size of the read buffer provided by the
  1825.                      caller.
  1826.  
  1827.      EINTR           A signal was received by the controlling process while
  1828.                      waiting for the traced process to stop via PIOCSTOP or
  1829.                      PIOCWSTOP.
  1830.  
  1831.      EAGAIN          The traced process has performed an _e_x_e_c of a
  1832.                      setuid/setgid object file or of an object file that it
  1833.                      cannot read; all further operations on the process file
  1834.                      descriptor (except _c_l_o_s_e(2)) elicit this error.
  1835.  
  1836. BBBBUUUUGGGGSSSS
  1837.      When a signal is sent to the target process, but it is cleared (either by
  1838.      PIOCUNKILL or by using the PRCSIG flag to PIOCRUN), most system calls
  1839.      complete normally and do not return EINTR.  However, the specific system
  1840.      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)
  1841.      to the _i_m_o_n(7M) device are interrupted and do return EINTR.
  1842.  
  1843.  
  1844.  
  1845.                                                                        PPPPaaaaggggeeee 22228888
  1846.  
  1847.  
  1848.  
  1849.