* gdbtypes.h (builtin_type_true_char): Remove.
authorUlrich Weigand <uweigand@de.ibm.com>
Thu, 2 Jul 2009 12:44:34 +0000 (12:44 +0000)
committerUlrich Weigand <uweigand@de.ibm.com>
Thu, 2 Jul 2009 12:44:34 +0000 (12:44 +0000)
(builtin_type_true_unsigned_char): Likewise.
(struct builtin_type): Add builtin_true_char and
builtin_true_unsigned_char members.
* gdbtypes.c (builtin_type_true_char): Remove.
(builtin_type_true_unsigned_char): Likewise.
(_initialize_gdbtypes): Do not initialize them.
(gdbtypes_post_init): Initialize builtin_true_char and
builtin_true_unsigned_char members of builtin_type.

* printcmd.c (print_scalar_formatted): Use builtin_type
members instead of builtin_type_true_char and
builtin_type_true_unsigned_char.
* ada-valprint.c (ada_val_print_1): Likewise.

gdb/ChangeLog
gdb/ada-valprint.c
gdb/gdbtypes.c
gdb/gdbtypes.h
gdb/printcmd.c

index b616d5a47c351c3067716d27939e3746b55d22ed..cfa317b70ba7fc11e68622d79a025b0a1404ea8c 100644 (file)
@@ -1,3 +1,20 @@
+2009-07-02  Ulrich Weigand  <uweigand@de.ibm.com>
+
+       * gdbtypes.h (builtin_type_true_char): Remove.
+       (builtin_type_true_unsigned_char): Likewise.
+       (struct builtin_type): Add builtin_true_char and
+       builtin_true_unsigned_char members.
+       * gdbtypes.c (builtin_type_true_char): Remove.
+       (builtin_type_true_unsigned_char): Likewise.
+       (_initialize_gdbtypes): Do not initialize them.
+       (gdbtypes_post_init): Initialize builtin_true_char and
+       builtin_true_unsigned_char members of builtin_type.
+
+       * printcmd.c (print_scalar_formatted): Use builtin_type
+       members instead of builtin_type_true_char and
+       builtin_type_true_unsigned_char.
+       * ada-valprint.c (ada_val_print_1): Likewise.
+
 2009-07-02  Ulrich Weigand  <uweigand@de.ibm.com>
 
        * gdbtypes.h (builtin_type_void): Remove.
