diff options
author | Ulrich Weigand <uweigand@de.ibm.com> | 2007-06-16 20:10:51 +0000 |
---|---|---|
committer | Ulrich Weigand <uweigand@de.ibm.com> | 2007-06-16 20:10:51 +0000 |
commit | 5760b90a9095ebf24c15e2e8c427683f3a36dd0d (patch) | |
tree | d2241d220808b3bc7607d6e09ea2587618db97c2 /gdb | |
parent | 54ef06c7261244bfa0f99988fdb0942f72da728f (diff) | |
download | gdb-5760b90a9095ebf24c15e2e8c427683f3a36dd0d.zip gdb-5760b90a9095ebf24c15e2e8c427683f3a36dd0d.tar.gz gdb-5760b90a9095ebf24c15e2e8c427683f3a36dd0d.tar.bz2 |
* gdbtypes.h (builtin_type_m2_char, builtin_type_m2_int,
builtin_type_m2_card, builtin_type_m2_real, builtin_type_m2_bool):
Replace global variable declaration with compatibility macro.
(struct builtin_m2_type): New data type.
(builtin_m2_type): Add prototype.
* m2-lang.c (builtin_type_m2_char, builtin_type_m2_int,
builtin_type_m2_card, builtin_type_m2_real, builtin_type_m2_bool):
Remove global variables.
(m2_language_arch_info): Use builtin_m2_type instead of variables.
(build_m2_types): New function.
(m2_type_data): New variable.
(builtin_m2_type): New function.
(_initialize_m2_language): Do not build data types. Register
m2_type_data per-gdbarch data.
Diffstat (limited to 'gdb')
-rw-r--r-- | gdb/ChangeLog | 17 | ||||
-rw-r--r-- | gdb/gdbtypes.h | 29 | ||||
-rw-r--r-- | gdb/m2-lang.c | 58 |
3 files changed, 78 insertions, 26 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 95a98a9..00c3141 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,5 +1,22 @@ 2007-06-16 Ulrich Weigand <uweigand@de.ibm.com> + * gdbtypes.h (builtin_type_m2_char, builtin_type_m2_int, + builtin_type_m2_card, builtin_type_m2_real, builtin_type_m2_bool): + Replace global variable declaration with compatibility macro. + (struct builtin_m2_type): New data type. + (builtin_m2_type): Add prototype. + * m2-lang.c (builtin_type_m2_char, builtin_type_m2_int, + builtin_type_m2_card, builtin_type_m2_real, builtin_type_m2_bool): + Remove global variables. + (m2_language_arch_info): Use builtin_m2_type instead of variables. + (build_m2_types): New function. + (m2_type_data): New variable. + (builtin_m2_type): New function. + (_initialize_m2_language): Do not build data types. Register + m2_type_data per-gdbarch data. + +2007-06-16 Ulrich Weigand <uweigand@de.ibm.com> + * gdbtypes.h (builtin_type_f_character, builtin_type_f_logical, builtin_type_f_logical_s1, builtin_type_f_logical_s2, builtin_type_f_integer, builtin_type_f_integer_s2, builtin_type_f_real, diff --git a/gdb/gdbtypes.h b/gdb/gdbtypes.h index 9dd05a5..220400c 100644 --- a/gdb/gdbtypes.h +++ b/gdb/gdbtypes.h @@ -1120,11 +1120,30 @@ extern struct type *builtin_type_unsigned_long_long; /* Modula-2 types */ -extern struct type *builtin_type_m2_char; -extern struct type *builtin_type_m2_int; -extern struct type *builtin_type_m2_card; -extern struct type *builtin_type_m2_real; -extern struct type *builtin_type_m2_bool; +struct builtin_m2_type +{ + struct type *builtin_char; + struct type *builtin_int; + struct type *builtin_card; + struct type *builtin_real; + struct type *builtin_bool; +}; + +/* Return the Modula-2 type table for the specified architecture. */ +extern const struct builtin_m2_type *builtin_m2_type (struct gdbarch *gdbarch); + +/* Compatibility macros to access types for the current architecture. */ +#define builtin_type_m2_char \ + (builtin_m2_type (current_gdbarch)->builtin_char) +#define builtin_type_m2_int \ + (builtin_m2_type (current_gdbarch)->builtin_int) +#define builtin_type_m2_card \ + (builtin_m2_type (current_gdbarch)->builtin_card) +#define builtin_type_m2_real \ + (builtin_m2_type (current_gdbarch)->builtin_real) +#define builtin_type_m2_bool \ + (builtin_m2_type (current_gdbarch)->builtin_bool) + /* Fortran (F77) types */ diff --git a/gdb/m2-lang.c b/gdb/m2-lang.c index 668106d..acb2de6 100644 --- a/gdb/m2-lang.c +++ b/gdb/m2-lang.c @@ -396,12 +396,6 @@ static const struct op_print m2_op_print_tab[] = /* The built-in types of Modula-2. */ -struct type *builtin_type_m2_char; -struct type *builtin_type_m2_int; -struct type *builtin_type_m2_card; -struct type *builtin_type_m2_real; -struct type *builtin_type_m2_bool; - enum m2_primitive_types { m2_primitive_type_char, m2_primitive_type_int, @@ -415,21 +409,23 @@ static void m2_language_arch_info (struct gdbarch *gdbarch, struct language_arch_info *lai) { - lai->string_char_type = builtin_type_m2_char; + const struct builtin_m2_type *builtin = builtin_m2_type (gdbarch); + + lai->string_char_type = builtin->builtin_char; lai->primitive_type_vector = GDBARCH_OBSTACK_CALLOC (gdbarch, nr_m2_primitive_types + 1, struct type *); lai->primitive_type_vector [m2_primitive_type_char] - = builtin_type_m2_char; + = builtin->builtin_char; lai->primitive_type_vector [m2_primitive_type_int] - = builtin_type_m2_int; + = builtin->builtin_int; lai->primitive_type_vector [m2_primitive_type_card] - = builtin_type_m2_card; + = builtin->builtin_card; lai->primitive_type_vector [m2_primitive_type_real] - = builtin_type_m2_real; + = builtin->builtin_real; lai->primitive_type_vector [m2_primitive_type_bool] - = builtin_type_m2_bool; + = builtin->builtin_bool; } const struct language_defn m2_language_defn = @@ -468,35 +464,55 @@ const struct language_defn m2_language_defn = LANG_MAGIC }; -/* Initialization for Modula-2 */ - -void -_initialize_m2_language (void) +static void * +build_m2_types (struct gdbarch *gdbarch) { + struct builtin_m2_type *builtin_m2_type + = GDBARCH_OBSTACK_ZALLOC (gdbarch, struct builtin_m2_type); + /* Modula-2 "pervasive" types. NOTE: these can be redefined!!! */ - builtin_type_m2_int = + builtin_m2_type->builtin_int = init_type (TYPE_CODE_INT, gdbarch_int_bit (current_gdbarch) / TARGET_CHAR_BIT, 0, "INTEGER", (struct objfile *) NULL); - builtin_type_m2_card = + builtin_m2_type->builtin_card = init_type (TYPE_CODE_INT, gdbarch_int_bit (current_gdbarch) / TARGET_CHAR_BIT, TYPE_FLAG_UNSIGNED, "CARDINAL", (struct objfile *) NULL); - builtin_type_m2_real = + builtin_m2_type->builtin_real = init_type (TYPE_CODE_FLT, gdbarch_float_bit (current_gdbarch) / TARGET_CHAR_BIT, 0, "REAL", (struct objfile *) NULL); - builtin_type_m2_char = + builtin_m2_type->builtin_char = init_type (TYPE_CODE_CHAR, TARGET_CHAR_BIT / TARGET_CHAR_BIT, TYPE_FLAG_UNSIGNED, "CHAR", (struct objfile *) NULL); - builtin_type_m2_bool = + builtin_m2_type->builtin_bool = init_type (TYPE_CODE_BOOL, gdbarch_int_bit (current_gdbarch) / TARGET_CHAR_BIT, TYPE_FLAG_UNSIGNED, "BOOLEAN", (struct objfile *) NULL); + return builtin_m2_type; +} + +static struct gdbarch_data *m2_type_data; + +const struct builtin_m2_type * +builtin_m2_type (struct gdbarch *gdbarch) +{ + return gdbarch_data (gdbarch, m2_type_data); +} + + +/* Initialization for Modula-2 */ + +void +_initialize_m2_language (void) +{ + m2_type_data = gdbarch_data_register_post_init (build_m2_types); + add_language (&m2_language_defn); } |