Print this page
XXX AVX procfs


   6  * You may not use this file except in compliance with the License.
   7  *
   8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
   9  * or http://www.opensolaris.org/os/licensing.
  10  * See the License for the specific language governing permissions
  11  * and limitations under the License.
  12  *
  13  * When distributing Covered Code, include this CDDL HEADER in each
  14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15  * If applicable, add the following below this CDDL HEADER, with the
  16  * fields enclosed by brackets "[]" replaced with your own identifying
  17  * information: Portions Copyright [yyyy] [name of copyright owner]
  18  *
  19  * CDDL HEADER END
  20  */
  21 /*
  22  * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
  23  * Use is subject to license terms.
  24  */
  25 
  26 #pragma ident   "%Z%%M% %I%     %E% SMI"
  27 
  28 #include <stdarg.h>
  29 #include <string.h>
  30 #include "Pcontrol.h"
  31 
  32 /*
  33  * This file implements the process services declared in <proc_service.h>.
  34  * This enables libproc to be used in conjunction with libc_db and
  35  * librtld_db.  As most of these facilities are already provided by
  36  * (more elegant) interfaces in <libproc.h>, we can just call those.
  37  *
  38  * NOTE: We explicitly do *not* implement the functions ps_kill() and
  39  * ps_lrolltoaddr() in this library.  The very existence of these functions
  40  * causes libc_db to create an "agent thread" in the target process.
  41  * The only way to turn off this behavior is to omit these functions.
  42  */
  43 
  44 #pragma weak ps_pdread = ps_pread
  45 #pragma weak ps_ptread = ps_pread
  46 #pragma weak ps_pdwrite = ps_pwrite
  47 #pragma weak ps_ptwrite = ps_pwrite


 149                 return (PS_ERR);
 150 
 151         if (Plwp_getfpregs(P, lwpid, regs) == 0)
 152                 return (PS_OK);
 153 
 154         return (PS_BADLID);
 155 }
 156 
 157 ps_err_e
 158 ps_lsetfpregs(struct ps_prochandle *P, lwpid_t lwpid, const prfpregset_t *regs)
 159 {
 160         if (P->state != PS_STOP)
 161                 return (PS_ERR);
 162 
 163         if (Plwp_setfpregs(P, lwpid, regs) == 0)
 164                 return (PS_OK);
 165 
 166         return (PS_BADLID);
 167 }
 168 
 169 #if defined(sparc) || defined(__sparc)
 170 
 171 ps_err_e
 172 ps_lgetxregsize(struct ps_prochandle *P, lwpid_t lwpid, int *xrsize)
 173 {
 174         char fname[PATH_MAX];
 175         struct stat statb;
 176 
 177         if (P->state == PS_DEAD) {
 178                 lwp_info_t *lwp = list_next(&P->core->core_lwp_head);
 179                 uint_t i;
 180 
 181                 for (i = 0; i < P->core->core_nlwp; i++, lwp = list_next(lwp)) {
 182                         if (lwp->lwp_id == lwpid) {
 183                                 if (lwp->lwp_xregs != NULL)
 184                                         *xrsize = sizeof (prxregset_t);
 185                                 else
 186                                         *xrsize = 0;
 187                                 return (PS_OK);
 188                         }
 189                 }
 190 


 210         /* LINTED - alignment */
 211         if (Plwp_getxregs(P, lwpid, (prxregset_t *)xregs) == 0)
 212                 return (PS_OK);
 213 
 214         return (PS_BADLID);
 215 }
 216 
 217 ps_err_e
 218 ps_lsetxregs(struct ps_prochandle *P, lwpid_t lwpid, caddr_t xregs)
 219 {
 220         if (P->state != PS_STOP)
 221                 return (PS_ERR);
 222 
 223         /* LINTED - alignment */
 224         if (Plwp_setxregs(P, lwpid, (prxregset_t *)xregs) == 0)
 225                 return (PS_OK);
 226 
 227         return (PS_BADLID);
 228 }
 229 
 230 #endif  /* sparc */
 231 
 232 #if defined(__i386) || defined(__amd64)
 233 
 234 ps_err_e
 235 ps_lgetLDT(struct ps_prochandle *P, lwpid_t lwpid, struct ssd *ldt)
 236 {
 237 #if defined(__amd64) && defined(_LP64)
 238         if (P->status.pr_dmodel != PR_MODEL_NATIVE) {
 239 #endif
 240         prgregset_t regs;
 241         struct ssd *ldtarray;
 242         ps_err_e error;
 243         uint_t gs;
 244         int nldt;
 245         int i;
 246 
 247         if (P->state != PS_STOP && P->state != PS_DEAD)
 248                 return (PS_ERR);
 249 
 250         /*
 251          * We need to get the ldt entry that matches the




   6  * You may not use this file except in compliance with the License.
   7  *
   8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
   9  * or http://www.opensolaris.org/os/licensing.
  10  * See the License for the specific language governing permissions
  11  * and limitations under the License.
  12  *
  13  * When distributing Covered Code, include this CDDL HEADER in each
  14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15  * If applicable, add the following below this CDDL HEADER, with the
  16  * fields enclosed by brackets "[]" replaced with your own identifying
  17  * information: Portions Copyright [yyyy] [name of copyright owner]
  18  *
  19  * CDDL HEADER END
  20  */
  21 /*
  22  * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
  23  * Use is subject to license terms.
  24  */
  25 


  26 #include <stdarg.h>
  27 #include <string.h>
  28 #include "Pcontrol.h"
  29 
  30 /*
  31  * This file implements the process services declared in <proc_service.h>.
  32  * This enables libproc to be used in conjunction with libc_db and
  33  * librtld_db.  As most of these facilities are already provided by
  34  * (more elegant) interfaces in <libproc.h>, we can just call those.
  35  *
  36  * NOTE: We explicitly do *not* implement the functions ps_kill() and
  37  * ps_lrolltoaddr() in this library.  The very existence of these functions
  38  * causes libc_db to create an "agent thread" in the target process.
  39  * The only way to turn off this behavior is to omit these functions.
  40  */
  41 
  42 #pragma weak ps_pdread = ps_pread
  43 #pragma weak ps_ptread = ps_pread
  44 #pragma weak ps_pdwrite = ps_pwrite
  45 #pragma weak ps_ptwrite = ps_pwrite


 147                 return (PS_ERR);
 148 
 149         if (Plwp_getfpregs(P, lwpid, regs) == 0)
 150                 return (PS_OK);
 151 
 152         return (PS_BADLID);
 153 }
 154 
 155 ps_err_e
 156 ps_lsetfpregs(struct ps_prochandle *P, lwpid_t lwpid, const prfpregset_t *regs)
 157 {
 158         if (P->state != PS_STOP)
 159                 return (PS_ERR);
 160 
 161         if (Plwp_setfpregs(P, lwpid, regs) == 0)
 162                 return (PS_OK);
 163 
 164         return (PS_BADLID);
 165 }
 166 


 167 ps_err_e
 168 ps_lgetxregsize(struct ps_prochandle *P, lwpid_t lwpid, int *xrsize)
 169 {
 170         char fname[PATH_MAX];
 171         struct stat statb;
 172 
 173         if (P->state == PS_DEAD) {
 174                 lwp_info_t *lwp = list_next(&P->core->core_lwp_head);
 175                 uint_t i;
 176 
 177                 for (i = 0; i < P->core->core_nlwp; i++, lwp = list_next(lwp)) {
 178                         if (lwp->lwp_id == lwpid) {
 179                                 if (lwp->lwp_xregs != NULL)
 180                                         *xrsize = sizeof (prxregset_t);
 181                                 else
 182                                         *xrsize = 0;
 183                                 return (PS_OK);
 184                         }
 185                 }
 186 


 206         /* LINTED - alignment */
 207         if (Plwp_getxregs(P, lwpid, (prxregset_t *)xregs) == 0)
 208                 return (PS_OK);
 209 
 210         return (PS_BADLID);
 211 }
 212 
 213 ps_err_e
 214 ps_lsetxregs(struct ps_prochandle *P, lwpid_t lwpid, caddr_t xregs)
 215 {
 216         if (P->state != PS_STOP)
 217                 return (PS_ERR);
 218 
 219         /* LINTED - alignment */
 220         if (Plwp_setxregs(P, lwpid, (prxregset_t *)xregs) == 0)
 221                 return (PS_OK);
 222 
 223         return (PS_BADLID);
 224 }
 225 


 226 #if defined(__i386) || defined(__amd64)
 227 
 228 ps_err_e
 229 ps_lgetLDT(struct ps_prochandle *P, lwpid_t lwpid, struct ssd *ldt)
 230 {
 231 #if defined(__amd64) && defined(_LP64)
 232         if (P->status.pr_dmodel != PR_MODEL_NATIVE) {
 233 #endif
 234         prgregset_t regs;
 235         struct ssd *ldtarray;
 236         ps_err_e error;
 237         uint_t gs;
 238         int nldt;
 239         int i;
 240 
 241         if (P->state != PS_STOP && P->state != PS_DEAD)
 242                 return (PS_ERR);
 243 
 244         /*
 245          * We need to get the ldt entry that matches the