/* Interface GDB to the GNU Hurd.
- Copyright (C) 1992-2020 Free Software Foundation, Inc.
+ Copyright (C) 1992-2021 Free Software Foundation, Inc.
This file is part of GDB.
#include <mach/message.h>
#include <mach/notify.h>
#include <mach/vm_attributes.h>
+#include <mach/vm_param.h>
#include <hurd.h>
#include <hurd/interrupt.h>
if (set)
{
/* XXX We don't get the exception unless the thread has its own
- exception port???? */
+ exception port???? */
if (proc->exc_port == MACH_PORT_NULL)
proc_steal_exc_port (proc, proc->inf->event_port);
THREAD_STATE_SET_TRACED (state);
proc_steal_exc_port (proc, inf->event_port);
else
/* Just clear thread exception ports -- they default to the
- task one. */
+ task one. */
proc_steal_exc_port (proc, MACH_PORT_NULL);
}
if (inf->task->cur_sc < pi->taskinfo.suspend_count && suspend_count == -1)
{
/* The proc server might have suspended the task while stopping
- it. This happens when the task is handling a traced signal.
- Refetch the suspend count. The proc server should be
- finished stopping the task by now. */
+ it. This happens when the task is handling a traced signal.
+ Refetch the suspend count. The proc server should be
+ finished stopping the task by now. */
suspend_count = pi->taskinfo.suspend_count;
goto retry;
}
inf->running = thread_running && task_running;
/* Once any thread has executed some code, we can't depend on the
- threads list any more. */
+ threads list any more. */
if (inf->running)
inf->threads_up_to_date = 0;
ptid_t
gnu_nat_target::wait (ptid_t ptid, struct target_waitstatus *status,
- int options)
+ target_wait_flags options)
{
struct msg
{
int from_tty)
{
struct inf *inf = cur_inf ();
+ inferior *inferior = current_inferior ();
int pid;
inf_debug (inf, "creating inferior");
- if (!target_is_pushed (this))
- push_target (this);
+ if (!inf->target_is_pushed (this))
+ inf->push_target (this);
pid = fork_inferior (exec_file, allargs, env, gnu_ptrace_me,
- NULL, NULL, NULL, NULL);
+ NULL, NULL, NULL, NULL);
/* We have something that executes now. We'll be running through
the shell at this point (if startup-with-shell is true), but the
pid shouldn't change. */
- add_thread_silent (this, ptid_t (pid));
+ thread_info *thr = add_thread_silent (this, ptid_t (pid));
+ switch_to_thread (thr);
/* Attach to the now stopped child, which is actually a shell... */
inf_debug (inf, "attaching to child: %d", pid);
inf_attach (inf, pid);
- push_target (this);
-
inferior = current_inferior ();
+ inferior->push_target (this);
+
inferior_appeared (inferior, pid);
inferior->attach_flag = 1;
inf_update_procs (inf);
- inferior_ptid = ptid_t (pid, inf_pick_first_thread (), 0);
+ thread_info *thr
+ = find_thread_ptid (this, ptid_t (pid, inf_pick_first_thread ()));
+ switch_to_thread (thr);
/* We have to initialize the terminal settings now, since the code
below might try to restore them. */
void
gnu_nat_target::detach (inferior *inf, int from_tty)
{
- int pid;
-
if (from_tty)
{
const char *exec_file = get_exec_file (0);
printf_unfiltered ("Detaching from pid %d\n", gnu_current_inf->pid);
}
- pid = gnu_current_inf->pid;
-
inf_detach (gnu_current_inf);
- inferior_ptid = null_ptid;
- detach_inferior (find_inferior_pid (this, pid));
+ switch_to_no_thread ();
+ detach_inferior (inf);
maybe_unpush_target ();
}
_("Show the default detach-suspend-count value for new threads."),
&show_thread_default_cmd_list);
- add_cmd ("signals", class_run, set_signals_cmd, _("\
+ cmd_list_element *set_signals_cmd
+ = add_cmd ("signals", class_run, set_signals_cmd, _("\
Set whether the inferior process's signals will be intercepted.\n\
Mach exceptions (such as breakpoint traps) are not affected."),
- &setlist);
- add_alias_cmd ("sigs", "signals", class_run, 1, &setlist);
- add_cmd ("signals", no_class, show_signals_cmd, _("\
+ &setlist);
+ add_alias_cmd ("sigs", set_signals_cmd, class_run, 1, &setlist);
+
+ cmd_list_element *show_signals_cmd
+ = add_cmd ("signals", no_class, show_signals_cmd, _("\
Show whether the inferior process's signals will be intercepted."),
- &showlist);
- add_alias_cmd ("sigs", "signals", no_class, 1, &showlist);
+ &showlist);
+ add_alias_cmd ("sigs", show_signals_cmd, no_class, 1, &showlist);
- add_cmd ("signal-thread", class_run, set_sig_thread_cmd, _("\
+ cmd_list_element *set_signal_thread_cmd
+ = add_cmd ("signal-thread", class_run, set_sig_thread_cmd, _("\
Set the thread that gdb thinks is the libc signal thread.\n\
This thread is run when delivering a signal to a non-stopped process."),
- &setlist);
- add_alias_cmd ("sigthread", "signal-thread", class_run, 1, &setlist);
- add_cmd ("signal-thread", no_class, show_sig_thread_cmd, _("\
+ &setlist);
+ add_alias_cmd ("sigthread", set_signal_thread_cmd, class_run, 1, &setlist);
+
+ cmd_list_element *show_signal_thread_cmd
+ = add_cmd ("signal-thread", no_class, show_sig_thread_cmd, _("\
Set the thread that gdb thinks is the libc signal thread."),
- &showlist);
- add_alias_cmd ("sigthread", "signal-thread", no_class, 1, &showlist);
+ &showlist);
+ add_alias_cmd ("sigthread", show_signal_thread_cmd, no_class, 1, &showlist);
add_cmd ("stopped", class_run, set_stopped_cmd, _("\
Set whether gdb thinks the inferior process is stopped as with SIGSTOP.\n\
Show whether gdb thinks the inferior process is stopped as with SIGSTOP."),
&showlist);
- add_cmd ("exceptions", class_run, set_exceptions_cmd, _("\
+ cmd_list_element *set_exceptions_cmd
+ = add_cmd ("exceptions", class_run, set_exceptions_cmd, _("\
Set whether exceptions in the inferior process will be trapped.\n\
When exceptions are turned off, neither breakpoints nor single-stepping\n\
-will work."),
- &setlist);
+will work."), &setlist);
/* Allow `set exc' despite conflict with `set exception-port'. */
- add_alias_cmd ("exc", "exceptions", class_run, 1, &setlist);
+ add_alias_cmd ("exc", set_exceptions_cmd, class_run, 1, &setlist);
+
add_cmd ("exceptions", no_class, show_exceptions_cmd, _("\
Show whether exceptions in the inferior process will be trapped."),
&showlist);
add_prefix_cmd ("task", no_class, set_task_cmd,
_("Command prefix for setting task attributes."),
- &set_task_cmd_list, "set task ", 0, &setlist);
+ &set_task_cmd_list, 0, &setlist);
add_prefix_cmd ("task", no_class, show_task_cmd,
_("Command prefix for showing task attributes."),
- &show_task_cmd_list, "show task ", 0, &showlist);
+ &show_task_cmd_list, 0, &showlist);
add_cmd ("pause", class_run, set_task_pause_cmd, _("\
Set whether the task is suspended while gdb has control.\n\
"on the thread when detaching."),
&show_task_cmd_list);
- add_cmd ("exception-port", no_class, set_task_exc_port_cmd, _("\
+ cmd_list_element *set_task_exception_port_cmd
+ = add_cmd ("exception-port", no_class, set_task_exc_port_cmd, _("\
Set the task exception port to which we forward exceptions.\n\
The argument should be the value of the send right in the task."),
- &set_task_cmd_list);
- add_alias_cmd ("excp", "exception-port", no_class, 1, &set_task_cmd_list);
- add_alias_cmd ("exc-port", "exception-port", no_class, 1,
+ &set_task_cmd_list);
+ add_alias_cmd ("excp", set_task_exception_port_cmd, no_class, 1,
+ &set_task_cmd_list);
+ add_alias_cmd ("exc-port", set_task_exception_port_cmd, no_class, 1,
&set_task_cmd_list);
/* A convenient way of turning on all options require to noninvasively
{
add_prefix_cmd ("thread", no_class, set_thread_cmd,
_("Command prefix for setting thread properties."),
- &set_thread_cmd_list, "set thread ", 0, &setlist);
+ &set_thread_cmd_list, 0, &setlist);
add_prefix_cmd ("default", no_class, show_thread_cmd,
_("Command prefix for setting default thread properties."),
- &set_thread_default_cmd_list, "set thread default ", 0,
+ &set_thread_default_cmd_list, 0,
&set_thread_cmd_list);
add_prefix_cmd ("thread", no_class, set_thread_default_cmd,
_("Command prefix for showing thread properties."),
- &show_thread_cmd_list, "show thread ", 0, &showlist);
+ &show_thread_cmd_list, 0, &showlist);
add_prefix_cmd ("default", no_class, show_thread_default_cmd,
_("Command prefix for showing default thread properties."),
- &show_thread_default_cmd_list, "show thread default ", 0,
+ &show_thread_default_cmd_list, 0,
&show_thread_cmd_list);
add_cmd ("pause", class_run, set_thread_pause_cmd, _("\
This overrides the task exception port.\n\
The argument should be the value of the send right in the task."),
&set_thread_cmd_list);
- add_alias_cmd ("excp", "exception-port", no_class, 1, &set_thread_cmd_list);
- add_alias_cmd ("exc-port", "exception-port", no_class, 1,
+ add_alias_cmd ("excp", set_thread_exception_port_cmd, no_class, 1,
+ &set_thread_cmd_list);
+ add_alias_cmd ("exc-port", set_thread_exception_port_cmd, no_class, 1,
&set_thread_cmd_list);
add_cmd ("takeover-suspend-count", no_class, thread_takeover_sc_cmd, _("\