new queue.h in common/.

Hi,
When writing the patches for 'general notification', I find queue is
used in many places, so I think we may need a general queue.  This
queue not only have typical operations enqueue and dequeue, but also
has some have some operations like remove and remove_all.

gdb/

2012-10-23  Yao Qi  <yao@codesourcery.com>
	    Doug Evans  <dje@google.com>

	* common/queue.h: New.
de-couple %Stop from notification: gdbserver

Hi,
I give some explanations/descriptions in the comment in
gdbserver/notif.c, so I don't write the same words down here.

gdb/gdbserver:

2012-10-23  Yao Qi  <yao@codesourcery.com>

	* Makefile.in (OBS): Add notif.o.
	(notif_h, queue_h): New.
	(notif.o): New rule.

	* linux-low.c: Include "notif.h".
	(linux_wait): Put notif_stop into queue.
	* notif.c, notif.h: New.
	* server.c: Include 'notif.h'.
	(struct vstop_notif): Move it to notif.h.
	(notif_reply_stop): New.
	(notif_stop): New variable.
	(push_event, notif_queue): Remove.
	(vstop_notif_match_pid, notif_queued_replies_discard): New.
	(notif_queued_replies_discard_all): New.
	(discard_queued_stop_replies, send_next_stop_reply): Remove.
	(handle_v_kill): Don't call discard_queued_stop_replies.  Call
	notif_queued_replies_discard_all instead.
	(handle_v_stopped): Remove.
	(handle_v_requests): Don't call handle_v_stopped.  Call
	handle_ack_notif instead.
	(queue_stop_reply_callback): Call notif_reply_enqueue instead
	of queue_stop_reply.
	(handle_status): Don't call discard_queued_stop_replies.  Call
	notif_queued_replies_discard instead.
	(kill_inferior_callback): Likewise.
	(detach_or_kill_inferior_callback): Likewise.
	(main): Call initialize_notif.
	(process_serial_event): Likewise.  Call
	notif_queued_replies_empty_p.
	(handle_target_event): Process queued replies.
	* server.h: Remove declaration of push_event.
de-couple %Stop from notification: gdb

This patch is to de-couple vStopped/%Stop from notification in gdb side.
I just put the necessary explanations into the comments in
remote-notif.c, so don't write down too much here.

gdb:

2012-10-23  Yao Qi  <yao@codesourcery.com>

	* Makefile.in (REMOTE_OBS): Add 'remote-notif.o'.
	(SFILES): Add 'remote-notif.c'.
	(HFILES_NO_SRCDIR): Add 'remote-notif.h' and 'common/queue.h'.
	* remote-notif.c: New.  Moved from remote.c.
	* remote-notif.h: New.
	* remote.c: Include 'remote-notif.h'.
	Remove declarations of stop_reply_xmalloc, stop_reply_xfree,
	do_stop_reply_xfree, remote_parse_stop_reply, push_stop_reply,
	remote_get_pending_stop_replies,
	remote_async_get_pending_events_handler, and
	discard_pending_stop_replies.
	Declare remote_parse_stop_reply and notif_queued_reply_push.
	Remove variable pending_stop_reply.
	(remote_async_inferior_event_token): Remove 'static'.
	(remote_async_get_pending_events_token): Move to
	remote-notif.c.

	(remote_close): Replace 'delete_async_event_handler' with
	remote_notif_unregister_async_event_handler.
	(remote_start_remote): Replace code with remote_notif_parse
	and remote_notif_pending_replies.
	(remote_open_1): Replace 'create_async_event_handler' with
	remote_notif_register_async_event_handler.
	(extended_remote_attach_1): Call remote_notif_parse and
	notif_reply_push.

	(struct stop_reply) <next>: Remove.
	<base>: New field.
	<ptid>: Move it to 'struct notif_reply'.
	Callers update.
	(stop_reply_queue): Remove.
	(stop_reply_xmalloc, stop_reply_xfree, do_stop_reply_xfree): Remove
	(remote_notif_ack_stop, stop_reply_dtr): New.
	(remote_notif_alloc_reply_stop): New.
	(notif_packet_stop): New variable.
	(stop_reply_match_ptid, stop_reply_match_ptid_and_ws: New.
	(queued_stop_reply, peek_stop_reply): Adjust.
	(push_stop_reply): Add one more parameter 'queue', and rename to
	notif_queued_reply_push.

	(remote_get_pending_stop_replies): Move to remote-notif.c.
	(handle_notification): Likewise.
	(remote_async_get_pending_events_handler): Likewise.
	(remote_wait_as): Adjust to call remote_notif_parse.
	(remote_wait): Call QUEUE_is_empty (notif_reply_p).
	* remote.h: Include "target.h" and "remote-notif.h".
	Declare remote_notif_pending_replies and
	remote_async_inferior_event_token
command 'set debug notification'.

This patch adds new commands 'set|show debug notification', and
documents this new command.

gdb:

2012-10-23  Yao Qi  <yao@codesourcery.com>

	* remote-notif.c (_initialize_notif): Add new commands
	'set debug notification' and 'show debug notification'.
	* NEWS: Mention these new commands.
gdb/doc:

2012-10-23 Yao Qi  <yao@codesourcery.com>

	* gdb.texinfo (Debugging Output): Document 'set debug
	notification' and 'show debug notification'.
Handle notification for all-stop.

Hi,
In all-stop mode, notification packet will be parsed/handled in
'remote_wait_as', so we define that all notifications have a
prefix 'N'.  We parse rsp packet, and enqueue notification if it
is found.  These queued notifications will be processed before
resuming inferior (in remote_resume).

gdb:

2012-10-23  Yao Qi  <yao@codesourcery.com>

	* remote.c (remote_wait_as): Call 'getpkt_or_notif_sane' instead
	of 'getpkt_sane'.
	Call 'handle_notification'.
Cleanup pending queues before resume in all-stop

In patch 3/N, we mark 'remote_async_get_pending_events_token'
only in non-stop mode, and function 'remote_notif_process' is
called in async event handler accordingly.  In all-stop mode,
we need to find a place to call 'remote_notif_process', I find
it is reasonable to process them before resume inferior.  So
this is what this patch does.

gdb:

2012-10-23  Yao Qi  <yao@codesourcery.com>

	* remote.c (remote_resume): Call 'remote_notif_process' in
	all-stop mode.
new notification "TEST".

This patch is only to present how do we add a new type of notifcation
in the future, and to test two types of notifications coexist together
for testing purpose.  In each time GDB fetches registers, a new event
is pushed, and GDBserver will send a notification %Test to GDB.

This patch is not for committing to CVS trunk.

gdb/gdbserver:

2012-10-23  Yao Qi  <yao@codesourcery.com>

   	* linux-low.c (linux_fetch_registers): Call circular_queue_enque
	and async_file_mark.
	* notif.c (notif_process_vtested): New.
	(notif_test): New variable.
	(notfi_packets): Add new element 'notif_test'.
	* notif.h (notif_type): New enum 'NOTIF_TEST'.
	* server.c (handle_target_event): Handle 'NOTIF_TEST'.

gdb:

2012-10-23  Yao Qi  <yao@codesourcery.com>

	* remote-notif.c (struct test_reply): New.
	(remote_notif_parse_test): New.
	(remote_notif_ack_test): New.
	(remote_notif_alloc_reply_test): New.
	(notif_packet_test): New variable.
	(notifs): New element 'notif_packet_test'.