This is the mail archive of the gdb-patches@sources.redhat.com mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

[RFA]: gdbserver cleanup, add m68k & ns32k support to low-nbsd.c


I submit the enclosed patch for approval.

I only planning to add support for m68k and ns32k based NetBSD
systems, when I found some unused variables, etc. in the low-*.c
files.  I couldn't fix the instances in only low-nbsd.c without
fixing the others, so those changes are in here as well.

        --jtc

2000-12-01  J.T. Conklin  <jtc@redback.com>

	* gdbserver/low-hppabsd.c (buf2, environ, quit, quit_flag):
 	Removed unused variables and declarations.
	* gdbserver/low-linux.c (buf2, environ, query, quit, quit_flag):
	Likewise.
	* gdbserver/low-nbsd.c (buf2, environ, quit, quit_flag):
	Likewise.
	* gdbserver/low-sparc.c (buf2, environ, query, quit, quit_flag):
	Likewise.
	* gdbserver/low-sun.c (buf2, environ, query, quit, quit_flag):
	Likewise.

	* gdbserver/low-hppabsd.c, gdbserver/low-linux.c,
 	gdbserver/low-nbsd.c, gdbserver/low-sparc.c, gdbserver/low-sun3.c
 	(create_inferior): Update comment.

	* gdbserver/low-nbsd.c (initialize_arch, fetch_inferior_registers,
	store_inferior_registers): Provide implementations for the m68k 
	and ns32k.
	* config/m68k/nbsd.mt (GDBSERVER_DEPFILES): Add low-nbsd.o
	* config/ns32k/nbsd.mt (GDBSERVER_DEPFILES): Likewise.
	* configure.tgt (m68*-*-netbsd*, ns32k-*-netbsd*): Add gdbserver
 	to configdirs.

Index: configure.tgt
===================================================================
RCS file: /cvs/src/src/gdb/configure.tgt,v
retrieving revision 1.14
diff -c -r1.14 configure.tgt
*** configure.tgt	2000/11/26 20:04:41	1.14
--- configure.tgt	2000/12/02 00:40:45
***************
*** 167,173 ****
  		configdirs="${configdirs} gdbserver" ;;
  m68*-*-lynxos*)		gdb_target=m68klynx
  		configdirs="${configdirs} gdbserver" ;;
! m68*-*-netbsd*)		gdb_target=nbsd ;;
  m68*-*-os68k*)		gdb_target=os68k ;;
  m68*-*-sunos3*)		gdb_target=sun3os3 ;;
  m68*-*-sunos4*)		gdb_target=sun3os4 ;;
--- 167,174 ----
  		configdirs="${configdirs} gdbserver" ;;
  m68*-*-lynxos*)		gdb_target=m68klynx
  		configdirs="${configdirs} gdbserver" ;;
! m68*-*-netbsd*)		gdb_target=nbsd
! 		configdirs="${configdirs} gdbserver" ;;
  m68*-*-os68k*)		gdb_target=os68k ;;
  m68*-*-sunos3*)		gdb_target=sun3os3 ;;
  m68*-*-sunos4*)		gdb_target=sun3os4 ;;
***************
*** 222,228 ****
  none-*-*)		gdb_target=none ;;
  
  ns32k-*-mach3*)		gdb_target=ns32km3 ;;
! ns32k-*-netbsd*)	gdb_target=nbsd ;;
  ns32k-utek-sysv*)	gdb_target=merlin ;;
  ns32k-utek-*)		gdb_target=umax ;;
  
--- 223,230 ----
  none-*-*)		gdb_target=none ;;
  
  ns32k-*-mach3*)		gdb_target=ns32km3 ;;
! ns32k-*-netbsd*)	gdb_target=nbsd
! 		configdirs="${configdirs} gdbserver" ;;
  ns32k-utek-sysv*)	gdb_target=merlin ;;
  ns32k-utek-*)		gdb_target=umax ;;
  
Index: config/m68k/nbsd.mt
===================================================================
RCS file: /cvs/src/src/gdb/config/m68k/nbsd.mt,v
retrieving revision 1.3
diff -c -r1.3 nbsd.mt
*** nbsd.mt	2000/11/09 22:57:02	1.3
--- nbsd.mt	2000/12/02 00:40:45
***************
*** 1,3 ****
--- 1,5 ----
  # Target: Motorola m68k running NetBSD
  TDEPFILES= m68k-tdep.o solib.o solib-svr4.o
  TM_FILE= tm-nbsd.h
