diff options
author | Ulrich Weigand <uweigand@de.ibm.com> | 2008-09-11 14:11:40 +0000 |
---|---|---|
committer | Ulrich Weigand <uweigand@de.ibm.com> | 2008-09-11 14:11:40 +0000 |
commit | fbb06eb1ba120adde645d64133f5a9bbf2d62ec7 (patch) | |
tree | 2dc42cd0011089aeca55de8bb8dfa2da1ff77dca /gdb | |
parent | de7b6b470188ff9f2b8fcfd831d98f8807fdf6c8 (diff) | |
download | gdb-fbb06eb1ba120adde645d64133f5a9bbf2d62ec7.zip gdb-fbb06eb1ba120adde645d64133f5a9bbf2d62ec7.tar.gz gdb-fbb06eb1ba120adde645d64133f5a9bbf2d62ec7.tar.bz2 |
* language.h (struct language_arch_info): New members
bool_type_default and bool_type_symbol.
(lang_bool_type): Remove prototype.
(LA_BOOL_TYPE): Remove macro.
(language_bool_type): Add prototype.
* language.c (lang_bool_type): Remove.
(language_bool_type): New function.
* value.h (value_in): Change return value to int.
* value.c (value_in): Return int instead of struct value *.
* eval.c (evaluate_subexp_standard): Call language_bool_type instead
of using LA_BOOL_TYPE. Update call to value_in.
* ada-lang.c (ada_evaluate_subexp): Call language_bool_type instead
of using LA_BOOL_TYPE or builtin_type_int for boolean values.
* language.c (unknown_language_arch_info): Set bool_type_default member
of struct language_arch_info.
* ada-lang.c (ada_language_arch_info): Set bool_type_symbol and
bool_type_default members of struct language_arch_info.
* c-lang.c (c_language_arch_info): Set bool_type_default member
of struct language_arch_info.
(cplus_language_arch_info): Set bool_type_symbol and bool_type_default
members of struct language_arch_info.
* f-lang.c (f_language_arch_info): Set bool_type_symbol and
bool_type_default members of struct language_arch_info.
* jv-lang.c (java_language_arch_info): Set bool_type_symbol and
bool_type_default members of struct language_arch_info.
* m2-lang.c (m2_language_arch_info): Set bool_type_symbol and
bool_type_default members of struct language_arch_info.
* p-lang.c (p_language_arch_info): Set bool_type_symbol and
bool_type_default members of struct language_arch_info.
Diffstat (limited to 'gdb')
-rw-r--r-- | gdb/ChangeLog | 35 | ||||
-rw-r--r-- | gdb/ada-lang.c | 28 | ||||
-rw-r--r-- | gdb/c-lang.c | 5 | ||||
-rw-r--r-- | gdb/eval.c | 40 | ||||
-rw-r--r-- | gdb/f-lang.c | 3 | ||||
-rw-r--r-- | gdb/jv-lang.c | 3 | ||||
-rw-r--r-- | gdb/language.c | 69 | ||||
-rw-r--r-- | gdb/language.h | 13 | ||||
-rw-r--r-- | gdb/m2-lang.c | 3 | ||||
-rw-r--r-- | gdb/p-lang.c | 3 | ||||
-rw-r--r-- | gdb/valarith.c | 4 | ||||
-rw-r--r-- | gdb/value.h | 2 |
12 files changed, 133 insertions, 75 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 0ba2e95..91869e4 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,5 +1,40 @@ 2008-09-11 Ulrich Weigand <uweigand@de.ibm.com> + * language.h (struct language_arch_info): New members + bool_type_default and bool_type_symbol. + (lang_bool_type): Remove prototype. + (LA_BOOL_TYPE): Remove macro. + (language_bool_type): Add prototype. + * language.c (lang_bool_type): Remove. + (language_bool_type): New function. + + * value.h (value_in): Change return value to int. + * value.c (value_in): Return int instead of struct value *. + + * eval.c (evaluate_subexp_standard): Call language_bool_type instead + of using LA_BOOL_TYPE. Update call to value_in. + * ada-lang.c (ada_evaluate_subexp): Call language_bool_type instead + of using LA_BOOL_TYPE or builtin_type_int for boolean values. + + * language.c (unknown_language_arch_info): Set bool_type_default member + of struct language_arch_info. + * ada-lang.c (ada_language_arch_info): Set bool_type_symbol and + bool_type_default members of struct language_arch_info. + * c-lang.c (c_language_arch_info): Set bool_type_default member + of struct language_arch_info. + (cplus_language_arch_info): Set bool_type_symbol and bool_type_default + members of struct language_arch_info. + * f-lang.c (f_language_arch_info): Set bool_type_symbol and + bool_type_default members of struct language_arch_info. + * jv-lang.c (java_language_arch_info): Set bool_type_symbol and + bool_type_default members of struct language_arch_info. + * m2-lang.c (m2_language_arch_info): Set bool_type_symbol and + bool_type_default members of struct language_arch_info. + * p-lang.c (p_language_arch_info): Set bool_type_symbol and + bool_type_default members of struct language_arch_info. + +2008-09-11 Ulrich Weigand <uweigand@de.ibm.com> + * jv-lang.c (enum java_primitive_types): New type. (java_language_arch_info): New function. (java_language): Use it instead of c_language_arch_info. diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c index 50fd5eb..d7dddd0 100644 --- a/gdb/ada-lang.c +++ b/gdb/ada-lang.c @@ -8525,7 +8525,8 @@ ada_evaluate_subexp (struct type *expect_type, struct expression *exp, tem = ada_value_equal (arg1, arg2); if (op == BINOP_NOTEQUAL) tem = !tem; - return value_from_longest (LA_BOOL_TYPE, (LONGEST) tem); + type = language_bool_type (exp->language_defn, exp->gdbarch); + return value_from_longest (type, (LONGEST) tem); case UNOP_NEG: arg1 = evaluate_subexp (NULL_TYPE, exp, pos, noside); @@ -8544,7 +8545,8 @@ ada_evaluate_subexp (struct type *expect_type, struct expression *exp, *pos -= 1; val = evaluate_subexp_standard (expect_type, exp, pos, noside); - return value_cast (LA_BOOL_TYPE, val); + type = language_bool_type (exp->language_defn, exp->gdbarch); + return value_cast (type, val); } case BINOP_BITWISE_AND: @@ -8812,13 +8814,15 @@ ada_evaluate_subexp (struct type *expect_type, struct expression *exp, default: lim_warning (_("Membership test incompletely implemented; " "always returns true")); - return value_from_longest (builtin_type_int, (LONGEST) 1); + type = language_bool_type (exp->language_defn, exp->gdbarch); + return value_from_longest (type, (LONGEST) 1); case TYPE_CODE_RANGE: arg2 = value_from_longest (type, TYPE_LOW_BOUND (type)); arg3 = value_from_longest (type, TYPE_HIGH_BOUND (type)); - return - value_from_longest (builtin_type_int, + type = language_bool_type (exp->language_defn, exp->gdbarch); + return + value_from_longest (type, (value_less (arg1, arg3) || value_equal (arg1, arg3)) && (value_less (arg2, arg1) @@ -8834,7 +8838,10 @@ ada_evaluate_subexp (struct type *expect_type, struct expression *exp, goto nosideret; if (noside == EVAL_AVOID_SIDE_EFFECTS) - return value_zero (builtin_type_int, not_lval); + { + type = language_bool_type (exp->language_defn, exp->gdbarch); + return value_zero (type, not_lval); + } tem = longest_to_int (exp->elts[pc + 1].longconst); @@ -8844,8 +8851,9 @@ ada_evaluate_subexp (struct type *expect_type, struct expression *exp, arg3 = ada_array_bound (arg2, tem, 1); arg2 = ada_array_bound (arg2, tem, 0); + type = language_bool_type (exp->language_defn, exp->gdbarch); return - value_from_longest (builtin_type_int, + value_from_longest (type, (value_less (arg1, arg3) || value_equal (arg1, arg3)) && (value_less (arg2, arg1) @@ -8859,8 +8867,9 @@ ada_evaluate_subexp (struct type *expect_type, struct expression *exp, if (noside == EVAL_SKIP) goto nosideret; + type = language_bool_type (exp->language_defn, exp->gdbarch); return - value_from_longest (builtin_type_int, + value_from_longest (type, (value_less (arg1, arg3) || value_equal (arg1, arg3)) && (value_less (arg2, arg1) @@ -10872,6 +10881,9 @@ ada_language_arch_info (struct gdbarch *gdbarch, (struct objfile *) NULL)); TYPE_NAME (lai->primitive_type_vector [ada_primitive_type_system_address]) = "system__address"; + + lai->bool_type_symbol = "boolean"; + lai->bool_type_default = builtin->builtin_bool; } /* Language vector */ diff --git a/gdb/c-lang.c b/gdb/c-lang.c index 9ce4bb9..ebe781b 100644 --- a/gdb/c-lang.c +++ b/gdb/c-lang.c @@ -380,6 +380,8 @@ c_language_arch_info (struct gdbarch *gdbarch, lai->primitive_type_vector [c_primitive_type_decfloat] = builtin->builtin_decfloat; lai->primitive_type_vector [c_primitive_type_decdouble] = builtin->builtin_decdouble; lai->primitive_type_vector [c_primitive_type_declong] = builtin->builtin_declong; + + lai->bool_type_default = builtin->builtin_int; } const struct language_defn c_language_defn = @@ -493,6 +495,9 @@ cplus_language_arch_info (struct gdbarch *gdbarch, = builtin->builtin_decdouble; lai->primitive_type_vector [cplus_primitive_type_declong] = builtin->builtin_declong; + + lai->bool_type_symbol = "bool"; + lai->bool_type_default = builtin->builtin_bool; } const struct language_defn cplus_language_defn = @@ -562,8 +562,8 @@ evaluate_subexp_standard (struct type *expect_type, } case OP_BOOL: (*pos) += 2; - return value_from_longest (LA_BOOL_TYPE, - exp->elts[pc + 1].longconst); + type = language_bool_type (exp->language_defn, exp->gdbarch); + return value_from_longest (type, exp->elts[pc + 1].longconst); case OP_INTERNALVAR: (*pos) += 2; @@ -1618,7 +1618,8 @@ evaluate_subexp_standard (struct type *expect_type, arg2 = evaluate_subexp_with_coercion (exp, pos, noside); if (noside == EVAL_SKIP) goto nosideret; - return value_in (arg1, arg2); + type = language_bool_type (exp->language_defn, exp->gdbarch); + return value_from_longest (type, (LONGEST) value_in (arg1, arg2)); case MULTI_SUBSCRIPT: (*pos) += 2; @@ -1678,7 +1679,8 @@ evaluate_subexp_standard (struct type *expect_type, break; case TYPE_CODE_BITSTRING: - arg1 = value_bitstring_subscript (LA_BOOL_TYPE, arg1, arg2); + type = language_bool_type (exp->language_defn, exp->gdbarch); + arg1 = value_bitstring_subscript (type, arg1, arg2); break; default: @@ -1798,7 +1800,8 @@ evaluate_subexp_standard (struct type *expect_type, tem = value_logical_not (arg1); arg2 = evaluate_subexp (NULL_TYPE, exp, pos, (tem ? EVAL_SKIP : noside)); - return value_from_longest (LA_BOOL_TYPE, + type = language_bool_type (exp->language_defn, exp->gdbarch); + return value_from_longest (type, (LONGEST) (!tem && !value_logical_not (arg2))); } @@ -1824,7 +1827,8 @@ evaluate_subexp_standard (struct type *expect_type, tem = value_logical_not (arg1); arg2 = evaluate_subexp (NULL_TYPE, exp, pos, (!tem ? EVAL_SKIP : noside)); - return value_from_longest (LA_BOOL_TYPE, + type = language_bool_type (exp->language_defn, exp->gdbarch); + return value_from_longest (type, (LONGEST) (!tem || !value_logical_not (arg2))); } @@ -1840,7 +1844,8 @@ evaluate_subexp_standard (struct type *expect_type, else { tem = value_equal (arg1, arg2); - return value_from_longest (LA_BOOL_TYPE, (LONGEST) tem); + type = language_bool_type (exp->language_defn, exp->gdbarch); + return value_from_longest (type, (LONGEST) tem); } case BINOP_NOTEQUAL: @@ -1855,7 +1860,8 @@ evaluate_subexp_standard (struct type *expect_type, else { tem = value_equal (arg1, arg2); - return value_from_longest (LA_BOOL_TYPE, (LONGEST) ! tem); + type = language_bool_type (exp->language_defn, exp->gdbarch); + return value_from_longest (type, (LONGEST) ! tem); } case BINOP_LESS: @@ -1870,7 +1876,8 @@ evaluate_subexp_standard (struct type *expect_type, else { tem = value_less (arg1, arg2); - return value_from_longest (LA_BOOL_TYPE, (LONGEST) tem); + type = language_bool_type (exp->language_defn, exp->gdbarch); + return value_from_longest (type, (LONGEST) tem); } case BINOP_GTR: @@ -1885,7 +1892,8 @@ evaluate_subexp_standard (struct type *expect_type, else { tem = value_less (arg2, arg1); - return value_from_longest (LA_BOOL_TYPE, (LONGEST) tem); + type = language_bool_type (exp->language_defn, exp->gdbarch); + return value_from_longest (type, (LONGEST) tem); } case BINOP_GEQ: @@ -1900,7 +1908,8 @@ evaluate_subexp_standard (struct type *expect_type, else { tem = value_less (arg2, arg1) || value_equal (arg1, arg2); - return value_from_longest (LA_BOOL_TYPE, (LONGEST) tem); + type = language_bool_type (exp->language_defn, exp->gdbarch); + return value_from_longest (type, (LONGEST) tem); } case BINOP_LEQ: @@ -1915,7 +1924,8 @@ evaluate_subexp_standard (struct type *expect_type, else { tem = value_less (arg1, arg2) || value_equal (arg1, arg2); - return value_from_longest (LA_BOOL_TYPE, (LONGEST) tem); + type = language_bool_type (exp->language_defn, exp->gdbarch); + return value_from_longest (type, (LONGEST) tem); } case BINOP_REPEAT: @@ -1975,8 +1985,10 @@ evaluate_subexp_standard (struct type *expect_type, if (unop_user_defined_p (op, arg1)) return value_x_unop (arg1, op, noside); else - return value_from_longest (LA_BOOL_TYPE, - (LONGEST) value_logical_not (arg1)); + { + type = language_bool_type (exp->language_defn, exp->gdbarch); + return value_from_longest (type, (LONGEST) value_logical_not (arg1)); + } case UNOP_IND: if (expect_type && TYPE_CODE (expect_type) == TYPE_CODE_PTR) diff --git a/gdb/f-lang.c b/gdb/f-lang.c index 5dcbd33..8ae7775 100644 --- a/gdb/f-lang.c +++ b/gdb/f-lang.c @@ -298,6 +298,9 @@ f_language_arch_info (struct gdbarch *gdbarch, = builtin->builtin_complex_s16; lai->primitive_type_vector [f_primitive_type_void] = builtin->builtin_void; + + lai->bool_type_symbol = "logical"; + lai->bool_type_default = builtin->builtin_logical_s2; } /* This is declared in c-lang.h but it is silly to import that file for what diff --git a/gdb/jv-lang.c b/gdb/jv-lang.c index 3428292..e74b72d 100644 --- a/gdb/jv-lang.c +++ b/gdb/jv-lang.c @@ -1080,6 +1080,9 @@ java_language_arch_info (struct gdbarch *gdbarch, = java_double_type; lai->primitive_type_vector [java_primitive_type_void] = java_void_type; + + lai->bool_type_symbol = "boolean"; + lai->bool_type_default = java_boolean_type; } const struct exp_descriptor exp_descriptor_java = diff --git a/gdb/language.c b/gdb/language.c index 66e5542..7b0b44a 100644 --- a/gdb/language.c +++ b/gdb/language.c @@ -787,51 +787,6 @@ structured_type (struct type *type) } #endif -struct type * -lang_bool_type (void) -{ - struct symbol *sym; - struct type *type; - switch (current_language->la_language) - { - case language_fortran: - sym = lookup_symbol ("logical", NULL, VAR_DOMAIN, NULL); - if (sym) - { - type = SYMBOL_TYPE (sym); - if (type && TYPE_CODE (type) == TYPE_CODE_BOOL) - return type; - } - return builtin_type_f_logical_s2; - case language_cplus: - case language_pascal: - case language_ada: - if (current_language->la_language==language_cplus) - {sym = lookup_symbol ("bool", NULL, VAR_DOMAIN, NULL);} - else - {sym = lookup_symbol ("boolean", NULL, VAR_DOMAIN, NULL);} - if (sym) - { - type = SYMBOL_TYPE (sym); - if (type && TYPE_CODE (type) == TYPE_CODE_BOOL) - return type; - } - return builtin_type_bool; - case language_java: - sym = lookup_symbol ("boolean", NULL, VAR_DOMAIN, NULL); - if (sym) - { - type = SYMBOL_TYPE (sym); - if (type && TYPE_CODE (type) == TYPE_CODE_BOOL) - return type; - } - return java_boolean_type; - - default: - return builtin_type_int; - } -} - /* This page contains functions that return info about (struct value) values used in GDB. */ @@ -1169,6 +1124,7 @@ unknown_language_arch_info (struct gdbarch *gdbarch, struct language_arch_info *lai) { lai->string_char_type = builtin_type (gdbarch)->builtin_char; + lai->bool_type_default = builtin_type (gdbarch)->builtin_int; lai->primitive_type_vector = GDBARCH_OBSTACK_CALLOC (gdbarch, 1, struct type *); } @@ -1317,6 +1273,29 @@ language_string_char_type (const struct language_defn *la, } struct type * +language_bool_type (const struct language_defn *la, + struct gdbarch *gdbarch) +{ + struct language_gdbarch *ld = gdbarch_data (gdbarch, + language_gdbarch_data); + + if (ld->arch_info[la->la_language].bool_type_symbol) + { + struct symbol *sym; + sym = lookup_symbol (ld->arch_info[la->la_language].bool_type_symbol, + NULL, VAR_DOMAIN, NULL); + if (sym) + { + struct type *type = SYMBOL_TYPE (sym); + if (type && TYPE_CODE (type) == TYPE_CODE_BOOL) + return type; + } + } + + return ld->arch_info[la->la_language].bool_type_default; +} + +struct type * language_lookup_primitive_type_by_name (const struct language_defn *la, struct gdbarch *gdbarch, const char *name) diff --git a/gdb/language.h b/gdb/language.h index 8bdc212..04d4da2 100644 --- a/gdb/language.h +++ b/gdb/language.h @@ -125,6 +125,11 @@ struct language_arch_info struct type **primitive_type_vector; /* Type of elements of strings. */ struct type *string_char_type; + + /* Symbol name of type to use as boolean type, if defined. */ + const char *bool_type_symbol; + /* Otherwise, this is the default boolean builtin type. */ + struct type *bool_type_default; }; /* Structure tying together assorted information about a language. */ @@ -306,6 +311,9 @@ extern enum language_mode } language_mode; +struct type *language_bool_type (const struct language_defn *l, + struct gdbarch *gdbarch); + struct type *language_string_char_type (const struct language_defn *l, struct gdbarch *gdbarch); @@ -416,11 +424,6 @@ extern void range_error (const char *, ...) ATTR_FORMAT (printf, 1, 2); extern int value_true (struct value *); -extern struct type *lang_bool_type (void); - -/* The type used for Boolean values in the current language. */ -#define LA_BOOL_TYPE lang_bool_type () - /* Misc: The string representing a particular enum language. */ extern enum language language_enum (char *str); diff --git a/gdb/m2-lang.c b/gdb/m2-lang.c index bb205ad..793ae03 100644 --- a/gdb/m2-lang.c +++ b/gdb/m2-lang.c @@ -345,6 +345,9 @@ m2_language_arch_info (struct gdbarch *gdbarch, = builtin->builtin_real; lai->primitive_type_vector [m2_primitive_type_bool] = builtin->builtin_bool; + + lai->bool_type_symbol = "BOOLEAN"; + lai->bool_type_default = builtin->builtin_bool; } const struct exp_descriptor exp_descriptor_modula2 = diff --git a/gdb/p-lang.c b/gdb/p-lang.c index 2accf35..b763e04 100644 --- a/gdb/p-lang.c +++ b/gdb/p-lang.c @@ -393,6 +393,9 @@ pascal_language_arch_info (struct gdbarch *gdbarch, = builtin->builtin_complex; lai->primitive_type_vector [pascal_primitive_type_double_complex] = builtin->builtin_double_complex; + + lai->bool_type_symbol = "boolean"; + lai->bool_type_default = builtin->builtin_bool; } const struct language_defn pascal_language_defn = diff --git a/gdb/valarith.c b/gdb/valarith.c index 909c1a0..c13c393 100644 --- a/gdb/valarith.c +++ b/gdb/valarith.c @@ -1851,7 +1851,7 @@ value_bit_index (struct type *type, const gdb_byte *valaddr, int index) return (word >> rel_index) & 1; } -struct value * +int value_in (struct value *element, struct value *set) { int member; @@ -1870,7 +1870,7 @@ value_in (struct value *element, struct value *set) value_as_long (element)); if (member < 0) error (_("First argument of 'IN' not in range")); - return value_from_longest (LA_BOOL_TYPE, member); + return member; } void diff --git a/gdb/value.h b/gdb/value.h index 77de981..d0545e2 100644 --- a/gdb/value.h +++ b/gdb/value.h @@ -412,7 +412,7 @@ extern struct value *value_bitstring_subscript (struct type *type, extern struct value *register_value_being_returned (struct type *valtype, struct regcache *retbuf); -extern struct value *value_in (struct value *element, struct value *set); +extern int value_in (struct value *element, struct value *set); extern int value_bit_index (struct type *type, const gdb_byte *addr, int index); |