From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 17063 invoked by alias); 29 Aug 2008 07:11:42 -0000 Received: (qmail 17055 invoked by uid 22791); 29 Aug 2008 07:11:41 -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, 29 Aug 2008 07:10:59 +0000 Received: (qmail 8577 invoked from network); 29 Aug 2008 07:10:56 -0000 Received: from unknown (HELO localhost) (vladimir@127.0.0.2) by mail.codesourcery.com with ESMTPA; 29 Aug 2008 07:10:56 -0000 From: Vladimir Prus Date: Fri, 29 Aug 2008 07:11:00 -0000 Subject: [RFA] Make attach_command exception-safe To: gdb-patches@sources.redhat.com X-TUID: 7bd4482315b4bfb3 X-Length: 2168 X-UID: 315 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200808291110.43091.vladimir@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-08/txt/msg00658.txt.bz2 When attach_command executes, it might disable stdin. It further might throw, and does not enable stdin in that case. For CLI case, top-level event loop will catch the exception and enable stdin. For MI case, MI interpreter catches the exception in order to print the error message, and of course it has no idea about any stdin disabling. This patch makes attach_command exception-safe, enabling stdin on throw. OK? - Volodya * infcmd.c (attach_command): Call async_enable_stdin if exception is thrown. --- ChangeLog.csl | 6 ++++++ gdb/infcmd.c | 4 ++++ 2 files changed, 10 insertions(+), 0 deletions(-) diff --git a/ChangeLog.csl b/ChangeLog.csl index 9f4f686..5699492 100644 --- a/ChangeLog.csl +++ b/ChangeLog.csl @@ -1,3 +1,9 @@ +2008-08-28 Vladimir Prus + + Make attach_command exception-safe + * infcmd.c (attach_command): Call async_enable_stdin + if exception is thrown. + 2008-08-19 Pedro Alves * infcmd.c (post_create_inferior_1): If the solist is global, diff --git a/gdb/infcmd.c b/gdb/infcmd.c index feb045a..f0d3a6f 100644 --- a/gdb/infcmd.c +++ b/gdb/infcmd.c @@ -2084,6 +2084,7 @@ attach_command (char *args, int from_tty) char *exec_file; char *full_exec_path = NULL; int async_exec = 0; + struct cleanup *back_to = make_cleanup (null_cleanup, NULL); dont_repeat (); /* Not for the faint of heart */ @@ -2139,6 +2140,7 @@ attach_command (char *args, int from_tty) { /* Simulate synchronous execution */ async_disable_stdin (); + make_cleanup ((make_cleanup_ftype *)async_enable_stdin, NULL); } target_attach (args, from_tty); @@ -2181,6 +2183,7 @@ attach_command (char *args, int from_tty) add_continuation (inferior_thread (), attach_command_continuation, a, attach_command_continuation_free_args); + discard_cleanups (back_to); return; } @@ -2188,6 +2191,7 @@ attach_command (char *args, int from_tty) } attach_command_post_wait (args, from_tty, async_exec); + discard_cleanups (back_to); } /* -- 1.5.3.5