From: Nick Roberts Date: Mon, 4 Sep 2006 10:12:06 +0000 (+0000) Subject: (inf_ptrace_target): Move async_terminal target methods here from X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=39882e987ed506db43704119136e8065d8640b05;p=thirdparty%2Fbinutils-gdb.git (inf_ptrace_target): Move async_terminal target methods here from init_exec_ops. Add async methods. (inf_ptrace_async): New function (was old standard_async). --- diff --git a/gdb/inf-ptrace.c b/gdb/inf-ptrace.c index b3ece3aa22c..cbee144cc77 100644 --- a/gdb/inf-ptrace.c +++ b/gdb/inf-ptrace.c @@ -37,11 +37,45 @@ #include #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; +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; }