From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 8926 invoked by alias); 3 Jul 2013 17:21:21 -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 8914 invoked by uid 89); 3 Jul 2013 17:21:20 -0000 X-Spam-SWARE-Status: No, score=-3.7 required=5.0 tests=AWL,BAYES_00,KHOP_RCVD_UNTRUST,RCVD_IN_DNSWL_MED,RCVD_IN_HOSTKARMA_W,RP_MATCHES_RCVD,TW_EG autolearn=ham version=3.3.1 Received: from e06smtp10.uk.ibm.com (HELO e06smtp10.uk.ibm.com) (195.75.94.106) by sourceware.org (qpsmtpd/0.84/v0.84-167-ge50287c) with ESMTP; Wed, 03 Jul 2013 17:21:15 +0000 Received: from /spool/local by e06smtp10.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 3 Jul 2013 18:18:43 +0100 Received: from d06dlp02.portsmouth.uk.ibm.com (9.149.20.14) by e06smtp10.uk.ibm.com (192.168.101.140) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Wed, 3 Jul 2013 18:18:42 +0100 Received: from b06cxnps4076.portsmouth.uk.ibm.com (d06relay13.portsmouth.uk.ibm.com [9.149.109.198]) by d06dlp02.portsmouth.uk.ibm.com (Postfix) with ESMTP id 688AD2190059 for ; Wed, 3 Jul 2013 18:24:57 +0100 (BST) Received: from d06av03.portsmouth.uk.ibm.com (d06av03.portsmouth.uk.ibm.com [9.149.37.213]) by b06cxnps4076.portsmouth.uk.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id r63HL1AZ4587638 for ; Wed, 3 Jul 2013 17:21:01 GMT Received: from d06av03.portsmouth.uk.ibm.com (localhost [127.0.0.1]) by d06av03.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id r63HLB1s011031 for ; Wed, 3 Jul 2013 11:21:11 -0600 Received: from br87z6lw.de.ibm.com (dyn-9-152-212-143.boeblingen.de.ibm.com [9.152.212.143]) by d06av03.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id r63HLBmI011028; Wed, 3 Jul 2013 11:21:11 -0600 From: Andreas Arnez To: gdb-patches@sourceware.org Cc: Ulrich.Weigand@de.ibm.com Subject: [RFA][PATCH v4 5/5] PowerPC: Exploit dynamic core regset sections References: <87zju3intq.fsf@br87z6lw.de.ibm.com> Date: Wed, 03 Jul 2013 17:21:00 -0000 In-Reply-To: <87zju3intq.fsf@br87z6lw.de.ibm.com> (Andreas Arnez's message of "Wed, 03 Jul 2013 18:57:05 +0200") Message-ID: <87ehbfimpk.fsf@br87z6lw.de.ibm.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.3 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-TM-AS-MML: No X-Content-Scanned: Fidelis XPS MAILER x-cbid: 13070317-4966-0000-0000-000006311054 X-SW-Source: 2013-07/txt/msg00151.txt.bz2 Use a dynamic iterator function for enumerating the supported core regset sections on a PowerPC target. Compared to the previous approach of selecting one out of six static lists, this simplifies the code. 2013-07-03 Andreas Arnez * ppc-linux-tdep.c (ppc_linux_vsx_regset_sections): Remove array. (ppc_linux_vmx_regset_sections): Likewise. (ppc_linux_fp_regset_sections): Likewise. (ppc64_linux_vsx_regset_sections): Likewise. (ppc64_linux_vmx_regset_sections): Likewise. (ppc64_linux_fp_regset_sections): Likewise. (ppc_linux_iterate_over_regset_sections): New function. (ppc_linux_init_abi): Remove all invocations of set_gdbarch_core_regset_sections; instead, call set_gdbarch_iterate_over_regset_sections. Index: gdb/gdb/ppc-linux-tdep.c =================================================================== --- gdb.orig/gdb/ppc-linux-tdep.c +++ gdb/gdb/ppc-linux-tdep.c @@ -256,53 +256,28 @@ ppc_linux_return_value (struct gdbarch * readbuf, writebuf); } -static struct core_regset_section ppc_linux_vsx_regset_sections[] = -{ - { ".reg", 48 * 4, "general-purpose" }, - { ".reg2", 264, "floating-point" }, - { ".reg-ppc-vmx", 544, "ppc Altivec" }, - { ".reg-ppc-vsx", 256, "POWER7 VSX" }, - { NULL, 0} -}; - -static struct core_regset_section ppc_linux_vmx_regset_sections[] = -{ - { ".reg", 48 * 4, "general-purpose" }, - { ".reg2", 264, "floating-point" }, - { ".reg-ppc-vmx", 544, "ppc Altivec" }, - { NULL, 0} -}; - -static struct core_regset_section ppc_linux_fp_regset_sections[] = -{ - { ".reg", 48 * 4, "general-purpose" }, - { ".reg2", 264, "floating-point" }, - { NULL, 0} -}; - -static struct core_regset_section ppc64_linux_vsx_regset_sections[] = -{ - { ".reg", 48 * 8, "general-purpose" }, - { ".reg2", 264, "floating-point" }, - { ".reg-ppc-vmx", 544, "ppc Altivec" }, - { ".reg-ppc-vsx", 256, "POWER7 VSX" }, - { NULL, 0} -}; +/* Iterate over supported core file register note sections. */ -static struct core_regset_section ppc64_linux_vmx_regset_sections[] = +static void +ppc_linux_iterate_over_regset_sections (struct gdbarch *gdbarch, + iterate_over_regset_sections_cb *cb, + void *cb_data, + const struct regcache *regcache) { - { ".reg", 48 * 8, "general-purpose" }, - { ".reg2", 264, "floating-point" }, - { ".reg-ppc-vmx", 544, "ppc Altivec" }, - { NULL, 0} -}; + struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + int have_vsx = tdep->ppc_vr0_regnum != -1; + int have_altivec = tdep->ppc_vsr0_upper_regnum != -1; -static struct core_regset_section ppc64_linux_fp_regset_sections[] = -{ - { ".reg", 48 * 8, "general-purpose" }, - { ".reg2", 264, "floating-point" }, - { NULL, 0} -}; + if (cb (".reg", 48 * tdep->wordsize, "general-purpose", cb_data)) + return; + if (cb (".reg2", 264, "floating-point", cb_data)) + return; + if (have_altivec) + if (cb (".reg-ppc-vmx", 544, "ppc Altivec", cb_data)) + return; + if (have_vsx) + cb (".reg-ppc-vsx", 256, "POWER7 VSX", cb_data); +} /* PLT stub in executable. */ static struct ppc_insn_pattern powerpc32_plt_stub[] = @@ -1305,19 +1280,6 @@ ppc_linux_init_abi (struct gdbarch_info else set_gdbarch_gcore_bfd_target (gdbarch, "elf32-powerpc"); - /* Supported register sections. */ - if (tdesc_find_feature (info.target_desc, - "org.gnu.gdb.power.vsx")) - set_gdbarch_core_regset_sections (gdbarch, - ppc_linux_vsx_regset_sections); - else if (tdesc_find_feature (info.target_desc, - "org.gnu.gdb.power.altivec")) - set_gdbarch_core_regset_sections (gdbarch, - ppc_linux_vmx_regset_sections); - else - set_gdbarch_core_regset_sections (gdbarch, - ppc_linux_fp_regset_sections); - if (powerpc_so_ops.in_dynsym_resolve_code == NULL) { powerpc_so_ops = svr4_so_ops; @@ -1359,19 +1321,6 @@ ppc_linux_init_abi (struct gdbarch_info set_gdbarch_gcore_bfd_target (gdbarch, "elf64-powerpcle"); else set_gdbarch_gcore_bfd_target (gdbarch, "elf64-powerpc"); - - /* Supported register sections. */ - if (tdesc_find_feature (info.target_desc, - "org.gnu.gdb.power.vsx")) - set_gdbarch_core_regset_sections (gdbarch, - ppc64_linux_vsx_regset_sections); - else if (tdesc_find_feature (info.target_desc, - "org.gnu.gdb.power.altivec")) - set_gdbarch_core_regset_sections (gdbarch, - ppc64_linux_vmx_regset_sections); - else - set_gdbarch_core_regset_sections (gdbarch, - ppc64_linux_fp_regset_sections); } /* PPC32 uses a different prpsinfo32 compared to most other Linux @@ -1383,6 +1332,8 @@ ppc_linux_init_abi (struct gdbarch_info set_gdbarch_regset_from_core_section (gdbarch, ppc_linux_regset_from_core_section); set_gdbarch_core_read_description (gdbarch, ppc_linux_core_read_description); + set_gdbarch_iterate_over_regset_sections (gdbarch, + ppc_linux_iterate_over_regset_sections); /* Enable TLS support. */ set_gdbarch_fetch_tls_load_module_address (gdbarch,