From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 23702 invoked by alias); 21 Apr 2010 23:09:44 -0000 Received: (qmail 23392 invoked by uid 22791); 21 Apr 2010 23:09:37 -0000 X-SWARE-Spam-Status: No, hits=-1.7 required=5.0 tests=BAYES_00,NO_DNS_FOR_FROM,TW_EG,TW_MX,TW_XC,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mga09.intel.com (HELO mga09.intel.com) (134.134.136.24) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 21 Apr 2010 23:09:31 +0000 Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga102.jf.intel.com with ESMTP; 21 Apr 2010 16:08:37 -0700 X-ExtLoop1: 1 Received: from gnu-6.sc.intel.com ([10.3.194.107]) by orsmga001.jf.intel.com with ESMTP; 21 Apr 2010 16:09:21 -0700 Received: by gnu-6.sc.intel.com (Postfix, from userid 500) id 0B220812386; Wed, 21 Apr 2010 16:09:29 -0700 (PDT) Date: Wed, 21 Apr 2010 23:09:00 -0000 From: "H.J. Lu" To: GDB Cc: Mark Kettenis Subject: PATCH: Remove amd64_linux_gregset64_reg_offset and regmap Message-ID: <20100421230929.GA11193@intel.com> Reply-To: "H.J. Lu" MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.20 (2009-08-17) 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 X-SW-Source: 2010-04/txt/msg00716.txt.bz2 Hi, As we have discussed, this patch removes amd64_linux_gregset64_reg_offset and regmap from i386/amd64 Linux targets. OK to install? Thanks. H.J. --- 2010-04-21 H.J. Lu * amd64-linux-nat.c (amd64_linux_gregset64_reg_offset): Removed. (_initialize_amd64_linux_nat): Replace amd64_linux_gregset64_reg_offset with amd64_linux_gregset_reg_offset. * amd64-linux-tdep.c (amd64_linux_gregset_reg_offset): Make it global. * amd64-tdep.h (amd64_linux_gregset_reg_offset): New. * i386-linux-nat.c (regmap): Removed. (fetch_register): Replace regmap with i386_linux_gregset_reg_offset. (store_register): Likewise. (supply_gregset): Likewise. (fill_gregset): Likewise. * i386-linux-tdep.c (i386_linux_gregset_reg_offset): Make it global. * i386-linux-tdep.h (i386_linux_gregset_reg_offset): New. diff --git a/gdb/amd64-linux-nat.c b/gdb/amd64-linux-nat.c index 9812610..c0edc10 100644 --- a/gdb/amd64-linux-nat.c +++ b/gdb/amd64-linux-nat.c @@ -68,33 +68,6 @@ static int have_ptrace_getregset = -1; /* Mapping between the general-purpose registers in GNU/Linux x86-64 - `struct user' format and GDB's register cache layout. */ - -static int amd64_linux_gregset64_reg_offset[] = -{ - RAX * 8, RBX * 8, /* %rax, %rbx */ - RCX * 8, RDX * 8, /* %rcx, %rdx */ - RSI * 8, RDI * 8, /* %rsi, %rdi */ - RBP * 8, RSP * 8, /* %rbp, %rsp */ - R8 * 8, R9 * 8, /* %r8 ... */ - R10 * 8, R11 * 8, - R12 * 8, R13 * 8, - R14 * 8, R15 * 8, /* ... %r15 */ - RIP * 8, EFLAGS * 8, /* %rip, %eflags */ - CS * 8, SS * 8, /* %cs, %ss */ - DS * 8, ES * 8, /* %ds, %es */ - FS * 8, GS * 8, /* %fs, %gs */ - -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, - ORIG_RAX * 8 -}; - - -/* Mapping between the general-purpose registers in GNU/Linux x86-64 `struct user' format and GDB's register cache layout for GNU/Linux i386. @@ -807,13 +780,11 @@ _initialize_amd64_linux_nat (void) amd64_native_gregset32_reg_offset = amd64_linux_gregset32_reg_offset; amd64_native_gregset32_num_regs = I386_LINUX_NUM_REGS; - amd64_native_gregset64_reg_offset = amd64_linux_gregset64_reg_offset; + amd64_native_gregset64_reg_offset = amd64_linux_gregset_reg_offset; amd64_native_gregset64_num_regs = AMD64_LINUX_NUM_REGS; gdb_assert (ARRAY_SIZE (amd64_linux_gregset32_reg_offset) == amd64_native_gregset32_num_regs); - gdb_assert (ARRAY_SIZE (amd64_linux_gregset64_reg_offset) - == amd64_native_gregset64_num_regs); /* Fill in the generic GNU/Linux methods. */ t = linux_target (); diff --git a/gdb/amd64-linux-tdep.c b/gdb/amd64-linux-tdep.c index 7376ba7..1eac4c6 100644 --- a/gdb/amd64-linux-tdep.c +++ b/gdb/amd64-linux-tdep.c @@ -62,7 +62,7 @@ static struct core_regset_section amd64_linux_regset_sections[] = format and GDB's register cache layout. */ /* From . */ -static int amd64_linux_gregset_reg_offset[] = +int amd64_linux_gregset_reg_offset[] = { 10 * 8, /* %rax */ 5 * 8, /* %rbx */ diff --git a/gdb/amd64-tdep.h b/gdb/amd64-tdep.h index 9f07dda..e67106d 100644 --- a/gdb/amd64-tdep.h +++ b/gdb/amd64-tdep.h @@ -109,6 +109,9 @@ void amd64_classify (struct type *type, enum amd64_reg_class class[2]); +/* Variables exported from amd64-linux-tdep.c. */ +extern int amd64_linux_gregset_reg_offset[]; + /* Variables exported from amd64nbsd-tdep.c. */ extern int amd64nbsd_r_reg_offset[]; diff --git a/gdb/i386-linux-nat.c b/gdb/i386-linux-nat.c index d559811..35bc3bd 100644 --- a/gdb/i386-linux-nat.c +++ b/gdb/i386-linux-nat.c @@ -99,26 +99,6 @@ static int have_ptrace_getregset = -1; those names are now used for the register sets used in the `mcontext_t' type, and have a different size and layout. */ -/* Mapping between the general-purpose registers in `struct user' - format and GDB's register array layout. */ -static int regmap[] = -{ - EAX, ECX, EDX, EBX, - UESP, EBP, ESI, EDI, - EIP, EFL, CS, SS, - DS, ES, FS, GS, - -1, -1, -1, -1, /* st0, st1, st2, st3 */ - -1, -1, -1, -1, /* st4, st5, st6, st7 */ - -1, -1, -1, -1, /* fctrl, fstat, ftag, fiseg */ - -1, -1, -1, -1, /* fioff, foseg, fooff, fop */ - -1, -1, -1, -1, /* xmm0, xmm1, xmm2, xmm3 */ - -1, -1, -1, -1, /* xmm4, xmm5, xmm6, xmm6 */ - -1, /* mxcsr */ - -1, -1, -1, -1, /* ymm0h, ymm1h, ymm2h, ymm3h */ - -1, -1, -1, -1, /* ymm4h, ymm5h, ymm6h, ymm6h */ - ORIG_EAX -}; - /* Which ptrace request retrieves which registers? These apply to the corresponding SET requests as well. */ @@ -168,7 +148,7 @@ fetch_register (struct regcache *regcache, int regno) int val; gdb_assert (!have_ptrace_getregs); - if (regmap[regno] == -1) + if (i386_linux_gregset_reg_offset[regno] == -1) { regcache_raw_supply (regcache, regno, NULL); return; @@ -180,7 +160,8 @@ fetch_register (struct regcache *regcache, int regno) tid = PIDGET (inferior_ptid); /* Not a threaded program. */ errno = 0; - val = ptrace (PTRACE_PEEKUSER, tid, 4 * regmap[regno], 0); + val = ptrace (PTRACE_PEEKUSER, tid, + i386_linux_gregset_reg_offset[regno], 0); if (errno != 0) error (_("Couldn't read register %s (#%d): %s."), gdbarch_register_name (get_regcache_arch (regcache), regno), @@ -198,7 +179,7 @@ store_register (const struct regcache *regcache, int regno) int val; gdb_assert (!have_ptrace_getregs); - if (regmap[regno] == -1) + if (i386_linux_gregset_reg_offset[regno] == -1) return; /* GNU/Linux LWP ID's are process ID's. */ @@ -208,7 +189,8 @@ store_register (const struct regcache *regcache, int regno) errno = 0; regcache_raw_collect (regcache, regno, &val); - ptrace (PTRACE_POKEUSER, tid, 4 * regmap[regno], val); + ptrace (PTRACE_POKEUSER, tid, + i386_linux_gregset_reg_offset[regno], val); if (errno != 0) error (_("Couldn't write register %s (#%d): %s."), gdbarch_register_name (get_regcache_arch (regcache), regno), @@ -225,16 +207,17 @@ store_register (const struct regcache *regcache, int regno) void supply_gregset (struct regcache *regcache, const elf_gregset_t *gregsetp) { - const elf_greg_t *regp = (const elf_greg_t *) gregsetp; + const gdb_byte *regp = (const gdb_byte *) gregsetp; int i; for (i = 0; i < I386_NUM_GREGS; i++) - regcache_raw_supply (regcache, i, regp + regmap[i]); + regcache_raw_supply (regcache, i, + regp + i386_linux_gregset_reg_offset[i]); if (I386_LINUX_ORIG_EAX_REGNUM < gdbarch_num_regs (get_regcache_arch (regcache))) regcache_raw_supply (regcache, I386_LINUX_ORIG_EAX_REGNUM, - regp + ORIG_EAX); + regp + 4 * ORIG_EAX); } /* Fill register REGNO (if it is a general-purpose register) in @@ -245,18 +228,19 @@ void fill_gregset (const struct regcache *regcache, elf_gregset_t *gregsetp, int regno) { - elf_greg_t *regp = (elf_greg_t *) gregsetp; + gdb_byte *regp = (gdb_byte *) gregsetp; int i; for (i = 0; i < I386_NUM_GREGS; i++) if (regno == -1 || regno == i) - regcache_raw_collect (regcache, i, regp + regmap[i]); + regcache_raw_collect (regcache, i, + regp + i386_linux_gregset_reg_offset[i]); if ((regno == -1 || regno == I386_LINUX_ORIG_EAX_REGNUM) && I386_LINUX_ORIG_EAX_REGNUM < gdbarch_num_regs (get_regcache_arch (regcache))) regcache_raw_collect (regcache, I386_LINUX_ORIG_EAX_REGNUM, - regp + ORIG_EAX); + regp + 4 * ORIG_EAX); } #ifdef HAVE_PTRACE_GETREGS diff --git a/gdb/i386-linux-tdep.c b/gdb/i386-linux-tdep.c index 272cc99..3ae19a7 100644 --- a/gdb/i386-linux-tdep.c +++ b/gdb/i386-linux-tdep.c @@ -529,7 +529,7 @@ i386_linux_get_syscall_number (struct gdbarch *gdbarch, format and GDB's register cache layout. */ /* From . */ -static int i386_linux_gregset_reg_offset[] = +int i386_linux_gregset_reg_offset[] = { 6 * 4, /* %eax */ 1 * 4, /* %ecx */ diff --git a/gdb/i386-linux-tdep.h b/gdb/i386-linux-tdep.h index 1228681..c2291b0 100644 --- a/gdb/i386-linux-tdep.h +++ b/gdb/i386-linux-tdep.h @@ -65,4 +65,6 @@ extern struct target_desc *tdesc_i386_avx_linux; the process/thread is in. */ #define I386_LINUX_XSAVE_XCR0_OFFSET 464 +extern int i386_linux_gregset_reg_offset[]; + #endif /* i386-linux-tdep.h */