Move pending_event to remote_notif_state.
authorYao Qi <yao@codesourcery.com>
Fri, 4 Oct 2013 07:42:06 +0000 (07:42 +0000)
committerYao Qi <yao@codesourcery.com>
Fri, 4 Oct 2013 07:42:06 +0000 (07:42 +0000)
commitf48ff2a7d3f69653dbf164e03d3397de8f6ba7c0
treec865c15272902c555bae310d136f73eee5db53c7
parent5965e02896b242f2ffe086def9c83a205eef31aa
Move pending_event to remote_notif_state.

This patch moves pending_event to remote_notif_state.  All pending
events are destroyed in remote_notif_state_xfree.  However,
discard_pending_stop_replies release pending event too, so the pending
event of stop notification is released twice, we need some refactor
here.  We add a new function discard_pending_stop_replies_in_queue
which only discard events in stop_reply_queue, and let
remote_notif_state_xfree release pending event for all notif_client.

After this change, discard_pending_stop_replies is only attached to
ifnerior_exit observer, so the INF can't be NULL any more.  The
NULL checking is removed too.

gdb:

2013-10-04  Yao Qi  <yao@codesourcery.com>

* remote-notif.h (REMOTE_NOTIF_ID): New enum.
(struct notif_client) <pending_event>: Moved
to struct remote_notif_state.
<id>: New field.
(struct remote_notif_state) <pending_event>: New field.
(notif_event_xfree): Declare.
* remote-notif.c (handle_notification): Adjust.
(notif_event_xfree): New function.
(do_notif_event_xfree): Call notif_event_xfree.
(remote_notif_state_xfree): Call notif_event_xfree to free
each element in field pending_event.
* remote.c (discard_pending_stop_replies): Remove declaration.
(discard_pending_stop_replies_in_queue): Declare.
(remote_close): Call discard_pending_stop_replies_in_queue
instead of discard_pending_stop_replies.
(remote_start_remote): Adjust.
(stop_reply_xfree): Call notif_event_xfree.
(notif_client_stop): Adjust initialization.
(remote_notif_remove_all): Rename it to ...
(remove_stop_reply_for_inferior): ... this.  Update comments.
Don't check INF is NULL.
(discard_pending_stop_replies): Return early if notif_state is
NULL.  Adjust.  Don't check INF is NULL.
(remote_notif_get_pending_events): Adjust.
  (discard_pending_stop_replies_in_queue): New function.
(remote_wait_ns): Likewise.
gdb/ChangeLog
gdb/remote-notif.c
gdb/remote-notif.h
gdb/remote.c