* disasm.h (gdb_disassembly): Add GDBARCH parameter.
[deliverable/binutils-gdb.git] / gdb / printcmd.c
index f01d40e3a0a9afd669f52a5f4e7d66b04b95b57f..7601d7c416f7c4b4e8d91513b29d42a6c4ffd7ef 100644 (file)
@@ -293,7 +293,8 @@ print_formatted (struct value *val, int size,
          /* We often wrap here if there are long symbolic names.  */
          wrap_here ("    ");
          next_address = (value_address (val)
-                         + gdb_print_insn (value_address (val), stream,
+                         + gdb_print_insn (get_type_arch (type),
+                                           value_address (val), stream,
                                            &branch_delay_insns));
          return;
        }
@@ -317,8 +318,9 @@ print_formatted (struct value *val, int size,
 /* Return builtin floating point type of same length as TYPE.
    If no such type is found, return TYPE itself.  */
 static struct type *
-float_type_from_length (struct gdbarch *gdbarch, struct type *type)
+float_type_from_length (struct type *type)
 {
+  struct gdbarch *gdbarch = get_type_arch (type);
   const struct builtin_type *builtin = builtin_type (gdbarch);
   unsigned int len = TYPE_LENGTH (type);
 
@@ -344,9 +346,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 = get_type_arch (type);
   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 +398,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,18 +457,18 @@ 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;
 
     case 'f':
-      type = float_type_from_length (current_gdbarch, type);
+      type = float_type_from_length (type);
       print_floating (valaddr, type, stream);
       break;
 
@@ -780,13 +783,13 @@ do_examine (struct format_data fmt, struct gdbarch *gdbarch, CORE_ADDR addr)
     }
 
   if (size == 'b')
-    val_type = builtin_type_int8;
+    val_type = builtin_type (next_gdbarch)->builtin_int8;
   else if (size == 'h')
-    val_type = builtin_type_int16;
+    val_type = builtin_type (next_gdbarch)->builtin_int16;
   else if (size == 'w')
-    val_type = builtin_type_int32;
+    val_type = builtin_type (next_gdbarch)->builtin_int32;
   else if (size == 'g')
-    val_type = builtin_type_int64;
+    val_type = builtin_type (next_gdbarch)->builtin_int64;
 
   maxelts = 8;
   if (size == 'w')
@@ -2274,8 +2277,9 @@ printf_command (char *arg, int from_tty)
              gdb_byte *str;
              CORE_ADDR tem;
              int j;
-             struct type *wctype = lookup_typename (current_language,
-                                                    current_gdbarch,
+             struct gdbarch *gdbarch
+               = get_type_arch (value_type (val_args[i]));
+             struct type *wctype = lookup_typename (current_language, gdbarch,
                                                     "wchar_t", NULL, 0);
              int wcwidth = TYPE_LENGTH (wctype);
              gdb_byte *buf = alloca (wcwidth);
@@ -2314,8 +2318,9 @@ printf_command (char *arg, int from_tty)
            break;
          case wide_char_arg:
            {
-             struct type *wctype = lookup_typename (current_language,
-                                                    current_gdbarch,
+             struct gdbarch *gdbarch
+               = get_type_arch (value_type (val_args[i]));
+             struct type *wctype = lookup_typename (current_language, gdbarch,
                                                     "wchar_t", NULL, 0);
              struct type *valtype;
              struct obstack output;
@@ -2351,7 +2356,7 @@ printf_command (char *arg, int from_tty)
 
              /* If format string wants a float, unchecked-convert the value
                 to floating point of the same size.  */
-             type = float_type_from_length (current_gdbarch, type);
+             type = float_type_from_length (type);
              val = unpack_double (type, value_contents (val_args[i]), &inv);
              if (inv)
                error (_("Invalid floating value found in program."));
@@ -2368,7 +2373,7 @@ printf_command (char *arg, int from_tty)
 
              /* If format string wants a float, unchecked-convert the value
                 to floating point of the same size.  */
-             type = float_type_from_length (current_gdbarch, type);
+             type = float_type_from_length (type);
              val = unpack_double (type, value_contents (val_args[i]), &inv);
              if (inv)
                error (_("Invalid floating value found in program."));
@@ -2422,6 +2427,7 @@ printf_command (char *arg, int from_tty)
              /* Parameter data.  */
              struct type *param_type = value_type (val_args[i]);
              unsigned int param_len = TYPE_LENGTH (param_type);
+             struct gdbarch *gdbarch = get_type_arch (param_type);
 
              /* DFP output data.  */
              struct value *dfp_value = NULL;
@@ -2450,18 +2456,18 @@ printf_command (char *arg, int from_tty)
                  if (*sos == 'H')
                    {
                      dfp_len = 4;
-                     dfp_type = builtin_type (current_gdbarch)->builtin_decfloat;
+                     dfp_type = builtin_type (gdbarch)->builtin_decfloat;
                    }
                  else if (*sos == 'D' && *(sos - 1) == 'D')
                    {
                      dfp_len = 16;
-                     dfp_type = builtin_type (current_gdbarch)->builtin_declong;
+                     dfp_type = builtin_type (gdbarch)->builtin_declong;
                      sos--;
                    }
                  else
                    {
                      dfp_len = 8;
-                     dfp_type = builtin_type (current_gdbarch)->builtin_decdouble;
+                     dfp_type = builtin_type (gdbarch)->builtin_decdouble;
                    }
                }
 
This page took 0.028144 seconds and 4 git commands to generate.