+ 
+ GDBSERVER_DEPFILES= low-nbsd.o
Index: config/ns32k/nbsd.mt
===================================================================
RCS file: /cvs/src/src/gdb/config/ns32k/nbsd.mt,v
retrieving revision 1.3
diff -c -r1.3 nbsd.mt
*** nbsd.mt	2000/11/09 22:57:02	1.3
--- nbsd.mt	2000/12/02 00:40:46
***************
*** 1,3 ****
--- 1,5 ----
  # Target: PC532 running NetBSD
  TDEPFILES= ns32k-tdep.o solib.o solib-svr4.o
  TM_FILE= tm-nbsd.h
+ 
+ GDBSERVER_DEPFILES= low-nbsd.o
Index: gdbserver/low-hppabsd.c
===================================================================
RCS file: /cvs/src/src/gdb/gdbserver/low-hppabsd.c,v
retrieving revision 1.2
diff -c -r1.2 low-hppabsd.c
*** low-hppabsd.c	2000/07/30 01:48:28	1.2
--- low-hppabsd.c	2000/12/02 00:40:46
***************
*** 33,61 ****
  #include <fcntl.h>
  
  /***************Begin MY defs*********************/
- int quit_flag = 0;
  static char my_registers[REGISTER_BYTES];
  char *registers = my_registers;
- 
- /* Index within `registers' of the first byte of the space for
-    register N.  */
- 
- 
- char buf2[MAX_REGISTER_RAW_SIZE];
  /***************End MY defs*********************/
  
  #include <sys/ptrace.h>
  #include <machine/reg.h>
  
- extern char **environ;
  extern int errno;
  extern int inferior_pid;
! void quit (), perror_with_name ();
! int query ();
  
  /* Start an inferior process and returns its pid.
!    ALLARGS is a vector of program-name and args.
!    ENV is the environment vector to pass.  */
  
  int
  create_inferior (char *program, char **allargs)
--- 33,51 ----
  #include <fcntl.h>
  
  /***************Begin MY defs*********************/
  static char my_registers[REGISTER_BYTES];
  char *registers = my_registers;
  /***************End MY defs*********************/
  
  #include <sys/ptrace.h>
  #include <machine/reg.h>
  
  extern int errno;
  extern int inferior_pid;
! void perror_with_name ();
  
  /* Start an inferior process and returns its pid.
!    ALLARGS is a vector of program-name and args. */
  
  int
  create_inferior (char *program, char **allargs)
Index: gdbserver/low-linux.c
===================================================================
RCS file: /cvs/src/src/gdb/gdbserver/low-linux.c,v
retrieving revision 1.4
diff -c -r1.4 low-linux.c
*** low-linux.c	2000/07/30 01:48:28	1.4
--- low-linux.c	2000/12/02 00:40:46
***************
*** 33,47 ****
  #include <fcntl.h>
  
  /***************Begin MY defs*********************/
- int quit_flag = 0;
  static char my_registers[REGISTER_BYTES];
  char *registers = my_registers;
- 
- /* Index within `registers' of the first byte of the space for
-    register N.  */
- 
- 
- char buf2[MAX_REGISTER_RAW_SIZE];
  /***************End MY defs*********************/
  
  #ifdef HAVE_SYS_REG_H
--- 33,40 ----
***************
*** 53,69 ****
  #define PTRACE_XFER_TYPE int
  #endif
  
- extern char **environ;
  extern int errno;
  extern int inferior_pid;
! void quit (), perror_with_name ();
! int query ();
  
  static void initialize_arch (void);
  
  /* Start an inferior process and returns its pid.
!    ALLARGS is a vector of program-name and args.
!    ENV is the environment vector to pass.  */
  
  int
  create_inferior (char *program, char **allargs)
--- 46,59 ----
  #define PTRACE_XFER_TYPE int
  #endif
  
  extern int errno;
  extern int inferior_pid;
! void perror_with_name ();
  
  static void initialize_arch (void);
  
  /* Start an inferior process and returns its pid.
!    ALLARGS is a vector of program-name and args. */
  
  int
  create_inferior (char *program, char **allargs)
