Print this page
3946 ::gcore
Reviewed by: Adam Leventhal <ahl@delphix.com>
Reviewed by: Matthew Ahrens <mahrens@delphix.com>

Split Close
Expand all
Collapse all
          --- old/usr/src/lib/libproc/common/libproc.h
          +++ new/usr/src/lib/libproc/common/libproc.h
↓ open down ↓ 18 lines elided ↑ open up ↑
  19   19   * CDDL HEADER END
  20   20   */
  21   21  
  22   22  /*
  23   23   * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
  24   24   * Use is subject to license terms.
  25   25   *
  26   26   * Portions Copyright 2007 Chad Mynhier
  27   27   * Copyright 2012 DEY Storage Systems, Inc.  All rights reserved.
  28   28   * Copyright (c) 2013, Joyent, Inc. All rights reserved.
       29 + * Copyright (c) 2013 by Delphix. All rights reserved.
  29   30   */
  30   31  
  31   32  /*
  32   33   * Interfaces available from the process control library, libproc.
  33   34   *
  34   35   * libproc provides process control functions for the /proc tools
  35   36   * (commands in /usr/proc/bin), /usr/bin/truss, and /usr/bin/gcore.
  36   37   * libproc is a private support library for these commands only.
  37   38   * It is _not_ a public interface, although it might become one
  38   39   * in the fullness of time, when the interfaces settle down.
↓ open down ↓ 81 lines elided ↑ open up ↑
 120  121  #define PS_LOST         3       /* process is lost to control (EAGAIN) */
 121  122  #define PS_UNDEAD       4       /* process is terminated (zombie) */
 122  123  #define PS_DEAD         5       /* process is terminated (core file) */
 123  124  #define PS_IDLE         6       /* process has not been run */
 124  125  
 125  126  /* Flags accepted by Pgrab() */
 126  127  #define PGRAB_RETAIN    0x01    /* Retain tracing flags, else clear flags */
 127  128  #define PGRAB_FORCE     0x02    /* Open the process w/o O_EXCL */
 128  129  #define PGRAB_RDONLY    0x04    /* Open the process or core w/ O_RDONLY */
 129  130  #define PGRAB_NOSTOP    0x08    /* Open the process but do not stop it */
      131 +#define PGRAB_INCORE    0x10    /* Use in-core data to build symbol tables */
 130  132  
 131  133  /* Error codes from Pcreate() */
 132  134  #define C_STRANGE       -1      /* Unanticipated error, errno is meaningful */
 133  135  #define C_FORK          1       /* Unable to fork */
 134  136  #define C_PERM          2       /* No permission (file set-id or unreadable) */
 135  137  #define C_NOEXEC        3       /* Cannot execute file */
 136  138  #define C_INTR          4       /* Interrupt received while creating */
 137  139  #define C_LP64          5       /* Program is _LP64, self is _ILP32 */
 138  140  #define C_NOENT         6       /* Cannot find executable file */
 139  141  
