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

Split Close
Expand all
Collapse all
          --- old/usr/src/uts/common/exec/elf/elf_notes.c
          +++ new/usr/src/uts/common/exec/elf/elf_notes.c
↓ open down ↓ 18 lines elided ↑ open up ↑
  19   19   *
  20   20   * CDDL HEADER END
  21   21   */
  22   22  /*
  23   23   * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
  24   24   * Use is subject to license terms.
  25   25   */
  26   26  
  27   27  /*
  28   28   * Copyright 2012 DEY Storage Systems, Inc.  All rights reserved.
  29      - * Copyright (c) 2014, Joyent, Inc. All rights reserved.
       29 + * Copyright 2018 Joyent, Inc.
  30   30   */
  31   31  
  32   32  #include <sys/types.h>
  33   33  #include <sys/param.h>
  34   34  #include <sys/thread.h>
  35   35  #include <sys/sysmacros.h>
  36   36  #include <sys/signal.h>
  37   37  #include <sys/cred.h>
  38   38  #include <sys/priv.h>
  39   39  #include <sys/user.h>
↓ open down ↓ 47 lines elided ↑ open up ↑
  87   87          for (fd = 0; fd < fip->fi_nfiles; fd++) {
  88   88                  UF_ENTER(ufp, fip, fd);
  89   89                  if ((ufp->uf_file != NULL) && (ufp->uf_file->f_count > 0))
  90   90                          nfd++;
  91   91                  UF_EXIT(ufp);
  92   92          }
  93   93          mutex_exit(&fip->fi_lock);
  94   94  
  95   95          v[0].p_type = PT_NOTE;
  96   96          v[0].p_flags = PF_R;
  97      -        v[0].p_filesz = (sizeof (Note) * (10 + 2 * nlwp + nzomb + nfd))
       97 +        v[0].p_filesz = (sizeof (Note) * (10 + 3 * nlwp + nzomb + nfd))
  98   98              + roundup(sizeof (psinfo_t), sizeof (Word))
  99   99              + roundup(sizeof (pstatus_t), sizeof (Word))
 100  100              + roundup(prgetprivsize(), sizeof (Word))
 101  101              + roundup(priv_get_implinfo_size(), sizeof (Word))
 102  102              + roundup(strlen(platform) + 1, sizeof (Word))
 103  103              + roundup(strlen(p->p_zone->zone_name) + 1, sizeof (Word))
 104  104              + roundup(__KERN_NAUXV_IMPL * sizeof (aux_entry_t), sizeof (Word))
 105  105              + roundup(sizeof (utsname), sizeof (Word))
 106  106              + roundup(sizeof (core_content_t), sizeof (Word))
 107  107              + roundup(sizeof (prsecflags_t), sizeof (Word))
 108  108              + (nlwp + nzomb) * roundup(sizeof (lwpsinfo_t), sizeof (Word))
 109  109              + nlwp * roundup(sizeof (lwpstatus_t), sizeof (Word))
      110 +            + nlwp * roundup(sizeof (prlwpname_t), sizeof (Word))
 110  111              + nfd * roundup(sizeof (prfdinfo_t), sizeof (Word));
 111  112  
 112  113          if (curproc->p_agenttp != NULL) {
 113  114                  v[0].p_filesz += sizeof (Note) +
 114  115                      roundup(sizeof (psinfo_t), sizeof (Word));
 115  116          }
 116  117  
 117  118          size = sizeof (prcred_t) + sizeof (gid_t) * (ngroups_max - 1);
 118  119          pcrp = kmem_alloc(size, KM_SLEEP);
 119  120          prgetcred(p, pcrp);
