aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJim Kingdon <jkingdon@engr.sgi.com>1994-02-02 17:20:45 +0000
committerJim Kingdon <jkingdon@engr.sgi.com>1994-02-02 17:20:45 +0000
commit61932a8ee900c0368eef3b101fa9a04050aa7c56 (patch)
treee0a50d67f3e5ef8de7283822ecacc3d4d93fee3c
parent1051c97f630bf96febe9e0029ba8df161d3a4db1 (diff)
downloadgdb-61932a8ee900c0368eef3b101fa9a04050aa7c56.zip
gdb-61932a8ee900c0368eef3b101fa9a04050aa7c56.tar.gz
gdb-61932a8ee900c0368eef3b101fa9a04050aa7c56.tar.bz2
* gdbtypes.h, ch-typeprint.c, ch-valprint.c:
Change comments regarding TYPE_CODE_BOOL. * language.c (boolean_type): Always return 1 for TYPE_CODE_BOOL, regardless of the language. (value_true): Just call value_logical_not regardless of language. * coffread.c (coff_read_enum_type), stabsread.c (read_enum_type): Remove #if 0'd code which makes some enums TYPE_CODE_BOOL. * language.h: Improve comment for la_builtin_type_vector. * m2-lang.c (_initialize_m2_language): Don't add any fields to builtin_type_m2_bool.
-rw-r--r--gdb/ChangeLog13
-rw-r--r--gdb/ch-typeprint.c4
-rw-r--r--gdb/ch-valprint.c1
-rw-r--r--gdb/gdbtypes.h12
-rw-r--r--gdb/language.c68
-rw-r--r--gdb/language.h5
-rw-r--r--gdb/m2-lang.c10
-rw-r--r--gdb/stabsread.c11
8 files changed, 50 insertions, 74 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 25f69ad..adca9e1 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,16 @@
+Wed Feb 2 11:16:45 1994 Jim Kingdon (kingdon@lioth.cygnus.com)
+
+ * gdbtypes.h, ch-typeprint.c, ch-valprint.c:
+ Change comments regarding TYPE_CODE_BOOL.
+ * language.c (boolean_type): Always return 1 for TYPE_CODE_BOOL,
+ regardless of the language.
+ (value_true): Just call value_logical_not regardless of language.
+ * coffread.c (coff_read_enum_type), stabsread.c (read_enum_type):
+ Remove #if 0'd code which makes some enums TYPE_CODE_BOOL.
+ * language.h: Improve comment for la_builtin_type_vector.
+ * m2-lang.c (_initialize_m2_language): Don't add any fields to
+ builtin_type_m2_bool.
+
Tue Feb 1 17:13:32 1994 Kevin Buettner (kev@cujo.geg.mot.com)
* config/m88k/{tm-delta88.h,tm-delta88v4.h}, m88k-tdep.c:
diff --git a/gdb/ch-typeprint.c b/gdb/ch-typeprint.c
index 377fff9..740af37 100644
--- a/gdb/ch-typeprint.c
+++ b/gdb/ch-typeprint.c
@@ -115,6 +115,10 @@ chill_type_print_base (type, stream, show, level)
break;
case TYPE_CODE_BOOL:
+ /* FIXME: we should probably just print the TYPE_NAME, in case
+ anyone ever fixes the compiler to give us the real names
+ in the presence of the chill equivalent of typedef (assuming
+ there is one). */
fprintf_filtered (stream, "BOOL");
break;
diff --git a/gdb/ch-valprint.c b/gdb/ch-valprint.c
index 37ca0f4..b9ae35b 100644
--- a/gdb/ch-valprint.c
+++ b/gdb/ch-valprint.c
@@ -128,6 +128,7 @@ chill_val_print (type, valaddr, address, stream, format, deref_ref, recurse,
}
else
{
+ /* FIXME: Why is this using builtin_type_chill_bool not type? */
val = unpack_long (builtin_type_chill_bool, valaddr);
fprintf_filtered (stream, val ? "TRUE" : "FALSE");
}
diff --git a/gdb/gdbtypes.h b/gdb/gdbtypes.h
index bf21d90..559e7ec 100644
--- a/gdb/gdbtypes.h
+++ b/gdb/gdbtypes.h
@@ -111,14 +111,18 @@ enum type_code
TYPE_CODE_METHOD, /* Method type */
TYPE_CODE_REF, /* C++ Reference types */
- /* Modula-2 */
TYPE_CODE_CHAR, /* *real* character type */
- TYPE_CODE_BOOL /* BOOLEAN type */
+
+ /* Boolean type. 0 is false, 1 is true, and other values are non-boolean
+ (e.g. FORTRAN "logical" used as unsigned int). */
+ TYPE_CODE_BOOL
};
/* For now allow source to use TYPE_CODE_CLASS for C++ classes, as an
- alias for TYPE_CODE_STRUCT. Eventually these should probably be
- officially distinct types within gdb. */
+ alias for TYPE_CODE_STRUCT. This is for DWARF, which has a distinct
+ "class" attribute. Perhaps we should actually have a separate TYPE_CODE
+ so that we can print "class" or "struct" depending on what the debug
+ info said. It's not clear we should bother. */
#define TYPE_CODE_CLASS TYPE_CODE_STRUCT
diff --git a/gdb/language.c b/gdb/language.c
index b74e428..03cf667 100644
--- a/gdb/language.c
+++ b/gdb/language.c
@@ -698,18 +698,20 @@ int
boolean_type (type)
struct type *type;
{
- switch(current_language->la_language)
- {
- case language_chill:
- case language_m2:
- return TYPE_CODE(type) != TYPE_CODE_BOOL ? 0 : 1;
-
- case language_c:
- case language_cplus:
- return TYPE_CODE(type) != TYPE_CODE_INT ? 0 : 1;
+ if (TYPE_CODE (type) == TYPE_CODE_BOOL)
+ return 1;
+ switch(current_language->la_language)
+ {
+ case language_c:
+ case language_cplus:
+ /* Might be more cleanly handled by having a TYPE_CODE_INT_NOT_BOOL
+ for CHILL and such languages, or a TYPE_CODE_INT_OR_BOOL for C. */
+ if (TYPE_CODE (type) == TYPE_CODE_INT)
+ return 1;
default:
- return (0);
+ break;
}
+ return 0;
}
/* Returns non-zero if the value is a floating-point type */
@@ -757,46 +759,16 @@ structured_type(type)
/* Returns non-zero if the value VAL represents a true value. */
int
-value_true(val)
+value_true (val)
value val;
{
- int len, i;
- struct type *type;
- LONGEST v;
-
- switch (current_language->la_language) {
-
- case language_c:
- case language_cplus:
- return !value_logical_not (val);
-
- case language_m2:
- type = VALUE_TYPE(val);
- if (TYPE_CODE (type) != TYPE_CODE_BOOL)
- return 0; /* Not a BOOLEAN at all */
- /* Search the fields for one that matches the current value. */
- len = TYPE_NFIELDS (type);
- v = value_as_long (val);
- for (i = 0; i < len; i++)
- {
- QUIT;
- if (v == TYPE_FIELD_BITPOS (type, i))
- break;
- }
- if (i >= len)
- return 0; /* Not a valid BOOLEAN value */
- if (STREQ ("TRUE", TYPE_FIELD_NAME(VALUE_TYPE(val), i)))
- return 1; /* BOOLEAN with value TRUE */
- else
- return 0; /* BOOLEAN with value FALSE */
- break;
-
- case language_chill:
- error ("Missing Chill support in function value_type."); /*FIXME*/
-
- default:
- error ("Language not supported.");
- }
+ /* It is possible that we should have some sort of error if a non-boolean
+ value is used in this context. Possibly dependent on some kind of
+ "boolean-checking" option like range checking. But it should probably
+ not depend on the language except insofar as is necessary to identify
+ a "boolean" value (i.e. in C using a float, pointer, etc., as a boolean
+ should be an error, probably). */
+ return !value_logical_not (val);
}
/* Returns non-zero if the operator OP is defined on
diff --git a/gdb/language.h b/gdb/language.h
index e197aaa..9d087ce 100644
--- a/gdb/language.h
+++ b/gdb/language.h
@@ -106,7 +106,10 @@ struct language_defn
enum language la_language;
- /* Its builtin types */
+ /* Its builtin types. This is a vector ended by a NULL pointer. These
+ types can be specified by name in parsing types in expressions,
+ regardless of whether the program being debugged actually defines
+ such a type. */
struct type ** const *la_builtin_type_vector;
diff --git a/gdb/m2-lang.c b/gdb/m2-lang.c
index 5561561..03ff12d 100644
--- a/gdb/m2-lang.c
+++ b/gdb/m2-lang.c
@@ -443,15 +443,5 @@ _initialize_m2_language ()
TYPE_FLAG_UNSIGNED,
"BOOLEAN", (struct objfile *) NULL);
- TYPE_NFIELDS(builtin_type_m2_bool) = 2;
- TYPE_FIELDS(builtin_type_m2_bool) =
- (struct field *) xmalloc (sizeof (struct field) * 2);
- TYPE_FIELD_BITPOS(builtin_type_m2_bool,0) = 0;
- TYPE_FIELD_NAME(builtin_type_m2_bool,0) = (char *)xmalloc(6);
- strcpy(TYPE_FIELD_NAME(builtin_type_m2_bool,0),"FALSE");
- TYPE_FIELD_BITPOS(builtin_type_m2_bool,1) = 1;
- TYPE_FIELD_NAME(builtin_type_m2_bool,1) = (char *)xmalloc(5);
- strcpy(TYPE_FIELD_NAME(builtin_type_m2_bool,1),"TRUE");
-
add_language (&m2_language_defn);
}
diff --git a/gdb/stabsread.c b/gdb/stabsread.c
index 59a659c..0b18d04 100644
--- a/gdb/stabsread.c
+++ b/gdb/stabsread.c
@@ -2980,17 +2980,6 @@ read_enum_type (pp, type, objfile)
break;
}
-#if 0
- /* This screws up perfectly good C programs with enums. FIXME. */
- /* Is this Modula-2's BOOLEAN type? Flag it as such if so. */
- if(TYPE_NFIELDS(type) == 2 &&
- ((STREQ(TYPE_FIELD_NAME(type,0),"TRUE") &&
- STREQ(TYPE_FIELD_NAME(type,1),"FALSE")) ||
- (STREQ(TYPE_FIELD_NAME(type,1),"TRUE") &&
- STREQ(TYPE_FIELD_NAME(type,0),"FALSE"))))
- TYPE_CODE(type) = TYPE_CODE_BOOL;
-#endif
-
return type;
}