From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 58309 invoked by alias); 9 Dec 2015 11:04:27 -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 58288 invoked by uid 89); 9 Dec 2015 11:04:26 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.2 required=5.0 tests=AWL,BAYES_00,KAM_LAZY_DOMAIN_SECURITY,RCVD_IN_DNSWL_LOW autolearn=no version=3.3.2 X-HELO: smtp.eu.adacore.com Received: from mel.act-europe.fr (HELO smtp.eu.adacore.com) (194.98.77.210) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Wed, 09 Dec 2015 11:04:25 +0000 Received: from localhost (localhost [127.0.0.1]) by filtered-smtp.eu.adacore.com (Postfix) with ESMTP id 6B0753000BDE for ; Wed, 9 Dec 2015 12:04:22 +0100 (CET) Received: from smtp.eu.adacore.com ([127.0.0.1]) by localhost (smtp.eu.adacore.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id UsszmtwdYhga for ; Wed, 9 Dec 2015 12:04:22 +0100 (CET) Received: from dhcp-guest-231.act-europe.fr (dhcp-guest-231.act-europe.fr [10.10.127.231]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.eu.adacore.com (Postfix) with ESMTPSA id 5C9173000BDA for ; Wed, 9 Dec 2015 12:04:22 +0100 (CET) From: Tristan Gingold Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Subject: [PATCH/aarch64] Fix handling of hfa/hva arrays Message-Id: <9807AC8E-AB8B-42D5-BEF8-1CF4D5731E28@adacore.com> Date: Wed, 09 Dec 2015 11:04:00 -0000 To: GDB Patches Mime-Version: 1.0 (Mac OS X Mail 8.2 \(2104\)) X-IsSubscribed: yes X-SW-Source: 2015-12/txt/msg00174.txt.bz2 Hello, the current handling of hfa arrays is not correct: first the length compari= son is using the size instead of the length so only array of a single float cou= ld be considered as an hfa. Second, where used HFA were only considered as struct/union. Incorrect accessor (like TYPE_NFIELDS) were used on arrays. Unfortunately, we don=E2=80=99t have the setup to run the gdb testsuite on = that processor. So this patch was only manually tested (using our own internal testsuite) on a slightly older version of gdb. Is it ok to push ? Tristan. =46rom 9a3e54726903e1c01ef79e2c4ba9e0317f3f90a6 Mon Sep 17 00:00:00 2001 From: Tristan Gingold Date: Tue, 8 Dec 2015 13:01:24 +0100 Subject: [PATCH] aarch64: fix handling of hfa/hva arrays. gdb/ * aarch64-tdep.c (is_hfa_or_hva): Fix length comparaison for arrays. (aarch64_extract_return_value): Handle arrays. (aarch64_push_dummy_call): Handle hfa arrays. (aarch64_record_load_store): Fix compiler warning. diff --git a/gdb/ChangeLog b/gdb/ChangeLog index b5d2431..d85cf4f 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,10 @@ +2015-12-09 Tristan Gingold + + * aarch64-tdep.c (is_hfa_or_hva): Fix length comparaison for arrays. + (aarch64_extract_return_value): Handle arrays. + (aarch64_push_dummy_call): Handle hfa arrays. + (aarch64_record_load_store): Fix compiler warning. + 2015-12-08 Pierre-Marie de Rodat =20 * NEWS: Announce this enhancement and the corresponding new diff --git a/gdb/aarch64-tdep.c b/gdb/aarch64-tdep.c index 2d1df03..c651872 100644 --- a/gdb/aarch64-tdep.c +++ b/gdb/aarch64-tdep.c @@ -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 if (TYPE_VECTOR (ty)) return 0; =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)))) @@ -1313,7 +1314,16 @@ aarch64_push_dummy_call (struct gdbarch *gdbarch, st= ruct 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); =20 /* Homogeneous Aggregates */ if (info.nsrn + elements < 8) @@ -1325,13 +1335,16 @@ aarch64_push_dummy_call (struct gdbarch *gdbarch, s= truct value *function, /* We know that we have sufficient registers available therefore this will never fallback to the stack. */ - struct value *field =3D - value_primitive_field (arg, 0, i, arg_type); - struct type *field_type =3D - check_typedef (value_type (field)); + struct value *val; + + if (TYPE_CODE (arg_type) =3D=3D TYPE_CODE_ARRAY) + val =3D value_subscript (arg, i); + else + val =3D value_primitive_field (arg, 0, i, arg_type); =20 pass_in_v_or_stack (gdbarch, regcache, &info, - field_type, field); + check_typedef (value_type (val)), + val); } } else @@ -1649,11 +1662,24 @@ aarch64_extract_return_value (struct type *type, st= ruct regcache *regs, } else if (is_hfa_or_hva (type)) { - int elements =3D TYPE_NFIELDS (type); - struct type *member_type =3D check_typedef (TYPE_FIELD_TYPE (type, 0= )); - int len =3D TYPE_LENGTH (member_type); + int elements; + struct type *el_type; + int len; int i; =20 + if (TYPE_CODE (type) =3D=3D TYPE_CODE_ARRAY) + { + el_type =3D check_typedef (TYPE_TARGET_TYPE (type)); + len =3D TYPE_LENGTH (el_type); + elements =3D TYPE_LENGTH (type) / len; + } + else + { + elements =3D TYPE_NFIELDS (type); + el_type =3D check_typedef (TYPE_FIELD_TYPE (type, 0)); + len =3D TYPE_LENGTH (el_type); + } + for (i =3D 0; i < elements; i++) { int regno =3D AARCH64_V0_REGNUM + i; @@ -3470,7 +3496,7 @@ aarch64_record_load_store (insn_decode_record *aarch6= 4_insn_r) =20 if (!ld_flag) { - uint64_t reg_rm_val; + ULONGEST reg_rm_val; regcache_raw_read_unsigned (aarch64_insn_r->regcache, bits (aarch64_insn_r->aarch64_insn, 16, 20), ®_rm_= val); if (bit (aarch64_insn_r->aarch64_insn, 12))