* dsrec.c (load_srec, make_srec): Use bfd_get_section_size instead of
[binutils-gdb.git] / gdb / infptrace.c
index e75ea4c41f2ed65b688bda54547f680608cdc381..f40e6e97703905891437646dcfc3e6c7808c0a2e 100644 (file)
 #define PT_KILL                8       /* Send child a SIGKILL signal */
 #endif
 
-#ifndef PT_ATTACH
-#define PT_ATTACH PTRACE_ATTACH
-#endif
-#ifndef PT_DETACH
-#define PT_DETACH PTRACE_DETACH
-#endif
-
 #include "gdbcore.h"
 #ifndef        NO_SYS_FILE
 #include <sys/file.h>
@@ -208,6 +201,7 @@ ptrace_wait (ptid_t ptid, int *status)
   return wstate;
 }
 
+#ifndef KILL_INFERIOR
 void
 kill_inferior (void)
 {
@@ -229,6 +223,7 @@ kill_inferior (void)
   ptrace_wait (null_ptid, &status);
   target_mourn_inferior ();
 }
+#endif /* KILL_INFERIOR */
 
 #ifndef CHILD_RESUME
 
@@ -277,18 +272,25 @@ child_resume (ptid_t ptid, int step, enum target_signal signal)
 }
 #endif /* CHILD_RESUME */
 \f
-
-#ifdef ATTACH_DETACH
 /* Start debugging the process whose number is PID.  */
 int
 attach (int pid)
 {
   errno = 0;
+#ifndef PT_ATTACH
+#ifdef PTRACE_ATTACH
+#define PT_ATTACH PTRACE_ATTACH
+#endif
+#endif
+#ifdef PT_ATTACH
   ptrace (PT_ATTACH, pid, (PTRACE_ARG3_TYPE) 0, 0);
   if (errno)
     perror_with_name ("ptrace");
   attach_flag = 1;
   return pid;
+#else
+  error ("This system does not support attaching to a process");
+#endif
 }
 
 /* Stop debugging the process whose number is PID
@@ -299,13 +301,21 @@ void
 detach (int signal)
 {
   errno = 0;
+#ifndef PT_DETACH
+#ifdef PTRACE_DETACH
+#define PT_DETACH PTRACE_DETACH
+#endif
+#endif
+#ifdef PT_DETACH
   ptrace (PT_DETACH, PIDGET (inferior_ptid), (PTRACE_ARG3_TYPE) 1,
           signal);
   if (errno)
-    perror_with_name ("ptrace");
+    print_sys_errmsg ("ptrace", errno);
   attach_flag = 0;
+#else
+  error ("This system does not support detaching from a process");
+#endif
 }
-#endif /* ATTACH_DETACH */
 \f
 /* Default the type of the ptrace transfer to int.  */
 #ifndef PTRACE_XFER_TYPE
@@ -357,14 +367,14 @@ fetch_register (int regno)
   /* This isn't really an address.  But ptrace thinks of it as one.  */
   CORE_ADDR regaddr;
   char mess[128];              /* For messages */
-  register int i;
+  int i;
   unsigned int offset;         /* Offset of registers within the u area.  */
-  char *buf = alloca (MAX_REGISTER_RAW_SIZE);
+  char buf[MAX_REGISTER_SIZE];
   int tid;
 
   if (CANNOT_FETCH_REGISTER (regno))
     {
-      memset (buf, '\0', REGISTER_RAW_SIZE (regno));   /* Supply zeroes */
+      memset (buf, '\0', DEPRECATED_REGISTER_RAW_SIZE (regno));        /* Supply zeroes */
       supply_register (regno, buf);
       return;
     }
@@ -376,7 +386,7 @@ fetch_register (int regno)
   offset = U_REGS_OFFSET;
 
   regaddr = register_addr (regno, offset);
-  for (i = 0; i < REGISTER_RAW_SIZE (regno); i += sizeof (PTRACE_XFER_TYPE))
+  for (i = 0; i < DEPRECATED_REGISTER_RAW_SIZE (regno); i += sizeof (PTRACE_XFER_TYPE))
     {
       errno = 0;
       *(PTRACE_XFER_TYPE *) & buf[i] = ptrace (PT_READ_U, tid,
@@ -421,10 +431,10 @@ store_register (int regno)
   /* This isn't really an address.  But ptrace thinks of it as one.  */
   CORE_ADDR regaddr;
   char mess[128];              /* For messages */
-  register int i;
+  int i;
   unsigned int offset;         /* Offset of registers within the u area.  */
   int tid;
-  char *buf = alloca (MAX_REGISTER_RAW_SIZE);
+  char buf[MAX_REGISTER_SIZE];
 
   if (CANNOT_STORE_REGISTER (regno))
     {
@@ -443,7 +453,7 @@ store_register (int regno)
   regcache_collect (regno, buf);
 
   /* Store the local buffer into the inferior a chunk at the time. */
-  for (i = 0; i < REGISTER_RAW_SIZE (regno); i += sizeof (PTRACE_XFER_TYPE))
+  for (i = 0; i < DEPRECATED_REGISTER_RAW_SIZE (regno); i += sizeof (PTRACE_XFER_TYPE))
     {
       errno = 0;
       ptrace (PT_WRITE_U, tid, (PTRACE_ARG3_TYPE) regaddr,
@@ -596,9 +606,6 @@ child_xfer_memory (CORE_ADDR memaddr, char *myaddr, int len, int write,
          if (errno)
            return 0;
        }
-#ifdef CLEAR_INSN_CACHE
-      CLEAR_INSN_CACHE ();
-#endif
     }
   else
     {