/* 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
+ Free Software Foundation, Inc.
Contributed by Cygnus Support.
## Contains temporary hacks..
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);
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);
/* 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;
int related_pid;
int syscall_id;
enum target_waitkind kind;
+ int pid;
do
{
attached process. */
set_sigio_trap ();
- pid = ptrace_wait (inferior_pid, &status);
+ pid = ptrace_wait (inferior_ptid, &status);
save_errno = errno;
/* 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?
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))
{
ourstatus->kind = TARGET_WAITKIND_EXECD;
ourstatus->value.execd_pathname = execd_pathname;
- return pid;
+ return pid_to_ptid (pid);
}
}
{
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.
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);
}
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);
}
else
REQUIRE_ATTACH (pid);
- inferior_pid = pid;
+ inferior_ptid = pid_to_ptid (pid);
push_target (&child_ops);
}
#endif /* ATTACH_DETACH */
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)
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);
}
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 */
/* 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(). */
#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.
#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
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;