From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 46213 invoked by alias); 21 Mar 2015 15:05:05 -0000 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 Received: (qmail 46204 invoked by uid 89); 21 Mar 2015 15:05:04 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.0 required=5.0 tests=AWL,BAYES_00,SPF_HELO_PASS,SPF_PASS,T_RP_MATCHES_RCVD,UNSUBSCRIBE_BODY autolearn=no version=3.3.2 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Sat, 21 Mar 2015 15:05:03 +0000 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (Postfix) with ESMTPS id C1AEA2F2F98 for ; Sat, 21 Mar 2015 15:05:02 +0000 (UTC) Received: from [127.0.0.1] (ovpn01.gateway.prod.ext.ams2.redhat.com [10.39.146.11]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t2LF50Nj019665; Sat, 21 Mar 2015 11:05:01 -0400 Message-ID: <550D889C.3030900@redhat.com> Date: Sat, 21 Mar 2015 15:05:00 -0000 From: Pedro Alves User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.5.0 MIME-Version: 1.0 To: Cleber Rosa , gdb-patches@sourceware.org CC: areis@redhat.com, Sergio Durigan Junior Subject: Re: [PATCH 0/4] GDBServer: introduce a dedicated stderr stream References: <1426905265-8495-1-git-send-email-crosa@redhat.com> In-Reply-To: <1426905265-8495-1-git-send-email-crosa@redhat.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit X-SW-Source: 2015-03/txt/msg00689.txt.bz2 On 03/21/2015 02:34 AM, Cleber Rosa wrote: > This patch series add command line options and monitor commands that > will redirect all of the gdbserver's own output (always sent to stderr) > to a separate file. This feature makes it possible to distinguish between > the inferior process stderr and gdbserver's own stderr. A specific FILE* is a fragile approach; libraries that gdbserver loads may well print to stdout/stderr or write to file descriptors 1 or 2 directly, for example. If we're doing this, redirection is best done at the lower OS file descriptor layer, not at C-runtime stdio (stdout/stderr) layer, with e.g., dup/dup2. And, gdbserver itself may print to stdout/stderr _before_ the redirection command-line option is processed. Thus it's safer/better to just start gdbserver with its input/output redirected already. Of course, then because new inferiors inherit the input/output from gdbserver, we'd need a way to start the inferior with input/output redirected somewhere instead. When native debugging, we can already do exactly that: we can tell gdb to starts inferior with input/output redirected, using the "set inferior-tty" command. I'd be very desirable to be able to do that with gdbserver as well, in the context of local/remote parity too. That makes it possible to have one single gdbserver start multiple programs on separate ttys, for example. And I think that would cover your use case too. You'd start gdbserver with input/output redirected to a pipe, like you seem to already do (for example), and pass it --inferior-tty=`tty` so that new inferiors start with input/output connected to that tty. What do you think? The code to do this in gdb is in fork-child.c and inflow.c. Ideally we'd share it with gdbserver... Sergio has been on and off working on exactly sharing that code, for startup-with-shell. Thanks, Pedro Alves