↓ open down ↓ 41 lines elided ↑ open up ↑
 181  183  #define AI_OUTPUT       2
 182  184  #define AI_INOUT        3
 183  185  
 184  186  /* maximum number of syscall arguments */
 185  187  #define MAXARGS         8
 186  188  
 187  189  /* maximum size in bytes of a BYREF argument */
 188  190  #define MAXARGL         (4*1024)
 189  191  
 190  192  /*
      193 + * Ops vector definition for the Pgrab_ops().
      194 + */
      195 +typedef ssize_t (*pop_pread_t)(struct ps_prochandle *, void *, size_t,
      196 +    uintptr_t, void *);
      197 +typedef ssize_t (*pop_pwrite_t)(struct ps_prochandle *, const void *, size_t,
      198 +    uintptr_t, void *);
      199 +typedef int (*pop_read_maps_t)(struct ps_prochandle *, prmap_t **, ssize_t *,
      200 +    void *);
      201 +typedef void (*pop_read_aux_t)(struct ps_prochandle *, auxv_t **, int *,
      202 +    void *);
      203 +typedef int (*pop_cred_t)(struct ps_prochandle *, prcred_t *, int,
      204 +    void *);
      205 +typedef int (*pop_priv_t)(struct ps_prochandle *, prpriv_t **, void *);
      206 +typedef const psinfo_t *(*pop_psinfo_t)(struct ps_prochandle *, psinfo_t *,
      207 +    void *);
      208 +typedef void (*pop_status_t)(struct ps_prochandle *, pstatus_t *, void *);
      209 +typedef prheader_t *(*pop_lstatus_t)(struct ps_prochandle *, void *);
      210 +typedef prheader_t *(*pop_lpsinfo_t)(struct ps_prochandle *, void *);
      211 +typedef void (*pop_fini_t)(struct ps_prochandle *, void *);
      212 +typedef char *(*pop_platform_t)(struct ps_prochandle *, char *, size_t, void *);
      213 +typedef int (*pop_uname_t)(struct ps_prochandle *, struct utsname *, void *);
      214 +typedef char *(*pop_zonename_t)(struct ps_prochandle *, char *, size_t, void *);
      215 +typedef char *(*pop_execname_t)(struct ps_prochandle *, char *, size_t, void *);
      216 +#if defined(__i386) || defined(__amd64)
      217 +typedef int (*pop_ldt_t)(struct ps_prochandle *, struct ssd *, int, void *);
      218 +#endif
      219 +
      220 +typedef struct ps_ops {
      221 +        pop_pread_t             pop_pread;
      222 +        pop_pwrite_t            pop_pwrite;
      223 +        pop_read_maps_t         pop_read_maps;
      224 +        pop_read_aux_t          pop_read_aux;
      225 +        pop_cred_t              pop_cred;
      226 +        pop_priv_t              pop_priv;
      227 +        pop_psinfo_t            pop_psinfo;
      228 +        pop_status_t            pop_status;
      229 +        pop_lstatus_t           pop_lstatus;
      230 +        pop_lpsinfo_t           pop_lpsinfo;
      231 +        pop_fini_t              pop_fini;
      232 +        pop_platform_t          pop_platform;
      233 +        pop_uname_t             pop_uname;
      234 +        pop_zonename_t          pop_zonename;
      235 +        pop_execname_t          pop_execname;
      236 +#if defined(__i386) || defined(__amd64)
      237 +        pop_ldt_t               pop_ldt;
      238 +#endif
      239 +} ps_ops_t;
      240 +
      241 +/*
 191  242   * Function prototypes for routines in the process control package.
 192  243   */
 193  244  extern struct ps_prochandle *Pcreate(const char *, char *const *,
 194  245      int *, char *, size_t);
 195  246  extern struct ps_prochandle *Pxcreate(const char *, char *const *,
 196  247      char *const *, int *, char *, size_t);
 197  248  
 198  249  extern const char *Pcreate_error(int);
 199  250  
 200  251  extern struct ps_prochandle *Pgrab(pid_t, int, int *);
 201  252  extern struct ps_prochandle *Pgrab_core(const char *, const char *, int, int *);
 202  253  extern struct ps_prochandle *Pfgrab_core(int, const char *, int *);
 203  254  extern struct ps_prochandle *Pgrab_file(const char *, int *);
      255 +extern struct ps_prochandle *Pgrab_ops(pid_t, void *, const ps_ops_t *, int);
 204  256  extern const char *Pgrab_error(int);
 205  257  
 206  258  extern  int     Preopen(struct ps_prochandle *);
 207  259  extern  void    Prelease(struct ps_prochandle *, int);
 208  260  extern  void    Pfree(struct ps_prochandle *);
 209  261  
 210  262  extern  int     Pasfd(struct ps_prochandle *);
 211  263  extern  char   *Pbrandname(struct ps_prochandle *, char *, size_t);
 212  264  extern  int     Pctlfd(struct ps_prochandle *);
 213  265  extern  int     Pcreate_agent(struct ps_prochandle *);
 214  266  extern  void    Pdestroy_agent(struct ps_prochandle *);
 215  267  extern  int     Pstopstatus(struct ps_prochandle *, long, uint_t);
 216  268  extern  int     Pwait(struct ps_prochandle *, uint_t);
 217  269  extern  int     Pstop(struct ps_prochandle *, uint_t);
 218  270  extern  int     Pdstop(struct ps_prochandle *);
 219  271  extern  int     Pstate(struct ps_prochandle *);
 220  272  extern  const psinfo_t *Ppsinfo(struct ps_prochandle *);
 221  273  extern  const pstatus_t *Pstatus(struct ps_prochandle *);
 222  274  extern  int     Pcred(struct ps_prochandle *, prcred_t *, int);
 223  275  extern  int     Psetcred(struct ps_prochandle *, const prcred_t *);
 224      -extern  ssize_t Ppriv(struct ps_prochandle *, prpriv_t *, size_t);
      276 +extern  int     Ppriv(struct ps_prochandle *, prpriv_t **);
 225  277  extern  int     Psetpriv(struct ps_prochandle *, prpriv_t *);
 226  278  extern  void   *Pprivinfo(struct ps_prochandle *);
 227  279  extern  int     Psetzoneid(struct ps_prochandle *, zoneid_t);
 228  280  extern  int     Pgetareg(struct ps_prochandle *, int, prgreg_t *);
 229  281  extern  int     Pputareg(struct ps_prochandle *, int, prgreg_t);
 230  282  extern  int     Psetrun(struct ps_prochandle *, int, int);
 231  283  extern  ssize_t Pread(struct ps_prochandle *, void *, size_t, uintptr_t);
 232  284  extern  ssize_t Pread_string(struct ps_prochandle *, char *, size_t, uintptr_t);
 233  285  extern  ssize_t Pwrite(struct ps_prochandle *, const void *, size_t, uintptr_t);
 234  286  extern  int     Pclearsig(struct ps_prochandle *);
↓ open down ↓ 495 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX