From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 28406 invoked by alias); 25 Jun 2014 16:49:23 -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 28262 invoked by uid 89); 25 Jun 2014 16:49:22 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.3 required=5.0 tests=AWL,BAYES_00,T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: e06smtp12.uk.ibm.com Received: from e06smtp12.uk.ibm.com (HELO e06smtp12.uk.ibm.com) (195.75.94.108) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-SHA encrypted) ESMTPS; Wed, 25 Jun 2014 16:49:17 +0000 Received: from /spool/local by e06smtp12.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 25 Jun 2014 17:49:14 +0100 Received: from d06dlp03.portsmouth.uk.ibm.com (9.149.20.15) by e06smtp12.uk.ibm.com (192.168.101.142) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Wed, 25 Jun 2014 17:49:12 +0100 Received: from b06cxnps3074.portsmouth.uk.ibm.com (d06relay09.portsmouth.uk.ibm.com [9.149.109.194]) by d06dlp03.portsmouth.uk.ibm.com (Postfix) with ESMTP id 8145A1B08040 for ; Wed, 25 Jun 2014 17:49:44 +0100 (BST) Received: from d06av04.portsmouth.uk.ibm.com (d06av04.portsmouth.uk.ibm.com [9.149.37.216]) by b06cxnps3074.portsmouth.uk.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id s5PGnCDs32637174 for ; Wed, 25 Jun 2014 16:49:12 GMT Received: from d06av04.portsmouth.uk.ibm.com (localhost [127.0.0.1]) by d06av04.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id s5PGnB0b024891 for ; Wed, 25 Jun 2014 10:49:11 -0600 Received: from br87z6lw.boeblingen.de.ibm.com (dyn-9-152-212-196.boeblingen.de.ibm.com [9.152.212.196]) by d06av04.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id s5PGn9Gs024835; Wed, 25 Jun 2014 10:49:10 -0600 From: Andreas Arnez To: gdb-patches@sourceware.org Cc: Ulrich Weigand Subject: [PATCH v2 03/13] S390: Migrate to regcache_supply/collect_regset. Date: Wed, 25 Jun 2014 16:49:00 -0000 Message-Id: <1403714949-28133-4-git-send-email-arnez@linux.vnet.ibm.com> In-Reply-To: <1403714949-28133-1-git-send-email-arnez@linux.vnet.ibm.com> References: <1403714949-28133-1-git-send-email-arnez@linux.vnet.ibm.com> X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 14062516-8372-0000-0000-00000052EEAA X-IsSubscribed: yes X-SW-Source: 2014-06/txt/msg00882.txt.bz2 Rather than supplying own supply/collect functions, use the generic functions regcache_supply_regset and regcache_collect_regset instead. The register maps are rewritten accordingly and become much shorter (and better readable) than before. gdb/ * s390-linux-nat.c: Include "regset.h". (regmap_gregset): Delete macro. (s390_64_regmap_gregset): New register map for regcache_supply/_collect_regset. (s390_64_gregset): New regset. (S390_PSWM_OFFSET, S390_PSWA_OFFSET): New macros. (regmap_fpregset): Delete macro. (s390_native_supply, s390_native_collect): Delete functions. (supply_gregset, fill_gregset): Replace s390-specific regmap handling by a call to regcache_supply/_collect_regset. (supply_fpregset, fill_fpregset): Call regcache_supply/ _collect_regset instead of s390_native_supply/_collect. (fetch_regset, store_regset): Likewise. Also change the last parameter to a regset instead of a regmap. (s390_linux_fetch_inferior_registers) (390_linux_store_inferior_registers): Adjust last parameter in calls to fetch_regset and store_regset. * s390-linux-tdep.c (s390_regmap_gregset): Rename to... (s390_gregmap): ... this. Also make static const and convert to regcache_map_entry format. (s390x_regmap_gregset): Delete. (s390_regmap_fpregset): Rename to... (s390_fpregmap): ... this. Make static const and convert to regcache_map_entry format. (s390_regmap_upper, s390_regmap_last_break) (s390x_regmap_last_break, s390_regmap_system_call) (s390_regmap_tdb): Likewise. (s390_supply_regset, s390_collect_regset): Remove functions. (s390_supply_tdb_regset): Call regcache_supply_regset instead of s390_supply_regset. (s390_gregset, s390_fpregset, s390_upper_regset) (s390_last_break_regset, s390x_last_break_regset) (s390_system_call_regset, s390_tdb_regset): Make global and replace s390_supply/_collect_regset by regcache_supply/ _collect_regset. (s390x_gregset): Delete. (s390_gdbarch_init): Replace s390x_gregset by s390_gregset. * s390-linux-tdep.h (s390_regmap_gregset, s390x_regmap_gregset) (s390_regmap_fpregset, s390_regmap_last_break) (s390x_regmap_last_break, s390_regmap_system_call) (s390_regmap_tdb): Delete global variable declarations. (s390_gregset, s390_fpregset, s390_last_break_regset) (s390x_last_break_regset, s390_system_call_regset) (s390_tdb_regset): New global variable declarations. --- gdb/s390-linux-nat.c | 177 ++++++++++++++------------------ gdb/s390-linux-tdep.c | 278 +++++++++++--------------------------------------- gdb/s390-linux-tdep.h | 13 ++- 3 files changed, 140 insertions(+), 328 deletions(-) diff --git a/gdb/s390-linux-nat.c b/gdb/s390-linux-nat.c index 45db7c9..8d8cf59 100644 --- a/gdb/s390-linux-nat.c +++ b/gdb/s390-linux-nat.c @@ -26,6 +26,7 @@ #include "linux-nat.h" #include "auxv.h" #include "gregset.h" +#include "regset.h" #include "s390-linux-tdep.h" #include "elf/common.h" @@ -49,42 +50,46 @@ static int have_regset_last_break = 0; static int have_regset_system_call = 0; static int have_regset_tdb = 0; -/* Map registers to gregset/ptrace offsets. - These arrays are defined in s390-tdep.c. */ +/* Register map for 32-bit executables running under a 64-bit + kernel. */ #ifdef __s390x__ -#define regmap_gregset s390x_regmap_gregset -#else -#define regmap_gregset s390_regmap_gregset +static const struct regcache_map_entry s390_64_regmap_gregset[] = + { + /* Skip PSWM and PSWA, since they must be handled specially. */ + { 16, REGCACHE_MAP_SKIP_BYTES }, + { 1, S390_R0_UPPER_REGNUM }, { 1, S390_R0_REGNUM }, + { 1, S390_R1_UPPER_REGNUM }, { 1, S390_R1_REGNUM }, + { 1, S390_R2_UPPER_REGNUM }, { 1, S390_R2_REGNUM }, + { 1, S390_R3_UPPER_REGNUM }, { 1, S390_R3_REGNUM }, + { 1, S390_R4_UPPER_REGNUM }, { 1, S390_R4_REGNUM }, + { 1, S390_R5_UPPER_REGNUM }, { 1, S390_R5_REGNUM }, + { 1, S390_R6_UPPER_REGNUM }, { 1, S390_R6_REGNUM }, + { 1, S390_R7_UPPER_REGNUM }, { 1, S390_R7_REGNUM }, + { 1, S390_R8_UPPER_REGNUM }, { 1, S390_R8_REGNUM }, + { 1, S390_R9_UPPER_REGNUM }, { 1, S390_R9_REGNUM }, + { 1, S390_R10_UPPER_REGNUM }, { 1, S390_R10_REGNUM }, + { 1, S390_R11_UPPER_REGNUM }, { 1, S390_R11_REGNUM }, + { 1, S390_R12_UPPER_REGNUM }, { 1, S390_R12_REGNUM }, + { 1, S390_R13_UPPER_REGNUM }, { 1, S390_R13_REGNUM }, + { 1, S390_R14_UPPER_REGNUM }, { 1, S390_R14_REGNUM }, + { 1, S390_R15_UPPER_REGNUM }, { 1, S390_R15_REGNUM }, + { 16, S390_A0_REGNUM }, + { 4, REGCACHE_MAP_SKIP_BYTES }, { 1, S390_ORIG_R2_REGNUM }, + { 0 } + }; + +static const struct regset s390_64_gregset = + { + s390_64_regmap_gregset, + regcache_supply_regset, + regcache_collect_regset + }; + +#define S390_PSWM_OFFSET 0 +#define S390_PSWA_OFFSET 8 #endif -#define regmap_fpregset s390_regmap_fpregset - -/* Fill the regset described by MAP into REGCACHE, using the values - from REGP. The MAP array represents each register as a pair - (offset, regno) of short integers and is terminated with -1. */ - -static void -s390_native_supply (struct regcache *regcache, const short *map, - const gdb_byte *regp) -{ - for (; map[0] >= 0; map += 2) - regcache_raw_supply (regcache, map[1], regp ? regp + map[0] : NULL); -} - -/* Collect the register REGNO out of the regset described by MAP from - REGCACHE into REGP. If REGNO == -1, do this for all registers in - this regset. */ - -static void -s390_native_collect (const struct regcache *regcache, const short *map, - int regno, gdb_byte *regp) -{ - for (; map[0] >= 0; map += 2) - if (regno == -1 || regno == map[1]) - regcache_raw_collect (regcache, map[1], regp + map[0]); -} - /* Fill GDB's register array with the general-purpose register values in *REGP. @@ -100,28 +105,15 @@ supply_gregset (struct regcache *regcache, const gregset_t *regp) if (gdbarch_ptr_bit (gdbarch) == 32) { enum bfd_endian byte_order = gdbarch_byte_order (gdbarch); - ULONGEST pswm = 0, pswa = 0; + ULONGEST pswm, pswa; gdb_byte buf[4]; - const short *map; - - for (map = regmap_gregset; map[0] >= 0; map += 2) - { - const gdb_byte *p = (const gdb_byte *) regp + map[0]; - int regno = map[1]; - - if (regno == S390_PSWM_REGNUM) - pswm = extract_unsigned_integer (p, 8, byte_order); - else if (regno == S390_PSWA_REGNUM) - pswa = extract_unsigned_integer (p, 8, byte_order); - else - { - if ((regno >= S390_R0_REGNUM && regno <= S390_R15_REGNUM) - || regno == S390_ORIG_R2_REGNUM) - p += 4; - regcache_raw_supply (regcache, regno, p); - } - } + regcache_supply_regset (&s390_64_gregset, regcache, -1, + regp, sizeof (gregset_t)); + pswm = extract_unsigned_integer ((const gdb_byte *) regp + + S390_PSWM_OFFSET, 8, byte_order); + pswa = extract_unsigned_integer ((const gdb_byte *) regp + + S390_PSWA_OFFSET, 8, byte_order); store_unsigned_integer (buf, 4, byte_order, (pswm >> 32) | 0x80000); regcache_raw_supply (regcache, S390_PSWM_REGNUM, buf); store_unsigned_integer (buf, 4, byte_order, @@ -131,7 +123,8 @@ supply_gregset (struct regcache *regcache, const gregset_t *regp) } #endif - s390_native_supply (regcache, regmap_gregset, (const gdb_byte *) regp); + regcache_supply_regset (&s390_gregset, regcache, -1, regp, + sizeof (gregset_t)); } /* Fill register REGNO (if it is a general-purpose register) in @@ -145,28 +138,8 @@ fill_gregset (const struct regcache *regcache, gregset_t *regp, int regno) struct gdbarch *gdbarch = get_regcache_arch (regcache); if (gdbarch_ptr_bit (gdbarch) == 32) { - gdb_byte *psw_p[2]; - const short *map; - - for (map = regmap_gregset; map[0] >= 0; map += 2) - { - gdb_byte *p = (gdb_byte *) regp + map[0]; - int reg = map[1]; - - if (reg >= S390_PSWM_REGNUM && reg <= S390_PSWA_REGNUM) - psw_p[reg - S390_PSWM_REGNUM] = p; - - else if (regno == -1 || regno == reg) - { - if ((reg >= S390_R0_REGNUM && reg <= S390_R15_REGNUM) - || reg == S390_ORIG_R2_REGNUM) - { - memset (p, 0, 4); - p += 4; - } - regcache_raw_collect (regcache, reg, p); - } - } + regcache_collect_regset (&s390_64_gregset, regcache, regno, + regp, sizeof (gregset_t)); if (regno == -1 || regno == S390_PSWM_REGNUM || regno == S390_PSWA_REGNUM) @@ -181,18 +154,19 @@ fill_gregset (const struct regcache *regcache, gregset_t *regp, int regno) pswa = extract_unsigned_integer (buf, 4, byte_order); if (regno == -1 || regno == S390_PSWM_REGNUM) - store_unsigned_integer (psw_p[0], 8, byte_order, - ((pswm & 0xfff7ffff) << 32) | + store_unsigned_integer ((gdb_byte *) regp + S390_PSWM_OFFSET, 8, + byte_order, ((pswm & 0xfff7ffff) << 32) | (pswa & 0x80000000)); if (regno == -1 || regno == S390_PSWA_REGNUM) - store_unsigned_integer (psw_p[1], 8, byte_order, - pswa & 0x7fffffff); + store_unsigned_integer ((gdb_byte *) regp + S390_PSWA_OFFSET, 8, + byte_order, pswa & 0x7fffffff); } return; } #endif - s390_native_collect (regcache, regmap_gregset, regno, (gdb_byte *) regp); + regcache_collect_regset (&s390_gregset, regcache, regno, regp, + sizeof (gregset_t)); } /* Fill GDB's register array with the floating-point register values @@ -200,7 +174,8 @@ fill_gregset (const struct regcache *regcache, gregset_t *regp, int regno) void supply_fpregset (struct regcache *regcache, const fpregset_t *regp) { - s390_native_supply (regcache, regmap_fpregset, (const gdb_byte *) regp); + regcache_supply_regset (&s390_fpregset, regcache, -1, regp, + sizeof (fpregset_t)); } /* Fill register REGNO (if it is a general-purpose register) in @@ -209,7 +184,8 @@ supply_fpregset (struct regcache *regcache, const fpregset_t *regp) void fill_fpregset (const struct regcache *regcache, fpregset_t *regp, int regno) { - s390_native_collect (regcache, regmap_fpregset, regno, (gdb_byte *) regp); + regcache_collect_regset (&s390_fpregset, regcache, regno, regp, + sizeof (fpregset_t)); } /* Find the TID for the current inferior thread to use with ptrace. */ @@ -298,12 +274,13 @@ store_fpregs (const struct regcache *regcache, int tid, int regnum) perror_with_name (_("Couldn't write floating point status")); } -/* Fetch all registers in the kernel's register set whose number is REGSET, - whose size is REGSIZE, and whose layout is described by REGMAP, from - process/thread TID and store their values in GDB's register cache. */ +/* Fetch all registers in the kernel's register set whose number is + REGSET_ID, whose size is REGSIZE, and whose layout is described by + REGSET, from process/thread TID and store their values in GDB's + register cache. */ static void fetch_regset (struct regcache *regcache, int tid, - int regset, int regsize, const short *regmap) + int regset_id, int regsize, const struct regset *regset) { gdb_byte *buf = alloca (regsize); struct iovec iov; @@ -311,23 +288,23 @@ fetch_regset (struct regcache *regcache, int tid, iov.iov_base = buf; iov.iov_len = regsize; - if (ptrace (PTRACE_GETREGSET, tid, (long) regset, (long) &iov) < 0) + if (ptrace (PTRACE_GETREGSET, tid, (long) regset_id, (long) &iov) < 0) { if (errno == ENODATA) - s390_native_supply (regcache, regmap, NULL); + regcache_supply_regset (regset, regcache, -1, NULL, regsize); else perror_with_name (_("Couldn't get register set")); } else - s390_native_supply (regcache, regmap, buf); + regcache_supply_regset (regset, regcache, -1, buf, regsize); } -/* Store all registers in the kernel's register set whose number is REGSET, - whose size is REGSIZE, and whose layout is described by REGMAP, from - GDB's register cache back to process/thread TID. */ +/* Store all registers in the kernel's register set whose number is + REGSET_ID, whose size is REGSIZE, and whose layout is described by + REGSET, from GDB's register cache back to process/thread TID. */ static void store_regset (struct regcache *regcache, int tid, - int regset, int regsize, const short *regmap) + int regset_id, int regsize, const struct regset *regset) { gdb_byte *buf = alloca (regsize); struct iovec iov; @@ -335,12 +312,12 @@ store_regset (struct regcache *regcache, int tid, iov.iov_base = buf; iov.iov_len = regsize; - if (ptrace (PTRACE_GETREGSET, tid, (long) regset, (long) &iov) < 0) + if (ptrace (PTRACE_GETREGSET, tid, (long) regset_id, (long) &iov) < 0) perror_with_name (_("Couldn't get register set")); - s390_native_collect (regcache, regmap, -1, buf); + regcache_collect_regset (regset, regcache, -1, buf, regsize); - if (ptrace (PTRACE_SETREGSET, tid, (long) regset, (long) &iov) < 0) + if (ptrace (PTRACE_SETREGSET, tid, (long) regset_id, (long) &iov) < 0) perror_with_name (_("Couldn't set register set")); } @@ -379,17 +356,17 @@ s390_linux_fetch_inferior_registers (struct target_ops *ops, if (regnum == -1 || regnum == S390_LAST_BREAK_REGNUM) fetch_regset (regcache, tid, NT_S390_LAST_BREAK, 8, (gdbarch_ptr_bit (get_regcache_arch (regcache)) == 32 - ? s390_regmap_last_break : s390x_regmap_last_break)); + ? &s390_last_break_regset : &s390x_last_break_regset)); if (have_regset_system_call) if (regnum == -1 || regnum == S390_SYSTEM_CALL_REGNUM) fetch_regset (regcache, tid, NT_S390_SYSTEM_CALL, 4, - s390_regmap_system_call); + &s390_system_call_regset); if (have_regset_tdb) if (regnum == -1 || S390_IS_TDBREGSET_REGNUM (regnum)) fetch_regset (regcache, tid, NT_S390_TDB, s390_sizeof_tdbregset, - s390_regmap_tdb); + &s390_tdb_regset); } /* Store register REGNUM back into the child process. If REGNUM is @@ -411,7 +388,7 @@ s390_linux_store_inferior_registers (struct target_ops *ops, if (have_regset_system_call) if (regnum == -1 || regnum == S390_SYSTEM_CALL_REGNUM) store_regset (regcache, tid, NT_S390_SYSTEM_CALL, 4, - s390_regmap_system_call); + &s390_system_call_regset); } diff --git a/gdb/s390-linux-tdep.c b/gdb/s390-linux-tdep.c index 3658033..f67ba9c 100644 --- a/gdb/s390-linux-tdep.c +++ b/gdb/s390-linux-tdep.c @@ -420,204 +420,61 @@ s390_pseudo_register_reggroup_p (struct gdbarch *gdbarch, int regnum, /* Maps for register sets. */ -const short s390_regmap_gregset[] = +static const struct regcache_map_entry s390_gregmap[] = { - 0x00, S390_PSWM_REGNUM, - 0x04, S390_PSWA_REGNUM, - 0x08, S390_R0_REGNUM, - 0x0c, S390_R1_REGNUM, - 0x10, S390_R2_REGNUM, - 0x14, S390_R3_REGNUM, - 0x18, S390_R4_REGNUM, - 0x1c, S390_R5_REGNUM, - 0x20, S390_R6_REGNUM, - 0x24, S390_R7_REGNUM, - 0x28, S390_R8_REGNUM, - 0x2c, S390_R9_REGNUM, - 0x30, S390_R10_REGNUM, - 0x34, S390_R11_REGNUM, - 0x38, S390_R12_REGNUM, - 0x3c, S390_R13_REGNUM, - 0x40, S390_R14_REGNUM, - 0x44, S390_R15_REGNUM, - 0x48, S390_A0_REGNUM, - 0x4c, S390_A1_REGNUM, - 0x50, S390_A2_REGNUM, - 0x54, S390_A3_REGNUM, - 0x58, S390_A4_REGNUM, - 0x5c, S390_A5_REGNUM, - 0x60, S390_A6_REGNUM, - 0x64, S390_A7_REGNUM, - 0x68, S390_A8_REGNUM, - 0x6c, S390_A9_REGNUM, - 0x70, S390_A10_REGNUM, - 0x74, S390_A11_REGNUM, - 0x78, S390_A12_REGNUM, - 0x7c, S390_A13_REGNUM, - 0x80, S390_A14_REGNUM, - 0x84, S390_A15_REGNUM, - 0x88, S390_ORIG_R2_REGNUM, - -1, -1 + { 1, S390_PSWM_REGNUM }, + { 1, S390_PSWA_REGNUM }, + { 16, S390_R0_REGNUM }, + { 16, S390_A0_REGNUM }, + { 1, S390_ORIG_R2_REGNUM }, + { 0 } }; -const short s390x_regmap_gregset[] = +static const struct regcache_map_entry s390_fpregmap[] = { - 0x00, S390_PSWM_REGNUM, - 0x08, S390_PSWA_REGNUM, - 0x10, S390_R0_REGNUM, - 0x18, S390_R1_REGNUM, - 0x20, S390_R2_REGNUM, - 0x28, S390_R3_REGNUM, - 0x30, S390_R4_REGNUM, - 0x38, S390_R5_REGNUM, - 0x40, S390_R6_REGNUM, - 0x48, S390_R7_REGNUM, - 0x50, S390_R8_REGNUM, - 0x58, S390_R9_REGNUM, - 0x60, S390_R10_REGNUM, - 0x68, S390_R11_REGNUM, - 0x70, S390_R12_REGNUM, - 0x78, S390_R13_REGNUM, - 0x80, S390_R14_REGNUM, - 0x88, S390_R15_REGNUM, - 0x90, S390_A0_REGNUM, - 0x94, S390_A1_REGNUM, - 0x98, S390_A2_REGNUM, - 0x9c, S390_A3_REGNUM, - 0xa0, S390_A4_REGNUM, - 0xa4, S390_A5_REGNUM, - 0xa8, S390_A6_REGNUM, - 0xac, S390_A7_REGNUM, - 0xb0, S390_A8_REGNUM, - 0xb4, S390_A9_REGNUM, - 0xb8, S390_A10_REGNUM, - 0xbc, S390_A11_REGNUM, - 0xc0, S390_A12_REGNUM, - 0xc4, S390_A13_REGNUM, - 0xc8, S390_A14_REGNUM, - 0xcc, S390_A15_REGNUM, - 0x10, S390_R0_UPPER_REGNUM, - 0x18, S390_R1_UPPER_REGNUM, - 0x20, S390_R2_UPPER_REGNUM, - 0x28, S390_R3_UPPER_REGNUM, - 0x30, S390_R4_UPPER_REGNUM, - 0x38, S390_R5_UPPER_REGNUM, - 0x40, S390_R6_UPPER_REGNUM, - 0x48, S390_R7_UPPER_REGNUM, - 0x50, S390_R8_UPPER_REGNUM, - 0x58, S390_R9_UPPER_REGNUM, - 0x60, S390_R10_UPPER_REGNUM, - 0x68, S390_R11_UPPER_REGNUM, - 0x70, S390_R12_UPPER_REGNUM, - 0x78, S390_R13_UPPER_REGNUM, - 0x80, S390_R14_UPPER_REGNUM, - 0x88, S390_R15_UPPER_REGNUM, - 0xd0, S390_ORIG_R2_REGNUM, - -1, -1 + { 1, S390_FPC_REGNUM }, { 4, REGCACHE_MAP_SKIP_BYTES }, + { 16, S390_F0_REGNUM }, + { 0 } }; -const short s390_regmap_fpregset[] = +static const struct regcache_map_entry s390_regmap_upper[] = { - 0x00, S390_FPC_REGNUM, - 0x08, S390_F0_REGNUM, - 0x10, S390_F1_REGNUM, - 0x18, S390_F2_REGNUM, - 0x20, S390_F3_REGNUM, - 0x28, S390_F4_REGNUM, - 0x30, S390_F5_REGNUM, - 0x38, S390_F6_REGNUM, - 0x40, S390_F7_REGNUM, - 0x48, S390_F8_REGNUM, - 0x50, S390_F9_REGNUM, - 0x58, S390_F10_REGNUM, - 0x60, S390_F11_REGNUM, - 0x68, S390_F12_REGNUM, - 0x70, S390_F13_REGNUM, - 0x78, S390_F14_REGNUM, - 0x80, S390_F15_REGNUM, - -1, -1 + { 16, S390_R0_UPPER_REGNUM }, + { 0 } }; -const short s390_regmap_upper[] = +static const struct regcache_map_entry s390_regmap_last_break[] = { - 0x00, S390_R0_UPPER_REGNUM, - 0x04, S390_R1_UPPER_REGNUM, - 0x08, S390_R2_UPPER_REGNUM, - 0x0c, S390_R3_UPPER_REGNUM, - 0x10, S390_R4_UPPER_REGNUM, - 0x14, S390_R5_UPPER_REGNUM, - 0x18, S390_R6_UPPER_REGNUM, - 0x1c, S390_R7_UPPER_REGNUM, - 0x20, S390_R8_UPPER_REGNUM, - 0x24, S390_R9_UPPER_REGNUM, - 0x28, S390_R10_UPPER_REGNUM, - 0x2c, S390_R11_UPPER_REGNUM, - 0x30, S390_R12_UPPER_REGNUM, - 0x34, S390_R13_UPPER_REGNUM, - 0x38, S390_R14_UPPER_REGNUM, - 0x3c, S390_R15_UPPER_REGNUM, - -1, -1 + { 1, S390_LAST_BREAK_REGNUM }, + { 0 } }; -const short s390_regmap_last_break[] = +static const struct regcache_map_entry s390x_regmap_last_break[] = { - 0x04, S390_LAST_BREAK_REGNUM, - -1, -1 + { 1, S390_LAST_BREAK_REGNUM }, + { 0 } }; -const short s390x_regmap_last_break[] = +static const struct regcache_map_entry s390_regmap_system_call[] = { - 0x00, S390_LAST_BREAK_REGNUM, - -1, -1 + { 1, S390_SYSTEM_CALL_REGNUM }, + { 0 } }; -const short s390_regmap_system_call[] = +static const struct regcache_map_entry s390_regmap_tdb[] = { - 0x00, S390_SYSTEM_CALL_REGNUM, - -1, -1 + { 1, S390_TDB_DWORD0_REGNUM }, + { 1, S390_TDB_ABORT_CODE_REGNUM }, + { 1, S390_TDB_CONFLICT_TOKEN_REGNUM }, + { 1, S390_TDB_ATIA_REGNUM }, + { 96, REGCACHE_MAP_SKIP_BYTES }, + { 16, S390_TDB_R0_REGNUM }, + { 0 } }; -const short s390_regmap_tdb[] = - { - 0x00, S390_TDB_DWORD0_REGNUM, - 0x08, S390_TDB_ABORT_CODE_REGNUM, - 0x10, S390_TDB_CONFLICT_TOKEN_REGNUM, - 0x18, S390_TDB_ATIA_REGNUM, - 0x80, S390_TDB_R0_REGNUM, - 0x88, S390_TDB_R1_REGNUM, - 0x90, S390_TDB_R2_REGNUM, - 0x98, S390_TDB_R3_REGNUM, - 0xa0, S390_TDB_R4_REGNUM, - 0xa8, S390_TDB_R5_REGNUM, - 0xb0, S390_TDB_R6_REGNUM, - 0xb8, S390_TDB_R7_REGNUM, - 0xc0, S390_TDB_R8_REGNUM, - 0xc8, S390_TDB_R9_REGNUM, - 0xd0, S390_TDB_R10_REGNUM, - 0xd8, S390_TDB_R11_REGNUM, - 0xe0, S390_TDB_R12_REGNUM, - 0xe8, S390_TDB_R13_REGNUM, - 0xf0, S390_TDB_R14_REGNUM, - 0xf8, S390_TDB_R15_REGNUM, - -1, -1 - }; - - -/* Supply register REGNUM from the register set REGSET to register cache - REGCACHE. If REGNUM is -1, do this for all registers in REGSET. */ -static void -s390_supply_regset (const struct regset *regset, struct regcache *regcache, - int regnum, const void *regs, size_t len) -{ - const short *map; - for (map = regset->regmap; map[0] >= 0; map += 2) - if (regnum == -1 || regnum == map[1]) - regcache_raw_supply (regcache, map[1], - regs ? (const char *)regs + map[0] : NULL); -} -/* Supply the TDB regset. Like s390_supply_regset, but invalidate the - TDB registers unless the TDB format field is valid. */ +/* Supply the TDB regset. Like regcache_supply_regset, but invalidate + the TDB registers unless the TDB format field is valid. */ static void s390_supply_tdb_regset (const struct regset *regset, struct regcache *regcache, @@ -627,73 +484,52 @@ s390_supply_tdb_regset (const struct regset *regset, struct regcache *regcache, enum register_status ret; int i; - s390_supply_regset (regset, regcache, regnum, regs, len); + regcache_supply_regset (regset, regcache, regnum, regs, len); ret = regcache_cooked_read_unsigned (regcache, S390_TDB_DWORD0_REGNUM, &tdw); if (ret != REG_VALID || (tdw >> 56) != 1) - s390_supply_regset (regset, regcache, regnum, NULL, len); + regcache_supply_regset (regset, regcache, regnum, NULL, len); } -/* Collect register REGNUM from the register cache REGCACHE and store - it in the buffer specified by REGS and LEN as described by the - general-purpose register set REGSET. If REGNUM is -1, do this for - all registers in REGSET. */ -static void -s390_collect_regset (const struct regset *regset, - const struct regcache *regcache, - int regnum, void *regs, size_t len) -{ - const short *map; - for (map = regset->regmap; map[0] >= 0; map += 2) - if (regnum == -1 || regnum == map[1]) - regcache_raw_collect (regcache, map[1], (char *)regs + map[0]); -} - -static const struct regset s390_gregset = { - s390_regmap_gregset, - s390_supply_regset, - s390_collect_regset +const struct regset s390_gregset = { + s390_gregmap, + regcache_supply_regset, + regcache_collect_regset }; -static const struct regset s390x_gregset = { - s390x_regmap_gregset, - s390_supply_regset, - s390_collect_regset -}; - -static const struct regset s390_fpregset = { - s390_regmap_fpregset, - s390_supply_regset, - s390_collect_regset +const struct regset s390_fpregset = { + s390_fpregmap, + regcache_supply_regset, + regcache_collect_regset }; static const struct regset s390_upper_regset = { s390_regmap_upper, - s390_supply_regset, - s390_collect_regset + regcache_supply_regset, + regcache_collect_regset }; -static const struct regset s390_last_break_regset = { +const struct regset s390_last_break_regset = { s390_regmap_last_break, - s390_supply_regset, - s390_collect_regset + regcache_supply_regset, + regcache_collect_regset }; -static const struct regset s390x_last_break_regset = { +const struct regset s390x_last_break_regset = { s390x_regmap_last_break, - s390_supply_regset, - s390_collect_regset + regcache_supply_regset, + regcache_collect_regset }; -static const struct regset s390_system_call_regset = { +const struct regset s390_system_call_regset = { s390_regmap_system_call, - s390_supply_regset, - s390_collect_regset + regcache_supply_regset, + regcache_collect_regset }; -static const struct regset s390_tdb_regset = { +const struct regset s390_tdb_regset = { s390_regmap_tdb, s390_supply_tdb_regset, - s390_collect_regset + regcache_collect_regset }; static struct core_regset_section s390_linux32_regset_sections[] = @@ -3371,7 +3207,7 @@ s390_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) break; case ABI_LINUX_ZSERIES: - tdep->gregset = &s390x_gregset; + tdep->gregset = &s390_gregset; tdep->sizeof_gregset = s390x_sizeof_gregset; tdep->fpregset = &s390_fpregset; tdep->sizeof_fpregset = s390_sizeof_fpregset; diff --git a/gdb/s390-linux-tdep.h b/gdb/s390-linux-tdep.h index 52bed9d..1e12000 100644 --- a/gdb/s390-linux-tdep.h +++ b/gdb/s390-linux-tdep.h @@ -150,15 +150,14 @@ /* Core file register sets, defined in s390-tdep.c. */ #define s390_sizeof_gregset 0x90 -extern const short s390_regmap_gregset[]; #define s390x_sizeof_gregset 0xd8 -extern const short s390x_regmap_gregset[]; +extern const struct regset s390_gregset; #define s390_sizeof_fpregset 0x88 -extern const short s390_regmap_fpregset[]; -extern const short s390_regmap_last_break[]; -extern const short s390x_regmap_last_break[]; -extern const short s390_regmap_system_call[]; -extern const short s390_regmap_tdb[]; +extern const struct regset s390_fpregset; +extern const struct regset s390_last_break_regset; +extern const struct regset s390x_last_break_regset; +extern const struct regset s390_system_call_regset; +extern const struct regset s390_tdb_regset; #define s390_sizeof_tdbregset 0x100 /* GNU/Linux target descriptions. */ -- 1.8.4.2