From patchwork Fri Nov 28 15:47:44 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulrich Weigand X-Patchwork-Id: 3990 Received: (qmail 29330 invoked by alias); 28 Nov 2014 15:47:54 -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 29317 invoked by uid 89); 28 Nov 2014 15:47:52 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.5 required=5.0 tests=AWL, BAYES_00, MSGID_FROM_MTA_HEADER, SPF_SOFTFAIL, T_RP_MATCHES_RCVD autolearn=no version=3.3.2 X-HELO: e37.co.us.ibm.com Received: from e37.co.us.ibm.com (HELO e37.co.us.ibm.com) (32.97.110.158) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-SHA encrypted) ESMTPS; Fri, 28 Nov 2014 15:47:51 +0000 Received: from /spool/local by e37.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 28 Nov 2014 08:47:49 -0700 Received: from d03dlp02.boulder.ibm.com (9.17.202.178) by e37.co.us.ibm.com (192.168.1.137) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Fri, 28 Nov 2014 08:47:48 -0700 Received: from b03cxnp08026.gho.boulder.ibm.com (b03cxnp08026.gho.boulder.ibm.com [9.17.130.18]) by d03dlp02.boulder.ibm.com (Postfix) with ESMTP id 447943E4003E for ; Fri, 28 Nov 2014 08:45:01 -0700 (MST) Received: from d03av02.boulder.ibm.com (d03av02.boulder.ibm.com [9.17.195.168]) by b03cxnp08026.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id sASFmWq247644918 for ; Fri, 28 Nov 2014 08:48:32 -0700 Received: from d03av02.boulder.ibm.com (localhost [127.0.0.1]) by d03av02.boulder.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id sASFllPA031274 for ; Fri, 28 Nov 2014 08:47:47 -0700 Received: from tuxmaker.boeblingen.de.ibm.com (tuxmaker.boeblingen.de.ibm.com [9.152.85.9]) by d03av02.boulder.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with SMTP id sASFliJL031137; Fri, 28 Nov 2014 08:47:45 -0700 Message-Id: <201411281547.sASFliJL031137@d03av02.boulder.ibm.com> Received: by tuxmaker.boeblingen.de.ibm.com (sSMTP sendmail emulation); Fri, 28 Nov 2014 16:47:44 +0100 Subject: [RFC/RFT] Use core regset iterators on GNU Hurd To: gdb-patches@sourceware.org Date: Fri, 28 Nov 2014 16:47:44 +0100 (CET) From: "Ulrich Weigand" Cc: ams@gnu.org, samuel.thibault@gnu.org MIME-Version: 1.0 X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 14112815-0025-0000-0000-00000674F114 Hello, GNU Hurd is one of the few remaining targets that still does not use the new-style iterate_over_regset_sections core file logic (allowing cross- debugging of core files and core file generation). Fortunately, it should be straightforward to enable to generic i386 logic here by simply providing an appropriate register map. I've extracted the necessary offsets from glibc headers for the Hurd. The patch is untested so far since I don't have access to a Hurd system. Testing by Hurd maintainers would be much appreciated. Bye, Ulrich ChangeLog: * config/i386/i386gnu.mh (NATDEPFILES): Remove core-regset.o. * i386gnu-nat.c: Do not include or "gregset.h". (CREG_OFFSET, creg_offset, CREG_ADDR): Remove. (supply_gregset, supply_fpregset): Remove. * i386gnu-tdep.c (i386gnu_gregset_reg_offset): New variable. (i386gnu_init_abi): Set tdep->gregset_reg_offset, gregset_num_regs, and sizeof_gregset. Index: binutils-gdb/gdb/config/i386/i386gnu.mh =================================================================== --- binutils-gdb.orig/gdb/config/i386/i386gnu.mh 2014-11-11 16:31:24.724883719 +0100 +++ binutils-gdb/gdb/config/i386/i386gnu.mh 2014-11-28 15:18:34.856204985 +0100 @@ -1,6 +1,6 @@ # Host: Intel 386 running the GNU Hurd NATDEPFILES= i386gnu-nat.o gnu-nat.o \ - x86-nat.o x86-dregs.o core-regset.o fork-child.o \ + x86-nat.o x86-dregs.o fork-child.o \ notify_S.o process_reply_S.o msg_reply_S.o \ msg_U.o exc_request_U.o exc_request_S.o HAVE_NATIVE_GCORE_HOST = 1 Index: binutils-gdb/gdb/i386gnu-nat.c =================================================================== --- binutils-gdb.orig/gdb/i386gnu-nat.c 2014-11-11 16:31:26.540893961 +0100 +++ binutils-gdb/gdb/i386gnu-nat.c 2014-11-28 15:18:34.865205046 +0100 @@ -34,11 +34,6 @@ #include "inf-child.h" #include "i387-tdep.h" -#ifdef HAVE_SYS_PROCFS_H -# include -# include "gregset.h" -#endif - /* Offset to the thread_state_t location where REG is stored. */ #define REG_OFFSET(reg) offsetof (struct i386_thread_state, reg) @@ -52,21 +47,7 @@ static int reg_offset[] = REG_OFFSET (ds), REG_OFFSET (es), REG_OFFSET (fs), REG_OFFSET (gs) }; -/* Offset to the greg_t location where REG is stored. */ -#define CREG_OFFSET(reg) (REG_##reg * 4) - -/* At CREG_OFFSET[N] is the offset to the greg_t location where - the GDB register N is stored. */ -static int creg_offset[] = -{ - CREG_OFFSET (EAX), CREG_OFFSET (ECX), CREG_OFFSET (EDX), CREG_OFFSET (EBX), - CREG_OFFSET (UESP), CREG_OFFSET (EBP), CREG_OFFSET (ESI), CREG_OFFSET (EDI), - CREG_OFFSET (EIP), CREG_OFFSET (EFL), CREG_OFFSET (CS), CREG_OFFSET (SS), - CREG_OFFSET (DS), CREG_OFFSET (ES), CREG_OFFSET (FS), CREG_OFFSET (GS) -}; - #define REG_ADDR(state, regnum) ((char *)(state) + reg_offset[regnum]) -#define CREG_ADDR(state, regnum) ((const char *)(state) + creg_offset[regnum]) /* Get the whole floating-point state of THREAD and record the values @@ -100,24 +81,6 @@ fetch_fpregs (struct regcache *regcache, } } -#ifdef HAVE_SYS_PROCFS_H -/* These two calls are used by the core-regset.c code for - reading ELF core files. */ -void -supply_gregset (struct regcache *regcache, const gdb_gregset_t *gregs) -{ - int i; - for (i = 0; i < I386_NUM_GREGS; i++) - regcache_raw_supply (regcache, i, CREG_ADDR (gregs, i)); -} - -void -supply_fpregset (struct regcache *regcache, const gdb_fpregset_t *fpregs) -{ - i387_supply_fsave (regcache, -1, fpregs); -} -#endif - /* Fetch register REGNO, or all regs if REGNO is -1. */ static void gnu_fetch_registers (struct target_ops *ops, Index: binutils-gdb/gdb/i386gnu-tdep.c =================================================================== --- binutils-gdb.orig/gdb/i386gnu-tdep.c 2014-11-11 16:31:26.543893979 +0100 +++ binutils-gdb/gdb/i386gnu-tdep.c 2014-11-28 15:18:34.869205072 +0100 @@ -22,6 +22,27 @@ #include "i386-tdep.h" +/* From . */ +static int i386gnu_gregset_reg_offset[] = +{ + 11 * 4, /* %eax */ + 10 * 4, /* %ecx */ + 9 * 4, /* %edx */ + 8 * 4, /* %ebx */ + 17 * 4, /* %uesp */ + 6 * 4, /* %ebp */ + 5 * 4, /* %esi */ + 4 * 4, /* %edi */ + 14 * 4, /* %eip */ + 16 * 4, /* %efl */ + 15 * 4, /* %cs */ + 18 * 4, /* %ss */ + 3 * 4, /* %ds */ + 2 * 4, /* %es */ + 1 * 4, /* %fs */ + 0 * 4, /* %gs */ +}; + static void i386gnu_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch) { @@ -33,6 +54,10 @@ i386gnu_init_abi (struct gdbarch_info in set_solib_svr4_fetch_link_map_offsets (gdbarch, svr4_ilp32_fetch_link_map_offsets); + tdep->gregset_reg_offset = i386gnu_gregset_reg_offset; + tdep->gregset_num_regs = ARRAY_SIZE (i386gnu_gregset_reg_offset); + tdep->sizeof_gregset = 19 * 4; + tdep->jb_pc_offset = 20; /* From . */ }