From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 3461 invoked by alias); 14 Mar 2008 08:05:51 -0000 Received: (qmail 3446 invoked by uid 22791); 14 Mar 2008 08:05:50 -0000 X-Spam-Check-By: sourceware.org Received: from mail.codesourcery.com (HELO mail.codesourcery.com) (65.74.133.4) by sourceware.org (qpsmtpd/0.31) with ESMTP; Fri, 14 Mar 2008 08:05:33 +0000 Received: (qmail 28091 invoked from network); 14 Mar 2008 08:05:31 -0000 Received: from unknown (HELO orlando) (pedro@127.0.0.2) by mail.codesourcery.com with ESMTPA; 14 Mar 2008 08:05:31 -0000 From: Pedro Alves Subject: attach& support, and attach "async + sync_execution" support. Date: Fri, 14 Mar 2008 08:05:00 -0000 User-Agent: KMail/1.9.6 (enterprise 0.20070907.709405) MIME-Version: 1.0 To: gdb-patches@sourceware.org Content-Type: Multipart/Mixed; boundary="Boundary-00=_UHj2Ha+i/BBxcpe" Message-Id: <200803140805.40116.pedro@codesourcery.com> Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2008-03/txt/msg00163.txt.bz2 --Boundary-00=_UHj2Ha+i/BBxcpe Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Content-Disposition: inline Content-length: 172 This patch adds support for attach&, and for synchronous attach in sync_execution mode. The linux native async patch I'll post next will support attach&. -- Pedro Alves --Boundary-00=_UHj2Ha+i/BBxcpe Content-Type: text/x-diff; charset="utf-8"; name="attach_async_support.diff" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="attach_async_support.diff" Content-length: 5154 2008-03-14 Pedro Alves * infcmd.c (attach_command_async_continuation): New. (attach_command): Support background async execution, and async execution in synchronous mode. --- gdb/infcmd.c | 122 ++++++++++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 112 insertions(+), 10 deletions(-) Index: src/gdb/infcmd.c =================================================================== --- src.orig/gdb/infcmd.c 2008-03-14 03:58:34.000000000 +0000 +++ src/gdb/infcmd.c 2008-03-14 03:59:37.000000000 +0000 @@ -1852,6 +1852,63 @@ vector_info (char *args, int from_tty) } +static void +attach_command_async_continuation (struct continuation_arg * arg) +{ + char *exec_file; + char *full_exec_path = NULL; + + char *args; + int from_tty; + + args = (char *) arg->data.pointer; + from_tty = arg->next->data.integer; + + stop_soon = NO_STOP_QUIETLY; + + /* If no exec file is yet known, try to determine it from the + process itself. */ + exec_file = (char *) get_exec_file (0); + if (!exec_file) + { + exec_file = target_pid_to_exec_file (PIDGET (inferior_ptid)); + if (exec_file) + { + /* It's possible we don't have a full path, but rather just a + filename. Some targets, such as HP-UX, don't provide the + full path, sigh. + + Attempt to qualify the filename against the source path. + (If that fails, we'll just fall back on the original + filename. Not much more we can do...) + */ + if (!source_full_path_of (exec_file, &full_exec_path)) + full_exec_path = savestring (exec_file, strlen (exec_file)); + + exec_file_attach (full_exec_path, from_tty); + symbol_file_add_main (full_exec_path, from_tty); + } + } + else + { + reopen_exec_file (); + reread_symbols (); + } + + /* Take any necessary post-attaching actions for this platform. */ + target_post_attach (PIDGET (inferior_ptid)); + + post_create_inferior (¤t_target, from_tty); + + /* Install inferior's terminal modes. */ + target_terminal_inferior (); + + normal_stop (); + async_enable_stdin (); + if (deprecated_attach_hook) + deprecated_attach_hook (); +} + /* * TODO: * Should save/restore the tty state since it might be that the @@ -1906,6 +1963,24 @@ attach_command (char *args, int from_tty */ clear_solib (); + if (args) + { + int async_exec = strip_bg_char (&args); + + /* If we get a request for running in the bg but the target + doesn't support it, error out. */ + if (async_exec && !target_can_async_p ()) + error (_("Asynchronous execution not supported on this target.")); + + /* If we don't get a request of running in the bg, then we need + to simulate synchronous (fg) execution. */ + if (!async_exec && target_can_async_p ()) + { + /* Simulate synchronous execution */ + async_disable_stdin (); + } + } + target_attach (args, from_tty); /* Set up the "saved terminal modes" of the inferior @@ -1917,17 +1992,39 @@ attach_command (char *args, int from_tty init_wait_for_inferior (); clear_proceed_status (); - /* No traps are generated when attaching to inferior under Mach 3 - or GNU hurd. */ + if (target_can_async_p () && !sync_execution) + proceed ((CORE_ADDR) -1, TARGET_SIGNAL_0, 0); + else + { + /* No traps are generated when attaching to inferior under Mach 3 + or GNU hurd. */ #ifndef ATTACH_NO_WAIT - /* Careful here. See comments in inferior.h. Basically some OSes - don't ignore SIGSTOPs on continue requests anymore. We need a - way for handle_inferior_event to reset the stop_signal variable - after an attach, and this is what STOP_QUIETLY_NO_SIGSTOP is for. */ - stop_soon = STOP_QUIETLY_NO_SIGSTOP; - wait_for_inferior (0); - stop_soon = NO_STOP_QUIETLY; + /* Careful here. See comments in inferior.h. Basically some OSes + don't ignore SIGSTOPs on continue requests anymore. We need a + way for handle_inferior_event to reset the stop_signal variable + after an attach, and this is what STOP_QUIETLY_NO_SIGSTOP is for. */ + stop_soon = STOP_QUIETLY_NO_SIGSTOP; + + if (target_can_async_p ()) + { + struct continuation_arg *arg1, *arg2, *arg3; + + arg1 = + (struct continuation_arg *) xmalloc (sizeof (struct continuation_arg)); + arg2 = + (struct continuation_arg *) xmalloc (sizeof (struct continuation_arg)); + arg1->next = arg2; + arg2->next = NULL; + arg1->data.pointer = args; + arg2->data.integer = from_tty; + add_continuation (attach_command_async_continuation, arg1); + return; + } + + wait_for_inferior (0); + stop_soon = NO_STOP_QUIETLY; #endif + } /* * If no exec file is yet known, try to determine it from the @@ -1969,7 +2066,12 @@ attach_command (char *args, int from_tty /* Install inferior's terminal modes. */ target_terminal_inferior (); - normal_stop (); + if (target_can_async_p ()) + /* We got here in !sync_execution mode, so there's no stop + reason. */ + ; + else + normal_stop (); if (deprecated_attach_hook) deprecated_attach_hook (); --Boundary-00=_UHj2Ha+i/BBxcpe--