Print this page
8158 Want named threads API
9857 proc manpages should have LIBRARY section


   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 /*
  23  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
  24  * Use is subject to license terms.
  25  */
  26 /*
  27  * Copyright 2012 DEY Storage Systems, Inc.  All rights reserved.
  28  * Copyright 2015 Joyent, Inc.
  29  * Copyright (c) 2013 by Delphix. All rights reserved.
  30  */
  31 
  32 #define _STRUCTURED_PROC        1
  33 
  34 #include <stdlib.h>
  35 #include <ctype.h>
  36 #include <string.h>
  37 #include <strings.h>
  38 #include <errno.h>
  39 #include <procfs.h>
  40 #include <priv.h>
  41 #include <sys/elf.h>
  42 #include <sys/machelf.h>
  43 #include <sys/sysmacros.h>
  44 #include <sys/systeminfo.h>
  45 #include <sys/proc.h>
  46 #include <sys/utsname.h>
  47 
  48 #include <sys/old_procfs.h>


 492         }
 493 
 494 #ifdef sparc
 495         {
 496                 prxregset_t xregs;
 497                 if (Plwp_getxregs(P, lsp->pr_lwpid, &xregs) == 0 &&
 498                     write_note(pgc->pgc_fd, NT_PRXREG, &xregs,
 499                     sizeof (prxregset_t), pgc->pgc_doff) != 0)
 500                         return (1);
 501         }
 502 #endif  /* sparc */
 503 
 504         return (0);
 505 }
 506 
 507 static int
 508 new_per_lwp(void *data, const lwpstatus_t *lsp, const lwpsinfo_t *lip)
 509 {
 510         pgcore_t *pgc = data;
 511         struct ps_prochandle *P = pgc->P;

 512         psinfo_t ps;
 513 
 514         /*
 515          * If lsp is NULL this indicates that this is a zombie LWP in
 516          * which case we dump only the lwpsinfo_t structure and none of
 517          * the other ancillary LWP state data.
 518          */
 519         if (P->status.pr_dmodel == PR_MODEL_NATIVE) {
 520                 if (write_note(pgc->pgc_fd, NT_LWPSINFO, lip,
 521                     sizeof (lwpsinfo_t), pgc->pgc_doff) != 0)
 522                         return (1);
 523                 if (lsp == NULL)
 524                         return (0);
 525                 if (write_note(pgc->pgc_fd, NT_LWPSTATUS, lsp,
 526                     sizeof (lwpstatus_t), pgc->pgc_doff) != 0)
 527                         return (1);
 528 #ifdef _LP64
 529         } else {
 530                 lwpsinfo32_t li32;
 531                 lwpstatus32_t ls32;


 560                             gwins.wbcnt * sizeof (gwins.wbuf[0]);
 561 
 562                         if (write_note(pgc->pgc_fd, NT_GWINDOWS, &gwins, size,
 563                             pgc->pgc_doff) != 0)
 564                                 return (1);
 565                 }
 566 
 567         }
 568 #ifdef __sparcv9
 569         if (P->status.pr_dmodel == PR_MODEL_LP64) {
 570                 asrset_t asrs;
 571                 if (Plwp_getasrs(P, lsp->pr_lwpid, asrs) == 0) {
 572                         if (write_note(pgc->pgc_fd, NT_ASRS, &asrs,
 573                             sizeof (asrset_t), pgc->pgc_doff) != 0)
 574                                 return (1);
 575                 }
 576         }
 577 #endif  /* __sparcv9 */
 578 #endif  /* sparc */
 579 








 580         if (!(lsp->pr_flags & PR_AGENT))
 581                 return (0);
 582 
 583         if (Plwp_getspymaster(P, lsp->pr_lwpid, &ps) != 0)
 584                 return (0);
 585 
 586         if (P->status.pr_dmodel == PR_MODEL_NATIVE) {
 587                 if (write_note(pgc->pgc_fd, NT_SPYMASTER, &ps,
 588                     sizeof (psinfo_t), pgc->pgc_doff) != 0)
 589                         return (1);
 590 #ifdef _LP64
 591         } else {
 592                 psinfo32_t ps32;
 593                 psinfo_n_to_32(&ps, &ps32);
 594                 if (write_note(pgc->pgc_fd, NT_SPYMASTER, &ps32,
 595                     sizeof (psinfo32_t), pgc->pgc_doff) != 0)
 596                         return (1);
 597 #endif  /* _LP64 */
 598         }
 599 




   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 /*
  23  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
  24  * Use is subject to license terms.
  25  */
  26 /*
  27  * Copyright 2012 DEY Storage Systems, Inc.  All rights reserved.
  28  * Copyright 2018 Joyent, Inc.
  29  * Copyright (c) 2013 by Delphix. All rights reserved.
  30  */
  31 
  32 #define _STRUCTURED_PROC        1
  33 
  34 #include <stdlib.h>
  35 #include <ctype.h>
  36 #include <string.h>
  37 #include <strings.h>
  38 #include <errno.h>
  39 #include <procfs.h>
  40 #include <priv.h>
  41 #include <sys/elf.h>
  42 #include <sys/machelf.h>
  43 #include <sys/sysmacros.h>
  44 #include <sys/systeminfo.h>
  45 #include <sys/proc.h>
  46 #include <sys/utsname.h>
  47 
  48 #include <sys/old_procfs.h>


 492         }
 493 
 494 #ifdef sparc
 495         {
 496                 prxregset_t xregs;
 497                 if (Plwp_getxregs(P, lsp->pr_lwpid, &xregs) == 0 &&
 498                     write_note(pgc->pgc_fd, NT_PRXREG, &xregs,
 499                     sizeof (prxregset_t), pgc->pgc_doff) != 0)
 500                         return (1);
 501         }
 502 #endif  /* sparc */
 503 
 504         return (0);
 505 }
 506 
 507 static int
 508 new_per_lwp(void *data, const lwpstatus_t *lsp, const lwpsinfo_t *lip)
 509 {
 510         pgcore_t *pgc = data;
 511         struct ps_prochandle *P = pgc->P;
 512         prlwpname_t name = { 0, "" };
 513         psinfo_t ps;
 514 
 515         /*
 516          * If lsp is NULL this indicates that this is a zombie LWP in
 517          * which case we dump only the lwpsinfo_t structure and none of
 518          * the other ancillary LWP state data.
 519          */
 520         if (P->status.pr_dmodel == PR_MODEL_NATIVE) {
 521                 if (write_note(pgc->pgc_fd, NT_LWPSINFO, lip,
 522                     sizeof (lwpsinfo_t), pgc->pgc_doff) != 0)
 523                         return (1);
 524                 if (lsp == NULL)
 525                         return (0);
 526                 if (write_note(pgc->pgc_fd, NT_LWPSTATUS, lsp,
 527                     sizeof (lwpstatus_t), pgc->pgc_doff) != 0)
 528                         return (1);
 529 #ifdef _LP64
 530         } else {
 531                 lwpsinfo32_t li32;
 532                 lwpstatus32_t ls32;


 561                             gwins.wbcnt * sizeof (gwins.wbuf[0]);
 562 
 563                         if (write_note(pgc->pgc_fd, NT_GWINDOWS, &gwins, size,
 564                             pgc->pgc_doff) != 0)
 565                                 return (1);
 566                 }
 567 
 568         }
 569 #ifdef __sparcv9
 570         if (P->status.pr_dmodel == PR_MODEL_LP64) {
 571                 asrset_t asrs;
 572                 if (Plwp_getasrs(P, lsp->pr_lwpid, asrs) == 0) {
 573                         if (write_note(pgc->pgc_fd, NT_ASRS, &asrs,
 574                             sizeof (asrset_t), pgc->pgc_doff) != 0)
 575                                 return (1);
 576                 }
 577         }
 578 #endif  /* __sparcv9 */
 579 #endif  /* sparc */
 580 
 581         if (Plwp_getname(P, lsp->pr_lwpid, name.pr_lwpname,
 582             sizeof (name.pr_lwpname)) == 0) {
 583                 name.pr_lwpid = lsp->pr_lwpid;
 584                 if (write_note(pgc->pgc_fd, NT_LWPNAME, &name,
 585                     sizeof (name), pgc->pgc_doff) != 0)
 586                         return (1);
 587         }
 588 
 589         if (!(lsp->pr_flags & PR_AGENT))
 590                 return (0);
 591 
 592         if (Plwp_getspymaster(P, lsp->pr_lwpid, &ps) != 0)
 593                 return (0);
 594 
 595         if (P->status.pr_dmodel == PR_MODEL_NATIVE) {
 596                 if (write_note(pgc->pgc_fd, NT_SPYMASTER, &ps,
 597                     sizeof (psinfo_t), pgc->pgc_doff) != 0)
 598                         return (1);
 599 #ifdef _LP64
 600         } else {
 601                 psinfo32_t ps32;
 602                 psinfo_n_to_32(&ps, &ps32);
 603                 if (write_note(pgc->pgc_fd, NT_SPYMASTER, &ps32,
 604                     sizeof (psinfo32_t), pgc->pgc_doff) != 0)
 605                         return (1);
 606 #endif  /* _LP64 */
 607         }
 608