From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 22040 invoked by alias); 27 Jun 2008 23:26:12 -0000 Received: (qmail 22030 invoked by uid 22791); 27 Jun 2008 23:26:10 -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, 27 Jun 2008 23:25:36 +0000 Received: (qmail 27062 invoked from network); 27 Jun 2008 23:25:33 -0000 Received: from unknown (HELO orlando.local) (pedro@127.0.0.2) by mail.codesourcery.com with ESMTPA; 27 Jun 2008 23:25:33 -0000 From: Pedro Alves To: gdb-patches@sourceware.org Subject: Re: Get rid of ATTACH_NO_WAIT Date: Sat, 28 Jun 2008 01:00:00 -0000 User-Agent: KMail/1.9.9 References: <200806280018.59156.pedro@codesourcery.com> In-Reply-To: <200806280018.59156.pedro@codesourcery.com> MIME-Version: 1.0 Content-Type: Multipart/Mixed; boundary="Boundary-00=_0bXZI0cnLqopIOR" Message-Id: <200806280025.40155.pedro@codesourcery.com> X-IsSubscribed: yes 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-06/txt/msg00525.txt.bz2 --Boundary-00=_0bXZI0cnLqopIOR Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Content-Disposition: inline Content-length: 645 A Saturday 28 June 2008 00:18:59, Pedro Alves wrote: > Index: src/gdb/remote.c > =================================================================== > --- src.orig/gdb/remote.c > +++ src/gdb/remote.c > @@ -7099,6 +7099,7 @@ Specify the serial device it is connecte > extended_remote_ops.to_mourn_inferior = extended_remote_mourn; > extended_remote_ops.to_detach = extended_remote_detach; > extended_remote_ops.to_attach = extended_remote_attach; > + extended_remote_ops.to_attach_no_wait = 0; > } Ooops, this bit wasn't supposed to go public :-) Updated patch without it. (it is a nop, I was using it for testing) -- Pedro Alves --Boundary-00=_0bXZI0cnLqopIOR Content-Type: text/x-diff; charset="utf-8"; name="attach_no_wait.diff" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="attach_no_wait.diff" Content-length: 7351 2008-06-28 Pedro Alves * config/i386/nm-cygwin.h (ATTACH_NO_WAIT): Delete. * config/i386/nm-i386gnu.h (ATTACH_NO_WAIT): Delete. * target.h (struct target_ops): Add to_attach_no_wait member. (target_attach_no_wait): New. * target.c (update_current_target): Inherit to_attach_no_wait. * infcmd.c: Replace ATTACH_NO_WAIT compile time check by target_attach_no_wait runtime check. * gnu-nat.c (init_gnu_ops): Set to_attach_no_wait in gnu_ops. * win32-nat.c (init_win32_ops): Set to_attach_no_wait in win32_ops. --- gdb/config/i386/nm-cygwin.h | 1 gdb/config/i386/nm-i386gnu.h | 3 -- gdb/gnu-nat.c | 1 gdb/infcmd.c | 60 ++++++++++++++++++++++--------------------- gdb/target.c | 1 gdb/target.h | 8 +++++ gdb/win32-nat.c | 1 7 files changed, 42 insertions(+), 33 deletions(-) Index: src/gdb/config/i386/nm-cygwin.h =================================================================== --- src.orig/gdb/config/i386/nm-cygwin.h 2008-06-28 00:24:00.000000000 +0100 +++ src/gdb/config/i386/nm-cygwin.h 2008-06-28 00:24:06.000000000 +0100 @@ -16,7 +16,6 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ -#define ATTACH_NO_WAIT #define ADD_SHARED_SYMBOL_FILES dll_symbol_command void dll_symbol_command (char *, int); Index: src/gdb/config/i386/nm-i386gnu.h =================================================================== --- src.orig/gdb/config/i386/nm-i386gnu.h 2008-06-28 00:24:00.000000000 +0100 +++ src/gdb/config/i386/nm-i386gnu.h 2008-06-28 00:24:06.000000000 +0100 @@ -26,9 +26,6 @@ extern char *gnu_target_pid_to_str (int pid); -/* Don't do wait_for_inferior on attach. */ -#define ATTACH_NO_WAIT - /* Thread flavors used in re-setting the T bit. */ #define THREAD_STATE_FLAVOR i386_REGS_SEGS_STATE #define THREAD_STATE_SIZE i386_THREAD_STATE_COUNT Index: src/gdb/gnu-nat.c =================================================================== --- src.orig/gdb/gnu-nat.c 2008-06-28 00:24:00.000000000 +0100 +++ src/gdb/gnu-nat.c 2008-06-28 00:24:06.000000000 +0100 @@ -2592,6 +2592,7 @@ init_gnu_ops (void) gnu_ops.to_doc = "GNU Hurd process"; /* to_doc */ gnu_ops.to_open = gnu_open; /* to_open */ gnu_ops.to_attach = gnu_attach; /* to_attach */ + gnu_ops.to_attach_no_wait = 1; /* to_attach_no_wait */ gnu_ops.to_detach = gnu_detach; /* to_detach */ gnu_ops.to_resume = gnu_resume; /* to_resume */ gnu_ops.to_wait = gnu_wait; /* to_wait */ Index: src/gdb/infcmd.c =================================================================== --- src.orig/gdb/infcmd.c 2008-06-28 00:24:01.000000000 +0100 +++ src/gdb/infcmd.c 2008-06-28 00:24:06.000000000 +0100 @@ -2014,38 +2014,40 @@ 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. */ -#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; - - if (target_can_async_p ()) + /* Some system don't generate traps when attaching to inferior. + E.g. Mach 3 or GNU hurd. */ + if (!target_attach_no_wait) { - /* sync_execution mode. Wait for stop. */ - struct continuation_arg *arg1, *arg2, *arg3; + /* 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; - arg1 = - (struct continuation_arg *) xmalloc (sizeof (struct continuation_arg)); - arg2 = - (struct continuation_arg *) xmalloc (sizeof (struct continuation_arg)); - arg3 = - (struct continuation_arg *) xmalloc (sizeof (struct continuation_arg)); - arg1->next = arg2; - arg2->next = arg3; - arg3->next = NULL; - arg1->data.pointer = args; - arg2->data.integer = from_tty; - arg3->data.integer = async_exec; - add_continuation (attach_command_continuation, arg1); - return; - } + if (target_can_async_p ()) + { + /* sync_execution mode. Wait for stop. */ + struct continuation_arg *arg1, *arg2, *arg3; - wait_for_inferior (0); -#endif + arg1 = + (struct continuation_arg *) xmalloc (sizeof (struct continuation_arg)); + arg2 = + (struct continuation_arg *) xmalloc (sizeof (struct continuation_arg)); + arg3 = + (struct continuation_arg *) xmalloc (sizeof (struct continuation_arg)); + arg1->next = arg2; + arg2->next = arg3; + arg3->next = NULL; + arg1->data.pointer = args; + arg2->data.integer = from_tty; + arg3->data.integer = async_exec; + add_continuation (attach_command_continuation, arg1); + return; + } + + wait_for_inferior (0); + } attach_command_post_wait (args, from_tty, async_exec); } Index: src/gdb/target.h =================================================================== --- src.orig/gdb/target.h 2008-06-28 00:24:01.000000000 +0100 +++ src/gdb/target.h 2008-06-28 00:24:06.000000000 +0100 @@ -407,6 +407,7 @@ struct target_ops int to_has_registers; int to_has_execution; int to_has_thread_control; /* control thread execution */ + int to_attach_no_wait; struct section_table *to_sections; struct section_table @@ -559,6 +560,13 @@ void target_close (struct target_ops *ta #define target_attach(args, from_tty) \ (*current_target.to_attach) (args, from_tty) +/* Some targets don't generate traps when attaching to the inferior, + or their target_attach implementation takes care of the waiting. + These targets must set to_attach_no_wait. */ + +#define target_attach_no_wait \ + (current_target.to_attach_no_wait) + /* The target_attach operation places a process under debugger control, and stops the process. Index: src/gdb/win32-nat.c =================================================================== --- src.orig/gdb/win32-nat.c 2008-06-28 00:24:00.000000000 +0100 +++ src/gdb/win32-nat.c 2008-06-28 00:24:06.000000000 +0100 @@ -2080,6 +2080,7 @@ init_win32_ops (void) win32_ops.to_open = win32_open; win32_ops.to_close = win32_close; win32_ops.to_attach = win32_attach; + win32_ops.to_attach_no_wait = 1; win32_ops.to_detach = win32_detach; win32_ops.to_resume = win32_resume; win32_ops.to_wait = win32_wait; Index: src/gdb/target.c =================================================================== --- src.orig/gdb/target.c 2008-06-28 00:24:00.000000000 +0100 +++ src/gdb/target.c 2008-06-28 00:24:06.000000000 +0100 @@ -406,6 +406,7 @@ update_current_target (void) INHERIT (to_close, t); INHERIT (to_attach, t); INHERIT (to_post_attach, t); + INHERIT (to_attach_no_wait, t); INHERIT (to_detach, t); /* Do not inherit to_disconnect. */ INHERIT (to_resume, t); --Boundary-00=_0bXZI0cnLqopIOR--