This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[commit/ada] Fix infinite loop when printing tagged type


The attached patch fixes a problem when trying to print a "tagged" type.
Tagged types in Ada are the equivalent of objects in object-oriented
languages.

Before applying the patch:

    (gdb) p Meas_Traj
    Cannot access memory at address 0x1
    [1]    1868 segmentation fault  ../obj/gdb/gdb q

Unfortunately, I cannot submit a testcase for this fix, because
the example program is derived from some code sent to us by a customer.

The source of the problem is explained in a comment that Jerome added:

+ /* Get the fixed type of the field. Note that, in this case, we
+    do not want to get the real type out of the tag: if the current
+    field is the parent part of a tagged record, we will get the
+    tag of the object. Clearly wrong: the real type of the parent
+    is not the real type of the child. We would end up in an infinite
+    loop.  */

2008-01-03  Jerome Guitton  <guitton@adacore.com>

        * ada-lang.c (ada_value_struct_elt, to_fixed_array_type)
        (to_fixed_array_type, ada_to_fixed_value_create, unwrap_value): 
        Update calls to ada_to_fixed_type.
        (ada_template_to_fixed_record_type_1): Ditto, but without looking
        for the tag.
        (ada_to_fixed_type): Add check_tag parameter; do not look for
        tag if null.  When looking for a tag, use a fixed record type.
        * ada-lang.h (ada_to_fixed_type): Add check_tag parameter.
        * ada-valprint.c (printable_val_type, ada_value_print): Update
        calls to ada_to_fixed_type.

Tested on x86-linux. No regression.
Checked in.

-- 
Joel

Attachment: tagged.diff
Description: Text document


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]