]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Fix printing of Wide_Character & Wide_Wide_Character entities.
authorJoel Brobecker <brobecker@gnat.com>
Fri, 14 Jan 2011 20:18:21 +0000 (20:18 +0000)
committerJoel Brobecker <brobecker@gnat.com>
Fri, 14 Jan 2011 20:18:21 +0000 (20:18 +0000)
Wide_Characters and Wide_Wide_Characters are incorrectly printed.
Consider for instance:

    Medium : Wide_Character := Wide_Character'Val(16#dead#);

Trying to print the value of this variable yields:

    (gdb) p medium
    $1 = 57005 '["ad"]'

The integer value is correct (57005 = 0xdead), but the character
representation is not, it should be:

    $1 = 57005 '["dead"]'

Same for Wide_Wide_Characters.

There were two issues:
   (a) The first issue was in ada-valprint, where we were assuming
       that character types were 1 byte long;
   (b) The second problem was in c-valprint, where we were down-casting
       the integer value of the character to type `unsigned char',
       causing use to lose all but the lowest byte.

gdb/ChangeLog:

        * ada-valprint. (ada_printchar): Use the correct type length
        in call to ada_emit_char.
        * c-valprint.c (c_val_print): Remove cast in call to LA_PRINT_CHAR.

gdb/ChangeLog
gdb/ada-valprint.c
gdb/c-valprint.c

index 0e01c044c716cf1ba4efd042ff840f52dd0a7ae7..4edda80c5c37201715a655468a2510e0ac61f357 100644 (file)
@@ -1,3 +1,9 @@
+2011-01-14  Joel Brobecker  <brobecker@adacore.com>
+
+       * ada-valprint. (ada_printchar): Use the correct type length
+       in call to ada_emit_char.
+       * c-valprint.c (c_val_print): Remove cast in call to LA_PRINT_CHAR.
+
 2011-01-14  Joel Brobecker  <brobecker@adacore.com>
 
        * ada-valprint.c (ada_emit_char): Remove strange code.
index ea8450684d76d179d7cbe5a962062ac3dc6110de..c9a8c94628db29ceb9761b80104f7db580224e47 100644 (file)
@@ -368,7 +368,7 @@ void
 ada_printchar (int c, struct type *type, struct ui_file *stream)
 {
   fputs_filtered ("'", stream);
-  ada_emit_char (c, type, stream, '\'', 1);
+  ada_emit_char (c, type, stream, '\'', TYPE_LENGTH (type));
   fputs_filtered ("'", stream);
 }
 
index f0895a4d9c1ee462d120fef5055011598c648370..85ca3543ef0c17307458358c4d8bf917a23e04ca 100644 (file)
@@ -507,7 +507,7 @@ c_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
          if (c_textual_element_type (unresolved_type, options->format))
            {
              fputs_filtered (" ", stream);
-             LA_PRINT_CHAR ((unsigned char) unpack_long (type, valaddr + embedded_offset),
+             LA_PRINT_CHAR (unpack_long (type, valaddr + embedded_offset),
                             unresolved_type, stream);
            }
        }
@@ -530,7 +530,7 @@ c_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
          else
            fprintf_filtered (stream, "%d", (int) val);
          fputs_filtered (" ", stream);
-         LA_PRINT_CHAR ((unsigned char) val, unresolved_type, stream);
+         LA_PRINT_CHAR (val, unresolved_type, stream);
        }
       break;