From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr1-f65.google.com (mail-wr1-f65.google.com [209.85.221.65]) by sourceware.org (Postfix) with ESMTPS id 6E8A43857C5E for ; Wed, 5 Aug 2020 14:50:32 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 6E8A43857C5E Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=palves.net Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=alves.ped@gmail.com Received: by mail-wr1-f65.google.com with SMTP id r4so38006186wrx.9 for ; Wed, 05 Aug 2020 07:50:32 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:cc:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=qTvzFNGNtz6f292ZuxxkeJ3gdOrONE5aamcfsS9Z4bA=; b=JYP0ILqJqK1rTP/Z8HQ591myWSgZC7F2izfm3QeisF+Lk13iLWlDAHfM2qtBNL3Ckf mrqvn6NLSYdEV/LUefzVagC3mujaEtG1J0OPcjRjB1sJso/hDCcVNLwR1T5iGRCevQto OREnf6o/L7zS2tMmRV7v+kSPHZPFhfpl9tDKA9tUfCmyoql2/ycbaNFvoWpx5B7hT975 1GCysZvJ0Y+AemVZZKvTgzU/ps2TjlCVn773p+BCYYalXNzhEQINoND9fItGjg5nCPS8 edBYD67fgYeJ5AMJtDACeid7SCU5qLxIU5zrz4p+h4MXcwRI61cMmP4I9CBmtYAO30G9 356A== X-Gm-Message-State: AOAM532tpVb1BXPcMhlSOgYjiQHGUCwYBJUoYgrOiSG8rZhg1xJiqV8N +rw3ig1lDlUtKAGa9Wt/Bjal8sum32w= X-Google-Smtp-Source: ABdhPJxE4RcBg/LgKZevDNB8DKPF0FBaXXcfq1Aw1WHpe8YMHw6aI6b7aqz424jw3yom2XmHuRm3JQ== X-Received: by 2002:adf:ba83:: with SMTP id p3mr3203403wrg.246.1596639031474; Wed, 05 Aug 2020 07:50:31 -0700 (PDT) Received: from ?IPv6:2001:8a0:f91a:c400:56ee:75ff:fe8d:232b? ([2001:8a0:f91a:c400:56ee:75ff:fe8d:232b]) by smtp.gmail.com with ESMTPSA id w2sm3332797wre.5.2020.08.05.07.50.29 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 05 Aug 2020 07:50:30 -0700 (PDT) Subject: Re: [PATCH 3/4] gdb: pass target to thread_ptid_changed observable To: Simon Marchi , gdb-patches@sourceware.org References: <20200720204101.2849535-1-simon.marchi@efficios.com> <20200720204101.2849535-4-simon.marchi@efficios.com> <6bd06f25-c89b-58b5-3639-94813a7284f5@efficios.com> Cc: Laurent From: Pedro Alves Message-ID: <5e34235b-a256-0255-b268-d929ff2e7a1d@palves.net> Date: Wed, 5 Aug 2020 15:50:29 +0100 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: <6bd06f25-c89b-58b5-3639-94813a7284f5@efficios.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00, FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, KAM_DMARC_STATUS, NICE_REPLY_A, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 05 Aug 2020 14:50:34 -0000 On 7/30/20 4:27 PM, Simon Marchi wrote: > On 2020-07-23 4:42 p.m., Pedro Alves wrote: >>> @@ -1817,6 +1818,58 @@ cooked_write_test (struct gdbarch *gdbarch) >>> } >>> } >>> >>> +/* Verify that when two threads with the same ptid exist (from two different >>> + targets) and one of them changes ptid, we only update the appropriate >>> + regcaches. */ >>> + >>> +static void >>> +regcache_thread_ptid_changed () >>> +{ >>> + /* Any arch will do. */ >>> + gdbarch *arch = current_inferior ()->gdbarch; >>> + >>> + /* Prepare two targets with one thread each, with the same ptid. */ >>> + scoped_mock_context target1 (arch); >>> + scoped_mock_context target2 (arch); >>> + target2.mock_inferior.next = &target1.mock_inferior; >>> + >>> + ptid_t old_ptid (111, 222); >>> + ptid_t new_ptid (111, 333); >>> + >>> + target1.mock_inferior.pid = old_ptid.pid (); >>> + target1.mock_thread.ptid = old_ptid; >>> + target2.mock_inferior.pid = old_ptid.pid (); >>> + target2.mock_thread.ptid = old_ptid; >>> + >>> + gdb_assert (regcaches.empty ()); >> >> This will fail if you debug something, e.g., run to main, >> and then do: >> >> (gdb) maint selftest regcache_thread_ptid_changed > > I don't know, do we really want to support this? I don't really see the point. We can design > the selftests to make it possible, but is there any advantage? In the selftests command, we > could ensure that you are not debugging something, and otherwise error out with "You can't run > selftests while debugging.". I don't see why we shouldn't. Assuming that the regcaches are empty like in the current patch can also fail is someone inserts some test before this new test that ends up filling in the regcache. I see it as your new test being fragile because of that, and running the "maint selftest" while some program is running is just a way to trigger it. To me, not allowing selftests while the program is running is just an admission that the tests aren't well isolated enough.