Print this page
XXX AVX procfs


  10  * or http://www.opensolaris.org/os/licensing.
  11  * See the License for the specific language governing permissions
  12  * and limitations under the License.
  13  *
  14  * When distributing Covered Code, include this CDDL HEADER in each
  15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  16  * If applicable, add the following below this CDDL HEADER, with the
  17  * fields enclosed by brackets "[]" replaced with your own identifying
  18  * information: Portions Copyright [yyyy] [name of copyright owner]
  19  *
  20  * CDDL HEADER END
  21  */
  22 /*
  23  * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
  24  * Use is subject to license terms.
  25  */
  26 
  27 #ifndef _MDB_PROC_H
  28 #define _MDB_PROC_H
  29 
  30 #pragma ident   "%Z%%M% %I%     %E% SMI"
  31 
  32 #include <mdb/mdb_target_impl.h>
  33 #include <mdb/mdb_io_impl.h>
  34 #include <mdb/mdb_addrvec.h>
  35 #include <mdb/mdb_modapi.h>
  36 #include <mdb/mdb_gelf.h>
  37 #include <mdb/mdb_tdb.h>
  38 
  39 #include <sys/param.h>
  40 #include <libproc.h>
  41 
  42 #ifdef  __cplusplus
  43 extern "C" {
  44 #endif
  45 
  46 #ifdef _MDB
  47 
  48 /*
  49  * The proc target must provide support for examining multi-threaded processes
  50  * that use the raw LWP interface, as well as those that use either of the
  51  * existing libthread.so implementations.  We must also support multiple active
  52  * instances of the proc target, as well as the notion that a clean process
  53  * can dlopen() libthread after startup, at which point we need to switch to
  54  * using libthread_db interfaces to properly debug it.  To satisfy these
  55  * constraints, we declare an ops vector of functions for obtaining the
  56  * register sets of each thread.  The proc target will define two versions
  57  * of this vector, one for the LWP mode and one for the libthread_db mode,
  58  * and then switch the ops vector pointer as appropriate during debugging.
  59  * The macros defined below expand to calls to the appropriate entry point.
  60  */
  61 typedef struct pt_ptl_ops {
  62         int (*ptl_ctor)(mdb_tgt_t *);
  63         void (*ptl_dtor)(mdb_tgt_t *, void *);
  64         mdb_tgt_tid_t (*ptl_tid)(mdb_tgt_t *, void *);
  65         int (*ptl_iter)(mdb_tgt_t *, void *, mdb_addrvec_t *);
  66         int (*ptl_getregs)(mdb_tgt_t *, void *, mdb_tgt_tid_t, prgregset_t);
  67         int (*ptl_setregs)(mdb_tgt_t *, void *, mdb_tgt_tid_t, prgregset_t);
  68 #ifdef  __sparc
  69         int (*ptl_getxregs)(mdb_tgt_t *, void *, mdb_tgt_tid_t,
  70             prxregset_t *);
  71         int (*ptl_setxregs)(mdb_tgt_t *, void *, mdb_tgt_tid_t,
  72             const prxregset_t *);
  73 #endif
  74         int (*ptl_getfpregs)(mdb_tgt_t *, void *, mdb_tgt_tid_t,
  75             prfpregset_t *);
  76         int (*ptl_setfpregs)(mdb_tgt_t *, void *, mdb_tgt_tid_t,
  77             const prfpregset_t *);
  78 } pt_ptl_ops_t;
  79 
  80 #define PTL_CTOR(t) \
  81         (((pt_data_t *)(t)->t_data)->p_ptl_ops->ptl_ctor(t))
  82 
  83 #define PTL_DTOR(t) \
  84         (((pt_data_t *)(t)->t_data)->p_ptl_ops->ptl_dtor((t), \
  85         ((pt_data_t *)((t)->t_data))->p_ptl_hdl))
  86 
  87 #define PTL_TID(t) \
  88         (((pt_data_t *)((t)->t_data))->p_ptl_ops->ptl_tid((t), \
  89         ((pt_data_t *)(t)->t_data)->p_ptl_hdl))
  90 
  91 #define PTL_ITER(t, ap) \
  92         (((pt_data_t *)(t)->t_data)->p_ptl_ops->ptl_iter((t), \
  93         ((pt_data_t *)((t)->t_data))->p_ptl_hdl, (ap)))
  94 
  95 #define PTL_GETREGS(t, tid, gregs) \
  96         (((pt_data_t *)((t)->t_data))->p_ptl_ops->ptl_getregs((t), \
  97         ((pt_data_t *)((t)->t_data))->p_ptl_hdl, (tid), (gregs)))
  98 
  99 #define PTL_SETREGS(t, tid, gregs) \
 100         (((pt_data_t *)((t)->t_data))->p_ptl_ops->ptl_setregs((t), \
 101         ((pt_data_t *)((t)->t_data))->p_ptl_hdl, (tid), (gregs)))
 102 
 103 #ifdef  __sparc
 104 
 105 #define PTL_GETXREGS(t, tid, xregs) \
 106         (((pt_data_t *)((t)->t_data))->p_ptl_ops->ptl_getxregs((t), \
 107         ((pt_data_t *)((t)->t_data))->p_ptl_hdl, (tid), (xregs)))
 108 
 109 #define PTL_SETXREGS(t, tid, xregs) \
 110         (((pt_data_t *)((t)->t_data))->p_ptl_ops->ptl_setxregs((t), \
 111         ((pt_data_t *)((t)->t_data))->p_ptl_hdl, (tid), (xregs)))
 112 
 113 #endif  /* __sparc */
 114 
 115 #define PTL_GETFPREGS(t, tid, fpregs) \
 116         (((pt_data_t *)((t)->t_data))->p_ptl_ops->ptl_getfpregs((t), \
 117         ((pt_data_t *)((t)->t_data))->p_ptl_hdl, (tid), (fpregs)))
 118 
 119 #define PTL_SETFPREGS(t, tid, fpregs) \
 120         (((pt_data_t *)((t)->t_data))->p_ptl_ops->ptl_setfpregs((t), \
 121         ((pt_data_t *)((t)->t_data))->p_ptl_hdl, (tid), (fpregs)))
 122 
 123 /*
 124  * When we are following children and a vfork(2) occurs, we append the libproc
 125  * handle for the parent to a list of vfork parents.  We need to keep track of
 126  * this handle so that when the child subsequently execs or dies, we clear out
 127  * our breakpoints before releasing the parent.
 128  */
 129 typedef struct pt_vforkp {
 130         mdb_list_t p_list;                      /* List forward/back pointers */
 131         struct ps_prochandle *p_pshandle;       /* libproc handle */
 132 } pt_vforkp_t;
 133 
 134 /*




  10  * or http://www.opensolaris.org/os/licensing.
  11  * See the License for the specific language governing permissions
  12  * and limitations under the License.
  13  *
  14  * When distributing Covered Code, include this CDDL HEADER in each
  15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  16  * If applicable, add the following below this CDDL HEADER, with the
  17  * fields enclosed by brackets "[]" replaced with your own identifying
  18  * information: Portions Copyright [yyyy] [name of copyright owner]
  19  *
  20  * CDDL HEADER END
  21  */
  22 /*
  23  * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
  24  * Use is subject to license terms.
  25  */
  26 
  27 #ifndef _MDB_PROC_H
  28 #define _MDB_PROC_H
  29 


  30 #include <mdb/mdb_target_impl.h>
  31 #include <mdb/mdb_io_impl.h>
  32 #include <mdb/mdb_addrvec.h>
  33 #include <mdb/mdb_modapi.h>
  34 #include <mdb/mdb_gelf.h>
  35 #include <mdb/mdb_tdb.h>
  36 
  37 #include <sys/param.h>
  38 #include <libproc.h>
  39 
  40 #ifdef  __cplusplus
  41 extern "C" {
  42 #endif
  43 
  44 #ifdef _MDB
  45 
  46 /*
  47  * The proc target must provide support for examining multi-threaded processes
  48  * that use the raw LWP interface, as well as those that use either of the
  49  * existing libthread.so implementations.  We must also support multiple active
  50  * instances of the proc target, as well as the notion that a clean process
  51  * can dlopen() libthread after startup, at which point we need to switch to
  52  * using libthread_db interfaces to properly debug it.  To satisfy these
  53  * constraints, we declare an ops vector of functions for obtaining the
  54  * register sets of each thread.  The proc target will define two versions
  55  * of this vector, one for the LWP mode and one for the libthread_db mode,
  56  * and then switch the ops vector pointer as appropriate during debugging.
  57  * The macros defined below expand to calls to the appropriate entry point.
  58  */
  59 typedef struct pt_ptl_ops {
  60         int (*ptl_ctor)(mdb_tgt_t *);
  61         void (*ptl_dtor)(mdb_tgt_t *, void *);
  62         mdb_tgt_tid_t (*ptl_tid)(mdb_tgt_t *, void *);
  63         int (*ptl_iter)(mdb_tgt_t *, void *, mdb_addrvec_t *);
  64         int (*ptl_getregs)(mdb_tgt_t *, void *, mdb_tgt_tid_t, prgregset_t);
  65         int (*ptl_setregs)(mdb_tgt_t *, void *, mdb_tgt_tid_t, prgregset_t);

  66         int (*ptl_getxregs)(mdb_tgt_t *, void *, mdb_tgt_tid_t,
  67             prxregset_t *);
  68         int (*ptl_setxregs)(mdb_tgt_t *, void *, mdb_tgt_tid_t,
  69             const prxregset_t *);

  70         int (*ptl_getfpregs)(mdb_tgt_t *, void *, mdb_tgt_tid_t,
  71             prfpregset_t *);
  72         int (*ptl_setfpregs)(mdb_tgt_t *, void *, mdb_tgt_tid_t,
  73             const prfpregset_t *);
  74 } pt_ptl_ops_t;
  75 
  76 #define PTL_CTOR(t) \
  77         (((pt_data_t *)(t)->t_data)->p_ptl_ops->ptl_ctor(t))
  78 
  79 #define PTL_DTOR(t) \
  80         (((pt_data_t *)(t)->t_data)->p_ptl_ops->ptl_dtor((t), \
  81         ((pt_data_t *)((t)->t_data))->p_ptl_hdl))
  82 
  83 #define PTL_TID(t) \
  84         (((pt_data_t *)((t)->t_data))->p_ptl_ops->ptl_tid((t), \
  85         ((pt_data_t *)(t)->t_data)->p_ptl_hdl))
  86 
  87 #define PTL_ITER(t, ap) \
  88         (((pt_data_t *)(t)->t_data)->p_ptl_ops->ptl_iter((t), \
  89         ((pt_data_t *)((t)->t_data))->p_ptl_hdl, (ap)))
  90 
  91 #define PTL_GETREGS(t, tid, gregs) \
  92         (((pt_data_t *)((t)->t_data))->p_ptl_ops->ptl_getregs((t), \
  93         ((pt_data_t *)((t)->t_data))->p_ptl_hdl, (tid), (gregs)))
  94 
  95 #define PTL_SETREGS(t, tid, gregs) \
  96         (((pt_data_t *)((t)->t_data))->p_ptl_ops->ptl_setregs((t), \
  97         ((pt_data_t *)((t)->t_data))->p_ptl_hdl, (tid), (gregs)))
  98 


  99 #define PTL_GETXREGS(t, tid, xregs) \
 100         (((pt_data_t *)((t)->t_data))->p_ptl_ops->ptl_getxregs((t), \
 101         ((pt_data_t *)((t)->t_data))->p_ptl_hdl, (tid), (xregs)))
 102 
 103 #define PTL_SETXREGS(t, tid, xregs) \
 104         (((pt_data_t *)((t)->t_data))->p_ptl_ops->ptl_setxregs((t), \
 105         ((pt_data_t *)((t)->t_data))->p_ptl_hdl, (tid), (xregs)))
 106 


 107 #define PTL_GETFPREGS(t, tid, fpregs) \
 108         (((pt_data_t *)((t)->t_data))->p_ptl_ops->ptl_getfpregs((t), \
 109         ((pt_data_t *)((t)->t_data))->p_ptl_hdl, (tid), (fpregs)))
 110 
 111 #define PTL_SETFPREGS(t, tid, fpregs) \
 112         (((pt_data_t *)((t)->t_data))->p_ptl_ops->ptl_setfpregs((t), \
 113         ((pt_data_t *)((t)->t_data))->p_ptl_hdl, (tid), (fpregs)))
 114 
 115 /*
 116  * When we are following children and a vfork(2) occurs, we append the libproc
 117  * handle for the parent to a list of vfork parents.  We need to keep track of
 118  * this handle so that when the child subsequently execs or dies, we clear out
 119  * our breakpoints before releasing the parent.
 120  */
 121 typedef struct pt_vforkp {
 122         mdb_list_t p_list;                      /* List forward/back pointers */
 123         struct ps_prochandle *p_pshandle;       /* libproc handle */
 124 } pt_vforkp_t;
 125 
 126 /*