From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 4662 invoked by alias); 8 Nov 2013 17:08:30 -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 4651 invoked by uid 89); 8 Nov 2013 17:08:29 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.5 required=5.0 tests=AWL,BAYES_00,RDNS_NONE,SPF_HELO_PASS autolearn=no version=3.3.2 X-HELO: mx1.redhat.com Received: from Unknown (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 08 Nov 2013 17:08:28 +0000 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id rA8H8L45027452 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Fri, 8 Nov 2013 12:08:21 -0500 Received: from [127.0.0.1] (ovpn01.gateway.prod.ext.ams2.redhat.com [10.39.146.11]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id rA8H8KN3031001; Fri, 8 Nov 2013 12:08:20 -0500 Message-ID: <527D1A84.9040106@redhat.com> Date: Fri, 08 Nov 2013 17:44:00 -0000 From: Pedro Alves User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130625 Thunderbird/17.0.7 MIME-Version: 1.0 To: Tom Tromey CC: gdb-patches@sourceware.org Subject: Re: [PATCH v4 3/9] add target method delegation References: <1382464769-2465-1-git-send-email-tromey@redhat.com> <1382464769-2465-4-git-send-email-tromey@redhat.com> <526E8B54.8040104@redhat.com> <87eh75cmig.fsf@fleche.redhat.com> <87a9htcme3.fsf@fleche.redhat.com> <87habz7q6g.fsf@fleche.redhat.com> In-Reply-To: <87habz7q6g.fsf@fleche.redhat.com> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-SW-Source: 2013-11/txt/msg00246.txt.bz2 On 10/29/2013 08:55 PM, Tom Tromey wrote: > Tom> But looking more closely at the code on the branch, there is an > Tom> assertion in those methods returning something other than void. > > Tom> I'll think about it some more. > > I looked at all the delegation functions today. > > I think it would be fine to make nearly all of them assert. > > The two exceptions are target_delegate_xfer_partial (already does not > assert) and target_delegate_wait (which does assert but which I think > should not). > > In all other cases there is either a de_fault call for the method, or > the dummy target implements the method. The de_fault only applies to current_target. As the delegation always starts at ops->beneath, the de_fault shouldn't ever come into play. So target methods that do the beneath walk either have the choice of having a default in the target method itself, or installing it in the dummy target. Off hand, I don't think there's a real behavioral difference. Looks like the sort of thing that could be normalized. > > target_delegate_wait is a tricky one, as it returns a value. Perhaps > just throwing an exception is best. The current code isn't much of a > guide because it throws the exception when the record target is pushed > -- but as noted in the thread, this is not robust as the target stack > can change even after a target is pushed. So to take that example, if we made dummy_target.to_wait be the current to_wait default, which is to call noprocess(), then it'd be clear that target_delegate_wait shouldn't ever go past the loop, and then it'd be clear that an assertion is appropriate. target_wait would then be: ptid_t target_wait (ptid_t ptid, struct target_waitstatus *status, int options) { struct target_ops *t; ptid_t retval; retval = target_delegate_wait (¤t_traget, ptid, status, options); if (targetdebug) { char *status_string; char *options_string; status_string = target_waitstatus_to_string (status); options_string = target_options_to_string (options); fprintf_unfiltered (gdb_stdlog, "target_wait (%d, status, options={%s})" " = %d, %s\n", ptid_get_pid (ptid), options_string, ptid_get_pid (retval), status_string); xfree (status_string); xfree (options_string); } } WDYT? > > Your comments on this would be much appreciated. > > > Some thoughts the target vector. > > I think the underlying problem here is complex, so it is reasonable if > the model is as well. That is, I think it's fine to combine inheritance > (e.g., the various linux-* vectors) with delegation (the whole stack > itself plus special hacks in record and maybe elsewhere). That in > itself is tractable. > > However, I think the combination of using INHERIT, plus de_fault, plus > the dummy target, plus special wrappers for some target APIs leads to > madness. > > It's much too hard to navigate this. I think we should adopt some > simpler rule. Yes, agreed. That's why I'm trying to see if we can reuse the delegation with the public API. -- Pedro Alves