From patchwork Fri Sep 12 15:39:39 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Arnez X-Patchwork-Id: 2794 Received: (qmail 31627 invoked by alias); 12 Sep 2014 15:40:10 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 31395 invoked by uid 89); 12 Sep 2014 15:40:09 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.4 required=5.0 tests=AWL, BAYES_00, RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: e06smtp15.uk.ibm.com Received: from e06smtp15.uk.ibm.com (HELO e06smtp15.uk.ibm.com) (195.75.94.111) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-SHA encrypted) ESMTPS; Fri, 12 Sep 2014 15:40:06 +0000 Received: from /spool/local by e06smtp15.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 12 Sep 2014 16:40:01 +0100 Received: from d06dlp02.portsmouth.uk.ibm.com (9.149.20.14) by e06smtp15.uk.ibm.com (192.168.101.145) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Fri, 12 Sep 2014 16:40:00 +0100 Received: from b06cxnps4075.portsmouth.uk.ibm.com (d06relay12.portsmouth.uk.ibm.com [9.149.109.197]) by d06dlp02.portsmouth.uk.ibm.com (Postfix) with ESMTP id 283C42190023 for ; Fri, 12 Sep 2014 16:39:40 +0100 (BST) Received: from d06av06.portsmouth.uk.ibm.com (d06av06.portsmouth.uk.ibm.com [9.149.37.217]) by b06cxnps4075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id s8CFdxOq42008578 for ; Fri, 12 Sep 2014 15:39:59 GMT Received: from d06av06.portsmouth.uk.ibm.com (localhost [127.0.0.1]) by d06av06.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id s8CAcOUj014893 for ; Fri, 12 Sep 2014 06:38:25 -0400 Received: from br87z6lw.boeblingen.de.ibm.com (dyn-9-152-212-196.boeblingen.de.ibm.com [9.152.212.196]) by d06av06.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id s8CAcL6l014757; Fri, 12 Sep 2014 06:38:24 -0400 From: Andreas Arnez To: gdb-patches@sourceware.org Cc: Mark Kettenis Subject: [PATCH 09/26] X86: Migrate from 'regset_from_core_section' to 'iterate_over_regset_sections' Date: Fri, 12 Sep 2014 17:39:39 +0200 Message-Id: <1410536396-25524-10-git-send-email-arnez@linux.vnet.ibm.com> In-Reply-To: <1410536396-25524-1-git-send-email-arnez@linux.vnet.ibm.com> References: <1410536396-25524-1-git-send-email-arnez@linux.vnet.ibm.com> X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 14091215-0342-0000-0000-00000109B442 X-IsSubscribed: yes For all I386 and AMD64 targets, replace all occurrences of regset_from_core_section by the iterator method. gdb/ChangeLog: * amd64obsd-tdep.c (amd64obsd_regset_from_core_section): Remove. (amd64obsd_iterate_over_regset_sections): New. (amd64obsd_core_init_abi): Adjust gdbarch initialization. * i386-cygwin-tdep.c (i386_windows_regset_from_core_section): Remove. (i386_cygwin_init_abi): Clear tdep->sizeof_fpregset. Drop regset_from_core_section initialization. * i386-tdep.c (i386_regset_from_core_section): Remove. (i386_iterate_over_regset_sections): New. (i386_gdbarch_init): Adjust gdbarch initialization. * i386-tdep.h (i386_regset_from_core_section): Remove prototype. (i386_iterate_over_regset_sections): New prototype. * i386obsd-tdep.c (i386obsd_aout_regset_from_core_section): Remove. (i386obsd_aout_iterate_over_regset_sections): New. (i386obsd_aout_init_abi): Adjust gdbarch initialization. * configure.tgt (gdb_target_obs): Add fbsd-tdep.o for all x86 FreeBSD targets. * amd64fbsd-tdep.c (fbsd-tdep.h): Include. (amd64fbsd_init_abi): Call fbsd_init_abi. * i386fbsd-tdep.c (fbsd-tdep.h): Include. (i386fbsd4_init_abi): Call fbsd_init_abi. * amd64fbsd-nat.c (_initialize_amd64fbsd_nat): No longer set target method 'make_corefile_notes'. * i386fbsd-nat.c (_initialize_i386fbsd_nat): Likewise. --- gdb/amd64fbsd-nat.c | 1 - gdb/amd64fbsd-tdep.c | 4 ++++ gdb/amd64obsd-tdep.c | 19 +++++++++---------- gdb/configure.tgt | 4 ++-- gdb/i386-cygwin-tdep.c | 18 ++---------------- gdb/i386-tdep.c | 26 +++++++++++--------------- gdb/i386-tdep.h | 12 ++++++------ gdb/i386fbsd-nat.c | 1 - gdb/i386fbsd-tdep.c | 4 ++++ gdb/i386obsd-tdep.c | 20 +++++++++----------- 10 files changed, 47 insertions(+), 62 deletions(-) diff --git a/gdb/amd64fbsd-nat.c b/gdb/amd64fbsd-nat.c index fe4e009..df101d0 100644 --- a/gdb/amd64fbsd-nat.c +++ b/gdb/amd64fbsd-nat.c @@ -183,7 +183,6 @@ _initialize_amd64fbsd_nat (void) t->to_pid_to_exec_file = fbsd_pid_to_exec_file; t->to_find_memory_regions = fbsd_find_memory_regions; - t->to_make_corefile_notes = fbsd_make_corefile_notes; add_target (t); /* Support debugging kernel virtual memory images. */ diff --git a/gdb/amd64fbsd-tdep.c b/gdb/amd64fbsd-tdep.c index 07b065a..13e14ad 100644 --- a/gdb/amd64fbsd-tdep.c +++ b/gdb/amd64fbsd-tdep.c @@ -26,6 +26,7 @@ #include "amd64-tdep.h" #include "bsd-uthread.h" +#include "fbsd-tdep.h" #include "solib-svr4.h" /* Support for signal handlers. */ @@ -182,6 +183,9 @@ amd64fbsd_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch) { struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + /* Generic FreeBSD support. */ + fbsd_init_abi (info, gdbarch); + /* Obviously FreeBSD is BSD-based. */ i386bsd_init_abi (info, gdbarch); diff --git a/gdb/amd64obsd-tdep.c b/gdb/amd64obsd-tdep.c index ef0c0c2..80300c8 100644 --- a/gdb/amd64obsd-tdep.c +++ b/gdb/amd64obsd-tdep.c @@ -57,20 +57,19 @@ static const struct regset amd64obsd_combined_regset = NULL, amd64obsd_supply_regset, NULL }; -static const struct regset * -amd64obsd_regset_from_core_section (struct gdbarch *gdbarch, - const char *sect_name, size_t sect_size) +static void +amd64obsd_iterate_over_regset_sections (struct gdbarch *gdbarch, + iterate_over_regset_sections_cb *cb, + void *cb_data, + const struct regcache *regcache) { struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); /* OpenBSD core dumps don't use seperate register sets for the general-purpose and floating-point registers. */ - if (strcmp (sect_name, ".reg") == 0 - && sect_size >= tdep->sizeof_gregset + I387_SIZEOF_FXSAVE) - return &amd64obsd_combined_regset; - - return NULL; + cb (".reg", tdep->sizeof_gregset + I387_SIZEOF_FXSAVE, + &amd64obsd_combined_regset, NULL, cb_data); } @@ -492,8 +491,8 @@ amd64obsd_core_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch) { amd64obsd_init_abi (info, gdbarch); - set_gdbarch_regset_from_core_section - (gdbarch, amd64obsd_regset_from_core_section); + set_gdbarch_iterate_over_regset_sections + (gdbarch, amd64obsd_iterate_over_regset_sections); } diff --git a/gdb/configure.tgt b/gdb/configure.tgt index 01311b2..4b09d3a 100644 --- a/gdb/configure.tgt +++ b/gdb/configure.tgt @@ -189,7 +189,7 @@ i[34567]86-*-dicos*) i[34567]86-*-freebsd* | i[34567]86-*-kfreebsd*-gnu) # Target: FreeBSD/i386 gdb_target_obs="i386-tdep.o i387-tdep.o i386bsd-tdep.o i386fbsd-tdep.o \ - bsd-uthread.o solib-svr4.o" + bsd-uthread.o fbsd-tdep.o solib-svr4.o" ;; i[34567]86-*-netbsd* | i[34567]86-*-knetbsd*-gnu) # Target: NetBSD/i386 @@ -667,7 +667,7 @@ x86_64-*-freebsd* | x86_64-*-kfreebsd*-gnu) # Target: FreeBSD/amd64 gdb_target_obs="amd64-tdep.o amd64fbsd-tdep.o i386-tdep.o \ i387-tdep.o i386bsd-tdep.o i386fbsd-tdep.o \ - bsd-uthread.o solib-svr4.o" + bsd-uthread.o fbsd-tdep.o solib-svr4.o" ;; x86_64-*-mingw* | x86_64-*-cygwin*) # Target: MingW/amd64 diff --git a/gdb/i386-cygwin-tdep.c b/gdb/i386-cygwin-tdep.c index 47c7bde..b8793c1 100644 --- a/gdb/i386-cygwin-tdep.c +++ b/gdb/i386-cygwin-tdep.c @@ -88,20 +88,6 @@ static int i386_windows_gregset_reg_offset[] = #define I386_WINDOWS_SIZEOF_GREGSET 716 -/* Return the appropriate register set for the core section identified - by SECT_NAME and SECT_SIZE. */ - -static const struct regset * -i386_windows_regset_from_core_section (struct gdbarch *gdbarch, - const char *sect_name, size_t sect_size) -{ - if (strcmp (sect_name, ".reg") == 0 - && sect_size == I386_WINDOWS_SIZEOF_GREGSET) - return &i386_gregset; - - return NULL; -} - struct cpms_data { struct gdbarch *gdbarch; @@ -235,9 +221,9 @@ i386_cygwin_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch) tdep->gregset_num_regs = ARRAY_SIZE (i386_windows_gregset_reg_offset); tdep->sizeof_gregset = I386_WINDOWS_SIZEOF_GREGSET; + tdep->sizeof_fpregset = 0; + /* Core file support. */ - set_gdbarch_regset_from_core_section - (gdbarch, i386_windows_regset_from_core_section); set_gdbarch_core_xfer_shared_libraries (gdbarch, windows_core_xfer_shared_libraries); set_gdbarch_core_pid_to_str (gdbarch, i386_windows_core_pid_to_str); diff --git a/gdb/i386-tdep.c b/gdb/i386-tdep.c index 8f8cc99..f685a6a 100644 --- a/gdb/i386-tdep.c +++ b/gdb/i386-tdep.c @@ -3818,22 +3818,19 @@ const struct regset i386_fpregset = NULL, i386_supply_fpregset, i386_collect_fpregset }; -/* Return the appropriate register set for the core section identified - by SECT_NAME and SECT_SIZE. */ +/* Default iterator over core file register note sections. */ -const struct regset * -i386_regset_from_core_section (struct gdbarch *gdbarch, - const char *sect_name, size_t sect_size) +void +i386_iterate_over_regset_sections (struct gdbarch *gdbarch, + iterate_over_regset_sections_cb *cb, + void *cb_data, + const struct regcache *regcache) { struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); - if (strcmp (sect_name, ".reg") == 0 && sect_size == tdep->sizeof_gregset) - return &i386_gregset; - - if (strcmp (sect_name, ".reg2") == 0 && sect_size == tdep->sizeof_fpregset) - return tdep->fpregset; - - return NULL; + cb (".reg", tdep->sizeof_gregset, &i386_gregset, NULL, cb_data); + if (tdep->sizeof_fpregset) + cb (".reg2", tdep->sizeof_fpregset, tdep->fpregset, NULL, cb_data); } @@ -8566,10 +8563,9 @@ i386_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) /* If we have a register mapping, enable the generic core file support, unless it has already been enabled. */ if (tdep->gregset_reg_offset - && !gdbarch_regset_from_core_section_p (gdbarch) && !gdbarch_iterate_over_regset_sections_p (gdbarch)) - set_gdbarch_regset_from_core_section (gdbarch, - i386_regset_from_core_section); + set_gdbarch_iterate_over_regset_sections + (gdbarch, i386_iterate_over_regset_sections); set_gdbarch_skip_permanent_breakpoint (gdbarch, i386_skip_permanent_breakpoint); diff --git a/gdb/i386-tdep.h b/gdb/i386-tdep.h index db8f4f7..90f4007 100644 --- a/gdb/i386-tdep.h +++ b/gdb/i386-tdep.h @@ -393,12 +393,12 @@ extern const struct regset i386_gregset; /* Floating-point register set. */ extern const struct regset i386_fpregset; -/* Return the appropriate register set for the core section identified - by SECT_NAME and SECT_SIZE. */ -extern const struct regset * - i386_regset_from_core_section (struct gdbarch *gdbarch, - const char *sect_name, size_t sect_size); - +/* Default iterator over core file register note sections. */ +extern void + i386_iterate_over_regset_sections (struct gdbarch *gdbarch, + iterate_over_regset_sections_cb *cb, + void *cb_data, + const struct regcache *regcache); extern struct displaced_step_closure *i386_displaced_step_copy_insn (struct gdbarch *gdbarch, CORE_ADDR from, CORE_ADDR to, diff --git a/gdb/i386fbsd-nat.c b/gdb/i386fbsd-nat.c index 754677f..6fafbf0 100644 --- a/gdb/i386fbsd-nat.c +++ b/gdb/i386fbsd-nat.c @@ -143,7 +143,6 @@ _initialize_i386fbsd_nat (void) t->to_resume = i386fbsd_resume; t->to_pid_to_exec_file = fbsd_pid_to_exec_file; t->to_find_memory_regions = fbsd_find_memory_regions; - t->to_make_corefile_notes = fbsd_make_corefile_notes; add_target (t); /* Support debugging kernel virtual memory images. */ diff --git a/gdb/i386fbsd-tdep.c b/gdb/i386fbsd-tdep.c index 8942ad3..b37427f 100644 --- a/gdb/i386fbsd-tdep.c +++ b/gdb/i386fbsd-tdep.c @@ -26,6 +26,7 @@ #include "i386-tdep.h" #include "i387-tdep.h" #include "bsd-uthread.h" +#include "fbsd-tdep.h" #include "solib-svr4.h" /* FreeBSD 3.0-RELEASE or later. */ @@ -204,6 +205,9 @@ i386fbsd4_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch) { struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + /* Generic FreeBSD support. */ + fbsd_init_abi (info, gdbarch); + /* Inherit stuff from older releases. We assume that FreeBSD 4.0-RELEASE always uses ELF. */ i386fbsd_init_abi (info, gdbarch); diff --git a/gdb/i386obsd-tdep.c b/gdb/i386obsd-tdep.c index 2b7d48b..1fd414f 100644 --- a/gdb/i386obsd-tdep.c +++ b/gdb/i386obsd-tdep.c @@ -154,21 +154,19 @@ static const struct regset i386obsd_aout_gregset = NULL, i386obsd_aout_supply_regset, NULL }; -static const struct regset * -i386obsd_aout_regset_from_core_section (struct gdbarch *gdbarch, - const char *sect_name, - size_t sect_size) +static void +i386obsd_aout_iterate_over_regset_sections (struct gdbarch *gdbarch, + iterate_over_regset_sections_cb *cb, + void *cb_data, + const struct regcache *regcache) { struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); /* OpenBSD a.out core dumps don't use seperate register sets for the general-purpose and floating-point registers. */ - if (strcmp (sect_name, ".reg") == 0 - && sect_size >= tdep->sizeof_gregset + I387_SIZEOF_FSAVE) - return &i386obsd_aout_gregset; - - return NULL; + cb (".reg", tdep->sizeof_gregset + I387_SIZEOF_FSAVE, + &i386obsd_aout_gregset, NULL, cb_data); } @@ -482,8 +480,8 @@ i386obsd_aout_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch) i386obsd_init_abi (info, gdbarch); /* OpenBSD a.out has a single register set. */ - set_gdbarch_regset_from_core_section - (gdbarch, i386obsd_aout_regset_from_core_section); + set_gdbarch_iterate_over_regset_sections + (gdbarch, i386obsd_aout_iterate_over_regset_sections); } /* OpenBSD ELF. */