Index: gdbserver/low-nbsd.c
===================================================================
RCS file: /cvs/src/src/gdb/gdbserver/low-nbsd.c,v
retrieving revision 1.5
diff -c -r1.5 low-nbsd.c
*** low-nbsd.c	2000/11/21 00:25:58	1.5
--- low-nbsd.c	2000/12/02 00:40:47
***************
*** 27,50 ****
  #include <errno.h>
  
  /***************Begin MY defs*********************/
- int quit_flag = 0;
  static char my_registers[REGISTER_BYTES];
  char *registers = my_registers;
- 
- /* Index within `registers' of the first byte of the space for
-    register N.  */
- 
- char buf2[MAX_REGISTER_RAW_SIZE];
  /***************End MY defs*********************/
  
  #include <sys/ptrace.h>
  #include <machine/reg.h>
  
! extern int sys_nerr;
  // extern char **sys_errlist;
- extern char **environ;
  extern int inferior_pid;
! void quit (), perror_with_name ();
  
  #define RF(dst, src) \
  	memcpy(&registers[REGISTER_BYTE(dst)], &src, sizeof(src))
--- 27,43 ----
  #include <errno.h>
  
  /***************Begin MY defs*********************/
  static char my_registers[REGISTER_BYTES];
  char *registers = my_registers;
  /***************End MY defs*********************/
  
  #include <sys/ptrace.h>
  #include <machine/reg.h>
  
! // extern int sys_nerr;
  // extern char **sys_errlist;
  extern int inferior_pid;
! void perror_with_name ();
  
  #define RF(dst, src) \
  	memcpy(&registers[REGISTER_BYTE(dst)], &src, sizeof(src))
***************
*** 106,111 ****
--- 99,118 ----
  }       
  #endif	/* !__i386__ */
  
+ #ifdef __m68k__
+ static void
+ initialize_arch (void)
+ {
+ }
+ #endif	/* !__m68k__ */
+ 
+ #ifdef __ns32k__
+ static void
+ initialize_arch (void)
+ {
+ }
+ #endif	/* !__ns32k__ */
+ 
  #ifdef __powerpc__
  #include "ppc-tdep.h"
  
***************
*** 117,124 ****
  
  
  /* Start an inferior process and returns its pid.
!    ALLARGS is a vector of program-name and args.
!    ENV is the environment vector to pass.  */
  
  int
  create_inferior (char *program, char **allargs)
--- 124,130 ----
  
  
  /* Start an inferior process and returns its pid.
!    ALLARGS is a vector of program-name and args. */
  
  int
  create_inferior (char *program, char **allargs)
***************
*** 312,317 ****
--- 318,451 ----
  	  (PTRACE_ARG3_TYPE) &inferior_fp_registers, 0);
  }
  #endif	/* !__i386__ */
