diff options
author | Paul N. Hilfinger <hilfinger@adacore.com> | 2004-09-18 22:23:23 +0000 |
---|---|---|
committer | Paul N. Hilfinger <hilfinger@adacore.com> | 2004-09-18 22:23:23 +0000 |
commit | 72d5681a84985b3eef4cb6bf613026c151f4a5b4 (patch) | |
tree | 8352c394eec54f9b0f03318980b1973bc1c15656 | |
parent | 30b0e2d89f2dd2a37c2d459fa8007306e67c8e2e (diff) | |
download | gdb-72d5681a84985b3eef4cb6bf613026c151f4a5b4.zip gdb-72d5681a84985b3eef4cb6bf613026c151f4a5b4.tar.gz gdb-72d5681a84985b3eef4cb6bf613026c151f4a5b4.tar.bz2 |
* ada-exp.y (type_int): New function to add layer of abstraction
around references to expression types.
(type_long): Ditto.
(type_long_long): Ditto.
(type_float): Ditto.
(type_double): Ditto.
(type_long_double): Ditto.
(type_char): Ditto.
(type_system_address): Ditto.
(simple_exp): Use type_* functions in place of builtin_*
variables.
(exp): Ditto.
(write_var_from_name): Ditto.
(write_object_renaming): Ditto.
* ada-lang.c (ada_create_fundamental_type): Remove redundant
declaration.
(build_ada_types): Remove, replacing with...
(ada_language_arch_info): New function to initialize primitive
type vector in language_arch_info.
(ada_array_length): Remove use of builtin_type_ada_int.
(value_pos_atr): Ditto.
(ada_evaluate_subexp): Ditto.
(builtin_type_ada_int, builtin_type_ada_short, builtin_type_ada_long,
builtin_type_ada_long_long, builtin_type_ada_char,
builtin_type_ada_float, builtin_type_ada_double,
builtin_type_ada_long_double, builtin_type_ada_natural,
builtin_type_ada_positive, builtin_type_ada_system_address): Remove.
(ada_builtin_types): Remove.
(ada_language_defn): Remove entries for la_builtin_type_vector and
string_char_type and use ada_language_arch_info.
(_initialize_ada_language): Do type-vector initialization along
the lines of c-lang.c.
(ada_create_fundamental_type): Break up line.
(ada_dump_symtab): Remove unused function.
(enum ada_primitive_types): Define.
* ada-lang.h (builtin_type_ada_int, builtin_type_ada_short,
builtin_type_ada_long,builtin_type_ada_long_long,builtin_type_ada_char,
builtin_type_ada_float, builtin_type_ada_double,
builtin_type_ada_long_double, builtin_type_ada_natural,
builtin_type_ada_positive, builtin_type_ada_system_address): Remove.
* ada-lex.l: Use type_* functions in place of builtin_* variables.
(processInt): Ditto.
(processReal): Ditto.
(name_lookup): Ditto.
* ada-typeprint.c (print_range): Use builtin_type_int, not
builtin_type_ada_int.
-rw-r--r-- | gdb/ChangeLog | 51 | ||||
-rw-r--r-- | gdb/ada-exp.y | 90 | ||||
-rw-r--r-- | gdb/ada-lang.c | 122 | ||||
-rw-r--r-- | gdb/ada-lang.h | 12 | ||||
-rw-r--r-- | gdb/ada-lex.l | 18 | ||||
-rw-r--r-- | gdb/ada-typeprint.c | 2 |
6 files changed, 192 insertions, 103 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 743c088..e9081a0 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,52 @@ +2004-09-18 Paul N. Hilfinger <hilfinger@gnat.com> + + * ada-exp.y (type_int): New function to add layer of abstraction + around references to expression types. + (type_long): Ditto. + (type_long_long): Ditto. + (type_float): Ditto. + (type_double): Ditto. + (type_long_double): Ditto. + (type_char): Ditto. + (type_system_address): Ditto. + (simple_exp): Use type_* functions in place of builtin_* + variables. + (exp): Ditto. + (write_var_from_name): Ditto. + (write_object_renaming): Ditto. + * ada-lang.c (ada_create_fundamental_type): Remove redundant + declaration. + (build_ada_types): Remove, replacing with... + (ada_language_arch_info): New function to initialize primitive + type vector in language_arch_info. + (ada_array_length): Remove use of builtin_type_ada_int. + (value_pos_atr): Ditto. + (ada_evaluate_subexp): Ditto. + (builtin_type_ada_int, builtin_type_ada_short, builtin_type_ada_long, + builtin_type_ada_long_long, builtin_type_ada_char, + builtin_type_ada_float, builtin_type_ada_double, + builtin_type_ada_long_double, builtin_type_ada_natural, + builtin_type_ada_positive, builtin_type_ada_system_address): Remove. + (ada_builtin_types): Remove. + (ada_language_defn): Remove entries for la_builtin_type_vector and + string_char_type and use ada_language_arch_info. + (_initialize_ada_language): Do type-vector initialization along + the lines of c-lang.c. + (ada_create_fundamental_type): Break up line. + (ada_dump_symtab): Remove unused function. + (enum ada_primitive_types): Define. + * ada-lang.h (builtin_type_ada_int, builtin_type_ada_short, + builtin_type_ada_long,builtin_type_ada_long_long,builtin_type_ada_char, + builtin_type_ada_float, builtin_type_ada_double, + builtin_type_ada_long_double, builtin_type_ada_natural, + builtin_type_ada_positive, builtin_type_ada_system_address): Remove. + * ada-lex.l: Use type_* functions in place of builtin_* variables. + (processInt): Ditto. + (processReal): Ditto. + (name_lookup): Ditto. + * ada-typeprint.c (print_range): Use builtin_type_int, not + builtin_type_ada_int. + 2004-09-18 Mark Kettenis <kettenis@gnu.org> * i386-tdep.c (i386_register_name): Rename regno to regnum. @@ -10,7 +59,7 @@ standard curses on HP-UX. * configure: Regenerated. -2004-09-18 Paul N. Hilfinger <hilfingr@otisco.mckusick.com> +2004-09-18 Paul N. Hilfinger <hilfinger@gnat.com> * ada-lang.c: (ada_main_name, ada_value_slice_ptr, ada_value_slice, ada_breakpoint_rewrite, ada_template_to_fixed_record_type_1): diff --git a/gdb/ada-exp.y b/gdb/ada-exp.y index 9e91817..73bd120 100644 --- a/gdb/ada-exp.y +++ b/gdb/ada-exp.y @@ -126,6 +126,22 @@ static void write_object_renaming (struct block *, struct symbol *, int); static void write_var_from_name (struct block *, struct name_info); static LONGEST convert_char_literal (struct type *, LONGEST); + +static struct type *type_int (void); + +static struct type *type_long (void); + +static struct type *type_long_long (void); + +static struct type *type_float (void); + +static struct type *type_double (void); + +static struct type *type_long_double (void); + +static struct type *type_char (void); + +static struct type *type_system_address (void); %} %union @@ -426,17 +442,17 @@ simple_exp : simple_exp TICK_ACCESS | simple_exp TICK_ADDRESS { write_exp_elt_opcode (UNOP_ADDR); write_exp_elt_opcode (UNOP_CAST); - write_exp_elt_type (builtin_type_ada_system_address); + write_exp_elt_type (type_system_address ()); write_exp_elt_opcode (UNOP_CAST); } | simple_exp TICK_FIRST tick_arglist - { write_int ($3, builtin_type_int); + { write_int ($3, type_int ()); write_exp_elt_opcode (OP_ATR_FIRST); } | simple_exp TICK_LAST tick_arglist - { write_int ($3, builtin_type_int); + { write_int ($3, type_int ()); write_exp_elt_opcode (OP_ATR_LAST); } | simple_exp TICK_LENGTH tick_arglist - { write_int ($3, builtin_type_int); + { write_int ($3, type_int ()); write_exp_elt_opcode (OP_ATR_LENGTH); } | simple_exp TICK_SIZE { write_exp_elt_opcode (OP_ATR_SIZE); } @@ -449,13 +465,13 @@ simple_exp : simple_exp TICK_ACCESS | opt_type_prefix TICK_POS '(' exp ')' { write_exp_elt_opcode (OP_ATR_POS); } | type_prefix TICK_FIRST tick_arglist - { write_int ($3, builtin_type_int); + { write_int ($3, type_int ()); write_exp_elt_opcode (OP_ATR_FIRST); } | type_prefix TICK_LAST tick_arglist - { write_int ($3, builtin_type_int); + { write_int ($3, type_int ()); write_exp_elt_opcode (OP_ATR_LAST); } | type_prefix TICK_LENGTH tick_arglist - { write_int ($3, builtin_type_int); + { write_int ($3, type_int ()); write_exp_elt_opcode (OP_ATR_LENGTH); } | type_prefix TICK_VAL '(' exp ')' { write_exp_elt_opcode (OP_ATR_VAL); } @@ -505,7 +521,7 @@ exp : FLOAT ; exp : NULL_PTR - { write_int (0, builtin_type_int); } + { write_int (0, type_int ()); } ; exp : STRING @@ -666,8 +682,8 @@ write_var_from_name (struct block *orig_left_context, if (name.msym != NULL) { write_exp_msymbol (name.msym, - lookup_function_type (builtin_type_int), - builtin_type_int); + lookup_function_type (type_int ()), + type_int ()); } else if (name.sym == NULL) { @@ -779,7 +795,7 @@ write_object_renaming (struct block *orig_left_context, goto BadEncoding; suffix = next; write_exp_elt_opcode (OP_LONG); - write_exp_elt_type (builtin_type_ada_int); + write_exp_elt_type (type_int ()); write_exp_elt_longcst ((LONGEST) val); write_exp_elt_opcode (OP_LONG); } @@ -879,6 +895,58 @@ convert_char_literal (struct type *type, LONGEST val) return val; } +static struct type * +type_int (void) +{ + return builtin_type (current_gdbarch)->builtin_int; +} + +static struct type * +type_long (void) +{ + return builtin_type (current_gdbarch)->builtin_long; +} + +static struct type * +type_long_long (void) +{ + return builtin_type (current_gdbarch)->builtin_long_long; +} + +static struct type * +type_float (void) +{ + return builtin_type (current_gdbarch)->builtin_float; +} + +static struct type * +type_double (void) +{ + return builtin_type (current_gdbarch)->builtin_double; +} + +static struct type * +type_long_double (void) +{ + return builtin_type (current_gdbarch)->builtin_long_double; +} + +static struct type * +type_char (void) +{ + return language_string_char_type (current_language, current_gdbarch); +} + +static struct type * +type_system_address (void) +{ + struct type *type + = language_lookup_primitive_type_by_name (current_language, + current_gdbarch, + "system__address"); + return type != NULL ? type : lookup_pointer_type (builtin_type_void); +} + void _initialize_ada_exp (void) { diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c index 9eee22c..0babcca 100644 --- a/gdb/ada-lang.c +++ b/gdb/ada-lang.c @@ -192,8 +192,6 @@ static struct value *evaluate_subexp (struct type *, struct expression *, static struct value *evaluate_subexp_type (struct expression *, int *); -static struct type *ada_create_fundamental_type (struct objfile *, int); - static int is_dynamic_field (struct type *, int); static struct type *to_fixed_variant_branch_type (struct type *, char *, @@ -281,6 +279,11 @@ static int ada_is_direct_array_type (struct type *); static void error_breakpoint_runtime_sym_not_found (const char *err_desc); static int is_runtime_sym_defined (const char *name, int allow_tramp); + +static void ada_language_arch_info (struct gdbarch *, + struct language_arch_info *); + +static void check_size (const struct type *); @@ -2440,7 +2443,7 @@ ada_array_length (struct value *arr, int n) } else return - value_from_longest (builtin_type_ada_int, + value_from_longest (builtin_type_int, value_as_long (desc_one_bound (desc_bounds (arr), n, 1)) - value_as_long (desc_one_bound (desc_bounds (arr), @@ -8343,7 +8346,7 @@ pos_atr (struct value *arg) static struct value * value_pos_atr (struct value *arg) { - return value_from_longest (builtin_type_ada_int, pos_atr (arg)); + return value_from_longest (builtin_type_int, pos_atr (arg)); } /* Evaluate the TYPE'VAL attribute applied to ARG. */ @@ -9320,7 +9323,7 @@ ada_evaluate_subexp (struct type *expect_type, struct expression *exp, if (noside == EVAL_SKIP) goto nosideret; else if (noside == EVAL_AVOID_SIDE_EFFECTS) - return value_zero (builtin_type_ada_int, not_lval); + return value_zero (builtin_type_int, not_lval); else return value_pos_atr (arg1); @@ -9329,9 +9332,9 @@ ada_evaluate_subexp (struct type *expect_type, struct expression *exp, if (noside == EVAL_SKIP) goto nosideret; else if (noside == EVAL_AVOID_SIDE_EFFECTS) - return value_zero (builtin_type_ada_int, not_lval); + return value_zero (builtin_type_int, not_lval); else - return value_from_longest (builtin_type_ada_int, + return value_from_longest (builtin_type_int, TARGET_CHAR_BIT * TYPE_LENGTH (VALUE_TYPE (arg1))); @@ -10167,7 +10170,9 @@ ada_create_fundamental_type (struct objfile *objfile, int typeid) 0, "integer", objfile); break; case FT_SIGNED_INTEGER: - type = init_type (TYPE_CODE_INT, TARGET_INT_BIT / TARGET_CHAR_BIT, 0, "integer", objfile); /* FIXME -fnf */ + type = init_type (TYPE_CODE_INT, TARGET_INT_BIT / + TARGET_CHAR_BIT, + 0, "integer", objfile); /* FIXME -fnf */ break; case FT_UNSIGNED_INTEGER: type = init_type (TYPE_CODE_INT, @@ -10223,88 +10228,69 @@ ada_create_fundamental_type (struct objfile *objfile, int typeid) return (type); } -struct type *builtin_type_ada_int; -struct type *builtin_type_ada_short; -struct type *builtin_type_ada_long; -struct type *builtin_type_ada_long_long; -struct type *builtin_type_ada_char; -struct type *builtin_type_ada_float; -struct type *builtin_type_ada_double; -struct type *builtin_type_ada_long_double; -struct type *builtin_type_ada_natural; -struct type *builtin_type_ada_positive; -struct type *builtin_type_ada_system_address; - -struct type **const (ada_builtin_types[]) = -{ - &builtin_type_ada_int, - &builtin_type_ada_long, - &builtin_type_ada_short, - &builtin_type_ada_char, - &builtin_type_ada_float, - &builtin_type_ada_double, - &builtin_type_ada_long_long, - &builtin_type_ada_long_double, - &builtin_type_ada_natural, &builtin_type_ada_positive, - /* The following types are carried over from C for convenience. */ -&builtin_type_int, - &builtin_type_long, - &builtin_type_short, - &builtin_type_char, - &builtin_type_float, - &builtin_type_double, - &builtin_type_long_long, - &builtin_type_void, - &builtin_type_signed_char, - &builtin_type_unsigned_char, - &builtin_type_unsigned_short, - &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}; +enum ada_primitive_types { + ada_primitive_type_int, + ada_primitive_type_long, + ada_primitive_type_short, + ada_primitive_type_char, + ada_primitive_type_float, + ada_primitive_type_double, + ada_primitive_type_void, + ada_primitive_type_long_long, + ada_primitive_type_long_double, + ada_primitive_type_natural, + ada_primitive_type_positive, + ada_primitive_type_system_address, + nr_ada_primitive_types +}; static void -build_ada_types (struct gdbarch *current_gdbarch) -{ - builtin_type_ada_int = +ada_language_arch_info (struct gdbarch *current_gdbarch, + struct language_arch_info *lai) +{ + const struct builtin_type *builtin = builtin_type (current_gdbarch); + lai->primitive_type_vector + = GDBARCH_OBSTACK_CALLOC (current_gdbarch, nr_ada_primitive_types + 1, + struct type *); + lai->primitive_type_vector [ada_primitive_type_int] = init_type (TYPE_CODE_INT, TARGET_INT_BIT / TARGET_CHAR_BIT, 0, "integer", (struct objfile *) NULL); - builtin_type_ada_long = + lai->primitive_type_vector [ada_primitive_type_long] = init_type (TYPE_CODE_INT, TARGET_LONG_BIT / TARGET_CHAR_BIT, 0, "long_integer", (struct objfile *) NULL); - builtin_type_ada_short = + lai->primitive_type_vector [ada_primitive_type_short] = init_type (TYPE_CODE_INT, TARGET_SHORT_BIT / TARGET_CHAR_BIT, 0, "short_integer", (struct objfile *) NULL); - builtin_type_ada_char = + lai->primitive_type_vector [ada_primitive_type_char] = init_type (TYPE_CODE_INT, TARGET_CHAR_BIT / TARGET_CHAR_BIT, 0, "character", (struct objfile *) NULL); - builtin_type_ada_float = + lai->string_char_type = builtin->builtin_char; + lai->primitive_type_vector [ada_primitive_type_float] = init_type (TYPE_CODE_FLT, TARGET_FLOAT_BIT / TARGET_CHAR_BIT, 0, "float", (struct objfile *) NULL); - builtin_type_ada_double = + lai->primitive_type_vector [ada_primitive_type_double] = init_type (TYPE_CODE_FLT, TARGET_DOUBLE_BIT / TARGET_CHAR_BIT, 0, "long_float", (struct objfile *) NULL); - builtin_type_ada_long_long = + lai->primitive_type_vector [ada_primitive_type_long_long] = init_type (TYPE_CODE_INT, TARGET_LONG_LONG_BIT / TARGET_CHAR_BIT, 0, "long_long_integer", (struct objfile *) NULL); - builtin_type_ada_long_double = + lai->primitive_type_vector [ada_primitive_type_long_double] = init_type (TYPE_CODE_FLT, TARGET_LONG_DOUBLE_BIT / TARGET_CHAR_BIT, 0, "long_long_float", (struct objfile *) NULL); - builtin_type_ada_natural = + lai->primitive_type_vector [ada_primitive_type_natural] = init_type (TYPE_CODE_INT, TARGET_INT_BIT / TARGET_CHAR_BIT, 0, "natural", (struct objfile *) NULL); - builtin_type_ada_positive = + lai->primitive_type_vector [ada_primitive_type_positive] = init_type (TYPE_CODE_INT, TARGET_INT_BIT / TARGET_CHAR_BIT, 0, "positive", (struct objfile *) NULL); + lai->primitive_type_vector [ada_primitive_type_void] = builtin->builtin_void; - - builtin_type_ada_system_address = + lai->primitive_type_vector [ada_primitive_type_system_address] = lookup_pointer_type (init_type (TYPE_CODE_VOID, 1, 0, "void", (struct objfile *) NULL)); - TYPE_NAME (builtin_type_ada_system_address) = "system__address"; + TYPE_NAME (lai->primitive_type_vector [ada_primitive_type_system_address]) + = "system__address"; } - /* Language vector */ @@ -10334,7 +10320,7 @@ static const struct exp_descriptor ada_exp_descriptor = { const struct language_defn ada_language_defn = { "ada", /* Language name */ language_ada, - ada_builtin_types, + NULL, range_check_off, type_check_off, case_sensitive_on, /* Yes, Ada is case-insensitive, but @@ -10364,8 +10350,9 @@ const struct language_defn ada_language_defn = { ada_op_print_tab, /* expression operators for printing */ 0, /* c-style arrays */ 1, /* String lower bound */ - &builtin_type_ada_char, + NULL, ada_get_gdb_completer_word_break_characters, + ada_language_arch_info, #ifdef GNAT_GDB ada_translate_error_message, /* Substitute Ada-specific terminology in errors and warnings. */ @@ -10376,9 +10363,6 @@ const struct language_defn ada_language_defn = { void _initialize_ada_language (void) { - - build_ada_types (current_gdbarch); - gdbarch_data_register_post_init (build_ada_types); add_language (&ada_language_defn); varsize_limit = 65536; diff --git a/gdb/ada-lang.h b/gdb/ada-lang.h index 12eaf4b..931fd8e 100644 --- a/gdb/ada-lang.h +++ b/gdb/ada-lang.h @@ -160,18 +160,6 @@ struct task_entry int stack_per; }; -extern struct type *builtin_type_ada_int; -extern struct type *builtin_type_ada_short; -extern struct type *builtin_type_ada_long; -extern struct type *builtin_type_ada_long_long; -extern struct type *builtin_type_ada_char; -extern struct type *builtin_type_ada_float; -extern struct type *builtin_type_ada_double; -extern struct type *builtin_type_ada_long_double; -extern struct type *builtin_type_ada_natural; -extern struct type *builtin_type_ada_positive; -extern struct type *builtin_type_ada_system_address; - /* The maximum number of tasks known to the Ada runtime. */ extern const int MAX_NUMBER_OF_KNOWN_TASKS; diff --git a/gdb/ada-lex.l b/gdb/ada-lex.l index 21dba2c..6ecd849 100644 --- a/gdb/ada-lex.l +++ b/gdb/ada-lex.l @@ -144,14 +144,14 @@ static int find_dot_all (const char *); } <INITIAL>"'"({GRAPHIC}|\")"'" { - yylval.typed_val.type = builtin_type_ada_char; + yylval.typed_val.type = type_char (); yylval.typed_val.val = yytext[1]; return CHARLIT; } <INITIAL>"'[\""{HEXDIG}{2}"\"]'" { int v; - yylval.typed_val.type = builtin_type_ada_char; + yylval.typed_val.type = type_char (); sscanf (yytext+3, "%2x", &v); yylval.typed_val.val = v; return CHARLIT; @@ -478,9 +478,9 @@ processInt (const char *base0, const char *num0, const char *exp0) } if ((result >> (TARGET_INT_BIT-1)) == 0) - yylval.typed_val.type = builtin_type_ada_int; + yylval.typed_val.type = type_int (); else if ((result >> (TARGET_LONG_BIT-1)) == 0) - yylval.typed_val.type = builtin_type_ada_long; + yylval.typed_val.type = type_long (); else if (((result >> (TARGET_LONG_BIT-1)) >> 1) == 0) { /* We have a number representable as an unsigned integer quantity. @@ -500,7 +500,7 @@ processInt (const char *base0, const char *num0, const char *exp0) return INT; } else - yylval.typed_val.type = builtin_type_ada_long_long; + yylval.typed_val.type = type_long_long (); yylval.typed_val.val = (LONGEST) result; return INT; @@ -527,11 +527,11 @@ processReal (const char *num0) yylval.typed_val_float.dval = temp; } - yylval.typed_val_float.type = builtin_type_ada_float; + yylval.typed_val_float.type = type_float (); if (sizeof(DOUBLEST) >= TARGET_DOUBLE_BIT / TARGET_CHAR_BIT) - yylval.typed_val_float.type = builtin_type_ada_double; + yylval.typed_val_float.type = type_double (); if (sizeof(DOUBLEST) >= TARGET_LONG_DOUBLE_BIT / TARGET_CHAR_BIT) - yylval.typed_val_float.type = builtin_type_ada_long_double; + yylval.typed_val_float.type = type_long_double (); return FLOAT; } @@ -745,7 +745,7 @@ name_lookup (char *name0, char *err_name, int *token_type, int depth) current_gdbarch, name); if (type == NULL && strcmp ("system__address", name) == 0) - type = builtin_type_ada_system_address; + type = type_system_address (); if (type != NULL) { /* First check to see if we have a regular definition of this diff --git a/gdb/ada-typeprint.c b/gdb/ada-typeprint.c index fb9c690..5e3385c 100644 --- a/gdb/ada-typeprint.c +++ b/gdb/ada-typeprint.c @@ -149,7 +149,7 @@ print_range (struct type *type, struct ui_file *stream) case TYPE_CODE_ENUM: break; default: - target_type = builtin_type_ada_int; + target_type = builtin_type_int; break; } |