From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 100140 invoked by alias); 29 Apr 2015 15:53:03 -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 100095 invoked by uid 89); 29 Apr 2015 15:53:02 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=AWL,BAYES_00,SPF_HELO_PASS,SPF_PASS,T_RP_MATCHES_RCVD autolearn=ham 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; Wed, 29 Apr 2015 15:53:01 +0000 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id t3TFr0en002691 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Wed, 29 Apr 2015 11:53:00 -0400 Received: from [127.0.0.1] (ovpn01.gateway.prod.ext.ams2.redhat.com [10.39.146.11]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t3TFqwsf018109; Wed, 29 Apr 2015 11:52:59 -0400 Message-ID: <5540FE5A.1000005@redhat.com> Date: Wed, 29 Apr 2015 16:12: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: Jan Kratochvil , gdb-patches@sourceware.org CC: Phil Muldoon Subject: Re: [PATCH v3 9/9] compile: compile printf: gdbserver support References: <20150411194322.29128.52477.stgit@host1.jankratochvil.net> <20150411194437.29128.58569.stgit@host1.jankratochvil.net> In-Reply-To: <20150411194437.29128.58569.stgit@host1.jankratochvil.net> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-SW-Source: 2015-04/txt/msg01079.txt.bz2 On 04/11/2015 08:44 PM, Jan Kratochvil wrote: > Hi, > > former patch injects plain: > printf (...); > This patch injects gdbserver-compatible: > f = open_memstream (&s, ...); > fprintf (f, ...); > fclose (f); > return s; (A more expanded explanation would have helped here. The first time I skimmed this, I didn't really understand what this meant.) So the issue here is that calling "printf" in the inferior ends up with output sent to the inferior's stdout. If gdbserver is running on a separate terminal (or machine), then the output of "compile printf" without this patch goes to the inferior's terminal, unlike using "(gdb) printf ...". That's not just an issue for gdbserver, actually. Even with the native target, using "compile printf" without this patch against an inferior that gdb attached to, with "attach PID" (a process that was already running on a separate terminal), or if you use the "set inferior-tty" option, you get the exact same problem. > @@ -233,10 +241,15 @@ add_code_footer (enum compile_i_scope_types type, struct ui_file *buf) > { > switch (type) > { > + case COMPILE_I_PRINTF_SCOPE: > + fputs_unfiltered ("\tif (fclose (__gdb_outf) != 0)\n" > + "\t\treturn NULL;\n" > + "\treturn __gdb_retval;\n", > + buf); > + // FALLTHRU Please use /* */ comments, here and elsewhere. (replying to the other mail) Thanks, Pedro Alves