< prev index next >

agent/src/os/solaris/proc/salibproc.h

Print this page


   1 /*
   2  * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *


  29  * We used to use the copy of it from Solaris 8.0. But there are
  30  * problems with that approach in building this library across Solaris
  31  * versions.  Solaris 10 has libproc.h in /usr/include. And libproc.h
  32  * varies slightly across Solaris versions. On Solaris 9, we get
  33  * 'sysret_t multiply defined' error. This is common minimum subset we
  34  * really need from libproc.h. The libproc.h in the current dir has
  35  * been left for reference and not used in build.
  36  */
  37 
  38 #include <dlfcn.h>
  39 #include <gelf.h>
  40 #include <procfs.h>
  41 #include <proc_service.h>
  42 #include <fcntl.h>
  43 #include <unistd.h>
  44 
  45 #ifdef __cplusplus
  46 extern "C" {
  47 #endif
  48 











  49 /*
  50  * 'object_name' is the name of a load object obtained from an
  51  * iteration over the process's address space mappings (Pmapping_iter),
  52  * or an iteration over the process's mapped objects (Pobject_iter),
  53  * or else it is one of the special PR_OBJ_* values above.
  54  */
  55 
  56 extern int Plookup_by_addr(struct ps_prochandle *,
  57     uintptr_t, char *, size_t, GElf_Sym *);
  58 

  59 typedef int proc_map_f(void *, const prmap_t *, const char *);
  60 extern int Pobject_iter(struct ps_prochandle *, proc_map_f *, void *);
  61 
  62 /*
  63  * Utility functions for processing arguments which should be /proc files,
  64  * pids, and/or core files.  The returned error code can be passed to
  65  * Pgrab_error() in order to convert it to an error string.
  66  */
  67 #define PR_ARG_PIDS     0x1     /* Allow pid and /proc file arguments */
  68 #define PR_ARG_CORES    0x2     /* Allow core file arguments */
  69 #define PR_ARG_ANY      (PR_ARG_PIDS | PR_ARG_CORES)
  70 
  71 /* Flags accepted by Pgrab() (partial) */
  72 #define PGRAB_FORCE     0x02    /* Open the process w/o O_EXCL */
  73 
  74 /* Error codes from Pgrab(), Pfgrab_core(), and Pgrab_core() */
  75 #define G_STRANGE       -1      /* Unanticipated error, errno is meaningful */
  76 #define G_NOPROC        1       /* No such process */
  77 #define G_NOCORE        2       /* No such core file */
  78 #define G_NOPROCORCORE  3       /* No such proc or core (for proc_arg_grab) */
  79 #define G_NOEXEC        4       /* Cannot locate executable file */
  80 #define G_ZOMB          5       /* Zombie process */
  81 #define G_PERM          6       /* No permission */
  82 #define G_BUSY          7       /* Another process has control */
  83 #define G_SYS           8       /* System process */
  84 #define G_SELF          9       /* Process is self */
  85 #define G_INTR          10      /* Interrupt received while grabbing */
  86 #define G_LP64          11      /* Process is _LP64, self is ILP32 */
  87 #define G_FORMAT        12      /* File is not an ELF format core file */
  88 #define G_ELF           13      /* Libelf error, elf_errno() is meaningful */
  89 #define G_NOTE          14      /* Required PT_NOTE Phdr not present in core */
  90 
  91 extern struct ps_prochandle *proc_arg_grab(const char *, int, int, int *);
  92 extern  const pstatus_t *Pstatus(struct ps_prochandle *);
  93 
  94 /* Flags accepted by Prelease (partial) */
  95 #define PRELEASE_CLEAR  0x10    /* Clear all tracing flags */
  96 
  97 extern  void    Prelease(struct ps_prochandle *, int);
  98 extern  int     Psetrun(struct ps_prochandle *, int, int);
  99 extern  int     Pstop(struct ps_prochandle *, uint_t);
 100 
 101 /*
 102  * Stack frame iteration interface.
 103  */
 104 #ifdef SOLARIS_11_B159_OR_LATER
 105 /* building on Nevada-B159 or later so define the new callback */
 106 typedef int proc_stack_f(
 107     void *,             /* the cookie given to Pstack_iter() */
 108     const prgregset_t,  /* the frame's registers */
 109     uint_t,             /* argc for the frame's function */
 110     const long *,       /* argv for the frame's function */
 111     int,                /* bitwise flags describing the frame (see below) */
 112     int);               /* a signal number */
 113 
 114 #define PR_SIGNAL_FRAME    1    /* called by a signal handler */
 115 #define PR_FOUND_SIGNAL    2    /* we found the corresponding signal number */
 116 #else
 117 /* building on Nevada-B158 or earlier so define the old callback */
 118 typedef int proc_stack_f(void *, const prgregset_t, uint_t, const long *);
 119 #endif
 120 
 121 extern int Pstack_iter(struct ps_prochandle *,
 122     const prgregset_t, proc_stack_f *, void *);
 123 
 124 #define PR_OBJ_EVERY    ((const char *)-1)      /* search every load object */
 125 
 126 
 127 #ifdef __cplusplus
 128 }
 129 #endif
 130 
 131 #endif /* _SALIBPROC_H_ */
   1 /*
   2  * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *


  29  * We used to use the copy of it from Solaris 8.0. But there are
  30  * problems with that approach in building this library across Solaris
  31  * versions.  Solaris 10 has libproc.h in /usr/include. And libproc.h
  32  * varies slightly across Solaris versions. On Solaris 9, we get
  33  * 'sysret_t multiply defined' error. This is common minimum subset we
  34  * really need from libproc.h. The libproc.h in the current dir has
  35  * been left for reference and not used in build.
  36  */
  37 
  38 #include <dlfcn.h>
  39 #include <gelf.h>
  40 #include <procfs.h>
  41 #include <proc_service.h>
  42 #include <fcntl.h>
  43 #include <unistd.h>
  44 
  45 #ifdef __cplusplus
  46 extern "C" {
  47 #endif
  48 
  49 /* extended symbol table information */
  50 typedef struct {
  51         const char      *prs_object;            /* object name */
  52         const char      *prs_name;              /* symbol name */
  53         Lmid_t          prs_lmid;               /* link map id */
  54         uint_t          prs_id;                 /* symbol id */
  55         uint_t          prs_table;              /* symbol table id */
  56 } prsyminfo_t;
  57 
  58 typedef struct ps_prochandle ps_prochandle_t;
  59 
  60 /*
  61  * 'object_name' is the name of a load object obtained from an
  62  * iteration over the process's address space mappings (Pmapping_iter),
  63  * or an iteration over the process's mapped objects (Pobject_iter),
  64  * or else it is one of the special PR_OBJ_* values above.
  65  */
  66 
  67 extern int Plookup_by_addr(ps_prochandle_t *, uintptr_t, char *,
  68                            size_t, GElf_Sym *, prsyminfo_t *);
  69 extern ps_prochandle_t *proc_arg_grab(const char *, int, int,
  70                                       int *, const char **);
  71 typedef int proc_map_f(void *, const prmap_t *, const char *);
  72 extern int Pobject_iter(struct ps_prochandle *, proc_map_f *, void *);
  73 
  74 /*
  75  * Utility functions for processing arguments which should be /proc files,
  76  * pids, and/or core files.  The returned error code can be passed to
  77  * Pgrab_error() in order to convert it to an error string.
  78  */
  79 #define PR_ARG_PIDS     0x1     /* Allow pid and /proc file arguments */
  80 #define PR_ARG_CORES    0x2     /* Allow core file arguments */
  81 #define PR_ARG_ANY      (PR_ARG_PIDS | PR_ARG_CORES)
  82 
  83 /* Flags accepted by Pgrab() (partial) */
  84 #define PGRAB_FORCE     0x02    /* Open the process w/o O_EXCL */
  85 
  86 /* Error codes from Pgrab(), Pfgrab_core(), and Pgrab_core() */
  87 #define G_STRANGE       -1      /* Unanticipated error, errno is meaningful */
  88 #define G_NOPROC        1       /* No such process */
  89 #define G_NOCORE        2       /* No such core file */
  90 #define G_NOPROCORCORE  3       /* No such proc or core (for proc_arg_grab) */
  91 #define G_NOEXEC        4       /* Cannot locate executable file */
  92 #define G_ZOMB          5       /* Zombie process */
  93 #define G_PERM          6       /* No permission */
  94 #define G_BUSY          7       /* Another process has control */
  95 #define G_SYS           8       /* System process */
  96 #define G_SELF          9       /* Process is self */
  97 #define G_INTR          10      /* Interrupt received while grabbing */
  98 #define G_LP64          11      /* Process is _LP64, self is ILP32 */
  99 #define G_FORMAT        12      /* File is not an ELF format core file */
 100 #define G_ELF           13      /* Libelf error, elf_errno() is meaningful */
 101 #define G_NOTE          14      /* Required PT_NOTE Phdr not present in core */
 102 

 103 extern  const pstatus_t *Pstatus(struct ps_prochandle *);
 104 
 105 /* Flags accepted by Prelease (partial) */
 106 #define PRELEASE_CLEAR  0x10    /* Clear all tracing flags */
 107 
 108 extern  void    Prelease(struct ps_prochandle *, int);
 109 extern  int     Psetrun(struct ps_prochandle *, int, int);
 110 extern  int     Pstop(struct ps_prochandle *, uint_t);
 111 
 112 /*
 113  * Stack frame iteration interface.
 114  */


 115 typedef int proc_stack_f(
 116     void *,             /* the cookie given to Pstack_iter() */
 117     const prgregset_t,  /* the frame's registers */
 118     uint_t,             /* argc for the frame's function */
 119     const long *,       /* argv for the frame's function */
 120     int,                /* bitwise flags describing the frame (see below) */
 121     int);               /* a signal number */
 122 
 123 #define PR_SIGNAL_FRAME    1    /* called by a signal handler */
 124 #define PR_FOUND_SIGNAL    2    /* we found the corresponding signal number */




 125 
 126 extern int Pstack_iter(struct ps_prochandle *,
 127     const prgregset_t, proc_stack_f *, void *);
 128 
 129 #define PR_OBJ_EVERY    ((const char *)-1)      /* search every load object */
 130 
 131 
 132 #ifdef __cplusplus
 133 }
 134 #endif
 135 
 136 #endif /* _SALIBPROC_H_ */
< prev index next >