summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gdb/ChangeLog14
-rw-r--r--gdb/event-loop.c8
-rw-r--r--gdb/event-loop.h4
-rw-r--r--gdb/record-btrace.c17
-rw-r--r--gdb/record-full.c32
-rw-r--r--gdb/remote.c10
6 files changed, 72 insertions, 13 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index e7e60bb787d..9a36dc8276b 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,19 @@
2015-02-03 Pedro Alves <palves@redhat.com>
+ * event-loop.c (clear_async_event_handler): New function.
+ * event-loop.h (clear_async_event_handler): New declaration.
+ * record-btrace.c (record_btrace_async): New function.
+ (init_record_btrace_ops): Install record_btrace_async.
+ * record-full.c (record_full_async): New function.
+ (record_full_resume): Don't mark the async event source here.
+ (init_record_full_ops): Install record_full_async.
+ (record_full_core_resume): Don't mark the async event source here.
+ (init_record_full_core_ops): Install record_full_async.
+ * remote.c (remote_async): Mark and clear the async stop reply
+ queue event-loop token as appropriate.
+
+2015-02-03 Pedro Alves <palves@redhat.com>
+
* linux-nat.c (linux_child_follow_fork, linux_nat_wait_1): Use
target_is_async_p instead of target_can_async.
(linux_nat_wait): Use target_is_async_p instead of
diff --git a/gdb/event-loop.c b/gdb/event-loop.c
index cfdd9a67162..e4de57265df 100644
--- a/gdb/event-loop.c
+++ b/gdb/event-loop.c
@@ -1050,6 +1050,14 @@ mark_async_event_handler (async_event_handler *async_handler_ptr)
async_handler_ptr->ready = 1;
}
+/* See event-loop.h. */
+
+void
+clear_async_event_handler (async_event_handler *async_handler_ptr)
+{
+ async_handler_ptr->ready = 0;
+}
+
struct async_event_handler_data
{
async_event_handler_func* proc;
diff --git a/gdb/event-loop.h b/gdb/event-loop.h
index feb5ea06961..b9338a2a47e 100644
--- a/gdb/event-loop.h
+++ b/gdb/event-loop.h
@@ -131,3 +131,7 @@ extern void
/* Call the handler from HANDLER the next time through the event
loop. */
extern void mark_async_event_handler (struct async_event_handler *handler);
+
+/* Mark the handler (ASYNC_HANDLER_PTR) as NOT ready. */
+
+extern void clear_async_event_handler (struct async_event_handler *handler);
diff --git a/gdb/record-btrace.c b/gdb/record-btrace.c
index 3b7ef5ca5d0..7af549f33cd 100644
--- a/gdb/record-btrace.c
+++ b/gdb/record-btrace.c
@@ -266,6 +266,22 @@ record_btrace_close (struct target_ops *self)
btrace_teardown (tp);
}
+/* The to_async method of target record-btrace. */
+
+static void
+record_btrace_async (struct target_ops *ops,
+ void (*callback) (enum inferior_event_type event_type,
+ void *context),
+ void *context)
+{
+ if (callback != NULL)
+ mark_async_event_handler (record_btrace_async_inferior_event_handler);
+ else
+ clear_async_event_handler (record_btrace_async_inferior_event_handler);
+
+ ops->beneath->to_async (ops->beneath, callback, context);
+}
+
/* The to_info_record method of target record-btrace. */
static void
@@ -1940,6 +1956,7 @@ init_record_btrace_ops (void)
ops->to_doc = "Collect control-flow trace and provide the execution history.";
ops->to_open = record_btrace_open;
ops->to_close = record_btrace_close;
+ ops->to_async = record_btrace_async;
ops->to_detach = record_detach;
ops->to_disconnect = record_disconnect;
ops->to_mourn_inferior = record_mourn_inferior;
diff --git a/gdb/record-full.c b/gdb/record-full.c
index 6db16d6447b..c660743a407 100644
--- a/gdb/record-full.c
+++ b/gdb/record-full.c
@@ -910,6 +910,22 @@ record_full_close (struct target_ops *self)
delete_async_event_handler (&record_full_async_inferior_event_token);
}
+/* "to_async" target method. */
+
+static void
+record_full_async (struct target_ops *ops,
+ void (*callback) (enum inferior_event_type event_type,
+ void *context),
+ void *context)
+{
+ if (callback != NULL)
+ mark_async_event_handler (record_full_async_inferior_event_token);
+ else
+ clear_async_event_handler (record_full_async_inferior_event_token);
+
+ ops->beneath->to_async (ops->beneath, callback, context);
+}
+
static int record_full_resume_step = 0;
/* True if we've been resumed, and so each record_full_wait call should
@@ -989,12 +1005,7 @@ record_full_resume (struct target_ops *ops, ptid_t ptid, int step,
/* We are about to start executing the inferior (or simulate it),
let's register it with the event loop. */
if (target_can_async_p ())
- {
- target_async (inferior_event_handler, 0);
- /* Notify the event loop there's an event to wait for. We do
- most of the work in record_full_wait. */
- mark_async_event_handler (record_full_async_inferior_event_token);
- }
+ target_async (inferior_event_handler, 0);
}
static int record_full_get_sig = 0;
@@ -1902,6 +1913,7 @@ init_record_full_ops (void)
"Log program while executing and replay execution from log.";
record_full_ops.to_open = record_full_open;
record_full_ops.to_close = record_full_close;
+ record_full_ops.to_async = record_full_async;
record_full_ops.to_resume = record_full_resume;
record_full_ops.to_wait = record_full_wait;
record_full_ops.to_disconnect = record_disconnect;
@@ -1943,12 +1955,7 @@ record_full_core_resume (struct target_ops *ops, ptid_t ptid, int step,
/* We are about to start executing the inferior (or simulate it),
let's register it with the event loop. */
if (target_can_async_p ())
- {
- target_async (inferior_event_handler, 0);
-
- /* Notify the event loop there's an event to wait for. */
- mark_async_event_handler (record_full_async_inferior_event_token);
- }
+ target_async (inferior_event_handler, 0);
}
/* "to_kill" method for prec over corefile. */
@@ -2141,6 +2148,7 @@ init_record_full_core_ops (void)
"Log program while executing and replay execution from log.";
record_full_core_ops.to_open = record_full_open;
record_full_core_ops.to_close = record_full_close;
+ record_full_core_ops.to_async = record_full_async;
record_full_core_ops.to_resume = record_full_core_resume;
record_full_core_ops.to_wait = record_full_wait;
record_full_core_ops.to_kill = record_full_core_kill;
diff --git a/gdb/remote.c b/gdb/remote.c
index 9be15cb3073..e971a29d51a 100644
--- a/gdb/remote.c
+++ b/gdb/remote.c
@@ -11691,9 +11691,17 @@ remote_async (struct target_ops *ops,
serial_async (rs->remote_desc, remote_async_serial_handler, rs);
rs->async_client_callback = callback;
rs->async_client_context = context;
+
+ /* If there are pending events in the stop reply queue tell the
+ event loop to process them. */
+ if (!QUEUE_is_empty (stop_reply_p, stop_reply_queue))
+ mark_async_event_handler (remote_async_inferior_event_token);
}
else
- serial_async (rs->remote_desc, NULL, NULL);
+ {
+ serial_async (rs->remote_desc, NULL, NULL);
+ clear_async_event_handler (remote_async_inferior_event_token);
+ }
}
static void