Thu Oct 24 01:32:51 1991 Fred Fish (fnf at cygnus.com)
+ * c-exp.y, defs.h, symtab.h, valprint.c: Add three new builtin
+ types to gdb, builtin_type_long_double, builtin_type_complex, and
+ builtin_type_double_complex. Add and use new TARGET_SHORT_BIT,
+ TARGET_INT_BIT, TARGET_LONG_BIT, TARGET_FLOAT_BIT,
+ TARGET_DOUBLE_BIT, TARGET_LONG_DOUBLE_BIT, TARGET_COMPLEX_BIT, and
+ TARGET_DOUBLE_COMPLEX_BIT, as the sizes in bits of the indicated
+ types on the target machine (ala the existing TARGET_LONG_LONG_BIT).
+
* infrun.c: When using SVR4 /proc interface instead of ptrace(),
call proc_set_exec_trap() to setup child to stop at first instruction.
struct type *builtin_type_unsigned_long_long;
struct type *builtin_type_float;
struct type *builtin_type_double;
+struct type *builtin_type_long_double;
+struct type *builtin_type_complex;
+struct type *builtin_type_double_complex;
struct type ** const (c_builtin_types[]) =
{
&builtin_type_unsigned_int,
&builtin_type_unsigned_long,
&builtin_type_unsigned_long_long,
+ &builtin_type_long_double,
+ &builtin_type_complex,
+ &builtin_type_double_complex,
0
};
c_error,
&BUILTIN_TYPE_LONGEST, /* longest signed integral type */
&BUILTIN_TYPE_UNSIGNED_LONGEST,/* longest unsigned integral type */
- &builtin_type_double, /* longest floating point type */
+ &builtin_type_double, /* longest floating point type */ /*FIXME*/
"0x%x", "0x%", "x", /* Hex format, prefix, suffix */
"0%o", "0%", "o", /* Octal format, prefix, suffix */
c_op_print_tab, /* expression operators for printing */
void
_initialize_c_exp ()
{
- /* FIXME: The code below assumes that the sizes of the basic data
- types are the same on the host and target machines!!! */
-
- builtin_type_void = init_type (TYPE_CODE_VOID, 1, 0, "void");
-
- builtin_type_float = init_type (TYPE_CODE_FLT, sizeof (float), 0, "float");
- builtin_type_double = init_type (TYPE_CODE_FLT, sizeof (double), 0, "double");
-
- builtin_type_char = init_type (TYPE_CODE_INT, sizeof (char), 0, "char");
- builtin_type_short = init_type (TYPE_CODE_INT, sizeof (short), 0, "short");
- builtin_type_long = init_type (TYPE_CODE_INT, sizeof (long), 0, "long");
- builtin_type_int = init_type (TYPE_CODE_INT, sizeof (int), 0, "int");
-
- builtin_type_unsigned_char = init_type (TYPE_CODE_INT, sizeof (char), 1, "unsigned char");
- builtin_type_unsigned_short = init_type (TYPE_CODE_INT, sizeof (short), 1, "unsigned short");
- builtin_type_unsigned_long = init_type (TYPE_CODE_INT, sizeof (long), 1, "unsigned long");
- builtin_type_unsigned_int = init_type (TYPE_CODE_INT, sizeof (int), 1, "unsigned int");
-
+ builtin_type_void =
+ init_type (TYPE_CODE_VOID, 1, 0,
+ "void");
+ builtin_type_char =
+ init_type (TYPE_CODE_INT, TARGET_CHAR_BIT / TARGET_CHAR_BIT, 0,
+ "char");
+ builtin_type_unsigned_char =
+ init_type (TYPE_CODE_INT, TARGET_CHAR_BIT / TARGET_CHAR_BIT, 1,
+ "unsigned char");
+ builtin_type_short =
+ init_type (TYPE_CODE_INT, TARGET_SHORT_BIT / TARGET_CHAR_BIT, 0,
+ "short");
+ builtin_type_unsigned_short =
+ init_type (TYPE_CODE_INT, TARGET_SHORT_BIT / TARGET_CHAR_BIT, 1,
+ "unsigned short");
+ builtin_type_int =
+ init_type (TYPE_CODE_INT, TARGET_INT_BIT / TARGET_CHAR_BIT, 0,
+ "int");
+ builtin_type_unsigned_int =
+ init_type (TYPE_CODE_INT, TARGET_INT_BIT / TARGET_CHAR_BIT, 1,
+ "unsigned int");
+ builtin_type_long =
+ init_type (TYPE_CODE_INT, TARGET_LONG_BIT / TARGET_CHAR_BIT, 0,
+ "long");
+ builtin_type_unsigned_long =
+ init_type (TYPE_CODE_INT, TARGET_LONG_BIT / TARGET_CHAR_BIT, 1,
+ "unsigned long");
builtin_type_long_long =
- init_type (TYPE_CODE_INT, TARGET_LONG_LONG_BIT / TARGET_CHAR_BIT,
- 0, "long long");
+ init_type (TYPE_CODE_INT, TARGET_LONG_LONG_BIT / TARGET_CHAR_BIT, 0,
+ "long long");
builtin_type_unsigned_long_long =
- init_type (TYPE_CODE_INT, TARGET_LONG_LONG_BIT / TARGET_CHAR_BIT,
- 1, "unsigned long long");
+ init_type (TYPE_CODE_INT, TARGET_LONG_LONG_BIT / TARGET_CHAR_BIT, 1,
+ "unsigned long long");
+ builtin_type_float =
+ init_type (TYPE_CODE_FLT, TARGET_FLOAT_BIT / TARGET_CHAR_BIT, 0,
+ "float");
+ builtin_type_double =
+ init_type (TYPE_CODE_FLT, TARGET_DOUBLE_BIT / TARGET_CHAR_BIT, 0,
+ "double");
+ builtin_type_long_double =
+ init_type (TYPE_CODE_FLT, TARGET_LONG_DOUBLE_BIT / TARGET_CHAR_BIT, 0,
+ "long double");
+ builtin_type_complex =
+ init_type (TYPE_CODE_FLT, TARGET_COMPLEX_BIT / TARGET_CHAR_BIT, 0,
+ "complex");
+ builtin_type_double_complex =
+ init_type (TYPE_CODE_FLT, TARGET_DOUBLE_COMPLEX_BIT / TARGET_CHAR_BIT, 0,
+ "double complex");
add_language (&c_language_defn);
set_language (language_c); /* Make C the default language */
#define INT_MIN -0x80000000
#endif
-/* Just like CHAR_BIT in <limits.h> but describes the target machine. */
+/* Number of bits in a char or unsigned char for the target machine.
+ Just like CHAR_BIT in <limits.h> but describes the target machine. */
#if !defined (TARGET_CHAR_BIT)
#define TARGET_CHAR_BIT 8
#endif
-/* Number of bits in a long long or unsigned long long
- for the target machine. */
+/* Number of bits in a short or unsigned short for the target machine. */
+#if !defined (TARGET_SHORT_BIT)
+#define TARGET_SHORT_BIT (sizeof (short) * TARGET_CHAR_BIT)
+#endif
+
+/* Number of bits in an int or unsigned int for the target machine. */
+#if !defined (TARGET_INT_BIT)
+#define TARGET_INT_BIT (sizeof (int) * TARGET_CHAR_BIT)
+#endif
+
+/* Number of bits in a long or unsigned long for the target machine. */
+#if !defined (TARGET_LONG_BIT)
+#define TARGET_LONG_BIT (sizeof (long) * TARGET_CHAR_BIT)
+#endif
+
+/* Number of bits in a long long or unsigned long long for the target machine. */
#if !defined (TARGET_LONG_LONG_BIT)
-#define TARGET_LONG_LONG_BIT 64
+#define TARGET_LONG_LONG_BIT (2 * TARGET_LONG_BIT)
+#endif
+
+/* Number of bits in a float for the target machine. */
+#if !defined (TARGET_FLOAT_BIT)
+#define TARGET_FLOAT_BIT (sizeof (float) * TARGET_CHAR_BIT)
+#endif
+
+/* Number of bits in a double for the target machine. */
+#if !defined (TARGET_DOUBLE_BIT)
+#define TARGET_DOUBLE_BIT (sizeof (double) * TARGET_CHAR_BIT)
+#endif
+
+/* Number of bits in a long double for the target machine. */
+#if !defined (TARGET_LONG_DOUBLE_BIT)
+#define TARGET_LONG_DOUBLE_BIT (2 * TARGET_DOUBLE_BIT)
+#endif
+
+/* Number of bits in a "complex" for the target machine. */
+#if !defined (TARGET_COMPLEX_BIT)
+#define TARGET_COMPLEX_BIT (2 * TARGET_FLOAT_BIT)
+#endif
+
+/* Number of bits in a "double complex" for the target machine. */
+#if !defined (TARGET_DOUBLE_COMPLEX_BIT)
+#define TARGET_DOUBLE_COMPLEX_BIT (2 * TARGET_DOUBLE_BIT)
#endif
/* Convert a LONGEST to an int. This is used in contexts (e.g. number
#endif /* No LONG_LONG. */
#endif /* No longest_to_int. */
+/* Languages represented in the symbol table and elsewhere. */
+
+enum language
+{
+ language_unknown, /* Language not known */
+ language_auto, /* Placeholder for automatic setting */
+ language_c, /* C */
+ language_m2, /* Modula-2 */
+};
+
/* Return a format string for printf that will print a number in the local
(language-specific) hexadecimal format. Result is static and is
overwritten by the next call. local_hex_format_custom takes printf
options like "08" or "l" (to produce e.g. %08x or %lx). */
-#define local_hex_format() local_hex_format_custom("")
+#define local_hex_format() (current_language->la_hex_format)
char *local_hex_format_custom(); /* language.c */
/* Return a string that contains a number formatted in the local
overwritten by the next call. local_hex_string_custom takes printf
options like "08" or "l". */
-#define local_hex_string(n) local_hex_string_custom((n),"")
-char *local_hex_string_custom(); /* language.c */
+char *local_hex_string (); /* language.c */
+char *local_hex_string_custom (); /* language.c */
#endif /* no DEFS_H */
extern struct type *builtin_type_unsigned_long;
extern struct type *builtin_type_float;
extern struct type *builtin_type_double;
+extern struct type *builtin_type_long_double;
+extern struct type *builtin_type_complex;
+extern struct type *builtin_type_double_complex;
/* This type represents a type that was unrecognized in symbol
read-in. */
extern struct type *builtin_type_error;
fprintf_filtered (stream, "?");
break;
+ case TYPE_CODE_RANGE:
+ /* FIXME, we should not ever have to print one of these yet. */
+ fprintf_filtered (stream, "<range type>");
+ break;
+
default:
error ("Invalid type code in symbol table.");
}
wrap_here (" ");
if (type == 0)
{
- fprintf_filtered (stream, "type unknown");
+ fprintf_filtered (stream, "<type unknown>");
return;
}
fprintf_filtered (stream, "void");
break;
- case 0:
- fprintf_filtered (stream, "struct unknown");
+ case TYPE_CODE_UNDEF:
+ fprintf_filtered (stream, "struct <unknown>");
break;
case TYPE_CODE_ERROR:
fprintf_filtered (stream, "<unknown type>");
break;
+ case TYPE_CODE_RANGE:
+ /* This should not occur */
+ fprintf_filtered (stream, "<range type>");
+ break;
+
default:
error ("Invalid type code in symbol table.");
}
print_max = 200;
- /* FIXME! This assumes that these sizes and types are the same on the
- host and target machines! */
- unsigned_type_table
- = (char **) xmalloc ((1 + sizeof (unsigned LONGEST)) * sizeof (char *));
- bzero (unsigned_type_table, (1 + sizeof (unsigned LONGEST)));
- unsigned_type_table[sizeof (unsigned char)] = "unsigned char";
- unsigned_type_table[sizeof (unsigned short)] = "unsigned short";
- unsigned_type_table[sizeof (unsigned long)] = "unsigned long";
- unsigned_type_table[sizeof (unsigned int)] = "unsigned int";
-#ifdef LONG_LONG
- unsigned_type_table[TARGET_LONG_LONG_BIT/TARGET_CHAR_BIT] =
- "unsigned long long";
-#endif
-
- signed_type_table
- = (char **) xmalloc ((1 + sizeof (LONGEST)) * sizeof (char *));
- bzero (signed_type_table, (1 + sizeof (LONGEST)));
- signed_type_table[sizeof (char)] = "char";
- signed_type_table[sizeof (short)] = "short";
- signed_type_table[sizeof (long)] = "long";
- signed_type_table[sizeof (int)] = "int";
-#ifdef LONG_LONG
+ /* Initialize the names of the various types based on their lengths on
+ the target, in bits. Note that ordering is important, so that for example,
+ if ints and longs are the same size, that size will default to "int". */
+
+ unsigned_type_table = (char **)
+ xmalloc ((1 + (TARGET_LONG_LONG_BIT/TARGET_CHAR_BIT)) * sizeof (char *));
+ bzero (unsigned_type_table, (1 + (TARGET_LONG_LONG_BIT/TARGET_CHAR_BIT)));
+ unsigned_type_table[TARGET_CHAR_BIT/TARGET_CHAR_BIT] = "unsigned char";
+ unsigned_type_table[TARGET_SHORT_BIT/TARGET_CHAR_BIT] = "unsigned short";
+ unsigned_type_table[TARGET_LONG_LONG_BIT/TARGET_CHAR_BIT] = "unsigned long long";
+ unsigned_type_table[TARGET_LONG_BIT/TARGET_CHAR_BIT] = "unsigned long";
+ unsigned_type_table[TARGET_INT_BIT/TARGET_CHAR_BIT] = "unsigned int";
+
+ signed_type_table = (char **)
+ xmalloc ((1 + (TARGET_LONG_LONG_BIT/TARGET_CHAR_BIT)) * sizeof (char *));
+ bzero (signed_type_table, (1 + (TARGET_LONG_LONG_BIT/TARGET_CHAR_BIT)));
+ signed_type_table[TARGET_CHAR_BIT/TARGET_CHAR_BIT] = "char";
+ signed_type_table[TARGET_SHORT_BIT/TARGET_CHAR_BIT] = "short";
signed_type_table[TARGET_LONG_LONG_BIT/TARGET_CHAR_BIT] = "long long";
-#endif
+ signed_type_table[TARGET_LONG_BIT/TARGET_CHAR_BIT] = "long";
+ signed_type_table[TARGET_INT_BIT/TARGET_CHAR_BIT] = "int";
+
+ float_type_table = (char **)
+ xmalloc ((1 + (TARGET_LONG_DOUBLE_BIT/TARGET_CHAR_BIT)) * sizeof (char *));
+ bzero (float_type_table, (1 + (TARGET_LONG_DOUBLE_BIT/TARGET_CHAR_BIT)));
+ float_type_table[TARGET_FLOAT_BIT/TARGET_CHAR_BIT] = "float";
+ float_type_table[TARGET_DOUBLE_COMPLEX_BIT/TARGET_CHAR_BIT] = "double complex";
+ float_type_table[TARGET_COMPLEX_BIT/TARGET_CHAR_BIT] = "complex";
+ float_type_table[TARGET_LONG_DOUBLE_BIT/TARGET_CHAR_BIT] = "long double";
+ float_type_table[TARGET_DOUBLE_BIT/TARGET_CHAR_BIT] = "double";
- float_type_table
- = (char **) xmalloc ((1 + sizeof (double)) * sizeof (char *));
- bzero (float_type_table, (1 + sizeof (double)));
- float_type_table[sizeof (float)] = "float";
- float_type_table[sizeof (double)] = "double";
obstack_begin (&dont_print_obstack, 32 * sizeof (struct type *));
}