* gdbtypes.h (builtin_type_m2_char, builtin_type_m2_int,
authorUlrich Weigand <uweigand@de.ibm.com>
Sat, 16 Jun 2007 20:10:51 +0000 (20:10 +0000)
committerUlrich Weigand <uweigand@de.ibm.com>
Sat, 16 Jun 2007 20:10:51 +0000 (20:10 +0000)
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.

gdb/ChangeLog
gdb/gdbtypes.h
gdb/m2-lang.c

index 95a98a9e5bd3f0ed2e48d96f81923b68742583d8..00c31410064a76f14d3f2deaa9fa106ba306364e 100644 (file)
@@ -1,3 +1,20 @@
+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,
index 9dd05a553f6c5f2630a1b0ef42ebcd79379e4db4..220400cae3c835967560d018e71e9f0ce49152eb 100644 (file)
@@ -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 */
 
index 668106d75c4efc04b324e62f4304b73578378183..acb2de6d6c12e206b16d685992763135e0f02387 100644 (file)
@@ -396,12 +396,6 @@ static const struct op_print m2_op_print_tab[] =
 \f
 /* 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);
 }