From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 19599 invoked by alias); 16 Jul 2013 15:26:18 -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 19584 invoked by uid 89); 16 Jul 2013 15:26:18 -0000 X-Spam-SWARE-Status: No, score=-3.3 required=5.0 tests=AWL,BAYES_00,KHOP_RCVD_UNTRUST,RCVD_IN_DNSWL_MED,RCVD_IN_HOSTKARMA_W,RDNS_NONE,TW_EG autolearn=ham version=3.3.1 Received: from Unknown (HELO e06smtp18.uk.ibm.com) (195.75.94.114) by sourceware.org (qpsmtpd/0.84/v0.84-167-ge50287c) with ESMTP; Tue, 16 Jul 2013 15:26:17 +0000 Received: from /spool/local by e06smtp18.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 16 Jul 2013 16:20:12 +0100 Received: from d06dlp02.portsmouth.uk.ibm.com (9.149.20.14) by e06smtp18.uk.ibm.com (192.168.101.148) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Tue, 16 Jul 2013 16:20:10 +0100 Received: from b06cxnps3075.portsmouth.uk.ibm.com (d06relay10.portsmouth.uk.ibm.com [9.149.109.195]) by d06dlp02.portsmouth.uk.ibm.com (Postfix) with ESMTP id 6D7C5219005F for ; Tue, 16 Jul 2013 16:30:05 +0100 (BST) Received: from d06av01.portsmouth.uk.ibm.com (d06av01.portsmouth.uk.ibm.com [9.149.37.212]) by b06cxnps3075.portsmouth.uk.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id r6GFPsPR58458308 for ; Tue, 16 Jul 2013 15:25:54 GMT Received: from d06av01.portsmouth.uk.ibm.com (localhost [127.0.0.1]) by d06av01.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id r6GFQ40p005376 for ; Tue, 16 Jul 2013 09:26:05 -0600 Received: from br87z6lw.de.ibm.com (dyn-9-152-212-143.boeblingen.de.ibm.com [9.152.212.143]) by d06av01.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id r6GFQ4bv005363; Tue, 16 Jul 2013 09:26:04 -0600 From: Andreas Arnez To: lgustavo@codesourcery.com Cc: gdb-patches@sourceware.org, Ulrich.Weigand@de.ibm.com Subject: Re: [ping 2] [RFA][PATCH v4 0/5] Add TDB regset support References: <87zju3intq.fsf@br87z6lw.de.ibm.com> <87d2qt83au.fsf@br87z6lw.de.ibm.com> <874nbwtdgk.fsf_-_@br87z6lw.de.ibm.com> <51E3F8B3.10109@codesourcery.com> <87zjtnsupy.fsf@br87z6lw.de.ibm.com> <51E417DD.90806@codesourcery.com> <87vc4bss41.fsf@br87z6lw.de.ibm.com> Date: Tue, 16 Jul 2013 15:26:00 -0000 In-Reply-To: <87vc4bss41.fsf@br87z6lw.de.ibm.com> (Andreas Arnez's message of "Mon, 15 Jul 2013 18:30:38 +0200") Message-ID: <87wqoqle5v.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: 13071615-6892-0000-0000-000005B3472E X-SW-Source: 2013-07/txt/msg00364.txt.bz2 Andreas Arnez writes: > In the scope of this patch set the PowerPC change is purely optional. > I'll just remove it from the next version of the patch set. Actually, before I do that, here's another try. Would it help to merge the iterator function with the logic of ppc_regset_from_core_section(), like outlined in the patch below? I see the following advantages: - One less gdbarch function needed: gdbarch_regset_from_core_section becomes obsolete. - The regset description is more "self-contained": it now includes the name, description, and size. - Even less code than the previous version, all condensed in a single function. Thoughts? diff --git a/gdb/ppc-linux-tdep.c b/gdb/ppc-linux-tdep.c index fc09560..854b356 100644 --- a/gdb/ppc-linux-tdep.c +++ b/gdb/ppc-linux-tdep.c @@ -256,54 +256,6 @@ ppc_linux_return_value (struct gdbarch *gdbarch, struct value *function, 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} -}; - -static struct core_regset_section ppc64_linux_vmx_regset_sections[] = -{ - { ".reg", 48 * 8, "general-purpose" }, - { ".reg2", 264, "floating-point" }, - { ".reg-ppc-vmx", 544, "ppc Altivec" }, - { NULL, 0} -}; - -static struct core_regset_section ppc64_linux_fp_regset_sections[] = -{ - { ".reg", 48 * 8, "general-purpose" }, - { ".reg2", 264, "floating-point" }, - { NULL, 0} -}; - /* PLT stub in executable. */ static struct ppc_insn_pattern powerpc32_plt_stub[] = { @@ -498,35 +450,40 @@ static const struct regset ppc32_linux_gregset = { &ppc32_linux_reg_offsets, ppc_linux_supply_gregset, ppc_linux_collect_gregset, - NULL + NULL, + ".reg", "general-purpose", 48 * 4 }; static const struct regset ppc64_linux_gregset = { &ppc64_linux_reg_offsets, ppc_linux_supply_gregset, ppc_linux_collect_gregset, - NULL + NULL, + ".reg", "general-purpose", 48 * 8 }; static const struct regset ppc32_linux_fpregset = { &ppc32_linux_reg_offsets, ppc_supply_fpregset, ppc_collect_fpregset, - NULL + NULL, + ".reg2", "floating-point", 264 }; static const struct regset ppc32_linux_vrregset = { &ppc32_linux_reg_offsets, ppc_supply_vrregset, ppc_collect_vrregset, - NULL + NULL, + ".reg-ppc-vmx", "ppc Altivec", 544 }; static const struct regset ppc32_linux_vsxregset = { &ppc32_linux_reg_offsets, ppc_supply_vsxregset, ppc_collect_vsxregset, - NULL + NULL, + ".reg-ppc-vsx", "POWER7 VSX", 256 }; const struct regset * @@ -541,25 +498,26 @@ ppc_linux_fpregset (void) return &ppc32_linux_fpregset; } -static const struct regset * -ppc_linux_regset_from_core_section (struct gdbarch *core_arch, - const char *sect_name, size_t sect_size) +static void +ppc_linux_iterate_over_regset_sections (struct gdbarch *core_arch, + iterate_over_regset_sections_cb *cb, + void *cb_data, + const struct regcache *regcache) { struct gdbarch_tdep *tdep = gdbarch_tdep (core_arch); - if (strcmp (sect_name, ".reg") == 0) - { - if (tdep->wordsize == 4) - return &ppc32_linux_gregset; - else - return &ppc64_linux_gregset; - } - if (strcmp (sect_name, ".reg2") == 0) - return &ppc32_linux_fpregset; - if (strcmp (sect_name, ".reg-ppc-vmx") == 0) - return &ppc32_linux_vrregset; - if (strcmp (sect_name, ".reg-ppc-vsx") == 0) - return &ppc32_linux_vsxregset; - return NULL; + int have_vsx = tdep->ppc_vr0_regnum != -1; + int have_altivec = tdep->ppc_vsr0_upper_regnum != -1; + int res; + + res = cb (tdep->wordsize == 4 ? + &ppc32_linux_gregset : &ppc64_linux_gregset, + cb_data); + if (!res) + res = cb (&ppc32_linux_fpregset, cb_data); + if (!res && have_altivec) + res = cb (&ppc32_linux_vrregset, cb_data); + if (!res && have_vsx) + cb (&ppc32_linux_vsxregset, cb_data); } static void @@ -1305,19 +1263,6 @@ ppc_linux_init_abi (struct gdbarch_info 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 +1304,6 @@ ppc_linux_init_abi (struct gdbarch_info 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 +1315,8 @@ ppc_linux_init_abi (struct gdbarch_info 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,