#include "defs.h"
#include "gdb_string.h"
#include "symtab.h"
#include "gdbtypes.h"
#include "value.h"
#include "gdbcore.h"
#include "gdbcmd.h"
#include "target.h"
#include "language.h"
#include "annotate.h"
#include "valprint.h"
#include "floatformat.h"
#include "doublest.h"
#include <errno.h>
static int partial_memory_read (CORE_ADDR memaddr, char *myaddr,
int len, int *errnoptr);
static void show_print (char *, int);
static void set_print (char *, int);
static void set_radix (char *, int);
static void show_radix (char *, int);
static void set_input_radix (char *, int, struct cmd_list_element *);
static void set_input_radix_1 (int, unsigned);
static void set_output_radix (char *, int, struct cmd_list_element *);
static void set_output_radix_1 (int, unsigned);
void _initialize_valprint (void);
unsigned int print_max;
#define PRINT_MAX_DEFAULT 200
unsigned input_radix = 10;
unsigned output_radix = 10;
int output_format = 0;
unsigned int repeat_count_threshold = 10;
int stop_print_at_null;
int prettyprint_structs;
int prettyprint_arrays;
int unionprint;
int addressprint;
int
val_print (struct type *type, char *valaddr, int embedded_offset,
CORE_ADDR address, struct ui_file *stream, int format, int deref_ref,
int recurse, enum val_prettyprint pretty)
{
struct type *real_type = check_typedef (type);
if (pretty == Val_pretty_default)
{
pretty = prettyprint_structs ? Val_prettyprint : Val_no_prettyprint;
}
QUIT;
if (TYPE_STUB (real_type))
{
fprintf_filtered (stream, "<incomplete type>");
gdb_flush (stream);
return (0);
}
return (LA_VAL_PRINT (type, valaddr, embedded_offset, address,
stream, format, deref_ref, recurse, pretty));
}
int
value_print (struct value *val, struct ui_file *stream, int format,
enum val_prettyprint pretty)
{
if (val == 0)
{
printf_filtered ("<address of value unknown>");
return 0;
}
if (VALUE_OPTIMIZED_OUT (val))
{
printf_filtered ("<value optimized out>");
return 0;
}
return LA_VALUE_PRINT (val, stream, format, pretty);
}
void
val_print_type_code_int (struct type *type, char *valaddr,
struct ui_file *stream)
{
if (TYPE_LENGTH (type) > sizeof (LONGEST))
{
LONGEST val;
if (TYPE_UNSIGNED (type)
&& extract_long_unsigned_integer (valaddr, TYPE_LENGTH (type),
&val))
{
print_longest (stream, 'u', 0, val);
}
else
{
print_hex_chars (stream, (unsigned char *) valaddr,
TYPE_LENGTH (type));
}
}
else
{
print_longest (stream, TYPE_UNSIGNED (type) ? 'u' : 'd', 0,
unpack_long (type, valaddr));
}
}
#if defined (CC_HAS_LONG_LONG) && !defined (PRINTF_HAS_LONG_LONG)
static void print_decimal (struct ui_file * stream, char *sign,
int use_local, ULONGEST val_ulong);
static void
print_decimal (struct ui_file *stream, char *sign, int use_local,
ULONGEST val_ulong)
{
unsigned long temp[3];
int i = 0;
do
{
temp[i] = val_ulong % (1000 * 1000 * 1000);
val_ulong /= (1000 * 1000 * 1000);
i++;
}
while (val_ulong != 0 && i < (sizeof (temp) / sizeof (temp[0])));
switch (i)
{
case 1:
fprintf_filtered (stream, "%s%lu",
sign, temp[0]);
break;
case 2:
fprintf_filtered (stream, "%s%lu%09lu",
sign, temp[1], temp[0]);
break;
case 3:
fprintf_filtered (stream, "%s%lu%09lu%09lu",
sign, temp[2], temp[1], temp[0]);
break;
default:
internal_error (__FILE__, __LINE__, "failed internal consistency check");
}
return;
}
#endif
void
print_longest (struct ui_file *stream, int format, int use_local,
LONGEST val_long)
{
#if defined (CC_HAS_LONG_LONG) && !defined (PRINTF_HAS_LONG_LONG)
if (sizeof (long) < sizeof (LONGEST))
{
switch (format)
{
case 'd':
{
if ((long) val_long != val_long)
{
if (val_long < 0)
print_decimal (stream, "-", use_local, -val_long);
else
print_decimal (stream, "", use_local, val_long);
return;
}
break;
}
case 'u':
{
if ((unsigned long) val_long != (ULONGEST) val_long)
{
print_decimal (stream, "", use_local, val_long);
return;
}
break;
}
case 'x':
case 'o':
case 'b':
case 'h':
case 'w':
case 'g':
{
unsigned long temp = val_long;
if (temp != val_long)
{
unsigned long vbot = (unsigned long) val_long;
LONGEST temp = (val_long >> (sizeof (long) * HOST_CHAR_BIT - 1));
unsigned long vtop = temp >> 1;
fprintf_filtered (stream, "0x%lx%08lx", vtop, vbot);
return;
}
break;
}
}
}
#endif
#if defined (CC_HAS_LONG_LONG) && defined (PRINTF_HAS_LONG_LONG)
switch (format)
{
case 'd':
fprintf_filtered (stream,
use_local ? local_decimal_format_custom ("ll")
: "%lld",
(long long) val_long);
break;
case 'u':
fprintf_filtered (stream, "%llu", (long long) val_long);
break;
case 'x':
fprintf_filtered (stream,
use_local ? local_hex_format_custom ("ll")
: "%llx",
(unsigned long long) val_long);
break;
case 'o':
fprintf_filtered (stream,
use_local ? local_octal_format_custom ("ll")
: "%llo",
(unsigned long long) val_long);
break;
case 'b':
fprintf_filtered (stream, local_hex_format_custom ("02ll"), val_long);
break;
case 'h':
fprintf_filtered (stream, local_hex_format_custom ("04ll"), val_long);
break;
case 'w':
fprintf_filtered (stream, local_hex_format_custom ("08ll"), val_long);
break;
case 'g':
fprintf_filtered (stream, local_hex_format_custom ("016ll"), val_long);
break;
default:
internal_error (__FILE__, __LINE__, "failed internal consistency check");
}
#else
switch (format)
{
case 'd':
fprintf_filtered (stream,
use_local ? local_decimal_format_custom ("l")
: "%ld",
(long) val_long);
break;
case 'u':
fprintf_filtered (stream, "%lu", (unsigned long) val_long);
break;
case 'x':
fprintf_filtered (stream,
use_local ? local_hex_format_custom ("l")
: "%lx",
(unsigned long) val_long);
break;
case 'o':
fprintf_filtered (stream,
use_local ? local_octal_format_custom ("l")
: "%lo",
(unsigned long) val_long);
break;
case 'b':
fprintf_filtered (stream, local_hex_format_custom ("02l"),
(unsigned long) val_long);
break;
case 'h':
fprintf_filtered (stream, local_hex_format_custom ("04l"),
(unsigned long) val_long);
break;
case 'w':
fprintf_filtered (stream, local_hex_format_custom ("08l"),
(unsigned long) val_long);
break;
case 'g':
fprintf_filtered (stream, local_hex_format_custom ("016l"),
(unsigned long) val_long);
break;
default:
internal_error (__FILE__, __LINE__, "failed internal consistency check");
}
#endif
}
int
longest_to_int (LONGEST arg)
{
int rtnval = (int) arg;
if (sizeof (LONGEST) > sizeof (int))
{
if (rtnval != arg)
{
error ("Value out of range.");
}
}
return (rtnval);
}
void
print_floating (char *valaddr, struct type *type, struct ui_file *stream)
{
DOUBLEST doub;
int inv;
const struct floatformat *fmt = NULL;
unsigned len = TYPE_LENGTH (type);
if (TYPE_CODE (type) == TYPE_CODE_FLT)
fmt = floatformat_from_type (type);
if (fmt != NULL && floatformat_is_nan (fmt, valaddr))
{
if (floatformat_is_negative (fmt, valaddr))
fprintf_filtered (stream, "-");
fprintf_filtered (stream, "nan(");
fputs_filtered (local_hex_format_prefix (), stream);
fputs_filtered (floatformat_mantissa (fmt, valaddr), stream);
fputs_filtered (local_hex_format_suffix (), stream);
fprintf_filtered (stream, ")");
return;
}
doub = unpack_double (type, valaddr, &inv);
if (inv)
{
fprintf_filtered (stream, "<invalid float value>");
return;
}
if (len < sizeof (double))
fprintf_filtered (stream, "%.9g", (double) doub);
else if (len == sizeof (double))
fprintf_filtered (stream, "%.17g", (double) doub);
else
#ifdef PRINTF_HAS_LONG_DOUBLE
fprintf_filtered (stream, "%.35Lg", doub);
#else
fprintf_filtered (stream, "%.17g", (double) doub);
#endif
}
void
print_binary_chars (struct ui_file *stream, unsigned char *valaddr,
unsigned len)
{
#define BITS_IN_BYTES 8
unsigned char *p;
unsigned int i;
int b;
const int mask = 0x080;
fputs_filtered (local_binary_format_prefix (), stream);
if (TARGET_BYTE_ORDER == BFD_ENDIAN_BIG)
{
for (p = valaddr;
p < valaddr + len;
p++)
{
for (i = 0; i < (BITS_IN_BYTES * sizeof (*p)); i++)
{
if (*p & (mask >> i))
b = 1;
else
b = 0;
fprintf_filtered (stream, "%1d", b);
}
}
}
else
{
for (p = valaddr + len - 1;
p >= valaddr;
p--)
{
for (i = 0; i < (BITS_IN_BYTES * sizeof (*p)); i++)
{
if (*p & (mask >> i))
b = 1;
else
b = 0;
fprintf_filtered (stream, "%1d", b);
}
}
}
fputs_filtered (local_binary_format_suffix (), stream);
}
void
print_octal_chars (struct ui_file *stream, unsigned char *valaddr, unsigned len)
{
unsigned char *p;
unsigned char octa1, octa2, octa3, carry;
int cycle;
#define BITS_IN_OCTAL 3
#define HIGH_ZERO 0340
#define LOW_ZERO 0016
#define CARRY_ZERO 0003
#define HIGH_ONE 0200
#define MID_ONE 0160
#define LOW_ONE 0016
#define CARRY_ONE 0001
#define HIGH_TWO 0300
#define MID_TWO 0070
#define LOW_TWO 0007
cycle = (len * BITS_IN_BYTES) % BITS_IN_OCTAL;
carry = 0;
fputs_filtered (local_octal_format_prefix (), stream);
if (TARGET_BYTE_ORDER == BFD_ENDIAN_BIG)
{
for (p = valaddr;
p < valaddr + len;
p++)
{
switch (cycle)
{
case 0:
octa1 = (HIGH_ZERO & *p) >> 5;
octa2 = (LOW_ZERO & *p) >> 2;
carry = (CARRY_ZERO & *p);
fprintf_filtered (stream, "%o", octa1);
fprintf_filtered (stream, "%o", octa2);
break;
case 1:
octa1 = (carry << 1) | ((HIGH_ONE & *p) >> 7);
octa2 = (MID_ONE & *p) >> 4;
octa3 = (LOW_ONE & *p) >> 1;
carry = (CARRY_ONE & *p);
fprintf_filtered (stream, "%o", octa1);
fprintf_filtered (stream, "%o", octa2);
fprintf_filtered (stream, "%o", octa3);
break;
case 2:
octa1 = (carry << 2) | ((HIGH_TWO & *p) >> 6);
octa2 = (MID_TWO & *p) >> 3;
octa3 = (LOW_TWO & *p);
carry = 0;
fprintf_filtered (stream, "%o", octa1);
fprintf_filtered (stream, "%o", octa2);
fprintf_filtered (stream, "%o", octa3);
break;
default:
error ("Internal error in octal conversion;");
}
cycle++;
cycle = cycle % BITS_IN_OCTAL;
}
}
else
{
for (p = valaddr + len - 1;
p >= valaddr;
p--)
{
switch (cycle)
{
case 0:
octa1 = (HIGH_ZERO & *p) >> 5;
octa2 = (LOW_ZERO & *p) >> 2;
carry = (CARRY_ZERO & *p);
fprintf_filtered (stream, "%o", octa1);
fprintf_filtered (stream, "%o", octa2);
break;
case 1:
octa1 = (carry << 1) | ((HIGH_ONE & *p) >> 7);
octa2 = (MID_ONE & *p) >> 4;
octa3 = (LOW_ONE & *p) >> 1;
carry = (CARRY_ONE & *p);
fprintf_filtered (stream, "%o", octa1);
fprintf_filtered (stream, "%o", octa2);
fprintf_filtered (stream, "%o", octa3);
break;
case 2:
octa1 = (carry << 2) | ((HIGH_TWO & *p) >> 6);
octa2 = (MID_TWO & *p) >> 3;
octa3 = (LOW_TWO & *p);
carry = 0;
fprintf_filtered (stream, "%o", octa1);
fprintf_filtered (stream, "%o", octa2);
fprintf_filtered (stream, "%o", octa3);
break;
default:
error ("Internal error in octal conversion;");
}
cycle++;
cycle = cycle % BITS_IN_OCTAL;
}
}
fputs_filtered (local_octal_format_suffix (), stream);
}
void
print_decimal_chars (struct ui_file *stream, unsigned char *valaddr,
unsigned len)
{
#define TEN 10
#define TWO_TO_FOURTH 16
#define CARRY_OUT( x ) ((x) / TEN)
#define CARRY_LEFT( x ) ((x) % TEN)
#define SHIFT( x ) ((x) << 4)
#define START_P \
((TARGET_BYTE_ORDER == BFD_ENDIAN_BIG) ? valaddr : valaddr + len - 1)
#define NOT_END_P \
((TARGET_BYTE_ORDER == BFD_ENDIAN_BIG) ? (p < valaddr + len) : (p >= valaddr))
#define NEXT_P \
((TARGET_BYTE_ORDER == BFD_ENDIAN_BIG) ? p++ : p-- )
#define LOW_NIBBLE( x ) ( (x) & 0x00F)
#define HIGH_NIBBLE( x ) (((x) & 0x0F0) >> 4)
unsigned char *p;
unsigned char *digits;
int carry;
int decimal_len;
int i, j, decimal_digits;
int dummy;
int flip;
decimal_len = len * 2 * 2;
digits = (unsigned char *) xmalloc (decimal_len);
for (i = 0; i < decimal_len; i++)
{
digits[i] = 0;
}
fputs_filtered (local_decimal_format_prefix (), stream);
decimal_digits = 0;
p = START_P;
flip = 0;
while (NOT_END_P)
{
for (j = 0; j < decimal_digits; j++)
{
digits[j] = SHIFT (digits[j]);
}
if (flip == 0)
{
digits[0] += HIGH_NIBBLE (*p);
flip = 1;
}
else
{
digits[0] += LOW_NIBBLE (*p);
NEXT_P;
flip = 0;
}
carry = 0;
for (j = 0; j < decimal_len - 1; j++)
{
digits[j] += carry;
dummy = digits[j];
carry = CARRY_OUT (dummy);
digits[j] = CARRY_LEFT (dummy);
if (j >= decimal_digits && carry == 0)
{
decimal_digits = j + 1;
break;
}
}
}
for (i = decimal_digits - 1; i >= 0; i--)
{
fprintf_filtered (stream, "%1d", digits[i]);
}
xfree (digits);
fputs_filtered (local_decimal_format_suffix (), stream);
}
void
print_hex_chars (struct ui_file *stream, unsigned char *valaddr, unsigned len)
{
unsigned char *p;
fputs_filtered (local_hex_format_prefix (), stream);
if (TARGET_BYTE_ORDER == BFD_ENDIAN_BIG)
{
for (p = valaddr;
p < valaddr + len;
p++)
{
fprintf_filtered (stream, "%02x", *p);
}
}
else
{
for (p = valaddr + len - 1;
p >= valaddr;
p--)
{
fprintf_filtered (stream, "%02x", *p);
}
}
fputs_filtered (local_hex_format_suffix (), stream);
}
void
print_char_chars (struct ui_file *stream, unsigned char *valaddr, unsigned len)
{
unsigned char *p;
if (TARGET_BYTE_ORDER == BFD_ENDIAN_BIG)
{
p = valaddr;
while (p < valaddr + len - 1 && *p == 0)
++p;
while (p < valaddr + len)
{
LA_EMIT_CHAR (*p, stream, '\'');
++p;
}
}
else
{
p = valaddr + len - 1;
while (p > valaddr && *p == 0)
--p;
while (p >= valaddr)
{
LA_EMIT_CHAR (*p, stream, '\'');
--p;
}
}
}
void
val_print_array_elements (struct type *type, char *valaddr, CORE_ADDR address,
struct ui_file *stream, int format, int deref_ref,
int recurse, enum val_prettyprint pretty,
unsigned int i)
{
unsigned int things_printed = 0;
unsigned len;
struct type *elttype;
unsigned eltlen;
unsigned int rep1;
unsigned int reps;
elttype = TYPE_TARGET_TYPE (type);
eltlen = TYPE_LENGTH (check_typedef (elttype));
len = TYPE_LENGTH (type) / eltlen;
annotate_array_section_begin (i, elttype);
for (; i < len && things_printed < print_max; i++)
{
if (i != 0)
{
if (prettyprint_arrays)
{
fprintf_filtered (stream, ",\n");
print_spaces_filtered (2 + 2 * recurse, stream);
}
else
{
fprintf_filtered (stream, ", ");
}
}
wrap_here (n_spaces (2 + 2 * recurse));
rep1 = i + 1;
reps = 1;
while ((rep1 < len) &&
!memcmp (valaddr + i * eltlen, valaddr + rep1 * eltlen, eltlen))
{
++reps;
++rep1;
}
if (reps > repeat_count_threshold)
{
val_print (elttype, valaddr + i * eltlen, 0, 0, stream, format,
deref_ref, recurse + 1, pretty);
annotate_elt_rep (reps);
fprintf_filtered (stream, " <repeats %u times>", reps);
annotate_elt_rep_end ();
i = rep1 - 1;
things_printed += repeat_count_threshold;
}
else
{
val_print (elttype, valaddr + i * eltlen, 0, 0, stream, format,
deref_ref, recurse + 1, pretty);
annotate_elt ();
things_printed++;
}
}
annotate_array_section_end ();
if (i < len)
{
fprintf_filtered (stream, "...");
}
}
static int
partial_memory_read (CORE_ADDR memaddr, char *myaddr, int len, int *errnoptr)
{
int nread;
int errcode;
errcode = target_read_memory (memaddr, myaddr, len);
if (errcode == 0)
{
nread = len;
}
else
{
for (errcode = 0, nread = 0; len > 0 && errcode == 0; nread++, len--)
{
errcode = target_read_memory (memaddr++, myaddr++, 1);
}
if (errcode != 0)
{
nread--;
}
}
if (errnoptr != NULL)
{
*errnoptr = errcode;
}
return (nread);
}
int
val_print_string (CORE_ADDR addr, int len, int width, struct ui_file *stream)
{
int force_ellipsis = 0;
int errcode;
unsigned int fetchlimit;
unsigned int nfetch;
unsigned int chunksize;
char *buffer = NULL;
char *bufptr;
char *limit;
struct cleanup *old_chain = NULL;
int found_nul;
fetchlimit = (len == -1 ? print_max : min (len, print_max));
chunksize = (len == -1 ? min (8, fetchlimit) : fetchlimit);
found_nul = 0;
old_chain = make_cleanup (null_cleanup, 0);
if (len > 0)
{
buffer = (char *) xmalloc (len * width);
bufptr = buffer;
old_chain = make_cleanup (xfree, buffer);
nfetch = partial_memory_read (addr, bufptr, len * width, &errcode)
/ width;
addr += nfetch * width;
bufptr += nfetch * width;
}
else if (len == -1)
{
unsigned long bufsize = 0;
do
{
QUIT;
nfetch = min (chunksize, fetchlimit - bufsize);
if (buffer == NULL)
buffer = (char *) xmalloc (nfetch * width);
else
{
discard_cleanups (old_chain);
buffer = (char *) xrealloc (buffer, (nfetch + bufsize) * width);
}
old_chain = make_cleanup (xfree, buffer);
bufptr = buffer + bufsize * width;
bufsize += nfetch;
nfetch = partial_memory_read (addr, bufptr, nfetch * width, &errcode)
/ width;
limit = bufptr + nfetch * width;
while (bufptr < limit)
{
unsigned long c;
c = extract_unsigned_integer (bufptr, width);
addr += width;
bufptr += width;
if (c == 0)
{
errcode = 0;
found_nul = 1;
break;
}
}
}
while (errcode == 0
&& bufptr - buffer < fetchlimit * width
&& !found_nul);
}
else
{
buffer = bufptr = NULL;
errcode = 0;
}
if (len == -1 && !found_nul)
{
char *peekbuf;
peekbuf = (char *) alloca (width);
if (target_read_memory (addr, peekbuf, width) == 0
&& extract_unsigned_integer (peekbuf, width) != 0)
force_ellipsis = 1;
}
else if ((len >= 0 && errcode != 0) || (len > (bufptr - buffer) / width))
{
force_ellipsis = 1;
}
QUIT;
if (errcode == 0 || bufptr > buffer)
{
if (addressprint)
{
fputs_filtered (" ", stream);
}
LA_PRINT_STRING (stream, buffer, (bufptr - buffer) / width, width, force_ellipsis);
}
if (errcode != 0)
{
if (errcode == EIO)
{
fprintf_filtered (stream, " <Address ");
print_address_numeric (addr, 1, stream);
fprintf_filtered (stream, " out of bounds>");
}
else
{
fprintf_filtered (stream, " <Error reading address ");
print_address_numeric (addr, 1, stream);
fprintf_filtered (stream, ": %s>", safe_strerror (errcode));
}
}
gdb_flush (stream);
do_cleanups (old_chain);
return ((bufptr - buffer) / width);
}
static void
set_input_radix (char *args, int from_tty, struct cmd_list_element *c)
{
set_input_radix_1 (from_tty, input_radix);
}
static void
set_input_radix_1 (int from_tty, unsigned radix)
{
if (radix < 2)
{
error ("Nonsense input radix ``decimal %u''; input radix unchanged.",
radix);
}
input_radix = radix;
set_internalvar (lookup_internalvar ("input_radix"),
value_from_longest (builtin_type_int, (LONGEST) radix));
if (from_tty)
{
printf_filtered ("Input radix now set to decimal %u, hex %x, octal %o.\n",
radix, radix, radix);
}
}
static void
set_output_radix (char *args, int from_tty, struct cmd_list_element *c)
{
set_output_radix_1 (from_tty, output_radix);
}
static void
set_output_radix_1 (int from_tty, unsigned radix)
{
switch (radix)
{
case 16:
output_format = 'x';
break;
case 10:
output_format = 0;
break;
case 8:
output_format = 'o';
break;
default:
error ("Unsupported output radix ``decimal %u''; output radix unchanged.",
radix);
}
output_radix = radix;
set_internalvar (lookup_internalvar ("output_radix"),
value_from_longest (builtin_type_int, (LONGEST) radix));
if (from_tty)
{
printf_filtered ("Output radix now set to decimal %u, hex %x, octal %o.\n",
radix, radix, radix);
}
}
static void
set_radix (char *arg, int from_tty)
{
unsigned radix;
radix = (arg == NULL) ? 10 : parse_and_eval_long (arg);
set_output_radix_1 (0, radix);
set_input_radix_1 (0, radix);
if (from_tty)
{
printf_filtered ("Input and output radices now set to decimal %u, hex %x, octal %o.\n",
radix, radix, radix);
}
}
static void
show_radix (char *arg, int from_tty)
{
if (from_tty)
{
if (input_radix == output_radix)
{
printf_filtered ("Input and output radices set to decimal %u, hex %x, octal %o.\n",
input_radix, input_radix, input_radix);
}
else
{
printf_filtered ("Input radix set to decimal %u, hex %x, octal %o.\n",
input_radix, input_radix, input_radix);
printf_filtered ("Output radix set to decimal %u, hex %x, octal %o.\n",
output_radix, output_radix, output_radix);
}
}
}
static void
set_print (char *arg, int from_tty)
{
printf_unfiltered (
"\"set print\" must be followed by the name of a print subcommand.\n");
help_list (setprintlist, "set print ", -1, gdb_stdout);
}
static void
show_print (char *args, int from_tty)
{
cmd_show_list (showprintlist, from_tty, "");
}
void
_initialize_valprint (void)
{
struct cmd_list_element *c;
add_prefix_cmd ("print", no_class, set_print,
"Generic command for setting how things print.",
&setprintlist, "set print ", 0, &setlist);
add_alias_cmd ("p", "print", no_class, 1, &setlist);
add_alias_cmd ("pr", "print", no_class, 1, &setlist);
add_prefix_cmd ("print", no_class, show_print,
"Generic command for showing print settings.",
&showprintlist, "show print ", 0, &showlist);
add_alias_cmd ("p", "print", no_class, 1, &showlist);
add_alias_cmd ("pr", "print", no_class, 1, &showlist);
add_show_from_set
(add_set_cmd ("elements", no_class, var_uinteger, (char *) &print_max,
"Set limit on string chars or array elements to print.\n\
\"set print elements 0\" causes there to be no limit.",
&setprintlist),
&showprintlist);
add_show_from_set
(add_set_cmd ("null-stop", no_class, var_boolean,
(char *) &stop_print_at_null,
"Set printing of char arrays to stop at first null char.",
&setprintlist),
&showprintlist);
add_show_from_set
(add_set_cmd ("repeats", no_class, var_uinteger,
(char *) &repeat_count_threshold,
"Set threshold for repeated print elements.\n\
\"set print repeats 0\" causes all elements to be individually printed.",
&setprintlist),
&showprintlist);
add_show_from_set
(add_set_cmd ("pretty", class_support, var_boolean,
(char *) &prettyprint_structs,
"Set prettyprinting of structures.",
&setprintlist),
&showprintlist);
add_show_from_set
(add_set_cmd ("union", class_support, var_boolean, (char *) &unionprint,
"Set printing of unions interior to structures.",
&setprintlist),
&showprintlist);
add_show_from_set
(add_set_cmd ("array", class_support, var_boolean,
(char *) &prettyprint_arrays,
"Set prettyprinting of arrays.",
&setprintlist),
&showprintlist);
add_show_from_set
(add_set_cmd ("address", class_support, var_boolean, (char *) &addressprint,
"Set printing of addresses.",
&setprintlist),
&showprintlist);
c = add_set_cmd ("input-radix", class_support, var_uinteger,
(char *) &input_radix,
"Set default input radix for entering numbers.",
&setlist);
add_show_from_set (c, &showlist);
set_cmd_sfunc (c, set_input_radix);
c = add_set_cmd ("output-radix", class_support, var_uinteger,
(char *) &output_radix,
"Set default output radix for printing of values.",
&setlist);
add_show_from_set (c, &showlist);
set_cmd_sfunc (c, set_output_radix);
add_cmd ("radix", class_support, set_radix,
"Set default input and output number radices.\n\
Use 'set input-radix' or 'set output-radix' to independently set each.\n\
Without an argument, sets both radices back to the default value of 10.",
&setlist);
add_cmd ("radix", class_support, show_radix,
"Show the default input and output number radices.\n\
Use 'show input-radix' or 'show output-radix' to independently show each.",
&showlist);
prettyprint_structs = 0;
prettyprint_arrays = 0;
unionprint = 1;
addressprint = 1;
print_max = PRINT_MAX_DEFAULT;
}