From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id iaG5C5rQ4mNLnywAWB0awg (envelope-from ) for ; Tue, 07 Feb 2023 17:28:42 -0500 Received: by simark.ca (Postfix, from userid 112) id 22BA41E15D; Tue, 7 Feb 2023 17:28:42 -0500 (EST) Authentication-Results: simark.ca; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.a=rsa-sha256 header.s=default header.b=BdfRujeF; dkim-atps=neutral X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-8.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 Received: from sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 7FEC21E112 for ; Tue, 7 Feb 2023 17:28:41 -0500 (EST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 836F2385840F for ; Tue, 7 Feb 2023 22:28:40 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 836F2385840F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1675808920; bh=vvLmblVKWRRuyLAMIH3laiY5+P/ghQ3qhrzqfIJA/k0=; h=References:To:Cc:Subject:In-reply-to:Date:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=BdfRujeF4XMW++/oOq1gYDDFzc2tVWn5ue8SmhVKfUPA4/UimKRKZzViYl9eXbjJL Z5oiYXUstOQ358ctbk/WwZGv4cuCrJU7A8k4BERfT54VGYyp6YTHb8EHnSV4UG4szs XRgmnSDc6lNx0IY6a/adzkkFVdYPTzSF0ny1IXUg= Received: from mail-ot1-x32c.google.com (mail-ot1-x32c.google.com [IPv6:2607:f8b0:4864:20::32c]) by sourceware.org (Postfix) with ESMTPS id 8EA1B3858D33 for ; Tue, 7 Feb 2023 22:28:20 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 8EA1B3858D33 Received: by mail-ot1-x32c.google.com with SMTP id x26-20020a056830115a00b0068bbc0ee3eeso4711002otq.0 for ; Tue, 07 Feb 2023 14:28:20 -0800 (PST) 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=vvLmblVKWRRuyLAMIH3laiY5+P/ghQ3qhrzqfIJA/k0=; b=unSoNZs6zftSzChw1H4CmE/vMk8FhwAipOONWuAx2SozK9VfrNiV4o/Z9KWEBSri71 GlL2RP/yyw/V/sYKE1xT9iG3jd7s7v7NE5UPlYZMESLrJGsmdPhGenErH32TjbMML8I4 Tei/yjUYfUhWCK2UjQTvXEdVhabiQV3jPW1Cts8r+qx9jeJdOKK9ttGzaT6bxGAJB4j+ 3Bxwag59VThv509/8khNXTmmq05lpTsc1wsVtnGqUamxCglHxNhfB6zilVu1HMV63pLW MM8zyZtFnJd5msQS6KBlAJ8OQGltL6VO/0m5KmLUzjxey7WXh44Q1nt6Uud4FEPCrdya 9Xkw== X-Gm-Message-State: AO0yUKVaDErnxaoTLc3AgIDhHzrx3lW6Og+pRnkbd3VgMQuxx1VdvY6M ckPLVgOcS7hmpEVFhx5J4o3ZTw== X-Google-Smtp-Source: AK7set+9QIZJx1CC0wPwZZv72EJ7lnNMh9t7rgHl8+ehZ1JAHYULnU6D0rS3QrNSAp5xyGQPvLAvkQ== X-Received: by 2002:a9d:4e91:0:b0:68b:ddb1:89a2 with SMTP id v17-20020a9d4e91000000b0068bddb189a2mr2583360otk.32.1675808899854; Tue, 07 Feb 2023 14:28:19 -0800 (PST) Received: from localhost ([2804:14d:7e39:8470:56ca:1532:909:af92]) by smtp.gmail.com with ESMTPSA id z3-20020a05683010c300b0068d542f630fsm7091622oto.76.2023.02.07.14.28.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Feb 2023 14:28:19 -0800 (PST) References: <20230130044518.3322695-1-thiago.bauermann@linaro.org> <20230130044518.3322695-3-thiago.bauermann@linaro.org> User-agent: mu4e 1.8.13; emacs 28.2 To: Pedro Alves Cc: gdb-patches@sourceware.org, Simon Marchi Subject: Re: [PATCH v3 2/8] gdbserver: Add PID parameter to linux_get_auxv and linux_get_hwcap In-reply-to: Date: Tue, 07 Feb 2023 22:28:16 +0000 Message-ID: <87k00t9klb.fsf@linaro.org> MIME-Version: 1.0 Content-Type: text/plain 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: , From: Thiago Jung Bauermann via Gdb-patches Reply-To: Thiago Jung Bauermann Errors-To: gdb-patches-bounces+public-inbox=simark.ca@sourceware.org Sender: "Gdb-patches" Pedro Alves writes: > On 2023-01-30 4:45 a.m., Thiago Jung Bauermann via Gdb-patches wrote: >> This patch doesn't change gdbserver behaviour, > > That's not actually true -- before the patch, we use the lwpid > of the current thread, while after the patch we always use the pid of the > process. Ah, indeed that is true. Thanks for pointing it out. > Here: > >> int >> -linux_process_target::read_auxv (CORE_ADDR offset, unsigned char *myaddr, >> - unsigned int len) >> +linux_process_target::read_auxv (int pid, CORE_ADDR offset, >> + unsigned char *myaddr, unsigned int len) >> { >> char filename[PATH_MAX]; >> int fd, n; >> - int pid = lwpid_of (current_thread); >> >> xsnprintf (filename, sizeof filename, "/proc/%d/auxv", pid); >> > > AFAICT by playing with debugging the gdb.threads/leader-exit.exp program, > you can't read /proc/PID/auxv if the leader thread has exited (is zombie). > > Maybe that ends up not mattering in practice, not sure, but it is a > behavior change. We are talking about this in the other branch of this email thread so I won't respond here, but I'll leave the quote above because I reference it below. >> diff --git a/gdbserver/linux-aarch64-low.cc b/gdbserver/linux-aarch64-low.cc >> index 3c09e086afee..2ed6e95562c5 100644 >> --- a/gdbserver/linux-aarch64-low.cc >> +++ b/gdbserver/linux-aarch64-low.cc >> @@ -846,12 +846,13 @@ aarch64_target::low_arch_setup () >> if (is_elf64) >> { >> struct aarch64_features features; >> + int pid = current_thread->id.pid (); > > You can also write: > > current_process ()->pid > > which is a more to the point. Also, sometimes there's a current > process, but not a current thread, so when we don't actually need a thread, > current_process() is better. In the case of the spots changed by this patch, we know that current_thread is always set because, as can be seen in the first code hunk you quoted, before this patch was applied linux_process_target::read_auxv dereferenced it. But I agree that it makes more sense to use current_process (). I'll post a new patch with the change. -- Thiago