* expprint.c (print_subexp_standard): Compare against builtin type

associated with exp->gdbarch instead of builtin_type_char.

	* f-valprint.c (f_val_print): Use extract_unsigned_integer to
	extract values of arbitrary logical type.  Handle arbitrary
	complex types.

	* printcmd.c (float_type_from_length): New function.
	(print_scalar_formatted, printf_command): Use it.
This commit is contained in:
Ulrich Weigand
2008-09-11 14:28:47 +00:00
parent 3e3b026fee
commit b806fb9a9b
4 changed files with 61 additions and 57 deletions

View File

@@ -309,6 +309,24 @@ print_formatted (struct value *val, int format, int size,
format, size, stream);
}
/* Return builtin floating point type of same length as TYPE.
If no such type is found, return TYPE itself. */
static struct type *
float_type_from_length (struct gdbarch *gdbarch, struct type *type)
{
const struct builtin_type *builtin = builtin_type (gdbarch);
unsigned int len = TYPE_LENGTH (type);
if (len == TYPE_LENGTH (builtin->builtin_float))
type = builtin->builtin_float;
else if (len == TYPE_LENGTH (builtin->builtin_double))
type = builtin->builtin_double;
else if (len == TYPE_LENGTH (builtin->builtin_long_double))
type = builtin->builtin_long_double;
return type;
}
/* Print a scalar of data of type TYPE, pointed to in GDB by VALADDR,
according to letters FORMAT and SIZE on STREAM.
FORMAT may not be zero. Formats s and i are not supported at this level.
@@ -434,12 +452,7 @@ print_scalar_formatted (const void *valaddr, struct type *type,
break;
case 'f':
if (len == TYPE_LENGTH (builtin_type_float))
type = builtin_type_float;
else if (len == TYPE_LENGTH (builtin_type_double))
type = builtin_type_double;
else if (len == TYPE_LENGTH (builtin_type_long_double))
type = builtin_type_long_double;
type = float_type_from_length (current_gdbarch, type);
print_floating (valaddr, type, stream);
break;
@@ -1999,17 +2012,6 @@ printf_command (char *arg, int from_tty)
s1 = s;
val_args[nargs] = parse_to_comma_and_eval (&s1);
/* If format string wants a float, unchecked-convert the value to
floating point of the same size */
if (argclass[nargs] == double_arg)
{
struct type *type = value_type (val_args[nargs]);
if (TYPE_LENGTH (type) == sizeof (float))
deprecated_set_value_type (val_args[nargs], builtin_type_float);
if (TYPE_LENGTH (type) == sizeof (double))
deprecated_set_value_type (val_args[nargs], builtin_type_double);
}
nargs++;
s = s1;
if (*s == ',')
@@ -2053,15 +2055,35 @@ printf_command (char *arg, int from_tty)
break;
case double_arg:
{
double val = value_as_double (val_args[i]);
printf_filtered (current_substring, val);
struct type *type = value_type (val_args[i]);
DOUBLEST val;
int inv;
/* If format string wants a float, unchecked-convert the value
to floating point of the same size. */
type = float_type_from_length (current_gdbarch, type);
val = unpack_double (type, value_contents (val_args[i]), &inv);
if (inv)
error (_("Invalid floating value found in program."));
printf_filtered (current_substring, (double) val);
break;
}
case long_double_arg:
#ifdef HAVE_LONG_DOUBLE
{
long double val = value_as_double (val_args[i]);
printf_filtered (current_substring, val);
struct type *type = value_type (val_args[i]);
DOUBLEST val;
int inv;
/* If format string wants a float, unchecked-convert the value
to floating point of the same size. */
type = float_type_from_length (current_gdbarch, type);
val = unpack_double (type, value_contents (val_args[i]), &inv);
if (inv)
error (_("Invalid floating value found in program."));
printf_filtered (current_substring, (long double) val);
break;
}
#else