aboutsummaryrefslogtreecommitdiff
path: root/gdb/c-exp.y
diff options
context:
space:
mode:
authorFred Fish <fnf@specifix.com>1992-12-03 20:28:16 +0000
committerFred Fish <fnf@specifix.com>1992-12-03 20:28:16 +0000
commitbf229b4ea5f95fa036f6d3dc8fc7b236c5028f5e (patch)
treecc20d393117640e08a39907258a8a2c389bd3fe4 /gdb/c-exp.y
parentef6bfbdbccdf4a0cbb759614c0ef73e9c07ec04b (diff)
downloadfsf-binutils-gdb-bf229b4ea5f95fa036f6d3dc8fc7b236c5028f5e.zip
fsf-binutils-gdb-bf229b4ea5f95fa036f6d3dc8fc7b236c5028f5e.tar.gz
fsf-binutils-gdb-bf229b4ea5f95fa036f6d3dc8fc7b236c5028f5e.tar.bz2
* c-exp.y (c_create_fundamental_type): New function to create
language specific fundamental types for C. * m2-exp.y (m2_create_fundamental_type): New function to create language specific fundamental types for Modula 2. * c-exp.y (c_language_defn, cplus_language_defn): Add c_create_fundamental_type to language struct initializers. * m2-exp.y (m2_language_defn): Add m2_create_fundamental_type to language struct initializers. * dwarfread.c (expression.h, language.h): Include. * dwarfread.c (ftypes): New array to hold fundamental types for current compilation unit. * dwarfread.c (cu_language_defn): New pointer to language struct for language of current compilation unit. * dwarfread.c (dwarf_fundamental_type): New function to create/lookup fundamental types. * dwarfread.c (set_cu_language): Initialize cu_language_defn. * dwarfread.c (throughout): Replace lookup_fundamental_type with dwarf_fundamental_type. * dwarfread.c (read_file_scope): Zero out ftypes for each new compilation unit (may be different language or different objfile). * gdbtypes.c (lookup_fundamental_type): Move actual type creations into language specific fundamental type creation functions and call via create_fundamental_type. Add comment about this function being obsolescent. * gdbtypes.h (FT_BYTE, FT_UNSIGNED_BYTE): New types, true byte sized signed and unsigned integers. * gdbtypes.h (FT_NUM_MEMBERS): Increment, new types added. * language.c (language_def): New function to lookup a language struct given it's enumeration. * language.h (struct language_defn): Add la_fund_type, a pointer to a function that creates fundamental types for this language. * language.h (create_fundamental_type): New macro to create fundamental types based on the current language. * language.h (language_def): Add prototype. * language.c (unk_lang_create_fundamental_type): New function for initializing language structs, calls error if called. * language.c (unk_language_defn, auto_language_defn, local_language_defn): Use unk_lang_create_fundamental_type. **** start-sanitize-chill **** ch-exp.y (chill_create_fundamental_type): New function. ch-exp.y (chill_language_defn): Add chill_create_fundamental_type. ch-exp.y (_initialize_chill_exp): BOOL types are only one byte. **** end-sanitize-chill ****
Diffstat (limited to 'gdb/c-exp.y')
-rw-r--r--gdb/c-exp.y146
1 files changed, 145 insertions, 1 deletions
diff --git a/gdb/c-exp.y b/gdb/c-exp.y
index c368aa9..25567a7 100644
--- a/gdb/c-exp.y
+++ b/gdb/c-exp.y
@@ -1666,6 +1666,148 @@ c_printstr (stream, string, length, force_ellipses)
fputs_filtered ("...", stream);
}
+/* Create a fundamental C type using default reasonable for the current
+ target machine.
+
+ Some object/debugging file formats (DWARF version 1, COFF, etc) do not
+ define fundamental types such as "int" or "double". Others (stabs or
+ DWARF version 2, etc) do define fundamental types. For the formats which
+ don't provide fundamental types, gdb can create such types using this
+ function.
+
+ FIXME: Some compilers distinguish explicitly signed integral types
+ (signed short, signed int, signed long) from "regular" integral types
+ (short, int, long) in the debugging information. There is some dis-
+ agreement as to how useful this feature is. In particular, gcc does
+ not support this. Also, only some debugging formats allow the
+ distinction to be passed on to a debugger. For now, we always just
+ use "short", "int", or "long" as the type name, for both the implicit
+ and explicitly signed types. This also makes life easier for the
+ gdb test suite since we don't have to account for the differences
+ in output depending upon what the compiler and debugging format
+ support. We will probably have to re-examine the issue when gdb
+ starts taking it's fundamental type information directly from the
+ debugging information supplied by the compiler. fnf@cygnus.com */
+
+static struct type *
+c_create_fundamental_type (objfile, typeid)
+ struct objfile *objfile;
+ int typeid;
+{
+ register struct type *type = NULL;
+ register int nbytes;
+
+ switch (typeid)
+ {
+ default:
+ /* FIXME: For now, if we are asked to produce a type not in this
+ language, create the equivalent of a C integer type with the
+ name "<?type?>". When all the dust settles from the type
+ reconstruction work, this should probably become an error. */
+ type = init_type (TYPE_CODE_INT,
+ TARGET_INT_BIT / TARGET_CHAR_BIT,
+ 0, "<?type?>", objfile);
+ warning ("internal error: no C/C++ fundamental type %d", typeid);
+ break;
+ case FT_VOID:
+ type = init_type (TYPE_CODE_VOID,
+ TARGET_CHAR_BIT / TARGET_CHAR_BIT,
+ 0, "void", objfile);
+ break;
+ case FT_CHAR:
+ type = init_type (TYPE_CODE_INT,
+ TARGET_CHAR_BIT / TARGET_CHAR_BIT,
+ 0, "char", objfile);
+ break;
+ case FT_SIGNED_CHAR:
+ type = init_type (TYPE_CODE_INT,
+ TARGET_CHAR_BIT / TARGET_CHAR_BIT,
+ TYPE_FLAG_SIGNED, "signed char", objfile);
+ break;
+ case FT_UNSIGNED_CHAR:
+ type = init_type (TYPE_CODE_INT,
+ TARGET_CHAR_BIT / TARGET_CHAR_BIT,
+ TYPE_FLAG_UNSIGNED, "unsigned char", objfile);
+ break;
+ case FT_SHORT:
+ type = init_type (TYPE_CODE_INT,
+ TARGET_SHORT_BIT / TARGET_CHAR_BIT,
+ 0, "short", objfile);
+ break;
+ case FT_SIGNED_SHORT:
+ type = init_type (TYPE_CODE_INT,
+ TARGET_SHORT_BIT / TARGET_CHAR_BIT,
+ TYPE_FLAG_SIGNED, "short", objfile); /* FIXME-fnf */
+ break;
+ case FT_UNSIGNED_SHORT:
+ type = init_type (TYPE_CODE_INT,
+ TARGET_SHORT_BIT / TARGET_CHAR_BIT,
+ TYPE_FLAG_UNSIGNED, "unsigned short", objfile);
+ break;
+ case FT_INTEGER:
+ type = init_type (TYPE_CODE_INT,
+ TARGET_INT_BIT / TARGET_CHAR_BIT,
+ 0, "int", objfile);
+ break;
+ case FT_SIGNED_INTEGER:
+ type = init_type (TYPE_CODE_INT,
+ TARGET_INT_BIT / TARGET_CHAR_BIT,
+ TYPE_FLAG_SIGNED, "int", objfile); /* FIXME -fnf */
+ break;
+ case FT_UNSIGNED_INTEGER:
+ type = init_type (TYPE_CODE_INT,
+ TARGET_INT_BIT / TARGET_CHAR_BIT,
+ TYPE_FLAG_UNSIGNED, "unsigned int", objfile);
+ break;
+ case FT_LONG:
+ type = init_type (TYPE_CODE_INT,
+ TARGET_LONG_BIT / TARGET_CHAR_BIT,
+ 0, "long", objfile);
+ break;
+ case FT_SIGNED_LONG:
+ type = init_type (TYPE_CODE_INT,
+ TARGET_LONG_BIT / TARGET_CHAR_BIT,
+ TYPE_FLAG_SIGNED, "long", objfile); /* FIXME -fnf */
+ break;
+ case FT_UNSIGNED_LONG:
+ type = init_type (TYPE_CODE_INT,
+ TARGET_LONG_BIT / TARGET_CHAR_BIT,
+ TYPE_FLAG_UNSIGNED, "unsigned long", objfile);
+ break;
+ case FT_LONG_LONG:
+ type = init_type (TYPE_CODE_INT,
+ TARGET_LONG_LONG_BIT / TARGET_CHAR_BIT,
+ 0, "long long", objfile);
+ break;
+ case FT_SIGNED_LONG_LONG:
+ type = init_type (TYPE_CODE_INT,
+ TARGET_LONG_LONG_BIT / TARGET_CHAR_BIT,
+ TYPE_FLAG_SIGNED, "signed long long", objfile);
+ break;
+ case FT_UNSIGNED_LONG_LONG:
+ type = init_type (TYPE_CODE_INT,
+ TARGET_LONG_LONG_BIT / TARGET_CHAR_BIT,
+ TYPE_FLAG_UNSIGNED, "unsigned long long", objfile);
+ break;
+ case FT_FLOAT:
+ type = init_type (TYPE_CODE_FLT,
+ TARGET_FLOAT_BIT / TARGET_CHAR_BIT,
+ 0, "float", objfile);
+ break;
+ case FT_DBL_PREC_FLOAT:
+ type = init_type (TYPE_CODE_FLT,
+ TARGET_DOUBLE_BIT / TARGET_CHAR_BIT,
+ 0, "double", objfile);
+ break;
+ case FT_EXT_PREC_FLOAT:
+ type = init_type (TYPE_CODE_FLT,
+ TARGET_LONG_DOUBLE_BIT / TARGET_CHAR_BIT,
+ 0, "long double", objfile);
+ break;
+ }
+ return (type);
+}
+
/* Table mapping opcodes into strings for printing operators
and precedences of the operators. */
@@ -1759,7 +1901,8 @@ const struct language_defn c_language_defn = {
c_error,
c_printchar, /* Print a character constant */
c_printstr, /* Function to print string constant */
- &BUILTIN_TYPE_LONGEST, /* longest signed integral type */
+ c_create_fundamental_type, /* Create fundamental type in this language */
+ &BUILTIN_TYPE_LONGEST, /* longest signed integral type */
&BUILTIN_TYPE_UNSIGNED_LONGEST,/* longest unsigned integral type */
&builtin_type_double, /* longest floating point type */ /*FIXME*/
{"", "", "", ""}, /* Binary format info */
@@ -1780,6 +1923,7 @@ const struct language_defn cplus_language_defn = {
c_error,
c_printchar, /* Print a character constant */
c_printstr, /* Function to print string constant */
+ c_create_fundamental_type, /* Create fundamental type in this language */
&BUILTIN_TYPE_LONGEST, /* longest signed integral type */
&BUILTIN_TYPE_UNSIGNED_LONGEST,/* longest unsigned integral type */
&builtin_type_double, /* longest floating point type */ /*FIXME*/