Remove DW_ADDR
[deliverable/binutils-gdb.git] / gdb / printcmd.c
index 388a0b2c6d414450f6c54c5f463d538167b29a9b..d3b1075ed8fcefcdbff5b1804b12ea8511c3eef6 100644 (file)
@@ -368,12 +368,21 @@ print_scalar_formatted (const gdb_byte *valaddr, struct type *type,
      a negative signed value (e.g. "print/u (short)-1" should print 65535
      (if shorts are 16 bits) instead of 4294967295).  */
   if (options->format != 'c'
-      && (options->format != 'd' || TYPE_UNSIGNED (type)))
+      && (options->format != 'd' || type->is_unsigned ()))
     {
       if (len < TYPE_LENGTH (type) && byte_order == BFD_ENDIAN_BIG)
        valaddr += TYPE_LENGTH (type) - len;
     }
 
+  /* Allow LEN == 0, and in this case, don't assume that VALADDR is
+     valid.  */
+  const gdb_byte zero = 0;
+  if (len == 0)
+    {
+      len = 1;
+      valaddr = &zero;
+    }
+
   if (size != 0 && (options->format == 'x' || options->format == 't'))
     {
       /* Truncate to fit.  */
@@ -404,8 +413,8 @@ print_scalar_formatted (const gdb_byte *valaddr, struct type *type,
      long, and then printing the long.  PR cli/16242 suggests changing
      this to using C-style hex float format.
 
-     Biased range types must also be unbiased here; the unbiasing is
-     done by unpack_long.  */
+     Biased range types and sub-word scalar types must also be handled
+     here; the value is correctly computed by unpack_long.  */
   gdb::byte_vector converted_bytes;
   /* Some cases below will unpack the value again.  In the biased
      range case, we want to avoid this, so we store the unpacked value
@@ -418,8 +427,8 @@ print_scalar_formatted (const gdb_byte *valaddr, struct type *type,
           || options->format == 'z'
           || options->format == 'd'
           || options->format == 'u'))
-      || (type->code () == TYPE_CODE_RANGE
-         && TYPE_RANGE_DATA (type)->bias != 0))
+      || (type->code () == TYPE_CODE_RANGE && type->bounds ()->bias != 0)
+      || type->bit_size_differs_p ())
     {
       val_long.emplace (unpack_long (type, valaddr));
       converted_bytes.resize (TYPE_LENGTH (type));
@@ -453,7 +462,7 @@ print_scalar_formatted (const gdb_byte *valaddr, struct type *type,
     case 0:
       if (type->code () != TYPE_CODE_FLT)
        {
-         print_decimal_chars (stream, valaddr, len, !TYPE_UNSIGNED (type),
+         print_decimal_chars (stream, valaddr, len, !type->is_unsigned (),
                               byte_order);
          break;
        }
@@ -479,7 +488,7 @@ print_scalar_formatted (const gdb_byte *valaddr, struct type *type,
          val_long.emplace (unpack_long (type, valaddr));
 
        opts.format = 0;
-       if (TYPE_UNSIGNED (type))
+       if (type->is_unsigned ())
          type = builtin_type (gdbarch)->builtin_true_unsigned_char;
        else
          type = builtin_type (gdbarch)->builtin_true_char;
This page took 0.026944 seconds and 4 git commands to generate.