Print this page
    
uts: Allow for address space randomisation.
Randomise the base addresses of shared objects, non-fixed mappings, the
stack and the heap.  Introduce a service, svc:/system/process-security,
and a tool psecflags(1) to control and observe it
    
      
        | Split | Close | 
      | Expand all | 
      | Collapse all | 
    
    
          --- old/usr/src/cmd/sgs/elfdump/common/corenote.c
          +++ new/usr/src/cmd/sgs/elfdump/common/corenote.c
   1    1  /*
   2    2   * CDDL HEADER START
   3    3   *
   4    4   * The contents of this file are subject to the terms of the
   5    5   * Common Development and Distribution License (the "License").
   6    6   * You may not use this file except in compliance with the License.
   7    7   *
   8    8   * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
   9    9   * or http://www.opensolaris.org/os/licensing.
  10   10   * See the License for the specific language governing permissions
  11   11   * and limitations under the License.
  12   12   *
  13   13   * When distributing Covered Code, include this CDDL HEADER in each
  14   14   * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15   15   * If applicable, add the following below this CDDL HEADER, with the
  16   16   * fields enclosed by brackets "[]" replaced with your own identifying
  17   17   * information: Portions Copyright [yyyy] [name of copyright owner]
  18   18   *
  19   19   * CDDL HEADER END
  20   20   */
  21   21  
  22   22  /*
  23   23   * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
  24   24   * Use is subject to license terms.
  25   25   */
  26   26  /*
  27   27   * Copyright 2012 DEY Storage Systems, Inc.  All rights reserved.
  28   28   * Copyright (c) 2013, Joyent, Inc. All rights reserved.
  29   29   */
  30   30  
  31   31  #include <stdlib.h>
  32   32  #include <stdio.h>
  33   33  #include <string.h>
  34   34  #include <sys/types.h>
  35   35  #include <unistd.h>
  36   36  #include <sys/corectl.h>
  37   37  #include <msg.h>
  38   38  #include <_elfdump.h>
  39   39  #include <struct_layout.h>
  40   40  #include <conv.h>
  41   41  
  42   42  
  43   43  /*
  44   44   * This module contains the code that displays data from the note
  45   45   * sections found in Solaris core files. The format of these
  46   46   * note sections are described in the core(4) manpage.
  47   47   */
  48   48  
  49   49  
  50   50  
  51   51  
  52   52  /*
  53   53   * Much of the code in this file uses the "%*s" format to set
  54   54   * the left margin indentation. This macro combines the indent
  55   55   * integer argument and the NULL string that follows it.
  56   56   */
  57   57  #define INDENT state->ns_indent, MSG_ORIG(MSG_STR_EMPTY)
  58   58  
  59   59  /*
  60   60   * Indent unit, used for each nesting
  61   61   */
  62   62  #define INDENT_STEP 4
  63   63  
  64   64  /*
  65   65   * The PRINT_ macros are convenience wrappers on print_num(),
  66   66   * print_subtype(), and print_strbuf(). They reduce code
  67   67   * clutter by hiding the boilerplate arguments.
  68   68   *
  69   69   * Assumptions:
  70   70   *      - A variable named "layout" exists in the compilation
  71   71   *              environment, referencing the layout information for the
  72   72   *              current type.
  73   73   *      - The variable "state" references the current note state.
  74   74   */
  75   75  #define PRINT_DEC(_title, _field) \
  76   76          print_num(state, _title, &layout->_field, SL_FMT_NUM_DEC)
  77   77  #define PRINT_DEC_2UP(_title1, _field1, _title2, _field2) \
  78   78          print_num_2up(state, _title1, &layout->_field1, SL_FMT_NUM_DEC, \
  79   79              _title2, &layout->_field2, SL_FMT_NUM_DEC)
  80   80  #define PRINT_HEX(_title, _field) \
  81   81          print_num(state, _title, &layout->_field, SL_FMT_NUM_HEX)
  82   82  #define PRINT_HEX_2UP(_title1, _field1, _title2, _field2) \
  83   83          print_num_2up(state, _title1, &layout->_field1, SL_FMT_NUM_HEX, \
  84   84              _title2, &layout->_field2, SL_FMT_NUM_HEX)
  85   85  #define PRINT_ZHEX(_title, _field) \
  86   86          print_num(state, _title, &layout->_field, SL_FMT_NUM_ZHEX)
  87   87  #define PRINT_ZHEX_2UP(_title1, _field1, _title2, _field2) \
  88   88          print_num_2up(state, _title1, &layout->_field1, SL_FMT_NUM_ZHEX, \
  89   89              _title2, &layout->_field2, SL_FMT_NUM_ZHEX)
  90   90  #define PRINT_SUBTYPE(_title, _field, _func) \
  91   91          print_subtype(state, _title, &layout->_field, _func)
  92   92  #define PRINT_STRBUF(_title, _field) \
  93   93          print_strbuf(state, _title, &layout->_field)
  94   94  
  95   95  
  96   96  
  97   97  /*
  98   98   * Structure used to maintain state data for a core note, or a subregion
  99   99   * (sub-struct) of a core note. These values would otherwise need to be
 100  100   * passed to nearly every routine.
 101  101   */
 102  102  typedef struct {
 103  103          Half            ns_mach;        /* ELF machine type of core file */
 104  104          const sl_arch_layout_t *ns_arch; /* structure layout def for mach */
 105  105          int             ns_swap;        /* True if byte swapping is needed */
 106  106          int             ns_indent;      /* Left margin indentation */
 107  107          int             ns_vcol;        /* Column where value starts */
 108  108          int             ns_t2col;       /* Column where 2up title starts */
 109  109          int             ns_v2col;       /* Column where 2up value starts */
 110  110          const char      *ns_data;       /* Pointer to struct data area */
 111  111          Word            ns_len;         /* Length of struct data area */
 112  112  } note_state_t;
 113  113  
 114  114  /*
 115  115   * Standard signature for a dump function used to process a note
 116  116   * or a sub-structure within a note.
 117  117   */
 118  118  typedef void (* dump_func_t)(note_state_t *state, const char *title);
 119  119  
 120  120  
 121  121  
 122  122  
 123  123  
 124  124  
 125  125  /*
 126  126   * Some core notes contain string buffers of fixed size
 127  127   * that are expected to contain NULL terminated strings.
 128  128   * If the NULL is there, we can print these strings directly.
 129  129   * However, the potential exists for a corrupt file to have
 130  130   * a non-terminated buffer. This routine examines the given
 131  131   * string, and if the string is terminated, the string itself
 132  132   * is returned. Otherwise, it is copied to a static buffer,
 133  133   * and a pointer to the buffer is returned.
 134  134   */
 135  135  static const char *
 136  136  safe_str(const char *str, size_t n)
 137  137  {
 138  138          static char     buf[512];
 139  139          char            *s;
 140  140          size_t          i;
 141  141  
 142  142          if (n == 0)
 143  143                  return (MSG_ORIG(MSG_STR_EMPTY));
 144  144  
 145  145          for (i = 0; i < n; i++)
 146  146                  if (str[i] == '\0')
 147  147                          return (str);
 148  148  
 149  149          i = (n >= sizeof (buf)) ? (sizeof (buf) - 4) : (n - 1);
 150  150          (void) memcpy(buf, str, i);
 151  151          s = buf + i;
 152  152          if (n >= sizeof (buf)) {
 153  153                  *s++ = '.';
 154  154                  *s++ = '.';
 155  155                  *s++ = '.';
 156  156          }
 157  157          *s = '\0';
 158  158          return (buf);
 159  159  }
 160  160  
 161  161  /*
 162  162   * Convenience wrappers on top of the corresponding sl_XXX() functions.
 163  163   */
 164  164  static Word
 165  165  extract_as_word(note_state_t *state, const sl_field_t *fdesc)
 166  166  {
 167  167          return (sl_extract_as_word(state->ns_data, state->ns_swap, fdesc));
 168  168  }
 169  169  static Word
 170  170  extract_as_lword(note_state_t *state, const sl_field_t *fdesc)
 171  171  {
 172  172          return (sl_extract_as_lword(state->ns_data, state->ns_swap, fdesc));
 173  173  }
 174  174  static int
 175  175  extract_as_sword(note_state_t *state, const sl_field_t *fdesc)
 176  176  {
 177  177          return (sl_extract_as_sword(state->ns_data, state->ns_swap, fdesc));
 178  178  }
 179  179  static const char *
 180  180  fmt_num(note_state_t *state, const sl_field_t *fdesc,
 181  181      sl_fmt_num_t fmt_type, sl_fmtbuf_t buf)
 182  182  {
 183  183          return (sl_fmt_num(state->ns_data, state->ns_swap, fdesc,
 184  184              fmt_type, buf));
 185  185  }
 186  186  
 187  187  
 188  188  /*
 189  189   * Return true of the data for the specified field is available.
 190  190   */
 191  191  inline static int
 192  192  data_present(note_state_t *state, const sl_field_t *fdesc)
 193  193  {
 194  194          return ((fdesc->slf_offset + fdesc->slf_eltlen) <= state->ns_len);
 195  195  }
 196  196  
 197  197  /*
 198  198   * indent_enter/exit are used to start/end output for a subitem.
 199  199   * On entry, a title is output, and the indentation level is raised
 200  200   * by one unit. On exit, the indentation level is restrored to its
 201  201   * previous value.
 202  202   */
 203  203  static void
 204  204  indent_enter(note_state_t *state, const char *title,
 205  205      const sl_field_t *first_fdesc)
 206  206  {
 207  207          /*
 208  208           * If the first field offset and extent fall past the end of the
 209  209           * available data, then return without printing a title. That note
 210  210           * is from an older core file that doesn't have all the fields
 211  211           * that we know about.
 212  212           */
 213  213          if (data_present(state, first_fdesc))
 214  214                  dbg_print(0, MSG_ORIG(MSG_CNOTE_FMT_TITLE), INDENT, title);
 215  215  
 216  216          state->ns_indent += INDENT_STEP;
 217  217  }
 218  218  static void
 219  219  indent_exit(note_state_t *state)
 220  220  {
 221  221          state->ns_indent -= INDENT_STEP;
 222  222  }
 223  223  
 224  224  
 225  225  /*
 226  226   * print_num outputs a field on one line, in the format:
 227  227   *
 228  228   *      title: value
 229  229   */
 230  230  static void
 231  231  print_num(note_state_t *state, const char *title,
 232  232      const sl_field_t *fdesc, sl_fmt_num_t fmt_type)
 233  233  {
 234  234          sl_fmtbuf_t     buf;
 235  235  
 236  236          /*
 237  237           * If the field offset and extent fall past the end of the
 238  238           * available data, then return without doing anything. That note
 239  239           * is from an older core file that doesn't have all the fields
 240  240           * that we know about.
 241  241           */
 242  242          if (!data_present(state, fdesc))
 243  243                  return;
 244  244  
 245  245          dbg_print(0, MSG_ORIG(MSG_CNOTE_FMT_LINE), INDENT,
 246  246              state->ns_vcol - state->ns_indent, title,
 247  247              fmt_num(state, fdesc, fmt_type, buf));
 248  248  }
 249  249  
 250  250  /*
 251  251   * print_num_2up outputs two fields on one line, in the format:
 252  252   *
 253  253   *      title1: value1  title2: value2
 254  254   */
 255  255  static void
 256  256  print_num_2up(note_state_t *state, const char *title1,
 257  257      const sl_field_t *fdesc1, sl_fmt_num_t fmt_type1, const char *title2,
 258  258      const sl_field_t *fdesc2, sl_fmt_num_t fmt_type2)
 259  259  {
 260  260          sl_fmtbuf_t     buf1, buf2;
 261  261  
 262  262          /*
 263  263           * If the field offset and extent fall past the end of the
 264  264           * available data, then return without doing anything. That note
 265  265           * is from an older core file that doesn't have all the fields
 266  266           * that we know about.
 267  267           */
 268  268          if (!(data_present(state, fdesc1) &&
 269  269              data_present(state, fdesc2)))
 270  270                  return;
 271  271  
 272  272          dbg_print(0, MSG_ORIG(MSG_CNOTE_FMT_LINE_2UP), INDENT,
 273  273              state->ns_vcol - state->ns_indent, title1,
 274  274              state->ns_t2col - state->ns_vcol,
 275  275              fmt_num(state, fdesc1, fmt_type1, buf1),
 276  276              state->ns_v2col - state->ns_t2col, title2,
 277  277              fmt_num(state, fdesc2, fmt_type2, buf2));
 278  278  }
 279  279  
 280  280  /*
 281  281   * print_strbuf outputs a fixed sized character buffer field
 282  282   * on one line, in the format:
 283  283   *
 284  284   *      title: value
 285  285   */
 286  286  static void
 287  287  print_strbuf(note_state_t *state, const char *title,
 288  288      const sl_field_t *fdesc)
 289  289  {
 290  290          Word    n;
 291  291  
 292  292          /*
 293  293           * If we are past the end of the data area, then return
 294  294           * without doing anything. That note is from an older core
 295  295           * file that doesn't have all the fields that we know about.
 296  296           *
 297  297           * Note that we are willing to accept a partial buffer,
 298  298           * so we don't use data_present() for this test.
 299  299           */
 300  300          if (fdesc->slf_offset >= state->ns_len)
 301  301                  return;
 302  302  
 303  303          /*
 304  304           * We expect the full buffer to be present, but if there
 305  305           * is less than that, we will still proceed. The use of safe_str()
 306  306           * protects us from the effect of printing garbage data.
 307  307           */
 308  308          n = state->ns_len - fdesc->slf_offset;
 309  309          if (n > fdesc->slf_nelts)
 310  310                  n = fdesc->slf_nelts;
 311  311  
 312  312          dbg_print(0, MSG_ORIG(MSG_CNOTE_FMT_LINE), INDENT,
 313  313              state->ns_vcol - state->ns_indent,
 314  314              title, safe_str(fdesc->slf_offset + state->ns_data, n));
 315  315  }
 316  316  
 317  317  /*
 318  318   * print_str outputs an arbitrary string value item
 319  319   * on one line, in the format:
 320  320   *
 321  321   *      title: str
 322  322   */
 323  323  static void
 324  324  print_str(note_state_t *state, const char *title, const char *str)
 325  325  {
 326  326          dbg_print(0, MSG_ORIG(MSG_CNOTE_FMT_LINE), INDENT,
 327  327              state->ns_vcol - state->ns_indent, title, str);
 328  328  }
 329  329  
 330  330  /*
 331  331   * Used when one dump function needs to call another dump function
 332  332   * in order to display a subitem. This routine constructs a state
 333  333   * block for the sub-region, and then calls the dump function with it.
 334  334   * This limits the amount of data visible to the sub-function to that
 335  335   * for the sub-item.
 336  336   */
 337  337  static void
 338  338  print_subtype(note_state_t *state, const char *title,
 339  339      const sl_field_t *fdesc, dump_func_t dump_func)
 340  340  {
 341  341          note_state_t sub_state;
 342  342  
 343  343          /*
 344  344           * If there is no data for the sub-item, return immediately.
 345  345           * Partial data is left to the dump function to handle,
 346  346           * as that can be a sign of an older core file with less data,
 347  347           * which can still be interpreted.
 348  348           */
 349  349          if (fdesc->slf_offset >= state->ns_len)
 350  350                  return;
 351  351  
 352  352          /*
 353  353           * Construct a state block that reflects the sub-item
 354  354           */
 355  355          sub_state = *state;
 356  356          sub_state.ns_data += fdesc->slf_offset;
 357  357          sub_state.ns_len -= fdesc->slf_offset;
 358  358          if (sub_state.ns_len > fdesc->slf_eltlen)
 359  359                  sub_state.ns_len = fdesc->slf_eltlen;
 360  360  
 361  361          (* dump_func)(&sub_state, title);
 362  362  }
 363  363  
 364  364  
 365  365  /*
 366  366   * Output a sequence of array elements, giving each
 367  367   * element an index, in the format:
 368  368   *
 369  369   *      [ndx] value
 370  370   *
 371  371   * entry:
 372  372   *      state - Current state
 373  373   *      base_desc - Field descriptor for 1st element of array
 374  374   *      nelts - # of array elements to display
 375  375   *      check_nelts - If True (1), nelts is clipped to fdesc->slf_nelts.
 376  376   *              If False (1), nelts is not clipped.
 377  377   *      title - Name of array
 378  378   */
 379  379  static void
 380  380  print_array(note_state_t *state, const sl_field_t *base_desc,
 381  381      sl_fmt_num_t fmt_type, int nelts, int check_nelts, const char *title)
 382  382  {
 383  383          char            index1[MAXNDXSIZE], index2[MAXNDXSIZE];
 384  384          int             i;
 385  385          sl_field_t      fdesc1, fdesc2;
 386  386  
 387  387          if (check_nelts && (check_nelts > base_desc->slf_nelts))
 388  388                  nelts = base_desc->slf_nelts;
 389  389          if (nelts == 0)
 390  390                  return;
 391  391  
 392  392          indent_enter(state, title, base_desc);
 393  393  
 394  394          fdesc1 = fdesc2 = *base_desc;
 395  395          for (i = 0; i < nelts; ) {
 396  396                  if (i == (nelts - 1)) {
 397  397                          /*  One final value is left  */
 398  398                          if (!data_present(state, &fdesc1))
 399  399                                  break;
 400  400                          (void) snprintf(index1, sizeof (index1),
 401  401                              MSG_ORIG(MSG_FMT_INDEX2), EC_WORD(i));
 402  402                          print_num(state, index1, &fdesc1, fmt_type);
 403  403                          fdesc1.slf_offset += fdesc1.slf_eltlen;
 404  404                          i++;
 405  405                          continue;
 406  406                  }
 407  407  
 408  408                  /* There are at least 2 items left. Show 2 up. */
 409  409                  fdesc2.slf_offset = fdesc1.slf_offset + fdesc1.slf_eltlen;
 410  410                  if (!(data_present(state, &fdesc1) &&
 411  411                      data_present(state, &fdesc2)))
 412  412                          break;
 413  413                  (void) snprintf(index1, sizeof (index1),
 414  414                      MSG_ORIG(MSG_FMT_INDEX2), EC_WORD(i));
 415  415                  (void) snprintf(index2, sizeof (index2),
 416  416                      MSG_ORIG(MSG_FMT_INDEX2), EC_WORD(i + 1));
 417  417                  print_num_2up(state, index1, &fdesc1, fmt_type,
 418  418                      index2, &fdesc2, fmt_type);
 419  419                  fdesc1.slf_offset += 2 * fdesc1.slf_eltlen;
 420  420                  i += 2;
 421  421          }
 422  422  
 423  423          indent_exit(state);
 424  424  }
 425  425  
 426  426  
 427  427  /*
 428  428   * Output information from auxv_t structure.
  
    | ↓ open down ↓ | 428 lines elided | ↑ open up ↑ | 
 429  429   */
 430  430  static void
 431  431  dump_auxv(note_state_t *state, const char *title)
 432  432  {
 433  433          const sl_auxv_layout_t  *layout = state->ns_arch->auxv;
 434  434          union {
 435  435                  Conv_cap_val_hw1_buf_t          hw1;
 436  436                  Conv_cap_val_hw2_buf_t          hw2;
 437  437                  Conv_cnote_auxv_af_buf_t        auxv_af;
 438  438                  Conv_ehdr_flags_buf_t           ehdr_flags;
      439 +                Conv_secflags_buf_t             secflags;
 439  440                  Conv_inv_buf_t                  inv;
 440  441          } conv_buf;
 441  442          sl_fmtbuf_t     buf;
 442  443          int             ndx, ndx_start;
 443  444          Word            sizeof_auxv;
 444  445  
 445  446          sizeof_auxv = layout->sizeof_struct.slf_eltlen;
 446  447  
 447  448          indent_enter(state, title, &layout->sizeof_struct);
 448  449  
 449  450          /*
 450  451           * Immediate indent_exit() restores the indent level to
 451  452           * that of the title. We include indentation as part of
 452  453           * the index string, which is right justified, and don't
 453  454           * want the usual indentation spacing.
 454  455           */
 455  456          indent_exit(state);
 456  457  
 457  458          ndx = 0;
 458  459          while (state->ns_len > sizeof_auxv) {
 459  460                  char            index[(MAXNDXSIZE * 2) + 1];
 460  461                  sl_fmt_num_t    num_fmt = SL_FMT_NUM_ZHEX;
 461  462                  const char      *vstr = NULL;
 462  463                  Word            w;
 463  464                  int             type;
 464  465                  sl_field_t      a_type_next;
 465  466  
 466  467                  type = extract_as_word(state, &layout->a_type);
 467  468                  ndx_start = ndx;
 468  469                  switch (type) {
 469  470                  case AT_NULL:
 470  471                          a_type_next = layout->a_type;
 471  472                          a_type_next.slf_offset += sizeof_auxv;
 472  473                          while ((state->ns_len - sizeof_auxv) >= sizeof_auxv) {
 473  474                                  type = extract_as_word(state, &a_type_next);
 474  475                                  if (type != AT_NULL)
 475  476                                          break;
 476  477                                  ndx++;
 477  478                                  state->ns_data += sizeof_auxv;
 478  479                                  state->ns_len -= sizeof_auxv;
 479  480                          }
  
    | ↓ open down ↓ | 31 lines elided | ↑ open up ↑ | 
 480  481                          num_fmt = SL_FMT_NUM_HEX;
 481  482                          break;
 482  483  
 483  484  
 484  485  
 485  486                  case AT_IGNORE:
 486  487                  case AT_SUN_IFLUSH:
 487  488                          num_fmt = SL_FMT_NUM_HEX;
 488  489                          break;
 489  490  
      491 +                case AT_SUN_SECFLAGS:
      492 +                        w = extract_as_word(state, &layout->a_val);
      493 +                        vstr = conv_psecflags(w, 0, &conv_buf.secflags);
      494 +                        break;
      495 +
 490  496                  case AT_EXECFD:
 491  497                  case AT_PHENT:
 492  498                  case AT_PHNUM:
 493  499                  case AT_PAGESZ:
 494  500                  case AT_SUN_UID:
 495  501                  case AT_SUN_RUID:
 496  502                  case AT_SUN_GID:
 497  503                  case AT_SUN_RGID:
 498  504                  case AT_SUN_LPAGESZ:
 499  505                          num_fmt = SL_FMT_NUM_DEC;
 500  506                          break;
 501  507  
 502  508                  case AT_FLAGS:  /* processor flags */
 503  509                          w = extract_as_word(state, &layout->a_val);
 504  510                          vstr = conv_ehdr_flags(state->ns_mach, w,
 505  511                              0, &conv_buf.ehdr_flags);
 506  512                          break;
 507  513  
 508  514                  case AT_SUN_HWCAP:
 509  515                          w = extract_as_word(state, &layout->a_val);
 510  516                          vstr = conv_cap_val_hw1(w, state->ns_mach,
 511  517                              0, &conv_buf.hw1);
 512  518                          /*
 513  519                           * conv_cap_val_hw1() produces output like:
 514  520                           *
 515  521                           *      0xfff [ flg1 flg2 0xff]
 516  522                           *
 517  523                           * where the first hex value is the complete value,
 518  524                           * and the second is the leftover bits. We only
 519  525                           * want the part in brackets, and failing that,
 520  526                           * would rather fall back to formatting the full
 521  527                           * value ourselves.
 522  528                           */
 523  529                          while ((*vstr != '\0') && (*vstr != '['))
 524  530                                  vstr++;
 525  531                          if (*vstr != '[')
 526  532                                  vstr = NULL;
 527  533                          num_fmt = SL_FMT_NUM_HEX;
 528  534                          break;
 529  535                  case AT_SUN_HWCAP2:
 530  536                          w = extract_as_word(state, &layout->a_val);
 531  537                          vstr = conv_cap_val_hw2(w, state->ns_mach,
 532  538                              0, &conv_buf.hw2);
 533  539                          /*
 534  540                           * conv_cap_val_hw2() produces output like:
 535  541                           *
 536  542                           *      0xfff [ flg1 flg2 0xff]
 537  543                           *
 538  544                           * where the first hex value is the complete value,
 539  545                           * and the second is the leftover bits. We only
 540  546                           * want the part in brackets, and failing that,
 541  547                           * would rather fall back to formatting the full
 542  548                           * value ourselves.
 543  549                           */
 544  550                          while ((*vstr != '\0') && (*vstr != '['))
 545  551                                  vstr++;
 546  552                          if (*vstr != '[')
 547  553                                  vstr = NULL;
 548  554                          num_fmt = SL_FMT_NUM_HEX;
 549  555                          break;
 550  556  
 551  557  
 552  558  
 553  559                  case AT_SUN_AUXFLAGS:
 554  560                          w = extract_as_word(state, &layout->a_val);
 555  561                          vstr = conv_cnote_auxv_af(w, 0, &conv_buf.auxv_af);
 556  562                          num_fmt = SL_FMT_NUM_HEX;
 557  563                          break;
 558  564                  }
 559  565  
 560  566                  if (ndx == ndx_start)
 561  567                          (void) snprintf(index, sizeof (index),
 562  568                              MSG_ORIG(MSG_FMT_INDEX2), EC_WORD(ndx));
 563  569                  else
 564  570                          (void) snprintf(index, sizeof (index),
 565  571                              MSG_ORIG(MSG_FMT_INDEXRNG),
 566  572                              EC_WORD(ndx_start), EC_WORD(ndx));
 567  573  
 568  574                  if (vstr == NULL)
 569  575                          vstr = fmt_num(state, &layout->a_val, num_fmt, buf);
 570  576                  dbg_print(0, MSG_ORIG(MSG_CNOTE_FMT_AUXVLINE), INDENT, index,
 571  577                      state->ns_vcol - state->ns_indent,
 572  578                      conv_cnote_auxv_type(type, CONV_FMT_DECIMAL,
 573  579                      &conv_buf.inv), vstr);
 574  580  
 575  581                  state->ns_data += sizeof_auxv;
 576  582                  state->ns_len -= sizeof_auxv;
 577  583                  ndx++;
 578  584          }
 579  585  }
 580  586  
 581  587  
 582  588  /*
 583  589   * Output information from fltset_t structure.
 584  590   */
 585  591  static void
 586  592  dump_fltset(note_state_t *state, const char *title)
 587  593  {
 588  594  #define NELTS 4
 589  595  
 590  596          const sl_fltset_layout_t        *layout = state->ns_arch->fltset;
 591  597          Conv_cnote_fltset_buf_t buf;
 592  598          sl_field_t              fdesc;
 593  599          uint32_t                mask[NELTS];
 594  600          int                     i, nelts;
 595  601  
 596  602          if (!data_present(state, &layout->sizeof_struct))
 597  603                  return;
 598  604  
 599  605          fdesc = layout->word;
 600  606          nelts = fdesc.slf_nelts;
 601  607          if (nelts > NELTS)      /* Type has grown? Show what we understand */
 602  608                  nelts = NELTS;
 603  609          for (i = 0; i < nelts; i++) {
 604  610                  mask[i] = extract_as_word(state, &fdesc);
 605  611                  fdesc.slf_offset += fdesc.slf_eltlen;
 606  612          }
 607  613  
 608  614          print_str(state, title, conv_cnote_fltset(mask, nelts, 0, &buf));
 609  615  
 610  616  #undef NELTS
 611  617  }
 612  618  
 613  619  
 614  620  /*
 615  621   * Output information from sigset_t structure.
 616  622   */
 617  623  static void
 618  624  dump_sigset(note_state_t *state, const char *title)
 619  625  {
 620  626  #define NELTS 4
 621  627  
 622  628          const sl_sigset_layout_t        *layout = state->ns_arch->sigset;
 623  629          Conv_cnote_sigset_buf_t buf;
 624  630          sl_field_t              fdesc;
 625  631          uint32_t                mask[NELTS];
 626  632          int                     i, nelts;
 627  633  
 628  634          if (!data_present(state, &layout->sizeof_struct))
 629  635                  return;
 630  636  
 631  637          fdesc = layout->sigbits;
 632  638          nelts = fdesc.slf_nelts;
 633  639          if (nelts > NELTS)      /* Type has grown? Show what we understand */
 634  640                  nelts = NELTS;
 635  641          for (i = 0; i < nelts; i++) {
 636  642                  mask[i] = extract_as_word(state, &fdesc);
 637  643                  fdesc.slf_offset += fdesc.slf_eltlen;
 638  644          }
 639  645  
 640  646          print_str(state, title, conv_cnote_sigset(mask, nelts, 0, &buf));
 641  647  
 642  648  #undef NELTS
 643  649  }
 644  650  
 645  651  
 646  652  /*
 647  653   * Output information from sigaction structure.
 648  654   */
 649  655  static void
 650  656  dump_sigaction(note_state_t *state, const char *title)
 651  657  {
 652  658          const sl_sigaction_layout_t     *layout = state->ns_arch->sigaction;
 653  659          Conv_cnote_sa_flags_buf_t       conv_buf;
 654  660          Word    w;
 655  661  
 656  662          indent_enter(state, title, &layout->sa_flags);
 657  663  
 658  664          if (data_present(state, &layout->sa_flags)) {
 659  665                  w = extract_as_word(state, &layout->sa_flags);
 660  666                  print_str(state, MSG_ORIG(MSG_CNOTE_T_SA_FLAGS),
 661  667                      conv_cnote_sa_flags(w, 0, &conv_buf));
 662  668          }
 663  669  
 664  670          PRINT_ZHEX_2UP(MSG_ORIG(MSG_CNOTE_T_SA_HANDLER), sa_hand,
 665  671              MSG_ORIG(MSG_CNOTE_T_SA_SIGACTION), sa_sigact);
 666  672          PRINT_SUBTYPE(MSG_ORIG(MSG_CNOTE_T_SA_MASK), sa_mask, dump_sigset);
 667  673  
 668  674          indent_exit(state);
 669  675  }
 670  676  
 671  677  
 672  678  /*
 673  679   * Output information from siginfo structure.
 674  680   */
 675  681  static void
 676  682  dump_siginfo(note_state_t *state, const char *title)
 677  683  {
 678  684          const sl_siginfo_layout_t       *layout = state->ns_arch->siginfo;
 679  685          Conv_inv_buf_t  inv_buf;
 680  686          Word            w;
 681  687          int             v_si_code, v_si_signo;
 682  688  
 683  689          if (!data_present(state, &layout->sizeof_struct))
 684  690                  return;
 685  691  
 686  692          indent_enter(state, title, &layout->f_si_signo);
 687  693  
 688  694          v_si_signo = extract_as_sword(state, &layout->f_si_signo);
 689  695          print_str(state, MSG_ORIG(MSG_CNOTE_T_SI_SIGNO),
 690  696              conv_cnote_signal(v_si_signo, CONV_FMT_DECIMAL, &inv_buf));
 691  697  
 692  698          w = extract_as_word(state, &layout->f_si_errno);
 693  699          print_str(state, MSG_ORIG(MSG_CNOTE_T_SI_ERRNO),
 694  700              conv_cnote_errno(w, CONV_FMT_DECIMAL, &inv_buf));
 695  701  
 696  702          v_si_code = extract_as_sword(state, &layout->f_si_code);
 697  703          print_str(state, MSG_ORIG(MSG_CNOTE_T_SI_CODE),
 698  704              conv_cnote_si_code(state->ns_mach, v_si_signo, v_si_code,
 699  705              CONV_FMT_DECIMAL, &inv_buf));
 700  706  
 701  707          if ((v_si_signo == 0) || (v_si_code == SI_NOINFO)) {
 702  708                  indent_exit(state);
 703  709                  return;
 704  710          }
 705  711  
 706  712          /* User generated signals have (si_code <= 0) */
 707  713          if (v_si_code <= 0) {
 708  714                  PRINT_DEC(MSG_ORIG(MSG_CNOTE_T_SI_PID), f_si_pid);
 709  715                  PRINT_DEC(MSG_ORIG(MSG_CNOTE_T_SI_UID), f_si_uid);
 710  716                  PRINT_DEC(MSG_ORIG(MSG_CNOTE_T_SI_CTID), f_si_ctid);
 711  717                  PRINT_DEC(MSG_ORIG(MSG_CNOTE_T_SI_ZONEID), f_si_zoneid);
 712  718                  switch (v_si_code) {
 713  719                  case SI_QUEUE:
 714  720                  case SI_TIMER:
 715  721                  case SI_ASYNCIO:
 716  722                  case SI_MESGQ:
 717  723                          indent_enter(state, MSG_ORIG(MSG_CNOTE_T_SI_VALUE),
 718  724                              &layout->f_si_value_int);
 719  725                          PRINT_ZHEX(MSG_ORIG(MSG_CNOTE_T_SIVAL_INT),
 720  726                              f_si_value_int);
 721  727                          PRINT_ZHEX(MSG_ORIG(MSG_CNOTE_T_SIVAL_PTR),
 722  728                              f_si_value_ptr);
 723  729                          indent_exit(state);
 724  730                          break;
 725  731                  }
 726  732                  indent_exit(state);
 727  733                  return;
 728  734          }
 729  735  
 730  736          /*
 731  737           * Remaining cases are kernel generated signals. Output any
 732  738           * signal or code specific information.
 733  739           */
 734  740          if (v_si_code == SI_RCTL)
 735  741                  PRINT_HEX(MSG_ORIG(MSG_CNOTE_T_SI_ENTITY), f_si_entity);
 736  742          switch (v_si_signo) {
 737  743          case SIGILL:
 738  744          case SIGFPE:
 739  745          case SIGSEGV:
 740  746          case SIGBUS:
 741  747                  PRINT_ZHEX(MSG_ORIG(MSG_CNOTE_T_SI_ADDR), f_si_addr);
 742  748                  break;
 743  749          case SIGCHLD:
 744  750                  PRINT_DEC(MSG_ORIG(MSG_CNOTE_T_SI_PID), f_si_pid);
 745  751                  PRINT_DEC(MSG_ORIG(MSG_CNOTE_T_SI_STATUS), f_si_status);
 746  752                  break;
 747  753          case SIGPOLL:
 748  754                  PRINT_DEC(MSG_ORIG(MSG_CNOTE_T_SI_BAND), f_si_band);
 749  755                  break;
 750  756          }
 751  757  
 752  758          indent_exit(state);
 753  759  }
 754  760  
 755  761  
 756  762  /*
 757  763   * Output information from stack_t structure.
 758  764   */
 759  765  static void
 760  766  dump_stack(note_state_t *state, const char *title)
 761  767  {
 762  768          const sl_stack_layout_t         *layout = state->ns_arch->stack;
 763  769          Conv_cnote_ss_flags_buf_t       conv_buf;
 764  770          Word            w;
 765  771  
 766  772          indent_enter(state, title, &layout->ss_size);
 767  773  
 768  774          print_num_2up(state, MSG_ORIG(MSG_CNOTE_T_SS_SP), &layout->ss_sp,
 769  775              SL_FMT_NUM_ZHEX, MSG_ORIG(MSG_CNOTE_T_SS_SIZE), &layout->ss_size,
 770  776              SL_FMT_NUM_HEX);
 771  777  
 772  778          if (data_present(state, &layout->ss_flags)) {
 773  779                  w = extract_as_word(state, &layout->ss_flags);
 774  780                  print_str(state, MSG_ORIG(MSG_CNOTE_T_SS_FLAGS),
 775  781                      conv_cnote_ss_flags(w, 0, &conv_buf));
 776  782          }
 777  783  
 778  784          indent_exit(state);
 779  785  }
 780  786  
 781  787  
 782  788  /*
 783  789   * Output information from sysset_t structure.
 784  790   */
 785  791  static void
 786  792  dump_sysset(note_state_t *state, const char *title)
 787  793  {
 788  794  #define NELTS 16
 789  795  
 790  796          const sl_sysset_layout_t        *layout = state->ns_arch->sysset;
 791  797          Conv_cnote_sysset_buf_t buf;
 792  798          sl_field_t              fdesc;
 793  799          uint32_t                mask[NELTS];
 794  800          int                     i, nelts;
 795  801  
 796  802          if (!data_present(state, &layout->sizeof_struct))
 797  803                  return;
 798  804  
 799  805          fdesc = layout->word;
 800  806          nelts = fdesc.slf_nelts;
 801  807          if (nelts > NELTS)      /* Type has grown? Show what we understand */
 802  808                  nelts = NELTS;
 803  809          for (i = 0; i < nelts; i++) {
 804  810                  mask[i] = extract_as_word(state, &fdesc);
 805  811                  fdesc.slf_offset += fdesc.slf_eltlen;
 806  812          }
 807  813  
 808  814          print_str(state, title, conv_cnote_sysset(mask, nelts, 0, &buf));
 809  815  
 810  816  #undef NELTS
 811  817  }
 812  818  
 813  819  
 814  820  /*
 815  821   * Output information from timestruc_t structure.
 816  822   */
 817  823  static void
 818  824  dump_timestruc(note_state_t *state, const char *title)
 819  825  {
  
    | ↓ open down ↓ | 320 lines elided | ↑ open up ↑ | 
 820  826          const sl_timestruc_layout_t *layout = state->ns_arch->timestruc;
 821  827  
 822  828          indent_enter(state, title, &layout->tv_sec);
 823  829  
 824  830          PRINT_DEC_2UP(MSG_ORIG(MSG_CNOTE_T_TV_SEC), tv_sec,
 825  831              MSG_ORIG(MSG_CNOTE_T_TV_NSEC), tv_nsec);
 826  832  
 827  833          indent_exit(state);
 828  834  }
 829  835  
      836 +/*
      837 + * Output information from psecflags_t structure.
      838 + */
      839 +static void
      840 +dump_secflags(note_state_t *state, const char *title)
      841 +{
      842 +        const sl_psecflags_layout_t *layout = state->ns_arch->psecflags;
      843 +        Conv_secflags_buf_t inv;
      844 +        Word w;
      845 +
      846 +        indent_enter(state, title, &layout->psf_effective);
      847 +
      848 +        w = extract_as_word(state, &layout->psf_effective);
      849 +        print_str(state, MSG_ORIG(MSG_CNOTE_T_PSF_EFFECTIVE),
      850 +            conv_psecflags(w, 0, &inv));
      851 +
      852 +        w = extract_as_word(state, &layout->psf_inherit);
      853 +        print_str(state, MSG_ORIG(MSG_CNOTE_T_PSF_INHERIT),
      854 +            conv_psecflags(w, 0, &inv));
      855 +}
 830  856  
 831  857  /*
 832  858   * Output information from utsname structure.
 833  859   */
 834  860  static void
 835  861  dump_utsname(note_state_t *state, const char *title)
 836  862  {
 837  863          const sl_utsname_layout_t       *layout = state->ns_arch->utsname;
 838  864  
 839  865          indent_enter(state, title, &layout->sysname);
 840  866  
 841  867          PRINT_STRBUF(MSG_ORIG(MSG_CNOTE_T_UTS_SYSNAME), sysname);
 842  868          PRINT_STRBUF(MSG_ORIG(MSG_CNOTE_T_UTS_NODENAME), nodename);
 843  869          PRINT_STRBUF(MSG_ORIG(MSG_CNOTE_T_UTS_RELEASE), release);
 844  870          PRINT_STRBUF(MSG_ORIG(MSG_CNOTE_T_UTS_VERSION), version);
 845  871          PRINT_STRBUF(MSG_ORIG(MSG_CNOTE_T_UTS_MACHINE), machine);
 846  872  
 847  873          indent_exit(state);
 848  874  }
 849  875  
 850  876  
 851  877  /*
 852  878   * Dump register contents
 853  879   */
 854  880  static void
 855  881  dump_prgregset(note_state_t *state, const char *title)
 856  882  {
 857  883          sl_field_t      fdesc1, fdesc2;
 858  884          sl_fmtbuf_t     buf1, buf2;
 859  885          Conv_inv_buf_t  inv_buf1, inv_buf2;
 860  886          Word            w;
 861  887  
 862  888          fdesc1 = fdesc2 = state->ns_arch->prgregset->elt0;
 863  889          indent_enter(state, title, &fdesc1);
 864  890  
 865  891          for (w = 0; w < fdesc1.slf_nelts; ) {
 866  892                  if (w == (fdesc1.slf_nelts - 1)) {
 867  893                          /* One last register is left */
 868  894                          if (!data_present(state, &fdesc1))
 869  895                                  break;
 870  896                          dbg_print(0, MSG_ORIG(MSG_CNOTE_FMT_LINE),
 871  897                              INDENT, state->ns_vcol - state->ns_indent,
 872  898                              conv_cnote_pr_regname(state->ns_mach, w,
 873  899                              CONV_FMT_DECIMAL, &inv_buf1),
 874  900                              fmt_num(state, &fdesc1, SL_FMT_NUM_ZHEX, buf1));
 875  901                          fdesc1.slf_offset += fdesc1.slf_eltlen;
 876  902                          w++;
 877  903                          continue;
 878  904                  }
 879  905  
 880  906                  /* There are at least 2 more registers left. Show 2 up */
 881  907                  fdesc2.slf_offset = fdesc1.slf_offset + fdesc1.slf_eltlen;
 882  908                  if (!(data_present(state, &fdesc1) &&
 883  909                      data_present(state, &fdesc2)))
 884  910                          break;
 885  911                  dbg_print(0, MSG_ORIG(MSG_CNOTE_FMT_LINE_2UP), INDENT,
 886  912                      state->ns_vcol - state->ns_indent,
 887  913                      conv_cnote_pr_regname(state->ns_mach, w,
 888  914                      CONV_FMT_DECIMAL, &inv_buf1),
 889  915                      state->ns_t2col - state->ns_vcol,
 890  916                      fmt_num(state, &fdesc1, SL_FMT_NUM_ZHEX, buf1),
 891  917                      state->ns_v2col - state->ns_t2col,
 892  918                      conv_cnote_pr_regname(state->ns_mach, w + 1,
 893  919                      CONV_FMT_DECIMAL, &inv_buf2),
 894  920                      fmt_num(state, &fdesc2, SL_FMT_NUM_ZHEX, buf2));
 895  921                  fdesc1.slf_offset += 2 * fdesc1.slf_eltlen;
 896  922                  w += 2;
 897  923          }
 898  924  
 899  925          indent_exit(state);
 900  926  }
 901  927  
 902  928  /*
 903  929   * Output information from lwpstatus_t structure.
 904  930   */
 905  931  static void
 906  932  dump_lwpstatus(note_state_t *state, const char *title)
 907  933  {
 908  934          const sl_lwpstatus_layout_t     *layout = state->ns_arch->lwpstatus;
 909  935          Word            w, w2;
 910  936          int32_t         i;
 911  937          union {
 912  938                  Conv_inv_buf_t                  inv;
 913  939                  Conv_cnote_pr_flags_buf_t       flags;
 914  940          } conv_buf;
 915  941  
 916  942          indent_enter(state, title, &layout->pr_flags);
 917  943  
 918  944          if (data_present(state, &layout->pr_flags)) {
 919  945                  w = extract_as_word(state, &layout->pr_flags);
 920  946                  print_str(state, MSG_ORIG(MSG_CNOTE_T_PR_FLAGS),
 921  947                      conv_cnote_pr_flags(w, 0, &conv_buf.flags));
 922  948          }
 923  949  
 924  950          PRINT_DEC(MSG_ORIG(MSG_CNOTE_T_PR_LWPID), pr_lwpid);
 925  951  
 926  952          if (data_present(state, &layout->pr_why)) {
 927  953                  w = extract_as_word(state, &layout->pr_why);
 928  954                  print_str(state, MSG_ORIG(MSG_CNOTE_T_PR_WHY),
 929  955                      conv_cnote_pr_why(w, 0, &conv_buf.inv));
 930  956  
 931  957                  if (data_present(state, &layout->pr_what)) {
 932  958                          w2 = extract_as_word(state, &layout->pr_what);
 933  959                          print_str(state, MSG_ORIG(MSG_CNOTE_T_PR_WHAT),
 934  960                              conv_cnote_pr_what(w, w2, 0, &conv_buf.inv));
 935  961                  }
 936  962          }
 937  963  
 938  964          if (data_present(state, &layout->pr_cursig)) {
 939  965                  w = extract_as_word(state, &layout->pr_cursig);
 940  966                  print_str(state, MSG_ORIG(MSG_CNOTE_T_PR_CURSIG),
 941  967                      conv_cnote_signal(w, CONV_FMT_DECIMAL, &conv_buf.inv));
 942  968          }
 943  969  
 944  970          PRINT_SUBTYPE(MSG_ORIG(MSG_CNOTE_T_PR_INFO), pr_info, dump_siginfo);
 945  971          PRINT_SUBTYPE(MSG_ORIG(MSG_CNOTE_T_PR_LWPPEND), pr_lwppend,
 946  972              dump_sigset);
 947  973          PRINT_SUBTYPE(MSG_ORIG(MSG_CNOTE_T_PR_LWPHOLD), pr_lwphold,
 948  974              dump_sigset);
 949  975          PRINT_SUBTYPE(MSG_ORIG(MSG_CNOTE_T_PR_ACTION), pr_action,
 950  976              dump_sigaction);
 951  977          PRINT_SUBTYPE(MSG_ORIG(MSG_CNOTE_T_PR_ALTSTACK), pr_altstack,
 952  978              dump_stack);
 953  979  
 954  980          PRINT_ZHEX(MSG_ORIG(MSG_CNOTE_T_PR_OLDCONTEXT), pr_oldcontext);
 955  981  
 956  982          if (data_present(state, &layout->pr_syscall)) {
 957  983                  w = extract_as_word(state, &layout->pr_syscall);
 958  984                  print_str(state, MSG_ORIG(MSG_CNOTE_T_PR_SYSCALL),
 959  985                      conv_cnote_syscall(w, CONV_FMT_DECIMAL, &conv_buf.inv));
 960  986          }
 961  987  
 962  988          PRINT_DEC(MSG_ORIG(MSG_CNOTE_T_PR_NSYSARG), pr_nsysarg);
 963  989  
 964  990          if (data_present(state, &layout->pr_errno)) {
 965  991                  w = extract_as_word(state, &layout->pr_errno);
 966  992                  print_str(state, MSG_ORIG(MSG_CNOTE_T_PR_ERRNO),
 967  993                      conv_cnote_errno(w, CONV_FMT_DECIMAL, &conv_buf.inv));
 968  994          }
 969  995  
 970  996          if (data_present(state, &layout->pr_nsysarg)) {
 971  997                  w2 = extract_as_word(state, &layout->pr_nsysarg);
 972  998                  print_array(state, &layout->pr_sysarg, SL_FMT_NUM_ZHEX, w2, 1,
 973  999                      MSG_ORIG(MSG_CNOTE_T_PR_SYSARG));
 974 1000          }
 975 1001  
 976 1002          PRINT_HEX_2UP(MSG_ORIG(MSG_CNOTE_T_PR_RVAL1), pr_rval1,
 977 1003              MSG_ORIG(MSG_CNOTE_T_PR_RVAL2), pr_rval2);
 978 1004          PRINT_STRBUF(MSG_ORIG(MSG_CNOTE_T_PR_CLNAME), pr_clname);
 979 1005          PRINT_SUBTYPE(MSG_ORIG(MSG_CNOTE_T_PR_TSTAMP), pr_tstamp,
 980 1006              dump_timestruc);
 981 1007          PRINT_SUBTYPE(MSG_ORIG(MSG_CNOTE_T_PR_UTIME), pr_utime, dump_timestruc);
 982 1008          PRINT_SUBTYPE(MSG_ORIG(MSG_CNOTE_T_PR_STIME), pr_stime, dump_timestruc);
 983 1009  
 984 1010          if (data_present(state, &layout->pr_errpriv)) {
 985 1011                  i = extract_as_sword(state, &layout->pr_errpriv);
 986 1012                  print_str(state, MSG_ORIG(MSG_CNOTE_T_PR_ERRPRIV),
 987 1013                      conv_cnote_priv(i, CONV_FMT_DECIMAL, &conv_buf.inv));
 988 1014          }
 989 1015  
 990 1016          PRINT_ZHEX_2UP(MSG_ORIG(MSG_CNOTE_T_PR_USTACK), pr_ustack,
 991 1017              MSG_ORIG(MSG_CNOTE_T_PR_INSTR), pr_instr);
 992 1018  
 993 1019          /*
 994 1020           * In order to line up all the values in a single column,
 995 1021           * we would have to set vcol to a very high value, which results
 996 1022           * in ugly looking output that runs off column 80. So, we use
 997 1023           * two levels of vcol, one for the contents so far, and a
 998 1024           * higher one for the pr_reg sub-struct.
 999 1025           */
1000 1026          state->ns_vcol += 3;
1001 1027          state->ns_t2col += 3;
1002 1028          state->ns_v2col += 2;
1003 1029          PRINT_SUBTYPE(MSG_ORIG(MSG_CNOTE_T_PR_REG), pr_reg, dump_prgregset);
1004 1030          state->ns_vcol -= 3;
1005 1031          state->ns_t2col -= 3;
1006 1032          state->ns_v2col -= 2;
1007 1033  
1008 1034          /*
1009 1035           * The floating point register state is complex, and highly
1010 1036           * platform dependent. For now, we simply display it as
1011 1037           * a hex dump. This can be replaced if better information
1012 1038           * is required.
1013 1039           */
1014 1040          if (data_present(state, &layout->pr_fpreg)) {
1015 1041                  indent_enter(state, MSG_ORIG(MSG_CNOTE_T_PR_FPREG),
1016 1042                      &layout->pr_fpreg);
1017 1043                  dump_hex_bytes(layout->pr_fpreg.slf_offset + state->ns_data,
1018 1044                      layout->pr_fpreg.slf_eltlen, state->ns_indent, 4, 3);
1019 1045                  indent_exit(state);
1020 1046          }
1021 1047  
1022 1048          indent_exit(state);
1023 1049  }
1024 1050  
1025 1051  
1026 1052  /*
1027 1053   * Output information from pstatus_t structure.
1028 1054   */
1029 1055  static void
1030 1056  dump_pstatus(note_state_t *state, const char *title)
1031 1057  {
1032 1058          const sl_pstatus_layout_t       *layout = state->ns_arch->pstatus;
1033 1059          Word                            w;
1034 1060          union {
1035 1061                  Conv_inv_buf_t                  inv;
1036 1062                  Conv_cnote_pr_flags_buf_t       flags;
1037 1063          } conv_buf;
1038 1064  
1039 1065          indent_enter(state, title, &layout->pr_flags);
1040 1066  
1041 1067          if (data_present(state, &layout->pr_flags)) {
1042 1068                  w = extract_as_word(state, &layout->pr_flags);
1043 1069                  print_str(state, MSG_ORIG(MSG_CNOTE_T_PR_FLAGS),
1044 1070                      conv_cnote_pr_flags(w, 0, &conv_buf.flags));
1045 1071          }
1046 1072  
1047 1073          PRINT_DEC(MSG_ORIG(MSG_CNOTE_T_PR_NLWP), pr_nlwp);
1048 1074          PRINT_DEC_2UP(MSG_ORIG(MSG_CNOTE_T_PR_PID), pr_pid,
1049 1075              MSG_ORIG(MSG_CNOTE_T_PR_PPID), pr_ppid);
1050 1076          PRINT_DEC_2UP(MSG_ORIG(MSG_CNOTE_T_PR_PGID), pr_pgid,
1051 1077              MSG_ORIG(MSG_CNOTE_T_PR_SID), pr_sid);
1052 1078          PRINT_DEC_2UP(MSG_ORIG(MSG_CNOTE_T_PR_ASLWPID), pr_aslwpid,
1053 1079              MSG_ORIG(MSG_CNOTE_T_PR_AGENTID), pr_agentid);
1054 1080          PRINT_SUBTYPE(MSG_ORIG(MSG_CNOTE_T_PR_SIGPEND), pr_sigpend,
1055 1081              dump_sigset);
1056 1082          print_num_2up(state, MSG_ORIG(MSG_CNOTE_T_PR_BRKBASE),
1057 1083              &layout->pr_brkbase, SL_FMT_NUM_ZHEX,
1058 1084              MSG_ORIG(MSG_CNOTE_T_PR_BRKSIZE),
1059 1085              &layout->pr_brksize, SL_FMT_NUM_HEX);
1060 1086          print_num_2up(state, MSG_ORIG(MSG_CNOTE_T_PR_STKBASE),
1061 1087              &layout->pr_stkbase, SL_FMT_NUM_ZHEX,
1062 1088              MSG_ORIG(MSG_CNOTE_T_PR_STKSIZE),
1063 1089              &layout->pr_stksize, SL_FMT_NUM_HEX);
1064 1090          PRINT_SUBTYPE(MSG_ORIG(MSG_CNOTE_T_PR_UTIME), pr_utime, dump_timestruc);
1065 1091          PRINT_SUBTYPE(MSG_ORIG(MSG_CNOTE_T_PR_STIME), pr_stime, dump_timestruc);
1066 1092          PRINT_SUBTYPE(MSG_ORIG(MSG_CNOTE_T_PR_CUTIME), pr_cutime,
1067 1093              dump_timestruc);
1068 1094          PRINT_SUBTYPE(MSG_ORIG(MSG_CNOTE_T_PR_CSTIME), pr_cstime,
1069 1095              dump_timestruc);
1070 1096          PRINT_SUBTYPE(MSG_ORIG(MSG_CNOTE_T_PR_SIGTRACE), pr_sigtrace,
1071 1097              dump_sigset);
1072 1098          PRINT_SUBTYPE(MSG_ORIG(MSG_CNOTE_T_PR_FLTTRACE), pr_flttrace,
1073 1099              dump_fltset);
1074 1100          PRINT_SUBTYPE(MSG_ORIG(MSG_CNOTE_T_PR_SYSENTRY), pr_sysentry,
1075 1101              dump_sysset);
1076 1102          PRINT_SUBTYPE(MSG_ORIG(MSG_CNOTE_T_PR_SYSEXIT), pr_sysexit,
1077 1103              dump_sysset);
1078 1104  
1079 1105          if (data_present(state, &layout->pr_dmodel)) {
1080 1106                  w = extract_as_word(state, &layout->pr_dmodel);
1081 1107                  print_str(state, MSG_ORIG(MSG_CNOTE_T_PR_DMODEL),
1082 1108                      conv_cnote_pr_dmodel(w, 0, &conv_buf.inv));
1083 1109          }
1084 1110  
1085 1111          PRINT_DEC_2UP(MSG_ORIG(MSG_CNOTE_T_PR_TASKID), pr_taskid,
1086 1112              MSG_ORIG(MSG_CNOTE_T_PR_PROJID), pr_projid);
1087 1113          PRINT_DEC_2UP(MSG_ORIG(MSG_CNOTE_T_PR_NZOMB), pr_nzomb,
1088 1114              MSG_ORIG(MSG_CNOTE_T_PR_ZONEID), pr_zoneid);
1089 1115  
  
    | ↓ open down ↓ | 250 lines elided | ↑ open up ↑ | 
1090 1116          /*
1091 1117           * In order to line up all the values in a single column,
1092 1118           * we would have to set vcol to a very high value, which results
1093 1119           * in ugly looking output that runs off column 80. So, we use
1094 1120           * two levels of vcol, one for the contents so far, and a
1095 1121           * higher one for the pr_lwp sub-struct.
1096 1122           */
1097 1123          state->ns_vcol += 5;
1098 1124          state->ns_t2col += 5;
1099 1125          state->ns_v2col += 5;
     1126 +
     1127 +        PRINT_SUBTYPE(MSG_ORIG(MSG_CNOTE_T_PR_SECFLAGS), pr_secflags,
     1128 +            dump_secflags);
     1129 +
1100 1130          PRINT_SUBTYPE(MSG_ORIG(MSG_CNOTE_T_PR_LWP), pr_lwp, dump_lwpstatus);
1101 1131          state->ns_vcol -= 5;
1102 1132          state->ns_t2col -= 5;
1103 1133          state->ns_v2col -= 5;
1104 1134  
1105 1135          indent_exit(state);
1106 1136  }
1107 1137  
1108 1138  
1109 1139  /*
1110 1140   * Output information from prstatus_t (<sys/old_procfs.h>) structure.
1111 1141   */
1112 1142  static void
1113 1143  dump_prstatus(note_state_t *state, const char *title)
1114 1144  {
1115 1145          const sl_prstatus_layout_t      *layout = state->ns_arch->prstatus;
1116 1146          Word                            w, w2;
1117 1147          int                             i;
1118 1148          union {
1119 1149                  Conv_inv_buf_t                  inv;
1120 1150                  Conv_cnote_old_pr_flags_buf_t   flags;
1121 1151          } conv_buf;
1122 1152  
1123 1153          indent_enter(state, title, &layout->pr_flags);
1124 1154  
1125 1155          if (data_present(state, &layout->pr_flags)) {
1126 1156                  w = extract_as_word(state, &layout->pr_flags);
1127 1157                  print_str(state, MSG_ORIG(MSG_CNOTE_T_PR_FLAGS),
1128 1158                      conv_cnote_old_pr_flags(w, 0, &conv_buf.flags));
1129 1159          }
1130 1160  
1131 1161          if (data_present(state, &layout->pr_why)) {
1132 1162                  w = extract_as_word(state, &layout->pr_why);
1133 1163                  print_str(state, MSG_ORIG(MSG_CNOTE_T_PR_WHY),
1134 1164                      conv_cnote_pr_why(w, 0, &conv_buf.inv));
1135 1165  
1136 1166  
1137 1167                  if (data_present(state, &layout->pr_what)) {
1138 1168                          w2 = extract_as_word(state, &layout->pr_what);
1139 1169                          print_str(state, MSG_ORIG(MSG_CNOTE_T_PR_WHAT),
1140 1170                              conv_cnote_pr_what(w, w2, 0, &conv_buf.inv));
1141 1171                  }
1142 1172          }
1143 1173  
1144 1174          PRINT_SUBTYPE(MSG_ORIG(MSG_CNOTE_T_PR_INFO), pr_info, dump_siginfo);
1145 1175  
1146 1176          if (data_present(state, &layout->pr_cursig)) {
1147 1177                  w = extract_as_word(state, &layout->pr_cursig);
1148 1178                  print_str(state, MSG_ORIG(MSG_CNOTE_T_PR_CURSIG),
1149 1179                      conv_cnote_signal(w, CONV_FMT_DECIMAL, &conv_buf.inv));
1150 1180          }
1151 1181  
1152 1182          PRINT_DEC(MSG_ORIG(MSG_CNOTE_T_PR_NLWP), pr_nlwp);
1153 1183          PRINT_SUBTYPE(MSG_ORIG(MSG_CNOTE_T_PR_SIGPEND), pr_sigpend,
1154 1184              dump_sigset);
1155 1185          PRINT_SUBTYPE(MSG_ORIG(MSG_CNOTE_T_PR_SIGHOLD), pr_sighold,
1156 1186              dump_sigset);
1157 1187          PRINT_SUBTYPE(MSG_ORIG(MSG_CNOTE_T_PR_ALTSTACK), pr_altstack,
1158 1188              dump_stack);
1159 1189          PRINT_SUBTYPE(MSG_ORIG(MSG_CNOTE_T_PR_ACTION), pr_action,
1160 1190              dump_sigaction);
1161 1191          PRINT_DEC_2UP(MSG_ORIG(MSG_CNOTE_T_PR_PID), pr_pid,
1162 1192              MSG_ORIG(MSG_CNOTE_T_PR_PPID), pr_ppid);
1163 1193          PRINT_DEC_2UP(MSG_ORIG(MSG_CNOTE_T_PR_PGRP), pr_pgrp,
1164 1194              MSG_ORIG(MSG_CNOTE_T_PR_SID), pr_sid);
1165 1195          PRINT_SUBTYPE(MSG_ORIG(MSG_CNOTE_T_PR_UTIME), pr_utime, dump_timestruc);
1166 1196          PRINT_SUBTYPE(MSG_ORIG(MSG_CNOTE_T_PR_STIME), pr_stime, dump_timestruc);
1167 1197          PRINT_SUBTYPE(MSG_ORIG(MSG_CNOTE_T_PR_CUTIME), pr_cutime,
1168 1198              dump_timestruc);
1169 1199          PRINT_SUBTYPE(MSG_ORIG(MSG_CNOTE_T_PR_CSTIME), pr_cstime,
1170 1200              dump_timestruc);
1171 1201          PRINT_STRBUF(MSG_ORIG(MSG_CNOTE_T_PR_CLNAME), pr_clname);
1172 1202  
1173 1203          if (data_present(state, &layout->pr_syscall)) {
1174 1204                  w = extract_as_word(state, &layout->pr_syscall);
1175 1205                  print_str(state, MSG_ORIG(MSG_CNOTE_T_PR_SYSCALL),
1176 1206                      conv_cnote_syscall(w, CONV_FMT_DECIMAL, &conv_buf.inv));
1177 1207          }
1178 1208  
1179 1209          PRINT_DEC(MSG_ORIG(MSG_CNOTE_T_PR_NSYSARG), pr_nsysarg);
1180 1210  
1181 1211          if (data_present(state, &layout->pr_nsysarg)) {
1182 1212                  w2 = extract_as_word(state, &layout->pr_nsysarg);
1183 1213                  print_array(state, &layout->pr_sysarg, SL_FMT_NUM_ZHEX, w2, 1,
1184 1214                      MSG_ORIG(MSG_CNOTE_T_PR_SYSARG));
1185 1215          }
1186 1216  
1187 1217          PRINT_DEC(MSG_ORIG(MSG_CNOTE_T_PR_WHO), pr_who);
1188 1218          PRINT_SUBTYPE(MSG_ORIG(MSG_CNOTE_T_PR_LWPPEND), pr_sigpend,
1189 1219              dump_sigset);
1190 1220          PRINT_ZHEX(MSG_ORIG(MSG_CNOTE_T_PR_OLDCONTEXT), pr_oldcontext);
1191 1221          print_num_2up(state, MSG_ORIG(MSG_CNOTE_T_PR_BRKBASE),
1192 1222              &layout->pr_brkbase, SL_FMT_NUM_ZHEX,
1193 1223              MSG_ORIG(MSG_CNOTE_T_PR_BRKSIZE),
1194 1224              &layout->pr_brksize, SL_FMT_NUM_HEX);
1195 1225          print_num_2up(state, MSG_ORIG(MSG_CNOTE_T_PR_STKBASE),
1196 1226              &layout->pr_stkbase, SL_FMT_NUM_ZHEX,
1197 1227              MSG_ORIG(MSG_CNOTE_T_PR_STKSIZE),
1198 1228              &layout->pr_stksize, SL_FMT_NUM_HEX);
1199 1229          PRINT_DEC(MSG_ORIG(MSG_CNOTE_T_PR_PROCESSOR), pr_processor);
1200 1230  
1201 1231          if (data_present(state, &layout->pr_bind)) {
1202 1232                  i = extract_as_sword(state, &layout->pr_bind);
1203 1233                  print_str(state, MSG_ORIG(MSG_CNOTE_T_PR_BIND),
1204 1234                      conv_cnote_psetid(i, CONV_FMT_DECIMAL, &conv_buf.inv));
1205 1235          }
1206 1236  
1207 1237          PRINT_ZHEX(MSG_ORIG(MSG_CNOTE_T_PR_INSTR), pr_instr);
1208 1238          PRINT_SUBTYPE(MSG_ORIG(MSG_CNOTE_T_PR_REG), pr_reg, dump_prgregset);
1209 1239  
1210 1240          indent_exit(state);
1211 1241  }
1212 1242  
1213 1243  
1214 1244  /*
1215 1245   * Print percent from 16-bit binary fraction [0 .. 1]
1216 1246   * Round up .01 to .1 to indicate some small percentage (the 0x7000 below).
1217 1247   *
1218 1248   * Note: This routine was copied from ps(1) and then modified.
1219 1249   */
1220 1250  static const char *
1221 1251  prtpct_value(note_state_t *state, const sl_field_t *fdesc,
1222 1252      sl_fmtbuf_t buf)
1223 1253  {
1224 1254          uint_t value;           /* need 32 bits to compute with */
1225 1255  
1226 1256          value = extract_as_word(state, fdesc);
1227 1257          value = ((value * 1000) + 0x7000) >> 15;        /* [0 .. 1000] */
1228 1258          if (value >= 1000)
1229 1259                  value = 999;
1230 1260  
1231 1261          (void) snprintf(buf, sizeof (sl_fmtbuf_t),
1232 1262              MSG_ORIG(MSG_CNOTE_FMT_PRTPCT), value / 10, value % 10);
1233 1263  
1234 1264          return (buf);
1235 1265  }
1236 1266  
1237 1267  
1238 1268  
1239 1269  /*
1240 1270   * Version of prtpct() used for a 2-up display of two adjacent percentages.
1241 1271   */
1242 1272  static void
1243 1273  prtpct_2up(note_state_t *state, const sl_field_t *fdesc1,
1244 1274      const char *title1, const sl_field_t *fdesc2, const char *title2)
1245 1275  {
1246 1276          sl_fmtbuf_t     buf1, buf2;
1247 1277  
1248 1278          if (!(data_present(state, fdesc1) &&
1249 1279              data_present(state, fdesc2)))
1250 1280                  return;
1251 1281  
1252 1282          dbg_print(0, MSG_ORIG(MSG_CNOTE_FMT_LINE_2UP), INDENT,
1253 1283              state->ns_vcol - state->ns_indent, title1,
1254 1284              state->ns_t2col - state->ns_vcol,
1255 1285              prtpct_value(state, fdesc1, buf1),
1256 1286              state->ns_v2col - state->ns_t2col, title2,
1257 1287              prtpct_value(state, fdesc2, buf2));
1258 1288  }
1259 1289  
1260 1290  
1261 1291  /*
1262 1292   * The psinfo_t and prpsinfo_t structs have pr_state and pr_sname
1263 1293   * fields that we wish to print in a 2up format. The pr_state is
1264 1294   * an integer, while pr_sname is a single character.
1265 1295   */
1266 1296  static void
1267 1297  print_state_sname_2up(note_state_t *state,
1268 1298      const sl_field_t *state_fdesc,
1269 1299      const sl_field_t *sname_fdesc)
1270 1300  {
1271 1301          sl_fmtbuf_t     buf1, buf2;
1272 1302          int             sname;
1273 1303  
1274 1304          /*
1275 1305           * If the field slf_offset and extent fall past the end of the
1276 1306           * available data, then return without doing anything. That note
1277 1307           * is from an older core file that doesn't have all the fields
1278 1308           * that we know about.
1279 1309           */
1280 1310          if (!(data_present(state, state_fdesc) &&
1281 1311              data_present(state, sname_fdesc)))
1282 1312                  return;
1283 1313  
1284 1314          sname = extract_as_sword(state, sname_fdesc);
1285 1315          buf2[0] = sname;
1286 1316          buf2[1] = '\0';
1287 1317  
1288 1318          dbg_print(0, MSG_ORIG(MSG_CNOTE_FMT_LINE_2UP), INDENT,
1289 1319              state->ns_vcol - state->ns_indent, MSG_ORIG(MSG_CNOTE_T_PR_STATE),
1290 1320              state->ns_t2col - state->ns_vcol,
1291 1321              fmt_num(state, state_fdesc, SL_FMT_NUM_DEC, buf1),
1292 1322              state->ns_v2col - state->ns_t2col, MSG_ORIG(MSG_CNOTE_T_PR_SNAME),
1293 1323              buf2);
1294 1324  }
1295 1325  
1296 1326  /*
1297 1327   * Output information from lwpsinfo_t structure.
1298 1328   */
1299 1329  static void
1300 1330  dump_lwpsinfo(note_state_t *state, const char *title)
1301 1331  {
1302 1332          const sl_lwpsinfo_layout_t      *layout = state->ns_arch->lwpsinfo;
1303 1333          Word                    w;
1304 1334          int32_t                 i;
1305 1335          union {
1306 1336                  Conv_cnote_proc_flag_buf_t      proc_flag;
1307 1337                  Conv_inv_buf_t                  inv;
1308 1338          } conv_buf;
1309 1339  
1310 1340          indent_enter(state, title, &layout->pr_flag);
1311 1341  
1312 1342          if (data_present(state, &layout->pr_flag)) {
1313 1343                  w = extract_as_word(state, &layout->pr_flag);
1314 1344                  print_str(state, MSG_ORIG(MSG_CNOTE_T_PR_FLAG),
1315 1345                      conv_cnote_proc_flag(w, 0, &conv_buf.proc_flag));
1316 1346          }
1317 1347  
1318 1348          print_num_2up(state, MSG_ORIG(MSG_CNOTE_T_PR_LWPID), &layout->pr_lwpid,
1319 1349              SL_FMT_NUM_DEC, MSG_ORIG(MSG_CNOTE_T_PR_ADDR), &layout->pr_addr,
1320 1350              SL_FMT_NUM_ZHEX);
1321 1351          PRINT_HEX(MSG_ORIG(MSG_CNOTE_T_PR_WCHAN), pr_wchan);
1322 1352  
1323 1353          if (data_present(state, &layout->pr_stype)) {
1324 1354                  w = extract_as_word(state, &layout->pr_stype);
1325 1355                  print_str(state, MSG_ORIG(MSG_CNOTE_T_PR_STYPE),
1326 1356                      conv_cnote_pr_stype(w, CONV_FMT_DECIMAL, &conv_buf.inv));
1327 1357          }
1328 1358  
1329 1359          print_state_sname_2up(state, &layout->pr_state, &layout->pr_sname);
1330 1360  
1331 1361          PRINT_DEC(MSG_ORIG(MSG_CNOTE_T_PR_NICE), pr_nice);
1332 1362  
1333 1363          if (data_present(state, &layout->pr_syscall)) {
1334 1364                  w = extract_as_word(state, &layout->pr_syscall);
1335 1365                  print_str(state, MSG_ORIG(MSG_CNOTE_T_PR_SYSCALL),
1336 1366                      conv_cnote_syscall(w, CONV_FMT_DECIMAL, &conv_buf.inv));
1337 1367          }
1338 1368  
1339 1369          PRINT_DEC_2UP(MSG_ORIG(MSG_CNOTE_T_PR_OLDPRI), pr_oldpri,
1340 1370              MSG_ORIG(MSG_CNOTE_T_PR_CPU), pr_cpu);
1341 1371  
1342 1372          if (data_present(state, &layout->pr_pri) &&
1343 1373              data_present(state, &layout->pr_pctcpu)) {
1344 1374                  sl_fmtbuf_t     buf1, buf2;
1345 1375  
1346 1376                  dbg_print(0, MSG_ORIG(MSG_CNOTE_FMT_LINE_2UP), INDENT,
1347 1377                      state->ns_vcol - state->ns_indent,
1348 1378                      MSG_ORIG(MSG_CNOTE_T_PR_PRI),
1349 1379                      state->ns_t2col - state->ns_vcol,
1350 1380                      fmt_num(state, &layout->pr_pri, SL_FMT_NUM_DEC, buf1),
1351 1381                      state->ns_v2col - state->ns_t2col,
1352 1382                      MSG_ORIG(MSG_CNOTE_T_PR_PCTCPU),
1353 1383                      prtpct_value(state, &layout->pr_pctcpu, buf2));
1354 1384          }
1355 1385  
1356 1386          PRINT_SUBTYPE(MSG_ORIG(MSG_CNOTE_T_PR_START), pr_start, dump_timestruc);
1357 1387          PRINT_SUBTYPE(MSG_ORIG(MSG_CNOTE_T_PR_TIME), pr_time, dump_timestruc);
1358 1388          PRINT_STRBUF(MSG_ORIG(MSG_CNOTE_T_PR_CLNAME), pr_clname);
1359 1389          PRINT_STRBUF(MSG_ORIG(MSG_CNOTE_T_PR_NAME), pr_name);
1360 1390          PRINT_DEC_2UP(MSG_ORIG(MSG_CNOTE_T_PR_ONPRO), pr_onpro,
1361 1391              MSG_ORIG(MSG_CNOTE_T_PR_BINDPRO), pr_bindpro);
1362 1392  
1363 1393          if (data_present(state, &layout->pr_bindpset)) {
1364 1394                  i = extract_as_sword(state, &layout->pr_bindpset);
1365 1395                  print_str(state, MSG_ORIG(MSG_CNOTE_T_PR_BINDPSET),
1366 1396                      conv_cnote_psetid(i, CONV_FMT_DECIMAL, &conv_buf.inv));
1367 1397          }
1368 1398  
1369 1399          PRINT_DEC(MSG_ORIG(MSG_CNOTE_T_PR_LGRP), pr_lgrp);
1370 1400  
1371 1401          indent_exit(state);
1372 1402  }
1373 1403  
1374 1404  
1375 1405  /*
1376 1406   * Output information from psinfo_t structure.
1377 1407   */
1378 1408  static void
1379 1409  dump_psinfo(note_state_t *state, const char *title)
1380 1410  {
1381 1411          const sl_psinfo_layout_t        *layout = state->ns_arch->psinfo;
1382 1412          Word                            w;
1383 1413          union {
1384 1414                  Conv_cnote_proc_flag_buf_t      proc_flag;
1385 1415                  Conv_inv_buf_t                  inv;
1386 1416          } conv_buf;
1387 1417  
1388 1418          indent_enter(state, title, &layout->pr_flag);
1389 1419  
1390 1420          if (data_present(state, &layout->pr_flag)) {
1391 1421                  w = extract_as_word(state, &layout->pr_flag);
1392 1422                  print_str(state, MSG_ORIG(MSG_CNOTE_T_PR_FLAG),
1393 1423                      conv_cnote_proc_flag(w, 0, &conv_buf.proc_flag));
1394 1424          }
1395 1425  
1396 1426          PRINT_DEC(MSG_ORIG(MSG_CNOTE_T_PR_NLWP), pr_nlwp);
1397 1427          PRINT_DEC_2UP(MSG_ORIG(MSG_CNOTE_T_PR_PID), pr_pid,
1398 1428              MSG_ORIG(MSG_CNOTE_T_PR_PPID), pr_ppid);
1399 1429          PRINT_DEC_2UP(MSG_ORIG(MSG_CNOTE_T_PR_PGID), pr_pgid,
1400 1430              MSG_ORIG(MSG_CNOTE_T_PR_SID), pr_sid);
1401 1431          PRINT_DEC_2UP(MSG_ORIG(MSG_CNOTE_T_PR_UID), pr_uid,
1402 1432              MSG_ORIG(MSG_CNOTE_T_PR_EUID), pr_euid);
1403 1433          PRINT_DEC_2UP(MSG_ORIG(MSG_CNOTE_T_PR_GID), pr_gid,
1404 1434              MSG_ORIG(MSG_CNOTE_T_PR_EGID), pr_egid);
1405 1435          print_num_2up(state, MSG_ORIG(MSG_CNOTE_T_PR_ADDR), &layout->pr_addr,
1406 1436              SL_FMT_NUM_ZHEX, MSG_ORIG(MSG_CNOTE_T_PR_SIZE), &layout->pr_size,
1407 1437              SL_FMT_NUM_HEX);
1408 1438          print_num_2up(state, MSG_ORIG(MSG_CNOTE_T_PR_RSSIZE),
1409 1439              &layout->pr_rssize, SL_FMT_NUM_HEX, MSG_ORIG(MSG_CNOTE_T_PR_TTYDEV),
1410 1440              &layout->pr_ttydev, SL_FMT_NUM_DEC);
1411 1441          prtpct_2up(state, &layout->pr_pctcpu, MSG_ORIG(MSG_CNOTE_T_PR_PCTCPU),
1412 1442              &layout->pr_pctmem, MSG_ORIG(MSG_CNOTE_T_PR_PCTMEM));
1413 1443          PRINT_SUBTYPE(MSG_ORIG(MSG_CNOTE_T_PR_START), pr_start, dump_timestruc);
1414 1444          PRINT_SUBTYPE(MSG_ORIG(MSG_CNOTE_T_PR_TIME), pr_time, dump_timestruc);
1415 1445          PRINT_SUBTYPE(MSG_ORIG(MSG_CNOTE_T_PR_CTIME), pr_ctime, dump_timestruc);
1416 1446          PRINT_STRBUF(MSG_ORIG(MSG_CNOTE_T_PR_FNAME), pr_fname);
1417 1447          PRINT_STRBUF(MSG_ORIG(MSG_CNOTE_T_PR_PSARGS), pr_psargs);
1418 1448          print_num_2up(state, MSG_ORIG(MSG_CNOTE_T_PR_WSTAT), &layout->pr_wstat,
1419 1449              SL_FMT_NUM_HEX, MSG_ORIG(MSG_CNOTE_T_PR_ARGC), &layout->pr_argc,
1420 1450              SL_FMT_NUM_DEC);
1421 1451          PRINT_ZHEX_2UP(MSG_ORIG(MSG_CNOTE_T_PR_ARGV), pr_argv,
1422 1452              MSG_ORIG(MSG_CNOTE_T_PR_ENVP), pr_envp);
1423 1453  
1424 1454          if (data_present(state, &layout->pr_dmodel)) {
1425 1455                  w = extract_as_word(state, &layout->pr_dmodel);
1426 1456                  print_str(state, MSG_ORIG(MSG_CNOTE_T_PR_DMODEL),
1427 1457                      conv_cnote_pr_dmodel(w, 0, &conv_buf.inv));
1428 1458          }
1429 1459  
1430 1460          PRINT_DEC_2UP(MSG_ORIG(MSG_CNOTE_T_PR_TASKID), pr_taskid,
1431 1461              MSG_ORIG(MSG_CNOTE_T_PR_PROJID), pr_projid);
1432 1462          PRINT_DEC_2UP(MSG_ORIG(MSG_CNOTE_T_PR_NZOMB), pr_nzomb,
1433 1463              MSG_ORIG(MSG_CNOTE_T_PR_POOLID), pr_poolid);
1434 1464          PRINT_DEC_2UP(MSG_ORIG(MSG_CNOTE_T_PR_ZONEID), pr_zoneid,
1435 1465              MSG_ORIG(MSG_CNOTE_T_PR_CONTRACT), pr_contract);
1436 1466  
1437 1467          PRINT_SUBTYPE(MSG_ORIG(MSG_CNOTE_T_PR_LWP), pr_lwp, dump_lwpsinfo);
1438 1468  
1439 1469          indent_exit(state);
1440 1470  }
1441 1471  
1442 1472  /*
1443 1473   * Output information from prpsinfo_t structure.
1444 1474   */
1445 1475  static void
1446 1476  dump_prpsinfo(note_state_t *state, const char *title)
1447 1477  {
1448 1478          const sl_prpsinfo_layout_t      *layout = state->ns_arch->prpsinfo;
1449 1479          Word                            w;
1450 1480          union {
1451 1481                  Conv_cnote_proc_flag_buf_t      proc_flag;
1452 1482                  Conv_inv_buf_t                  inv;
1453 1483          } conv_buf;
1454 1484  
1455 1485          indent_enter(state, title, &layout->pr_state);
1456 1486  
1457 1487          print_state_sname_2up(state, &layout->pr_state, &layout->pr_sname);
1458 1488          PRINT_DEC_2UP(MSG_ORIG(MSG_CNOTE_T_PR_ZOMB), pr_zomb,
1459 1489              MSG_ORIG(MSG_CNOTE_T_PR_NICE), pr_nice);
1460 1490  
1461 1491          if (data_present(state, &layout->pr_flag)) {
1462 1492                  w = extract_as_word(state, &layout->pr_flag);
1463 1493                  print_str(state, MSG_ORIG(MSG_CNOTE_T_PR_FLAG),
1464 1494                      conv_cnote_proc_flag(w, 0, &conv_buf.proc_flag));
1465 1495          }
1466 1496  
1467 1497  
1468 1498          PRINT_DEC_2UP(MSG_ORIG(MSG_CNOTE_T_PR_UID), pr_uid,
1469 1499              MSG_ORIG(MSG_CNOTE_T_PR_GID), pr_gid);
1470 1500          PRINT_DEC_2UP(MSG_ORIG(MSG_CNOTE_T_PR_PID), pr_pid,
1471 1501              MSG_ORIG(MSG_CNOTE_T_PR_PPID), pr_ppid);
1472 1502          PRINT_DEC_2UP(MSG_ORIG(MSG_CNOTE_T_PR_PGRP), pr_pgrp,
1473 1503              MSG_ORIG(MSG_CNOTE_T_PR_SID), pr_sid);
1474 1504          print_num_2up(state, MSG_ORIG(MSG_CNOTE_T_PR_ADDR), &layout->pr_addr,
1475 1505              SL_FMT_NUM_ZHEX, MSG_ORIG(MSG_CNOTE_T_PR_SIZE), &layout->pr_size,
1476 1506              SL_FMT_NUM_HEX);
1477 1507          PRINT_HEX_2UP(MSG_ORIG(MSG_CNOTE_T_PR_RSSIZE), pr_rssize,
1478 1508              MSG_ORIG(MSG_CNOTE_T_PR_WCHAN), pr_wchan);
1479 1509          PRINT_SUBTYPE(MSG_ORIG(MSG_CNOTE_T_PR_START), pr_start, dump_timestruc);
1480 1510          PRINT_SUBTYPE(MSG_ORIG(MSG_CNOTE_T_PR_TIME), pr_time, dump_timestruc);
1481 1511          PRINT_DEC_2UP(MSG_ORIG(MSG_CNOTE_T_PR_PRI), pr_pri,
1482 1512              MSG_ORIG(MSG_CNOTE_T_PR_OLDPRI), pr_oldpri);
1483 1513          PRINT_DEC(MSG_ORIG(MSG_CNOTE_T_PR_CPU), pr_cpu);
1484 1514          PRINT_DEC_2UP(MSG_ORIG(MSG_CNOTE_T_PR_OTTYDEV), pr_ottydev,
1485 1515              MSG_ORIG(MSG_CNOTE_T_PR_LTTYDEV), pr_lttydev);
1486 1516          PRINT_STRBUF(MSG_ORIG(MSG_CNOTE_T_PR_CLNAME), pr_clname);
1487 1517          PRINT_STRBUF(MSG_ORIG(MSG_CNOTE_T_PR_FNAME), pr_fname);
1488 1518          PRINT_STRBUF(MSG_ORIG(MSG_CNOTE_T_PR_PSARGS), pr_psargs);
1489 1519  
1490 1520          if (data_present(state, &layout->pr_syscall)) {
1491 1521                  w = extract_as_word(state, &layout->pr_syscall);
1492 1522                  print_str(state, MSG_ORIG(MSG_CNOTE_T_PR_SYSCALL),
1493 1523                      conv_cnote_syscall(w, CONV_FMT_DECIMAL, &conv_buf.inv));
1494 1524          }
1495 1525  
1496 1526          PRINT_SUBTYPE(MSG_ORIG(MSG_CNOTE_T_PR_CTIME), pr_ctime, dump_timestruc);
1497 1527          PRINT_HEX_2UP(MSG_ORIG(MSG_CNOTE_T_PR_BYSIZE), pr_bysize,
1498 1528              MSG_ORIG(MSG_CNOTE_T_PR_BYRSSIZE), pr_byrssize);
1499 1529          print_num_2up(state, MSG_ORIG(MSG_CNOTE_T_PR_ARGC), &layout->pr_argc,
1500 1530              SL_FMT_NUM_DEC, MSG_ORIG(MSG_CNOTE_T_PR_ARGV), &layout->pr_argv,
1501 1531              SL_FMT_NUM_ZHEX);
1502 1532          print_num_2up(state, MSG_ORIG(MSG_CNOTE_T_PR_ENVP), &layout->pr_envp,
1503 1533              SL_FMT_NUM_ZHEX, MSG_ORIG(MSG_CNOTE_T_PR_WSTAT), &layout->pr_wstat,
1504 1534              SL_FMT_NUM_HEX);
1505 1535          prtpct_2up(state, &layout->pr_pctcpu, MSG_ORIG(MSG_CNOTE_T_PR_PCTCPU),
1506 1536              &layout->pr_pctmem, MSG_ORIG(MSG_CNOTE_T_PR_PCTMEM));
1507 1537          PRINT_DEC_2UP(MSG_ORIG(MSG_CNOTE_T_PR_EUID), pr_euid,
1508 1538              MSG_ORIG(MSG_CNOTE_T_PR_EGID), pr_egid);
1509 1539          PRINT_DEC(MSG_ORIG(MSG_CNOTE_T_PR_ASLWPID), pr_aslwpid);
1510 1540  
1511 1541          if (data_present(state, &layout->pr_dmodel)) {
1512 1542                  w = extract_as_word(state, &layout->pr_dmodel);
1513 1543                  print_str(state, MSG_ORIG(MSG_CNOTE_T_PR_DMODEL),
1514 1544                      conv_cnote_pr_dmodel(w, 0, &conv_buf.inv));
1515 1545          }
1516 1546  
1517 1547          indent_exit(state);
1518 1548  }
1519 1549  
1520 1550  
1521 1551  /*
1522 1552   * Output information from prcred_t structure.
1523 1553   */
1524 1554  static void
1525 1555  dump_prcred(note_state_t *state, const char *title)
1526 1556  {
1527 1557          const sl_prcred_layout_t *layout = state->ns_arch->prcred;
1528 1558          Word            ngroups;
1529 1559  
1530 1560          indent_enter(state, title, &layout->pr_euid);
1531 1561  
1532 1562          PRINT_DEC_2UP(MSG_ORIG(MSG_CNOTE_T_PR_EUID), pr_euid,
1533 1563              MSG_ORIG(MSG_CNOTE_T_PR_RUID), pr_ruid);
1534 1564          PRINT_DEC_2UP(MSG_ORIG(MSG_CNOTE_T_PR_SUID), pr_suid,
1535 1565              MSG_ORIG(MSG_CNOTE_T_PR_EGID), pr_egid);
1536 1566          PRINT_DEC_2UP(MSG_ORIG(MSG_CNOTE_T_PR_RGID), pr_rgid,
1537 1567              MSG_ORIG(MSG_CNOTE_T_PR_SGID), pr_sgid);
1538 1568          PRINT_DEC(MSG_ORIG(MSG_CNOTE_T_PR_NGROUPS), pr_ngroups);
1539 1569  
1540 1570          if (data_present(state, &layout->pr_ngroups)) {
1541 1571                  ngroups = extract_as_word(state, &layout->pr_ngroups);
1542 1572                  print_array(state, &layout->pr_groups, SL_FMT_NUM_DEC, ngroups,
1543 1573                      0, MSG_ORIG(MSG_CNOTE_T_PR_GROUPS));
1544 1574          }
1545 1575  
1546 1576          indent_exit(state);
1547 1577  }
1548 1578  
1549 1579  
1550 1580  /*
1551 1581   * Output information from prpriv_t structure.
1552 1582   */
1553 1583  static void
1554 1584  dump_prpriv(note_state_t *state, const char *title)
1555 1585  {
1556 1586          const sl_prpriv_layout_t *layout = state->ns_arch->prpriv;
1557 1587          Word            nsets;
1558 1588  
1559 1589          indent_enter(state, title, &layout->pr_nsets);
1560 1590  
1561 1591          PRINT_DEC(MSG_ORIG(MSG_CNOTE_T_PR_NSETS), pr_nsets);
1562 1592          PRINT_HEX(MSG_ORIG(MSG_CNOTE_T_PR_SETSIZE), pr_setsize);
1563 1593          PRINT_HEX(MSG_ORIG(MSG_CNOTE_T_PR_INFOSIZE), pr_infosize);
1564 1594  
1565 1595          if (data_present(state, &layout->pr_nsets)) {
1566 1596                  nsets = extract_as_word(state, &layout->pr_nsets);
1567 1597                  print_array(state, &layout->pr_sets, SL_FMT_NUM_ZHEX, nsets,
1568 1598                      0, MSG_ORIG(MSG_CNOTE_T_PR_SETS));
1569 1599          }
1570 1600  
1571 1601          indent_exit(state);
1572 1602  }
1573 1603  
1574 1604  static void
1575 1605  dump_prfdinfo(note_state_t *state, const char *title)
1576 1606  {
1577 1607          const sl_prfdinfo_layout_t *layout = state->ns_arch->prfdinfo;
1578 1608          char buf[1024];
1579 1609          uint32_t fileflags, mode;
1580 1610  
1581 1611          indent_enter(state, title, &layout->pr_fd);
1582 1612  
1583 1613          PRINT_DEC(MSG_ORIG(MSG_CNOTE_T_PR_FD), pr_fd);
1584 1614          mode = extract_as_word(state, &layout->pr_mode);
1585 1615  
1586 1616          print_str(state, MSG_ORIG(MSG_CNOTE_T_PR_MODE),
1587 1617              conv_cnote_filemode(mode, 0, buf, sizeof (buf)));
1588 1618  
1589 1619          PRINT_DEC_2UP(MSG_ORIG(MSG_CNOTE_T_PR_UID), pr_uid,
1590 1620              MSG_ORIG(MSG_CNOTE_T_PR_GID), pr_gid);
1591 1621  
1592 1622          PRINT_DEC_2UP(MSG_ORIG(MSG_CNOTE_T_PR_MAJOR), pr_major,
1593 1623              MSG_ORIG(MSG_CNOTE_T_PR_MINOR), pr_minor);
1594 1624          PRINT_DEC_2UP(MSG_ORIG(MSG_CNOTE_T_PR_RMAJOR), pr_rmajor,
1595 1625              MSG_ORIG(MSG_CNOTE_T_PR_RMINOR), pr_rminor);
1596 1626  
1597 1627          PRINT_DEC(MSG_ORIG(MSG_CNOTE_T_PR_INO), pr_ino);
1598 1628  
1599 1629          PRINT_DEC_2UP(MSG_ORIG(MSG_CNOTE_T_PR_SIZE), pr_size,
1600 1630              MSG_ORIG(MSG_CNOTE_T_PR_OFFSET), pr_offset);
1601 1631  
1602 1632          fileflags = extract_as_word(state, &layout->pr_fileflags);
1603 1633  
1604 1634          print_str(state, MSG_ORIG(MSG_CNOTE_T_PR_FILEFLAGS),
1605 1635              conv_cnote_fileflags(fileflags, 0, buf, sizeof (buf)));
1606 1636  
1607 1637          PRINT_DEC(MSG_ORIG(MSG_CNOTE_T_PR_FDFLAGS), pr_fdflags);
1608 1638  
1609 1639          PRINT_STRBUF(MSG_ORIG(MSG_CNOTE_T_PR_PATH), pr_path);
1610 1640  
1611 1641          indent_exit(state);
1612 1642  }
1613 1643  
1614 1644  /*
1615 1645   * Output information from priv_impl_info_t structure.
1616 1646   */
1617 1647  static void
1618 1648  dump_priv_impl_info(note_state_t *state, const char *title)
1619 1649  {
1620 1650          const sl_priv_impl_info_layout_t *layout;
1621 1651  
1622 1652          layout = state->ns_arch->priv_impl_info;
1623 1653          indent_enter(state, title, &layout->priv_headersize);
1624 1654  
1625 1655          PRINT_HEX_2UP(MSG_ORIG(MSG_CNOTE_T_PRIV_HEADERSIZE), priv_headersize,
1626 1656              MSG_ORIG(MSG_CNOTE_T_PRIV_FLAGS), priv_flags);
1627 1657  
1628 1658          print_num_2up(state, MSG_ORIG(MSG_CNOTE_T_PRIV_NSETS),
1629 1659              &layout->priv_nsets, SL_FMT_NUM_DEC,
1630 1660              MSG_ORIG(MSG_CNOTE_T_PRIV_SETSIZE), &layout->priv_setsize,
1631 1661              SL_FMT_NUM_HEX);
1632 1662          print_num_2up(state, MSG_ORIG(MSG_CNOTE_T_PRIV_MAX), &layout->priv_max,
1633 1663              SL_FMT_NUM_DEC, MSG_ORIG(MSG_CNOTE_T_PRIV_INFOSIZE),
1634 1664              &layout->priv_infosize, SL_FMT_NUM_HEX);
1635 1665          PRINT_HEX(MSG_ORIG(MSG_CNOTE_T_PRIV_GLOBALINFOSIZE),
1636 1666              priv_globalinfosize);
1637 1667  
1638 1668          indent_exit(state);
1639 1669  }
1640 1670  
1641 1671  
1642 1672  /*
1643 1673   * Dump information from an asrset_t array. This data
1644 1674   * structure is specific to sparcv9, and does not appear
1645 1675   * on any other platform.
1646 1676   *
1647 1677   * asrset_t is a simple array, defined in <sys/regset.h> as
1648 1678   *      typedef int64_t asrset_t[16];    %asr16 - > %asr31
1649 1679   *
1650 1680   * As such, we do not make use of the struct_layout facilities
1651 1681   * for this routine.
1652 1682   */
1653 1683  static void
1654 1684  dump_asrset(note_state_t *state, const char *title)
1655 1685  {
1656 1686          static const sl_field_t ftemplate = { 0, sizeof (int64_t), 16, 0 };
1657 1687          sl_field_t      fdesc1, fdesc2;
1658 1688          sl_fmtbuf_t     buf1, buf2;
1659 1689          char            index1[MAXNDXSIZE * 2], index2[MAXNDXSIZE * 2];
1660 1690          Word            w, nelts;
1661 1691  
1662 1692          fdesc1 = fdesc2 =  ftemplate;
1663 1693  
1664 1694          /* We expect 16 values, but will print whatever is actually there */
1665 1695          nelts = state->ns_len / ftemplate.slf_eltlen;
1666 1696          if (nelts == 0)
1667 1697                  return;
1668 1698  
1669 1699          indent_enter(state, title, &fdesc1);
1670 1700  
1671 1701          for (w = 0; w < nelts; ) {
1672 1702                  (void) snprintf(index1, sizeof (index1),
1673 1703                      MSG_ORIG(MSG_FMT_ASRINDEX), w + 16);
1674 1704  
1675 1705                  if (w == (nelts - 1)) {
1676 1706                          /* One last register is left */
1677 1707                          dbg_print(0, MSG_ORIG(MSG_CNOTE_FMT_LINE),
1678 1708                              INDENT, state->ns_vcol - state->ns_indent, index1,
1679 1709                              fmt_num(state, &fdesc1, SL_FMT_NUM_ZHEX, buf1));
1680 1710                          fdesc1.slf_offset += fdesc1.slf_eltlen;
1681 1711                          w++;
1682 1712                          continue;
1683 1713                  }
1684 1714  
1685 1715                  /* There are at least 2 more registers left. Show 2 up */
1686 1716                  (void) snprintf(index2, sizeof (index2),
1687 1717                      MSG_ORIG(MSG_FMT_ASRINDEX), w + 17);
1688 1718  
1689 1719                  fdesc2.slf_offset = fdesc1.slf_offset + fdesc1.slf_eltlen;
1690 1720                  dbg_print(0, MSG_ORIG(MSG_CNOTE_FMT_LINE_2UP), INDENT,
1691 1721                      state->ns_vcol - state->ns_indent, index1,
1692 1722                      state->ns_t2col - state->ns_vcol,
1693 1723                      fmt_num(state, &fdesc1, SL_FMT_NUM_ZHEX, buf1),
1694 1724                      state->ns_v2col - state->ns_t2col, index2,
1695 1725                      fmt_num(state, &fdesc2, SL_FMT_NUM_ZHEX, buf2));
1696 1726                  fdesc1.slf_offset += 2 * fdesc1.slf_eltlen;
1697 1727                  w += 2;
1698 1728          }
1699 1729  
1700 1730          indent_exit(state);
1701 1731  }
1702 1732  
1703 1733  corenote_ret_t
1704 1734  corenote(Half mach, int do_swap, Word type,
1705 1735      const char *desc, Word descsz)
1706 1736  {
1707 1737          note_state_t            state;
1708 1738  
1709 1739          /*
1710 1740           * Get the per-architecture layout definition
1711 1741           */
1712 1742          state.ns_mach = mach;
1713 1743          state.ns_arch = sl_mach(state.ns_mach);
1714 1744          if (sl_mach(state.ns_mach) == NULL)
1715 1745                  return (CORENOTE_R_BADARCH);
1716 1746  
1717 1747          state.ns_swap = do_swap;
1718 1748          state.ns_indent = 4;
1719 1749          state.ns_t2col = state.ns_v2col = 0;
1720 1750          state.ns_data = desc;
1721 1751          state.ns_len = descsz;
1722 1752  
1723 1753          switch (type) {
1724 1754          case NT_PRSTATUS:               /* prstatus_t <sys/old_procfs.h> */
1725 1755                  state.ns_vcol = 26;
1726 1756                  state.ns_t2col = 46;
1727 1757                  state.ns_v2col = 60;
1728 1758                  dump_prstatus(&state, MSG_ORIG(MSG_CNOTE_DESC_PRSTATUS_T));
1729 1759                  return (CORENOTE_R_OK);
1730 1760  
1731 1761          case NT_PRFPREG:                /* prfpregset_t <sys/procfs_isa.h> */
1732 1762                  return (CORENOTE_R_OK_DUMP);
1733 1763  
1734 1764          case NT_PRPSINFO:               /* prpsinfo_t   <sys/old_procfs.h> */
1735 1765                  state.ns_vcol = 20;
1736 1766                  state.ns_t2col = 41;
1737 1767                  state.ns_v2col = 54;
1738 1768                  dump_prpsinfo(&state, MSG_ORIG(MSG_CNOTE_DESC_PRPSINFO_T));
1739 1769                  return (CORENOTE_R_OK);
1740 1770  
1741 1771          case NT_PRXREG:                 /* prxregset_t <sys/procfs_isa.h> */
1742 1772                  return (CORENOTE_R_OK_DUMP);
1743 1773  
1744 1774          case NT_PLATFORM:               /* string from sysinfo(SI_PLATFORM) */
1745 1775                  dbg_print(0, MSG_ORIG(MSG_NOTE_DESC));
1746 1776                  dbg_print(0, MSG_ORIG(MSG_FMT_INDENT), safe_str(desc, descsz));
1747 1777                  return (CORENOTE_R_OK);
1748 1778  
1749 1779          case NT_AUXV:                   /* auxv_t array <sys/auxv.h> */
1750 1780                  state.ns_vcol = 18;
1751 1781                  dump_auxv(&state, MSG_ORIG(MSG_CNOTE_DESC_AUXV_T));
1752 1782                  return (CORENOTE_R_OK);
1753 1783  
1754 1784          case NT_GWINDOWS:               /* gwindows_t SPARC only */
1755 1785                  return (CORENOTE_R_OK_DUMP);
1756 1786  
1757 1787          case NT_ASRS:                   /* asrset_t <sys/regset> sparcv9 only */
1758 1788                  state.ns_vcol = 18;
1759 1789                  state.ns_t2col = 38;
1760 1790                  state.ns_v2col = 46;
1761 1791                  dump_asrset(&state, MSG_ORIG(MSG_CNOTE_DESC_ASRSET_T));
1762 1792                  return (CORENOTE_R_OK);
1763 1793  
1764 1794          case NT_LDT:                    /* ssd array <sys/sysi86.h> IA32 only */
1765 1795                  return (CORENOTE_R_OK_DUMP);
1766 1796  
1767 1797          case NT_PSTATUS:                /* pstatus_t <sys/procfs.h> */
1768 1798                  state.ns_vcol = 22;
1769 1799                  state.ns_t2col = 42;
1770 1800                  state.ns_v2col = 54;
1771 1801                  dump_pstatus(&state, MSG_ORIG(MSG_CNOTE_DESC_PSTATUS_T));
1772 1802                  return (CORENOTE_R_OK);
1773 1803  
1774 1804          case NT_PSINFO:                 /* psinfo_t <sys/procfs.h> */
1775 1805                  state.ns_vcol = 25;
1776 1806                  state.ns_t2col = 45;
1777 1807                  state.ns_v2col = 58;
1778 1808                  dump_psinfo(&state, MSG_ORIG(MSG_CNOTE_DESC_PSINFO_T));
1779 1809                  return (CORENOTE_R_OK);
1780 1810  
1781 1811          case NT_PRCRED:                 /* prcred_t <sys/procfs.h> */
1782 1812                  state.ns_vcol = 20;
1783 1813                  state.ns_t2col = 34;
1784 1814                  state.ns_v2col = 44;
1785 1815                  dump_prcred(&state, MSG_ORIG(MSG_CNOTE_DESC_PRCRED_T));
1786 1816                  return (CORENOTE_R_OK);
1787 1817  
1788 1818          case NT_UTSNAME:                /* struct utsname <sys/utsname.h> */
1789 1819                  state.ns_vcol = 18;
1790 1820                  dump_utsname(&state, MSG_ORIG(MSG_CNOTE_DESC_STRUCT_UTSNAME));
1791 1821                  return (CORENOTE_R_OK);
1792 1822  
1793 1823          case NT_LWPSTATUS:              /* lwpstatus_t <sys/procfs.h> */
1794 1824                  state.ns_vcol = 24;
1795 1825                  state.ns_t2col = 44;
1796 1826                  state.ns_v2col = 54;
1797 1827                  dump_lwpstatus(&state, MSG_ORIG(MSG_CNOTE_DESC_LWPSTATUS_T));
1798 1828                  return (CORENOTE_R_OK);
1799 1829  
1800 1830          case NT_LWPSINFO:               /* lwpsinfo_t <sys/procfs.h> */
1801 1831                  state.ns_vcol = 22;
1802 1832                  state.ns_t2col = 42;
1803 1833                  state.ns_v2col = 54;
1804 1834                  dump_lwpsinfo(&state, MSG_ORIG(MSG_CNOTE_DESC_LWPSINFO_T));
1805 1835                  return (CORENOTE_R_OK);
1806 1836  
1807 1837          case NT_PRPRIV:                 /* prpriv_t <sys/procfs.h> */
1808 1838                  state.ns_vcol = 21;
1809 1839                  state.ns_t2col = 34;
1810 1840                  state.ns_v2col = 38;
1811 1841                  dump_prpriv(&state, MSG_ORIG(MSG_CNOTE_DESC_PRPRIV_T));
1812 1842                  return (CORENOTE_R_OK);
1813 1843  
1814 1844          case NT_PRPRIVINFO:             /* priv_impl_info_t <sys/priv.h> */
1815 1845                  state.ns_vcol = 29;
1816 1846                  state.ns_t2col = 41;
1817 1847                  state.ns_v2col = 56;
1818 1848                  dump_priv_impl_info(&state,
1819 1849                      MSG_ORIG(MSG_CNOTE_DESC_PRIV_IMPL_INFO_T));
1820 1850                  return (CORENOTE_R_OK);
1821 1851  
1822 1852          case NT_CONTENT:                /* core_content_t <sys/corectl.h> */
1823 1853                  if (sizeof (core_content_t) > descsz)
1824 1854                          return (CORENOTE_R_BADDATA);
1825 1855                  {
1826 1856                          static sl_field_t fdesc = { 0, 8, 0, 0 };
1827 1857                          Conv_cnote_cc_content_buf_t conv_buf;
1828 1858                          core_content_t content;
1829 1859  
1830 1860                          state.ns_vcol = 8;
1831 1861                          indent_enter(&state,
1832 1862                              MSG_ORIG(MSG_CNOTE_DESC_CORE_CONTENT_T),
1833 1863                              &fdesc);
1834 1864                          content = extract_as_lword(&state, &fdesc);
1835 1865                          print_str(&state, MSG_ORIG(MSG_STR_EMPTY),
1836 1866                              conv_cnote_cc_content(content, 0, &conv_buf));
1837 1867                          indent_exit(&state);
1838 1868                  }
1839 1869                  return (CORENOTE_R_OK);
1840 1870  
1841 1871          case NT_ZONENAME:               /* string from getzonenamebyid(3C) */
1842 1872                  dbg_print(0, MSG_ORIG(MSG_NOTE_DESC));
1843 1873                  dbg_print(0, MSG_ORIG(MSG_FMT_INDENT), safe_str(desc, descsz));
1844 1874                  return (CORENOTE_R_OK);
1845 1875  
1846 1876  
1847 1877          case NT_FDINFO:
1848 1878                  state.ns_vcol = 22;
1849 1879                  state.ns_t2col = 41;
1850 1880                  state.ns_v2col = 54;
1851 1881                  dump_prfdinfo(&state, MSG_ORIG(MSG_CNOTE_DESC_PRFDINFO_T));
1852 1882                  return (CORENOTE_R_OK);
1853 1883  
1854 1884          case NT_SPYMASTER:
1855 1885                  state.ns_vcol = 25;
1856 1886                  state.ns_t2col = 45;
1857 1887                  state.ns_v2col = 58;
1858 1888                  dump_psinfo(&state, MSG_ORIG(MSG_CNOTE_DESC_PSINFO_T));
1859 1889                  return (CORENOTE_R_OK);
1860 1890          }
1861 1891  
1862 1892          return (CORENOTE_R_BADTYPE);
1863 1893  }
  
    | ↓ open down ↓ | 754 lines elided | ↑ open up ↑ | 
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX