Print this page
XXX AVX procfs


 570 
 571         if (_libproc_debug) {
 572                 for (i = 0; i < n; i++) {
 573                         dprintf("P->auxv[%lu] = ( %d, 0x%lx )\n", (ulong_t)i,
 574                             P->auxv[i].a_type, P->auxv[i].a_un.a_val);
 575                 }
 576         }
 577 
 578         /*
 579          * Defensive coding for loops which depend upon the auxv array being
 580          * terminated by an AT_NULL element; in each case, we've allocated
 581          * P->auxv to have an additional element which we force to be AT_NULL.
 582          */
 583         P->auxv[n].a_type = AT_NULL;
 584         P->auxv[n].a_un.a_val = 0L;
 585         P->nauxv = (int)n;
 586 
 587         return (0);
 588 }
 589 
 590 #ifdef __sparc
 591 static int
 592 note_xreg(struct ps_prochandle *P, size_t nbytes)
 593 {
 594         lwp_info_t *lwp = P->core->core_lwp;
 595         size_t xbytes = sizeof (prxregset_t);
 596         prxregset_t *xregs;
 597 
 598         if (lwp == NULL || lwp->lwp_xregs != NULL || nbytes < xbytes)
 599                 return (0);     /* No lwp yet, already seen, or bad size */
 600 
 601         if ((xregs = malloc(xbytes)) == NULL)
 602                 return (-1);
 603 
 604         if (read(P->asfd, xregs, xbytes) != xbytes) {



 605                 dprintf("Pgrab_core: failed to read NT_PRXREG\n");
 606                 free(xregs);
 607                 return (-1);
 608         }
 609 
 610         lwp->lwp_xregs = xregs;
 611         return (0);
 612 }
 613 

 614 static int
 615 note_gwindows(struct ps_prochandle *P, size_t nbytes)
 616 {
 617         lwp_info_t *lwp = P->core->core_lwp;
 618 
 619         if (lwp == NULL || lwp->lwp_gwins != NULL || nbytes == 0)
 620                 return (0);     /* No lwp yet or already seen or no data */
 621 
 622         if ((lwp->lwp_gwins = malloc(sizeof (gwindows_t))) == NULL)
 623                 return (-1);
 624 
 625         /*
 626          * Since the amount of gwindows data varies with how many windows were
 627          * actually saved, we just read up to the minimum of the note size
 628          * and the size of the gwindows_t type.  It doesn't matter if the read
 629          * fails since we have to zero out gwindows first anyway.
 630          */
 631 #ifdef _LP64
 632         if (P->core->core_dmodel == PR_MODEL_ILP32) {
 633                 gwindows32_t g32;


 672 #endif  /* __sparcv9 */
 673 #endif  /* __sparc */
 674 
 675 /*ARGSUSED*/
 676 static int
 677 note_notsup(struct ps_prochandle *P, size_t nbytes)
 678 {
 679         dprintf("skipping unsupported note type\n");
 680         return (0);
 681 }
 682 
 683 /*
 684  * Populate a table of function pointers indexed by Note type with our
 685  * functions to process each type of core file note:
 686  */
 687 static int (*nhdlrs[])(struct ps_prochandle *, size_t) = {
 688         note_notsup,            /*  0   unassigned              */
 689         note_notsup,            /*  1   NT_PRSTATUS (old)       */
 690         note_notsup,            /*  2   NT_PRFPREG (old)        */
 691         note_notsup,            /*  3   NT_PRPSINFO (old)       */
 692 #ifdef __sparc
 693         note_xreg,              /*  4   NT_PRXREG               */
 694 #else
 695         note_notsup,            /*  4   NT_PRXREG               */
 696 #endif
 697         note_platform,          /*  5   NT_PLATFORM             */
 698         note_auxv,              /*  6   NT_AUXV                 */
 699 #ifdef __sparc
 700         note_gwindows,          /*  7   NT_GWINDOWS             */
 701 #ifdef __sparcv9
 702         note_asrs,              /*  8   NT_ASRS                 */
 703 #else
 704         note_notsup,            /*  8   NT_ASRS                 */
 705 #endif
 706 #else
 707         note_notsup,            /*  7   NT_GWINDOWS             */
 708         note_notsup,            /*  8   NT_ASRS                 */
 709 #endif
 710 #if defined(__i386) || defined(__amd64)
 711         note_ldt,               /*  9   NT_LDT                  */
 712 #else
 713         note_notsup,            /*  9   NT_LDT                  */
 714 #endif
 715         note_pstatus,           /* 10   NT_PSTATUS              */
 716         note_notsup,            /* 11   unassigned              */




 570 
 571         if (_libproc_debug) {
 572                 for (i = 0; i < n; i++) {
 573                         dprintf("P->auxv[%lu] = ( %d, 0x%lx )\n", (ulong_t)i,
 574                             P->auxv[i].a_type, P->auxv[i].a_un.a_val);
 575                 }
 576         }
 577 
 578         /*
 579          * Defensive coding for loops which depend upon the auxv array being
 580          * terminated by an AT_NULL element; in each case, we've allocated
 581          * P->auxv to have an additional element which we force to be AT_NULL.
 582          */
 583         P->auxv[n].a_type = AT_NULL;
 584         P->auxv[n].a_un.a_val = 0L;
 585         P->nauxv = (int)n;
 586 
 587         return (0);
 588 }
 589 

 590 static int
 591 note_xreg(struct ps_prochandle *P, size_t nbytes)
 592 {
 593         lwp_info_t *lwp = P->core->core_lwp;
 594         size_t xbytes = sizeof (prxregset_t);
 595         prxregset_t *xregs;
 596 
 597         if (lwp == NULL || lwp->lwp_xregs != NULL || nbytes < xbytes)
 598                 return (0);     /* No lwp yet, already seen, or bad size */
 599 
 600         if ((xregs = malloc(xbytes)) == NULL)
 601                 return (-1);
 602 #ifdef __sparc
 603         if (read(P->asfd, xregs, xbytes) != xbytes) {
 604 #else
 605         panic("port me");
 606 #endif
 607                 dprintf("Pgrab_core: failed to read NT_PRXREG\n");
 608                 free(xregs);
 609                 return (-1);
 610         }

 611         lwp->lwp_xregs = xregs;
 612         return (0);
 613 }
 614 
 615 #ifdef __sparc
 616 static int
 617 note_gwindows(struct ps_prochandle *P, size_t nbytes)
 618 {
 619         lwp_info_t *lwp = P->core->core_lwp;
 620 
 621         if (lwp == NULL || lwp->lwp_gwins != NULL || nbytes == 0)
 622                 return (0);     /* No lwp yet or already seen or no data */
 623 
 624         if ((lwp->lwp_gwins = malloc(sizeof (gwindows_t))) == NULL)
 625                 return (-1);
 626 
 627         /*
 628          * Since the amount of gwindows data varies with how many windows were
 629          * actually saved, we just read up to the minimum of the note size
 630          * and the size of the gwindows_t type.  It doesn't matter if the read
 631          * fails since we have to zero out gwindows first anyway.
 632          */
 633 #ifdef _LP64
 634         if (P->core->core_dmodel == PR_MODEL_ILP32) {
 635                 gwindows32_t g32;


 674 #endif  /* __sparcv9 */
 675 #endif  /* __sparc */
 676 
 677 /*ARGSUSED*/
 678 static int
 679 note_notsup(struct ps_prochandle *P, size_t nbytes)
 680 {
 681         dprintf("skipping unsupported note type\n");
 682         return (0);
 683 }
 684 
 685 /*
 686  * Populate a table of function pointers indexed by Note type with our
 687  * functions to process each type of core file note:
 688  */
 689 static int (*nhdlrs[])(struct ps_prochandle *, size_t) = {
 690         note_notsup,            /*  0   unassigned              */
 691         note_notsup,            /*  1   NT_PRSTATUS (old)       */
 692         note_notsup,            /*  2   NT_PRFPREG (old)        */
 693         note_notsup,            /*  3   NT_PRPSINFO (old)       */

 694         note_xreg,              /*  4   NT_PRXREG               */



 695         note_platform,          /*  5   NT_PLATFORM             */
 696         note_auxv,              /*  6   NT_AUXV                 */
 697 #ifdef __sparc
 698         note_gwindows,          /*  7   NT_GWINDOWS             */
 699 #ifdef __sparcv9
 700         note_asrs,              /*  8   NT_ASRS                 */
 701 #else
 702         note_notsup,            /*  8   NT_ASRS                 */
 703 #endif
 704 #else
 705         note_notsup,            /*  7   NT_GWINDOWS             */
 706         note_notsup,            /*  8   NT_ASRS                 */
 707 #endif
 708 #if defined(__i386) || defined(__amd64)
 709         note_ldt,               /*  9   NT_LDT                  */
 710 #else
 711         note_notsup,            /*  9   NT_LDT                  */
 712 #endif
 713         note_pstatus,           /* 10   NT_PSTATUS              */
 714         note_notsup,            /* 11   unassigned              */