*** empty log message ***
[deliverable/binutils-gdb.git] / gdb / inftarg.c
index 90762f867a12bd6b01194f9c8259a328ee847db7..9035310c4947f1f5b9638f534f62f2975c8bff84 100644 (file)
@@ -1,5 +1,7 @@
 /* Target-vector operations for controlling Unix child processes, for GDB.
-   Copyright 1990-1996, 1998, 1999 Free Software Foundation, Inc.
+   Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1998, 1999, 
+   2000, 2002
+   Free Software Foundation, Inc.
    Contributed by Cygnus Support.
 
    ## Contains temporary hacks..
@@ -46,11 +48,11 @@ extern void _initialize_inftarg (void);
 static void child_prepare_to_store (void);
 
 #ifndef CHILD_WAIT
-static int child_wait (int, struct target_waitstatus *);
+static ptid_t child_wait (ptid_t, struct target_waitstatus *);
 #endif /* CHILD_WAIT */
 
 #if !defined(CHILD_POST_WAIT)
-void child_post_wait (int, int);
+void child_post_wait (ptid_t, int);
 #endif
 
 static void child_open (char *, int);
@@ -86,7 +88,7 @@ static int child_can_run (void);
 static void child_stop (void);
 
 #ifndef CHILD_THREAD_ALIVE
-int child_thread_alive (int);
+int child_thread_alive (ptid_t);
 #endif
 
 static void init_child_ops (void);
@@ -115,8 +117,8 @@ int not_same_real_pid = 1;
 /* Wait for child to do something.  Return pid of child, or -1 in case
    of error; store status through argument pointer OURSTATUS.  */
 
-static int
-child_wait (int pid, struct target_waitstatus *ourstatus)
+static ptid_t
+child_wait (ptid_t ptid, struct target_waitstatus *ourstatus)
 {
   int save_errno;
   int status;
@@ -125,6 +127,7 @@ child_wait (int pid, struct target_waitstatus *ourstatus)
   int related_pid;
   int syscall_id;
   enum target_waitkind kind;
+  int pid;
 
   do
     {
@@ -132,7 +135,7 @@ child_wait (int pid, struct target_waitstatus *ourstatus)
                                   attached process. */
       set_sigio_trap ();
 
-      pid = ptrace_wait (inferior_pid, &status);
+      pid = ptrace_wait (inferior_ptid, &status);
 
       save_errno = errno;
 
@@ -151,7 +154,7 @@ child_wait (int pid, struct target_waitstatus *ourstatus)
          /* Claim it exited with unknown signal.  */
          ourstatus->kind = TARGET_WAITKIND_SIGNALLED;
          ourstatus->value.sig = TARGET_SIGNAL_UNKNOWN;
-         return -1;
+         return pid_to_ptid (-1);
        }
 
       /* Did it exit?
@@ -162,26 +165,28 @@ child_wait (int pid, struct target_waitstatus *ourstatus)
          continue;
        }
 
-      if (!target_thread_alive (pid))
+      if (!target_thread_alive (pid_to_ptid (pid)))
        {
          ourstatus->kind = TARGET_WAITKIND_SPURIOUS;
-         return pid;
+         return pid_to_ptid (pid);
        }
 
       if (target_has_forked (pid, &related_pid)
-         && ((pid == inferior_pid) || (related_pid == inferior_pid)))
+         && ((pid == PIDGET (inferior_ptid)) 
+             || (related_pid == PIDGET (inferior_ptid))))
        {
          ourstatus->kind = TARGET_WAITKIND_FORKED;
          ourstatus->value.related_pid = related_pid;
-         return pid;
+         return pid_to_ptid (pid);
        }
 
       if (target_has_vforked (pid, &related_pid)
-         && ((pid == inferior_pid) || (related_pid == inferior_pid)))
+         && ((pid == PIDGET (inferior_ptid))
+             || (related_pid == PIDGET (inferior_ptid))))
        {
          ourstatus->kind = TARGET_WAITKIND_VFORKED;
          ourstatus->value.related_pid = related_pid;
-         return pid;
+         return pid_to_ptid (pid);
        }
 
       if (target_has_execd (pid, &execd_pathname))
@@ -199,7 +204,7 @@ child_wait (int pid, struct target_waitstatus *ourstatus)
            {
              ourstatus->kind = TARGET_WAITKIND_EXECD;
              ourstatus->value.execd_pathname = execd_pathname;
-             return pid;
+             return pid_to_ptid (pid);
            }
        }
 
@@ -210,23 +215,23 @@ child_wait (int pid, struct target_waitstatus *ourstatus)
        {
          ourstatus->kind = kind;
          ourstatus->value.syscall_id = syscall_id;
-         return pid;
+         return pid_to_ptid (pid);
        }
 
-      /*##  } while (pid != inferior_pid); ## *//* Some other child died or stopped */
+      /*##  } while (pid != PIDGET (inferior_ptid)); ## *//* Some other child died or stopped */
 /* hack for thread testing */
     }
-  while ((pid != inferior_pid) && not_same_real_pid);
+  while ((pid != PIDGET (inferior_ptid)) && not_same_real_pid);
 /*## */
 
   store_waitstatus (ourstatus, status);
-  return pid;
+  return pid_to_ptid (pid);
 }
 #endif /* CHILD_WAIT */
 
 #if !defined(CHILD_POST_WAIT)
 void
