From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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 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-x32c.google.com with SMTP id x26-20020a056830115a00b0068bbc0ee3eeso4711002otq.0 for ; Tue, 07 Feb 2023 14:28:20 -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=vvLmblVKWRRuyLAMIH3laiY5+P/ghQ3qhrzqfIJA/k0=; b=vyRtlCTlDzJp43qKxksC33zeuI92z9H1lT3WudLCXqDYkUXz9a5CVTHvApDR9zvkkb 9PR6uzGbAVl3sevEnEp8by9HC6/4X7VvcXT0WoujF9CgS5bXhnDnFQrXRtDy+u5rqqlv szg9UUL4+USUO2gHAb2QV4bokVK+Umi0e4Fr8qVWkdQUnz/e5v9PNWtpB29Ud3hxMIcc Mw1EZaZnpJM2y8oJQBEYsRRbF6c4sOq41gSz52reIXwVAYHp4ZDmJ+8FpHD33vuRZji2 /db0iQQZfcbCixK9SCAFq5pLbOAQKissBMM0bvOEciJK/2N+PEPizsQg6XVvxC9FzSeV ysvw== 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 From: Thiago Jung Bauermann 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-Spam-Status: No, score=-11.3 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,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: 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