summaryrefslogtreecommitdiff
path: root/gdb/ada-valprint.c
diff options
context:
space:
mode:
authorJoel Brobecker <brobecker@gnat.com>2010-12-29 08:01:28 +0000
committerJoel Brobecker <brobecker@gnat.com>2010-12-29 08:01:28 +0000
commit4b88473c312f66c7fba0c1a5d862cd5f95b732c2 (patch)
tree690e774602715fe9c28c2700021b809f3d88c3d9 /gdb/ada-valprint.c
parent9d758ee0ddc2d3cc10691b1979e8c2a25554b51d (diff)
downloadgdb-4b88473c312f66c7fba0c1a5d862cd5f95b732c2.tar.gz
[Ada] do not print arrays as array pointers
This patch enhances the debugger to distinguish between fat pointers that represent either: array types, or array access types. In the latter case, the object/type is encoded as a typedef type pointing to the fat pointer. The first part of the change is to adjust ada_check_typedef to avoid stripping the typedef layer when it points to a fat pointer. The rest of the patch is adjustments required in various places to deal with the fact that the type is uses might now be a typedef. gdb/ChangeLog: * ada-lang.h (ada_coerce_to_simple_array): Add declaration. * ada-lang.c (ada_typedef_target_type): New function. (desc_base_type): Add handling of fat pointer typedefs. (ada_coerce_to_simple_array): Make non-static. (decode_packed_array_bitsize): Add handling of fat pointer typedefs. Add assertion. (ada_template_to_fixed_record_type_1, ada_to_fixed_type) (ada_check_typedef): Add handling of fat pointer typedefs. (ada_evaluate_subexp) [OP_FUNCALL]: Likewise. * ada-typeprint.c (ada_print_type): Add handling of fat pointer typedefs. * ada-valprint.c (ada_val_print_1): Convert fat pointers that are not array accesses to simple arrays rather than simple array pointers. (ada_value_print): In the case of array descriptors, do not print the value type description unless it is an array access. gdb/testsuite/ChangeLog: * gdb.ada/lang_switch.exp: Correct expected parameter value. gdb/doc/ChangeLog: * gdb.texinfo (Ada Glitches): Remove paragraph describing the occasional case where the debugger prints an array address instead of the array itself.
Diffstat (limited to 'gdb/ada-valprint.c')
-rw-r--r--gdb/ada-valprint.c17
1 files changed, 13 insertions, 4 deletions
diff --git a/gdb/ada-valprint.c b/gdb/ada-valprint.c
index ae2a47d7d86..b5d4b02329c 100644
--- a/gdb/ada-valprint.c
+++ b/gdb/ada-valprint.c
@@ -684,7 +684,10 @@ ada_val_print_1 (struct type *type, const gdb_byte *valaddr0,
struct value *val;
val = value_from_contents_and_address (type, valaddr, address);
- val = ada_coerce_to_simple_array_ptr (val);
+ if (TYPE_CODE (type) == TYPE_CODE_TYPEDEF) /* array access type. */
+ val = ada_coerce_to_simple_array_ptr (val);
+ else
+ val = ada_coerce_to_simple_array (val);
if (val == NULL)
{
fprintf_filtered (stream, "(null)");
@@ -947,9 +950,15 @@ ada_value_print (struct value *val0, struct ui_file *stream,
}
else if (ada_is_array_descriptor_type (type))
{
- fprintf_filtered (stream, "(");
- type_print (type, "", stream, -1);
- fprintf_filtered (stream, ") ");
+ /* We do not print the type description unless TYPE is an array
+ access type (this is encoded by the compiler as a typedef to
+ a fat pointer - hence the check against TYPE_CODE_TYPEDEF). */
+ if (TYPE_CODE (type) == TYPE_CODE_TYPEDEF)
+ {
+ fprintf_filtered (stream, "(");
+ type_print (type, "", stream, -1);
+ fprintf_filtered (stream, ") ");
+ }
}
else if (ada_is_bogus_array_descriptor (type))
{