]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
(inf_ptrace_target): Move async_terminal target methods here from
authorNick Roberts <nickrob@snap.net.nz>
Mon, 4 Sep 2006 10:12:06 +0000 (10:12 +0000)
committerNick Roberts <nickrob@snap.net.nz>
Mon, 4 Sep 2006 10:12:06 +0000 (10:12 +0000)
init_exec_ops.  Add async methods.
(inf_ptrace_async): New function (was old standard_async).

gdb/inf-ptrace.c

index b3ece3aa22c2c9fb365922c58151f6411fc3ba28..cbee144cc77537dc1eb2a5919c8e723f7e6b94c1 100644 (file)
 #include <signal.h>
 
 #include "inf-child.h"
+#include "event-loop.h"
+
+extern int standard_is_async_p (void);
+extern int standard_can_async_p (void);
 
 /* HACK: Save the ptrace ops returned by inf_ptrace_target.  */
 static struct target_ops *ptrace_ops_hack;
 \f
 
+static void
+async_file_handler (int error, gdb_client_data client_data)
+{
+  async_client_callback (INF_REG_EVENT, async_client_context);
+}
+
+static void
+inf_ptrace_async (void (*callback) (enum inferior_event_type event_type, 
+                                 void *context), void *context)
+{
+  if (current_target.to_async_mask_value == 0)
+    internal_error (__FILE__, __LINE__,
+                    "Calling remote_async when async is masked");
+
+  if (callback != NULL)
+    {
+      async_client_callback = callback;
+      async_client_context = context;
+      if (gdb_status->signal_status.receive_fd > 0)
+        add_file_handler (gdb_status->signal_status.receive_fd,
+                          async_file_handler, NULL);
+    }
+  else
+    {
+      if (gdb_status->signal_status.receive_fd > 0)
+        delete_file_handler (gdb_status->signal_status.receive_fd);
+    }
+  return;
+}
+
 #ifdef PT_GET_PROCESS_STATE
 
 static int
@@ -640,6 +674,16 @@ inf_ptrace_target (void)
   t->to_stop = inf_ptrace_stop;
   t->to_xfer_partial = inf_ptrace_xfer_partial;
 
+  if (event_loop_p)
+    {
+      t->to_can_async_p = standard_can_async_p;
+      t->to_is_async_p = standard_is_async_p;
+      t->to_async = inf_ptrace_async;
+      t->to_async_mask_value = 1;
+      t->to_terminal_inferior = async_terminal_inferior;
+      t->to_terminal_ours = async_terminal_ours;
+    }
+
   ptrace_ops_hack = t;
   return t;
 }