Print this page
3946 ::gcore
Reviewed by: Adam Leventhal <ahl@delphix.com>
Reviewed by: Matthew Ahrens <mahrens@delphix.com>

Split Close
Expand all
Collapse all
          --- old/usr/src/lib/libproc/common/Plwpregs.c
          +++ new/usr/src/lib/libproc/common/Plwpregs.c
↓ open down ↓ 17 lines elided ↑ open up ↑
  18   18   *
  19   19   * CDDL HEADER END
  20   20   */
  21   21  /*
  22   22   * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
  23   23   * Use is subject to license terms.
  24   24   */
  25   25  
  26   26  /*
  27   27   * Copyright (c) 2013, Joyent, Inc. All rights reserved.
       28 + * Copyright (c) 2013 by Delphix. All rights reserved.
  28   29   */
  29   30  
  30   31  #include <sys/types.h>
  31   32  #include <sys/uio.h>
  32   33  #include <string.h>
  33   34  #include <errno.h>
  34   35  #include <limits.h>
  35   36  
  36   37  #include "Pcontrol.h"
  37   38  #include "P32ton.h"
↓ open down ↓ 5 lines elided ↑ open up ↑
  43   44   * information, and then the public functions are all trivial calls to these.
  44   45   */
  45   46  
  46   47  /*
  47   48   * Utility function to return a pointer to the structure of cached information
  48   49   * about an lwp in the core file, given its lwpid.
  49   50   */
  50   51  static lwp_info_t *
  51   52  getlwpcore(struct ps_prochandle *P, lwpid_t lwpid)
  52   53  {
  53      -        lwp_info_t *lwp = list_next(&P->core->core_lwp_head);
       54 +        core_info_t *core = P->data;
       55 +        lwp_info_t *lwp = list_next(&core->core_lwp_head);
  54   56          uint_t i;
  55   57  
  56      -        for (i = 0; i < P->core->core_nlwp; i++, lwp = list_next(lwp)) {
       58 +        for (i = 0; i < core->core_nlwp; i++, lwp = list_next(lwp)) {
  57   59                  if (lwp->lwp_id == lwpid)
  58   60                          return (lwp);
  59   61          }
  60   62  
  61   63          errno = EINVAL;
  62   64          return (NULL);
  63   65  }
  64   66  
  65   67  /*
  66   68   * Utility function to open and read the contents of a per-lwp /proc file.
↓ open down ↓ 44 lines elided ↑ open up ↑
 111  113           */
 112  114          if (P->state != PS_DEAD) {
 113  115                  return (getlwpfile(P, lwpid, "lwpstatus",
 114  116                      lps, sizeof (lwpstatus_t)));
 115  117          }
 116  118  
 117  119          /*
 118  120           * If this is a core file, we need to iterate through our list of
 119  121           * cached lwp information and then copy out the status.
 120  122           */
 121      -        if (P->core != NULL && (lwp = getlwpcore(P, lwpid)) != NULL) {
      123 +        if (P->data != NULL && (lwp = getlwpcore(P, lwpid)) != NULL) {
 122  124                  (void) memcpy(lps, &lwp->lwp_status, sizeof (lwpstatus_t));
 123  125                  return (0);
 124  126          }
 125  127  
 126  128          return (-1);
 127  129  }
 128  130  
 129  131  /*
 130  132   * Utility function to modify lwp registers.  This is done using either the
 131  133   * process control file or per-lwp control file as necessary.
↓ open down ↓ 404 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX