Add three new builtin types (builtin_type_long_double, builtin_type_complex,

and builtin_type_double_complex).  Also add and use various TARGET_<TYPE>_BIT
macros to indicate the sizes of various types on the target machine.
This commit is contained in:
Fred Fish 1991-10-24 10:58:41 +00:00
parent 020706804b
commit e2aab0314f
5 changed files with 162 additions and 60 deletions

View File

@ -1,5 +1,13 @@
Thu Oct 24 01:32:51 1991 Fred Fish (fnf at cygnus.com) 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(), * infrun.c: When using SVR4 /proc interface instead of ptrace(),
call proc_set_exec_trap() to setup child to stop at first instruction. call proc_set_exec_trap() to setup child to stop at first instruction.

View File

@ -1455,6 +1455,9 @@ struct type *builtin_type_unsigned_long;
struct type *builtin_type_unsigned_long_long; struct type *builtin_type_unsigned_long_long;
struct type *builtin_type_float; struct type *builtin_type_float;
struct type *builtin_type_double; 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[]) = struct type ** const (c_builtin_types[]) =
{ {
@ -1471,6 +1474,9 @@ struct type ** const (c_builtin_types[]) =
&builtin_type_unsigned_int, &builtin_type_unsigned_int,
&builtin_type_unsigned_long, &builtin_type_unsigned_long,
&builtin_type_unsigned_long_long, &builtin_type_unsigned_long_long,
&builtin_type_long_double,
&builtin_type_complex,
&builtin_type_double_complex,
0 0
}; };
@ -1486,7 +1492,7 @@ const struct language_defn c_language_defn = {
c_error, c_error,
&BUILTIN_TYPE_LONGEST, /* longest signed integral type */ &BUILTIN_TYPE_LONGEST, /* longest signed integral type */
&BUILTIN_TYPE_UNSIGNED_LONGEST,/* longest unsigned 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 */ "0x%x", "0x%", "x", /* Hex format, prefix, suffix */
"0%o", "0%", "o", /* Octal format, prefix, suffix */ "0%o", "0%", "o", /* Octal format, prefix, suffix */
c_op_print_tab, /* expression operators for printing */ c_op_print_tab, /* expression operators for printing */
@ -1496,30 +1502,54 @@ const struct language_defn c_language_defn = {
void void
_initialize_c_exp () _initialize_c_exp ()
{ {
/* FIXME: The code below assumes that the sizes of the basic data builtin_type_void =
types are the same on the host and target machines!!! */ init_type (TYPE_CODE_VOID, 1, 0,
"void");
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,
builtin_type_float = init_type (TYPE_CODE_FLT, sizeof (float), 0, "float"); "char");
builtin_type_double = init_type (TYPE_CODE_FLT, sizeof (double), 0, "double"); builtin_type_unsigned_char =
init_type (TYPE_CODE_INT, TARGET_CHAR_BIT / TARGET_CHAR_BIT, 1,
builtin_type_char = init_type (TYPE_CODE_INT, sizeof (char), 0, "char"); "unsigned char");
builtin_type_short = init_type (TYPE_CODE_INT, sizeof (short), 0, "short"); builtin_type_short =
builtin_type_long = init_type (TYPE_CODE_INT, sizeof (long), 0, "long"); init_type (TYPE_CODE_INT, TARGET_SHORT_BIT / TARGET_CHAR_BIT, 0,
builtin_type_int = init_type (TYPE_CODE_INT, sizeof (int), 0, "int"); "short");
builtin_type_unsigned_short =
builtin_type_unsigned_char = init_type (TYPE_CODE_INT, sizeof (char), 1, "unsigned char"); init_type (TYPE_CODE_INT, TARGET_SHORT_BIT / TARGET_CHAR_BIT, 1,
builtin_type_unsigned_short = init_type (TYPE_CODE_INT, sizeof (short), 1, "unsigned short"); "unsigned short");
builtin_type_unsigned_long = init_type (TYPE_CODE_INT, sizeof (long), 1, "unsigned long"); builtin_type_int =
builtin_type_unsigned_int = init_type (TYPE_CODE_INT, sizeof (int), 1, "unsigned 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 = builtin_type_long_long =
init_type (TYPE_CODE_INT, TARGET_LONG_LONG_BIT / TARGET_CHAR_BIT, init_type (TYPE_CODE_INT, TARGET_LONG_LONG_BIT / TARGET_CHAR_BIT, 0,
0, "long long"); "long long");
builtin_type_unsigned_long_long = builtin_type_unsigned_long_long =
init_type (TYPE_CODE_INT, TARGET_LONG_LONG_BIT / TARGET_CHAR_BIT, init_type (TYPE_CODE_INT, TARGET_LONG_LONG_BIT / TARGET_CHAR_BIT, 1,
1, "unsigned long long"); "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); add_language (&c_language_defn);
set_language (language_c); /* Make C the default language */ set_language (language_c); /* Make C the default language */

View File

@ -202,15 +202,55 @@ char *baud_rate;
#define INT_MIN -0x80000000 #define INT_MIN -0x80000000
#endif #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) #if !defined (TARGET_CHAR_BIT)
#define TARGET_CHAR_BIT 8 #define TARGET_CHAR_BIT 8
#endif #endif
/* Number of bits in a long long or unsigned long long /* Number of bits in a short or unsigned short for the target machine. */
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) #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 #endif
/* Convert a LONGEST to an int. This is used in contexts (e.g. number /* Convert a LONGEST to an int. This is used in contexts (e.g. number
@ -227,12 +267,22 @@ char *baud_rate;
#endif /* No LONG_LONG. */ #endif /* No LONG_LONG. */
#endif /* No longest_to_int. */ #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 /* Return a format string for printf that will print a number in the local
(language-specific) hexadecimal format. Result is static and is (language-specific) hexadecimal format. Result is static and is
overwritten by the next call. local_hex_format_custom takes printf overwritten by the next call. local_hex_format_custom takes printf
options like "08" or "l" (to produce e.g. %08x or %lx). */ 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 */ char *local_hex_format_custom(); /* language.c */
/* Return a string that contains a number formatted in the local /* Return a string that contains a number formatted in the local
@ -240,7 +290,7 @@ char *local_hex_format_custom(); /* language.c */
overwritten by the next call. local_hex_string_custom takes printf overwritten by the next call. local_hex_string_custom takes printf
options like "08" or "l". */ options like "08" or "l". */
#define local_hex_string(n) local_hex_string_custom((n),"") char *local_hex_string (); /* language.c */
char *local_hex_string_custom(); /* language.c */ char *local_hex_string_custom (); /* language.c */
#endif /* no DEFS_H */ #endif /* no DEFS_H */

View File

@ -826,6 +826,9 @@ extern struct type *builtin_type_unsigned_int;
extern struct type *builtin_type_unsigned_long; extern struct type *builtin_type_unsigned_long;
extern struct type *builtin_type_float; extern struct type *builtin_type_float;
extern struct type *builtin_type_double; 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 /* This type represents a type that was unrecognized in symbol
read-in. */ read-in. */
extern struct type *builtin_type_error; extern struct type *builtin_type_error;

View File

@ -1212,6 +1212,11 @@ val_print (type, valaddr, address, stream, format,
fprintf_filtered (stream, "?"); fprintf_filtered (stream, "?");
break; break;
case TYPE_CODE_RANGE:
/* FIXME, we should not ever have to print one of these yet. */
fprintf_filtered (stream, "<range type>");
break;
default: default:
error ("Invalid type code in symbol table."); error ("Invalid type code in symbol table.");
} }
@ -1599,7 +1604,7 @@ type_print_base (type, stream, show, level)
wrap_here (" "); wrap_here (" ");
if (type == 0) if (type == 0)
{ {
fprintf_filtered (stream, "type unknown"); fprintf_filtered (stream, "<type unknown>");
return; return;
} }
@ -1813,14 +1818,19 @@ type_print_base (type, stream, show, level)
fprintf_filtered (stream, "void"); fprintf_filtered (stream, "void");
break; break;
case 0: case TYPE_CODE_UNDEF:
fprintf_filtered (stream, "struct unknown"); fprintf_filtered (stream, "struct <unknown>");
break; break;
case TYPE_CODE_ERROR: case TYPE_CODE_ERROR:
fprintf_filtered (stream, "<unknown type>"); fprintf_filtered (stream, "<unknown type>");
break; break;
case TYPE_CODE_RANGE:
/* This should not occur */
fprintf_filtered (stream, "<range type>");
break;
default: default:
error ("Invalid type code in symbol table."); error ("Invalid type code in symbol table.");
} }
@ -2017,35 +2027,36 @@ _initialize_valprint ()
print_max = 200; print_max = 200;
/* FIXME! This assumes that these sizes and types are the same on the /* Initialize the names of the various types based on their lengths on
host and target machines! */ the target, in bits. Note that ordering is important, so that for example,
unsigned_type_table if ints and longs are the same size, that size will default to "int". */
= (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 unsigned_type_table = (char **)
= (char **) xmalloc ((1 + sizeof (LONGEST)) * sizeof (char *)); xmalloc ((1 + (TARGET_LONG_LONG_BIT/TARGET_CHAR_BIT)) * sizeof (char *));
bzero (signed_type_table, (1 + sizeof (LONGEST))); bzero (unsigned_type_table, (1 + (TARGET_LONG_LONG_BIT/TARGET_CHAR_BIT)));
signed_type_table[sizeof (char)] = "char"; unsigned_type_table[TARGET_CHAR_BIT/TARGET_CHAR_BIT] = "unsigned char";
signed_type_table[sizeof (short)] = "short"; unsigned_type_table[TARGET_SHORT_BIT/TARGET_CHAR_BIT] = "unsigned short";
signed_type_table[sizeof (long)] = "long"; unsigned_type_table[TARGET_LONG_LONG_BIT/TARGET_CHAR_BIT] = "unsigned long long";
signed_type_table[sizeof (int)] = "int"; unsigned_type_table[TARGET_LONG_BIT/TARGET_CHAR_BIT] = "unsigned long";
#ifdef LONG_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"; 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 *)); obstack_begin (&dont_print_obstack, 32 * sizeof (struct type *));
} }