From patchwork Sun Feb 24 16:51:44 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 31578 Received: (qmail 113967 invoked by alias); 24 Feb 2019 16:52:02 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 113753 invoked by uid 89); 24 Feb 2019 16:52:00 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_HELO_PASS autolearn=ham version=3.3.2 spammy= X-HELO: gateway33.websitewelcome.com Received: from gateway33.websitewelcome.com (HELO gateway33.websitewelcome.com) (192.185.146.85) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sun, 24 Feb 2019 16:51:58 +0000 Received: from cm16.websitewelcome.com (cm16.websitewelcome.com [100.42.49.19]) by gateway33.websitewelcome.com (Postfix) with ESMTP id 8B8FF1D24A6 for ; Sun, 24 Feb 2019 10:51:57 -0600 (CST) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with SMTP id xx0PgWKXz4FKpxx0PgojB2; Sun, 24 Feb 2019 10:51:57 -0600 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Sender:Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=ON6MhQt7Q+kky7dWqDgXjjXV7hVBK2cOxb2rQEKuxFc=; b=xTy15NSc6gs3zKLeA2uqVmlxKz aXl8EUCJha3Vsz4f2xmj+A/5Ur3ozQxdK0S7w4fs0B082dd3TZSGQXTr09ebWCAoGUhySvy2NUnh0 pENzVd/TVOwE8mtah2DHrKmXb; Received: from 75-166-72-210.hlrn.qwest.net ([75.166.72.210]:44502 helo=bapiya.Home) by box5379.bluehost.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.91) (envelope-from ) id 1gxx0P-001AKk-Bt; Sun, 24 Feb 2019 10:51:57 -0600 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [RFC 08/17] Introduce and use flush_streams Date: Sun, 24 Feb 2019 09:51:44 -0700 Message-Id: <20190224165153.5062-9-tom@tromey.com> In-Reply-To: <20190224165153.5062-1-tom@tromey.com> References: <20190224165153.5062-1-tom@tromey.com> Code in common can't call gdb_flush, so this introduces a new "flush_streams" function that must be supplied by the client. Note that the similar gdb_flush_out_err exists, but it isn't defined in quite the same way, so it wasn't clear to me whether the two could be merged. gdb/ChangeLog 2019-02-24 Tom Tromey * utils.c (flush_streams): New function. * event-loop.c (gdb_wait_for_event): Call flush_streams. * common/errors.h (flush_streams): Declare. --- gdb/ChangeLog | 6 ++++++ gdb/common/errors.h | 4 ++++ gdb/event-loop.c | 3 +-- gdb/utils.c | 9 +++++++++ 4 files changed, 20 insertions(+), 2 deletions(-) diff --git a/gdb/common/errors.h b/gdb/common/errors.h index 8dbc6cff5f6..d7738337082 100644 --- a/gdb/common/errors.h +++ b/gdb/common/errors.h @@ -87,4 +87,8 @@ extern void perror_with_name (const char *string) ATTRIBUTE_NORETURN; extern void malloc_failure (long size) ATTRIBUTE_NORETURN; +/* Flush stdout and stderr. Must be provided by the client. */ + +extern void flush_streams (); + #endif /* COMMON_ERRORS_H */ diff --git a/gdb/event-loop.c b/gdb/event-loop.c index caa910c9f82..b9d9e7e098e 100644 --- a/gdb/event-loop.c +++ b/gdb/event-loop.c @@ -727,8 +727,7 @@ gdb_wait_for_event (int block) int num_found = 0; /* Make sure all output is done before getting another event. */ - gdb_flush (gdb_stdout); - gdb_flush (gdb_stderr); + flush_streams (); if (gdb_notifier.num_fds == 0) return -1; diff --git a/gdb/utils.c b/gdb/utils.c index e7fde4942ec..a9aef0031b7 100644 --- a/gdb/utils.c +++ b/gdb/utils.c @@ -730,6 +730,15 @@ malloc_failure (long size) } } +/* See common/errors.h. */ + +void +flush_streams () +{ + gdb_flush (gdb_stdout); + gdb_flush (gdb_stderr); +} + /* My replacement for the read system call. Used like `read' but keeps going if `read' returns too soon. */