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 <sys/types.h>
  29 #include <sys/uio.h>
  30 #include <string.h>
  31 #include <errno.h>
  32 #include <limits.h>
  33 
  34 #include "Pcontrol.h"
  35 #include "P32ton.h"
  36 
  37 /*
  38  * This file implements the routines to read and write per-lwp register
  39  * information from either a live process or core file opened with libproc.
  40  * We build up a few common routines for reading and writing register
  41  * information, and then the public functions are all trivial calls to these.
  42  */
  43 
  44 /*
  45  * Utility function to return a pointer to the structure of cached information
  46  * about an lwp in the core file, given its lwpid.
  47  */


 202 }
 203 
 204 int
 205 Plwp_getfpregs(struct ps_prochandle *P, lwpid_t lwpid, prfpregset_t *fpregs)
 206 {
 207         lwpstatus_t lps;
 208 
 209         if (getlwpstatus(P, lwpid, &lps) == -1)
 210                 return (-1);
 211 
 212         (void) memcpy(fpregs, &lps.pr_fpreg, sizeof (prfpregset_t));
 213         return (0);
 214 }
 215 
 216 int Plwp_setfpregs(struct ps_prochandle *P, lwpid_t lwpid,
 217     const prfpregset_t *fpregs)
 218 {
 219         return (setlwpregs(P, lwpid, PCSFPREG, fpregs, sizeof (prfpregset_t)));
 220 }
 221 
 222 #if defined(sparc) || defined(__sparc)
 223 int
 224 Plwp_getxregs(struct ps_prochandle *P, lwpid_t lwpid, prxregset_t *xregs)
 225 {
 226         lwp_info_t *lwp;
 227 
 228         if (P->state == PS_IDLE) {
 229                 errno = ENODATA;
 230                 return (-1);
 231         }
 232 
 233         if (P->state != PS_DEAD) {
 234                 if (P->state != PS_STOP) {
 235                         errno = EBUSY;
 236                         return (-1);
 237                 }
 238 
 239                 return (getlwpfile(P, lwpid, "xregs",
 240                     xregs, sizeof (prxregset_t)));
 241         }
 242 
 243         if ((lwp = getlwpcore(P, lwpid)) != NULL && lwp->lwp_xregs != NULL) {
 244                 (void) memcpy(xregs, lwp->lwp_xregs, sizeof (prxregset_t));
 245                 return (0);
 246         }
 247 
 248         if (lwp != NULL)
 249                 errno = ENODATA;
 250         return (-1);
 251 }
 252 
 253 int
 254 Plwp_setxregs(struct ps_prochandle *P, lwpid_t lwpid, const prxregset_t *xregs)
 255 {
 256         return (setlwpregs(P, lwpid, PCSXREG, xregs, sizeof (prxregset_t)));
 257 }
 258 

 259 int
 260 Plwp_getgwindows(struct ps_prochandle *P, lwpid_t lwpid, gwindows_t *gwins)
 261 {
 262         lwp_info_t *lwp;
 263 
 264         if (P->state == PS_IDLE) {
 265                 errno = ENODATA;
 266                 return (-1);
 267         }
 268 
 269         if (P->state != PS_DEAD) {
 270                 if (P->state != PS_STOP) {
 271                         errno = EBUSY;
 272                         return (-1);
 273                 }
 274 
 275                 return (getlwpfile(P, lwpid, "gwindows",
 276                     gwins, sizeof (gwindows_t)));
 277         }
 278 




   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 <sys/types.h>
  27 #include <sys/uio.h>
  28 #include <string.h>
  29 #include <errno.h>
  30 #include <limits.h>
  31 
  32 #include "Pcontrol.h"
  33 #include "P32ton.h"
  34 
  35 /*
  36  * This file implements the routines to read and write per-lwp register
  37  * information from either a live process or core file opened with libproc.
  38  * We build up a few common routines for reading and writing register
  39  * information, and then the public functions are all trivial calls to these.
  40  */
  41 
  42 /*
  43  * Utility function to return a pointer to the structure of cached information
  44  * about an lwp in the core file, given its lwpid.
  45  */


 200 }
 201 
 202 int
 203 Plwp_getfpregs(struct ps_prochandle *P, lwpid_t lwpid, prfpregset_t *fpregs)
 204 {
 205         lwpstatus_t lps;
 206 
 207         if (getlwpstatus(P, lwpid, &lps) == -1)
 208                 return (-1);
 209 
 210         (void) memcpy(fpregs, &lps.pr_fpreg, sizeof (prfpregset_t));
 211         return (0);
 212 }
 213 
 214 int Plwp_setfpregs(struct ps_prochandle *P, lwpid_t lwpid,
 215     const prfpregset_t *fpregs)
 216 {
 217         return (setlwpregs(P, lwpid, PCSFPREG, fpregs, sizeof (prfpregset_t)));
 218 }
 219 

 220 int
 221 Plwp_getxregs(struct ps_prochandle *P, lwpid_t lwpid, prxregset_t *xregs)
 222 {
 223         lwp_info_t *lwp;
 224 
 225         if (P->state == PS_IDLE) {
 226                 errno = ENODATA;
 227                 return (-1);
 228         }
 229 
 230         if (P->state != PS_DEAD) {
 231                 if (P->state != PS_STOP) {
 232                         errno = EBUSY;
 233                         return (-1);
 234                 }
 235 
 236                 return (getlwpfile(P, lwpid, "xregs",
 237                     xregs, sizeof (prxregset_t)));
 238         }
 239 
 240         if ((lwp = getlwpcore(P, lwpid)) != NULL && lwp->lwp_xregs != NULL) {
 241                 (void) memcpy(xregs, lwp->lwp_xregs, sizeof (prxregset_t));
 242                 return (0);
 243         }
 244 
 245         if (lwp != NULL)
 246                 errno = ENODATA;
 247         return (-1);
 248 }
 249 
 250 int
 251 Plwp_setxregs(struct ps_prochandle *P, lwpid_t lwpid, const prxregset_t *xregs)
 252 {
 253         return (setlwpregs(P, lwpid, PCSXREG, xregs, sizeof (prxregset_t)));
 254 }
 255 
 256 #if defined(sparc) || defined(__sparc)
 257 int
 258 Plwp_getgwindows(struct ps_prochandle *P, lwpid_t lwpid, gwindows_t *gwins)
 259 {
 260         lwp_info_t *lwp;
 261 
 262         if (P->state == PS_IDLE) {
 263                 errno = ENODATA;
 264                 return (-1);
 265         }
 266 
 267         if (P->state != PS_DEAD) {
 268                 if (P->state != PS_STOP) {
 269                         errno = EBUSY;
 270                         return (-1);
 271                 }
 272 
 273                 return (getlwpfile(P, lwpid, "gwindows",
 274                     gwins, sizeof (gwindows_t)));
 275         }
 276