From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-ot1-x32b.google.com (mail-ot1-x32b.google.com [IPv6:2607:f8b0:4864:20::32b]) by sourceware.org (Postfix) with ESMTPS id 871513857C51 for ; Tue, 29 Nov 2022 03:10:40 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 871513857C51 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=linaro.org Received: by mail-ot1-x32b.google.com with SMTP id w26-20020a056830061a00b0066c320f5b49so8283232oti.5 for ; Mon, 28 Nov 2022 19:10:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:message-id:date:in-reply-to:subject:cc:to:from :user-agent:references:from:to:cc:subject:date:message-id:reply-to; bh=i2X5/WXkedoXfk6Jgn0LHhL19cNoW/nTZd8q/GTzSLQ=; b=iOdqSjhqmjixDp2K+rmyL5cGib6SaS7RzvNDlYo+HXtJGM1LBd+KGOJd/7eHvVT1P6 vkvaDnpqHqS1QP8jbDzgStWfIMjWCnPV9yt9ZzmMGorNuGyDa2A8nLEr6FSdYsIShR2u 3A1RWQnGV0SyYLEKv0C/gKAt9ky9GiihEDZtGkrBCJy/vAVPLmJG2Y70aUjFLuRmeCwC CWASI/SzVqX1WHf1uD9ZqQFC2tFRyp3zwWeGZ4a7Oq5XJ/x1D/C4kJinZucvI/WWovdD Wrc4mjjErUGIczxBmDBd1EQpuQ63FvG++dOXx3m65urYbZz+82rtmRyrdjm5EafPynlZ o0NQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=mime-version:message-id:date:in-reply-to:subject:cc:to:from :user-agent:references:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=i2X5/WXkedoXfk6Jgn0LHhL19cNoW/nTZd8q/GTzSLQ=; b=Qd3EfO2x3k+BG0CgN2K5pzVsFrxVpgtI88kMs0qeGCD2e7kApw+L6xEOdp4MFbkkse br0MPgpZGyKYpGGvVp3rFhbESSqD6wSfv+aljxxIuGedw6No/psi4iVl3kBqTSRl6G63 XEcJx12p98andOS8dhEmhbTbA/CMs10KTIUo7MI8CmdqRqU531tzn2PdeYl+yEE0jro0 uwcQR0b7FASs43DSB2eduQWCjfIGpsTUvdpxfOlulDf7Tyoa3INe8P4QzVaS5rhNZg5U LDf0XRpk6mCrx8oJN11wI8k5CohsYPb7lLpP5b8F8ZtpHNtkp7wO51NO9IvcTP2VCpyC iLvA== X-Gm-Message-State: ANoB5pnFADjtf5VWhYPEdgMNkJseKHX0ErkH1ZU3ngi5WEc9XI3FDd1k /pxxDpxnWvAgU8DPA2GrwLxbUpSuB3bIlw== X-Google-Smtp-Source: AA0mqf6G+CVrWkw+fkobAj18dz0TJYwPNTBtPtaSsBGc3/vHUE3GeM5hGVrk4RZqJuBx/4Si60fuHw== X-Received: by 2002:a9d:61d3:0:b0:66e:4c3:548a with SMTP id h19-20020a9d61d3000000b0066e04c3548amr18065192otk.288.1669691439866; Mon, 28 Nov 2022 19:10:39 -0800 (PST) Received: from localhost ([2804:14d:7e39:8470:201c:ea26:41ce:5eb]) by smtp.gmail.com with ESMTPSA id s19-20020a056870ea9300b00132784a3a1fsm6795162oap.46.2022.11.28.19.10.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Nov 2022 19:10:39 -0800 (PST) References: <20221126020452.1686509-1-thiago.bauermann@linaro.org> <20221126020452.1686509-3-thiago.bauermann@linaro.org> <5309bed5-3145-0763-150d-75cad9ef4e44@arm.com> User-agent: mu4e 1.8.11; emacs 28.2 From: Thiago Jung Bauermann To: Simon Marchi Cc: Luis Machado , gdb-patches@sourceware.org Subject: Re: [PATCH v2 2/6] gdbserver: Add PID parameter to linux_get_auxv and linux_get_hwcap In-reply-to: Date: Tue, 29 Nov 2022 03:10:36 +0000 Message-ID: <8735a2ihg3.fsf@linaro.org> MIME-Version: 1.0 Content-Type: text/plain X-Spam-Status: No, score=-4.9 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: Simon Marchi writes: > On 11/28/22 06:50, Luis Machado via Gdb-patches wrote: >> Hi, >> >> On 11/26/22 02:04, Thiago Jung Bauermann wrote: >>> This patch doesn't change gdbserver behaviour, but after later changes are >>> made it avoids a null pointer dereference when HWCAP needs to be obtained >>> for a specific process while current_thread is nullptr. >>> >>> Fixing linux_read_auxv, linux_get_hwcap and linux_get_hwcap2 to take a PID >>> parameter seems more correct than setting current_thread in one particular >>> code path. >> >> I'm wondering if passing the pid is needed at all in gdbserver for the purposes of >> fetching the hwcap entries from auxv. >> >> While current thread can be nullptr, I suppose current_process will never be nullptr if >> we have a valid inferior. And the auxv entries are per-process rather than per-thread. >> >> There is a bit of a corner case when we have extended-remote without a live process and >> we need to fetch the hwcap bits to determine a particular feature to report via >> qSupported. But I suppose this is not what this change is trying to address, is it? >> >> If not, it may be the case that we don't need these changes, and we can just use >> current_process. > > Even if we could just use current_process, this patch is going in the > general direction I like, which is to reduce referring to the global > state everywhere, try to fetch it only at the entry points and then pass > the necessary context down by parameters. Thanks. As I looked into how to fix the problem I ran into, I thought this was a nice cleanup that would solve my problem and couldn't resist doing it. :-) -- Thiago