+ 
+ #ifdef __m68k__
+ /* Fetch one or more registers from the inferior.  REGNO == -1 to get
+    them all.  We actually fetch more than requested, when convenient,
+    marking them as valid so we won't fetch them again.  */
+ 
+ void
+ fetch_inferior_registers (int regno)
+ {
+   struct reg inferior_registers;
+   struct fpreg inferior_fp_registers;
+ 
+   ptrace (PT_GETREGS, inferior_pid,
+           (PTRACE_ARG3_TYPE) & inferior_registers, 0);
+   memcpy (&registers[REGISTER_BYTE (0)], &inferior_registers,
+           sizeof (inferior_registers));
+ 
+   ptrace (PT_GETFPREGS, inferior_pid,
+           (PTRACE_ARG3_TYPE) & inferior_fp_registers, 0);
+   memcpy (&registers[REGISTER_BYTE (FP0_REGNUM)], &inferior_fp_registers,
+           sizeof (inferior_fp_registers));
+ }
+ 
+ /* Store our register values back into the inferior.
+    If REGNO is -1, do this for all registers.
+    Otherwise, REGNO specifies which register (so we can save time).  */
+ 
+ void
+ store_inferior_registers (int regno)
+ {
+   struct reg inferior_registers;
+   struct fpreg inferior_fp_registers;
+ 
+   memcpy (&inferior_registers, &registers[REGISTER_BYTE (0)],
+           sizeof (inferior_registers));
+   ptrace (PT_SETREGS, inferior_pid,
+           (PTRACE_ARG3_TYPE) & inferior_registers, 0);
+ 
+   memcpy (&inferior_fp_registers, &registers[REGISTER_BYTE (FP0_REGNUM)],
+           sizeof (inferior_fp_registers));
+   ptrace (PT_SETFPREGS, inferior_pid,
+           (PTRACE_ARG3_TYPE) & inferior_fp_registers, 0);
+ }
+ #endif	/* !__m68k__ */
+ 
+ 
+ #ifdef __ns32k__
+ /* Fetch one or more registers from the inferior.  REGNO == -1 to get
+    them all.  We actually fetch more than requested, when convenient,
+    marking them as valid so we won't fetch them again.  */
+ 
+ void
+ fetch_inferior_registers (int regno)
+ {
+   struct reg inferior_registers;
+   struct fpreg inferior_fpregisters;
+ 
+   ptrace (PT_GETREGS, inferior_pid,
+           (PTRACE_ARG3_TYPE) & inferior_registers, 0);
+   ptrace (PT_GETFPREGS, inferior_pid,
+           (PTRACE_ARG3_TYPE) & inferior_fpregisters, 0);
+ 
+   RF (R0_REGNUM + 0, inferior_registers.r_r0);
+   RF (R0_REGNUM + 1, inferior_registers.r_r1);
+   RF (R0_REGNUM + 2, inferior_registers.r_r2);
+   RF (R0_REGNUM + 3, inferior_registers.r_r3);
+   RF (R0_REGNUM + 4, inferior_registers.r_r4);
+   RF (R0_REGNUM + 5, inferior_registers.r_r5);
+   RF (R0_REGNUM + 6, inferior_registers.r_r6);
+   RF (R0_REGNUM + 7, inferior_registers.r_r7);
+ 
+   RF (SP_REGNUM, inferior_registers.r_sp);
+   RF (FP_REGNUM, inferior_registers.r_fp);
+   RF (PC_REGNUM, inferior_registers.r_pc);
+   RF (PS_REGNUM, inferior_registers.r_psr);
+ 
+   RF (FPS_REGNUM, inferior_fpregisters.r_fsr);
+   RF (FP0_REGNUM + 0, inferior_fpregisters.r_freg[0]);
+   RF (FP0_REGNUM + 2, inferior_fpregisters.r_freg[2]);
+   RF (FP0_REGNUM + 4, inferior_fpregisters.r_freg[4]);
+   RF (FP0_REGNUM + 6, inferior_fpregisters.r_freg[6]);
+   RF (LP0_REGNUM + 1, inferior_fpregisters.r_freg[1]);
+   RF (LP0_REGNUM + 3, inferior_fpregisters.r_freg[3]);
+   RF (LP0_REGNUM + 5, inferior_fpregisters.r_freg[5]);
+   RF (LP0_REGNUM + 7, inferior_fpregisters.r_freg[7]);
+ }
+ 
+ /* Store our register values back into the inferior.
+    If REGNO is -1, do this for all registers.
+    Otherwise, REGNO specifies which register (so we can save time).  */
+ 
+ void
+ store_inferior_registers (int regno)
+ {
+   struct reg inferior_registers;
+   struct fpreg inferior_fpregisters;
+ 
+   RS (R0_REGNUM + 0, inferior_registers.r_r0);
+   RS (R0_REGNUM + 1, inferior_registers.r_r1);
+   RS (R0_REGNUM + 2, inferior_registers.r_r2);
+   RS (R0_REGNUM + 3, inferior_registers.r_r3);
+   RS (R0_REGNUM + 4, inferior_registers.r_r4);
+   RS (R0_REGNUM + 5, inferior_registers.r_r5);
+   RS (R0_REGNUM + 6, inferior_registers.r_r6);
+   RS (R0_REGNUM + 7, inferior_registers.r_r7);
+   
+   RS (SP_REGNUM, inferior_registers.r_sp);
+   RS (FP_REGNUM, inferior_registers.r_fp);
+   RS (PC_REGNUM, inferior_registers.r_pc);
+   RS (PS_REGNUM, inferior_registers.r_psr);
+   
+   RS (FPS_REGNUM, inferior_fpregisters.r_fsr);
+   RS (FP0_REGNUM + 0, inferior_fpregisters.r_freg[0]);
+   RS (FP0_REGNUM + 2, inferior_fpregisters.r_freg[2]);
+   RS (FP0_REGNUM + 4, inferior_fpregisters.r_freg[4]);
+   RS (FP0_REGNUM + 6, inferior_fpregisters.r_freg[6]);
+   RS (LP0_REGNUM + 1, inferior_fpregisters.r_freg[1]);
+   RS (LP0_REGNUM + 3, inferior_fpregisters.r_freg[3]);
+   RS (LP0_REGNUM + 5, inferior_fpregisters.r_freg[5]);
+   RS (LP0_REGNUM + 7, inferior_fpregisters.r_freg[7]);
+   
+   ptrace (PT_SETREGS, inferior_pid,
+           (PTRACE_ARG3_TYPE) & inferior_registers, 0);
+   ptrace (PT_SETFPREGS, inferior_pid,
+           (PTRACE_ARG3_TYPE) & inferior_fpregisters, 0);
+ 
+ }
+ #endif	/* !__ns32k__ */
  
  #ifdef __powerpc__
  /* Fetch one or more registers from the inferior.  REGNO == -1 to get
Index: gdbserver/low-sparc.c
===================================================================
RCS file: /cvs/src/src/gdb/gdbserver/low-sparc.c,v
retrieving revision 1.2
diff -c -r1.2 low-sparc.c
*** low-sparc.c	2000/07/30 01:48:28	1.2
--- low-sparc.c	2000/12/02 00:40:47
***************
*** 36,50 ****
  #include <fcntl.h>
  
  /***************Begin MY defs*********************/
