Skip to contentSkip to conversation

IA32 ptrace bug-fixes

PATCH New Pallipadi, Venkatesh 1 participant 1 message Nov 28, 2002

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 IA32 ptrace bug-fixes

Attached is the patch to IA32 ptrace code in IA64 kernel. This patch basically helps gdb'ing of an ia32 app (with ia32 gdb binary). The patch can easily be verified by running gdb and looking at all-registers.

The changes done in the patch include:
1) Support for xmm registers.
At present xmm registers are not saved/restored during ptrace and gdb wont show them. Patch adds new ptrace options (IA32_PTRACE_GETFPXREGS and IA32_PTRACE_SETFPXREGS, used by gdb to get/set fp+xmm state).
2) Bug fix in getting 'tag' field of fpstate

      (fsr>>16 in place of fsr>>32)
3) Bug fix in calculating fp TOS 
   (it is a 3 bit field in fsr. Using (fsr>>11) & 7 in place 
    of (fsr>>11) & 3)

Also, I had to add new structures in ia32.h, corresponding to the way gdb is expecting the data. Gdb uses structures defined in sys/user.h

Please let me know, if you need any more information on this.

Thanks,
-Venkatesh

include/asm-ia64/ia32.h renamed from include/asm-ia64/ia32.h.1 +40 -0
@@ -131,6 +131,44 @@
 };
 
 
+/* user.h */
+/*
+ * IA32 (Pentium III/4) FXSR, SSE support
+ *
+ * Provide support for the GDB 5.0+ PTRACE_{GET|SET}FPXREGS requests for
+ * interacting with the FXSR-format floating point environment.  Floating
+ * point data can be accessed in the regular format in the usual manner,
+ * and both the standard and SIMD floating point data can be accessed via
+ * the new ptrace requests.  In either case, changes to the FPU environment
+ * will be reflected in the task's state as expected.
+ */
+struct ia32_user_i387_struct {
+	int	cwd;
+	int	swd;
+	int	twd;
+	int	fip;
+	int	fcs;
+	int	foo;
+	int	fos;
+	int	st_space[20];	/* 8*10 bytes for each FP-reg = 80 bytes */
+};
+
+struct ia32_user_fxsr_struct {
+	unsigned short	cwd;
+	unsigned short	swd;
+	unsigned short	twd;
+	unsigned short	fop;
+	int	fip;
+	int	fcs;
+	int	foo;
+	int	fos;
+	int	mxcsr;
+	int	reserved;
+	int	st_space[32];	/* 8*16 bytes for each FP-reg = 128 bytes */
+	int	xmm_space[32];	/* 8*16 bytes for each XMM-reg = 128 bytes */
+	int	padding[56];
+};
+
 /* signal.h */
 #define _IA32_NSIG	       64
 #define _IA32_NSIG_BPW	       32
@@ -464,6 +502,8 @@
 #define IA32_PTRACE_SETREGS	13
 #define IA32_PTRACE_GETFPREGS	14
 #define IA32_PTRACE_SETFPREGS	15
+#define IA32_PTRACE_GETFPXREGS	18
+#define IA32_PTRACE_SETFPXREGS	19
 
 #define ia32_start_thread(regs,new_ip,new_sp) do {				\
 	set_fs(USER_DS);							\
arch/ia64/ia32/sys_ia32.c renamed from arch/ia64/ia32/sys_ia32.c.1 +122 -26

191 lines not on this page · raw message

include/asm-ia64/ia32.h renamed from include/asm-ia64/ia32.h.1 +40 -0
@@ -131,6 +131,44 @@
 };
 
 
+/* user.h */
+/*
+ * IA32 (Pentium III/4) FXSR, SSE support
+ *
+ * Provide support for the GDB 5.0+ PTRACE_{GET|SET}FPXREGS requests for
+ * interacting with the FXSR-format floating point environment.  Floating
+ * point data can be accessed in the regular format in the usual manner,
+ * and both the standard and SIMD floating point data can be accessed via
+ * the new ptrace requests.  In either case, changes to the FPU environment
+ * will be reflected in the task's state as expected.
+ */
+struct ia32_user_i387_struct {
+	int	cwd;
+	int	swd;
+	int	twd;
+	int	fip;
+	int	fcs;
+	int	foo;
+	int	fos;
+	int	st_space[20];	/* 8*10 bytes for each FP-reg = 80 bytes */
+};
+
+struct ia32_user_fxsr_struct {
+	unsigned short	cwd;
+	unsigned short	swd;
+	unsigned short	twd;
+	unsigned short	fop;
+	int	fip;
+	int	fcs;
+	int	foo;
+	int	fos;
+	int	mxcsr;
+	int	reserved;
+	int	st_space[32];	/* 8*16 bytes for each FP-reg = 128 bytes */
+	int	xmm_space[32];	/* 8*16 bytes for each XMM-reg = 128 bytes */
+	int	padding[56];
+};
+
 /* signal.h */
 #define _IA32_NSIG	       64
 #define _IA32_NSIG_BPW	       32
@@ -464,6 +502,8 @@
 #define IA32_PTRACE_SETREGS	13
 #define IA32_PTRACE_GETFPREGS	14
 #define IA32_PTRACE_SETFPREGS	15
+#define IA32_PTRACE_GETFPXREGS	18
+#define IA32_PTRACE_SETFPXREGS	19
 
 #define ia32_start_thread(regs,new_ip,new_sp) do {				\
 	set_fs(USER_DS);							\
arch/ia64/ia32/sys_ia32.c renamed from arch/ia64/ia32/sys_ia32.c.1 +122 -26

191 lines not on this page · raw message