From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 15303 invoked by alias); 26 Apr 2015 09:33:26 -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 15293 invoked by uid 89); 26 Apr 2015 09:33:25 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.3 required=5.0 tests=AWL,BAYES_00,KAM_LAZY_DOMAIN_SECURITY,SPF_HELO_PASS,T_RP_MATCHES_RCVD 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; Sun, 26 Apr 2015 09:33:24 +0000 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id t3Q9XMQW023078 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Sun, 26 Apr 2015 05:33:23 -0400 Received: from host1.jankratochvil.net (ovpn-116-27.ams2.redhat.com [10.36.116.27]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t3Q9XJ0T019236 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Sun, 26 Apr 2015 05:33:21 -0400 Date: Sun, 26 Apr 2015 09:33:00 -0000 From: Jan Kratochvil To: gdb-patches@sourceware.org Cc: Phil Muldoon Subject: Re: [PATCH v3 9/9] compile: compile printf: gdbserver support Message-ID: <20150426093318.GA6765@host1.jankratochvil.net> References: <20150411194322.29128.52477.stgit@host1.jankratochvil.net> <20150411194437.29128.58569.stgit@host1.jankratochvil.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20150411194437.29128.58569.stgit@host1.jankratochvil.net> User-Agent: Mutt/1.5.23 (2014-03-12) X-IsSubscribed: yes X-SW-Source: 2015-04/txt/msg00971.txt.bz2 On Sat, 11 Apr 2015 21:44:37 +0200, Jan Kratochvil wrote: > former patch injects plain: > printf (...); > This patch injects gdbserver-compatible: > f = open_memstream (&s, ...); > fprintf (f, ...); > fclose (f); > return s; I have realized this print+printf patchset introduces calling inferior implicit malloc() + explicit free() (by free_inferior_memory) which the original 'compile code' series avoided (using gdbarch_infcall_mmap() instead). The goal was not to crash the inferior futher with print commands when analyzing corrupted inferior memory lists. I somehow expected that printf()/fprintf() are so heavyweight they will call malloc() on their own so this mmap goal is no longer achievable for printf. But I have found now glibc in most real world cases uses just alloca(). The problem is even calling fmemopen() instead of open_memstream() still implicitly calls malloc() - for fmemopen_cookie_t and for FILE. The only idea I have is to redirect by a breakpoint glibc's implicit calls to malloc() into GDB's allocator by inferior mmap. But that seems a bit ugly. So currently keeping it as a known bug. Jan