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] better handling for unchecked union types


Hello,

We realized a while ago that we were not handling unchecked union
types very well... Unchecked union types are variant records with
an Unchecked_Union pragma applied to them, which transforms them
into the C-like union. For instance:

   type Discriminant is (First, Second, Third, Fourth);
   type Variant (Discr : Discriminant := First) is record
      Data : Integer;
      case Discr is
         when First =>
            F : Integer;
         when Second =>
            S : Float;
            E : Float;
         when Third | Fourth =>
            T : Boolean;
            H : Boolean;
      end case;
   end record;
   pragma Unchecked_Union (Variant);

Since the discriminant is no longer known, the debugger needs
to print the value of all branches, just like we do for C unions.
The attach patch fixes the various bugs we found.

2008-09-30  Paul Hilfinger  <brobecker@adacore.com>

        * ada-lang.c (ada_lookup_struct_elt_type): Handle case of a "naked"
        variant branch.
        (empty_record): Use INIT_CPLUS_SPECIFIC, since this field is not
        supposed to be null.  Fixes debugger segfaults.
        (is_unchecked_variant): New function.
        (to_fixed_variant_branch_type): Modify to leave unchecked unions
        untouched.
        (ada_template_to_fixed_record_type_1): Fix comment.

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

-- 
Joel

Attachment: unchecked-union.diff
Description: Text document


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