From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp.polymtl.ca (smtp.polymtl.ca [132.207.4.11]) by sourceware.org (Postfix) with ESMTPS id 44E9B3858405 for ; Wed, 23 Mar 2022 12:51:11 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 44E9B3858405 Received: from simark.ca (simark.ca [158.69.221.121]) (authenticated bits=0) by smtp.polymtl.ca (8.14.7/8.14.7) with ESMTP id 22NCk0Rx030693 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 23 Mar 2022 08:46:06 -0400 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp.polymtl.ca 22NCk0Rx030693 Received: from [10.0.0.11] (192-222-157-6.qc.cable.ebox.net [192.222.157.6]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by simark.ca (Postfix) with ESMTPSA id 374161F3B9; Wed, 23 Mar 2022 08:45:59 -0400 (EDT) Message-ID: <4d27b7e2-9866-ffef-23b9-727a7b770ccc@polymtl.ca> Date: Wed, 23 Mar 2022 08:45:59 -0400 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.6.1 Subject: Re: [PATCH v2] gdb:csky save fpu and vdsp info to struct csky_gdbarch_tdep Content-Language: en-US To: Jiangshuai Li , gdb-patches@sourceware.org References: <20220323122616.6041-1-jiangshuai_li@c-sky.com> From: Simon Marchi In-Reply-To: <20220323122616.6041-1-jiangshuai_li@c-sky.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Poly-FromMTA: (simark.ca [158.69.221.121]) at Wed, 23 Mar 2022 12:46:00 +0000 X-Spam-Status: No, score=-3038.9 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, NICE_REPLY_A, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_PASS, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 23 Mar 2022 12:51:12 -0000 On 2022-03-23 08:26, Jiangshuai Li wrote: > First, add three variables fpu_abi, fpu_hardfp and vdsp_version > to csky_gdbarch_tdep. They will be initialized from info.abfd in > cskg_gdbarch_init. > > Now, they are just used to find a candidate among the list of pre-declared > architectures > > Later, they will be used in gdbarch_return_value and gdbarch_push_dummy_call > for funtions described below: > fpu_abi: to check if the bfd is using VAL_CSKY_FPU_ABI_HARD or > VAL_CSKY_FPU_ABI_SOFT > fpu_hardfp: to check if the bfd is using VAL_CSKY_FPU_HARDFP_SINGLE > or VAL_CSKY_FPU_HARDFP_DOUBLE > vdsp_version: to check if a function is returned with CSKY_VRET_REGNUM > --- > gdb/csky-tdep.c | 42 +++++++++++++++++++++++++++++++++++++++--- > gdb/csky-tdep.h | 5 ++++- > 2 files changed, 43 insertions(+), 4 deletions(-) > > diff --git a/gdb/csky-tdep.c b/gdb/csky-tdep.c > index cba0065fa53..04f558cf14b 100644 > --- a/gdb/csky-tdep.c > +++ b/gdb/csky-tdep.c > @@ -2157,16 +2157,52 @@ static struct gdbarch * > csky_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) > { > struct gdbarch *gdbarch; > + /* Analyze info.abfd. */ > + unsigned int fpu_abi = 0; > + unsigned int vdsp_version = 0; > + unsigned int fpu_hardfp = 0; > + > + /* When the type of bfd file is srec(or any files are not elf), > + the E_FLAGS will be not credible. */ > + if (info.abfd != NULL && bfd_get_flavour (info.abfd) == bfd_target_elf_flavour) > + { > + /* Get FPU, VDSP build options. */ > + fpu_abi = bfd_elf_get_obj_attr_int (info.abfd, > + OBJ_ATTR_PROC, > + Tag_CSKY_FPU_ABI); > + vdsp_version = bfd_elf_get_obj_attr_int (info.abfd, > + OBJ_ATTR_PROC, > + Tag_CSKY_VDSP_VERSION); > + fpu_hardfp = bfd_elf_get_obj_attr_int (info.abfd, > + OBJ_ATTR_PROC, > + Tag_CSKY_FPU_HARDFP); > + } > > /* Find a candidate among the list of pre-declared architectures. */ > - arches = gdbarch_list_lookup_by_info (arches, &info); > - if (arches != NULL) > - return arches->gdbarch; > + for (arches = gdbarch_list_lookup_by_info (arches, &info); > + arches != NULL; > + arches = gdbarch_list_lookup_by_info (arches->next, &info)) > + { > + csky_gdbarch_tdep *tdep > + = (csky_gdbarch_tdep *) gdbarch_tdep (arches->gdbarch); > + if (fpu_abi != tdep->fpu_abi) > + continue; > + if (vdsp_version != tdep->vdsp_version) > + continue; > + if (fpu_hardfp != tdep->fpu_hardfp) > + continue; > + > + /* Found a match. */ > + return arches->gdbarch; > + } > > /* None found, create a new architecture from the information > provided. */ > csky_gdbarch_tdep *tdep = new csky_gdbarch_tdep; > gdbarch = gdbarch_alloc (&info, tdep); > + tdep->fpu_abi = fpu_abi; > + tdep->vdsp_version = vdsp_version; > + tdep->fpu_hardfp = fpu_hardfp; > > /* Target data types. */ > set_gdbarch_ptr_bit (gdbarch, 32); > diff --git a/gdb/csky-tdep.h b/gdb/csky-tdep.h > index 7898e0d325b..d0e5fc09270 100644 > --- a/gdb/csky-tdep.h > +++ b/gdb/csky-tdep.h > @@ -33,7 +33,10 @@ enum lr_type_t > /* Target-dependent structure in gdbarch. */ > struct csky_gdbarch_tdep : gdbarch_tdep > { > - /* This is Unused. */ > + /* Save FPU, VDSP ABI. */ > + unsigned int fpu_abi; > + unsigned int fpu_hardfp; > + unsigned int vdsp_version; > }; > > /* Instruction sizes. */ Thanks, this is OK. Simon