↓ open down ↓ 329 lines elided ↑ open up ↑
 449  450          }
 450  451          mutex_exit(&p->p_ldtlock);
 451  452          if (error)
 452  453                  goto done;
 453  454  #endif  /* __i386 || defined(__i386_COMPAT) */
 454  455  
 455  456          nlwp = p->p_lwpcnt;
 456  457          nzomb = p->p_zombcnt;
 457  458          /* for each entry in the lwp directory ... */
 458  459          for (ldp = p->p_lwpdir; nlwp + nzomb != 0; ldp++) {
      460 +                prlwpname_t name = { 0, };
 459  461  
 460  462                  if ((lep = ldp->ld_entry) == NULL)      /* empty slot */
 461  463                          continue;
 462  464  
 463  465                  if ((t = lep->le_thread) != NULL) {     /* active lwp */
 464  466                          ASSERT(nlwp != 0);
 465  467                          nlwp--;
 466  468                          lwp = ttolwp(t);
 467  469                          mutex_enter(&p->p_lock);
 468  470                          prgetlwpsinfo(t, &bigwad->lwpsinfo);
      471 +                        if (t->t_name != NULL) {
      472 +                                (void) strlcpy(name.pr_lwpname, t->t_name,
      473 +                                    sizeof (name.pr_lwpname));
      474 +                        }
 469  475                          mutex_exit(&p->p_lock);
 470  476                  } else {                                /* zombie lwp */
 471  477                          ASSERT(nzomb != 0);
 472  478                          nzomb--;
 473  479                          bzero(&bigwad->lwpsinfo, sizeof (bigwad->lwpsinfo));
 474  480                          bigwad->lwpsinfo.pr_lwpid = lep->le_lwpid;
 475  481                          bigwad->lwpsinfo.pr_state = SZOMB;
 476  482                          bigwad->lwpsinfo.pr_sname = 'Z';
 477  483                          bigwad->lwpsinfo.pr_start.tv_sec = lep->le_start;
 478  484                  }
      485 +
      486 +                name.pr_lwpid = bigwad->lwpsinfo.pr_lwpid;
      487 +
 479  488                  error = elfnote(vp, &offset, NT_LWPSINFO,
 480  489                      sizeof (bigwad->lwpsinfo), (caddr_t)&bigwad->lwpsinfo,
 481  490                      rlimit, credp);
 482  491                  if (error)
 483  492                          goto done;
      493 +
 484  494                  if (t == NULL)          /* nothing more to do for a zombie */
 485  495                          continue;
 486  496  
 487  497                  mutex_enter(&p->p_lock);
 488  498                  if (t == curthread) {
 489  499                          /*
 490  500                           * Modify t_whystop and lwp_cursig so it appears that
 491  501                           * the current LWP is stopped after faulting on the
 492  502                           * signal that caused the core dump.  As a result,
 493  503                           * prgetlwpstatus() will record that signal, the saved
↓ open down ↓ 13 lines elided ↑ open up ↑
 507  517                  } else {
 508  518                          prgetlwpstatus(t, &bigwad->lwpstatus, p->p_zone);
 509  519                  }
 510  520                  mutex_exit(&p->p_lock);
 511  521                  error = elfnote(vp, &offset, NT_LWPSTATUS,
 512  522                      sizeof (bigwad->lwpstatus), (caddr_t)&bigwad->lwpstatus,
 513  523                      rlimit, credp);
 514  524                  if (error)
 515  525                          goto done;
 516  526  
      527 +                if ((error = elfnote(vp, &offset, NT_LWPNAME, sizeof (name),
      528 +                    (caddr_t)&name, rlimit, credp)) != 0)
      529 +                        goto done;
      530 +
      531 +
 517  532  #if defined(__sparc)
 518  533                  /*
 519  534                   * Unspilled SPARC register windows.
 520  535                   */
 521  536                  {
 522  537                          size_t size = prnwindows(lwp);
 523  538  
 524  539                          if (size != 0) {
 525  540                                  size = sizeof (gwindows_t) -
 526  541                                      (SPARC_MAXREGWINDOW - size) *
↓ open down ↓ 61 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX