#include <unordered_map>
#include "target-connection.h"
#include "valprint.h"
+#include "cli/cli-decode.h"
static void generic_tls_error (void) ATTRIBUTE_NORETURN;
static void
open_target (const char *args, int from_tty, struct cmd_list_element *command)
{
- auto *ti = static_cast<target_info *> (get_cmd_context (command));
+ auto *ti = static_cast<target_info *> (command->context ());
target_open_ftype *func = target_factories[ti];
if (targetdebug)
Remaining arguments are interpreted by the target protocol. For more\n\
information on the arguments for a particular protocol, type\n\
`help target ' followed by the protocol name."),
- &targetlist, "target ", 0, &cmdlist);
+ &targetlist, 0, &cmdlist);
c = add_cmd (t.shortname, no_class, t.doc, &targetlist);
- set_cmd_context (c, (void *) &t);
+ c->set_context ((void *) &t);
set_cmd_sfunc (c, open_target);
if (completer != NULL)
set_cmd_completer (c, completer);
see PR cli/15104. */
c = add_cmd (alias, no_class, tinfo.doc, &targetlist);
set_cmd_sfunc (c, open_target);
- set_cmd_context (c, (void *) &tinfo);
+ c->set_context ((void *) &tinfo);
alt = xstrprintf ("target %s", tinfo.shortname);
deprecate_cmd (c, alt);
}
m_stack[stratum] = NULL;
if (m_top == stratum)
- m_top = t->beneath ()->stratum ();
+ m_top = this->find_beneath (t)->stratum ();
/* Finally close the target, if there are no inferiors
referencing this target still. Note we do this after unchaining,
target_wait_flags options)
{
target_ops *target = current_inferior ()->top_target ();
+ process_stratum_target *proc_target = current_inferior ()->process_target ();
+
+ gdb_assert (!proc_target->commit_resumed_state);
if (!target->can_async_p ())
gdb_assert ((options & TARGET_WNOHANG) == 0);
target_resume (ptid_t ptid, int step, enum gdb_signal signal)
{
process_stratum_target *curr_target = current_inferior ()->process_target ();
+ gdb_assert (!curr_target->commit_resumed_state);
target_dcache_invalidate ();
clear_inline_frame_state (curr_target, ptid);
}
-/* If true, target_commit_resume is a nop. */
-static int defer_target_commit_resume;
-
/* See target.h. */
void
-target_commit_resume (void)
+target_commit_resumed ()
{
- if (defer_target_commit_resume)
- return;
-
- current_inferior ()->top_target ()->commit_resume ();
+ gdb_assert (current_inferior ()->process_target ()->commit_resumed_state);
+ current_inferior ()->top_target ()->commit_resumed ();
}
/* See target.h. */
-scoped_restore_tmpl<int>
-make_scoped_defer_target_commit_resume ()
+bool
+target_has_pending_events ()
{
- return make_scoped_restore (&defer_target_commit_resume, 1);
+ return current_inferior ()->top_target ()->has_pending_events ();
}
void
current_inferior ()->top_target ()->program_signals (program_signals);
}
-static bool
+static void
default_follow_fork (struct target_ops *self, bool follow_child,
bool detach_fork)
{
_("could not find a target to follow fork"));
}
-/* Look through the list of possible targets for a target that can
- follow forks. */
+/* See target.h. */
-bool
+void
target_follow_fork (bool follow_child, bool detach_fork)
{
target_ops *target = current_inferior ()->top_target ();
return target->follow_fork (follow_child, detach_fork);
}
-/* Target wrapper for follow exec hook. */
+/* See target.h. */
void
-target_follow_exec (struct inferior *inf, const char *execd_pathname)
+target_follow_exec (inferior *follow_inf, ptid_t ptid,
+ const char *execd_pathname)
{
- current_inferior ()->top_target ()->follow_exec (inf, execd_pathname);
+ current_inferior ()->top_target ()->follow_exec (follow_inf, ptid,
+ execd_pathname);
}
static void
void
target_close (struct target_ops *targ)
{
- gdb_assert (!current_inferior ()->target_is_pushed (targ));
+ for (inferior *inf : all_inferiors ())
+ gdb_assert (!inf->target_is_pushed (targ));
fileio_handles_invalidate_target (targ);
void
target_stop (ptid_t ptid)
{
+ process_stratum_target *proc_target = current_inferior ()->process_target ();
+
+ gdb_assert (!proc_target->commit_resumed_state);
+
if (!may_stop)
{
warning (_("May not interrupt or stop the target, ignoring attempt"));
bool
target_is_non_stop_p ()
{
- return (non_stop
- || target_non_stop_enabled == AUTO_BOOLEAN_TRUE
- || (target_non_stop_enabled == AUTO_BOOLEAN_AUTO
- && target_always_non_stop_p ()));
+ return ((non_stop
+ || target_non_stop_enabled == AUTO_BOOLEAN_TRUE
+ || (target_non_stop_enabled == AUTO_BOOLEAN_AUTO
+ && target_always_non_stop_p ()))
+ && target_can_async_p ());
}
/* See target.h. */