From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx2.freebsd.org (mx2.freebsd.org [96.47.72.81]) by sourceware.org (Postfix) with ESMTPS id E8EF53858D1E for ; Sat, 9 Sep 2023 16:49:43 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org E8EF53858D1E Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=FreeBSD.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [96.47.72.80]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits)) (Client CN "mx1.freebsd.org", Issuer "R3" (verified OK)) by mx2.freebsd.org (Postfix) with ESMTPS id 4Rjf8k1q22z3McZ; Sat, 9 Sep 2023 16:49:42 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from smtp.freebsd.org (smtp.freebsd.org [96.47.72.83]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "smtp.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Rjf8k13NBz3HmQ; Sat, 9 Sep 2023 16:49:42 +0000 (UTC) (envelope-from jhb@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1694278182; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=X2qIMQ23OPyDoJd/iwFKe6y2cK2r7usRL36kim3wVLI=; b=SO9IGqrGIpOejvKp3Bxd982Or92cRAvXZEIHw+g1EvJZPYYFZSss0qwGpdU0dJ9UdKpjgR gzDvjwE6HZl/UrSgA+38W/t9JCHUTG535rmrXr2h+wdySsVg+FGTDZHgLhEh4+04XB7CVq NuZdt+LXX6n4Oo+U+t1QT7XY4iZmkltjsqOtN/s+NWSqWMmoRbHjZtE7g8pmVjfGpn9Ne5 2TcP9ET4IPJ4fAv0pzkIVsfH/q3zjsLJxS7Vz7Jh2D7ksuSLrg2wtoT+0zSgcku2ZpeGAX TvJehYG08KzjJK5/BQKMDQNgxXfuLQbAoUwYOjzgnt1HJyK8tnZipUwosBMUIg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1694278182; a=rsa-sha256; cv=none; b=UV8F0Aaqkve6Gx5Tp4cYsw4h0fK19Y/y52agcoSCQ0VvLVy02YNSD5TWUVZ6pvzEDvfmPJ wGomZCJVPUpgs3NUTc06mdVDDCzycPGJgW6qVU0hFNKP7nGruAYKQ7RBz0PaiTjXWQIjvN v1KTkwhELcXLqFKksyt5jKXi31oJRd9XC0DpgHenNQM2JnAXjfiwbcnb474t7aA55YNOH8 Z9HhU5IbOzhK6P5r9wrLRE83YYZXv6blS5g6QwmsqaXpHHe5e4LrvhyKMFOqB3E++CVny/ 5bgwQA2JE4ZCBBhe1UiPqAmmVEwv7pmiOb1U1PYZru7Ri1oXHgApHJOEG+wRFw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1694278182; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=X2qIMQ23OPyDoJd/iwFKe6y2cK2r7usRL36kim3wVLI=; b=INVWt8PgziHmfLT5CH/MKPavR0NLFEMB7z60b/Xv96zhoHCdjdozG0agOerjXCtpUuHGmB BrnB57E3Vts/VzXOz1iRsJK32zh/SZp1ylXW1Gi+nEA2EZyHMBJJXl1o4UoucM0slyP2HU Hdd/+46FSFH/+GEcw0ONZ+x9qIr1O2NLX3bbiFv72vQGd0/6MTvnSoNFuk/Ax1+AuZQ6zN 8JFRYCqwmOpV+oDdSLJwNZ/xfNK6eKRU62fPBRTc/UEGPd3z59bYRm5hgFTi2SkK65N/qP D7g1+q7JmlOAAYOa4XpTVihJ+fkITyKDVuap6D13Vb2T1w9oQ2ET+MCxPcf9Qg== Received: from [IPV6:2601:648:8683:a9e0:346e:8e34:11f3:aeb0] (unknown [IPv6:2601:648:8683:a9e0:346e:8e34:11f3:aeb0]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (Client did not present a certificate) (Authenticated sender: jhb) by smtp.freebsd.org (Postfix) with ESMTPSA id 4Rjf8j3Z9kz1BCR; Sat, 9 Sep 2023 16:49:41 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Message-ID: <769d6902-2363-5bbc-3336-03eb85ba95ce@FreeBSD.org> Date: Sat, 9 Sep 2023 09:49:40 -0700 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.15.0 Content-Language: en-US To: Enze Li , gdb-patches@sourceware.org Cc: enze.li@gmx.com References: From: John Baldwin Subject: Re: [PATCH] fbsd-nat: Pacify gcc with no functional changes In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-12.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,KAM_ASCII_DIVIDERS,NICE_REPLY_A,RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL,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: On 9/9/23 6:50 AM, Enze Li wrote: > I see these errors on FreeBSD/aarch64 when using gcc 12 without passing > --disable-werror. > > ===================================================================== > CXX fbsd-nat.o > fbsd-nat.c: In member function 'void fbsd_nat_target::resume_one_process(ptid_t, int, gdb_signal)': > fbsd-nat.c:1208:11: error: unused variable 'request' [-Werror=unused-variable] > 1208 | int request; > | ^~~~~~~ > fbsd-nat.c: In member function 'virtual ptid_t fbsd_nat_target::wait(ptid_t, target_waitstatus*, target_wait_flags)': > fbsd-nat.c:1726:22: error: declaration of 'inf' shadows a previous local [-Werror=shadow=compatible-local] > 1726 | for (inferior *inf : all_non_exited_inferiors (this)) > | ^~~ > fbsd-nat.c:1697:17: note: shadowed declaration is here > 1697 | inferior *inf = find_inferior_ptid (this, wptid); > | ^~~ > fbsd-nat.c: In member function 'virtual void fbsd_nat_target::detach(inferior*, int)': > fbsd-nat.c:2044:18: error: variable 'wptid' set but not used [-Werror=unused-but-set-variable] > 2044 | ptid_t wptid = wait_1 (ptid, &ws, 0); > | ^~~~~ > cc1plus: all warnings being treated as errors > ===================================================================== > > This patch includes the following non-functional changes, > > 1. Remove unused variable "request". > 2. Rename inf to inf_p to avoid shadowed declaration warnings. > 3. Set wptid to null_ptid when USE_SIGTRAP_SIGINFO is not defined. I'm surprised you see this third warning. USE_SIGTRAP_SIGINFO should be on for all modern versions of FreeBSD. In particular, fbsd-nat.h enables it on 11.3 and later. What version of FreeBSD are you building on? From fbsd-nat.h: /* FreeBSD kernels 11.3 and later report valid si_code values for SIGTRAP on all architectures. Older FreeBSD kernels that supported TRAP_BRKPT did not report valid values for MIPS and sparc64. Even older kernels without TRAP_BRKPT support did not report valid values on any architecture. */ #if (__FreeBSD_kernel_version >= 1102502) || (__FreeBSD_version >= 1102502) # define USE_SIGTRAP_SIGINFO > Tested on FreeBSD/aarch64 by rebuilding. > --- > gdb/fbsd-nat.c | 11 ++++++----- > 1 file changed, 6 insertions(+), 5 deletions(-) > > diff --git a/gdb/fbsd-nat.c b/gdb/fbsd-nat.c > index 0ee3bccb5ef..af416557504 100644 > --- a/gdb/fbsd-nat.c > +++ b/gdb/fbsd-nat.c > @@ -1205,8 +1205,6 @@ fbsd_nat_target::resume_one_process (ptid_t ptid, int step, > > for (thread_info *tp : inf->non_exited_threads ()) > { > - int request; > - > /* If ptid is a specific LWP, suspend all other LWPs in the > process, otherwise resume all LWPs in the process.. */ > if (!ptid.lwp_p() || tp->ptid.lwp () == ptid.lwp ()) Thanks. This a leftover from my recent patches, not sure why clang didn't notice. > @@ -1694,9 +1692,9 @@ fbsd_nat_target::wait (ptid_t ptid, struct target_waitstatus *ourstatus, > || ourstatus->kind () == TARGET_WAITKIND_NO_RESUMED) > break; > > - inferior *inf = find_inferior_ptid (this, wptid); > - gdb_assert (inf != nullptr); > - fbsd_inferior *fbsd_inf = get_fbsd_inferior (inf); > + inferior *inf_p = find_inferior_ptid (this, wptid); > + gdb_assert (inf_p != nullptr); > + fbsd_inferior *fbsd_inf = get_fbsd_inferior (inf_p); > gdb_assert (fbsd_inf != nullptr); > gdb_assert (fbsd_inf->resumed_lwps != null_ptid); > gdb_assert (fbsd_inf->running_lwps > 0); I might call this variable `winf` to match the `wptid` vs `ptid` pattern. > @@ -2094,6 +2092,9 @@ fbsd_nat_target::detach (inferior *inf, int from_tty) > } > } > } > +#else > + /* pacify gcc */ > + wptid = null_ptid; Probably the better way to pacify this is to use a (void) cast to mark it as used, e.g. `(void)null_ptid;` > #endif > sig = 0; > break; > > base-commit: 38a984fa440c7686c741b7804eae06a528849aa7 -- John Baldwin