From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 58259 invoked by alias); 14 Dec 2015 12:59:13 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 58241 invoked by uid 89); 14 Dec 2015 12:59:12 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.3 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-pa0-f46.google.com Received: from mail-pa0-f46.google.com (HELO mail-pa0-f46.google.com) (209.85.220.46) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Mon, 14 Dec 2015 12:59:10 +0000 Received: by pacdm15 with SMTP id dm15so103429984pac.3 for ; Mon, 14 Dec 2015 04:59:09 -0800 (PST) X-Received: by 10.67.22.99 with SMTP id hr3mr45036252pad.10.1450097948907; Mon, 14 Dec 2015 04:59:08 -0800 (PST) Received: from E107787-LIN (gcc1-power7.osuosl.org. [140.211.15.137]) by smtp.gmail.com with ESMTPSA id w20sm42494436pfi.55.2015.12.14.04.59.05 (version=TLS1_2 cipher=AES128-SHA bits=128/128); Mon, 14 Dec 2015 04:59:07 -0800 (PST) From: Yao Qi To: Tristan Gingold Cc: GDB Patches Subject: Re: [PATCH/aarch64] Fix handling of hfa/hva arrays References: <9807AC8E-AB8B-42D5-BEF8-1CF4D5731E28@adacore.com> Date: Mon, 14 Dec 2015 12:59:00 -0000 In-Reply-To: <9807AC8E-AB8B-42D5-BEF8-1CF4D5731E28@adacore.com> (Tristan Gingold's message of "Wed, 9 Dec 2015 12:04:22 +0100") Message-ID: <864mflp4oc.fsf@gmail.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-IsSubscribed: yes X-SW-Source: 2015-12/txt/msg00261.txt.bz2 Tristan Gingold writes: > the current handling of hfa arrays is not correct: first the length compa= rison > is using the size instead of the length so only array of a single float c= ould > be considered as an hfa. > > Second, where used HFA were only considered as struct/union. Incorrect > accessor (like TYPE_NFIELDS) were used on arrays. Hi Tristan, Thanks for your patch. I spot this problem before, but I didn't fix it because I can't write a test case in ada. Could you add a test case to expose these problems you described above? > > Unfortunately, we don=E2=80=99t have the setup to run the gdb testsuite o= n that > processor. So this patch was only manually tested (using our own > internal testsuite) on a slightly older version of gdb. Your can run testsuite on aarch64 machine on gcc compile farm, as Pedro suggested. > @@ -932,12 +932,13 @@ is_hfa_or_hva (struct type *ty) > { > case TYPE_CODE_ARRAY: > { > - struct type *target_ty =3D TYPE_TARGET_TYPE (ty); > + struct type *target_ty =3D check_typedef (TYPE_TARGET_TYPE (ty)); >=20=20 > if (TYPE_VECTOR (ty)) > return 0; >=20=20 > - if (TYPE_LENGTH (ty) <=3D 4 /* HFA or HVA has at most 4 members. */ > + /* HFA or HVA has at most 4 members. */ > + if (TYPE_LENGTH (ty) / TYPE_LENGTH (target_ty) <=3D 4 > && (TYPE_CODE (target_ty) =3D=3D TYPE_CODE_FLT /* HFA */ > || (TYPE_CODE (target_ty) =3D=3D TYPE_CODE_ARRAY /* HVA */ > && TYPE_VECTOR (target_ty)))) We can use get_array_bounds here, and take care of empty array in ada. We can do something like this? + LONGEST low_bound, high_bound; + + if (get_array_bounds (ty, &low_bound, &high_bound)) + { + struct type *target_ty =3D TYPE_TARGET_TYPE (ty); + + if (low_bound > high_bound) + { + /* Empty array in Ada. */ + return 0; + } + else if (high_bound - low_bound + 1 > 4) + { + /* There are at most 4 members in HFA. */ + return 0; + } + else if (TYPE_CODE (target_ty) =3D=3D TYPE_CODE_FLT /* HFA */ + || (TYPE_CODE (target_ty) =3D=3D TYPE_CODE_ARRAY /* HVA */ + && TYPE_VECTOR (target_ty)))) + return 1; + else + return 0; + } + else + return 0; + > @@ -1313,7 +1314,16 @@ aarch64_push_dummy_call (struct gdbarch *gdbarch, = struct value *function, > case TYPE_CODE_UNION: > if (is_hfa_or_hva (arg_type)) > { > - int elements =3D TYPE_NFIELDS (arg_type); > + int elements; > + > + if (TYPE_CODE (arg_type) =3D=3D TYPE_CODE_ARRAY) > + { > + struct type *el_type; > + el_type =3D check_typedef (TYPE_TARGET_TYPE (arg_type)); > + elements =3D TYPE_LENGTH (arg_type) / TYPE_LENGTH (el_type); > + } > + else > + elements =3D TYPE_NFIELDS (arg_type); The change is correct, but it would be nice to move them into is_hfa_or_hva, so that it becomes, static int is_hfa_or_hva (struct type *ty, int *elenum) *ELENUM is set to the number of elements or fields of *TY if *TY is a Homogeneous Aggregates. What do you think? --=20 Yao (=E9=BD=90=E5=B0=A7)