From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 92178 invoked by alias); 28 Apr 2017 13:20:37 -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 92155 invoked by uid 89); 28 Apr 2017 13:20:36 -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,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=ham version=3.3.2 spammy=totally, blown, suspect, wish X-HELO: mail-wm0-f53.google.com Received: from mail-wm0-f53.google.com (HELO mail-wm0-f53.google.com) (74.125.82.53) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 28 Apr 2017 13:20:35 +0000 Received: by mail-wm0-f53.google.com with SMTP id w64so42178111wma.0 for ; Fri, 28 Apr 2017 06:20:37 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version:content-transfer-encoding; bh=ZVsqf3ycHtxqzTyUtzdSz64zBGw7BX+OJ9KaOJz6yZs=; b=KZoCKAb2aFULJdGW4xbnlFUWlaXTnSr2g2W6g3ko+5gMpulJ8p2ouzz3zAFUXxLWdc ERTkfcCqrinA6C4rBwoOCWH7e3d7grLpNxW2sQruh2Buh56qpJCRn0ENtIL/Wnv+Rkfr 4Zwt2b90EWup34e3vbKBL6IykNq8p9RHMVLNzYW4qHjdsm4IwmnWvjEWbjZ+Rb/ncaLM ZhTpHOd8lVmX+3rlqm1lGxp5XxG56PQ7t/zb970MPt5LAwwE3IBwM+3HLXudMrVvni5X RaNaX+4FNcN7FroATG7eT9/lSMxzSuv2GgjNod2beWKX8zW1PIUJDqwtbMmXIgEoVjg1 OOJg== X-Gm-Message-State: AN3rC/5wCZoJO+JVBY/D82bKXU5WB4S1zZOdugNKsofLHY9hlAmYA2vx QZrvN45ufGROiw== X-Received: by 10.28.32.196 with SMTP id g187mr5367271wmg.127.1493385635539; Fri, 28 Apr 2017 06:20:35 -0700 (PDT) Received: from E107787-LIN ([194.214.185.158]) by smtp.gmail.com with ESMTPSA id h80sm6644859wmd.7.2017.04.28.06.20.34 (version=TLS1_2 cipher=AES128-SHA bits=128/128); Fri, 28 Apr 2017 06:20:35 -0700 (PDT) From: Yao Qi To: Pedro Alves Cc: gdb-patches@sourceware.org Subject: Re: [PATCH 5/6] Use copy ctor in regcache_dup References: <1493152106-3246-1-git-send-email-yao.qi@linaro.org> <1493152106-3246-6-git-send-email-yao.qi@linaro.org> <86shksc2xb.fsf@gmail.com> Date: Fri, 28 Apr 2017 13:20:00 -0000 In-Reply-To: (Pedro Alves's message of "Fri, 28 Apr 2017 10:50:56 +0100") Message-ID: <86lgqkbrdt.fsf@gmail.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-IsSubscribed: yes X-SW-Source: 2017-04/txt/msg00769.txt.bz2 Pedro Alves writes: > I think that that's too incomplete to evaluate. :-) > > Why regcache on top of readonly_regcache and not the other > way around? Off hand, I'd think that=20 > > struct regcache_base; > struct readonly_regcache : regcache_base {}; > struct regcache : regcache_base {}; > > would be the "obvious" first choice. I have to agree, design like this affects other parts a lot though. > > What happens to all the "regcache->readonly_p" checks in > spread around in multiple functions? Do they disappear? I wish they will. =20=20 > I think that if the design ends up with that flag still present=20 > and functions exposing interfaces that work with > a "struct regcache *" that can either be readonly > or write-through, then it's likely that the design > isn't complete. [But replacing a single boolean > checked in a few select places by virtual methods and a > full blown vtable and a bunch of dispatching makes me > cringe a bit too. :-) But OTOH, I suspect you want > to add virtual methods for unit testing.] I get your point and let me see how far can I go. Yes, I need to make some regcache methods virtual for unit tests, so far I only need to make raw_write and ~regcache virtual. > > I'm totally not against this direction, to be clear, > but it'd still suggest adding the tag dispatch ctor > first (the simple version with no factory, just adds two > lines of code compared to the copy ctor version), which > allows getting rid of the heap allocation and the cleanups > as you're doing in patch #6, and then consider changing > the hierarchy in a follow up patch. No problem, I'll replace my copy ctor with your tag dispatch ctor. --=20 Yao (=E9=BD=90=E5=B0=A7)