mirror of
https://sourceware.org/git/binutils-gdb.git
synced 2024-11-28 20:43:45 +08:00
* 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:
parent
3e3b026fee
commit
b806fb9a9b
@ -1,3 +1,15 @@
|
||||
2008-09-11 Ulrich Weigand <uweigand@de.ibm.com>
|
||||
|
||||
* 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.
|
||||
|
||||
2008-09-11 Ulrich Weigand <uweigand@de.ibm.com>
|
||||
|
||||
* valops.c: Include "objfiles.h" and "symtab.h".
|
||||
|
@ -237,7 +237,8 @@ print_subexp_standard (struct expression *exp, int *pos,
|
||||
nargs++;
|
||||
tem = 0;
|
||||
if (exp->elts[pc + 4].opcode == OP_LONG
|
||||
&& exp->elts[pc + 5].type == builtin_type_char
|
||||
&& exp->elts[pc + 5].type
|
||||
== builtin_type (exp->gdbarch)->builtin_char
|
||||
&& exp->language_defn->la_language == language_c)
|
||||
{
|
||||
/* Attempt to print C character arrays using string syntax.
|
||||
@ -252,7 +253,8 @@ print_subexp_standard (struct expression *exp, int *pos,
|
||||
while (tem < nargs)
|
||||
{
|
||||
if (exp->elts[pc].opcode != OP_LONG
|
||||
|| exp->elts[pc + 1].type != builtin_type_char)
|
||||
|| exp->elts[pc + 1].type
|
||||
!= builtin_type (exp->gdbarch)->builtin_char)
|
||||
{
|
||||
/* Not a simple array of char, use regular array printing. */
|
||||
tem = 0;
|
||||
|
@ -523,26 +523,7 @@ f_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
|
||||
print_scalar_formatted (valaddr, type, format, 0, stream);
|
||||
else
|
||||
{
|
||||
val = 0;
|
||||
switch (TYPE_LENGTH (type))
|
||||
{
|
||||
case 1:
|
||||
val = unpack_long (builtin_type_f_logical_s1, valaddr);
|
||||
break;
|
||||
|
||||
case 2:
|
||||
val = unpack_long (builtin_type_f_logical_s2, valaddr);
|
||||
break;
|
||||
|
||||
case 4:
|
||||
val = unpack_long (builtin_type_f_logical, valaddr);
|
||||
break;
|
||||
|
||||
default:
|
||||
error (_("Logicals of length %d bytes not supported"),
|
||||
TYPE_LENGTH (type));
|
||||
|
||||
}
|
||||
val = extract_unsigned_integer (valaddr, TYPE_LENGTH (type));
|
||||
|
||||
if (val == 0)
|
||||
fprintf_filtered (stream, ".FALSE.");
|
||||
@ -562,20 +543,7 @@ f_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
|
||||
break;
|
||||
|
||||
case TYPE_CODE_COMPLEX:
|
||||
switch (TYPE_LENGTH (type))
|
||||
{
|
||||
case 8:
|
||||
type = builtin_type_f_real;
|
||||
break;
|
||||
case 16:
|
||||
type = builtin_type_f_real_s8;
|
||||
break;
|
||||
case 32:
|
||||
type = builtin_type_f_real_s16;
|
||||
break;
|
||||
default:
|
||||
error (_("Cannot print out complex*%d variables"), TYPE_LENGTH (type));
|
||||
}
|
||||
type = TYPE_TARGET_TYPE (type);
|
||||
fputs_filtered ("(", stream);
|
||||
print_floating (valaddr, type, stream);
|
||||
fputs_filtered (",", stream);
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user