(gnu_detach): Remove it.
* go32-nat.c (go32_create_inferior): Add process to gdb's inferior
table.
* inf-ptrace.c (inf_ptrace_follow_fork): Delete and add inferiors
to inferior table accordingly.
(inf_ptrace_attach): Add new process to inferior table.
(inf_ptrace_detach): Remove it.
* inf-ttrace.c (inf_ttrace_follow_fork): Delete and add inferiors
to inferior table accordingly.
(inf_ttrace_attach): Add process to inferior table.
(inf_ttrace_detach): Remove it.
* linux-fork.c (init_fork_list): Delete any left over inferior.
(linux_fork_mourn_inferior, detach_fork_command): Also delete
processes from inferior list.
* monitor.c (monitor_open): Add process to inferior list.
(monitor_close): Remove it.
* nto-procfs.c (procfs_attach): Add process to inferior list.
Find threads after pushing the target.
(procfs_detach): Remove process from inferior list.
(procfs_create_inferior): Add process to inferior list.
* procfs.c (procfs_detach): Remove process from inferior list.
(do_attach): Add process to inferior list.
* remote-sim.c (sim_create_inferior): Add process to inferior list.
(gdbsim_close): Remove it.
* target.c (generic_mourn_inferior): If inferior_ptid is not
null_ptid, remove the corresponding inferior from inferior list.
* win32-nat.c (do_initial_win32_stuff): Add process to inferior list.
(win32_detach): Remove it.
* linux-nat.c (linux_child_follow_fork): Delete and add inferiors
to inferior list accordingly.
* fork-child.c (fork_inferior): Add process to inferior list.
* corelow.c (CORELOW_PID): Define.
(core_close): Remove core from inferior list.
(core_open): Add it.
+2008-09-22 Pedro Alves <pedro@codesourcery.com>
+
+ * gnu-nat.c (gnu_attach): Add process to inferiors table.
+ (gnu_detach): Remove it.
+ * go32-nat.c (go32_create_inferior): Add process to gdb's inferior
+ table.
+ * inf-ptrace.c (inf_ptrace_follow_fork): Delete and add inferiors
+ to inferior table accordingly.
+ (inf_ptrace_attach): Add new process to inferior table.
+ (inf_ptrace_detach): Remove it.
+ * inf-ttrace.c (inf_ttrace_follow_fork): Delete and add inferiors
+ to inferior table accordingly.
+ (inf_ttrace_attach): Add process to inferior table.
+ (inf_ttrace_detach): Remove it.
+ * linux-fork.c (init_fork_list): Delete any left over inferior.
+ (linux_fork_mourn_inferior, detach_fork_command): Also delete
+ processes from inferior list.
+ * monitor.c (monitor_open): Add process to inferior list.
+ (monitor_close): Remove it.
+ * nto-procfs.c (procfs_attach): Add process to inferior list.
+ Find threads after pushing the target.
+ (procfs_detach): Remove process from inferior list.
+ (procfs_create_inferior): Add process to inferior list.
+ * procfs.c (procfs_detach): Remove process from inferior list.
+ (do_attach): Add process to inferior list.
+ * remote-sim.c (sim_create_inferior): Add process to inferior list.
+ (gdbsim_close): Remove it.
+ * target.c (generic_mourn_inferior): If inferior_ptid is not
+ null_ptid, remove the corresponding inferior from inferior list.
+ * win32-nat.c (do_initial_win32_stuff): Add process to inferior list.
+ (win32_detach): Remove it.
+ * linux-nat.c (linux_child_follow_fork): Delete and add inferiors
+ to inferior list accordingly.
+ * fork-child.c (fork_inferior): Add process to inferior list.
+ * corelow.c (CORELOW_PID): Define.
+ (core_close): Remove core from inferior list.
+ (core_open): Add it.
+
2008-09-22 Pedro Alves <pedro@codesourcery.com>
* inferior.h: Forward declare struct ui_out.
struct target_ops core_ops;
+/* An arbitrary identifier for the core inferior. */
+#define CORELOW_PID 1
+
/* Link a new core_fns into the global core_file_fns list. Called on gdb
startup by the _initialize routine in each core file register reader, to
register information about each format the the reader is prepared to
if (core_bfd)
{
inferior_ptid = null_ptid; /* Avoid confusion from thread stuff */
+ delete_inferior_silent (CORELOW_PID);
/* Clear out solib state while the bfd is still open. See
comments in clear_solib in solib.c. */
bfd *temp_bfd;
int scratch_chan;
int flags;
- /* An arbitrary identifier for the core inferior. */
- int corelow_pid = 1;
+ int corelow_pid = CORELOW_PID;
target_preopen (from_tty);
if (!filename)
push_target (&core_ops);
discard_cleanups (old_chain);
+ add_inferior_silent (corelow_pid);
+
/* Do this before acknowledging the inferior, so if
post_create_inferior throws (can happen easilly if you're loading
a core file with the wrong exec), we aren't left with threads
init_thread_list ();
+ add_inferior (pid);
+
/* Needed for wait_for_inferior stuff below. */
inferior_ptid = pid_to_ptid (pid);
push_target (&gnu_ops);
+ add_inferior (pid);
+
inf_update_procs (inf);
inferior_ptid = ptid_build (pid, 0, inf_pick_first_thread ());
static void
gnu_detach (char *args, int from_tty)
{
+ int pid;
+
if (from_tty)
{
char *exec_file = get_exec_file (0);
gdb_flush (gdb_stdout);
}
+ pid = current_inferior->pid;
+
inf_detach (current_inferior);
inferior_ptid = null_ptid;
+ detach_inferior (pid);
unpush_target (&gnu_ops); /* Pop out of handling an inferior */
}
#endif
inferior_ptid = pid_to_ptid (SOME_PID);
+ add_inferior_silent (SOME_PID);
+
push_target (&go32_ops);
add_thread_silent (inferior_ptid);
if (ptrace (PT_DETACH, pid, (PTRACE_TYPE_ARG3)1, 0) == -1)
perror_with_name (("ptrace"));
+ /* Switch inferior_ptid out of the parent's way. */
+ inferior_ptid = pid_to_ptid (fpid);
+
/* Delete the parent. */
- delete_thread_silent (last_tp->ptid);
+ detach_inferior (pid);
/* Add the child. */
- inferior_ptid = pid_to_ptid (fpid);
+ add_inferior (fpid);
tp = add_thread_silent (inferior_ptid);
tp->step_resume_breakpoint = step_resume_breakpoint;
if (ptrace (PT_DETACH, fpid, (PTRACE_TYPE_ARG3)1, 0) == -1)
perror_with_name (("ptrace"));
+ detach_inferior (pid);
}
return 0;
inferior_ptid = pid_to_ptid (pid);
+ add_inferior (pid);
+
/* Always add a main thread. If some target extends the ptrace
target, it should decorate the ptid later with more info. */
add_thread_silent (inferior_ptid);
#endif
inferior_ptid = null_ptid;
+ detach_inferior (pid);
unpush_target (ptrace_ops_hack);
}
last_tp->step_resume_breakpoint = NULL;
inferior_ptid = ptid_build (fpid, flwpid, 0);
+ add_inferior (fpid);
detach_breakpoints (pid);
target_terminal_ours ();
/* Delete parent. */
delete_thread_silent (ptid_build (pid, lwpid, 0));
+ detach_inferior (pid);
- /* Add child. inferior_ptid was already set above. */
+ /* Add child thread. inferior_ptid was already set above. */
ti = add_thread_silent (inferior_ptid);
ti->private =
xmalloc (sizeof (struct inf_ttrace_private_thread_info));
perror_with_name (("ttrace"));
attach_flag = 1;
+ add_inferior (pid);
+
/* Set the initial event mask. */
memset (&tte, 0, sizeof (tte));
tte.tte_events |= TTEVT_EXEC | TTEVT_EXIT | TTEVT_FORK | TTEVT_VFORK;
inf_ttrace_num_lwps = 0;
inf_ttrace_num_lwps_in_syscall = 0;
- unpush_target (ttrace_ops_hack);
inferior_ptid = null_ptid;
+ detach_inferior (pid);
+
+ unpush_target (ttrace_ops_hack);
}
static void
for (fp = fork_list; fp; fp = fpnext)
{
fpnext = fp->next;
+ delete_inferior (ptid_get_pid (fp->ptid));
free_fork (fp);
}
We need to delete that one from the fork_list, and switch
to the next available fork. */
delete_fork (inferior_ptid);
+ /* Delete process from GDB's inferior list. */
+ delete_inferior (ptid_get_pid (inferior_ptid));
/* There should still be a fork - if there's only one left,
delete_fork won't remove it, because we haven't updated
printf_filtered (_("Killed %s\n"), target_pid_to_str (ptid));
delete_fork (ptid);
+ /* Delete process from GDB's inferior list. */
+ delete_inferior (ptid_get_pid (ptid));
}
static void
printf_filtered (_("Detached %s\n"), target_pid_to_str (ptid));
delete_fork (ptid);
+ /* Delete process from GDB's process table. */
+ detach_inferior (ptid_get_pid (ptid));
}
/* Print information about currently known forks. */
else
{
struct fork_info *fp;
+
+ /* Add process to GDB's tables. */
+ add_inferior (child_pid);
+
/* Retain child fork in ptrace (stopped) state. */
fp = find_fork_pid (child_pid);
if (!fp)
safely resume it. */
if (has_vforked)
- linux_parent_pid = parent_pid;
+ {
+ linux_parent_pid = parent_pid;
+ detach_inferior (parent_pid);
+ }
else if (!detach_fork)
{
struct fork_info *fp;
target_detach (NULL, 0);
inferior_ptid = ptid_build (child_pid, child_pid, 0);
+ add_inferior (child_pid);
/* Reinstall ourselves, since we might have been removed in
target_detach (which does other necessary cleanup). */
/* Make run command think we are busy... */
inferior_ptid = monitor_ptid;
+ add_inferior_silent (ptid_get_pid (inferior_ptid));
add_thread_silent (inferior_ptid);
/* Give monitor_wait something to read */
monitor_desc = NULL;
delete_thread_silent (monitor_ptid);
+ delete_inferior_silent (ptid_get_pid (monitor_ptid));
}
/* Terminate the open connection to the remote debugger. Use this
gdb_flush (gdb_stdout);
}
inferior_ptid = do_attach (pid_to_ptid (pid));
- procfs_find_new_threads ();
+ add_inferior (pid);
+
push_target (&procfs_ops);
+
+ procfs_find_new_threads ();
}
static void
procfs_detach (char *args, int from_tty)
{
int siggnal = 0;
+ int pid;
if (from_tty)
{
close (ctl_fd);
ctl_fd = -1;
- init_thread_list ();
+
+ pid = ptid_get_pid (inferior_ptid);
inferior_ptid = null_ptid;
attach_flag = 0;
+ detach_inferior (pid);
+ init_thread_list ();
unpush_target (&procfs_ops); /* Pop out of handling an inferior. */
}
inferior_ptid = do_attach (pid_to_ptid (pid));
+ add_inferior (pid);
attach_flag = 0;
+
flags = _DEBUG_FLAG_KLC; /* Kill-on-Last-Close flag. */
errn = devctl (ctl_fd, DCMD_PROC_SET_FLAG, &flags, sizeof (flags), 0);
if (errn != EOK)
procfs_detach (char *args, int from_tty)
{
int sig = 0;
+ int pid = PIDGET (inferior_ptid);
if (args)
sig = atoi (args);
if (from_tty)
{
- int pid = PIDGET (inferior_ptid);
char *exec_file;
exec_file = get_exec_file (0);
do_detach (sig);
inferior_ptid = null_ptid;
+ detach_inferior (pid);
unpush_target (&procfs_ops);
}
if ((fail = procfs_debug_inferior (pi)) != 0)
dead_procinfo (pi, "do_attach: failed in procfs_debug_inferior", NOKILL);
+ add_inferior (pi->pid);
/* Let GDB know that the inferior was attached. */
attach_flag = 1;
sim_create_inferior (gdbsim_desc, exec_bfd, argv, env);
inferior_ptid = remote_sim_ptid;
+ add_inferior_silent (ptid_get_pid (inferior_ptid);
add_thread_silent (inferior_ptid);
target_mark_running (&gdbsim_ops);
end_callbacks ();
generic_mourn_inferior ();
delete_thread_silent (remote_sim_ptid);
+ delete_inferior_silent (ptid_get_pid (remote_sim_ptid));
}
/* Takes a program previously attached to and detaches it.
generic_mourn_inferior (void)
{
extern int show_breakpoint_hit_counts;
+ ptid_t ptid;
+ ptid = inferior_ptid;
inferior_ptid = null_ptid;
+
+ if (!ptid_equal (ptid, null_ptid))
+ {
+ int pid = ptid_get_pid (ptid);
+ delete_inferior (pid);
+ }
+
attach_flag = 0;
breakpoint_init_inferior (inf_exited);
registers_changed ();
clear_proceed_status ();
init_wait_for_inferior ();
+ add_inferior (pid);
+
terminal_init_inferior_with_pgrp (pid);
target_terminal_inferior ();
current_event.dwProcessId);
gdb_flush (gdb_stdout);
}
+
inferior_ptid = null_ptid;
+ detach_inferior (current_event.dwProcessId);
+
unpush_target (&win32_ops);
}
clear_proceed_status ();
init_wait_for_inferior ();
+ add_inferior (pid);
+
terminal_init_inferior_with_pgrp (pid);
target_terminal_inferior ();
current_event.dwProcessId);
gdb_flush (gdb_stdout);
}
+
inferior_ptid = null_ptid;
+ detach_inferior (current_event.dwProcessId);
+
unpush_target (&win32_ops);
}