-child_post_wait (int pid, int wait_status)
+child_post_wait (ptid_t ptid, int wait_status)
 {
   /* This version of Unix doesn't require a meaningful "post wait"
      operation.
@@ -243,8 +248,10 @@ child_post_wait (int pid, int wait_status)
    for now we're going to try and be compatable with the old thread
    code.  */
 int
-child_thread_alive (int pid)
+child_thread_alive (ptid_t ptid)
 {
+  pid_t pid = PIDGET (ptid);
+
   return (kill (pid, 0) != -1);
 }
 
@@ -279,12 +286,13 @@ child_attach_to_process (char *args, int from_tty, int after_fork)
 
        if (after_fork)
          printf_unfiltered ("Attaching after fork to %s\n",
-                            target_pid_to_str (pid));
+                            target_pid_to_str (pid_to_ptid (pid)));
        else if (exec_file)
          printf_unfiltered ("Attaching to program: %s, %s\n", exec_file,
-                            target_pid_to_str (pid));
+                            target_pid_to_str (pid_to_ptid (pid)));
        else
-         printf_unfiltered ("Attaching to %s\n", target_pid_to_str (pid));
+         printf_unfiltered ("Attaching to %s\n", 
+                            target_pid_to_str (pid_to_ptid (pid)));
 
        gdb_flush (gdb_stdout);
       }
@@ -294,7 +302,7 @@ child_attach_to_process (char *args, int from_tty, int after_fork)
     else
       REQUIRE_ATTACH (pid);
 
-    inferior_pid = pid;
+    inferior_ptid = pid_to_ptid (pid);
     push_target (&child_ops);
   }
 #endif /* ATTACH_DETACH */
@@ -338,10 +346,10 @@ child_detach_from_process (int pid, char *args, int from_tty, int after_fork)
          exec_file = "";
        if (after_fork)
          printf_unfiltered ("Detaching after fork from %s\n",
-                            target_pid_to_str (pid));
+                            target_pid_to_str (pid_to_ptid (pid)));
        else
          printf_unfiltered ("Detaching from program: %s, %s\n", exec_file,
-                            target_pid_to_str (pid));
+                            target_pid_to_str (pid_to_ptid (pid)));
        gdb_flush (gdb_stdout);
       }
     if (args)
@@ -368,8 +376,8 @@ child_detach_from_process (int pid, char *args, int from_tty, int after_fork)
 static void
 child_detach (char *args, int from_tty)
 {
-  child_detach_from_process (inferior_pid, args, from_tty, 0);
-  inferior_pid = 0;
+  child_detach_from_process (PIDGET (inferior_ptid), args, from_tty, 0);
+  inferior_ptid = null_ptid;
   unpush_target (&child_ops);
 }
 
@@ -400,7 +408,7 @@ static void
 child_files_info (struct target_ops *ignore)
 {
   printf_unfiltered ("\tUsing the running image of %s %s.\n",
-      attach_flag ? "attached" : "child", target_pid_to_str (inferior_pid));
+      attach_flag ? "attached" : "child", target_pid_to_str (inferior_ptid));
 }
 
 /* ARGSUSED */
@@ -445,10 +453,10 @@ ptrace_him (int pid)
   /* On some targets, there must be some explicit actions taken after
      the inferior has been started up.
    */
-  target_post_startup_inferior (pid);
+  target_post_startup_inferior (pid_to_ptid (pid));
 }
 
-/* Start an inferior Unix child process and sets inferior_pid to its pid.
+/* Start an inferior Unix child process and sets inferior_ptid to its pid.
    EXEC_FILE is the file to run.
    ALLARGS is a string containing the arguments to the program.
    ENV is the environment vector to pass.  Errors reported with error().  */
@@ -468,7 +476,7 @@ child_create_inferior (char *exec_file, char *allargs, char **env)
 
 #if !defined(CHILD_POST_STARTUP_INFERIOR)
 void
-child_post_startup_inferior (int pid)
+child_post_startup_inferior (ptid_t ptid)
 {
   /* This version of Unix doesn't require a meaningful "post startup inferior"
      operation by a debugger.
@@ -735,9 +743,9 @@ child_core_file_to_sym_file (char *core)
 
 #if !defined(CHILD_PID_TO_STR)
 char *
-child_pid_to_str (int pid)
+child_pid_to_str (ptid_t ptid)
 {
-  return normal_pid_to_str (pid);
+  return normal_pid_to_str (ptid);
 }
 #endif
 
@@ -796,7 +804,6 @@ init_child_ops (void)
   child_ops.to_enable_exception_callback = child_enable_exception_callback;
   child_ops.to_get_current_exception_event = child_get_current_exception_event;
   child_ops.to_pid_to_exec_file = child_pid_to_exec_file;
-  child_ops.to_core_file_to_sym_file = child_core_file_to_sym_file;
   child_ops.to_stratum = process_stratum;
   child_ops.to_has_all_memory = 1;
   child_ops.to_has_memory = 1;
@@ -806,6 +813,24 @@ init_child_ops (void)
   child_ops.to_magic = OPS_MAGIC;
 }
 
+/* Take over the 'find_mapped_memory' vector from inftarg.c. */
+extern void 
+inftarg_set_find_memory_regions (int (*func) (int (*) (CORE_ADDR, 
+                                                      unsigned long, 
+                                                      int, int, int, 
+                                                      void *),
+                                             void *))
+{
+  child_ops.to_find_memory_regions = func;
+}
+
+/* Take over the 'make_corefile_notes' vector from inftarg.c. */
+extern void 
+inftarg_set_make_corefile_notes (char * (*func) (bfd *, int *))
+{
+  child_ops.to_make_corefile_notes = func;
+}
+
 void
 _initialize_inftarg (void)
 {
This page took 0.028132 seconds and 4 git commands to generate.