From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 15010 invoked by alias); 6 Nov 2002 19:51:45 -0000 Mailing-List: contact gdb-patches-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sources.redhat.com Received: (qmail 15003 invoked from network); 6 Nov 2002 19:51:43 -0000 Received: from unknown (HELO localhost.redhat.com) (216.138.202.10) by sources.redhat.com with SMTP; 6 Nov 2002 19:51:43 -0000 Received: from redhat.com (localhost [127.0.0.1]) by localhost.redhat.com (Postfix) with ESMTP id B9C8E3E60 for ; Wed, 6 Nov 2002 14:51:44 -0500 (EST) Message-ID: <3DC972D0.2010803@redhat.com> Date: Wed, 06 Nov 2002 11:51:00 -0000 From: Andrew Cagney User-Agent: Mozilla/5.0 (X11; U; NetBSD macppc; en-US; rv:1.0.0) Gecko/20020824 X-Accept-Language: en-us, en MIME-Version: 1.0 To: gdb-patches@sources.redhat.com Subject: [rfa/i386] FP_REGNUM_P() -> i386_fp_regnum_p() et.al. Content-Type: multipart/mixed; boundary="------------000106010809080104030201" X-SW-Source: 2002-11/txt/msg00113.txt.bz2 This is a multi-part message in MIME format. --------------000106010809080104030201 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Content-length: 1100 Hello, I was trying to figure out why I was seeing: $ gdb (gdb) maint print register-groups Name Nr Rel Offset Size Type Groups eax 0 0 0 4 int general,all,save,restore ... mm0 32 0 176 8 _vec64i sse,mmx,general,all,vector mm1 33 1 184 8 _vec64i mmx,general,all,vector ... when adding i386 specific register groups. Notice how mm0 ended up in the SSE register group :-( The problem was that tests like IS_SSE_REGNUM_P() and more specifically regnum==MXCSR_REGNUM weren't sufficient - they can trigger a false positive when the ISA doesn't have one set of registersSSE registers (the num can match an mmx register - regnum == MXCSR_REGNUM == MM0_REGNUM :-(). The attached: - converts all the macro's into functions - makes the function checks more robust - return true when both the regnum matches and the ISA has the register - adds a method to test for the orig_eax register (the I386_LINUX_ORIG_EAX_REGNUM is moved from i386-linux-tdep.h to i386-tdep.h). Ok to commit? Andrew --------------000106010809080104030201 Content-Type: text/plain; name="diffs" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="diffs" Content-length: 9165 2002-11-06 Andrew Cagney * i386-tdep.c (i386_mmx_regnum_p): Rename mmx_regnum_p. Update all callers. (i386_fp_regnum_p): New function. Use instead of FP_REGNUM_P. (i386_fpc_regnum_p): New function. Use instead of FPC_REGNUM_P. (i386_sse_regnum_p): New function. Use instead of SSE_REGNUM_P. (i386_mxcsr_regnum_p): new function. Use instead of MXCSR_REGNUM_P. (i386_linux_orig_eax_regnum_p): New function. * i386-linux-tdep.c (i386_linux_register_name): Use i386_linux_orig_eax_regnum_p. * i386-tdep.h (SSE_REGNUM_P): Delete macro. (i386_sse_regnum_p): Declare. (i386_mxcsr_regnum_p): Declare. (FP_REGNUM_P, FPC_REGNUM_P): Delete macros. (i386_fp_regnum_p, i386_fpc_regnum_p): Declare. (I386_LINUX_ORIG_EAX_REGNUM): Define macro. (i386_linux_orig_eax_regnum_p): Declare. (IS_FP_REGNUM): Update definition. (IS_FPU_CTRL_REGNUM): Update definition.. (IS_SSE_REGNUM): Update definition.. * i386-linux-tdep.h (I386_LINUX_ORIG_EAX_REGNUM): Delete macro. Moved to "i386-tdep.h". * i386v-nat.c (register_u_addr): Update. * go32-nat.c (fetch_register): Update. (store_register): Update. Index: go32-nat.c =================================================================== RCS file: /cvs/src/src/gdb/go32-nat.c,v retrieving revision 1.33 diff -u -r1.33 go32-nat.c --- go32-nat.c 11 May 2002 17:22:26 -0000 1.33 +++ go32-nat.c 6 Nov 2002 19:29:37 -0000 @@ -467,7 +467,7 @@ { if (regno < FP0_REGNUM) supply_register (regno, (char *) &a_tss + regno_mapping[regno].tss_ofs); - else if (FP_REGNUM_P (regno) || FPC_REGNUM_P (regno)) + else if (i386_fp_regnum_p (regno) || i386_fpc_regnum_p (regno)) i387_supply_register (regno, (char *) &npx); else internal_error (__FILE__, __LINE__, @@ -492,7 +492,7 @@ { if (regno < FP0_REGNUM) regcache_collect (regno, (char *) &a_tss + regno_mapping[regno].tss_ofs); - else if (FP_REGNUM_P (regno) || FPC_REGNUM_P (regno)) + else if (i386_fp_regnum_p (regno) || i386_fpc_regnum_p (regno)) i387_fill_fsave ((char *) &npx, regno); else internal_error (__FILE__, __LINE__, Index: i386-linux-tdep.c =================================================================== RCS file: /cvs/src/src/gdb/i386-linux-tdep.c,v retrieving revision 1.18 diff -u -r1.18 i386-linux-tdep.c --- i386-linux-tdep.c 31 Oct 2002 20:51:15 -0000 1.18 +++ i386-linux-tdep.c 6 Nov 2002 19:29:37 -0000 @@ -41,8 +41,7 @@ static const char * i386_linux_register_name (int reg) { - /* Deal with the extra "orig_eax" pseudo register. */ - if (reg == I386_LINUX_ORIG_EAX_REGNUM) + if (i386_linux_orig_eax_regnum_p (reg)) return "orig_eax"; return i386_register_name (reg); Index: i386-tdep.c =================================================================== RCS file: /cvs/src/src/gdb/i386-tdep.c,v retrieving revision 1.91 diff -u -r1.91 i386-tdep.c --- i386-tdep.c 2 Nov 2002 14:59:10 -0000 1.91 +++ i386-tdep.c 6 Nov 2002 19:29:38 -0000 @@ -70,11 +70,52 @@ #define MM0_REGNUM (NUM_REGS) static int -mmx_regnum_p (int reg) +i386_mmx_regnum_p (int reg) { return (reg >= MM0_REGNUM && reg < MM0_REGNUM + mmx_num_regs); } +/* FP register? */ + +int +i386_fp_regnum_p (int regnum) +{ + return (regnum < NUM_REGS + && (FP0_REGNUM && FP0_REGNUM <= (regnum) && (regnum) < FPC_REGNUM)); +} + +int +i386_fpc_regnum_p (int regnum) +{ + return (regnum < NUM_REGS + && (FPC_REGNUM <= (regnum) && (regnum) < XMM0_REGNUM)); +} + +/* SSE register? */ + +int +i386_sse_regnum_p (int regnum) +{ + return (regnum < NUM_REGS + && (XMM0_REGNUM <= (regnum) && (regnum) < MXCSR_REGNUM)); +} + +int +i386_mxcsr_regnum_p (int regnum) +{ + return (regnum < NUM_REGS + && (regnum == MXCSR_REGNUM)); +} + +/* The GNU/Linux orig eax? */ + +int +i386_linux_orig_eax_regnum_p (int regnum) +{ + return (regnum < NUM_REGS + && (regnum == I386_LINUX_ORIG_EAX_REGNUM)); +} + /* Return the name of register REG. */ const char * @@ -82,7 +123,7 @@ { if (reg < 0) return NULL; - if (mmx_regnum_p (reg)) + if (i386_mmx_regnum_p (reg)) return i386_mmx_names[reg - MM0_REGNUM]; if (reg >= sizeof (i386_register_names) / sizeof (*i386_register_names)) return NULL; @@ -1098,13 +1139,13 @@ if (regnum == PC_REGNUM || regnum == FP_REGNUM || regnum == SP_REGNUM) return lookup_pointer_type (builtin_type_void); - if (FP_REGNUM_P (regnum)) + if (i386_fp_regnum_p (regnum)) return builtin_type_i387_ext; - if (SSE_REGNUM_P (regnum)) + if (i386_sse_regnum_p (regnum)) return builtin_type_vec128i; - if (mmx_regnum_p (regnum)) + if (i386_mmx_regnum_p (regnum)) return builtin_type_vec64i; return builtin_type_int; @@ -1131,7 +1172,7 @@ i386_pseudo_register_read (struct gdbarch *gdbarch, struct regcache *regcache, int regnum, void *buf) { - if (mmx_regnum_p (regnum)) + if (i386_mmx_regnum_p (regnum)) { char *mmx_buf = alloca (MAX_REGISTER_RAW_SIZE); int fpnum = mmx_regnum_to_fp_regnum (regcache, regnum); @@ -1147,7 +1188,7 @@ i386_pseudo_register_write (struct gdbarch *gdbarch, struct regcache *regcache, int regnum, const void *buf) { - if (mmx_regnum_p (regnum)) + if (i386_mmx_regnum_p (regnum)) { char *mmx_buf = alloca (MAX_REGISTER_RAW_SIZE); int fpnum = mmx_regnum_to_fp_regnum (regcache, regnum); @@ -1171,7 +1212,7 @@ static int i386_register_convertible (int regnum) { - return FP_REGNUM_P (regnum); + return i386_fp_regnum_p (regnum); } /* Convert data from raw format for register REGNUM in buffer FROM to @@ -1181,7 +1222,7 @@ i386_register_convert_to_virtual (int regnum, struct type *type, char *from, char *to) { - gdb_assert (FP_REGNUM_P (regnum)); + gdb_assert (i386_fp_regnum_p (regnum)); /* We only support floating-point values. */ if (TYPE_CODE (type) != TYPE_CODE_FLT) @@ -1204,7 +1245,7 @@ i386_register_convert_to_raw (struct type *type, int regnum, char *from, char *to) { - gdb_assert (FP_REGNUM_P (regnum)); + gdb_assert (i386_fp_regnum_p (regnum)); /* We only support floating-point values. */ if (TYPE_CODE (type) != TYPE_CODE_FLT) Index: i386-tdep.h =================================================================== RCS file: /cvs/src/src/gdb/i386-tdep.h,v retrieving revision 1.14 diff -u -r1.14 i386-tdep.h --- i386-tdep.h 1 Sep 2002 23:24:19 -0000 1.14 +++ i386-tdep.h 6 Nov 2002 19:29:38 -0000 @@ -113,11 +113,10 @@ /* FPU opcode, bottom eleven bits. */ #define FOP_REGNUM (FPC_REGNUM + 7) -/* Return non-zero if N corresponds to a FPU data registers. */ -#define FP_REGNUM_P(n) (FP0_REGNUM && FP0_REGNUM <= (n) && (n) < FPC_REGNUM) - -/* Return non-zero if N corresponds to a FPU control register. */ -#define FPC_REGNUM_P(n) (FPC_REGNUM <= (n) && (n) < XMM0_REGNUM) +/* Return non-zero if REGNUM matches the FP register and the FP + register set is active. */ +extern int i386_fp_regnum_p (int regnum); +extern int i386_fpc_regnum_p (int regnum); /* SSE registers. */ @@ -128,17 +127,34 @@ #define MXCSR_REGNUM \ (XMM0_REGNUM + gdbarch_tdep (current_gdbarch)->num_xmm_regs) -/* Return non-zero if N corresponds to a SSE data register. */ -#define SSE_REGNUM_P(n) (XMM0_REGNUM <= (n) && (n) < MXCSR_REGNUM) +/* Return non-zero if REGNUM matches the SSE register and the SSE + register set is active. */ +extern int i386_sse_regnum_p (int regnum); +extern int i386_mxcsr_regnum_p (int regnum); + +/* The Linux kernel pretends there is an additional "orig_eax" + register. Since GDB needs access to that register to be able to + properly restart system calls when necessary (see + i386-linux-tdep.c) we need our own versions of a number of + functions that deal with GDB's register cache. */ + +/* Register number for the "orig_eax" pseudo-register. If this + pseudo-register contains a value >= 0 it is interpreted as the + system call number that the kernel is supposed to restart. */ +#define I386_LINUX_ORIG_EAX_REGNUM I386_SSE_NUM_REGS + +/* Return non-zero if REGNUM matches the ORIG_EAX register and the + register hack is active. */ +extern int i386_linux_orig_eax_regnum_p (int regnum); /* FIXME: kettenis/2001-11-24: Obsolete macro's. */ #define FCS_REGNUM FISEG_REGNUM #define FCOFF_REGNUM FIOFF_REGNUM #define FDS_REGNUM FOSEG_REGNUM #define FDOFF_REGNUM FOOFF_REGNUM -#define IS_FP_REGNUM(n) FP_REGNUM_P (n) -#define IS_FPU_CTRL_REGNUM(n) FPC_REGNUM_P (n) -#define IS_SSE_REGNUM(n) SSE_REGNUM_P (n) +#define IS_FP_REGNUM(n) i386_fp_regnum_p (n) +#define IS_FPU_CTRL_REGNUM(n) i386_fpc_regnum_p (n) +#define IS_SSE_REGNUM(n) i386_sse_regnum_p (n) #define I386_NUM_GREGS 16 #define I386_NUM_FREGS 16 Index: i386v-nat.c =================================================================== RCS file: /cvs/src/src/gdb/i386v-nat.c,v retrieving revision 1.12 diff -u -r1.12 i386v-nat.c --- i386v-nat.c 25 Oct 2002 18:50:23 -0000 1.12 +++ i386v-nat.c 6 Nov 2002 19:29:38 -0000 @@ -85,7 +85,7 @@ struct user u; CORE_ADDR fpstate; - if (FP_REGNUM_P (regnum)) + if (i386_fp_regnum_p (regnum)) { #ifdef KSTKSZ /* SCO, and others? */ blockend += 4 * (SS + 1) - KSTKSZ; --------------000106010809080104030201--