index b33199be1f28c5c83cde11a5e2070df592d30b89..2aa0d73cb7f151f029e992ea548fecea597d955a 100644 (file)
@@ -746,9 +746,10 @@ ada_val_print_1 (struct type *type, const gdb_byte *valaddr0,
          struct value *func = ada_vax_float_print_function (type);
          if (func != 0)
            {
+             struct gdbarch *gdbarch = current_gdbarch;
              CORE_ADDR addr;
              addr = value_as_address (call_function_by_hand (func, 1, &val));
-             val_print_string (builtin_type_true_char,
+             val_print_string (builtin_type (gdbarch)->builtin_true_char,
                                addr, -1, stream, options);
              return 0;
            }
index 7a44716b5f7c4f3671ea7a21f7460ad44c82707a..25d63218681ed45439d9e0f5c44b02f5e1c46536 100644 (file)
@@ -108,11 +108,6 @@ struct type *builtin_type_arm_ext;
 struct type *builtin_type_ia64_spill;
 struct type *builtin_type_ia64_quad;
 
-/* Platform-neutral character types.  */
-struct type *builtin_type_true_char;
-struct type *builtin_type_true_unsigned_char;
-
-
 int opaque_type_resolution = 1;
 static void
 show_opaque_type_resolution (struct ui_file *file, int from_tty,
@@ -3191,6 +3186,16 @@ gdbtypes_post_init (struct gdbarch *gdbarch)
               0,
               "_Decimal128", (struct objfile *) NULL);
 
+  /* "True" character types.  */
+  builtin_type->builtin_true_char =
+    init_type (TYPE_CODE_CHAR, TARGET_CHAR_BIT / TARGET_CHAR_BIT,
+              0,
+              "true character", (struct objfile *) NULL);
+  builtin_type->builtin_true_unsigned_char =
+    init_type (TYPE_CODE_CHAR, TARGET_CHAR_BIT / TARGET_CHAR_BIT,
+              TYPE_FLAG_UNSIGNED,
+              "true character", (struct objfile *) NULL);
+
   /* Default data/code pointer types.  */
   builtin_type->builtin_data_ptr =
     make_pointer_type (builtin_type->builtin_void, NULL);
@@ -3430,15 +3435,6 @@ _initialize_gdbtypes (void)
   builtin_type_ia64_quad =
     build_flt (-1, "builtin_type_ia64_quad", floatformats_ia64_quad);
 
-  builtin_type_true_char =
-    init_type (TYPE_CODE_CHAR, TARGET_CHAR_BIT / TARGET_CHAR_BIT,
-              0,
-              "true character", (struct objfile *) NULL);
-  builtin_type_true_unsigned_char =
-    init_type (TYPE_CODE_CHAR, TARGET_CHAR_BIT / TARGET_CHAR_BIT,
-              TYPE_FLAG_UNSIGNED,
-              "true character", (struct objfile *) NULL);
-
   add_setshow_zinteger_cmd ("overload", no_class, &overload_debug, _("\
 Set debugging of C++ overloading."), _("\
 Show debugging of C++ overloading."), _("\
index f2f339dc51028630f1dc93d7ff4d3d15ca195356..2d9ce126228e616be29b1187c2afcd7b34e35a12 100644 (file)
@@ -983,6 +983,13 @@ struct builtin_type
   struct type *builtin_decdouble;
   struct type *builtin_declong;
 
+  /* "True" character types.
+      We use these for the '/c' print format, because c_char is just a
+      one-byte integral type, which languages less laid back than C
+      will print as ... well, a one-byte integral type.  */
+  struct type *builtin_true_char;
+  struct type *builtin_true_unsigned_char;
+
 
   /* Pointer types.  */
 
@@ -1086,14 +1093,6 @@ extern struct type *builtin_type_ia64_spill;
 extern struct type *builtin_type_ia64_quad;
 
 
-/* Platform-neutral character types.
-   We use these for the '/c' print format, because c_char is just a
-   one-byte integral type, which languages less laid back than C
-   will print as ... well, a one-byte integral type.  */
-extern struct type *builtin_type_true_char;
-extern struct type *builtin_type_true_unsigned_char;
-
-
 /* Maximum and minimum values of built-in types */
 
 #define        MAX_OF_TYPE(t)  \
index f01d40e3a0a9afd669f52a5f4e7d66b04b95b57f..59bb656898c179e461a3a4892ac3b02bda413a0b 100644 (file)
@@ -344,9 +344,10 @@ print_scalar_formatted (const void *valaddr, struct type *type,
                        const struct value_print_options *options,
                        int size, struct ui_file *stream)
 {
+  struct gdbarch *gdbarch = current_gdbarch;
   LONGEST val_long = 0;
   unsigned int len = TYPE_LENGTH (type);
-  enum bfd_endian byte_order = gdbarch_byte_order (current_gdbarch);
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
 
   /* If we get here with a string format, try again without it.  Go
      all the way back to the language printers, which may call us
@@ -395,7 +396,7 @@ print_scalar_formatted (const void *valaddr, struct type *type,
      same, then at this point, the value's length (in target bytes) is
      gdbarch_addr_bit/TARGET_CHAR_BIT, not TYPE_LENGTH (type).  */
   if (TYPE_CODE (type) == TYPE_CODE_PTR)
-    len = gdbarch_addr_bit (current_gdbarch) / TARGET_CHAR_BIT;
+    len = gdbarch_addr_bit (gdbarch) / TARGET_CHAR_BIT;
 
   /* If we are printing it as unsigned, truncate it in case it is actually
      a negative signed value (e.g. "print/u (short)-1" should print 65535
@@ -454,13 +455,13 @@ print_scalar_formatted (const void *valaddr, struct type *type,
       {
        struct value_print_options opts = *options;
        opts.format = 0;
+
        if (TYPE_UNSIGNED (type))
-         value_print (value_from_longest (builtin_type_true_unsigned_char,
-                                          val_long),
-                      stream, &opts);
-       else
-         value_print (value_from_longest (builtin_type_true_char, val_long),
-                      stream, &opts);
+         type = builtin_type (gdbarch)->builtin_true_unsigned_char;
+       else
+         type = builtin_type (gdbarch)->builtin_true_char;
+
+       value_print (value_from_longest (type, val_long), stream, &opts);
       }
       break;