nc->ack_command);
nc->parse (remote, nc, buf, event.get ());
- nc->ack (remote, nc, buf, event.release ());
+ nc->ack (remote, nc, buf, std::move (event));
}
/* Parse the BUF for the expected notification NC. */
-struct notif_event *
+notif_event_up
remote_notif_parse (remote_target *remote,
const notif_client *nc, const char *buf)
{
nc->parse (remote, nc, buf, event.get ());
- return event.release ();
+ return event;
}
/* Process notifications in STATE's notification queue one by one.
}
else
{
- struct notif_event *event
+ notif_event_up event
= remote_notif_parse (state->remote, nc, buf + strlen (nc->name) + 1);
/* Be careful to only set it after parsing, since an error
may be thrown then. */
- state->pending_event[nc->id] = event;
+ state->pending_event[nc->id] = std::move (event);
/* Notify the event loop there's a stop reply to acknowledge
and that there may be more events to fetch. */
remote_notif_state::~remote_notif_state ()
{
- int i;
-
/* Unregister async_event_handler for notification. */
if (get_pending_events_token != NULL)
delete_async_event_handler (&get_pending_events_token);
-
- for (i = 0; i < REMOTE_NOTIF_LAST; i++)
- delete pending_event[i];
}
void _initialize_notif ();
ptid_t wait_as (ptid_t ptid, target_waitstatus *status,
target_wait_flags options);
- ptid_t process_stop_reply (struct stop_reply *stop_reply,
+ ptid_t process_stop_reply (stop_reply_up stop_reply,
target_waitstatus *status);
ptid_t select_thread_for_ambiguous_stop_reply
(bool *may_global_wildcard_vcont);
void discard_pending_stop_replies_in_queue ();
- struct stop_reply *remote_notif_remove_queued_reply (ptid_t ptid);
- struct stop_reply *queued_stop_reply (ptid_t ptid);
+ stop_reply_up remote_notif_remove_queued_reply (ptid_t ptid);
+ stop_reply_up queued_stop_reply (ptid_t ptid);
int peek_stop_reply (ptid_t ptid);
void remote_parse_stop_reply (const char *buf, stop_reply *event);
ULONGEST *xfered_len,
const unsigned int which_packet);
- void push_stop_reply (struct stop_reply *new_event);
+ void push_stop_reply (stop_reply_up new_event);
bool vcont_r_supported ();
scoped_restore_tmpl<bool> m_restore_starting_up;
};
+/* Transfer ownership of the stop_reply owned by EVENT to a
+ stop_reply_up object. */
+
+static stop_reply_up
+as_stop_reply_up (notif_event_up event)
+{
+ auto *stop_reply = static_cast<struct stop_reply *> (event.release ());
+ return stop_reply_up (stop_reply);
+}
+
/* Helper for remote_target::start_remote, start the remote connection and
sync state. Return true if everything goes OK, otherwise, return false.
This function exists so that the scoped_restore created within it will
/* Use the previously fetched status. */
gdb_assert (wait_status != NULL);
- struct notif_event *reply
+ notif_event_up reply
= remote_notif_parse (this, ¬if_client_stop, wait_status);
- push_stop_reply ((struct stop_reply *) reply);
+ push_stop_reply (as_stop_reply_up (std::move (reply)));
::start_remote (from_tty); /* Initialize gdb process mechanisms. */
}
/* Use the previously fetched status. */
gdb_assert (wait_status != NULL);
- struct notif_event *reply
- = remote_notif_parse (this, ¬if_client_stop, wait_status);
-
- push_stop_reply ((struct stop_reply *) reply);
+ notif_event_up reply
+ = remote_notif_parse (this, ¬if_client_stop, wait_status);
+ push_stop_reply (as_stop_reply_up (std::move (reply)));
}
else
{
= remote_thr->resumed_pending_vcont_info ();
gdb_assert (info.sig == GDB_SIGNAL_0);
- stop_reply *sr = new stop_reply ();
+ stop_reply_up sr = std::make_unique<stop_reply> ();
sr->ptid = tp->ptid;
sr->rs = rs;
sr->ws.set_stopped (GDB_SIGNAL_0);
sr->stop_reason = TARGET_STOPPED_BY_NO_REASON;
sr->watch_data_address = 0;
sr->core = 0;
- this->push_stop_reply (sr);
+ this->push_stop_reply (std::move (sr));
/* Pretend that this thread was actually resumed on the
remote target, then stopped. If we leave it in the
static void
remote_notif_stop_ack (remote_target *remote,
const notif_client *self, const char *buf,
- struct notif_event *event)
+ notif_event_up event)
{
- struct stop_reply *stop_reply = (struct stop_reply *) event;
+ stop_reply_up stop_reply = as_stop_reply_up (std::move (event));
/* acknowledge */
putpkt (remote, self->ack_command);
the notification. It was left in the queue because we need to
acknowledge it and pull the rest of the notifications out. */
if (stop_reply->ws.kind () != TARGET_WAITKIND_IGNORE)
- remote->push_stop_reply (stop_reply);
+ remote->push_stop_reply (std::move (stop_reply));
}
static int
void
remote_target::discard_pending_stop_replies (struct inferior *inf)
{
- struct stop_reply *reply;
struct remote_state *rs = get_remote_state ();
struct remote_notif_state *rns = rs->notif_state;
if (rs->remote_desc == NULL)
return;
- reply = (struct stop_reply *) rns->pending_event[notif_client_stop.id];
+ stop_reply_up reply
+ = as_stop_reply_up (std::move (rns->pending_event[notif_client_stop.id]));
/* Discard the in-flight notification. */
if (reply != NULL && reply->ptid.pid () == inf->pid)
/* Remove the first reply in 'stop_reply_queue' which matches
PTID. */
-struct stop_reply *
+stop_reply_up
remote_target::remote_notif_remove_queued_reply (ptid_t ptid)
{
remote_state *rs = get_remote_state ();
{
return event->ptid.matches (ptid);
});
- struct stop_reply *result;
- if (iter == rs->stop_reply_queue.end ())
- result = nullptr;
- else
+ stop_reply_up result;
+ if (iter != rs->stop_reply_queue.end ())
{
- result = iter->release ();
+ result = std::move (*iter);
rs->stop_reply_queue.erase (iter);
}
found. If there are still queued events left to process, tell the
event loop to get back to target_wait soon. */
-struct stop_reply *
+stop_reply_up
remote_target::queued_stop_reply (ptid_t ptid)
{
remote_state *rs = get_remote_state ();
- struct stop_reply *r = remote_notif_remove_queued_reply (ptid);
+ stop_reply_up r = remote_notif_remove_queued_reply (ptid);
if (!rs->stop_reply_queue.empty () && target_can_async_p ())
{
core side, tell the event loop to get back to target_wait soon. */
void
-remote_target::push_stop_reply (struct stop_reply *new_event)
+remote_target::push_stop_reply (stop_reply_up new_event)
{
remote_state *rs = get_remote_state ();
- rs->stop_reply_queue.push_back (stop_reply_up (new_event));
+ rs->stop_reply_queue.push_back (std::move (new_event));
if (notif_debug)
gdb_printf (gdb_stdlog,
/* acknowledge */
nc->ack (this, nc, rs->buf.data (),
- rs->notif_state->pending_event[nc->id]);
- rs->notif_state->pending_event[nc->id] = NULL;
+ std::move (rs->notif_state->pending_event[nc->id]));
while (1)
{
destroys STOP_REPLY. */
ptid_t
-remote_target::process_stop_reply (struct stop_reply *stop_reply,
+remote_target::process_stop_reply (stop_reply_up stop_reply,
struct target_waitstatus *status)
{
*status = stop_reply->ws;
}
}
- delete stop_reply;
return ptid;
}
target_wait_flags options)
{
struct remote_state *rs = get_remote_state ();
- struct stop_reply *stop_reply;
int ret;
bool is_notif = false;
remote_notif_get_pending_events (¬if_client_stop);
/* If indeed we noticed a stop reply, we're done. */
- stop_reply = queued_stop_reply (ptid);
+ stop_reply_up stop_reply = queued_stop_reply (ptid);
if (stop_reply != NULL)
- return process_stop_reply (stop_reply, status);
+ return process_stop_reply (std::move (stop_reply), status);
/* Still no event. If we're just polling for an event, then
return to the event loop. */
struct remote_state *rs = get_remote_state ();
ptid_t event_ptid = null_ptid;
char *buf;
- struct stop_reply *stop_reply;
+ stop_reply_up stop_reply;
again:
/* None of the paths that push a stop reply onto the queue should
have set the waiting_for_stop_reply flag. */
gdb_assert (!rs->waiting_for_stop_reply);
- event_ptid = process_stop_reply (stop_reply, status);
+ event_ptid = process_stop_reply (std::move (stop_reply), status);
}
else
{
rs->waiting_for_stop_reply = 0;
stop_reply
- = (struct stop_reply *) remote_notif_parse (this,
- ¬if_client_stop,
- rs->buf.data ());
+ = as_stop_reply_up (remote_notif_parse (this,
+ ¬if_client_stop,
+ rs->buf.data ()));
- event_ptid = process_stop_reply (stop_reply, status);
+ event_ptid = process_stop_reply (std::move (stop_reply), status);
break;
}
case 'O': /* Console output. */