From patchwork Fri Dec 20 17:49:44 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pedro Alves X-Patchwork-Id: 37036 Received: (qmail 6131 invoked by alias); 20 Dec 2019 17:49:51 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 6119 invoked by uid 89); 20 Dec 2019 17:49:51 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3 autolearn=ham version=3.3.1 spammy=HX-Languages-Length:1685 X-HELO: us-smtp-delivery-1.mimecast.com Received: from us-smtp-2.mimecast.com (HELO us-smtp-delivery-1.mimecast.com) (207.211.31.81) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 20 Dec 2019 17:49:50 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1576864188; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=iMdQiapb860Nt7/vhAiWcIZdWZlcItASDAaVOOVs8mM=; b=XVL1Ogv1ChcC3rKMd57Mrpx68Uo3psBMoMQ8N1KK74+WvNfqpwxCxaCLellczfg63w+U6c Ngn3uVTwR53aTjYve3oZAIebREbGhS4vvvHR34mUgD6fPlnJWpagHwAtMWxlBOQ7GNDHb9 oTo0NJLuMfcE56tPzjtDI6DSOVuKkwU= Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-199-DAC23y1TOLm5dVEo1lPVNA-1; Fri, 20 Dec 2019 12:49:47 -0500 Received: by mail-wm1-f70.google.com with SMTP id n17so2193528wmk.1 for ; Fri, 20 Dec 2019 09:49:47 -0800 (PST) Return-Path: Received: from ?IPv6:2001:8a0:f913:f700:56ee:75ff:fe8d:232b? ([2001:8a0:f913:f700:56ee:75ff:fe8d:232b]) by smtp.gmail.com with ESMTPSA id o4sm10396062wrw.97.2019.12.20.09.49.45 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 20 Dec 2019 09:49:45 -0800 (PST) Subject: Re: [PATCH v2 02/24] Don't rely on inferior_ptid in record_full_wait To: Tom Tromey References: <20191017225026.30496-1-palves@redhat.com> <20191017225026.30496-3-palves@redhat.com> <8736f74pfw.fsf@tromey.com> Cc: gdb-patches@sourceware.org From: Pedro Alves Message-ID: <683ef49e-3485-aa20-62dd-e43e7019ab41@redhat.com> Date: Fri, 20 Dec 2019 17:49:44 +0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.2.1 MIME-Version: 1.0 In-Reply-To: <8736f74pfw.fsf@tromey.com> X-Mimecast-Spam-Score: 0 On 11/1/19 2:54 PM, Tom Tromey wrote: >>>>>> "Pedro" == Pedro Alves writes: > > Pedro> The multi-target patch sets inferior_ptid to null_ptid before handling > Pedro> a target event, and thus before calling target_wait, in order to catch > Pedro> places in target_ops::wait implementations that are incorrectly > Pedro> relying on inferior_ptid (which could otherwise be a ptid of a > Pedro> different target, for example). > > I think it would be good to add a comment before target_ops::wait > explaining what is required from its implementation. If other > target_ops methods also cannot rely on inferior_ptid, then that > documentation should be updated as well. This would make it simpler to > know how to update an existing target, or to write a new target. How does this sound? Thanks, Pedro Alves diff --git i/gdb/target.h w/gdb/target.h index 1bb7276673..14a7d3e61f 100644 --- i/gdb/target.h +++ w/gdb/target.h @@ -478,6 +478,13 @@ struct target_ops TARGET_DEFAULT_NORETURN (noprocess ()); virtual void commit_resume () TARGET_DEFAULT_IGNORE (); + /* See target_wait's description. Note that implementations of + this method must not assume that inferior_ptid on entry is + pointing at the thread or inferior that ends up reporting an + event. The reported event could be for some other thread in + the current inferior or even for a different process of the + current target. inferior_ptid may also be null_ptid on + entry. */ virtual ptid_t wait (ptid_t, struct target_waitstatus *, int TARGET_DEBUG_PRINTER (target_debug_print_options)) TARGET_DEFAULT_FUNC (default_target_wait);