From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr1-f67.google.com (mail-wr1-f67.google.com [209.85.221.67]) by sourceware.org (Postfix) with ESMTPS id 9156A3858D38 for ; Thu, 23 Jul 2020 20:03:17 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 9156A3858D38 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-f67.google.com with SMTP id z18so2741562wrm.12; Thu, 23 Jul 2020 13:03:17 -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=V6UwUsNTJ+afKo12sjOg1rAaq/ikPQ9Lc+qi8vpK++4=; b=Bh9qjUdVX4pyK1f1j5DcfYMP7WbAA+tuDvfK9Jc9Z2E2kdzZzzbB2w9xYno2ZYv0Fj WZhyEuMxIUOKRa13U1r2TaFjIUFeP8HvgrRTqeOA/JMTnuXmYU2b6vHyJrnURnkSN5dI meObbQomNQ5gWu5FpUCLEpprGIZL1r6E6lDSOaw2APKyGlh97pYAwIDpiAJ1YC1Vct+0 kq8i/MBAJQxXydAjaikcLtrSTb5Xxf3xZrXfDJjMraMixdq9jtYSfcHr5orwNBIvfKCk AnWiP5L9pkIzNJYXxtKyqbErLbMCT8XM/iE+M2I+sllMcJOC6QK+7L0R5x+eEZrCzUmQ 70ZQ== X-Gm-Message-State: AOAM530SQUZecHdOU3jP5v/sz1Rf3Ney1puehhH+lyp+rJbSv1FANk6y 2goR5EJMp7fR7FqUwi6j+MHJg3duTZWkPg== X-Google-Smtp-Source: ABdhPJygD/B34HpIMZlyZNKXdI+WzCCFW+8TOC+/UJKfCj7JAoKA8bsD3uF1u8Ah5ZY20L4FKGQKaA== X-Received: by 2002:a5d:4dc2:: with SMTP id f2mr5494611wru.399.1595534596641; Thu, 23 Jul 2020 13:03:16 -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 j5sm4315041wmb.15.2020.07.23.13.03.14 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 23 Jul 2020 13:03:15 -0700 (PDT) Subject: Re: [PATCH 2/4] gdb: move regcache::regcaches to regcache.c To: Simon Marchi , gdb-patches@sourceware.org References: <20200720204101.2849535-1-simon.marchi@efficios.com> <20200720204101.2849535-3-simon.marchi@efficios.com> Cc: Morichetti@sourceware.org, Laurent From: Pedro Alves Message-ID: <09e7d7ca-1af0-f93e-6df5-7ad148c2e134@palves.net> Date: Thu, 23 Jul 2020 21:03:14 +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: <20200720204101.2849535-3-simon.marchi@efficios.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-3.7 required=5.0 tests=BAYES_00, FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, KAM_DMARC_STATUS, 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: Thu, 23 Jul 2020 20:03:19 -0000 On 7/20/20 9:40 PM, Simon Marchi via Gdb-patches wrote: > I don't really understand why `regcache_thread_ptid_changed` is a static > method of `struct regcache` instead of being a static free function in > regcache.c. And I don't understand why `current_regcache` is a static > member of `struct regcache` instead of being a static global in > regcache.c. It's not wrong per-se, but there's no other place where we > do it like this in GDB (as far as I remember) and it just exposes things > unnecessarily in the .h. current_regcache was made a static member of struct regcache in: commit e521e87e8514b9d3497208b70bcd067f132c58ed Author: Yao Qi AuthorDate: Wed May 24 22:15:23 2017 +0100 Move current_regcache to regcache::current_regcache https://sourceware.org/pipermail/gdb-patches/2017-May/140583.html which was needed for: commit b77b02a5ca5a021ee8b5e5453e8843447d1132b2 Author: Yao Qi AuthorDate: Wed May 24 22:15:23 2017 +0100 Add unit test to gdbarch methods register_to_value and value_to_register https://sourceware.org/pipermail/gdb-patches/2017-May/140589.html But then later I redesigned the mocking environment: commit 55b11ddf16b97b9c50ed480bc9da8b3e1c6c4198 Author: Pedro Alves AuthorDate: Wed Oct 4 18:21:09 2017 +0100 Redesign mock environment for gdbarch selftests https://sourceware.org/legacy-ml/gdb-patches/2017-10/msg00022.html ... and that got rid of the need to expose current_regcache. > > Move them to be just static in regcache.c. As a result, > registers_changed_ptid doesn't need to be friend of the regcache class > anymore. > > Removing the include of forward_list in regcache.h showed that we were > missing an include for it in dwarf2/index-write.c, record-btrace.c and > sparc64-tdep.c. > > gdb/ChangeLog: > > * regcache.h (class regcache): Remove friend > registers_changed_ptid. > : Remove. > : Remove. > * regcache.c (regcache::regcaches): Rename to... > (regcaches): ... this. Make static. > (get_thread_arch_aspace_regcache): Update. > (regcache::regcache_thread_ptid_changed): Rename to... > (regcache_thread_ptid_changed): ... this. Update. > (class regcache_access): Remove. > (regcaches_test): Update. > (_initialize_regcache): Update. > * sparc64-tdep.c, dwarf2/index-write.c, record-btrace.c: Include > . > OK. Thanks, Pedro Alves