#include "gdbcmd.h"
#include "gdbthread.h"
#include "ui-out.h"
-#include "observer.h"
+#include "observable.h"
#include "gdbcore.h"
#include "symfile.h"
#include "environ.h"
struct inferior *inferior_list = NULL;
static int highest_inferior_num;
-/* Print notices on inferior events (attach, detach, etc.), set with
- `set print inferior-events'. */
-static int print_inferior_events = 0;
+/* See inferior.h. */
+int print_inferior_events = 1;
/* The Current Inferior. This is a strong reference. I.e., whenever
an inferior is the current inferior, its refcount is
last->next = inf;
}
- observer_notify_inferior_added (inf);
+ gdb::observers::inferior_added.notify (inf);
if (pid != 0)
inferior_appeared (inf, pid);
struct inferior *inf = add_inferior_silent (pid);
if (print_inferior_events)
- printf_unfiltered (_("[New inferior %d]\n"), pid);
+ printf_unfiltered (_("[New inferior %d (%s)]\n"),
+ inf->num,
+ target_pid_to_str (pid_to_ptid (pid)));
return inf;
}
else
inferior_list = inf->next;
- observer_notify_inferior_removed (inf);
+ gdb::observers::inferior_removed.notify (inf);
/* If this program space is rendered useless, remove it. */
if (program_space_empty_p (inf->pspace))
iterate_over_threads (delete_thread_of_inferior, &arg);
- observer_notify_inferior_exit (inf);
+ gdb::observers::inferior_exit.notify (inf);
inf->pid = 0;
inf->fake_pid_p = 0;
}
inf->pending_detach = 0;
+ /* Reset it. */
+ inf->control = {NO_STOP_QUIETLY};
}
void
struct inferior *inf = find_inferior_pid (pid);
exit_inferior_1 (inf, 0);
-
- if (print_inferior_events)
- printf_unfiltered (_("[Inferior %d exited]\n"), pid);
}
void
exit_inferior_1 (inf, 1);
}
+/* See inferior.h. */
+
void
-detach_inferior (int pid)
+detach_inferior (inferior *inf)
{
- struct inferior *inf = find_inferior_pid (pid);
+ /* Save the pid, since exit_inferior_1 will reset it. */
+ int pid = inf->pid;
exit_inferior_1 (inf, 0);
if (print_inferior_events)
- printf_unfiltered (_("[Inferior %d detached]\n"), pid);
+ printf_unfiltered (_("[Inferior %d (%s) detached]\n"),
+ inf->num,
+ target_pid_to_str (pid_to_ptid (pid)));
+}
+
+/* See inferior.h. */
+
+void
+detach_inferior (int pid)
+{
+ detach_inferior (find_inferior_pid (pid));
}
void
inf->has_exit_code = 0;
inf->exit_code = 0;
- observer_notify_inferior_appeared (inf);
+ gdb::observers::inferior_appeared.notify (inf);
}
void
switch_to_thread (tp->ptid);
}
- observer_notify_user_selected_context_changed
+ gdb::observers::user_selected_context_changed.notify
(USER_SELECTED_INFERIOR
| USER_SELECTED_THREAD
| USER_SELECTED_FRAME);
switch_to_thread (null_ptid);
set_current_program_space (inf->pspace);
- observer_notify_user_selected_context_changed (USER_SELECTED_INFERIOR);
+ gdb::observers::user_selected_context_changed.notify
+ (USER_SELECTED_INFERIOR);
}
}
doesn't really return a new address space; otherwise, it
really does. */
aspace = maybe_new_address_space ();
- pspace = add_program_space (aspace);
+ pspace = new program_space (aspace);
inf = add_inferior (0);
inf->pspace = pspace;
inf->aspace = pspace->aspace;
doesn't really return a new address space; otherwise, it
really does. */
aspace = maybe_new_address_space ();
- pspace = add_program_space (aspace);
+ pspace = new program_space (aspace);
inf = add_inferior (0);
inf->pspace = pspace;
inf->aspace = pspace->aspace;
can only allocate an inferior when all those modules have done
that. Do this after initialize_progspace, due to the
current_program_space reference. */
- current_inferior_ = add_inferior (0);
+ current_inferior_ = add_inferior_silent (0);
current_inferior_->incref ();
current_inferior_->pspace = current_program_space;
current_inferior_->aspace = current_program_space->aspace;