summaryrefslogtreecommitdiff
path: root/gdb/c-valprint.c
diff options
context:
space:
mode:
authorJoel Brobecker <brobecker@gnat.com>2011-01-14 19:32:56 +0000
committerJoel Brobecker <brobecker@gnat.com>2011-01-14 19:32:56 +0000
commita1a6376c78ed5738c041dac4060103db68479004 (patch)
treeb9e362ed6a00202d1e36a8095d8f8148d805a121 /gdb/c-valprint.c
parent654348f5c99e8119e538c96fd974dfab2eaf4e8a (diff)
downloadgdb-a1a6376c78ed5738c041dac4060103db68479004.tar.gz
Fix printing of Wide_Character & Wide_Wide_Character entities.
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.
Diffstat (limited to 'gdb/c-valprint.c')
-rw-r--r--gdb/c-valprint.c6
1 files changed, 2 insertions, 4 deletions
diff --git a/gdb/c-valprint.c b/gdb/c-valprint.c
index 0c23c7e1eca..c6d3eae0569 100644
--- a/gdb/c-valprint.c
+++ b/gdb/c-valprint.c
@@ -536,9 +536,7 @@ c_val_print (struct type *type, const gdb_byte *valaddr,
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);
}
}
@@ -561,7 +559,7 @@ c_val_print (struct type *type, const gdb_byte *valaddr,
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;