aboutsummaryrefslogtreecommitdiff
path: root/gdb/m2-lang.c
diff options
context:
space:
mode:
authorUlrich Weigand <uweigand@de.ibm.com>2007-06-16 20:10:51 +0000
committerUlrich Weigand <uweigand@de.ibm.com>2007-06-16 20:10:51 +0000
commit5760b90a9095ebf24c15e2e8c427683f3a36dd0d (patch)
treed2241d220808b3bc7607d6e09ea2587618db97c2 /gdb/m2-lang.c
parent54ef06c7261244bfa0f99988fdb0942f72da728f (diff)
downloadgdb-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/m2-lang.c')
-rw-r--r--gdb/m2-lang.c58
1 files changed, 37 insertions, 21 deletions
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);
}