From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 16192 invoked by alias); 29 Jun 2017 11:31:54 -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 16177 invoked by uid 89); 29 Jun 2017 11:31:53 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RP_MATCHES_RCVD,SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=Hx-languages-length:2205 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 ESMTP; Thu, 29 Jun 2017 11:31:52 +0000 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 2054D73B3C; Thu, 29 Jun 2017 11:31:51 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 2054D73B3C Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=palves@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 2054D73B3C Received: from [127.0.0.1] (ovpn04.gateway.prod.ext.ams2.redhat.com [10.39.146.4]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6FF6F89C9A; Thu, 29 Jun 2017 11:31:50 +0000 (UTC) Subject: Re: [PATCH 11/25] Use VEC for target_desc.reg_defs To: Yao Qi References: <1497256916-4958-1-git-send-email-yao.qi@linaro.org> <1497256916-4958-12-git-send-email-yao.qi@linaro.org> <297988f7-dffe-d922-0fcc-7b8c867c6c53@redhat.com> <86zicrcavm.fsf@gmail.com> Cc: gdb-patches@sourceware.org From: Pedro Alves Message-ID: <456b5fdb-891e-0195-2068-fc21fe6a0974@redhat.com> Date: Thu, 29 Jun 2017 11:31:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.4.0 MIME-Version: 1.0 In-Reply-To: <86zicrcavm.fsf@gmail.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-SW-Source: 2017-06/txt/msg00788.txt.bz2 On 06/29/2017 12:05 PM, Yao Qi wrote: > Pedro Alves writes: > >> Can you say more about the choice of VEC? It feels >> like new uses should come with a rationale for why it'd >> be preferred over std::vector. >> >> I'm guessing that it's because the gdb side uses VEC too? >> Or is it something else? (I can guess other reasons, but >> the point is that we shouldn't have to guess.) > > Yes, GDB target description uses VEC, so I chose VEC for GDBserver > target description too. OK. > >> >> [Note that the IPA avoids calling the inferior's malloc during >> normal operation, to avoid deadlocking the inferior. >> This is initialization code, so it's not covered by the exact >> same level of concern, even though one of the original goals was >> to also be able to inject the IPA into a running inferior (e.g., by >> calling dlopen via gdb). That does work (or at least used to), >> but it's a little unsafe because the IPA initialization code >> already calls malloc and other non-async-signal-safe functions. > > Such usage is documented, at least, > https://sourceware.org/gdb/onlinedocs/gdb/Server.html Yeah. We also call "malloc" in the inferior (value_allocate_space_in_inferior) for coercing arrays, etc. to the inferior ('print "hello"', etc.) which suffers from the same problem. I'm often surprised how we don't hear more bug reports about that. > >> I guess std::vector would make it possible to use a custom >> allocator in the IPA that would allocate memory with mmap >> directly (or we'd make the IPA's xmalloc allocate with mmap, >> and then the allocator would use xmalloc).] > > Do you suggest that we need to use std::vector plus a customized > allocator which uses mmap? No, not now, at least. At first I thought that using VEC instead of static arrays would be the introducing the problem of using malloc in the initialization path. Then while writing a review in that direction I looked at the code and realized/remembered that it's not really a new problem. But I chose to dump my thoughts on how that might be fixable in the future as a parenthesis. I don't mean to go fix that now. Thanks, Pedro Alves