- int quit_flag = 0;
  static char my_registers[REGISTER_BYTES];
  char *registers = my_registers;
- 
- /* Index within `registers' of the first byte of the space for
-    register N.  */
- 
- 
- char buf2[MAX_REGISTER_RAW_SIZE];
  /***************End MY defs*********************/
  
  #include <sys/ptrace.h>
--- 36,43 ----
***************
*** 52,66 ****
  
  extern int sys_nerr;
  extern char **sys_errlist;
- extern char **environ;
  extern int errno;
  extern int inferior_pid;
! void quit (), perror_with_name ();
! int query ();
  
  /* Start an inferior process and returns its pid.
!    ALLARGS is a vector of program-name and args.
!    ENV is the environment vector to pass.  */
  
  int
  create_inferior (char *program, char **allargs)
--- 45,56 ----
  
  extern int sys_nerr;
  extern char **sys_errlist;
  extern int errno;
  extern int inferior_pid;
! void perror_with_name ();
  
  /* Start an inferior process and returns its pid.
!    ALLARGS is a vector of program-name and args. */
  
  int
  create_inferior (char *program, char **allargs)
Index: gdbserver/low-sun3.c
===================================================================
RCS file: /cvs/src/src/gdb/gdbserver/low-sun3.c,v
retrieving revision 1.2
diff -c -r1.2 low-sun3.c
*** low-sun3.c	2000/07/30 01:48:28	1.2
--- low-sun3.c	2000/12/02 00:40:47
***************
*** 33,47 ****
  #include <fcntl.h>
  
  /***************Begin MY defs*********************/
- int quit_flag = 0;
  static char my_registers[REGISTER_BYTES];
  char *registers = my_registers;
- 
- /* Index within `registers' of the first byte of the space for
-    register N.  */
- 
- 
- char buf2[MAX_REGISTER_RAW_SIZE];
  /***************End MY defs*********************/
  
  #include <sys/ptrace.h>
--- 33,40 ----
***************
*** 49,63 ****
  
  extern int sys_nerr;
  extern char **sys_errlist;
- extern char **environ;
  extern int errno;
  extern int inferior_pid;
! void quit (), perror_with_name ();
! int query ();
  
  /* Start an inferior process and returns its pid.
!    ALLARGS is a vector of program-name and args.
!    ENV is the environment vector to pass.  */
  
  int
  create_inferior (char *program, char **allargs)
--- 42,53 ----
  
  extern int sys_nerr;
  extern char **sys_errlist;
  extern int errno;
  extern int inferior_pid;
! void perror_with_name ();
  
  /* Start an inferior process and returns its pid.
!    ALLARGS is a vector of program-name and args. */
  
  int
  create_inferior (char *program, char **allargs)


-- 
J.T. Conklin
RedBack Networks

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]