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".
(find_function_in_inferior): New argument OBJF_P. Use it to return
objfile where function is defined. Use per-objfile arch types
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.
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;
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.");
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);
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.
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;
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 == ',')
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