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